Skip to content

Commit 6e69bed

Browse files
author
Álvaro Velad Galván
authored
feat: Support frequent updates during streaming (#3483)
Close: #3332
1 parent f9c289e commit 6e69bed

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

demo/common/message_ids.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ shakaDemo.MessageIds = {
235235
TRICK_PLAY_CONTROLS_WARNING: 'DEMO_TRICK_PLAY_CONTROLS_WARNING',
236236
UI_LOCALE: 'DEMO_UI_LOCALE',
237237
UPDATE_EXPIRATION_TIME: 'DEMO_UPDATE_EXPIRATION_TIME',
238+
UPDATE_INTERVAL_SECONDS: 'DEMO_UPDATE_INTERVAL_SECONDS',
238239
USE_NATIVE_HLS_SAFARI: 'DEMO_USE_NATIVE_HLS_SAFARI',
239240
USE_PERSISTENT_LICENSES: 'DEMO_USE_PERSISTENT_LICENSES',
240241
VIDEO_ROBUSTNESS: 'DEMO_VIDEO_ROBUSTNESS',

demo/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ shakaDemo.Config = class {
359359
.addBoolInput_(MessageIds.FORCE_HTTPS,
360360
'streaming.forceHTTPS')
361361
.addBoolInput_(MessageIds.PREFER_NATIVE_HLS,
362-
'streaming.preferNativeHls');
362+
'streaming.preferNativeHls')
363+
.addNumberInput_(MessageIds.UPDATE_INTERVAL_SECONDS,
364+
'streaming.updateIntervalSeconds',
365+
/* canBeDecimal= */ true);
363366

364367
if (!shakaDemoMain.getNativeControlsEnabled()) {
365368
this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT,

demo/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
"DEMO_UNSUPPORTED_NO_LICENSE_SUPPORT": "Your browser does not support offline licenses for the required key systems.",
209209
"DEMO_UNSUPPORTED_NO_OFFLINE": "Your browser does not support offline storage.",
210210
"DEMO_UPDATE_EXPIRATION_TIME": "Update expiration time",
211+
"DEMO_UPDATE_INTERVAL_SECONDS": "Update interval seconds",
211212
"DEMO_UPLYNK": "Verizon Digital Media Services",
212213
"DEMO_USE_FULL_SEGMENTS_FOR_START_TIME": "Use Full Segments For Start Time",
213214
"DEMO_USE_NATIVE_HLS_SAFARI": "Use native HLS on Safari",

demo/locales/source.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,10 @@
839839
"description": "The name of a configuration value.",
840840
"message": "Update expiration time"
841841
},
842+
"DEMO_UPDATE_INTERVAL_SECONDS": {
843+
"description": "The name of a configuration value.",
844+
"message": "Update interval seconds"
845+
},
842846
"DEMO_UPLYNK": {
843847
"description": "Text that describes an asset that comes from the Verizon Digital Media Services asset library.",
844848
"message": "[PROPER_NAME:Verizon Digital Media Services]"

externs/shaka/player.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ shaka.extern.ManifestConfiguration;
789789
* lowLatencyMode: boolean,
790790
* autoLowLatencyMode: boolean,
791791
* forceHTTPS: boolean,
792-
* preferNativeHls: boolean
792+
* preferNativeHls: boolean,
793+
* updateIntervalSeconds: number
793794
* }}
794795
*
795796
* @description
@@ -896,6 +897,8 @@ shaka.extern.ManifestConfiguration;
896897
* If true, if the protocol is HTTP change it to HTTPs.
897898
* @property {boolean} preferNativeHls
898899
* If true, prefer native HLS playback when possible, regardless of platform.
900+
* @property {number} updateIntervalSeconds
901+
* The minimum number of seconds to see if the manifest has changes.
899902
*
900903
* @exportDoc
901904
*/

lib/media/streaming_engine.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,10 @@ shaka.media.StreamingEngine = class {
10011001
if (bufferedAhead >= scaledBufferingGoal) {
10021002
shaka.log.v2(logPrefix, 'buffering goal met');
10031003

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

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

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

10531053
const p = this.fetchAndAppend_(mediaState, presentationTime, reference);

lib/util/player_configuration.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ shaka.util.PlayerConfiguration = class {
162162
autoLowLatencyMode: false,
163163
forceHTTPS: false,
164164
preferNativeHls: false,
165+
updateIntervalSeconds: 1,
165166
};
166167

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

0 commit comments

Comments
 (0)