From cf3e1e333721166228735a5fa628a1f4554b3d03 Mon Sep 17 00:00:00 2001 From: Benjamin Wallberg <31063750+bwallbergBonnier@users.noreply.github.com> Date: Mon, 22 Jan 2018 18:31:22 +0100 Subject: [PATCH] Change so that default presentation delay for DASH is configurable (#1235) It is useful to have the default presentation delay configurable when the stream provider isn't able to add `suggestedPresentationDelay` in the manifest Fixes #1234 --- AUTHORS | 1 + CONTRIBUTORS | 1 + externs/shaka/player.js | 6 +++++- lib/dash/dash_parser.js | 19 +++++-------------- lib/player.js | 3 ++- .../dash_parser_content_protection_unit.js | 3 ++- test/dash/dash_parser_live_unit.js | 3 ++- test/hls/hls_live_unit.js | 3 ++- test/hls/hls_parser_unit.js | 3 ++- test/test/util/dash_parser_util.js | 3 ++- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8a5702c5dc..3d02f83be7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -14,6 +14,7 @@ # Please keep the list sorted. AdsWizz <*@adswizz.com> +Bonnier Broadcasting <*@bonnierbroadcasting.com> Bryan Huh Esteban Dosztal Google Inc. <*@google.com> diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 78a81bc5cf..ca819d95bc 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,6 +24,7 @@ Aaron Vaage Andy Hochhaus +Benjamin Wallberg Bryan Huh Chad Assareh Chris Fillmore diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 226768865b..2b1940bd43 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -490,7 +490,8 @@ shakaExtern.DrmConfiguration; * customScheme: shakaExtern.DashContentProtectionCallback, * clockSyncUri: string, * ignoreDrmInfo: boolean, - * xlinkFailGracefully: boolean + * xlinkFailGracefully: boolean, + * defaultPresentationDelay: number * }} * * @property {shakaExtern.DashContentProtectionCallback} customScheme @@ -510,6 +511,9 @@ shakaExtern.DrmConfiguration; * existing contents. If false, xlink-related errors will be propagated * to the application and will result in a playback failure. Defaults to * false if not provided. + * @property {number} defaultPresentationDelay + * A default presentationDelay if suggestedPresentationDelay is missing + * in the MPEG DASH manifest, has to be bigger than minBufferTime * 1.5. * * @exportDoc */ diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index bd80c95565..4da9992f62 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -96,15 +96,6 @@ shaka.dash.DashParser = function() { shaka.dash.DashParser.MIN_UPDATE_PERIOD_ = 3; -/** - * The default MPD@suggestedPresentationDelay in seconds. - * - * @private - * @const {number} - */ -shaka.dash.DashParser.DEFAULT_SUGGESTED_PRESENTATION_DELAY_ = 10; - - /** * @typedef { * !function(!Array., ?number, ?number):!Promise. @@ -495,12 +486,12 @@ shaka.dash.DashParser.prototype.processManifest_ = // available, and anything less than minBufferTime will cause buffering // issues. // - // We have decided that our default will be 1.5 * minBufferTime, or 10s, - // whichever is larger. This is fairly conservative. Content providers - // should provide a suggestedPresentationDelay whenever possible to optimize - // the live streaming experience. + // We have decided that our default will be 1.5 * minBufferTime, + // or 10s (configurable) whichever is larger. This is fairly conservative. + // Content providers should provide a suggestedPresentationDelay + // whenever possible to optimize the live streaming experience. var defaultPresentationDelay = Math.max( - shaka.dash.DashParser.DEFAULT_SUGGESTED_PRESENTATION_DELAY_, + this.config_.dash.defaultPresentationDelay, minBufferTime * 1.5); var presentationDelay = suggestedPresentationDelay != null ? suggestedPresentationDelay : defaultPresentationDelay; diff --git a/lib/player.js b/lib/player.js index b322574562..397d750f14 100644 --- a/lib/player.js +++ b/lib/player.js @@ -2016,7 +2016,8 @@ shaka.Player.prototype.defaultConfig_ = function() { }, clockSyncUri: '', ignoreDrmInfo: false, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }, streaming: { diff --git a/test/dash/dash_parser_content_protection_unit.js b/test/dash/dash_parser_content_protection_unit.js index c7a2a0d994..3973c05895 100644 --- a/test/dash/dash_parser_content_protection_unit.js +++ b/test/dash/dash_parser_content_protection_unit.js @@ -44,7 +44,8 @@ describe('DashParser ContentProtection', function() { clockSyncUri: '', customScheme: callback, ignoreDrmInfo: ignoreDrmInfo, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }); var playerEvents = { diff --git a/test/dash/dash_parser_live_unit.js b/test/dash/dash_parser_live_unit.js index 6b9ba75656..0bff480dc8 100644 --- a/test/dash/dash_parser_live_unit.js +++ b/test/dash/dash_parser_live_unit.js @@ -54,7 +54,8 @@ describe('DashParser Live', function() { clockSyncUri: '', customScheme: function(node) { return null; }, ignoreDrmInfo: false, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }); playerInterface = { diff --git a/test/hls/hls_live_unit.js b/test/hls/hls_live_unit.js index 89bebdcadc..ce9b6eca4b 100644 --- a/test/hls/hls_live_unit.js +++ b/test/hls/hls_live_unit.js @@ -127,7 +127,8 @@ describe('HlsParser live', function() { customScheme: function(node) { return null; }, clockSyncUri: '', ignoreDrmInfo: false, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }; diff --git a/test/hls/hls_parser_unit.js b/test/hls/hls_parser_unit.js index 959a6344f5..3df71e2a8b 100644 --- a/test/hls/hls_parser_unit.js +++ b/test/hls/hls_parser_unit.js @@ -93,7 +93,8 @@ describe('HlsParser', function() { customScheme: function(node) { return null; }, clockSyncUri: '', ignoreDrmInfo: false, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }; diff --git a/test/test/util/dash_parser_util.js b/test/test/util/dash_parser_util.js index 26afaa952b..6bb0f7aaf5 100644 --- a/test/test/util/dash_parser_util.js +++ b/test/test/util/dash_parser_util.js @@ -31,7 +31,8 @@ shaka.test.Dash.makeDashParser = function() { customScheme: function(node) { return null; }, clockSyncUri: '', ignoreDrmInfo: false, - xlinkFailGracefully: false + xlinkFailGracefully: false, + defaultPresentationDelay: 10 } }); return parser;