Skip to content

Commit

Permalink
feat: Simplify updatePeriod config (#7980)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jan 29, 2025
1 parent 195fd2b commit 7fa6cde
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 33 deletions.
8 changes: 3 additions & 5 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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');
}
Expand Down
35 changes: 17 additions & 18 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,6 @@ shaka.extern.xml.Node;
* sequenceMode: boolean,
* multiTypeVariantsAllowed: boolean,
* useStreamOnceInPeriodFlattening: boolean,
* updatePeriod: number,
* enableFastSwitching: boolean
* }}
*
Expand Down Expand Up @@ -1190,13 +1189,6 @@ shaka.extern.xml.Node;
* between periods.
* <br>
* Defaults to <code>false</code>.
* @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.
* <br>
* Defaults to <code>-1</code>.
* @property {boolean} enableFastSwitching
* If false, disables fast switching track recognition.
* <br>
Expand All @@ -1220,7 +1212,6 @@ shaka.extern.DashManifestConfiguration;
* disableCodecGuessing: boolean,
* disableClosedCaptionsDetection: boolean,
* allowLowLatencyByteRangeOptimization: boolean,
* updatePeriod: number,
* allowRangeRequestsToGuessMimeType: boolean
* }}
*
Expand Down Expand Up @@ -1307,14 +1298,6 @@ shaka.extern.DashManifestConfiguration;
* https://www.akamai.com/blog/performance/-using-ll-hls-with-byte-range-addressing-to-achieve-interoperabi
* <br>
* Defaults to <code>true</code>.
* @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.
* <br>
* Defaults to <code>-1</code>.
* @property {boolean} allowRangeRequestsToGuessMimeType
* If set to true, the HLS parser will use range request (only first byte) to
* guess the mime type.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1437,6 +1421,21 @@ shaka.extern.MssManifestConfiguration;
* If true, ignores supplemental codecs.
* <br>
* Defaults to <code>false</code>.
* @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.
* <br>
* 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.
* <br>
* Defaults to <code>-1</code>.
* @exportDoc
*/
shaka.extern.ManifestConfiguration;
Expand Down
8 changes: 4 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
3 changes: 1 addition & 2 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ shaka.util.PlayerConfiguration = class {
raiseFatalErrorOnManifestUpdateRequestFailure: false,
continueLoadingWhenPaused: true,
ignoreSupplementalCodecs: false,
updatePeriod: -1,
dash: {
clockSyncUri: '',
ignoreDrmInfo: false,
Expand Down Expand Up @@ -161,7 +162,6 @@ shaka.util.PlayerConfiguration = class {
sequenceMode: false,
multiTypeVariantsAllowed,
useStreamOnceInPeriodFlattening: false,
updatePeriod: -1,
enableFastSwitching: true,
},
hls: {
Expand All @@ -178,7 +178,6 @@ shaka.util.PlayerConfiguration = class {
ignoreManifestTimestampsInSegmentsMode: false,
disableCodecGuessing: false,
disableClosedCaptionsDetection: false,
updatePeriod: -1,
allowLowLatencyByteRangeOptimization: true,
allowRangeRequestsToGuessMimeType: false,
},
Expand Down

0 comments on commit 7fa6cde

Please sign in to comment.