shaka-player 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/AUTHORS +2 -0
- package/CHANGELOG.md +98 -0
- package/CODE_OF_CONDUCT.md +1 -1
- package/CONTRIBUTORS +2 -0
- package/README.md +38 -32
- package/demo/common/asset.js +11 -17
- package/demo/common/assets.js +117 -11
- package/demo/config.js +28 -1
- package/demo/custom.js +52 -38
- package/demo/main.js +11 -3
- package/demo/search.js +7 -0
- package/dist/controls.css +1 -1
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +133 -124
- package/dist/demo.compiled.debug.map +3 -3
- package/dist/demo.compiled.js +133 -124
- package/dist/demo.compiled.map +3 -3
- package/dist/deps.js +20 -18
- package/dist/locales.js +35 -31
- package/dist/receiver.compiled.debug.js +58 -50
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +58 -50
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.d.ts +440 -390
- package/dist/shaka-player.compiled.debug.d.ts +440 -390
- package/dist/shaka-player.compiled.debug.externs.js +162 -77
- package/dist/shaka-player.compiled.debug.js +786 -736
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +162 -77
- package/dist/shaka-player.compiled.js +1154 -1121
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +491 -437
- package/dist/shaka-player.ui.debug.d.ts +491 -437
- package/dist/shaka-player.ui.debug.externs.js +167 -77
- package/dist/shaka-player.ui.debug.js +877 -811
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +167 -77
- package/dist/shaka-player.ui.js +1362 -1318
- package/dist/shaka-player.ui.map +4 -4
- package/docs/tutorials/ad_monetization.md +54 -0
- package/docs/tutorials/basic-usage.md +2 -1
- package/docs/tutorials/errors.md +2 -1
- package/docs/tutorials/offline.md +10 -8
- package/docs/tutorials/plugins.md +5 -0
- package/docs/tutorials/ui-customization.md +13 -0
- package/docs/tutorials/ui.md +2 -1
- package/docs/tutorials/upgrade.md +3 -0
- package/externs/managedmediasource.js +24 -0
- package/externs/shaka/abr_manager.js +6 -2
- package/externs/shaka/cea.js +7 -0
- package/externs/shaka/codecs.js +5 -3
- package/externs/shaka/manifest.js +21 -5
- package/externs/shaka/manifest_parser.js +17 -0
- package/externs/shaka/net.js +2 -2
- package/externs/shaka/offline.js +9 -2
- package/externs/shaka/player.js +53 -7
- package/externs/shaka/text.js +3 -1
- package/externs/shaka/transmuxer.js +1 -1
- package/lib/abr/simple_abr_manager.js +25 -8
- package/lib/ads/media_tailor_ad_manager.js +14 -3
- package/lib/cast/cast_receiver.js +1 -1
- package/lib/cea/cea_decoder.js +28 -0
- package/lib/cea/dummy_caption_decoder.js +5 -0
- package/lib/dash/dash_parser.js +249 -83
- package/lib/dash/mpd_utils.js +52 -31
- package/lib/dash/segment_base.js +4 -5
- package/lib/dash/segment_list.js +5 -4
- package/lib/dash/segment_template.js +83 -26
- package/lib/hls/hls_classes.js +28 -43
- package/lib/hls/hls_parser.js +761 -649
- package/lib/hls/hls_utils.js +64 -5
- package/lib/hls/manifest_text_parser.js +7 -11
- package/lib/media/adaptation_set.js +20 -13
- package/lib/media/adaptation_set_criteria.js +70 -18
- package/lib/media/closed_caption_parser.js +13 -0
- package/lib/media/content_workarounds.js +6 -0
- package/lib/media/drm_engine.js +8 -13
- package/lib/media/manifest_parser.js +8 -113
- package/lib/media/media_source_capabilities.js +10 -3
- package/lib/media/media_source_engine.js +75 -21
- package/lib/media/play_rate_controller.js +8 -38
- package/lib/media/presentation_timeline.js +7 -1
- package/lib/media/quality_observer.js +1 -1
- package/lib/media/segment_index.js +5 -5
- package/lib/media/segment_prefetch.js +92 -24
- package/lib/media/segment_reference.js +67 -1
- package/lib/media/segment_utils.js +343 -0
- package/lib/media/stall_detector.js +0 -3
- package/lib/media/streaming_engine.js +41 -21
- package/lib/mss/mss_parser.js +18 -2
- package/lib/net/networking_engine.js +66 -12
- package/lib/net/networking_utils.js +95 -0
- package/lib/offline/indexeddb/v1_storage_cell.js +2 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +2 -0
- package/lib/offline/manifest_converter.js +2 -0
- package/lib/offline/offline_manifest_parser.js +10 -0
- package/lib/offline/storage.js +11 -7
- package/lib/player.js +993 -1502
- package/lib/polyfill/mediasource.js +22 -1
- package/lib/text/mp4_ttml_parser.js +2 -2
- package/lib/text/srt_text_parser.js +2 -2
- package/lib/text/stub_text_displayer.js +51 -0
- package/lib/text/text_engine.js +3 -2
- package/lib/text/ttml_text_parser.js +28 -5
- package/lib/text/ui_text_displayer.js +4 -0
- package/lib/text/vtt_text_parser.js +7 -2
- package/lib/transmuxer/aac_transmuxer.js +1 -1
- package/lib/transmuxer/ac3_transmuxer.js +1 -1
- package/lib/transmuxer/ec3_transmuxer.js +1 -1
- package/lib/transmuxer/h264.js +5 -4
- package/lib/transmuxer/h265.js +5 -4
- package/lib/transmuxer/mp3_transmuxer.js +1 -1
- package/lib/transmuxer/mpeg_ts_transmuxer.js +1 -1
- package/lib/transmuxer/mss_transmuxer.js +1 -1
- package/lib/transmuxer/ts_transmuxer.js +33 -13
- package/lib/util/buffer_utils.js +26 -4
- package/lib/util/content_steering_manager.js +358 -0
- package/lib/util/error.js +2 -6
- package/lib/util/fairplay_utils.js +1 -1
- package/lib/util/fake_event.js +5 -1
- package/lib/util/id3_utils.js +50 -1
- package/lib/util/manifest_parser_utils.js +12 -8
- package/lib/util/mp4_generator.js +2 -4
- package/lib/util/mutex.js +59 -0
- package/lib/util/object_utils.js +1 -1
- package/lib/util/periods.js +154 -179
- package/lib/util/platform.js +4 -3
- package/lib/util/player_configuration.js +35 -6
- package/lib/util/stream_utils.js +105 -98
- package/lib/util/ts_parser.js +124 -73
- package/lib/util/uint8array_utils.js +5 -1
- package/lib/util/xml_utils.js +5 -0
- package/maintained-branches.md +2 -2
- package/package.json +1 -1
- package/roadmap.md +15 -5
- package/shaka-player.uncompiled.js +0 -1
- package/test/abr/simple_abr_manager_unit.js +33 -33
- package/test/ads/ad_manager_unit.js +3 -2
- package/test/cast/cast_receiver_integration.js +3 -4
- package/test/cast/cast_utils_unit.js +2 -0
- package/test/cea/cea_decoder_unit.js +7 -0
- package/test/codec_switching/codec_switching_integration.js +2 -1
- package/test/dash/dash_parser_integration.js +2 -1
- package/test/dash/dash_parser_live_unit.js +0 -19
- package/test/dash/dash_parser_manifest_unit.js +494 -2
- package/test/dash/mpd_utils_unit.js +61 -30
- package/test/hls/hls_live_unit.js +12 -3
- package/test/hls/hls_parser_unit.js +377 -27
- package/test/hls/manifest_text_parser_unit.js +32 -99
- package/test/media/adaptation_set_criteria_unit.js +172 -21
- package/test/media/adaptation_set_unit.js +1 -0
- package/test/media/content_workarounds_unit.js +1 -1
- package/test/media/drm_engine_unit.js +3 -3
- package/test/media/media_source_engine_unit.js +1 -1
- package/test/media/play_rate_controller_unit.js +0 -48
- package/test/media/segment_index_unit.js +2 -1
- package/test/mss/mss_player_integration.js +3 -2
- package/test/net/networking_engine_unit.js +3 -3
- package/test/{media/manifest_parser_unit.js → net/networking_utils_unit.js} +2 -2
- package/test/offline/manifest_convert_unit.js +9 -0
- package/test/offline/offline_integration.js +2 -1
- package/test/offline/storage_integration.js +21 -9
- package/test/player_external.js +4 -2
- package/test/player_integration.js +15 -4
- package/test/player_load_graph_integration.js +47 -151
- package/test/player_src_equals_external.js +1 -0
- package/test/player_src_equals_integration.js +71 -4
- package/test/player_unit.js +80 -27
- package/test/test/util/fake_media_source_engine.js +5 -0
- package/test/test/util/fake_networking_engine.js +9 -1
- package/test/test/util/fake_segment_prefetch.js +3 -0
- package/test/test/util/manifest_generator.js +4 -0
- package/test/test/util/manifest_parser_util.js +14 -2
- package/test/test/util/offline_utils.js +1 -0
- package/test/test/util/simple_fakes.js +2 -2
- package/test/test/util/streaming_engine_util.js +3 -0
- package/test/test/util/test_scheme.js +6 -0
- package/test/test/util/ui_utils.js +4 -3
- package/test/text/mp4_ttml_parser_unit.js +4 -4
- package/test/text/srt_text_parser_unit.js +1 -1
- package/test/text/text_displayer_layout_unit.js +1 -1
- package/test/text/text_engine_unit.js +6 -0
- package/test/text/ttml_text_parser_unit.js +33 -2
- package/test/transmuxer/transmuxer_engine_integration.js +9 -0
- package/test/transmuxer/transmuxer_integration.js +33 -3
- package/test/ui/ad_ui_unit.js +2 -2
- package/test/ui/ui_customization_unit.js +17 -16
- package/test/ui/ui_integration.js +30 -20
- package/test/ui/ui_unit.js +25 -19
- package/test/util/buffer_utils_unit.js +1 -1
- package/test/util/content_steering_manager_unit.js +427 -0
- package/test/util/id3_utils_unit.js +52 -0
- package/test/util/stream_utils_unit.js +17 -113
- package/test/util/ts_parser_unit.js +3 -3
- package/third_party/closure-uri/uri.js +13 -1
- package/ui/audio_language_selection.js +9 -2
- package/ui/externs/ui.js +17 -2
- package/ui/language_utils.js +43 -8
- package/ui/less/range_elements.less +33 -0
- package/ui/locales/en.json +1 -0
- package/ui/locales/es-419.json +1 -0
- package/ui/locales/es.json +1 -0
- package/ui/locales/source.json +4 -0
- package/ui/localization.js +10 -0
- package/ui/remote_button.js +3 -1
- package/ui/resolution_selection.js +47 -10
- package/ui/seek_bar.js +296 -3
- package/ui/text_selection.js +2 -1
- package/ui/ui.js +6 -2
- package/lib/routing/node.js +0 -23
- package/lib/routing/payload.js +0 -47
- package/lib/routing/walker.js +0 -587
- package/test/routing/walker_unit.js +0 -505
|
@@ -63,7 +63,7 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
63
63
|
this.bandwidthEstimator_.configure(this.config_.advanced);
|
|
64
64
|
}
|
|
65
65
|
const chosenVariant = this.chooseVariant();
|
|
66
|
-
if (chosenVariant) {
|
|
66
|
+
if (chosenVariant && navigator.onLine) {
|
|
67
67
|
this.switch_(chosenVariant, this.config_.clearBufferSwitch,
|
|
68
68
|
this.config_.safeMarginSwitch);
|
|
69
69
|
}
|
|
@@ -165,10 +165,12 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
+
* @param {boolean=} preferFastSwitching
|
|
169
|
+
* @return {shaka.extern.Variant}
|
|
168
170
|
* @override
|
|
169
171
|
* @export
|
|
170
172
|
*/
|
|
171
|
-
chooseVariant() {
|
|
173
|
+
chooseVariant(preferFastSwitching = false) {
|
|
172
174
|
const SimpleAbrManager = shaka.abr.SimpleAbrManager;
|
|
173
175
|
|
|
174
176
|
let maxHeight = Infinity;
|
|
@@ -190,9 +192,24 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
190
192
|
maxWidth, this.mediaElement_.clientWidth * devicePixelRatio);
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
let normalVariants = this.variants_.filter((variant) => {
|
|
196
|
+
return !shaka.util.StreamUtils.isFastSwitching(variant);
|
|
197
|
+
});
|
|
198
|
+
if (!normalVariants.length) {
|
|
199
|
+
normalVariants = this.variants_;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
let variants = normalVariants;
|
|
203
|
+
if (preferFastSwitching &&
|
|
204
|
+
normalVariants.length != this.variants_.length) {
|
|
205
|
+
variants = this.variants_.filter((variant) => {
|
|
206
|
+
return shaka.util.StreamUtils.isFastSwitching(variant);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
193
210
|
// Get sorted Variants.
|
|
194
211
|
let sortedVariants = SimpleAbrManager.filterAndSortVariants_(
|
|
195
|
-
this.config_.restrictions,
|
|
212
|
+
this.config_.restrictions, variants,
|
|
196
213
|
/* maxHeight= */ Infinity, /* maxWidth= */ Infinity);
|
|
197
214
|
|
|
198
215
|
if (maxHeight != Infinity || maxWidth != Infinity) {
|
|
@@ -206,14 +223,14 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
206
223
|
}
|
|
207
224
|
|
|
208
225
|
sortedVariants = SimpleAbrManager.filterAndSortVariants_(
|
|
209
|
-
this.config_.restrictions,
|
|
226
|
+
this.config_.restrictions, variants, maxHeight, maxWidth);
|
|
210
227
|
}
|
|
211
228
|
|
|
212
229
|
const defaultBandwidthEstimate = this.getDefaultBandwidth_();
|
|
213
230
|
const currentBandwidth = this.bandwidthEstimator_.getBandwidthEstimate(
|
|
214
231
|
defaultBandwidthEstimate);
|
|
215
232
|
|
|
216
|
-
if (
|
|
233
|
+
if (variants.length && !sortedVariants.length) {
|
|
217
234
|
// If we couldn't meet the ABR restrictions, we should still play
|
|
218
235
|
// something.
|
|
219
236
|
// These restrictions are not "hard" restrictions in the way that
|
|
@@ -222,7 +239,7 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
222
239
|
shaka.log.warning('No variants met the ABR restrictions. ' +
|
|
223
240
|
'Choosing a variant by lowest bandwidth.');
|
|
224
241
|
sortedVariants = SimpleAbrManager.filterAndSortVariants_(
|
|
225
|
-
/* restrictions= */ null,
|
|
242
|
+
/* restrictions= */ null, variants,
|
|
226
243
|
/* maxHeight= */ Infinity, /* maxWidth= */ Infinity);
|
|
227
244
|
sortedVariants = [sortedVariants[0]];
|
|
228
245
|
}
|
|
@@ -285,7 +302,7 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
285
302
|
* @override
|
|
286
303
|
* @export
|
|
287
304
|
*/
|
|
288
|
-
segmentDownloaded(deltaTimeMs, numBytes) {
|
|
305
|
+
segmentDownloaded(deltaTimeMs, numBytes, allowSwitch) {
|
|
289
306
|
shaka.log.v2('Segment downloaded:',
|
|
290
307
|
'deltaTimeMs=' + deltaTimeMs,
|
|
291
308
|
'numBytes=' + numBytes,
|
|
@@ -294,7 +311,7 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
294
311
|
goog.asserts.assert(deltaTimeMs >= 0, 'expected a non-negative duration');
|
|
295
312
|
this.bandwidthEstimator_.sample(deltaTimeMs, numBytes);
|
|
296
313
|
|
|
297
|
-
if ((this.lastTimeChosenMs_ != null) && this.enabled_) {
|
|
314
|
+
if (allowSwitch && (this.lastTimeChosenMs_ != null) && this.enabled_) {
|
|
298
315
|
this.suggestStreams_();
|
|
299
316
|
}
|
|
300
317
|
}
|
|
@@ -612,8 +612,13 @@ shaka.ads.MediaTailorAdManager = class {
|
|
|
612
612
|
*/
|
|
613
613
|
setupCurrentAdListeners_() {
|
|
614
614
|
const MediaTailorAdManager = shaka.ads.MediaTailorAdManager;
|
|
615
|
-
|
|
616
|
-
this.
|
|
615
|
+
let needFirstEvents = false;
|
|
616
|
+
if (!this.video_.paused) {
|
|
617
|
+
this.sendTrackingEvent_(MediaTailorAdManager.IMPRESSION_);
|
|
618
|
+
this.sendTrackingEvent_(MediaTailorAdManager.START_);
|
|
619
|
+
} else {
|
|
620
|
+
needFirstEvents = true;
|
|
621
|
+
}
|
|
617
622
|
this.adListeners_.push({
|
|
618
623
|
target: this.video_,
|
|
619
624
|
type: 'volumechange',
|
|
@@ -636,7 +641,13 @@ shaka.ads.MediaTailorAdManager = class {
|
|
|
636
641
|
target: this.video_,
|
|
637
642
|
type: 'play',
|
|
638
643
|
listener: () => {
|
|
639
|
-
|
|
644
|
+
if (needFirstEvents) {
|
|
645
|
+
this.sendTrackingEvent_(MediaTailorAdManager.IMPRESSION_);
|
|
646
|
+
this.sendTrackingEvent_(MediaTailorAdManager.START_);
|
|
647
|
+
needFirstEvents = false;
|
|
648
|
+
} else {
|
|
649
|
+
this.sendTrackingEvent_(MediaTailorAdManager.RESUME_);
|
|
650
|
+
}
|
|
640
651
|
},
|
|
641
652
|
});
|
|
642
653
|
this.adListeners_.push({
|
|
@@ -408,7 +408,7 @@ shaka.cast.CastReceiver = class extends shaka.util.FakeEventTarget {
|
|
|
408
408
|
} catch (error) {
|
|
409
409
|
// Pass any errors through to the app.
|
|
410
410
|
goog.asserts.assert(error instanceof shaka.util.Error,
|
|
411
|
-
'Wrong error type!');
|
|
411
|
+
'Wrong error type! Error: ' + error);
|
|
412
412
|
const eventType = shaka.util.FakeEvent.EventName.Error;
|
|
413
413
|
const data = (new Map()).set('detail', error);
|
|
414
414
|
const event = new shaka.util.FakeEvent(eventType, data);
|
package/lib/cea/cea_decoder.js
CHANGED
|
@@ -83,6 +83,12 @@ shaka.cea.CeaDecoder = class {
|
|
|
83
83
|
*/
|
|
84
84
|
this.waitingForFirstPacket_ = true;
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Set used to track available streams.
|
|
88
|
+
* @private {!Set.<string>}
|
|
89
|
+
*/
|
|
90
|
+
this.streams_ = new Set();
|
|
91
|
+
|
|
86
92
|
this.reset();
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -131,6 +137,9 @@ shaka.cea.CeaDecoder = class {
|
|
|
131
137
|
const reader = new shaka.util.DataViewReader(
|
|
132
138
|
userDataSeiMessage, shaka.util.DataViewReader.Endianness.BIG_ENDIAN);
|
|
133
139
|
|
|
140
|
+
if (reader.getLength() < shaka.cea.CeaDecoder.MIN_LENGTH) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
134
143
|
if (reader.readUint8() !== shaka.cea.CeaDecoder.USA_COUNTRY_CODE) {
|
|
135
144
|
return;
|
|
136
145
|
}
|
|
@@ -300,6 +309,8 @@ shaka.cea.CeaDecoder = class {
|
|
|
300
309
|
return null;
|
|
301
310
|
}
|
|
302
311
|
|
|
312
|
+
this.streams_.add(selectedMode);
|
|
313
|
+
|
|
303
314
|
// Process the clean CC data pair.
|
|
304
315
|
let parsedClosedCaption = null;
|
|
305
316
|
if (shaka.cea.Cea608DataChannel.isControlCode(ccPacket.ccData1)) {
|
|
@@ -340,6 +351,7 @@ shaka.cea.CeaDecoder = class {
|
|
|
340
351
|
|
|
341
352
|
// As per CEA-708-E, service number 0 is invalid, and should be ignored.
|
|
342
353
|
if (serviceNumber != 0) {
|
|
354
|
+
this.streams_.add('svc'+ serviceNumber);
|
|
343
355
|
// If the service doesn't already exist, create it.
|
|
344
356
|
if (!this.serviceNumberToService_.has(serviceNumber)) {
|
|
345
357
|
const service = new shaka.cea.Cea708Service(serviceNumber);
|
|
@@ -386,6 +398,15 @@ shaka.cea.CeaDecoder = class {
|
|
|
386
398
|
}
|
|
387
399
|
return parity === 1;
|
|
388
400
|
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Returns the streams that the CEA decoder found.
|
|
404
|
+
*
|
|
405
|
+
* @override
|
|
406
|
+
*/
|
|
407
|
+
getStreams() {
|
|
408
|
+
return Array.from(this.streams_);
|
|
409
|
+
}
|
|
389
410
|
};
|
|
390
411
|
|
|
391
412
|
/**
|
|
@@ -417,5 +438,12 @@ shaka.cea.CeaDecoder.NTSC_CC_FIELD_2 = 1;
|
|
|
417
438
|
*/
|
|
418
439
|
shaka.cea.CeaDecoder.USA_COUNTRY_CODE = 0xb5;
|
|
419
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Caption packet min length
|
|
443
|
+
* Country Code + ATSC_PROVIDER_CODE + ATSC_1_USER_IDENTIFIER + USER_DATA_TYPE
|
|
444
|
+
* @private @const {number}
|
|
445
|
+
*/
|
|
446
|
+
shaka.cea.CeaDecoder.MIN_LENGTH = 8;
|
|
447
|
+
|
|
420
448
|
shaka.media.ClosedCaptionParser.registerDecoder(
|
|
421
449
|
() => new shaka.cea.CeaDecoder());
|