From 244a2c128d06b53121a994ba170775eed77af264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 29 Jan 2025 16:00:49 +0100 Subject: [PATCH] feat: Simplify updatePeriod config --- demo/config.js | 8 +++----- externs/shaka/player.js | 35 ++++++++++++++++---------------- lib/dash/dash_parser.js | 8 ++++---- lib/hls/hls_parser.js | 8 ++++---- lib/player.js | 22 ++++++++++++++++++++ lib/util/player_configuration.js | 3 +-- 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/demo/config.js b/demo/config.js index f6e23c5cab..76ce7ce2aa 100644 --- a/demo/config.js +++ b/demo/config.js @@ -225,7 +225,9 @@ shakaDemo.Config = class { .addBoolInput_('Continue loading when paused', 'manifest.continueLoadingWhenPaused') .addBoolInput_('Ignore supplemental codecs', - 'manifest.ignoreSupplementalCodecs'); + 'manifest.ignoreSupplementalCodecs') + .addNumberInput_('Override the Update time of the manifest', + 'manifest.updatePeriod'); } /** @private */ @@ -259,8 +261,6 @@ shakaDemo.Config = class { 'manifest.dash.sequenceMode') .addBoolInput_('Use stream once in period flattening', 'manifest.dash.useStreamOnceInPeriodFlattening') - .addNumberInput_('override the Update period of dash manifest', - 'manifest.dash.updatePeriod') .addBoolInput_('Enable fast switching', 'manifest.dash.enableFastSwitching'); } @@ -290,8 +290,6 @@ shakaDemo.Config = class { 'manifest.hls.disableClosedCaptionsDetection') .addBoolInput_('Allow LL-HLS byterange optimization', 'manifest.hls.allowLowLatencyByteRangeOptimization') - .addNumberInput_('override the Update time of the manifest', - 'manifest.hls.updatePeriod') .addBoolInput_('Allow range request to guess mime type', 'manifest.hls.allowRangeRequestsToGuessMimeType'); } diff --git a/externs/shaka/player.js b/externs/shaka/player.js index eff6748ba7..d374886b5e 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -1095,7 +1095,6 @@ shaka.extern.xml.Node; * sequenceMode: boolean, * multiTypeVariantsAllowed: boolean, * useStreamOnceInPeriodFlattening: boolean, - * updatePeriod: number, * enableFastSwitching: boolean * }} * @@ -1190,13 +1189,6 @@ shaka.extern.xml.Node; * between periods. *
* Defaults to false. - * @property {number} updatePeriod - * Override the minimumUpdatePeriod of the manifest. The value is in seconds. - * If the value is greater than the minimumUpdatePeriod, it will update the - * manifest less frequently. If you update the value during for a dynamic - * manifest, it will directly trigger a new download of the manifest. - *
- * Defaults to -1. * @property {boolean} enableFastSwitching * If false, disables fast switching track recognition. *
@@ -1220,7 +1212,6 @@ shaka.extern.DashManifestConfiguration; * disableCodecGuessing: boolean, * disableClosedCaptionsDetection: boolean, * allowLowLatencyByteRangeOptimization: boolean, - * updatePeriod: number, * allowRangeRequestsToGuessMimeType: boolean * }} * @@ -1307,14 +1298,6 @@ shaka.extern.DashManifestConfiguration; * https://www.akamai.com/blog/performance/-using-ll-hls-with-byte-range-addressing-to-achieve-interoperabi *
* Defaults to true. - * @property {number} updatePeriod - * Override the update period of the playlist. The value is in seconds. - * If the value is less than 0, the period will be determined based on the - * segment length. If the value is greater than 0, it will update the target - * duration. If you update the value during the live, it will directly - * trigger a new download of the manifest. - *
- * Defaults to -1. * @property {boolean} allowRangeRequestsToGuessMimeType * If set to true, the HLS parser will use range request (only first byte) to * guess the mime type. @@ -1371,7 +1354,8 @@ shaka.extern.MssManifestConfiguration; * mss: shaka.extern.MssManifestConfiguration, * raiseFatalErrorOnManifestUpdateRequestFailure: boolean, * continueLoadingWhenPaused: boolean, - * ignoreSupplementalCodecs: boolean + * ignoreSupplementalCodecs: boolean, + * updatePeriod: number * }} * * @property {shaka.extern.RetryParameters} retryParameters @@ -1437,6 +1421,21 @@ shaka.extern.MssManifestConfiguration; * If true, ignores supplemental codecs. *
* Defaults to false. + * @property {number} updatePeriod + * For DASH: + * Override the minimumUpdatePeriod of the manifest. The value is in seconds. + * If the value is greater than the minimumUpdatePeriod, it will update the + * manifest less frequently. If you update the value during for a dynamic + * manifest, it will directly trigger a new download of the manifest. + *
+ * For HLS: + * Override the update period of the playlist. The value is in seconds. + * If the value is less than 0, the period will be determined based on the + * segment length. If the value is greater than 0, it will update the target + * duration. If you update the value during the live, it will directly + * trigger a new download of the manifest. + *
+ * Defaults to -1. * @exportDoc */ shaka.extern.ManifestConfiguration; diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index fcdba10f3d..5773eb7ff4 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -207,8 +207,8 @@ shaka.dash.DashParser = class { goog.asserts.assert(config.dash != null, 'DashManifestConfiguration should not be null!'); const needFireUpdate = this.playerInterface_ && - config.dash.updatePeriod != this.config_.dash.updatePeriod && - config.dash.updatePeriod >= 0; + config.updatePeriod != this.config_.updatePeriod && + config.updatePeriod >= 0; this.config_ = config; if (isPreloadFn) { this.isPreloadFn_ = isPreloadFn; @@ -2539,8 +2539,8 @@ shaka.dash.DashParser = class { return; } let updateTime = this.updatePeriod_; - if (this.config_.dash.updatePeriod >= 0) { - updateTime = this.config_.dash.updatePeriod; + if (this.config_.updatePeriod >= 0) { + updateTime = this.config_.updatePeriod; } const finalDelay = Math.max( diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index ed32565b35..f7d74e3d28 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -300,8 +300,8 @@ shaka.hls.HlsParser = class { */ configure(config, isPreloadFn) { const needFireUpdate = this.playerInterface_ && - config.hls.updatePeriod != this.config_.hls.updatePeriod && - config.hls.updatePeriod >= 0; + config.updatePeriod != this.config_.updatePeriod && + config.updatePeriod >= 0; this.config_ = config; if (isPreloadFn) { this.isPreloadFn_ = isPreloadFn; @@ -4636,8 +4636,8 @@ shaka.hls.HlsParser = class { if (this.isLive_()) { const updateDuration = (endTime - startTime) / 1000.0; this.averageUpdateDuration_.sample(1, updateDuration); - const delay = this.config_.hls.updatePeriod > 0 ? - this.config_.hls.updatePeriod : this.getUpdatePlaylistDelay_(); + const delay = this.config_.updatePeriod > 0 ? + this.config_.updatePeriod : this.getUpdatePlaylistDelay_(); const finalDelay = Math.max(0, delay - this.averageUpdateDuration_.getEstimate()); this.updatePlaylistTimer_.tickAfter(/* seconds= */ finalDelay); diff --git a/lib/player.js b/lib/player.js index 04d7626c4f..fb1c8cd3c5 100644 --- a/lib/player.js +++ b/lib/player.js @@ -4093,6 +4093,28 @@ shaka.Player = class extends shaka.util.FakeEventTarget { delete config['manifest']['hls']['ignoreSupplementalCodecs']; } + // Deprecate 'manifest.dash.updatePeriod' configuration. + if (config['manifest'] && config['manifest']['dash'] && + 'updatePeriod' in config['manifest']['dash']) { + shaka.Deprecate.deprecateFeature(5, + 'manifest.dash.updatePeriod configuration', + 'Please Use manifest.updatePeriod instead.'); + config['manifest']['updatePeriod'] = + config['manifest']['dash']['updatePeriod']; + delete config['manifest']['dash']['updatePeriod']; + } + + // Deprecate 'manifest.hls.updatePeriod' configuration. + if (config['manifest'] && config['manifest']['hls'] && + 'updatePeriod' in config['manifest']['hls']) { + shaka.Deprecate.deprecateFeature(5, + 'manifest.hls.updatePeriod configuration', + 'Please Use manifest.updatePeriod instead.'); + config['manifest']['updatePeriod'] = + config['manifest']['hls']['updatePeriod']; + delete config['manifest']['hls']['updatePeriod']; + } + // Deprecate AdvancedDrmConfiguration's videoRobustness and audioRobustness // as a string. It's now an array of strings. if (config['drm'] && config['drm']['advanced']) { diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index d6522b3cf6..2fb617362e 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -127,6 +127,7 @@ shaka.util.PlayerConfiguration = class { raiseFatalErrorOnManifestUpdateRequestFailure: false, continueLoadingWhenPaused: true, ignoreSupplementalCodecs: false, + updatePeriod: -1, dash: { clockSyncUri: '', ignoreDrmInfo: false, @@ -161,7 +162,6 @@ shaka.util.PlayerConfiguration = class { sequenceMode: false, multiTypeVariantsAllowed, useStreamOnceInPeriodFlattening: false, - updatePeriod: -1, enableFastSwitching: true, }, hls: { @@ -178,7 +178,6 @@ shaka.util.PlayerConfiguration = class { ignoreManifestTimestampsInSegmentsMode: false, disableCodecGuessing: false, disableClosedCaptionsDetection: false, - updatePeriod: -1, allowLowLatencyByteRangeOptimization: true, allowRangeRequestsToGuessMimeType: false, },