From ef00170de31828ce0ace7c392c69fb3791d697f6 Mon Sep 17 00:00:00 2001 From: dsilhavy Date: Wed, 8 Sep 2021 14:35:55 +0200 Subject: [PATCH] Feature enable low latency (#3684) Enable low latency streaming automatically if availabilityTimeComplete is set to false --- index.d.ts | 1 + samples/dash-if-reference-player/app/main.js | 40 ++++++++++++------- .../dash-if-reference-player/app/sources.json | 7 +--- samples/dash-if-reference-player/index.html | 8 +++- src/core/Settings.js | 15 ++++--- src/dash/SegmentBaseLoader.js | 6 --- src/dash/WebmSegmentBaseLoader.js | 3 -- .../controllers/RepresentationController.js | 19 ++++++--- src/streaming/FragmentLoader.js | 1 - src/streaming/ManifestLoader.js | 1 - src/streaming/XlinkLoader.js | 1 - .../controllers/PlaybackController.js | 25 ++++++++++++ src/streaming/net/HTTPLoader.js | 3 +- src/streaming/net/URLLoader.js | 1 - test/unit/streaming.net.HTTPLoader.js | 38 +++++++++++++++--- 15 files changed, 117 insertions(+), 52 deletions(-) diff --git a/index.d.ts b/index.d.ts index f0d572cdb2..f2a288bacd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -152,6 +152,7 @@ declare namespace dashjs { abandonLoadTimeout?: number, wallclockTimeUpdateInterval?: number, lowLatencyEnabled?: boolean, + lowLatencyEnabledByManifest?: boolean, manifestUpdateRetryInterval?: number, cacheInitSegments?: boolean, eventControllerRefreshDelay?: number, diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 647dfcaada..c0ca7b7422 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -682,8 +682,16 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.togglelowLatencyMode = function () { $scope.player.updateSettings({ - 'streaming': { - 'lowLatencyEnabled': $scope.lowLatencyModeSelected + streaming: { + lowLatencyEnabled: $scope.lowLatencyModeSelected + } + }); + }; + + $scope.toggleLowLatencyByManifestMode = function () { + $scope.player.updateSettings({ + streaming: { + lowLatencyEnabledByManifest: $scope.lowLatencyEnabledByManifest } }); }; @@ -776,16 +784,17 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } var config = { - 'streaming': { - 'buffer': { - 'stableBufferTime': $scope.defaultStableBufferDelay, - 'bufferTimeAtTopQuality': $scope.defaultBufferTimeAtTopQuality, - 'bufferTimeAtTopQualityLongForm': $scope.defaultBufferTimeAtTopQualityLongForm, + streaming: { + buffer: { + stableBufferTime: $scope.defaultStableBufferDelay, + bufferTimeAtTopQuality: $scope.defaultBufferTimeAtTopQuality, + bufferTimeAtTopQualityLongForm: $scope.defaultBufferTimeAtTopQualityLongForm, }, - 'delay': { - 'liveDelay': $scope.defaultLiveDelay + delay: { + liveDelay: $scope.defaultLiveDelay }, - 'lowLatencyEnabled': $scope.lowLatencyModeSelected, + lowLatencyEnabled: $scope.lowLatencyModeSelected, + lowLatencyEnabledByManifest: $scope.lowLatencyEnabledByManifest, abr: {}, cmcd: {} } @@ -1008,7 +1017,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' protectionData[input.drmKeySystem]['httpRequestHeaders'] = input.httpRequestHeaders; } } else { - alert("Kid and Key must be specified!"); + alert('Kid and Key must be specified!'); } } else { @@ -1018,15 +1027,15 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' // Check if DRM-Priorisation is enabled if (this.prioritiesEnabled) { protectionData[input.drmKeySystem] = { - "serverURL": input.licenseServerUrl, - "priority": parseInt(input.priority) + 'serverURL': input.licenseServerUrl, + 'priority': parseInt(input.priority) } if (!angular.equals(input.httpRequestHeaders, {})) protectionData[input.drmKeySystem]['httpRequestHeaders'] = input.httpRequestHeaders; } else { protectionData[input.drmKeySystem] = { - "serverURL": input.licenseServerUrl, + 'serverURL': input.licenseServerUrl, } } @@ -1052,7 +1061,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } } else { - console.log(input.licenseServerUrl, "is not a valid url!") + console.log(input.licenseServerUrl, 'is not a valid url!') } } @@ -1535,6 +1544,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.defaultBufferTimeAtTopQuality = currentConfig.streaming.buffer.bufferTimeAtTopQuality; $scope.defaultBufferTimeAtTopQualityLongForm = currentConfig.streaming.buffer.bufferTimeAtTopQualityLongForm; $scope.lowLatencyModeSelected = currentConfig.streaming.lowLatencyEnabled; + $scope.lowLatencyEnabledByManifest = currentConfig.streaming.lowLatencyEnabledByManifest; $scope.liveCatchupEnabled = currentConfig.streaming.liveCatchup.enabled; } diff --git a/samples/dash-if-reference-player/app/sources.json b/samples/dash-if-reference-player/app/sources.json index b2f9aea7ef..7880d28a9e 100644 --- a/samples/dash-if-reference-player/app/sources.json +++ b/samples/dash-if-reference-player/app/sources.json @@ -285,8 +285,8 @@ "url": "https://akamaibroadcasteruseast.akamaized.net/cmaf/live/657078/akasource/out.mpd", "name": "Akamai Low Latency Stream (Single Rate)", "bufferConfig": { - "lowLatencyMode": true, - "liveDelay": 3 + "liveDelay": 3, + "lowLatencyMode": true }, "provider": "akamai" }, @@ -294,7 +294,6 @@ "url": "https://cmafref.akamaized.net/cmaf/live-ull/2006350/akambr/out.mpd", "name": "Akamai Low Latency Stream (Multi Rate)", "bufferConfig": { - "lowLatencyMode": true, "liveDelay": 3 }, "provider": "akamai" @@ -303,7 +302,6 @@ "url": "https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest300.mpd", "name": "Low Latency (Single-Rate) (livesim-chunked)", "bufferConfig": { - "lowLatencyMode": true, "liveDelay": 4 }, "provider": "dashif" @@ -312,7 +310,6 @@ "url": "https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest.mpd", "name": "Low Latency (Multi-Rate) (livesim-chunked)", "bufferConfig": { - "lowLatencyMode": true, "liveDelay": 4 }, "provider": "dashif" diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 953f0ccc29..d6f0d7dceb 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -187,7 +187,13 @@ title="Enable low latency mode"> - Low Latency Mode + Low latency mode + +