Skip to content

Commit 7fa6cde

Browse files
authored
feat: Simplify updatePeriod config (#7980)
1 parent 195fd2b commit 7fa6cde

File tree

6 files changed

+51
-33
lines changed

6 files changed

+51
-33
lines changed

demo/config.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ shakaDemo.Config = class {
225225
.addBoolInput_('Continue loading when paused',
226226
'manifest.continueLoadingWhenPaused')
227227
.addBoolInput_('Ignore supplemental codecs',
228-
'manifest.ignoreSupplementalCodecs');
228+
'manifest.ignoreSupplementalCodecs')
229+
.addNumberInput_('Override the Update time of the manifest',
230+
'manifest.updatePeriod');
229231
}
230232

231233
/** @private */
@@ -259,8 +261,6 @@ shakaDemo.Config = class {
259261
'manifest.dash.sequenceMode')
260262
.addBoolInput_('Use stream once in period flattening',
261263
'manifest.dash.useStreamOnceInPeriodFlattening')
262-
.addNumberInput_('override the Update period of dash manifest',
263-
'manifest.dash.updatePeriod')
264264
.addBoolInput_('Enable fast switching',
265265
'manifest.dash.enableFastSwitching');
266266
}
@@ -290,8 +290,6 @@ shakaDemo.Config = class {
290290
'manifest.hls.disableClosedCaptionsDetection')
291291
.addBoolInput_('Allow LL-HLS byterange optimization',
292292
'manifest.hls.allowLowLatencyByteRangeOptimization')
293-
.addNumberInput_('override the Update time of the manifest',
294-
'manifest.hls.updatePeriod')
295293
.addBoolInput_('Allow range request to guess mime type',
296294
'manifest.hls.allowRangeRequestsToGuessMimeType');
297295
}

externs/shaka/player.js

+17-18
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,6 @@ shaka.extern.xml.Node;
10951095
* sequenceMode: boolean,
10961096
* multiTypeVariantsAllowed: boolean,
10971097
* useStreamOnceInPeriodFlattening: boolean,
1098-
* updatePeriod: number,
10991098
* enableFastSwitching: boolean
11001099
* }}
11011100
*
@@ -1190,13 +1189,6 @@ shaka.extern.xml.Node;
11901189
* between periods.
11911190
* <br>
11921191
* Defaults to <code>false</code>.
1193-
* @property {number} updatePeriod
1194-
* Override the minimumUpdatePeriod of the manifest. The value is in seconds.
1195-
* If the value is greater than the minimumUpdatePeriod, it will update the
1196-
* manifest less frequently. If you update the value during for a dynamic
1197-
* manifest, it will directly trigger a new download of the manifest.
1198-
* <br>
1199-
* Defaults to <code>-1</code>.
12001192
* @property {boolean} enableFastSwitching
12011193
* If false, disables fast switching track recognition.
12021194
* <br>
@@ -1220,7 +1212,6 @@ shaka.extern.DashManifestConfiguration;
12201212
* disableCodecGuessing: boolean,
12211213
* disableClosedCaptionsDetection: boolean,
12221214
* allowLowLatencyByteRangeOptimization: boolean,
1223-
* updatePeriod: number,
12241215
* allowRangeRequestsToGuessMimeType: boolean
12251216
* }}
12261217
*
@@ -1307,14 +1298,6 @@ shaka.extern.DashManifestConfiguration;
13071298
* https://www.akamai.com/blog/performance/-using-ll-hls-with-byte-range-addressing-to-achieve-interoperabi
13081299
* <br>
13091300
* Defaults to <code>true</code>.
1310-
* @property {number} updatePeriod
1311-
* Override the update period of the playlist. The value is in seconds.
1312-
* If the value is less than 0, the period will be determined based on the
1313-
* segment length. If the value is greater than 0, it will update the target
1314-
* duration. If you update the value during the live, it will directly
1315-
* trigger a new download of the manifest.
1316-
* <br>
1317-
* Defaults to <code>-1</code>.
13181301
* @property {boolean} allowRangeRequestsToGuessMimeType
13191302
* If set to true, the HLS parser will use range request (only first byte) to
13201303
* guess the mime type.
@@ -1371,7 +1354,8 @@ shaka.extern.MssManifestConfiguration;
13711354
* mss: shaka.extern.MssManifestConfiguration,
13721355
* raiseFatalErrorOnManifestUpdateRequestFailure: boolean,
13731356
* continueLoadingWhenPaused: boolean,
1374-
* ignoreSupplementalCodecs: boolean
1357+
* ignoreSupplementalCodecs: boolean,
1358+
* updatePeriod: number
13751359
* }}
13761360
*
13771361
* @property {shaka.extern.RetryParameters} retryParameters
@@ -1437,6 +1421,21 @@ shaka.extern.MssManifestConfiguration;
14371421
* If true, ignores supplemental codecs.
14381422
* <br>
14391423
* Defaults to <code>false</code>.
1424+
* @property {number} updatePeriod
1425+
* For DASH:
1426+
* Override the minimumUpdatePeriod of the manifest. The value is in seconds.
1427+
* If the value is greater than the minimumUpdatePeriod, it will update the
1428+
* manifest less frequently. If you update the value during for a dynamic
1429+
* manifest, it will directly trigger a new download of the manifest.
1430+
* <br>
1431+
* For HLS:
1432+
* Override the update period of the playlist. The value is in seconds.
1433+
* If the value is less than 0, the period will be determined based on the
1434+
* segment length. If the value is greater than 0, it will update the target
1435+
* duration. If you update the value during the live, it will directly
1436+
* trigger a new download of the manifest.
1437+
* <br>
1438+
* Defaults to <code>-1</code>.
14401439
* @exportDoc
14411440
*/
14421441
shaka.extern.ManifestConfiguration;

