Skip to content

Commit

Permalink
feat(DASH): update period as part of configuration (#6419)
Browse files Browse the repository at this point in the history
Closes #6418
  • Loading branch information
Iragne committed Apr 9, 2024
1 parent 07a3241 commit bdabddc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 3 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ shakaDemo.Config = class {
.addBoolInput_('Enable DASH sequence mode',
'manifest.dash.sequenceMode')
.addBoolInput_('Use stream once in period flattening',
'manifest.dash.useStreamOnceInPeriodFlattening');
'manifest.dash.useStreamOnceInPeriodFlattening')
.addNumberInput_('override the Update period of dash manifest',
'manifest.dash.updatePeriod');
}

/** @private */
Expand Down
9 changes: 8 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ shaka.extern.xml.Node;
* sequenceMode: boolean,
* enableAudioGroups: boolean,
* multiTypeVariantsAllowed: boolean,
* useStreamOnceInPeriodFlattening: boolean
* useStreamOnceInPeriodFlattening: boolean,
* updatePeriod: number
* }}
*
* @property {string} clockSyncUri
Expand Down Expand Up @@ -970,6 +971,12 @@ shaka.extern.xml.Node;
* but may raise issues if manifest does not have stream consistency
* between periods.
* Defaults to <code>false</code>.
* @property {number} updatePeriod
* Override the minimumUpdatePeriod of the manifest. The value is in second
* 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 <code>-1</code>.
* @exportDoc
*/
shaka.extern.DashManifestConfiguration;
Expand Down
24 changes: 21 additions & 3 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ shaka.dash.DashParser = class {
configure(config) {
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;
this.config_ = config;

if (needFireUpdate && this.manifest_ &&
this.manifest_.presentationTimeline.isLive()) {
this.updateNow_();
}
if (this.contentSteeringManager_) {
this.contentSteeringManager_.configure(this.config_);
}
Expand Down Expand Up @@ -1689,6 +1694,15 @@ shaka.dash.DashParser = class {
this.setUpdateTimer_(updateDelay);
}

/**
* Update now the manifest
*
* @private
*/
updateNow_() {
this.updateTimer_.tickNow();
}

/**
* Sets the update timer. Does nothing if the manifest does not specify an
* update period.
Expand All @@ -1705,9 +1719,13 @@ shaka.dash.DashParser = class {
if (this.updatePeriod_ < 0) {
return;
}
let updateTime = this.updatePeriod_;
if (this.config_.dash.updatePeriod >= 0) {
updateTime = this.config_.dash.updatePeriod;
}

const finalDelay = Math.max(
this.updatePeriod_ - offset,
updateTime - offset,
this.averageUpdateDuration_.getEstimate());

// We do not run the timer as repeating because part of update is async and
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ shaka.util.PlayerConfiguration = class {
enableAudioGroups: false,
multiTypeVariantsAllowed,
useStreamOnceInPeriodFlattening: false,
updatePeriod: -1,
},
hls: {
ignoreTextStreamFailures: false,
Expand Down

0 comments on commit bdabddc

Please sign in to comment.