shaka-player 4.4.3 → 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/.github/workflows/release-please.yaml +2 -27
- package/AUTHORS +2 -0
- package/CHANGELOG.md +156 -39
- package/CODE_OF_CONDUCT.md +1 -1
- package/CONTRIBUTORS +2 -0
- package/README.md +54 -42
- package/demo/asset_card.js +18 -21
- package/demo/cast_receiver/index.html +0 -1
- package/demo/close_button.js +0 -3
- package/demo/common/asset.js +33 -22
- package/demo/common/assets.js +249 -60
- package/demo/config.js +219 -253
- package/demo/custom.js +88 -133
- package/demo/front.js +7 -10
- package/demo/index.html +19 -22
- package/demo/input.js +6 -11
- package/demo/input_container.js +8 -9
- package/demo/main.js +62 -126
- package/demo/search.js +29 -34
- package/demo/service_worker.js +0 -3
- package/demo/tooltip.js +3 -5
- package/demo/visualizer.js +3 -5
- package/demo/visualizer_button.js +1 -20
- package/dist/controls.css +1 -1
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +211 -228
- package/dist/demo.compiled.debug.map +4 -4
- package/dist/demo.compiled.js +211 -228
- package/dist/demo.compiled.map +4 -4
- package/dist/deps.js +42 -37
- package/dist/locales.js +34 -30
- package/dist/receiver.compiled.debug.js +64 -77
- package/dist/receiver.compiled.debug.map +4 -4
- package/dist/receiver.compiled.js +64 -77
- package/dist/receiver.compiled.map +4 -4
- package/dist/shaka-player.compiled.d.ts +343 -151
- package/dist/shaka-player.compiled.debug.d.ts +343 -151
- package/dist/shaka-player.compiled.debug.externs.js +356 -117
- package/dist/shaka-player.compiled.debug.js +952 -811
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +356 -117
- package/dist/shaka-player.compiled.js +1165 -1078
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +359 -153
- package/dist/shaka-player.ui.debug.d.ts +359 -153
- package/dist/shaka-player.ui.debug.externs.js +382 -117
- package/dist/shaka-player.ui.debug.js +1084 -918
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +382 -117
- package/dist/shaka-player.ui.js +1377 -1274
- package/dist/shaka-player.ui.map +4 -4
- package/docs/design/lcevc-integration.md +14 -14
- 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/faq.md +27 -55
- package/docs/tutorials/index.json +2 -1
- package/docs/tutorials/lcevc.md +118 -0
- package/docs/tutorials/offline.md +10 -8
- package/docs/tutorials/plugins.md +5 -0
- package/docs/tutorials/ui-customization.md +17 -0
- package/docs/tutorials/ui.md +2 -1
- package/docs/tutorials/upgrade.md +3 -0
- package/externs/css_style_declaration.js +19 -0
- package/externs/lcevc.js +37 -13
- package/externs/managedmediasource.js +24 -0
- package/externs/media_remote.js +68 -0
- package/externs/mediatailor.js +193 -0
- package/externs/pictureinpicture.js +11 -0
- package/externs/shaka/abr_manager.js +6 -2
- package/externs/shaka/ads.js +27 -0
- package/externs/shaka/cea.js +7 -0
- package/externs/shaka/codecs.js +5 -3
- package/externs/shaka/manifest.js +31 -10
- package/externs/shaka/manifest_parser.js +24 -1
- package/externs/shaka/net.js +2 -2
- package/externs/shaka/offline.js +13 -2
- package/externs/shaka/player.js +65 -8
- package/externs/shaka/text.js +3 -1
- package/externs/shaka/transmuxer.js +1 -1
- package/karma.conf.js +7 -3
- package/lib/abr/simple_abr_manager.js +66 -9
- package/lib/ads/ad_manager.js +104 -50
- package/lib/ads/media_tailor_ad.js +297 -0
- package/lib/ads/media_tailor_ad_manager.js +839 -0
- 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/cea/ts_cea_parser.js +15 -2
- package/lib/config/codec_switching_strategy.js +24 -0
- package/lib/dash/content_protection.js +120 -2
- package/lib/dash/dash_parser.js +322 -93
- package/lib/dash/mpd_utils.js +62 -37
- package/lib/dash/segment_base.js +17 -10
- package/lib/dash/segment_list.js +18 -9
- package/lib/dash/segment_template.js +122 -107
- package/lib/dependencies/all.js +8 -7
- package/lib/hls/hls_classes.js +28 -43
- package/lib/hls/hls_parser.js +798 -658
- package/lib/hls/hls_utils.js +64 -5
- package/lib/hls/manifest_text_parser.js +7 -11
- package/lib/lcevc/lcevc_dec.js +220 -0
- package/lib/media/adaptation_set.js +32 -14
- package/lib/media/adaptation_set_criteria.js +86 -16
- 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 +286 -44
- 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 +6 -6
- package/lib/media/segment_prefetch.js +92 -24
- package/lib/media/segment_reference.js +73 -7
- package/lib/media/segment_utils.js +343 -0
- package/lib/media/stall_detector.js +0 -3
- package/lib/media/streaming_engine.js +73 -38
- package/lib/mss/mss_parser.js +19 -2
- package/lib/net/networking_engine.js +67 -12
- package/lib/net/networking_utils.js +95 -0
- package/lib/offline/indexeddb/v1_storage_cell.js +3 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +3 -0
- package/lib/offline/manifest_converter.js +3 -0
- package/lib/offline/offline_manifest_parser.js +10 -0
- package/lib/offline/storage.js +14 -7
- package/lib/player.js +1098 -1537
- package/lib/polyfill/mediasource.js +22 -1
- package/lib/text/cue.js +15 -0
- 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 +45 -5
- package/lib/text/ui_text_displayer.js +8 -0
- package/lib/text/vtt_text_parser.js +40 -22
- 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 +863 -0
- package/lib/transmuxer/mp3_transmuxer.js +1 -1
- package/lib/transmuxer/mpeg_ts_transmuxer.js +4 -3
- package/lib/transmuxer/mss_transmuxer.js +1 -1
- package/lib/transmuxer/ts_transmuxer.js +187 -22
- package/lib/util/buffer_utils.js +26 -4
- package/lib/util/content_steering_manager.js +358 -0
- package/lib/util/error.js +30 -15
- package/lib/util/exp_golomb.js +30 -2
- package/lib/util/fairplay_utils.js +1 -1
- package/lib/util/fake_event.js +8 -1
- package/lib/util/id3_utils.js +50 -1
- package/lib/util/manifest_parser_utils.js +12 -8
- package/lib/util/mp4_generator.js +6 -8
- package/lib/util/mutex.js +59 -0
- package/lib/util/object_utils.js +1 -1
- package/lib/util/periods.js +156 -179
- package/lib/util/platform.js +44 -3
- package/lib/util/player_configuration.js +43 -6
- package/lib/util/state_history.js +6 -2
- package/lib/util/stream_utils.js +206 -283
- package/lib/util/ts_parser.js +335 -98
- package/lib/util/uint8array_utils.js +5 -1
- package/lib/util/xml_utils.js +5 -0
- package/maintained-branches.md +3 -2
- package/package.json +4 -6
- package/roadmap.md +25 -5
- package/shaka-player.uncompiled.js +2 -2
- package/support.html +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 +50 -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 +182 -0
- package/test/dash/dash_parser_content_protection_unit.js +2 -0
- package/test/dash/dash_parser_integration.js +74 -0
- package/test/dash/dash_parser_live_unit.js +2 -19
- package/test/dash/dash_parser_manifest_unit.js +536 -2
- package/test/dash/dash_parser_segment_base_unit.js +2 -0
- package/test/dash/dash_parser_segment_list_unit.js +2 -0
- package/test/dash/dash_parser_segment_template_unit.js +2 -0
- package/test/dash/mpd_utils_unit.js +61 -30
- package/test/demo/demo_unit.js +0 -16
- package/test/hls/hls_live_unit.js +14 -3
- package/test/hls/hls_parser_unit.js +385 -33
- package/test/hls/manifest_text_parser_unit.js +32 -99
- package/test/media/adaptation_set_criteria_unit.js +284 -15
- package/test/media/adaptation_set_unit.js +2 -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 +166 -2
- package/test/media/play_rate_controller_unit.js +0 -48
- package/test/media/segment_index_unit.js +5 -4
- package/test/media/segment_prefetch_unit.js +1 -1
- package/test/media/streaming_engine_unit.js +17 -17
- package/test/mss/mss_parser_unit.js +2 -0
- 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 +14 -0
- package/test/offline/offline_integration.js +2 -1
- package/test/offline/storage_integration.js +22 -13
- 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 +182 -158
- package/test/test/assets/dash-aes-128/Fragments(video=0,format=mpd-time-csf) +0 -0
- package/test/test/assets/dash-aes-128/Fragments(video=20000000,format=mpd-time-csf) +0 -0
- package/test/test/assets/dash-aes-128/Fragments(video=40000000,format=mpd-time-csf) +0 -0
- package/test/test/assets/dash-aes-128/Fragments(video=60000000,format=mpd-time-csf) +0 -0
- package/test/test/assets/dash-aes-128/Fragments(video=i,format=mpd-time-csf) +0 -0
- package/test/test/assets/dash-aes-128/dash.mpd +18 -0
- package/test/test/assets/dash-aes-128/license +1 -0
- package/test/test/assets/dash-multi-codec/audio_en_2c_128k_aac.mp4 +0 -0
- package/test/test/assets/dash-multi-codec/audio_es_2c_64k_opus.webm +0 -0
- package/test/test/assets/dash-multi-codec/dash.mpd +32 -0
- package/test/test/assets/dash-multi-codec/video_144p_108k_h264.mp4 +0 -0
- package/test/test/assets/hls-ts-h265/0.ts +0 -0
- package/test/test/assets/hls-ts-h265/hevc.m3u8 +6 -0
- package/test/test/assets/hls-ts-h265/index.m3u8 +7 -0
- package/test/test/assets/hls-ts-muxed-aac-h265/0.ts +0 -0
- package/test/test/assets/hls-ts-muxed-aac-h265/1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-aac-h265/media.m3u8 +9 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8 +24 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00000.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00001.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00002.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00003.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00004.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ac3-h264/s_00005.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0000.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0001.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0002.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0003.ts +0 -0
- package/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8 +14 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8 +23 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-1-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-2-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-3-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-4-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-5-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-6-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-7-v1-a1.ts +0 -0
- package/test/test/assets/hls-ts-muxed-mp3-h264/seg-8-v1-a1.ts +0 -0
- package/test/test/util/dash_parser_util.js +4 -0
- package/test/test/util/fake_ad_manager.js +20 -0
- package/test/test/util/fake_media_source_engine.js +13 -2
- 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 +11 -3
- package/test/test/util/manifest_parser_util.js +14 -2
- package/test/test/util/mss_parser_util.js +4 -0
- package/test/test/util/offline_utils.js +2 -0
- package/test/test/util/simple_fakes.js +2 -2
- package/test/test/util/streaming_engine_util.js +10 -4
- 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 +85 -2
- package/test/text/vtt_text_parser_unit.js +103 -31
- package/test/transmuxer/transmuxer_engine_integration.js +9 -0
- package/test/transmuxer/transmuxer_integration.js +150 -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 +28 -29
- 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 +207 -169
- 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/controls.js +125 -0
- package/ui/externs/ui.js +24 -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/pip_button.js +22 -120
- package/ui/remote_button.js +203 -0
- 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 +11 -4
- package/demo/common/message_ids.js +0 -309
- package/demo/locales/en.json +0 -288
- package/demo/locales/source.json +0 -1146
- package/externs/mux.js +0 -69
- package/lib/lcevc/lcevc_dil.js +0 -152
- package/lib/routing/node.js +0 -23
- package/lib/routing/payload.js +0 -43
- package/lib/routing/walker.js +0 -587
- package/lib/transmuxer/muxjs_transmuxer.js +0 -242
- package/test/routing/walker_unit.js +0 -504
- package/test/transmuxer/muxjs_transmuxer_integration.js +0 -177
|
@@ -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());
|
package/lib/cea/ts_cea_parser.js
CHANGED
|
@@ -49,10 +49,23 @@ shaka.cea.TsCeaParser = class {
|
|
|
49
49
|
return captionPackets;
|
|
50
50
|
}
|
|
51
51
|
const tsParser = new shaka.util.TsParser().parse(uint8ArrayData);
|
|
52
|
+
const codecs = tsParser.getCodecs();
|
|
52
53
|
const videoNalus = tsParser.getVideoNalus();
|
|
54
|
+
const validNaluTypes = [];
|
|
55
|
+
switch (codecs.video) {
|
|
56
|
+
case 'avc':
|
|
57
|
+
validNaluTypes.push(CeaUtils.H264_NALU_TYPE_SEI);
|
|
58
|
+
break;
|
|
59
|
+
case 'hvc':
|
|
60
|
+
validNaluTypes.push(CeaUtils.H265_PREFIX_NALU_TYPE_SEI);
|
|
61
|
+
validNaluTypes.push(CeaUtils.H265_SUFFIX_NALU_TYPE_SEI);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (!validNaluTypes.length) {
|
|
65
|
+
return captionPackets;
|
|
66
|
+
}
|
|
53
67
|
for (const nalu of videoNalus) {
|
|
54
|
-
if (nalu.type
|
|
55
|
-
nalu.time != null) {
|
|
68
|
+
if (validNaluTypes.includes(nalu.type) && nalu.time != null) {
|
|
56
69
|
for (const packet of this.seiProcessor_.process(nalu.data)) {
|
|
57
70
|
captionPackets.push({
|
|
58
71
|
packet: packet,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*! @license
|
|
2
|
+
* Shaka Player
|
|
3
|
+
* Copyright 2016 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
goog.provide('shaka.config.CodecSwitchingStrategy');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @enum {string}
|
|
11
|
+
* @export
|
|
12
|
+
*/
|
|
13
|
+
shaka.config.CodecSwitchingStrategy = {
|
|
14
|
+
// Allow codec switching which will always involve reloading the
|
|
15
|
+
// `MediaSource`.
|
|
16
|
+
RELOAD: 'reload',
|
|
17
|
+
// Allow codec switching; determine if `SourceBuffer.changeType` is available
|
|
18
|
+
// and attempt to use this first, but fall back to reloading `MediaSource` if
|
|
19
|
+
// not available.
|
|
20
|
+
//
|
|
21
|
+
// Note: Some devices that support `SourceBuffer.changeType` can become stuck
|
|
22
|
+
// in a pause state.
|
|
23
|
+
SMOOTH: 'smooth',
|
|
24
|
+
};
|
|
@@ -39,6 +39,8 @@ shaka.dash.ContentProtection = class {
|
|
|
39
39
|
/** @type {!Array.<shaka.extern.DrmInfo>} */
|
|
40
40
|
let drmInfos = [];
|
|
41
41
|
let parsedNonCenc = [];
|
|
42
|
+
/** @type {?shaka.dash.ContentProtection.Aes128Info} */
|
|
43
|
+
let aes128Info = null;
|
|
42
44
|
|
|
43
45
|
// Get the default key ID; if there are multiple, they must all match.
|
|
44
46
|
const keyIds = new Set(parsed.map((element) => element.keyId));
|
|
@@ -53,6 +55,21 @@ shaka.dash.ContentProtection = class {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
if (!ignoreDrmInfo) {
|
|
58
|
+
const aes128Elements = parsed.filter((elem) => {
|
|
59
|
+
return elem.schemeUri == ContentProtection.Aes128Protection_;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (aes128Elements.length > 1) {
|
|
63
|
+
throw new shaka.util.Error(
|
|
64
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
65
|
+
shaka.util.Error.Category.MANIFEST,
|
|
66
|
+
shaka.util.Error.Code.DASH_CONFLICTING_AES_128);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (aes128Elements.length) {
|
|
70
|
+
aes128Info = ContentProtection.parseAes128_(aes128Elements[0]);
|
|
71
|
+
}
|
|
72
|
+
|
|
56
73
|
// Find the default key ID and init data. Create a new array of all the
|
|
57
74
|
// non-CENC elements.
|
|
58
75
|
parsedNonCenc = parsed.filter((elem) => {
|
|
@@ -62,7 +79,7 @@ shaka.dash.ContentProtection = class {
|
|
|
62
79
|
defaultInit = elem.init || defaultInit;
|
|
63
80
|
return false;
|
|
64
81
|
} else {
|
|
65
|
-
return
|
|
82
|
+
return elem.schemeUri != ContentProtection.Aes128Protection_;
|
|
66
83
|
}
|
|
67
84
|
});
|
|
68
85
|
|
|
@@ -80,7 +97,8 @@ shaka.dash.ContentProtection = class {
|
|
|
80
97
|
|
|
81
98
|
// If there are only CENC element(s) or ignoreDrmInfo flag is set, assume
|
|
82
99
|
// all key-systems are supported.
|
|
83
|
-
if (parsed.length &&
|
|
100
|
+
if (parsed.length && !aes128Info &&
|
|
101
|
+
(ignoreDrmInfo || !parsedNonCenc.length)) {
|
|
84
102
|
drmInfos = [];
|
|
85
103
|
|
|
86
104
|
for (const keySystem of Object.values(keySystemsByURI)) {
|
|
@@ -110,6 +128,7 @@ shaka.dash.ContentProtection = class {
|
|
|
110
128
|
defaultKeyId: defaultKeyId,
|
|
111
129
|
defaultInit: defaultInit,
|
|
112
130
|
drmInfos: drmInfos,
|
|
131
|
+
aes128Info: aes128Info,
|
|
113
132
|
firstRepresentation: true,
|
|
114
133
|
};
|
|
115
134
|
}
|
|
@@ -551,6 +570,79 @@ shaka.dash.ContentProtection = class {
|
|
|
551
570
|
init: (init.length > 0 ? init : null),
|
|
552
571
|
};
|
|
553
572
|
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Parses the given AES-128 ContentProtection element.
|
|
576
|
+
*
|
|
577
|
+
* @param {shaka.dash.ContentProtection.Element} element
|
|
578
|
+
* @return {?shaka.dash.ContentProtection.Aes128Info}
|
|
579
|
+
* @private
|
|
580
|
+
*/
|
|
581
|
+
static parseAes128_(element) {
|
|
582
|
+
// Check if the Web Crypto API is available.
|
|
583
|
+
if (!window.crypto || !window.crypto.subtle) {
|
|
584
|
+
shaka.log.alwaysWarn('Web Crypto API is not available to decrypt ' +
|
|
585
|
+
'AES-128. (Web Crypto only exists in secure origins like https)');
|
|
586
|
+
throw new shaka.util.Error(
|
|
587
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
588
|
+
shaka.util.Error.Category.MANIFEST,
|
|
589
|
+
shaka.util.Error.Code.NO_WEB_CRYPTO_API);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const namespace = 'urn:mpeg:dash:schema:sea:2012';
|
|
593
|
+
const segmentEncryption = shaka.util.XmlUtils.findChildNS(
|
|
594
|
+
element.node, namespace, 'SegmentEncryption');
|
|
595
|
+
|
|
596
|
+
if (!segmentEncryption) {
|
|
597
|
+
throw new shaka.util.Error(
|
|
598
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
599
|
+
shaka.util.Error.Category.MANIFEST,
|
|
600
|
+
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const aesSchemeIdUri = 'urn:mpeg:dash:sea:aes128-cbc:2013';
|
|
604
|
+
const segmentEncryptionSchemeIdUri =
|
|
605
|
+
segmentEncryption.getAttribute('schemeIdUri');
|
|
606
|
+
if (segmentEncryptionSchemeIdUri != aesSchemeIdUri) {
|
|
607
|
+
throw new shaka.util.Error(
|
|
608
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
609
|
+
shaka.util.Error.Category.MANIFEST,
|
|
610
|
+
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const cryptoPeriod = shaka.util.XmlUtils.findChildNS(
|
|
614
|
+
element.node, namespace, 'CryptoPeriod');
|
|
615
|
+
|
|
616
|
+
if (!cryptoPeriod) {
|
|
617
|
+
throw new shaka.util.Error(
|
|
618
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
619
|
+
shaka.util.Error.Category.MANIFEST,
|
|
620
|
+
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const ivHex = cryptoPeriod.getAttribute('IV');
|
|
624
|
+
const keyUri = cryptoPeriod.getAttribute('keyUriTemplate');
|
|
625
|
+
if (!ivHex || !keyUri) {
|
|
626
|
+
throw new shaka.util.Error(
|
|
627
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
628
|
+
shaka.util.Error.Category.MANIFEST,
|
|
629
|
+
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Exclude 0x at the start of string.
|
|
633
|
+
const iv = shaka.util.Uint8ArrayUtils.fromHex(ivHex.substr(2));
|
|
634
|
+
if (iv.byteLength != 16) {
|
|
635
|
+
throw new shaka.util.Error(
|
|
636
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
637
|
+
shaka.util.Error.Category.MANIFEST,
|
|
638
|
+
shaka.util.Error.Code.AES_128_INVALID_IV_LENGTH);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return {
|
|
642
|
+
keyUri,
|
|
643
|
+
iv,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
554
646
|
};
|
|
555
647
|
|
|
556
648
|
/**
|
|
@@ -584,6 +676,7 @@ shaka.dash.ContentProtection.PLAYREADY_RECORD_TYPES = {
|
|
|
584
676
|
* defaultKeyId: ?string,
|
|
585
677
|
* defaultInit: Array.<shaka.extern.InitDataOverride>,
|
|
586
678
|
* drmInfos: !Array.<shaka.extern.DrmInfo>,
|
|
679
|
+
* aes128Info: ?shaka.dash.ContentProtection.Aes128Info,
|
|
587
680
|
* firstRepresentation: boolean
|
|
588
681
|
* }}
|
|
589
682
|
*
|
|
@@ -599,6 +692,8 @@ shaka.dash.ContentProtection.PLAYREADY_RECORD_TYPES = {
|
|
|
599
692
|
* is no default.
|
|
600
693
|
* @property {!Array.<shaka.extern.DrmInfo>} drmInfos
|
|
601
694
|
* The DrmInfo objects.
|
|
695
|
+
* @property {?shaka.dash.ContentProtection.Aes128Info} aes128Info
|
|
696
|
+
* The AES-128 key info.
|
|
602
697
|
* @property {boolean} firstRepresentation
|
|
603
698
|
* True when first parsed; changed to false after the first call to
|
|
604
699
|
* parseKeyIds. This is used to determine if a dummy key-system should be
|
|
@@ -607,6 +702,22 @@ shaka.dash.ContentProtection.PLAYREADY_RECORD_TYPES = {
|
|
|
607
702
|
*/
|
|
608
703
|
shaka.dash.ContentProtection.Context;
|
|
609
704
|
|
|
705
|
+
/**
|
|
706
|
+
* @typedef {{
|
|
707
|
+
* keyUri: string,
|
|
708
|
+
* iv: !Uint8Array
|
|
709
|
+
* }}
|
|
710
|
+
*
|
|
711
|
+
* @description
|
|
712
|
+
* Contains information about the AES-128 keyUri and IV found at the
|
|
713
|
+
* AdaptationSet level.
|
|
714
|
+
*
|
|
715
|
+
* @property {string} method
|
|
716
|
+
* The keyUri in the manifest.
|
|
717
|
+
* @property {!Uint8Array} iv
|
|
718
|
+
* The IV in the manifest.
|
|
719
|
+
*/
|
|
720
|
+
shaka.dash.ContentProtection.Aes128Info;
|
|
610
721
|
|
|
611
722
|
/**
|
|
612
723
|
* @typedef {{
|
|
@@ -658,6 +769,13 @@ shaka.dash.ContentProtection.licenseUrlParsers_ = new Map()
|
|
|
658
769
|
shaka.dash.ContentProtection.MP4Protection_ =
|
|
659
770
|
'urn:mpeg:dash:mp4protection:2011';
|
|
660
771
|
|
|
772
|
+
/**
|
|
773
|
+
* @const {string}
|
|
774
|
+
* @private
|
|
775
|
+
*/
|
|
776
|
+
shaka.dash.ContentProtection.Aes128Protection_ =
|
|
777
|
+
'urn:mpeg:dash:sea:2012';
|
|
778
|
+
|
|
661
779
|
|
|
662
780
|
/**
|
|
663
781
|
* @const {string}
|