lib/dash/dash_parser.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ shaka.dash.DashParser = class {
207207
goog.asserts.assert(config.dash != null,
208208
'DashManifestConfiguration should not be null!');
209209
const needFireUpdate = this.playerInterface_ &&
210-
config.dash.updatePeriod != this.config_.dash.updatePeriod &&
211-
config.dash.updatePeriod >= 0;
210+
config.updatePeriod != this.config_.updatePeriod &&
211+
config.updatePeriod >= 0;
212212
this.config_ = config;
213213
if (isPreloadFn) {
214214
this.isPreloadFn_ = isPreloadFn;
@@ -2539,8 +2539,8 @@ shaka.dash.DashParser = class {
25392539
return;
25402540
}
25412541
let updateTime = this.updatePeriod_;
2542-
if (this.config_.dash.updatePeriod >= 0) {
2543-
updateTime = this.config_.dash.updatePeriod;
2542+
if (this.config_.updatePeriod >= 0) {
2543+
updateTime = this.config_.updatePeriod;
25442544
}
25452545

25462546
const finalDelay = Math.max(

lib/hls/hls_parser.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ shaka.hls.HlsParser = class {
300300
*/
301301
configure(config, isPreloadFn) {
302302
const needFireUpdate = this.playerInterface_ &&
303-
config.hls.updatePeriod != this.config_.hls.updatePeriod &&
304-
config.hls.updatePeriod >= 0;
303+
config.updatePeriod != this.config_.updatePeriod &&
304+
config.updatePeriod >= 0;
305305
this.config_ = config;
306306
if (isPreloadFn) {
307307
this.isPreloadFn_ = isPreloadFn;
@@ -4636,8 +4636,8 @@ shaka.hls.HlsParser = class {
46364636
if (this.isLive_()) {
46374637
const updateDuration = (endTime - startTime) / 1000.0;
46384638
this.averageUpdateDuration_.sample(1, updateDuration);
4639-
const delay = this.config_.hls.updatePeriod > 0 ?
4640-
this.config_.hls.updatePeriod : this.getUpdatePlaylistDelay_();
4639+
const delay = this.config_.updatePeriod > 0 ?
4640+
this.config_.updatePeriod : this.getUpdatePlaylistDelay_();
46414641
const finalDelay = Math.max(0,
46424642
delay - this.averageUpdateDuration_.getEstimate());
46434643
this.updatePlaylistTimer_.tickAfter(/* seconds= */ finalDelay);

lib/player.js

+22
Original file line numberDiff line numberDiff line change
@@ -4093,6 +4093,28 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
40934093
delete config['manifest']['hls']['ignoreSupplementalCodecs'];
40944094
}
40954095

4096+
// Deprecate 'manifest.dash.updatePeriod' configuration.
4097+
if (config['manifest'] && config['manifest']['dash'] &&
4098+
'updatePeriod' in config['manifest']['dash']) {
4099+
shaka.Deprecate.deprecateFeature(5,
4100+
'manifest.dash.updatePeriod configuration',
4101+
'Please Use manifest.updatePeriod instead.');
4102+
config['manifest']['updatePeriod'] =
4103+
config['manifest']['dash']['updatePeriod'];
4104+
delete config['manifest']['dash']['updatePeriod'];
4105+
}
4106+
4107+
// Deprecate 'manifest.hls.updatePeriod' configuration.
4108+
if (config['manifest'] && config['manifest']['hls'] &&
4109+
'updatePeriod' in config['manifest']['hls']) {
4110+
shaka.Deprecate.deprecateFeature(5,
4111+
'manifest.hls.updatePeriod configuration',
4112+
'Please Use manifest.updatePeriod instead.');
4113+
config['manifest']['updatePeriod'] =
4114+
config['manifest']['hls']['updatePeriod'];
4115+
delete config['manifest']['hls']['updatePeriod'];
4116+
}
4117+
40964118
// Deprecate AdvancedDrmConfiguration's videoRobustness and audioRobustness
40974119
// as a string. It's now an array of strings.
40984120
if (config['drm'] && config['drm']['advanced']) {

lib/util/player_configuration.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ shaka.util.PlayerConfiguration = class {
127127
raiseFatalErrorOnManifestUpdateRequestFailure: false,
128128
continueLoadingWhenPaused: true,
129129
ignoreSupplementalCodecs: false,
130+
updatePeriod: -1,
130131
dash: {
131132
clockSyncUri: '',
132133
ignoreDrmInfo: false,
@@ -161,7 +162,6 @@ shaka.util.PlayerConfiguration = class {
161162
sequenceMode: false,
162163
multiTypeVariantsAllowed,
163164
useStreamOnceInPeriodFlattening: false,
164-
updatePeriod: -1,
165165
enableFastSwitching: true,
166166
},
167167
hls: {
@@ -178,7 +178,6 @@ shaka.util.PlayerConfiguration = class {
178178
ignoreManifestTimestampsInSegmentsMode: false,
179179
disableCodecGuessing: false,
180180
disableClosedCaptionsDetection: false,
181-
updatePeriod: -1,
182181
allowLowLatencyByteRangeOptimization: true,
183182
allowRangeRequestsToGuessMimeType: false,
184183
},

0 commit comments

Comments
 (0)