Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Frequent Manifest Updates #3483

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ shakaDemo.MessageIds = {
TRICK_PLAY_CONTROLS_WARNING: 'DEMO_TRICK_PLAY_CONTROLS_WARNING',
UI_LOCALE: 'DEMO_UI_LOCALE',
UPDATE_EXPIRATION_TIME: 'DEMO_UPDATE_EXPIRATION_TIME',
UPDATE_INTERVAL_SECONDS: 'DEMO_UPDATE_INTERVAL_SECONDS',
USE_NATIVE_HLS_SAFARI: 'DEMO_USE_NATIVE_HLS_SAFARI',
USE_PERSISTENT_LICENSES: 'DEMO_USE_PERSISTENT_LICENSES',
VIDEO_ROBUSTNESS: 'DEMO_VIDEO_ROBUSTNESS',
Expand Down
5 changes: 4 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ shakaDemo.Config = class {
.addBoolInput_(MessageIds.FORCE_HTTPS,
'streaming.forceHTTPS')
.addBoolInput_(MessageIds.PREFER_NATIVE_HLS,
'streaming.preferNativeHls');
'streaming.preferNativeHls')
.addNumberInput_(MessageIds.UPDATE_INTERVAL_SECONDS,
'streaming.updateIntervalSeconds',
/* canBeDecimal= */ true);

if (!shakaDemoMain.getNativeControlsEnabled()) {
this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT,
Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"DEMO_UNSUPPORTED_NO_LICENSE_SUPPORT": "Your browser does not support offline licenses for the required key systems.",
"DEMO_UNSUPPORTED_NO_OFFLINE": "Your browser does not support offline storage.",
"DEMO_UPDATE_EXPIRATION_TIME": "Update expiration time",
"DEMO_UPDATE_INTERVAL_SECONDS": "Update interval seconds",
"DEMO_UPLYNK": "Verizon Digital Media Services",
"DEMO_USE_FULL_SEGMENTS_FOR_START_TIME": "Use Full Segments For Start Time",
"DEMO_USE_NATIVE_HLS_SAFARI": "Use native HLS on Safari",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,10 @@
"description": "The name of a configuration value.",
"message": "Update expiration time"
},
"DEMO_UPDATE_INTERVAL_SECONDS": {
"description": "The name of a configuration value.",
"message": "Update interval seconds"
},
"DEMO_UPLYNK": {
"description": "Text that describes an asset that comes from the Verizon Digital Media Services asset library.",
"message": "[PROPER_NAME:Verizon Digital Media Services]"
Expand Down
5 changes: 4 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,8 @@ shaka.extern.ManifestConfiguration;
* lowLatencyMode: boolean,
* autoLowLatencyMode: boolean,
* forceHTTPS: boolean,
* preferNativeHls: boolean
* preferNativeHls: boolean,
* updateIntervalSeconds: number
* }}
*
* @description
Expand Down Expand Up @@ -896,6 +897,8 @@ shaka.extern.ManifestConfiguration;
* If true, if the protocol is HTTP change it to HTTPs.
* @property {boolean} preferNativeHls
* If true, prefer native HLS playback when possible, regardless of platform.
* @property {number} updateIntervalSeconds
* The minimum number of seconds to see if the manifest has changes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but you're really making me wonder if we should have an event instead. The manifest parser could send an event (through the player, to keep streaming decoupled) any time it updates. It might be a little weird with the updateEvery() method we use for SegmentTemplate+duration, but once we have a mechanism for closing SegmentIndexes that we aren't using (thanks, @michellezhuogg!), that event would only fire once per media type (audio + video + maybe text).

*
* @exportDoc
*/
Expand Down
12 changes: 6 additions & 6 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,10 +1001,10 @@ shaka.media.StreamingEngine = class {
if (bufferedAhead >= scaledBufferingGoal) {
shaka.log.v2(logPrefix, 'buffering goal met');

// Do not try to predict the next update. Just poll twice every second.
// The playback rate can change at any time, so any prediction we make now
// could be terribly invalid soon.
return 0.5;
// Do not try to predict the next update. Just poll according to
// configuration (seconds). The playback rate can change at any time, so
// any prediction we make now could be terribly invalid soon.
return this.config_.updateIntervalSeconds / 2;
}

const bufferEnd =
Expand All @@ -1016,7 +1016,7 @@ shaka.media.StreamingEngine = class {
// In any case just try again... if the manifest is incomplete or is not
// being updated then we'll idle forever; otherwise, we'll end up getting
// a SegmentReference eventually.
return 1;
return this.config_.updateIntervalSeconds;
}

// Do not let any one stream get far ahead of any other.
Expand Down Expand Up @@ -1047,7 +1047,7 @@ shaka.media.StreamingEngine = class {
// For example, let video buffering catch up to audio buffering before
// fetching another audio segment.
shaka.log.v2(logPrefix, 'waiting for other streams to buffer');
return 1;
return this.config_.updateIntervalSeconds;
}

const p = this.fetchAndAppend_(mediaState, presentationTime, reference);
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 @@ -162,6 +162,7 @@ shaka.util.PlayerConfiguration = class {
autoLowLatencyMode: false,
forceHTTPS: false,
preferNativeHls: false,
updateIntervalSeconds: 1,
};

// Some browsers will stop earlier than others before a gap (e.g., Edge
Expand Down