shaka-player 3.3.2 → 4.0.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/.csslintrc +11 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/pull_request_template.md +6 -34
- package/.github/workflows/build-and-test.yaml +129 -0
- package/.github/workflows/custom-actions/prep-for-appspot/action.yaml +56 -0
- package/.github/workflows/custom-actions/set-commit-status/action.yaml +41 -0
- package/.github/workflows/demo-version-index.yaml +37 -0
- package/.github/workflows/nightly-demo.yaml +42 -0
- package/.github/workflows/release-please.yaml +168 -0
- package/.github/workflows/safari-homedir-launcher.sh +18 -0
- package/.github/workflows/selenium-lab-tests.yaml +92 -0
- package/.github/workflows/sync-labels.yaml +33 -0
- package/.github/workflows/update-issues.yaml +29 -0
- package/.github/workflows/validate-pr-title.yaml +35 -0
- package/AUTHORS +3 -0
- package/CHANGELOG.md +1866 -1675
- package/CONTRIBUTING.md +2 -2
- package/CONTRIBUTORS +3 -0
- package/README.md +16 -13
- package/app-engine/README.md +9 -0
- package/app-engine/demo-version-index/README.md +14 -0
- package/app-engine/demo-version-index/app.yaml +28 -0
- package/app-engine/demo-version-index/generate.py +164 -0
- package/app-engine/demo-version-index/main.py +11 -0
- package/app-engine/demo-version-index/requirements.txt +5 -0
- package/app-engine/demo-version-index/templates/index.html +114 -0
- package/app-engine/shaka-player-demo/README.md +18 -0
- package/app-engine/shaka-player-demo/app.yaml +61 -0
- package/app-engine/shaka-player-demo/main.py +95 -0
- package/app-engine/shaka-player-demo/posters/10yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/10yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/1yo.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/2yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/2yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/3yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/3yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/4yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/4yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/5yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/5yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/6yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/6yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/7yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/7yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/8yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/8yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/9yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/9yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/audioOnly.gif +0 -0
- package/app-engine/shaka-player-demo/posters/audioRickRoll.gif +0 -0
- package/app-engine/shaka-player-demo/posters/colorbars.gif +0 -0
- package/app-engine/shaka-player-demo/posters/fireworks.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/party-hat.png +0 -0
- package/app-engine/shaka-player-demo/posters/sources.txt +46 -0
- package/app-engine/shaka-player-demo/posters/standard.png +0 -0
- package/app-engine/shaka-player-demo/posters/trek.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/valentines.png +0 -0
- package/app-engine/shaka-player-demo/posters/zombie.jpg +0 -0
- package/app-engine/shaka-player-demo/posters.py +110 -0
- package/app-engine/shaka-player-demo/requirements.txt +5 -0
- package/app-engine/shaka-player-demo/time.txt +1 -0
- package/build/README.md +3 -3
- package/build/checkversion.py +1 -1
- package/build/compiler.py +1 -1
- package/build/conformance.textproto +13 -0
- package/build/docker/Dockerfile +20 -0
- package/build/docker/docker-compose.yml +10 -0
- package/build/gendeps.py +18 -15
- package/build/shaka-lab.yaml +161 -0
- package/build/shakaBuildHelpers.py +4 -29
- package/build/test.py +94 -29
- package/build/types/core +0 -1
- package/build/types/polyfill +1 -3
- package/build/wrapper.template.js +2 -2
- package/demo/TengwarTelcontar.woff2 +0 -0
- package/demo/asset_card.js +1 -2
- package/demo/cast_receiver/index.html +1 -1
- package/demo/cast_receiver/receiver_app.css +14 -14
- package/demo/common/asset.js +17 -1
- package/demo/common/assets.js +31 -0
- package/demo/common/message_ids.js +6 -3
- package/demo/config.js +10 -12
- package/demo/custom.js +39 -1
- package/demo/customWarning.txt +2 -2
- package/demo/demo.less +29 -18
- package/demo/demo_uncompiled.js +1 -13
- package/demo/demo_utils.js +0 -1
- package/demo/index.html +1 -1
- package/demo/locales/en.json +6 -3
- package/demo/locales/source.json +22 -10
- package/demo/main.js +12 -9
- package/demo/search.js +2 -1
- package/dist/controls.css +3 -3
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +236 -232
- package/dist/demo.compiled.debug.map +4 -4
- package/dist/demo.compiled.js +236 -232
- package/dist/demo.compiled.map +4 -4
- package/dist/demo.css +1 -1
- package/dist/demo.css.map +1 -1
- package/dist/deps.js +229 -226
- package/dist/locales.js +34 -32
- package/dist/receiver.compiled.debug.js +75 -73
- package/dist/receiver.compiled.debug.map +4 -4
- package/dist/receiver.compiled.js +75 -73
- package/dist/receiver.compiled.map +4 -4
- package/dist/shaka-player.compiled.d.ts +321 -314
- package/dist/shaka-player.compiled.debug.d.ts +321 -314
- package/dist/shaka-player.compiled.debug.externs.js +140 -129
- package/dist/shaka-player.compiled.debug.js +527 -592
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +140 -129
- package/dist/shaka-player.compiled.js +836 -860
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +367 -358
- package/dist/shaka-player.ui.debug.d.ts +367 -358
- package/dist/shaka-player.ui.debug.externs.js +148 -129
- package/dist/shaka-player.ui.debug.js +586 -649
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +148 -129
- package/dist/shaka-player.ui.js +1008 -1028
- package/dist/shaka-player.ui.map +4 -4
- package/docs/design/REDESIGN.md +33 -33
- package/docs/design/bg-fetch.md +2 -2
- package/docs/design/codec_preferences.md +1 -1
- package/docs/design/dash-audio-channels.md +3 -3
- package/docs/design/dash-manifests.md +1 -1
- package/docs/design/gap-jumping.md +3 -3
- package/docs/design/preload.md +2 -2
- package/docs/tutorials/config.md +0 -2
- package/docs/tutorials/drm-config.md +5 -0
- package/docs/tutorials/fairplay.md +7 -22
- package/docs/tutorials/faq.md +8 -19
- package/docs/tutorials/index.json +3 -8
- package/docs/tutorials/plugins.md +4 -6
- package/docs/tutorials/selenium-grid-config.md +122 -0
- package/docs/tutorials/upgrade.md +83 -11
- package/docs/tutorials/welcome.md +10 -2
- package/externs/cmcd.js +1 -1
- package/externs/polyfill.js +15 -0
- package/externs/shaka/manifest.js +5 -1
- package/externs/shaka/net.js +12 -0
- package/externs/shaka/offline.js +5 -1
- package/externs/shaka/player.js +39 -32
- package/externs/shaka/text.js +12 -12
- package/externs/sourcebuffer.js +15 -0
- package/karma.conf.js +137 -30
- package/lib/abr/simple_abr_manager.js +12 -6
- package/lib/ads/client_side_ad.js +13 -2
- package/lib/ads/client_side_ad_manager.js +22 -4
- package/lib/cast/cast_proxy.js +3 -4
- package/lib/cast/cast_utils.js +0 -1
- package/lib/cea/cea608_data_channel.js +2 -2
- package/lib/cea/cea708_service.js +5 -4
- package/lib/cea/mp4_cea_parser.js +11 -5
- package/lib/cea/sei_processor.js +6 -3
- package/lib/dash/content_protection.js +85 -5
- package/lib/dash/dash_parser.js +10 -12
- package/lib/dash/mpd_utils.js +4 -5
- package/lib/dash/segment_list.js +1 -2
- package/lib/dash/segment_template.js +3 -3
- package/lib/hls/hls_parser.js +386 -749
- package/lib/hls/manifest_text_parser.js +5 -6
- package/lib/media/adaptation_set.js +1 -2
- package/lib/media/content_workarounds.js +2 -2
- package/lib/media/drm_engine.js +105 -55
- package/lib/media/gap_jumping_controller.js +10 -45
- package/lib/media/media_source_engine.js +90 -17
- package/lib/media/mp4_segment_index_parser.js +1 -4
- package/lib/media/playhead.js +4 -7
- package/lib/media/presentation_timeline.js +19 -10
- package/lib/media/segment_index.js +13 -46
- package/lib/media/segment_reference.js +47 -1
- package/lib/media/streaming_engine.js +35 -17
- package/lib/media/time_ranges_utils.js +5 -12
- package/lib/media/video_wrapper.js +1 -1
- package/lib/net/networking_engine.js +4 -1
- package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
- package/lib/offline/manifest_converter.js +1 -0
- package/lib/offline/storage.js +104 -136
- package/lib/player.js +50 -216
- package/lib/polyfill/all.js +2 -3
- package/lib/polyfill/encryption_scheme.js +1 -1
- package/lib/polyfill/media_capabilities.js +15 -9
- package/lib/polyfill/mediasource.js +0 -28
- package/lib/polyfill/patchedmediakeys_nop.js +2 -0
- package/lib/polyfill/patchedmediakeys_webkit.js +2 -0
- package/lib/polyfill/symbol.js +46 -0
- package/lib/text/cue.js +1 -7
- package/lib/text/lrc_text_parser.js +8 -0
- package/lib/text/mp4_ttml_parser.js +8 -0
- package/lib/text/mp4_vtt_parser.js +8 -0
- package/lib/text/sbv_text_parser.js +8 -0
- package/lib/text/simple_text_displayer.js +3 -8
- package/lib/text/srt_text_parser.js +8 -0
- package/lib/text/ssa_text_parser.js +8 -0
- package/lib/text/text_engine.js +19 -3
- package/lib/text/ttml_text_parser.js +16 -5
- package/lib/text/ui_text_displayer.js +2 -8
- package/lib/text/vtt_text_parser.js +24 -2
- package/lib/text/web_vtt_generator.js +1 -7
- package/lib/util/buffer_utils.js +1 -3
- package/lib/util/ebml_parser.js +3 -3
- package/lib/util/error.js +10 -14
- package/lib/util/fairplay_utils.js +109 -0
- package/lib/util/functional.js +0 -42
- package/lib/util/iterables.js +0 -46
- package/lib/util/mime_utils.js +2 -0
- package/lib/util/mp4_box_parsers.js +1 -4
- package/lib/util/mp4_parser.js +5 -7
- package/lib/util/periods.js +10 -11
- package/lib/util/platform.js +48 -3
- package/lib/util/player_configuration.js +12 -6
- package/lib/util/pssh.js +24 -8
- package/lib/util/stream_utils.js +96 -25
- package/lib/util/string_utils.js +3 -5
- package/lib/util/uint8array_utils.js +3 -21
- package/lib/util/xml_utils.js +16 -8
- package/package.json +61 -36
- package/roadmap.md +27 -27
- package/shaka-player.uncompiled.js +1 -3
- package/test/abr/simple_abr_manager_unit.js +3 -8
- package/test/ads/ad_manager_unit.js +0 -6
- package/test/cast/cast_proxy_unit.js +0 -8
- package/test/cast/cast_receiver_integration.js +1 -18
- package/test/cast/cast_receiver_unit.js +1 -9
- package/test/cast/cast_sender_unit.js +0 -6
- package/test/cast/cast_utils_unit.js +1 -13
- package/test/cea/cea608_memory_unit.js +0 -5
- package/test/cea/cea708_service_unit.js +0 -7
- package/test/cea/cea708_window_unit.js +0 -5
- package/test/cea/cea_decoder_unit.js +0 -6
- package/test/cea/dtvcc_packet_builder_unit.js +0 -3
- package/test/cea/dtvcc_packet_unit.js +0 -5
- package/test/cea/mp4_cea_parser_unit.js +0 -4
- package/test/dash/dash_parser_content_protection_unit.js +45 -10
- package/test/dash/dash_parser_live_unit.js +2 -15
- package/test/dash/dash_parser_manifest_unit.js +2 -40
- package/test/dash/dash_parser_segment_base_unit.js +1 -8
- package/test/dash/dash_parser_segment_list_unit.js +1 -7
- package/test/dash/dash_parser_segment_template_unit.js +3 -13
- package/test/dash/mpd_utils_unit.js +3 -11
- package/test/demo/demo_unit.js +2 -6
- package/test/deprecate/enforcer_unit.js +0 -4
- package/test/deprecate/version_unit.js +0 -2
- package/test/hls/hls_live_unit.js +101 -234
- package/test/hls/hls_parser_unit.js +517 -447
- package/test/hls/manifest_text_parser_unit.js +0 -10
- package/test/media/adaptation_set_criteria_unit.js +3 -7
- package/test/media/adaptation_set_unit.js +0 -2
- package/test/media/buffering_observer_unit.js +1 -4
- package/test/media/closed_caption_parser_unit.js +0 -3
- package/test/media/drm_engine_integration.js +2 -15
- package/test/media/drm_engine_unit.js +90 -144
- package/test/media/manifest_parser_unit.js +0 -4
- package/test/media/media_source_engine_integration.js +26 -10
- package/test/media/media_source_engine_unit.js +8 -20
- package/test/media/mp4_segment_index_parser_unit.js +0 -4
- package/test/media/play_rate_controller_unit.js +0 -4
- package/test/media/playhead_unit.js +35 -207
- package/test/media/presentation_timeline_unit.js +4 -7
- package/test/media/quality_observer_unit.js +0 -4
- package/test/media/region_observer_unit.js +1 -6
- package/test/media/region_timeline_unit.js +0 -3
- package/test/media/segment_index_unit.js +15 -31
- package/test/media/segment_reference_unit.js +0 -3
- package/test/media/stall_detector_unit.js +0 -5
- package/test/media/streaming_engine_integration.js +13 -75
- package/test/media/streaming_engine_unit.js +14 -37
- package/test/media/time_ranges_utils_unit.js +0 -7
- package/test/media/transmuxer_integration.js +0 -6
- package/test/media/webm_segment_index_parser_unit.js +0 -4
- package/test/net/data_uri_plugin_unit.js +0 -7
- package/test/net/http_plugin_unit.js +0 -9
- package/test/net/networking_engine_unit.js +0 -11
- package/test/offline/download_progress_estimator_unit.js +0 -2
- package/test/offline/indexeddb_storage_unit.js +0 -6
- package/test/offline/manifest_convert_unit.js +34 -12
- package/test/offline/offline_integration.js +1 -10
- package/test/offline/offline_manifest_parser_unit.js +1 -6
- package/test/offline/offline_scheme_unit.js +0 -8
- package/test/offline/offline_uri_unit.js +0 -2
- package/test/offline/storage_compatibility_unit.js +1 -14
- package/test/offline/storage_integration.js +6 -31
- package/test/player_external.js +1 -15
- package/test/player_integration.js +38 -28
- package/test/player_load_graph_integration.js +1 -6
- package/test/player_src_equals_external.js +3 -9
- package/test/player_src_equals_integration.js +0 -7
- package/test/player_unit.js +78 -37
- package/test/routing/walker_unit.js +0 -8
- package/test/test/assets/large_file.mpd +1 -1
- package/test/test/boot.js +75 -22
- package/test/test/externs/jasmine.js +2 -2
- package/test/test/externs/karma.js +4 -0
- package/test/test/namespace.js +10 -0
- package/test/test/util/canned_idb.js +0 -8
- package/test/test/util/cea_utils.js +0 -6
- package/test/test/util/dash_parser_util.js +0 -13
- package/test/test/util/fake_ad.js +0 -3
- package/test/test/util/fake_ad_manager.js +0 -9
- package/test/test/util/fake_demo_main.js +0 -5
- package/test/test/util/fake_drm_engine.js +0 -6
- package/test/test/util/fake_media_source_engine.js +11 -11
- package/test/test/util/fake_networking_engine.js +0 -5
- package/test/test/util/fake_text_displayer.js +0 -5
- package/test/test/util/indexeddb_utils.js +1 -10
- package/test/test/util/jasmine_fetch.js +0 -1
- package/test/test/util/loader.js +0 -18
- package/test/test/util/manifest_generator.js +12 -15
- package/test/test/util/manifest_parser_util.js +4 -7
- package/test/test/util/offline_utils.js +1 -5
- package/test/test/util/simple_fakes.js +9 -26
- package/test/test/util/stream_generator.js +0 -14
- package/test/test/util/streaming_engine_util.js +1 -15
- package/test/test/util/test_scheme.js +25 -20
- package/test/test/util/ttml_utils.js +0 -2
- package/test/test/util/ui_utils.js +0 -9
- package/test/test/util/util.js +9 -23
- package/test/test/util/waiter.js +84 -43
- package/test/text/cue_integration.js +2 -6
- package/test/text/lrc_text_parser_unit.js +6 -11
- package/test/text/mp4_ttml_parser_unit.js +6 -10
- package/test/text/mp4_vtt_parser_unit.js +7 -12
- package/test/text/sbv_text_parser_unit.js +5 -10
- package/test/text/simple_text_displayer_unit.js +1 -8
- package/test/text/srt_text_parser_unit.js +5 -10
- package/test/text/ssa_text_parser_unit.js +17 -34
- package/test/text/text_engine_unit.js +47 -12
- package/test/text/text_track_integration.js +0 -2
- package/test/text/ttml_text_parser_unit.js +79 -88
- package/test/text/ui_text_displayer_unit.js +44 -41
- package/test/text/vtt_text_parser_unit.js +55 -66
- package/test/text/web_vtt_generator_unit.js +0 -3
- package/test/ui/ad_ui_unit.js +0 -11
- package/test/ui/localization_unit.js +0 -3
- package/test/ui/text_displayer_layout_unit.js +1 -12
- package/test/ui/ui_customization_unit.js +0 -6
- package/test/ui/ui_integration.js +0 -32
- package/test/ui/ui_unit.js +28 -17
- package/test/util/abortable_operation_unit.js +4 -9
- package/test/util/array_utils_unit.js +0 -2
- package/test/util/buffer_utils_unit.js +0 -2
- package/test/util/cmcd_manager_unit.js +3 -3
- package/test/util/data_view_reader_unit.js +0 -4
- package/test/util/ebml_parser_unit.js +0 -4
- package/test/util/event_manager_unit.js +0 -3
- package/test/util/fake_event_target_unit.js +0 -5
- package/test/util/iterables_unit.js +0 -64
- package/test/util/language_utils_unit.js +0 -3
- package/test/util/manifest_parser_utils_unit.js +0 -2
- package/test/util/mp4_box_parsers_unit.js +0 -5
- package/test/util/mp4_parser_unit.js +0 -4
- package/test/util/multi_map_unit.js +0 -3
- package/test/util/object_utils_unit.js +0 -2
- package/test/util/periods_unit.js +14 -7
- package/test/util/pssh_unit.js +0 -5
- package/test/util/state_history_unit.js +0 -2
- package/test/util/stream_utils_unit.js +26 -15
- package/test/util/string_utils_unit.js +0 -6
- package/test/util/text_parser_unit.js +0 -2
- package/test/util/xml_utils_unit.js +0 -4
- package/ui/controls.js +65 -40
- package/ui/fullscreen_button.js +26 -6
- package/ui/less/ad_controls.less +6 -6
- package/ui/less/buttons.less +6 -6
- package/ui/less/containers.less +10 -12
- package/ui/less/overflow_menu.less +4 -4
- package/ui/less/range_elements.less +7 -2
- package/ui/less/tooltip.less +4 -4
- package/ui/locales/en.json +1 -0
- package/ui/locales/sjn-translations.yaml +257 -0
- package/ui/locales/sjn.json +42 -0
- package/ui/locales/source.json +5 -0
- package/ui/resolution_selection.js +31 -33
- package/ui/seek_bar.js +2 -1
- package/ui/ui.js +0 -17
- package/.github/workflows/build_and_test.yaml +0 -73
- package/.github/workflows/release.yaml +0 -53
- package/docs/tutorials/upgrade-v2-5.md +0 -441
- package/docs/tutorials/upgrade-v3.md +0 -38
- package/externs/svgelement.js +0 -18
- package/externs/webcrypto.js +0 -18
- package/lib/polyfill/mathround.js +0 -49
- package/lib/polyfill/patchedmediakeys_apple.js +0 -744
- package/lib/polyfill/patchedmediakeys_ms.js +0 -698
- package/lib/util/mutex.js +0 -52
- package/test/util/functional_unit.js +0 -82
|
@@ -1,698 +0,0 @@
|
|
|
1
|
-
/*! @license
|
|
2
|
-
* Shaka Player
|
|
3
|
-
* Copyright 2016 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
goog.provide('shaka.polyfill.PatchedMediaKeysMs');
|
|
8
|
-
|
|
9
|
-
goog.require('goog.asserts');
|
|
10
|
-
goog.require('shaka.log');
|
|
11
|
-
goog.require('shaka.media.DrmEngine');
|
|
12
|
-
goog.require('shaka.polyfill');
|
|
13
|
-
goog.require('shaka.util.BufferUtils');
|
|
14
|
-
goog.require('shaka.util.EventManager');
|
|
15
|
-
goog.require('shaka.util.FakeEvent');
|
|
16
|
-
goog.require('shaka.util.FakeEventTarget');
|
|
17
|
-
goog.require('shaka.util.MediaReadyState');
|
|
18
|
-
goog.require('shaka.util.Pssh');
|
|
19
|
-
goog.require('shaka.util.PublicPromise');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @summary A polyfill to implement
|
|
24
|
-
* {@link https://bit.ly/EmeMar15 EME draft 12 March 2015}
|
|
25
|
-
* on top of ms-prefixed
|
|
26
|
-
* {@link https://www.w3.org/TR/2014/WD-encrypted-media-20140218/ EME v20140218}
|
|
27
|
-
* @export
|
|
28
|
-
*/
|
|
29
|
-
shaka.polyfill.PatchedMediaKeysMs = class {
|
|
30
|
-
/**
|
|
31
|
-
* Installs the polyfill if needed.
|
|
32
|
-
* @export
|
|
33
|
-
*/
|
|
34
|
-
static install() {
|
|
35
|
-
if (!window.HTMLVideoElement || !window.MSMediaKeys ||
|
|
36
|
-
(navigator.requestMediaKeySystemAccess &&
|
|
37
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
38
|
-
MediaKeySystemAccess.prototype.getConfiguration)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
shaka.log.info('Using ms-prefixed EME v20140218');
|
|
42
|
-
|
|
43
|
-
// Alias
|
|
44
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
45
|
-
|
|
46
|
-
// Delete mediaKeys to work around strict mode compatibility issues.
|
|
47
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
48
|
-
delete HTMLMediaElement.prototype['mediaKeys'];
|
|
49
|
-
// Work around read-only declaration for mediaKeys by using a string.
|
|
50
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
51
|
-
HTMLMediaElement.prototype['mediaKeys'] = null;
|
|
52
|
-
|
|
53
|
-
// Install patches
|
|
54
|
-
window.MediaKeys = PatchedMediaKeysMs.MediaKeys;
|
|
55
|
-
window.MediaKeySystemAccess = PatchedMediaKeysMs.MediaKeySystemAccess;
|
|
56
|
-
navigator.requestMediaKeySystemAccess =
|
|
57
|
-
PatchedMediaKeysMs.requestMediaKeySystemAccess;
|
|
58
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
59
|
-
HTMLMediaElement.prototype.setMediaKeys =
|
|
60
|
-
PatchedMediaKeysMs.MediaKeySystemAccess.setMediaKeys;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* An implementation of navigator.requestMediaKeySystemAccess.
|
|
65
|
-
* Retrieves a MediaKeySystemAccess object.
|
|
66
|
-
*
|
|
67
|
-
* @this {!Navigator}
|
|
68
|
-
* @param {string} keySystem
|
|
69
|
-
* @param {!Array.<!MediaKeySystemConfiguration>} supportedConfigurations
|
|
70
|
-
* @return {!Promise.<!MediaKeySystemAccess>}
|
|
71
|
-
*/
|
|
72
|
-
static requestMediaKeySystemAccess(keySystem, supportedConfigurations) {
|
|
73
|
-
shaka.log.debug('PatchedMediaKeysMs.requestMediaKeySystemAccess');
|
|
74
|
-
goog.asserts.assert(this == navigator,
|
|
75
|
-
'bad "this" for requestMediaKeySystemAccess');
|
|
76
|
-
|
|
77
|
-
// Alias.
|
|
78
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
79
|
-
try {
|
|
80
|
-
const access = new PatchedMediaKeysMs.MediaKeySystemAccess(
|
|
81
|
-
keySystem, supportedConfigurations);
|
|
82
|
-
return Promise.resolve(/** @type {!MediaKeySystemAccess} */ (access));
|
|
83
|
-
} catch (exception) {
|
|
84
|
-
return Promise.reject(exception);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Handler for the native media elements msNeedKey event.
|
|
90
|
-
*
|
|
91
|
-
* @this {!HTMLMediaElement}
|
|
92
|
-
* @param {!MediaKeyEvent} event
|
|
93
|
-
* @suppress {constantProperty} We reassign what would be const on a real
|
|
94
|
-
* MediaEncryptedEvent, but in our look-alike event.
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
static onMsNeedKey_(event) {
|
|
98
|
-
shaka.log.debug('PatchedMediaKeysMs.onMsNeedKey_', event);
|
|
99
|
-
if (!event.initData) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const event2 = new CustomEvent('encrypted');
|
|
104
|
-
const encryptedEvent =
|
|
105
|
-
/** @type {!MediaEncryptedEvent} */(/** @type {?} */(event2));
|
|
106
|
-
encryptedEvent.initDataType = 'cenc';
|
|
107
|
-
encryptedEvent.initData = shaka.util.BufferUtils.toArrayBuffer(
|
|
108
|
-
shaka.util.Pssh.normaliseInitData(event.initData));
|
|
109
|
-
|
|
110
|
-
this.dispatchEvent(event2);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* An implementation of MediaKeySystemAccess.
|
|
117
|
-
*
|
|
118
|
-
* @implements {MediaKeySystemAccess}
|
|
119
|
-
*/
|
|
120
|
-
shaka.polyfill.PatchedMediaKeysMs.MediaKeySystemAccess = class {
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} keySystem
|
|
123
|
-
* @param {!Array.<!MediaKeySystemConfiguration>} supportedConfigurations
|
|
124
|
-
*/
|
|
125
|
-
constructor(keySystem, supportedConfigurations) {
|
|
126
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySystemAccess');
|
|
127
|
-
|
|
128
|
-
/** @type {string} */
|
|
129
|
-
this.keySystem = keySystem;
|
|
130
|
-
|
|
131
|
-
/** @private {!MediaKeySystemConfiguration} */
|
|
132
|
-
this.configuration_;
|
|
133
|
-
|
|
134
|
-
const allowPersistentState = false;
|
|
135
|
-
|
|
136
|
-
let success = false;
|
|
137
|
-
for (const cfg of supportedConfigurations) {
|
|
138
|
-
// Create a new config object and start adding in the pieces which we
|
|
139
|
-
// find support for. We will return this from getConfiguration() if
|
|
140
|
-
// asked.
|
|
141
|
-
/** @type {!MediaKeySystemConfiguration} */
|
|
142
|
-
const newCfg = {
|
|
143
|
-
'audioCapabilities': [],
|
|
144
|
-
'videoCapabilities': [],
|
|
145
|
-
// It is technically against spec to return these as optional, but we
|
|
146
|
-
// don't truly know their values from the prefixed API:
|
|
147
|
-
'persistentState': 'optional',
|
|
148
|
-
'distinctiveIdentifier': 'optional',
|
|
149
|
-
// Pretend the requested init data types are supported, since we don't
|
|
150
|
-
// really know that either:
|
|
151
|
-
'initDataTypes': cfg.initDataTypes,
|
|
152
|
-
'sessionTypes': ['temporary'],
|
|
153
|
-
'label': cfg.label,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// PatchedMediaKeysMs tests for key system availability through
|
|
157
|
-
// MSMediaKeys.isTypeSupported
|
|
158
|
-
let ranAnyTests = false;
|
|
159
|
-
if (cfg.audioCapabilities) {
|
|
160
|
-
for (const cap of cfg.audioCapabilities) {
|
|
161
|
-
if (cap.contentType) {
|
|
162
|
-
ranAnyTests = true;
|
|
163
|
-
const contentType = cap.contentType.split(';')[0];
|
|
164
|
-
if (MSMediaKeys.isTypeSupported(this.keySystem, contentType)) {
|
|
165
|
-
newCfg.audioCapabilities.push(cap);
|
|
166
|
-
success = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (cfg.videoCapabilities) {
|
|
172
|
-
for (const cap of cfg.videoCapabilities) {
|
|
173
|
-
if (cap.contentType) {
|
|
174
|
-
ranAnyTests = true;
|
|
175
|
-
const contentType = cap.contentType.split(';')[0];
|
|
176
|
-
if (MSMediaKeys.isTypeSupported(this.keySystem, contentType)) {
|
|
177
|
-
newCfg.videoCapabilities.push(cap);
|
|
178
|
-
success = true;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (!ranAnyTests) {
|
|
185
|
-
// If no specific types were requested, we check all common types to
|
|
186
|
-
// find out if the key system is present at all.
|
|
187
|
-
success = MSMediaKeys.isTypeSupported(this.keySystem, 'video/mp4');
|
|
188
|
-
}
|
|
189
|
-
if (cfg.persistentState == 'required') {
|
|
190
|
-
if (allowPersistentState) {
|
|
191
|
-
newCfg.persistentState = 'required';
|
|
192
|
-
newCfg.sessionTypes = ['persistent-license'];
|
|
193
|
-
} else {
|
|
194
|
-
success = false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (success) {
|
|
199
|
-
this.configuration_ = newCfg;
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
} // for each cfg in supportedConfigurations
|
|
203
|
-
|
|
204
|
-
// According to the spec, this should be a DOMException, but there is not a
|
|
205
|
-
// public constructor for that. So we make this look-alike instead.
|
|
206
|
-
const unsupportedKeySystemError = new Error('Unsupported keySystem');
|
|
207
|
-
unsupportedKeySystemError.name = 'NotSupportedError';
|
|
208
|
-
unsupportedKeySystemError['code'] = DOMException.NOT_SUPPORTED_ERR;
|
|
209
|
-
throw unsupportedKeySystemError;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** @override */
|
|
213
|
-
createMediaKeys() {
|
|
214
|
-
shaka.log.debug(
|
|
215
|
-
'PatchedMediaKeysMs.MediaKeySystemAccess.createMediaKeys');
|
|
216
|
-
|
|
217
|
-
// Alias
|
|
218
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
219
|
-
|
|
220
|
-
const mediaKeys = new PatchedMediaKeysMs.MediaKeys(this.keySystem);
|
|
221
|
-
return Promise.resolve(/** @type {!MediaKeys} */ (mediaKeys));
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** @override */
|
|
225
|
-
getConfiguration() {
|
|
226
|
-
shaka.log.debug(
|
|
227
|
-
'PatchedMediaKeysMs.MediaKeySystemAccess.getConfiguration');
|
|
228
|
-
return this.configuration_;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* An implementation of HTMLMediaElement.prototype.setMediaKeys.
|
|
233
|
-
* Attaches a MediaKeys object to the media element.
|
|
234
|
-
*
|
|
235
|
-
* @this {!HTMLMediaElement}
|
|
236
|
-
* @param {MediaKeys} mediaKeys
|
|
237
|
-
* @return {!Promise}
|
|
238
|
-
*/
|
|
239
|
-
static setMediaKeys(mediaKeys) {
|
|
240
|
-
shaka.log.debug('PatchedMediaKeysMs.setMediaKeys');
|
|
241
|
-
goog.asserts.assert(this instanceof HTMLMediaElement,
|
|
242
|
-
'bad "this" for setMediaKeys');
|
|
243
|
-
|
|
244
|
-
// Alias
|
|
245
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
246
|
-
|
|
247
|
-
const newMediaKeys =
|
|
248
|
-
/** @type {shaka.polyfill.PatchedMediaKeysMs.MediaKeys} */ (
|
|
249
|
-
mediaKeys);
|
|
250
|
-
const oldMediaKeys =
|
|
251
|
-
/** @type {shaka.polyfill.PatchedMediaKeysMs.MediaKeys} */ (
|
|
252
|
-
this.mediaKeys);
|
|
253
|
-
|
|
254
|
-
if (oldMediaKeys && oldMediaKeys != newMediaKeys) {
|
|
255
|
-
goog.asserts.assert(oldMediaKeys instanceof PatchedMediaKeysMs.MediaKeys,
|
|
256
|
-
'non-polyfill instance of oldMediaKeys');
|
|
257
|
-
// Have the old MediaKeys stop listening to events on the video tag.
|
|
258
|
-
oldMediaKeys.setMedia(null);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
delete this['mediaKeys']; // in case there is an existing getter
|
|
262
|
-
this['mediaKeys'] = mediaKeys; // work around read-only declaration
|
|
263
|
-
|
|
264
|
-
if (newMediaKeys) {
|
|
265
|
-
goog.asserts.assert(newMediaKeys instanceof PatchedMediaKeysMs.MediaKeys,
|
|
266
|
-
'non-polyfill instance of newMediaKeys');
|
|
267
|
-
return newMediaKeys.setMedia(this);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return Promise.resolve();
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* An implementation of MediaKeys.
|
|
277
|
-
*
|
|
278
|
-
* @implements {MediaKeys}
|
|
279
|
-
*/
|
|
280
|
-
shaka.polyfill.PatchedMediaKeysMs.MediaKeys = class {
|
|
281
|
-
/** @param {string} keySystem */
|
|
282
|
-
constructor(keySystem) {
|
|
283
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeys');
|
|
284
|
-
|
|
285
|
-
/** @private {!MSMediaKeys} */
|
|
286
|
-
this.nativeMediaKeys_ = new MSMediaKeys(keySystem);
|
|
287
|
-
|
|
288
|
-
/** @private {!shaka.util.EventManager} */
|
|
289
|
-
this.eventManager_ = new shaka.util.EventManager();
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/** @override */
|
|
293
|
-
createSession(sessionType) {
|
|
294
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeys.createSession');
|
|
295
|
-
|
|
296
|
-
sessionType = sessionType || 'temporary';
|
|
297
|
-
// For now, only the 'temporary' type is supported.
|
|
298
|
-
if (sessionType != 'temporary') {
|
|
299
|
-
throw new TypeError('Session type ' + sessionType +
|
|
300
|
-
' is unsupported on this platform.');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Alias
|
|
304
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
305
|
-
|
|
306
|
-
return new PatchedMediaKeysMs.MediaKeySession(
|
|
307
|
-
this.nativeMediaKeys_, sessionType);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/** @override */
|
|
311
|
-
setServerCertificate(serverCertificate) {
|
|
312
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeys.setServerCertificate');
|
|
313
|
-
|
|
314
|
-
// There is no equivalent in PatchedMediaKeysMs, so return failure.
|
|
315
|
-
return Promise.resolve(false);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* @param {HTMLMediaElement} media
|
|
320
|
-
* @protected
|
|
321
|
-
* @return {!Promise}
|
|
322
|
-
*/
|
|
323
|
-
setMedia(media) {
|
|
324
|
-
// Alias
|
|
325
|
-
const PatchedMediaKeysMs = shaka.polyfill.PatchedMediaKeysMs;
|
|
326
|
-
|
|
327
|
-
// Remove any old listeners.
|
|
328
|
-
this.eventManager_.removeAll();
|
|
329
|
-
|
|
330
|
-
// It is valid for media to be null; null is used to flag that event
|
|
331
|
-
// handlers need to be cleaned up.
|
|
332
|
-
if (!media) {
|
|
333
|
-
return Promise.resolve();
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Intercept and translate these prefixed EME events.
|
|
337
|
-
this.eventManager_.listen(media, 'msneedkey',
|
|
338
|
-
/** @type {shaka.util.EventManager.ListenerType} */
|
|
339
|
-
(PatchedMediaKeysMs.onMsNeedKey_));
|
|
340
|
-
|
|
341
|
-
// Wrap native HTMLMediaElement.msSetMediaKeys with a Promise.
|
|
342
|
-
try {
|
|
343
|
-
// Edge requires that readyState >=1 before mediaKeys can be set,
|
|
344
|
-
// so check this and wait for loadedmetadata if we are not in the
|
|
345
|
-
// correct state
|
|
346
|
-
shaka.util.MediaReadyState.waitForReadyState(media,
|
|
347
|
-
HTMLMediaElement.HAVE_METADATA,
|
|
348
|
-
this.eventManager_, () => {
|
|
349
|
-
media.msSetMediaKeys(this.nativeMediaKeys_);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
return Promise.resolve();
|
|
353
|
-
} catch (exception) {
|
|
354
|
-
return Promise.reject(exception);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* An implementation of MediaKeySession.
|
|
362
|
-
*
|
|
363
|
-
* @implements {MediaKeySession}
|
|
364
|
-
*/
|
|
365
|
-
shaka.polyfill.PatchedMediaKeysMs.MediaKeySession =
|
|
366
|
-
class extends shaka.util.FakeEventTarget {
|
|
367
|
-
/**
|
|
368
|
-
* @param {MSMediaKeys} nativeMediaKeys
|
|
369
|
-
* @param {string} sessionType
|
|
370
|
-
*/
|
|
371
|
-
constructor(nativeMediaKeys, sessionType) {
|
|
372
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession');
|
|
373
|
-
super();
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* The native MediaKeySession, which will be created in generateRequest.
|
|
377
|
-
* @private {MSMediaKeySession}
|
|
378
|
-
*/
|
|
379
|
-
this.nativeMediaKeySession_ = null;
|
|
380
|
-
|
|
381
|
-
/** @private {MSMediaKeys} */
|
|
382
|
-
this.nativeMediaKeys_ = nativeMediaKeys;
|
|
383
|
-
|
|
384
|
-
// Promises that are resolved later
|
|
385
|
-
/** @private {shaka.util.PublicPromise} */
|
|
386
|
-
this.generateRequestPromise_ = null;
|
|
387
|
-
|
|
388
|
-
/** @private {shaka.util.PublicPromise} */
|
|
389
|
-
this.updatePromise_ = null;
|
|
390
|
-
|
|
391
|
-
/** @private {!shaka.util.EventManager} */
|
|
392
|
-
this.eventManager_ = new shaka.util.EventManager();
|
|
393
|
-
|
|
394
|
-
/** @type {string} */
|
|
395
|
-
this.sessionId = '';
|
|
396
|
-
|
|
397
|
-
/** @type {number} */
|
|
398
|
-
this.expiration = NaN;
|
|
399
|
-
|
|
400
|
-
/** @type {!shaka.util.PublicPromise} */
|
|
401
|
-
this.closed = new shaka.util.PublicPromise();
|
|
402
|
-
|
|
403
|
-
/** @type {!shaka.polyfill.PatchedMediaKeysMs.MediaKeyStatusMap} */
|
|
404
|
-
this.keyStatuses =
|
|
405
|
-
new shaka.polyfill.PatchedMediaKeysMs.MediaKeyStatusMap();
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/** @override */
|
|
409
|
-
generateRequest(initDataType, initData) {
|
|
410
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession.generateRequest');
|
|
411
|
-
|
|
412
|
-
this.generateRequestPromise_ = new shaka.util.PublicPromise();
|
|
413
|
-
|
|
414
|
-
try {
|
|
415
|
-
// This EME spec version requires a MIME content type as the 1st param to
|
|
416
|
-
// createSession, but doesn't seem to matter what the value is.
|
|
417
|
-
|
|
418
|
-
// NOTE: Edge 12 only accepts Uint8Array.
|
|
419
|
-
this.nativeMediaKeySession_ = this.nativeMediaKeys_.createSession(
|
|
420
|
-
'video/mp4', shaka.util.BufferUtils.toUint8(initData), null);
|
|
421
|
-
|
|
422
|
-
// Attach session event handlers here.
|
|
423
|
-
this.eventManager_.listen(this.nativeMediaKeySession_, 'mskeymessage',
|
|
424
|
-
/** @type {shaka.util.EventManager.ListenerType} */
|
|
425
|
-
((event) => this.onMsKeyMessage_(event)));
|
|
426
|
-
this.eventManager_.listen(this.nativeMediaKeySession_, 'mskeyadded',
|
|
427
|
-
/** @type {shaka.util.EventManager.ListenerType} */
|
|
428
|
-
((event) => this.onMsKeyAdded_(event)));
|
|
429
|
-
this.eventManager_.listen(this.nativeMediaKeySession_, 'mskeyerror',
|
|
430
|
-
/** @type {shaka.util.EventManager.ListenerType} */
|
|
431
|
-
((event) => this.onMsKeyError_(event)));
|
|
432
|
-
|
|
433
|
-
this.updateKeyStatus_('status-pending');
|
|
434
|
-
} catch (exception) {
|
|
435
|
-
this.generateRequestPromise_.reject(exception);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return this.generateRequestPromise_;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/** @override */
|
|
442
|
-
load() {
|
|
443
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession.load');
|
|
444
|
-
|
|
445
|
-
return Promise.reject(new Error('MediaKeySession.load not yet supported'));
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/** @override */
|
|
449
|
-
update(response) {
|
|
450
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession.update');
|
|
451
|
-
|
|
452
|
-
this.updatePromise_ = new shaka.util.PublicPromise();
|
|
453
|
-
|
|
454
|
-
try {
|
|
455
|
-
// Pass through to the native session.
|
|
456
|
-
// NOTE: Edge 12 only accepts Uint8Array.
|
|
457
|
-
this.nativeMediaKeySession_.update(
|
|
458
|
-
shaka.util.BufferUtils.toUint8(response));
|
|
459
|
-
} catch (exception) {
|
|
460
|
-
this.updatePromise_.reject(exception);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return this.updatePromise_;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/** @override */
|
|
467
|
-
close() {
|
|
468
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession.close');
|
|
469
|
-
|
|
470
|
-
try {
|
|
471
|
-
// Pass through to the native session.
|
|
472
|
-
// NOTE: IE seems to have a spec discrepancy here - v2010218 should have
|
|
473
|
-
// MediaKeySession.release, but actually uses "close". The next version of
|
|
474
|
-
// the spec is the initial Promise based one, so it's not the target spec
|
|
475
|
-
// either.
|
|
476
|
-
this.nativeMediaKeySession_.close();
|
|
477
|
-
|
|
478
|
-
this.closed.resolve();
|
|
479
|
-
this.eventManager_.removeAll();
|
|
480
|
-
} catch (exception) {
|
|
481
|
-
this.closed.reject(exception);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return this.closed;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/** @override */
|
|
488
|
-
remove() {
|
|
489
|
-
shaka.log.debug('PatchedMediaKeysMs.MediaKeySession.remove');
|
|
490
|
-
|
|
491
|
-
return Promise.reject(new Error(
|
|
492
|
-
'MediaKeySession.remove is only applicable for persistent licenses, ' +
|
|
493
|
-
'which are not supported on this platform'));
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Handler for the native keymessage event on MSMediaKeySession.
|
|
498
|
-
*
|
|
499
|
-
* @param {!MediaKeyEvent} event
|
|
500
|
-
* @private
|
|
501
|
-
*/
|
|
502
|
-
onMsKeyMessage_(event) {
|
|
503
|
-
shaka.log.debug('PatchedMediaKeysMs.onMsKeyMessage_', event);
|
|
504
|
-
|
|
505
|
-
// We can now resolve this.generateRequestPromise, which should be non-null.
|
|
506
|
-
goog.asserts.assert(this.generateRequestPromise_,
|
|
507
|
-
'generateRequestPromise_ not set in onMsKeyMessage_');
|
|
508
|
-
if (this.generateRequestPromise_) {
|
|
509
|
-
this.generateRequestPromise_.resolve();
|
|
510
|
-
this.generateRequestPromise_ = null;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
const isNew = this.keyStatuses.getStatus() == undefined;
|
|
514
|
-
|
|
515
|
-
const data = new Map()
|
|
516
|
-
.set('messageType', isNew ? 'license-request' : 'license-renewal')
|
|
517
|
-
.set('message', shaka.util.BufferUtils.toArrayBuffer(event.message));
|
|
518
|
-
const event2 = new shaka.util.FakeEvent('message', data);
|
|
519
|
-
|
|
520
|
-
this.dispatchEvent(event2);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Handler for the native keyadded event on MSMediaKeySession.
|
|
525
|
-
*
|
|
526
|
-
* @param {!MediaKeyEvent} event
|
|
527
|
-
* @private
|
|
528
|
-
*/
|
|
529
|
-
onMsKeyAdded_(event) {
|
|
530
|
-
shaka.log.debug('PatchedMediaKeysMs.onMsKeyAdded_', event);
|
|
531
|
-
|
|
532
|
-
// PlayReady's concept of persistent licenses makes emulation difficult
|
|
533
|
-
// here. A license policy can say that the license persists, which causes
|
|
534
|
-
// the CDM to store it for use in a later session. The result is that in
|
|
535
|
-
// IE11, the CDM fires 'mskeyadded' without ever firing 'mskeymessage'.
|
|
536
|
-
if (this.generateRequestPromise_) {
|
|
537
|
-
shaka.log.debug('Simulating completion for a PR persistent license.');
|
|
538
|
-
goog.asserts.assert(!this.updatePromise_,
|
|
539
|
-
'updatePromise_ and generateRequestPromise_ set in onMsKeyAdded_');
|
|
540
|
-
this.updateKeyStatus_('usable');
|
|
541
|
-
this.generateRequestPromise_.resolve();
|
|
542
|
-
this.generateRequestPromise_ = null;
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// We can now resolve this.updatePromise, which should be non-null.
|
|
547
|
-
goog.asserts.assert(this.updatePromise_,
|
|
548
|
-
'updatePromise_ not set in onMsKeyAdded_');
|
|
549
|
-
if (this.updatePromise_) {
|
|
550
|
-
this.updateKeyStatus_('usable');
|
|
551
|
-
this.updatePromise_.resolve();
|
|
552
|
-
this.updatePromise_ = null;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* Handler for the native keyerror event on MSMediaKeySession.
|
|
558
|
-
*
|
|
559
|
-
* @param {!MediaKeyEvent} event
|
|
560
|
-
* @private
|
|
561
|
-
*/
|
|
562
|
-
onMsKeyError_(event) {
|
|
563
|
-
shaka.log.debug('PatchedMediaKeysMs.onMsKeyError_', event);
|
|
564
|
-
|
|
565
|
-
const error = new Error('EME PatchedMediaKeysMs key error');
|
|
566
|
-
error['errorCode'] = this.nativeMediaKeySession_.error;
|
|
567
|
-
|
|
568
|
-
if (this.generateRequestPromise_ != null) {
|
|
569
|
-
this.generateRequestPromise_.reject(error);
|
|
570
|
-
this.generateRequestPromise_ = null;
|
|
571
|
-
} else if (this.updatePromise_ != null) {
|
|
572
|
-
this.updatePromise_.reject(error);
|
|
573
|
-
this.updatePromise_ = null;
|
|
574
|
-
} else {
|
|
575
|
-
// Unexpected error - map native codes to standardised key statuses.
|
|
576
|
-
// Possible values of this.nativeMediaKeySession_.error.code:
|
|
577
|
-
// MS_MEDIA_KEYERR_UNKNOWN = 1
|
|
578
|
-
// MS_MEDIA_KEYERR_CLIENT = 2
|
|
579
|
-
// MS_MEDIA_KEYERR_SERVICE = 3
|
|
580
|
-
// MS_MEDIA_KEYERR_OUTPUT = 4
|
|
581
|
-
// MS_MEDIA_KEYERR_HARDWARECHANGE = 5
|
|
582
|
-
// MS_MEDIA_KEYERR_DOMAIN = 6
|
|
583
|
-
|
|
584
|
-
switch (this.nativeMediaKeySession_.error.code) {
|
|
585
|
-
case MSMediaKeyError.MS_MEDIA_KEYERR_OUTPUT:
|
|
586
|
-
case MSMediaKeyError.MS_MEDIA_KEYERR_HARDWARECHANGE:
|
|
587
|
-
this.updateKeyStatus_('output-not-allowed');
|
|
588
|
-
break;
|
|
589
|
-
default:
|
|
590
|
-
this.updateKeyStatus_('internal-error');
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Updates key status and dispatch a 'keystatuseschange' event.
|
|
598
|
-
*
|
|
599
|
-
* @param {string} status
|
|
600
|
-
* @private
|
|
601
|
-
*/
|
|
602
|
-
updateKeyStatus_(status) {
|
|
603
|
-
this.keyStatuses.setStatus(status);
|
|
604
|
-
const event = new shaka.util.FakeEvent('keystatuseschange');
|
|
605
|
-
this.dispatchEvent(event);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* @summary An implementation of MediaKeyStatusMap.
|
|
612
|
-
* This fakes a map with a single key ID.
|
|
613
|
-
*
|
|
614
|
-
* @todo Consolidate the MediaKeyStatusMap types in these polyfills.
|
|
615
|
-
* @implements {MediaKeyStatusMap}
|
|
616
|
-
*/
|
|
617
|
-
shaka.polyfill.PatchedMediaKeysMs.MediaKeyStatusMap = class {
|
|
618
|
-
/** */
|
|
619
|
-
constructor() {
|
|
620
|
-
/**
|
|
621
|
-
* @type {number}
|
|
622
|
-
*/
|
|
623
|
-
this.size = 0;
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* @private {string|undefined}
|
|
627
|
-
*/
|
|
628
|
-
this.status_ = undefined;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* An internal method used by the session to set key status.
|
|
633
|
-
* @param {string|undefined} status
|
|
634
|
-
*/
|
|
635
|
-
setStatus(status) {
|
|
636
|
-
this.size = status == undefined ? 0 : 1;
|
|
637
|
-
this.status_ = status;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* An internal method used by the session to get key status.
|
|
642
|
-
* @return {string|undefined}
|
|
643
|
-
*/
|
|
644
|
-
getStatus() {
|
|
645
|
-
return this.status_;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/** @override */
|
|
649
|
-
forEach(fn) {
|
|
650
|
-
if (this.status_) {
|
|
651
|
-
fn(this.status_, shaka.media.DrmEngine.DUMMY_KEY_ID.value());
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/** @override */
|
|
656
|
-
get(keyId) {
|
|
657
|
-
if (this.has(keyId)) {
|
|
658
|
-
return this.status_;
|
|
659
|
-
}
|
|
660
|
-
return undefined;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/** @override */
|
|
664
|
-
has(keyId) {
|
|
665
|
-
const fakeKeyId = shaka.media.DrmEngine.DUMMY_KEY_ID.value();
|
|
666
|
-
if (this.status_ && shaka.util.BufferUtils.equal(keyId, fakeKeyId)) {
|
|
667
|
-
return true;
|
|
668
|
-
}
|
|
669
|
-
return false;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* @suppress {missingReturn}
|
|
674
|
-
* @override
|
|
675
|
-
*/
|
|
676
|
-
entries() {
|
|
677
|
-
goog.asserts.assert(false, 'Not used! Provided only for the compiler.');
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* @suppress {missingReturn}
|
|
682
|
-
* @override
|
|
683
|
-
*/
|
|
684
|
-
keys() {
|
|
685
|
-
goog.asserts.assert(false, 'Not used! Provided only for the compiler.');
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* @suppress {missingReturn}
|
|
690
|
-
* @override
|
|
691
|
-
*/
|
|
692
|
-
values() {
|
|
693
|
-
goog.asserts.assert(false, 'Not used! Provided only for the compiler.');
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysMs.install);
|