Skip to content

Commit

Permalink
feat: Add config to set live stream duration to Infinity (#6207)
Browse files Browse the repository at this point in the history
Fixes: #6205
  • Loading branch information
Vasanthavanan-Devarajan authored Feb 20, 2024
1 parent 4a0d1ca commit de2957e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,9 @@ shakaDemo.Config = class {
/* canBeDecimal= */ true)
.addNumberInput_('VOD Dynamic Playback Rate Buffer Ratio',
'streaming.vodDynamicPlaybackRateBufferRatio',
/* canBeDecimal= */ true);


/* canBeDecimal= */ true)
.addBoolInput_('Infinite Live Stream Duration',
'streaming.infiniteLiveStreamDuration');
if (!shakaDemoMain.getNativeControlsEnabled()) {
this.addBoolInput_('Always Stream Text', 'streaming.alwaysStreamText');
} else {
Expand Down
7 changes: 6 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,8 @@ shaka.extern.ManifestConfiguration;
* minTimeBetweenRecoveries: number,
* vodDynamicPlaybackRate: boolean,
* vodDynamicPlaybackRateLowBufferRate: number,
* vodDynamicPlaybackRateBufferRatio: number
* vodDynamicPlaybackRateBufferRatio: number,
* infiniteLiveStreamDuration: boolean
* }}
*
* @description
Expand Down Expand Up @@ -1357,6 +1358,10 @@ shaka.extern.ManifestConfiguration;
* setting the playback rate to
* <code>vodDynamicPlaybackRateLowBufferRate</code>.
* Defaults to <code>0.5</code>.
* @property {boolean} infiniteLiveStreamDuration
* If <code>true</code>, the media source live duration
* set as a<code>Infinity</code>
* Defaults to <code> false </code>.
* @exportDoc
*/
shaka.extern.StreamingConfiguration;
Expand Down
6 changes: 5 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,13 @@ shaka.media.StreamingEngine = class {
if (duration < Infinity) {
this.playerInterface_.mediaSourceEngine.setDuration(duration);
} else {
// To set the media source live duration as Infinity
// If infiniteLiveStreamDuration as true
const duration =
this.config_.infiniteLiveStreamDuration ? Infinity : Math.pow(2, 32);
// Not all platforms support infinite durations, so set a finite duration
// so we can append segments and so the user agent can seek.
this.playerInterface_.mediaSourceEngine.setDuration(Math.pow(2, 32));
this.playerInterface_.mediaSourceEngine.setDuration(duration);
}
}

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 @@ -239,6 +239,7 @@ shaka.util.PlayerConfiguration = class {
vodDynamicPlaybackRate: false,
vodDynamicPlaybackRateLowBufferRate: 0.95,
vodDynamicPlaybackRateBufferRatio: 0.5,
infiniteLiveStreamDuration: false,
};

// WebOS, Tizen, Chromecast and Hisense have long hardware pipelines
Expand Down

0 comments on commit de2957e

Please sign in to comment.