rx-player 3.26.2 → 3.27.0-dev.20220317
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/workflows/perfs.yml +22 -0
- package/CHANGELOG.md +33 -1
- package/FILES.md +5 -4
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +4 -2
- package/dist/_esm5.processed/compat/browser_detection.js +4 -2
- package/dist/_esm5.processed/compat/eme/close_session.d.ts +11 -5
- package/dist/_esm5.processed/compat/eme/close_session.js +144 -36
- package/dist/_esm5.processed/compat/eme/custom_media_keys/index.d.ts +3 -5
- package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +27 -24
- package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +53 -34
- package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +43 -41
- package/dist/_esm5.processed/compat/eme/generate_key_request.d.ts +2 -3
- package/dist/_esm5.processed/compat/eme/generate_key_request.js +22 -26
- package/dist/_esm5.processed/compat/eme/load_session.d.ts +1 -2
- package/dist/_esm5.processed/compat/eme/load_session.js +68 -17
- package/dist/_esm5.processed/compat/event_listeners.js +2 -1
- package/dist/_esm5.processed/compat/should_favour_custom_safari_EME.js +2 -2
- package/dist/_esm5.processed/config.d.ts +166 -1080
- package/dist/_esm5.processed/config.js +17 -1119
- package/dist/_esm5.processed/core/abr/bandwidth_estimator.js +4 -1
- package/dist/_esm5.processed/core/abr/buffer_based_chooser.d.ts +28 -6
- package/dist/_esm5.processed/core/abr/buffer_based_chooser.js +63 -12
- package/dist/_esm5.processed/core/abr/network_analyzer.d.ts +1 -1
- package/dist/_esm5.processed/core/abr/network_analyzer.js +2 -1
- package/dist/_esm5.processed/core/abr/pending_requests_store.js +3 -5
- package/dist/_esm5.processed/core/abr/representation_estimator.d.ts +1 -1
- package/dist/_esm5.processed/core/abr/representation_estimator.js +2 -2
- package/dist/_esm5.processed/core/api/get_player_state.js +1 -1
- package/dist/_esm5.processed/core/api/index.d.ts +2 -1
- package/dist/_esm5.processed/core/api/media_element_track_choice_manager.d.ts +6 -0
- package/dist/_esm5.processed/core/api/media_element_track_choice_manager.js +22 -4
- package/dist/_esm5.processed/core/api/option_utils.d.ts +3 -1
- package/dist/_esm5.processed/core/api/option_utils.js +19 -6
- package/dist/_esm5.processed/core/api/playback_observer.js +5 -1
- package/dist/_esm5.processed/core/api/public_api.d.ts +82 -71
- package/dist/_esm5.processed/core/api/public_api.js +72 -33
- package/dist/_esm5.processed/core/api/track_choice_manager.d.ts +6 -6
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.d.ts +7 -51
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.js +30 -75
- package/dist/_esm5.processed/core/{eme → decrypt}/attach_media_keys.d.ts +12 -12
- package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +104 -0
- package/dist/_esm5.processed/core/{eme/clear_eme_session.d.ts → decrypt/clear_on_stop.d.ts} +3 -4
- package/dist/_esm5.processed/core/decrypt/clear_on_stop.js +41 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +216 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +866 -0
- package/dist/_esm5.processed/core/{eme/get_session.d.ts → decrypt/create_or_load_session.d.ts} +28 -26
- package/dist/_esm5.processed/core/decrypt/create_or_load_session.js +124 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/create_session.d.ts +22 -19
- package/dist/_esm5.processed/core/decrypt/create_session.js +174 -0
- package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.d.ts +21 -0
- package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.js +81 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/find_key_system.d.ts +11 -14
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +300 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/get_current_key_system.d.ts +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/get_current_key_system.js +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt}/get_media_keys.d.ts +13 -5
- package/dist/_esm5.processed/core/decrypt/get_media_keys.js +153 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/index.d.ts +5 -6
- package/dist/_esm5.processed/core/{eme → decrypt}/index.js +5 -5
- package/dist/_esm5.processed/core/{eme → decrypt}/init_media_keys.d.ts +6 -4
- package/dist/_esm5.processed/core/decrypt/init_media_keys.js +82 -0
- package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +77 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/session_events_listener.js +25 -24
- package/dist/_esm5.processed/core/{eme → decrypt}/set_server_certificate.d.ts +15 -6
- package/dist/_esm5.processed/core/decrypt/set_server_certificate.js +141 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/types.d.ts +120 -242
- package/dist/_esm5.processed/core/{eme → decrypt}/types.js +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/are_init_values_compatible.d.ts +3 -3
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/are_init_values_compatible.js +5 -5
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/check_key_statuses.d.ts +2 -2
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/check_key_statuses.js +4 -3
- package/dist/_esm5.processed/core/{eme/utils/close_session.d.ts → decrypt/utils/clean_old_loaded_sessions.d.ts} +8 -7
- package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +85 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.d.ts +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.js +2 -2
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/get_drm_system_id.d.ts +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/get_drm_system_id.js +1 -1
- package/dist/_esm5.processed/core/decrypt/utils/init_data_values_container.d.ts +69 -0
- package/dist/_esm5.processed/core/decrypt/utils/init_data_values_container.js +99 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/is_session_usable.d.ts +0 -1
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/is_session_usable.js +4 -5
- package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.d.ts +44 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.js +77 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_session_record.d.ts +104 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_session_record.js +155 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.d.ts +108 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +303 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/media_keys_infos_store.d.ts +4 -4
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/media_keys_infos_store.js +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/persistent_sessions_store.d.ts +8 -18
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/persistent_sessions_store.js +119 -97
- package/dist/_esm5.processed/core/{eme/utils/init_data_container.d.ts → decrypt/utils/serializable_bytes.d.ts} +8 -5
- package/dist/_esm5.processed/core/{eme/utils/init_data_container.js → decrypt/utils/serializable_bytes.js} +9 -9
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/server_certificate_store.d.ts +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/server_certificate_store.js +1 -1
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +4 -4
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +3 -3
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +2 -2
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +6 -2
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
- package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +1 -1
- package/dist/_esm5.processed/core/init/get_initial_time.js +1 -1
- package/dist/_esm5.processed/core/init/initialize_directfile.d.ts +3 -3
- package/dist/_esm5.processed/core/init/initialize_directfile.js +11 -17
- package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +5 -3
- package/dist/_esm5.processed/core/init/initialize_media_source.js +18 -69
- package/dist/_esm5.processed/core/init/link_drm_and_content.d.ts +61 -0
- package/dist/_esm5.processed/core/init/link_drm_and_content.js +94 -0
- package/dist/_esm5.processed/core/init/manifest_update_scheduler.d.ts +4 -4
- package/dist/_esm5.processed/core/init/manifest_update_scheduler.js +2 -1
- package/dist/_esm5.processed/core/init/stall_avoider.js +1 -1
- package/dist/_esm5.processed/core/init/stream_events_emitter/are_same_stream_events.d.ts +4 -4
- package/dist/_esm5.processed/core/init/stream_events_emitter/stream_events_emitter.js +1 -1
- package/dist/_esm5.processed/core/init/stream_events_emitter/types.d.ts +2 -2
- package/dist/_esm5.processed/core/init/types.d.ts +2 -4
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +3 -3
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +3 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +32 -31
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +4 -4
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +17 -1
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +22 -5
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +2 -1
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +6 -3
- package/dist/_esm5.processed/core/stream/events_generators.d.ts +8 -3
- package/dist/_esm5.processed/core/stream/events_generators.js +3 -2
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +1 -0
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +3 -3
- package/dist/_esm5.processed/core/stream/period/create_empty_adaptation_stream.js +2 -1
- package/dist/_esm5.processed/core/stream/period/get_adaptation_switch_strategy.js +1 -1
- package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +2 -1
- package/dist/_esm5.processed/core/stream/period/period_stream.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/force_garbage_collection.js +5 -6
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.d.ts +6 -1
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.js +12 -9
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.d.ts +19 -14
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.js +86 -10
- package/dist/_esm5.processed/core/stream/representation/get_segment_priority.js +1 -1
- package/dist/_esm5.processed/core/stream/representation/push_media_segment.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/representation_stream.d.ts +6 -0
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +19 -8
- package/dist/_esm5.processed/core/stream/types.d.ts +1 -1
- package/dist/_esm5.processed/default_config.d.ts +1114 -0
- package/dist/_esm5.processed/default_config.js +1145 -0
- package/dist/_esm5.processed/errors/request_error.js +3 -1
- package/dist/_esm5.processed/experimental/index.d.ts +2 -0
- package/dist/_esm5.processed/experimental/index.js +2 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/push_data.d.ts +1 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.d.ts +2 -2
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.js +2 -4
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +1 -1
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +1 -1
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/types.d.ts +3 -3
- package/dist/_esm5.processed/features/features_object.js +1 -1
- package/dist/_esm5.processed/features/initialize_features.js +1 -1
- package/dist/_esm5.processed/features/list/eme.d.ts +3 -3
- package/dist/_esm5.processed/features/list/eme.js +5 -5
- package/dist/_esm5.processed/features/types.d.ts +3 -3
- package/dist/_esm5.processed/manifest/adaptation.d.ts +2 -2
- package/dist/_esm5.processed/manifest/adaptation.js +3 -1
- package/dist/_esm5.processed/manifest/manifest.d.ts +10 -23
- package/dist/_esm5.processed/manifest/manifest.js +10 -74
- package/dist/_esm5.processed/manifest/period.d.ts +3 -3
- package/dist/_esm5.processed/manifest/representation.d.ts +37 -5
- package/dist/_esm5.processed/manifest/representation_index/types.d.ts +18 -18
- package/dist/_esm5.processed/manifest/types.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/get_hdr_information.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/get_periods_time_infos.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +6 -6
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/is_period_fulfilled.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +14 -14
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +17 -17
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +28 -20
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +20 -5
- package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +17 -35
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +109 -96
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +8 -8
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.d.ts +18 -27
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +25 -23
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +21 -15
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +19 -19
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.d.ts +15 -38
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +8 -8
- package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +30 -30
- package/dist/_esm5.processed/parsers/manifest/dash/parsers_types.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +7 -7
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +1 -0
- package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +8 -8
- package/dist/_esm5.processed/parsers/manifest/types.d.ts +28 -28
- package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.d.ts +3 -2
- package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.js +15 -5
- package/dist/_esm5.processed/parsers/manifest/utils/index_helpers.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.d.ts +11 -1
- package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.js +31 -19
- package/dist/_esm5.processed/parsers/texttracks/webvtt/html/to_html.d.ts +2 -2
- package/dist/_esm5.processed/parsers/texttracks/webvtt/parse_cue_block.d.ts +1 -1
- package/dist/_esm5.processed/public_types.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +2 -1
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +4 -1
- package/dist/_esm5.processed/transports/dash/init_segment_loader.js +1 -1
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/dash/segment_parser.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/segment_parser.js +6 -3
- package/dist/_esm5.processed/transports/dash/text_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/text_loader.js +1 -1
- package/dist/_esm5.processed/transports/dash/text_parser.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/text_parser.js +8 -2
- package/dist/_esm5.processed/transports/local/segment_loader.d.ts +1 -2
- package/dist/_esm5.processed/transports/local/segment_loader.js +1 -1
- package/dist/_esm5.processed/transports/local/segment_parser.js +4 -1
- package/dist/_esm5.processed/transports/local/text_parser.js +8 -2
- package/dist/_esm5.processed/transports/metaplaylist/manifest_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +1 -1
- package/dist/_esm5.processed/transports/smooth/pipelines.js +69 -11
- package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +0 -1
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/types.d.ts +58 -30
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +1 -1
- package/dist/_esm5.processed/transports/utils/generate_manifest_loader.d.ts +1 -1
- package/dist/_esm5.processed/utils/cancellable_sleep.js +1 -1
- package/dist/_esm5.processed/utils/cast_to_observable.d.ts +1 -2
- package/dist/_esm5.processed/utils/cast_to_observable.js +1 -1
- package/dist/_esm5.processed/utils/deep_merge.d.ts +12 -0
- package/dist/_esm5.processed/utils/deep_merge.js +53 -0
- package/dist/_esm5.processed/utils/reference.d.ts +29 -0
- package/dist/_esm5.processed/utils/reference.js +72 -24
- package/dist/_esm5.processed/utils/request/fetch.d.ts +4 -5
- package/dist/_esm5.processed/utils/request/fetch.js +8 -6
- package/dist/_esm5.processed/utils/request/xhr.d.ts +6 -6
- package/dist/_esm5.processed/utils/request/xhr.js +3 -2
- package/dist/_esm5.processed/utils/rx-from_cancellable_promise.d.ts +1 -2
- package/dist/_esm5.processed/utils/rx-from_cancellable_promise.js +7 -2
- package/dist/_esm5.processed/utils/task_canceller.d.ts +5 -3
- package/dist/_esm5.processed/utils/task_canceller.js +3 -3
- package/dist/rx-player.js +5242 -3190
- package/dist/rx-player.min.js +1 -1
- package/dummy +1 -0
- package/{dist/_esm5.processed/core/eme/dispose_eme.d.ts → experimental/index.d.ts} +1 -4
- package/{dist/_esm5.processed/core/eme/dispose_media_keys.d.ts → experimental/index.js} +1 -6
- package/package.json +33 -36
- package/scripts/build/templates/experimental/index.d.ts +16 -0
- package/scripts/build/templates/experimental/index.js +16 -0
- package/scripts/doc-generator/generate_header_html.js +6 -7
- package/scripts/doc-generator/generate_page_html.js +3 -4
- package/scripts/doc-generator/generate_page_list_html.js +4 -5
- package/scripts/doc-generator/generate_sidebar_html.js +4 -7
- package/scripts/doc-generator/utils.js +0 -11
- package/scripts/generate_demo_list.js +3 -3
- package/scripts/generate_documentation_list.js +3 -3
- package/scripts/launch_static_server.js +127 -67
- package/scripts/run_standalone_demo.js +1 -0
- package/scripts/start_demo_web_server.js +1 -0
- package/sonar-project.properties +1 -1
- package/src/README.md +6 -6
- package/src/compat/__tests__/fullscreen.test.ts +7 -7
- package/src/compat/__tests__/is_vtt_cue.test.ts +1 -1
- package/src/compat/__tests__/should_favour_custom_safari_EME.test.ts +45 -5
- package/src/compat/browser_detection.ts +4 -2
- package/src/compat/eme/close_session.ts +90 -56
- package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +1 -1
- package/src/compat/eme/custom_media_keys/index.ts +28 -41
- package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +63 -46
- package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +51 -49
- package/src/compat/eme/generate_key_request.ts +25 -33
- package/src/compat/eme/load_session.ts +29 -31
- package/src/compat/event_listeners.ts +2 -1
- package/src/compat/should_favour_custom_safari_EME.ts +5 -2
- package/src/config.ts +17 -1210
- package/src/core/README.md +1 -1
- package/src/core/abr/__tests__/{get_estimate_from_buffer_levels.test.ts → buffer_based_chooser.test.ts} +94 -123
- package/src/core/abr/bandwidth_estimator.ts +4 -4
- package/src/core/abr/buffer_based_chooser.ts +85 -20
- package/src/core/abr/network_analyzer.ts +6 -7
- package/src/core/abr/pending_requests_store.ts +3 -5
- package/src/core/abr/representation_estimator.ts +6 -3
- package/src/core/api/__tests__/get_player_state.test.ts +3 -3
- package/src/core/api/__tests__/option_utils.test.ts +17 -17
- package/src/core/api/get_player_state.ts +1 -1
- package/src/core/api/index.ts +3 -0
- package/src/core/api/media_element_track_choice_manager.ts +22 -3
- package/src/core/api/option_utils.ts +37 -20
- package/src/core/api/playback_observer.ts +12 -8
- package/src/core/api/public_api.ts +152 -112
- package/src/core/api/track_choice_manager.ts +10 -9
- package/src/core/decrypt/README.md +22 -0
- package/src/core/decrypt/__tests__/__global__/get_license.test.ts +418 -0
- package/src/core/decrypt/__tests__/__global__/init_data.test.ts +675 -0
- package/src/core/{eme → decrypt}/__tests__/__global__/media_key_system_access.test.ts +99 -92
- package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +156 -0
- package/src/core/decrypt/__tests__/__global__/server_certificate.test.ts +262 -0
- package/src/core/{eme → decrypt}/__tests__/__global__/utils.ts +36 -103
- package/src/core/{eme → decrypt}/attach_media_keys.ts +49 -56
- package/src/core/decrypt/clear_on_stop.ts +48 -0
- package/src/core/decrypt/content_decryptor.ts +1158 -0
- package/src/core/decrypt/create_or_load_session.ts +130 -0
- package/src/core/decrypt/create_session.ts +175 -0
- package/src/core/decrypt/dispose_decryption_resources.ts +39 -0
- package/src/core/{eme → decrypt}/find_key_system.ts +126 -134
- package/src/core/{eme → decrypt}/get_current_key_system.ts +1 -1
- package/src/core/decrypt/get_media_keys.ts +145 -0
- package/src/core/{eme → decrypt}/index.ts +11 -8
- package/src/core/decrypt/init_media_keys.ts +51 -0
- package/src/core/{eme → decrypt}/session_events_listener.ts +93 -55
- package/src/core/decrypt/set_server_certificate.ts +104 -0
- package/src/core/{eme → decrypt}/types.ts +129 -259
- package/src/core/{eme → decrypt}/utils/__tests__/are_init_values_compatible.test.ts +1 -1
- package/src/core/{eme → decrypt/utils}/__tests__/clean_old_loaded_sessions.test.ts +29 -71
- package/src/core/{eme → decrypt/utils}/__tests__/clean_old_stored_persistent_info.test.ts +6 -6
- package/src/core/{eme → decrypt}/utils/are_init_values_compatible.ts +9 -9
- package/src/core/{eme → decrypt/utils}/check_key_statuses.ts +6 -5
- package/{dist/_esm5.processed/core/eme/clean_old_loaded_sessions.js → src/core/decrypt/utils/clean_old_loaded_sessions.ts} +20 -20
- package/src/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.ts +3 -3
- package/src/core/{eme → decrypt/utils}/get_drm_system_id.ts +1 -1
- package/src/core/decrypt/utils/init_data_values_container.ts +119 -0
- package/src/core/{eme → decrypt}/utils/is_session_usable.ts +4 -5
- package/src/core/decrypt/utils/key_id_comparison.ts +82 -0
- package/src/core/decrypt/utils/key_session_record.ts +175 -0
- package/src/core/decrypt/utils/loaded_sessions_store.ts +318 -0
- package/src/core/{eme → decrypt/utils}/media_keys_infos_store.ts +4 -4
- package/src/core/{eme → decrypt}/utils/persistent_sessions_store.ts +122 -104
- package/src/core/{eme/utils/init_data_container.ts → decrypt/utils/serializable_bytes.ts} +8 -5
- package/src/core/{eme → decrypt/utils}/server_certificate_store.ts +2 -2
- package/src/core/fetchers/manifest/manifest_fetcher.ts +9 -9
- package/src/core/fetchers/segment/segment_fetcher.ts +10 -7
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +2 -2
- package/src/core/fetchers/utils/try_urls_with_backoff.ts +1 -1
- package/src/core/init/.initialize_media_source.ts.un~ +0 -0
- package/src/core/init/get_initial_time.ts +2 -1
- package/src/core/init/initialize_directfile.ts +19 -22
- package/src/core/init/initialize_media_source.ts +43 -106
- package/src/core/init/link_drm_and_content.ts +176 -0
- package/src/core/init/manifest_update_scheduler.ts +12 -10
- package/src/core/init/stall_avoider.ts +6 -5
- package/src/core/init/stream_events_emitter/are_same_stream_events.ts +4 -4
- package/src/core/init/stream_events_emitter/stream_events_emitter.ts +2 -1
- package/src/core/init/stream_events_emitter/types.ts +2 -2
- package/src/core/init/types.ts +1 -39
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +2 -1
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +6 -7
- package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +32 -31
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +4 -4
- package/src/core/segment_buffers/inventory/segment_inventory.ts +42 -8
- package/src/core/stream/adaptation/adaptation_stream.ts +7 -1
- package/src/core/stream/events_generators.ts +9 -4
- package/src/core/stream/orchestrator/stream_orchestrator.ts +9 -4
- package/src/core/stream/period/create_empty_adaptation_stream.ts +2 -1
- package/src/core/stream/period/get_adaptation_switch_strategy.ts +1 -1
- package/src/core/stream/period/period_stream.ts +5 -2
- package/src/core/stream/representation/force_garbage_collection.ts +5 -7
- package/src/core/stream/representation/get_buffer_status.ts +28 -16
- package/src/core/stream/representation/get_needed_segments.ts +124 -28
- package/src/core/stream/representation/get_segment_priority.ts +1 -2
- package/src/core/stream/representation/push_media_segment.ts +3 -2
- package/src/core/stream/representation/representation_stream.ts +30 -7
- package/src/core/stream/types.ts +1 -1
- package/src/default_config.ts +1241 -0
- package/src/errors/request_error.ts +4 -1
- package/src/experimental/index.ts +5 -0
- package/src/experimental/tools/VideoThumbnailLoader/push_data.ts +1 -0
- package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +5 -7
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +3 -10
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +4 -4
- package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
- package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +3 -3
- package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/types.ts +3 -3
- package/src/features/__tests__/initialize_features.test.ts +2 -2
- package/src/features/features_object.ts +1 -1
- package/src/features/initialize_features.ts +1 -1
- package/src/features/list/__tests__/eme.test.ts +5 -5
- package/src/features/list/eme.ts +5 -5
- package/src/features/types.ts +3 -10
- package/src/manifest/adaptation.ts +6 -4
- package/src/manifest/manifest.ts +16 -86
- package/src/manifest/period.ts +3 -3
- package/src/manifest/representation.ts +38 -5
- package/src/manifest/representation_index/types.ts +18 -18
- package/src/manifest/types.ts +3 -3
- package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +1 -0
- package/src/parsers/manifest/dash/common/get_hdr_information.ts +1 -1
- package/src/parsers/manifest/dash/common/get_periods_time_infos.ts +3 -3
- package/src/parsers/manifest/dash/common/indexes/base.ts +6 -6
- package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +4 -2
- package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +2 -2
- package/src/parsers/manifest/dash/common/indexes/is_period_fulfilled.ts +1 -2
- package/src/parsers/manifest/dash/common/indexes/list.ts +14 -14
- package/src/parsers/manifest/dash/common/indexes/template.ts +18 -18
- package/src/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.ts +1 -1
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +51 -23
- package/src/parsers/manifest/dash/common/infer_adaptation_type.ts +2 -2
- package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +1 -1
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +167 -134
- package/src/parsers/manifest/dash/common/parse_mpd.ts +9 -10
- package/src/parsers/manifest/dash/common/parse_periods.ts +80 -79
- package/src/parsers/manifest/dash/common/parse_representation_index.ts +83 -75
- package/src/parsers/manifest/dash/common/parse_representations.ts +44 -63
- package/src/parsers/manifest/dash/node_parser_types.ts +30 -30
- package/src/parsers/manifest/dash/parsers_types.ts +3 -3
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -1
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +4 -4
- package/src/parsers/manifest/smooth/create_parser.ts +24 -21
- package/src/parsers/manifest/smooth/representation_index.ts +14 -14
- package/src/parsers/manifest/types.ts +28 -28
- package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +31 -33
- package/src/parsers/manifest/utils/clear_timeline_from_position.ts +15 -6
- package/src/parsers/manifest/utils/index_helpers.ts +2 -2
- package/src/parsers/manifest/utils/update_segment_timeline.ts +32 -21
- package/src/parsers/texttracks/webvtt/html/__tests__/create_styled_element.test.ts +1 -0
- package/src/parsers/texttracks/webvtt/html/to_html.ts +2 -2
- package/src/parsers/texttracks/webvtt/parse_cue_block.ts +1 -1
- package/src/public_types.ts +5 -1
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +2 -2
- package/src/transports/dash/image_pipelines.ts +4 -1
- package/src/transports/dash/init_segment_loader.ts +1 -1
- package/src/transports/dash/manifest_parser.ts +1 -1
- package/src/transports/dash/segment_loader.ts +7 -7
- package/src/transports/dash/segment_parser.ts +8 -1
- package/src/transports/dash/text_loader.ts +2 -2
- package/src/transports/dash/text_parser.ts +11 -1
- package/src/transports/local/segment_loader.ts +4 -4
- package/src/transports/local/segment_parser.ts +4 -0
- package/src/transports/local/text_parser.ts +8 -0
- package/src/transports/metaplaylist/manifest_loader.ts +1 -1
- package/src/transports/metaplaylist/pipelines.ts +1 -1
- package/src/transports/smooth/pipelines.ts +29 -16
- package/src/transports/smooth/segment_loader.ts +8 -8
- package/src/transports/types.ts +59 -30
- package/src/transports/utils/call_custom_manifest_loader.ts +6 -6
- package/src/transports/utils/generate_manifest_loader.ts +1 -1
- package/src/utils/__tests__/deep_merge.test.ts +48 -0
- package/src/utils/__tests__/flat_map.test.ts +12 -7
- package/src/utils/cancellable_sleep.ts +1 -1
- package/src/utils/cast_to_observable.ts +1 -2
- package/src/utils/deep_merge.ts +46 -0
- package/src/utils/reference.ts +116 -23
- package/src/utils/request/fetch.ts +17 -15
- package/src/utils/request/xhr.ts +11 -8
- package/src/utils/rx-from_cancellable_promise.ts +8 -4
- package/src/utils/task_canceller.ts +6 -4
- package/tsconfig.json +1 -2
- package/tsconfig.modules.json +1 -2
- package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.d.ts +0 -29
- package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.js +0 -67
- package/dist/_esm5.processed/core/eme/attach_media_keys.js +0 -57
- package/dist/_esm5.processed/core/eme/clean_old_loaded_sessions.d.ts +0 -59
- package/dist/_esm5.processed/core/eme/clear_eme_session.js +0 -50
- package/dist/_esm5.processed/core/eme/create_session.js +0 -126
- package/dist/_esm5.processed/core/eme/dispose_eme.js +0 -23
- package/dist/_esm5.processed/core/eme/dispose_media_keys.js +0 -36
- package/dist/_esm5.processed/core/eme/eme_manager.d.ts +0 -31
- package/dist/_esm5.processed/core/eme/eme_manager.js +0 -278
- package/dist/_esm5.processed/core/eme/find_key_system.js +0 -243
- package/dist/_esm5.processed/core/eme/get_media_keys.js +0 -85
- package/dist/_esm5.processed/core/eme/get_session.js +0 -68
- package/dist/_esm5.processed/core/eme/init_media_keys.js +0 -66
- package/dist/_esm5.processed/core/eme/session_events_listener.d.ts +0 -41
- package/dist/_esm5.processed/core/eme/set_server_certificate.js +0 -85
- package/dist/_esm5.processed/core/eme/utils/close_session.js +0 -81
- package/dist/_esm5.processed/core/eme/utils/init_data_store.d.ts +0 -115
- package/dist/_esm5.processed/core/eme/utils/init_data_store.js +0 -181
- package/dist/_esm5.processed/core/eme/utils/loaded_sessions_store.d.ts +0 -123
- package/dist/_esm5.processed/core/eme/utils/loaded_sessions_store.js +0 -173
- package/dist/_esm5.processed/core/init/create_eme_manager.d.ts +0 -34
- package/dist/_esm5.processed/core/init/create_eme_manager.js +0 -52
- package/src/core/abr/get_estimate_from_buffer_levels.ts +0 -85
- package/src/core/eme/README.md +0 -26
- package/src/core/eme/__tests__/__global__/get_license.test.ts +0 -414
- package/src/core/eme/__tests__/__global__/init_data.test.ts +0 -908
- package/src/core/eme/__tests__/__global__/media_keys.test.ts +0 -266
- package/src/core/eme/__tests__/__global__/server_certificate.test.ts +0 -364
- package/src/core/eme/__tests__/init_media_keys.test.ts +0 -182
- package/src/core/eme/clean_old_loaded_sessions.ts +0 -96
- package/src/core/eme/clear_eme_session.ts +0 -62
- package/src/core/eme/create_session.ts +0 -187
- package/src/core/eme/dispose_eme.ts +0 -25
- package/src/core/eme/dispose_media_keys.ts +0 -46
- package/src/core/eme/eme_manager.ts +0 -387
- package/src/core/eme/get_media_keys.ts +0 -141
- package/src/core/eme/get_session.ts +0 -135
- package/src/core/eme/init_media_keys.ts +0 -106
- package/src/core/eme/set_server_certificate.ts +0 -115
- package/src/core/eme/utils/close_session.ts +0 -113
- package/src/core/eme/utils/init_data_store.ts +0 -234
- package/src/core/eme/utils/loaded_sessions_store.ts +0 -235
- package/src/core/init/create_eme_manager.ts +0 -95
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __extends = (this && this.__extends) || (function () {
|
|
17
|
+
var extendStatics = function (d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
return function (d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null)
|
|
25
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
extendStatics(d, b);
|
|
27
|
+
function __() { this.constructor = d; }
|
|
28
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
var __assign = (this && this.__assign) || function () {
|
|
32
|
+
__assign = Object.assign || function(t) {
|
|
33
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
|
+
s = arguments[i];
|
|
35
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
36
|
+
t[p] = s[p];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
return __assign.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
43
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
44
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
45
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
46
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
47
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
48
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
52
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
53
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
54
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while (_) try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
60
|
+
switch (op[0]) {
|
|
61
|
+
case 0: case 1: t = op; break;
|
|
62
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
63
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
64
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
65
|
+
default:
|
|
66
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
67
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
68
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
69
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
70
|
+
if (t[2]) _.ops.pop();
|
|
71
|
+
_.trys.pop(); continue;
|
|
72
|
+
}
|
|
73
|
+
op = body.call(thisArg, _);
|
|
74
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
75
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
79
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
80
|
+
if (ar || !(i in from)) {
|
|
81
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
82
|
+
ar[i] = from[i];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
86
|
+
};
|
|
87
|
+
import PPromise from "pinkie";
|
|
88
|
+
import { events, generateKeyRequest, getInitData, } from "../../compat/";
|
|
89
|
+
import config from "../../config";
|
|
90
|
+
import { EncryptedMediaError, OtherError, } from "../../errors";
|
|
91
|
+
import log from "../../log";
|
|
92
|
+
import areArraysOfNumbersEqual from "../../utils/are_arrays_of_numbers_equal";
|
|
93
|
+
import arrayFind from "../../utils/array_find";
|
|
94
|
+
import arrayIncludes from "../../utils/array_includes";
|
|
95
|
+
import EventEmitter from "../../utils/event_emitter";
|
|
96
|
+
import isNullOrUndefined from "../../utils/is_null_or_undefined";
|
|
97
|
+
import { bytesToHex } from "../../utils/string_parsing";
|
|
98
|
+
import TaskCanceller from "../../utils/task_canceller";
|
|
99
|
+
import attachMediaKeys from "./attach_media_keys";
|
|
100
|
+
import createOrLoadSession from "./create_or_load_session";
|
|
101
|
+
import initMediaKeys from "./init_media_keys";
|
|
102
|
+
import SessionEventsListener, { BlacklistedSessionError, } from "./session_events_listener";
|
|
103
|
+
import setServerCertificate from "./set_server_certificate";
|
|
104
|
+
import cleanOldStoredPersistentInfo from "./utils/clean_old_stored_persistent_info";
|
|
105
|
+
import getDrmSystemId from "./utils/get_drm_system_id";
|
|
106
|
+
import InitDataValuesContainer from "./utils/init_data_values_container";
|
|
107
|
+
import { areAllKeyIdsContainedIn, areKeyIdsEqual, areSomeKeyIdsContainedIn, isKeyIdContainedIn, } from "./utils/key_id_comparison";
|
|
108
|
+
var onEncrypted$ = events.onEncrypted$;
|
|
109
|
+
/**
|
|
110
|
+
* Module communicating with the Content Decryption Module (or CDM) to be able
|
|
111
|
+
* to decrypt contents.
|
|
112
|
+
*
|
|
113
|
+
* The `ContentDecryptor` starts communicating with the CDM, to initialize the
|
|
114
|
+
* key system, as soon as it is created.
|
|
115
|
+
*
|
|
116
|
+
* You can be notified of various events, such as fatal errors, by registering
|
|
117
|
+
* to one of its multiple events (@see IContentDecryptorEvent).
|
|
118
|
+
*
|
|
119
|
+
* @class ContentDecryptor
|
|
120
|
+
*/
|
|
121
|
+
var ContentDecryptor = /** @class */ (function (_super) {
|
|
122
|
+
__extends(ContentDecryptor, _super);
|
|
123
|
+
/**
|
|
124
|
+
* Create a new `ContentDecryptor`, and initialize its decryption capabilities
|
|
125
|
+
* right away.
|
|
126
|
+
* Goes into the `WaitingForAttachment` state once that initialization is
|
|
127
|
+
* done, after which you should call the `attach` method when you're ready for
|
|
128
|
+
* those decryption capabilities to be attached to the HTMLMediaElement.
|
|
129
|
+
*
|
|
130
|
+
* @param {HTMLMediaElement} mediaElement - The MediaElement which will be
|
|
131
|
+
* associated to a MediaKeys object
|
|
132
|
+
* @param {Array.<Object>} ksOptions - key system configuration.
|
|
133
|
+
* The `ContentDecryptor` can be given one or multiple key system
|
|
134
|
+
* configurations. It will choose the appropriate one depending on user
|
|
135
|
+
* settings and browser support.
|
|
136
|
+
*/
|
|
137
|
+
function ContentDecryptor(mediaElement, ksOptions) {
|
|
138
|
+
var _this = _super.call(this) || this;
|
|
139
|
+
log.debug("DRM: Starting ContentDecryptor logic.");
|
|
140
|
+
var canceller = new TaskCanceller();
|
|
141
|
+
_this._currentSessions = [];
|
|
142
|
+
_this._canceller = canceller;
|
|
143
|
+
_this._wasAttachCalled = false;
|
|
144
|
+
_this._initDataQueue = [];
|
|
145
|
+
_this._stateData = { state: ContentDecryptorState.Initializing,
|
|
146
|
+
isMediaKeysAttached: false,
|
|
147
|
+
isInitDataQueueLocked: true,
|
|
148
|
+
data: null };
|
|
149
|
+
_this.error = null;
|
|
150
|
+
var listenerSub = onEncrypted$(mediaElement).subscribe(function (evt) {
|
|
151
|
+
log.debug("DRM: Encrypted event received from media element.");
|
|
152
|
+
var initData = getInitData(evt);
|
|
153
|
+
if (initData !== null) {
|
|
154
|
+
_this.onInitializationData(initData);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
canceller.signal.register(function () {
|
|
158
|
+
listenerSub.unsubscribe();
|
|
159
|
+
});
|
|
160
|
+
initMediaKeys(mediaElement, ksOptions, canceller.signal)
|
|
161
|
+
.then(function (mediaKeysInfo) {
|
|
162
|
+
var options = mediaKeysInfo.options, mediaKeySystemAccess = mediaKeysInfo.mediaKeySystemAccess;
|
|
163
|
+
/**
|
|
164
|
+
* String identifying the key system, allowing the rest of the code to
|
|
165
|
+
* only advertise the required initialization data for license requests.
|
|
166
|
+
*
|
|
167
|
+
* Note that we only set this value if retro-compatibility to older
|
|
168
|
+
* persistent logic in the RxPlayer is not important, as the
|
|
169
|
+
* optimizations this property unlocks can break the loading of
|
|
170
|
+
* MediaKeySessions persisted in older RxPlayer's versions.
|
|
171
|
+
*/
|
|
172
|
+
var systemId;
|
|
173
|
+
if (isNullOrUndefined(options.licenseStorage) ||
|
|
174
|
+
options.licenseStorage.disableRetroCompatibility === true) {
|
|
175
|
+
systemId = getDrmSystemId(mediaKeySystemAccess.keySystem);
|
|
176
|
+
}
|
|
177
|
+
_this.systemId = systemId;
|
|
178
|
+
if (_this._stateData.state === ContentDecryptorState.Initializing) {
|
|
179
|
+
_this._stateData = { state: ContentDecryptorState.WaitingForAttachment,
|
|
180
|
+
isInitDataQueueLocked: true,
|
|
181
|
+
isMediaKeysAttached: false,
|
|
182
|
+
data: { mediaKeysInfo: mediaKeysInfo, mediaElement: mediaElement } };
|
|
183
|
+
_this.trigger("stateChange", _this._stateData.state);
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
.catch(function (err) {
|
|
187
|
+
_this._onFatalError(err);
|
|
188
|
+
});
|
|
189
|
+
return _this;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the current state of the ContentDecryptor.
|
|
193
|
+
* @see ContentDecryptorState
|
|
194
|
+
* @returns {Object}
|
|
195
|
+
*/
|
|
196
|
+
ContentDecryptor.prototype.getState = function () {
|
|
197
|
+
return this._stateData.state;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Attach the current decryption capabilities to the HTMLMediaElement.
|
|
201
|
+
* This method should only be called once the `ContentDecryptor` is in the
|
|
202
|
+
* `WaitingForAttachment` state.
|
|
203
|
+
*
|
|
204
|
+
* You might want to first set the HTMLMediaElement's `src` attribute before
|
|
205
|
+
* calling this method, and only push data to it once the `ReadyForContent`
|
|
206
|
+
* state is reached, for compatibility reasons.
|
|
207
|
+
*/
|
|
208
|
+
ContentDecryptor.prototype.attach = function () {
|
|
209
|
+
var _this = this;
|
|
210
|
+
if (this._stateData.state !== ContentDecryptorState.WaitingForAttachment) {
|
|
211
|
+
throw new Error("`attach` should only be called when " +
|
|
212
|
+
"in the WaitingForAttachment state");
|
|
213
|
+
}
|
|
214
|
+
else if (this._wasAttachCalled) {
|
|
215
|
+
log.warn("DRM: ContentDecryptor's `attach` method called more than once.");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this._wasAttachCalled = true;
|
|
219
|
+
var _a = this._stateData.data, mediaElement = _a.mediaElement, mediaKeysInfo = _a.mediaKeysInfo;
|
|
220
|
+
var options = mediaKeysInfo.options, mediaKeys = mediaKeysInfo.mediaKeys, mediaKeySystemAccess = mediaKeysInfo.mediaKeySystemAccess, stores = mediaKeysInfo.stores;
|
|
221
|
+
var stateToAttatch = { loadedSessionsStore: stores.loadedSessionsStore, mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, keySystemOptions: options };
|
|
222
|
+
var shouldDisableLock = options.disableMediaKeysAttachmentLock === true;
|
|
223
|
+
if (shouldDisableLock) {
|
|
224
|
+
this._stateData = { state: ContentDecryptorState.ReadyForContent,
|
|
225
|
+
isInitDataQueueLocked: true,
|
|
226
|
+
isMediaKeysAttached: false,
|
|
227
|
+
data: null };
|
|
228
|
+
this.trigger("stateChange", this._stateData.state);
|
|
229
|
+
if (this._isStopped()) { // previous trigger might have lead to disposal
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
log.debug("DRM: Attaching current MediaKeys");
|
|
234
|
+
attachMediaKeys(mediaElement, stateToAttatch, this._canceller.signal)
|
|
235
|
+
.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
236
|
+
var serverCertificate, resSsc, prevState;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
serverCertificate = options.serverCertificate;
|
|
241
|
+
if (!!isNullOrUndefined(serverCertificate)) return [3 /*break*/, 2];
|
|
242
|
+
return [4 /*yield*/, setServerCertificate(mediaKeys, serverCertificate)];
|
|
243
|
+
case 1:
|
|
244
|
+
resSsc = _a.sent();
|
|
245
|
+
if (resSsc.type === "error") {
|
|
246
|
+
this.trigger("warning", resSsc.value);
|
|
247
|
+
}
|
|
248
|
+
_a.label = 2;
|
|
249
|
+
case 2:
|
|
250
|
+
if (this._isStopped()) { // We might be stopped since then
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
}
|
|
253
|
+
prevState = this._stateData.state;
|
|
254
|
+
this._stateData = { state: ContentDecryptorState.ReadyForContent,
|
|
255
|
+
isMediaKeysAttached: true,
|
|
256
|
+
isInitDataQueueLocked: false,
|
|
257
|
+
data: { mediaKeysData: mediaKeysInfo } };
|
|
258
|
+
if (prevState !== ContentDecryptorState.ReadyForContent) {
|
|
259
|
+
this.trigger("stateChange", ContentDecryptorState.ReadyForContent);
|
|
260
|
+
}
|
|
261
|
+
if (!this._isStopped()) {
|
|
262
|
+
this._processCurrentInitDataQueue();
|
|
263
|
+
}
|
|
264
|
+
return [2 /*return*/];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}); })
|
|
268
|
+
.catch(function (err) {
|
|
269
|
+
_this._onFatalError(err);
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Stop this `ContentDecryptor` instance:
|
|
274
|
+
* - stop listening and reacting to the various event listeners
|
|
275
|
+
* - abort all operations.
|
|
276
|
+
*
|
|
277
|
+
* Once disposed, a `ContentDecryptor` cannot be used anymore.
|
|
278
|
+
*/
|
|
279
|
+
ContentDecryptor.prototype.dispose = function () {
|
|
280
|
+
this.removeEventListener();
|
|
281
|
+
this._stateData = { state: ContentDecryptorState.Disposed,
|
|
282
|
+
isMediaKeysAttached: undefined,
|
|
283
|
+
isInitDataQueueLocked: undefined,
|
|
284
|
+
data: null };
|
|
285
|
+
this._canceller.cancel();
|
|
286
|
+
this.trigger("stateChange", this._stateData.state);
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Method to call when new protection initialization data is encounted on the
|
|
290
|
+
* content.
|
|
291
|
+
*
|
|
292
|
+
* When called, the `ContentDecryptor` will try to obtain the decryption key
|
|
293
|
+
* if not already obtained.
|
|
294
|
+
*
|
|
295
|
+
* @param {Object} initializationData
|
|
296
|
+
*/
|
|
297
|
+
ContentDecryptor.prototype.onInitializationData = function (initializationData) {
|
|
298
|
+
var _this = this;
|
|
299
|
+
if (this._stateData.isInitDataQueueLocked !== false) {
|
|
300
|
+
if (this._isStopped()) {
|
|
301
|
+
throw new Error("ContentDecryptor either disposed or stopped.");
|
|
302
|
+
}
|
|
303
|
+
this._initDataQueue.push(initializationData);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
var mediaKeysData = this._stateData.data.mediaKeysData;
|
|
307
|
+
var processedInitializationData = __assign(__assign({}, initializationData), { values: new InitDataValuesContainer(initializationData.values) });
|
|
308
|
+
this._processInitializationData(processedInitializationData, mediaKeysData)
|
|
309
|
+
.catch(function (err) { _this._onFatalError(err); });
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Async logic run each time new initialization data has to be processed.
|
|
313
|
+
* The promise return may reject, in which case a fatal error should be linked
|
|
314
|
+
* the current `ContentDecryptor`.
|
|
315
|
+
*
|
|
316
|
+
* The Promise's resolution however provides no semantic value.
|
|
317
|
+
* @param {Object} initializationData
|
|
318
|
+
* @returns {Promise.<void>}
|
|
319
|
+
*/
|
|
320
|
+
ContentDecryptor.prototype._processInitializationData = function (initializationData, mediaKeysData) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var mediaKeySystemAccess, stores, options, firstCreatedSession, keyIds, hexKids, period, createdSessions, periodKeys, _i, createdSessions_1, createdSess, periodKeysArr, _a, periodKeysArr_1, kid, _b, periodKeysArr_2, innerKid, wantedSessionType, _c, EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION, maxSessionCacheSize, sessionRes, sessionInfo, _d, mediaKeySession, sessionType, isSessionPersisted, sub, requestData, error_1;
|
|
323
|
+
var _this = this;
|
|
324
|
+
return __generator(this, function (_e) {
|
|
325
|
+
switch (_e.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
mediaKeySystemAccess = mediaKeysData.mediaKeySystemAccess, stores = mediaKeysData.stores, options = mediaKeysData.options;
|
|
328
|
+
if (this._tryToUseAlreadyCreatedSession(initializationData, mediaKeysData) ||
|
|
329
|
+
this._isStopped()) // _isStopped is voluntarly checked after here
|
|
330
|
+
{
|
|
331
|
+
return [2 /*return*/];
|
|
332
|
+
}
|
|
333
|
+
if (options.singleLicensePer === "content") {
|
|
334
|
+
firstCreatedSession = arrayFind(this._currentSessions, function (x) {
|
|
335
|
+
return x.source === "created-session" /* Created */;
|
|
336
|
+
});
|
|
337
|
+
if (firstCreatedSession !== undefined) {
|
|
338
|
+
keyIds = initializationData.keyIds;
|
|
339
|
+
if (keyIds === undefined) {
|
|
340
|
+
if (initializationData.content === undefined) {
|
|
341
|
+
log.warn("DRM: Unable to fallback from a non-decipherable quality.");
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
blackListProtectionData(initializationData.content.manifest, initializationData);
|
|
345
|
+
}
|
|
346
|
+
return [2 /*return*/];
|
|
347
|
+
}
|
|
348
|
+
firstCreatedSession.record.associateKeyIds(keyIds);
|
|
349
|
+
if (initializationData.content !== undefined) {
|
|
350
|
+
if (log.getLevel() === "DEBUG") {
|
|
351
|
+
hexKids = keyIds
|
|
352
|
+
.reduce(function (acc, kid) { return "".concat(acc, ", ").concat(bytesToHex(kid)); }, "");
|
|
353
|
+
log.debug("DRM: Blacklisting new key ids", hexKids);
|
|
354
|
+
}
|
|
355
|
+
updateDecipherability(initializationData.content.manifest, [], keyIds);
|
|
356
|
+
}
|
|
357
|
+
return [2 /*return*/];
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
else if (options.singleLicensePer === "periods" &&
|
|
361
|
+
initializationData.content !== undefined) {
|
|
362
|
+
period = initializationData.content.period;
|
|
363
|
+
createdSessions = this._currentSessions
|
|
364
|
+
.filter(function (x) { return x.source === "created-session" /* Created */; });
|
|
365
|
+
periodKeys = new Set();
|
|
366
|
+
addKeyIdsFromPeriod(periodKeys, period);
|
|
367
|
+
for (_i = 0, createdSessions_1 = createdSessions; _i < createdSessions_1.length; _i++) {
|
|
368
|
+
createdSess = createdSessions_1[_i];
|
|
369
|
+
periodKeysArr = Array.from(periodKeys);
|
|
370
|
+
for (_a = 0, periodKeysArr_1 = periodKeysArr; _a < periodKeysArr_1.length; _a++) {
|
|
371
|
+
kid = periodKeysArr_1[_a];
|
|
372
|
+
if (createdSess.record.isAssociatedWithKeyId(kid)) {
|
|
373
|
+
createdSess.record.associateKeyIds(periodKeys.values());
|
|
374
|
+
// Re-loop through the Period's key ids to blacklist ones that are missing
|
|
375
|
+
// from `createdSess`'s `keyStatuses` and to update the content's
|
|
376
|
+
// decipherability.
|
|
377
|
+
for (_b = 0, periodKeysArr_2 = periodKeysArr; _b < periodKeysArr_2.length; _b++) {
|
|
378
|
+
innerKid = periodKeysArr_2[_b];
|
|
379
|
+
if (!isKeyIdContainedIn(innerKid, createdSess.keyStatuses.whitelisted) &&
|
|
380
|
+
!isKeyIdContainedIn(innerKid, createdSess.keyStatuses.blacklisted)) {
|
|
381
|
+
createdSess.keyStatuses.blacklisted.push(innerKid);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
updateDecipherability(initializationData.content.manifest, createdSess.keyStatuses.whitelisted, createdSess.keyStatuses.blacklisted);
|
|
385
|
+
return [2 /*return*/];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// /!\ Do not forget to unlock when done
|
|
391
|
+
// TODO this is error-prone and can lead to performance issue when loading
|
|
392
|
+
// persistent sessions.
|
|
393
|
+
// Can we find a better strategy?
|
|
394
|
+
this._lockInitDataQueue();
|
|
395
|
+
if (options.persistentLicense !== true) {
|
|
396
|
+
wantedSessionType = "temporary";
|
|
397
|
+
}
|
|
398
|
+
else if (!canCreatePersistentSession(mediaKeySystemAccess)) {
|
|
399
|
+
log.warn("DRM: Cannot create \"persistent-license\" session: not supported");
|
|
400
|
+
wantedSessionType = "temporary";
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
wantedSessionType = "persistent-license";
|
|
404
|
+
}
|
|
405
|
+
_c = config.getCurrent(), EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS = _c.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION = _c.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION;
|
|
406
|
+
maxSessionCacheSize = typeof options.maxSessionCacheSize === "number" ?
|
|
407
|
+
options.maxSessionCacheSize :
|
|
408
|
+
EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS;
|
|
409
|
+
return [4 /*yield*/, createOrLoadSession(initializationData, stores, wantedSessionType, maxSessionCacheSize, this._canceller.signal)];
|
|
410
|
+
case 1:
|
|
411
|
+
sessionRes = _e.sent();
|
|
412
|
+
if (this._isStopped()) {
|
|
413
|
+
return [2 /*return*/];
|
|
414
|
+
}
|
|
415
|
+
sessionInfo = {
|
|
416
|
+
record: sessionRes.value.keySessionRecord,
|
|
417
|
+
source: sessionRes.type,
|
|
418
|
+
keyStatuses: { whitelisted: [], blacklisted: [] },
|
|
419
|
+
blacklistedSessionError: null,
|
|
420
|
+
};
|
|
421
|
+
this._currentSessions.push(sessionInfo);
|
|
422
|
+
_d = sessionRes.value, mediaKeySession = _d.mediaKeySession, sessionType = _d.sessionType;
|
|
423
|
+
isSessionPersisted = false;
|
|
424
|
+
sub = SessionEventsListener(mediaKeySession, options, mediaKeySystemAccess.keySystem)
|
|
425
|
+
.subscribe({
|
|
426
|
+
next: function (evt) {
|
|
427
|
+
switch (evt.type) {
|
|
428
|
+
case "warning":
|
|
429
|
+
_this.trigger("warning", evt.value);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
var linkedKeys;
|
|
433
|
+
if (sessionInfo.source === "created-session" /* Created */) {
|
|
434
|
+
// When the license has been fetched, there might be implicit key ids
|
|
435
|
+
// linked to the session depending on the `singleLicensePer` option.
|
|
436
|
+
linkedKeys = getFetchedLicenseKeysInfo(initializationData, options.singleLicensePer, evt.value.whitelistedKeyIds, evt.value.blacklistedKeyIDs);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
// When the MediaKeySession is just a cached/persisted one, we don't
|
|
440
|
+
// have any concept of "implicit key id".
|
|
441
|
+
linkedKeys = { whitelisted: evt.value.whitelistedKeyIds,
|
|
442
|
+
blacklisted: evt.value.blacklistedKeyIDs };
|
|
443
|
+
}
|
|
444
|
+
sessionInfo.record.associateKeyIds(linkedKeys.whitelisted);
|
|
445
|
+
sessionInfo.record.associateKeyIds(linkedKeys.blacklisted);
|
|
446
|
+
sessionInfo.keyStatuses = { whitelisted: linkedKeys.whitelisted,
|
|
447
|
+
blacklisted: linkedKeys.blacklisted };
|
|
448
|
+
if (sessionInfo.record.getAssociatedKeyIds().length !== 0 &&
|
|
449
|
+
sessionType === "persistent-license" &&
|
|
450
|
+
stores.persistentSessionsStore !== null &&
|
|
451
|
+
!isSessionPersisted) {
|
|
452
|
+
var persistentSessionsStore = stores.persistentSessionsStore;
|
|
453
|
+
cleanOldStoredPersistentInfo(persistentSessionsStore, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION - 1);
|
|
454
|
+
persistentSessionsStore.add(initializationData, sessionInfo.record.getAssociatedKeyIds(), mediaKeySession);
|
|
455
|
+
isSessionPersisted = true;
|
|
456
|
+
}
|
|
457
|
+
if (initializationData.content !== undefined) {
|
|
458
|
+
updateDecipherability(initializationData.content.manifest, linkedKeys.whitelisted, linkedKeys.blacklisted);
|
|
459
|
+
}
|
|
460
|
+
_this._unlockInitDataQueue();
|
|
461
|
+
},
|
|
462
|
+
error: function (err) {
|
|
463
|
+
if (!(err instanceof BlacklistedSessionError)) {
|
|
464
|
+
_this._onFatalError(err);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
sessionInfo.blacklistedSessionError = err;
|
|
468
|
+
if (initializationData.content !== undefined) {
|
|
469
|
+
var manifest = initializationData.content.manifest;
|
|
470
|
+
log.info("DRM: blacklisting Representations based on " +
|
|
471
|
+
"protection data.");
|
|
472
|
+
blackListProtectionData(manifest, initializationData);
|
|
473
|
+
}
|
|
474
|
+
_this._unlockInitDataQueue();
|
|
475
|
+
// TODO warning for blacklisted session?
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
this._canceller.signal.register(function () {
|
|
479
|
+
sub.unsubscribe();
|
|
480
|
+
});
|
|
481
|
+
if (options.singleLicensePer === undefined ||
|
|
482
|
+
options.singleLicensePer === "init-data") {
|
|
483
|
+
this._unlockInitDataQueue();
|
|
484
|
+
}
|
|
485
|
+
if (!(sessionRes.type === "created-session" /* Created */)) return [3 /*break*/, 5];
|
|
486
|
+
requestData = initializationData.values.constructRequestData();
|
|
487
|
+
_e.label = 2;
|
|
488
|
+
case 2:
|
|
489
|
+
_e.trys.push([2, 4, , 5]);
|
|
490
|
+
return [4 /*yield*/, generateKeyRequest(mediaKeySession, initializationData.type, requestData)];
|
|
491
|
+
case 3:
|
|
492
|
+
_e.sent();
|
|
493
|
+
return [3 /*break*/, 5];
|
|
494
|
+
case 4:
|
|
495
|
+
error_1 = _e.sent();
|
|
496
|
+
throw new EncryptedMediaError("KEY_GENERATE_REQUEST_ERROR", error_1 instanceof Error ? error_1.toString() :
|
|
497
|
+
"Unknown error");
|
|
498
|
+
case 5: return [2 /*return*/, PPromise.resolve()];
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
ContentDecryptor.prototype._tryToUseAlreadyCreatedSession = function (initializationData, mediaKeysData) {
|
|
504
|
+
var stores = mediaKeysData.stores, options = mediaKeysData.options;
|
|
505
|
+
/**
|
|
506
|
+
* If set, a currently-used key session is already compatible to this
|
|
507
|
+
* initialization data.
|
|
508
|
+
*/
|
|
509
|
+
var compatibleSessionInfo = arrayFind(this._currentSessions, function (x) { return x.record.isCompatibleWith(initializationData); });
|
|
510
|
+
if (compatibleSessionInfo === undefined) {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
// Check if the compatible session is blacklisted
|
|
514
|
+
var blacklistedSessionError = compatibleSessionInfo.blacklistedSessionError;
|
|
515
|
+
if (!isNullOrUndefined(blacklistedSessionError)) {
|
|
516
|
+
if (initializationData.type === undefined ||
|
|
517
|
+
initializationData.content === undefined) {
|
|
518
|
+
log.error("DRM: This initialization data has already been blacklisted " +
|
|
519
|
+
"but the current content is not known.");
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
log.info("DRM: This initialization data has already been blacklisted. " +
|
|
524
|
+
"Blacklisting the related content.");
|
|
525
|
+
var manifest = initializationData.content.manifest;
|
|
526
|
+
blackListProtectionData(manifest, initializationData);
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// Check if the current key id(s) has been blacklisted by this session
|
|
531
|
+
if (initializationData.keyIds !== undefined) {
|
|
532
|
+
/**
|
|
533
|
+
* If set to `true`, the Representation(s) linked to this
|
|
534
|
+
* initialization data's key id should be marked as "not decipherable".
|
|
535
|
+
*/
|
|
536
|
+
var isUndecipherable = void 0;
|
|
537
|
+
if (options.singleLicensePer === undefined ||
|
|
538
|
+
options.singleLicensePer === "init-data") {
|
|
539
|
+
// Note: In the default "init-data" mode, we only avoid a
|
|
540
|
+
// Representation if the key id was originally explicitely
|
|
541
|
+
// blacklisted (and not e.g. if its key was just not present in
|
|
542
|
+
// the license).
|
|
543
|
+
//
|
|
544
|
+
// This is to enforce v3.x.x retro-compatibility: we cannot
|
|
545
|
+
// fallback from a Representation unless some RxPlayer option
|
|
546
|
+
// documentating this behavior has been set.
|
|
547
|
+
var blacklisted = compatibleSessionInfo.keyStatuses.blacklisted;
|
|
548
|
+
isUndecipherable = areSomeKeyIdsContainedIn(initializationData.keyIds, blacklisted);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
// In any other mode, as soon as not all of this initialization
|
|
552
|
+
// data's linked key ids are explicitely whitelisted, we can mark
|
|
553
|
+
// the corresponding Representation as "not decipherable".
|
|
554
|
+
// This is because we've no such retro-compatibility guarantee to
|
|
555
|
+
// make there.
|
|
556
|
+
var whitelisted = compatibleSessionInfo.keyStatuses.whitelisted;
|
|
557
|
+
isUndecipherable = !areAllKeyIdsContainedIn(initializationData.keyIds, whitelisted);
|
|
558
|
+
}
|
|
559
|
+
if (isUndecipherable) {
|
|
560
|
+
if (initializationData.content === undefined) {
|
|
561
|
+
log.error("DRM: Cannot forbid key id, the content is unknown.");
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
log.info("DRM: Current initialization data is linked to blacklisted keys. " +
|
|
565
|
+
"Marking Representations as not decipherable");
|
|
566
|
+
updateDecipherability(initializationData.content.manifest, [], initializationData.keyIds);
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
// If we reached here, it means that this initialization data is not
|
|
571
|
+
// blacklisted in any way.
|
|
572
|
+
// Search loaded session and put it on top of the cache if it exists.
|
|
573
|
+
var entry = stores.loadedSessionsStore.reuse(initializationData);
|
|
574
|
+
if (entry !== null) {
|
|
575
|
+
// TODO update decipherability to `true` if not?
|
|
576
|
+
log.debug("DRM: Init data already processed. Skipping it.");
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
// Session not found in `loadedSessionsStore`, it might have been closed
|
|
580
|
+
// since.
|
|
581
|
+
// Remove from `this._currentSessions` and start again.
|
|
582
|
+
var indexOf = this._currentSessions.indexOf(compatibleSessionInfo);
|
|
583
|
+
if (indexOf === -1) {
|
|
584
|
+
log.error("DRM: Unable to remove processed init data: not found.");
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
log.debug("DRM: A session from a processed init data is not available " +
|
|
588
|
+
"anymore. Re-processing it.");
|
|
589
|
+
this._currentSessions.splice(indexOf, 1);
|
|
590
|
+
}
|
|
591
|
+
return false;
|
|
592
|
+
};
|
|
593
|
+
ContentDecryptor.prototype._onFatalError = function (err) {
|
|
594
|
+
if (this._canceller.isUsed) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
var formattedErr = err instanceof Error ?
|
|
598
|
+
err :
|
|
599
|
+
new OtherError("NONE", "Unknown encryption error");
|
|
600
|
+
this.error = formattedErr;
|
|
601
|
+
this._initDataQueue.length = 0;
|
|
602
|
+
this._stateData = { state: ContentDecryptorState.Error,
|
|
603
|
+
isMediaKeysAttached: undefined,
|
|
604
|
+
isInitDataQueueLocked: undefined,
|
|
605
|
+
data: null };
|
|
606
|
+
this._canceller.cancel();
|
|
607
|
+
this.trigger("error", formattedErr);
|
|
608
|
+
// The previous trigger might have lead to a disposal of the `ContentDecryptor`.
|
|
609
|
+
if (this._stateData.state === ContentDecryptorState.Error) {
|
|
610
|
+
this.trigger("stateChange", this._stateData.state);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* Return `true` if the `ContentDecryptor` has either been disposed or
|
|
615
|
+
* encountered a fatal error which made it stop.
|
|
616
|
+
* @returns {boolean}
|
|
617
|
+
*/
|
|
618
|
+
ContentDecryptor.prototype._isStopped = function () {
|
|
619
|
+
return this._stateData.state === ContentDecryptorState.Disposed ||
|
|
620
|
+
this._stateData.state === ContentDecryptorState.Error;
|
|
621
|
+
};
|
|
622
|
+
ContentDecryptor.prototype._processCurrentInitDataQueue = function () {
|
|
623
|
+
while (this._stateData.isInitDataQueueLocked === false) {
|
|
624
|
+
var initData = this._initDataQueue.shift();
|
|
625
|
+
if (initData === undefined) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
this.onInitializationData(initData);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
ContentDecryptor.prototype._lockInitDataQueue = function () {
|
|
632
|
+
if (this._stateData.isInitDataQueueLocked === false) {
|
|
633
|
+
this._stateData.isInitDataQueueLocked = true;
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
ContentDecryptor.prototype._unlockInitDataQueue = function () {
|
|
637
|
+
if (this._stateData.isMediaKeysAttached !== true) {
|
|
638
|
+
log.error("DRM: Trying to unlock in the wrong state");
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
this._stateData.isInitDataQueueLocked = false;
|
|
642
|
+
this._processCurrentInitDataQueue();
|
|
643
|
+
};
|
|
644
|
+
return ContentDecryptor;
|
|
645
|
+
}(EventEmitter));
|
|
646
|
+
export default ContentDecryptor;
|
|
647
|
+
/**
|
|
648
|
+
* Returns `true` if the given MediaKeySystemAccess can create
|
|
649
|
+
* "persistent-license" MediaKeySessions.
|
|
650
|
+
* @param {MediaKeySystemAccess} mediaKeySystemAccess
|
|
651
|
+
* @returns {Boolean}
|
|
652
|
+
*/
|
|
653
|
+
function canCreatePersistentSession(mediaKeySystemAccess) {
|
|
654
|
+
var sessionTypes = mediaKeySystemAccess.getConfiguration().sessionTypes;
|
|
655
|
+
return sessionTypes !== undefined &&
|
|
656
|
+
arrayIncludes(sessionTypes, "persistent-license");
|
|
657
|
+
}
|
|
658
|
+
function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIDs) {
|
|
659
|
+
manifest.updateRepresentationsDeciperability(function (representation) {
|
|
660
|
+
if (representation.contentProtections === undefined) {
|
|
661
|
+
return representation.decipherable;
|
|
662
|
+
}
|
|
663
|
+
var contentKIDs = representation.contentProtections.keyIds;
|
|
664
|
+
for (var i = 0; i < contentKIDs.length; i++) {
|
|
665
|
+
var elt = contentKIDs[i];
|
|
666
|
+
for (var j = 0; j < blacklistedKeyIDs.length; j++) {
|
|
667
|
+
if (areKeyIdsEqual(blacklistedKeyIDs[j], elt.keyId)) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
for (var j = 0; j < whitelistedKeyIds.length; j++) {
|
|
672
|
+
if (areKeyIdsEqual(whitelistedKeyIds[j], elt.keyId)) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return representation.decipherable;
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
function blackListProtectionData(manifest, initData) {
|
|
681
|
+
manifest.updateRepresentationsDeciperability(function (representation) {
|
|
682
|
+
var _a, _b;
|
|
683
|
+
if (representation.decipherable === false) {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
var segmentProtections = (_b = (_a = representation.contentProtections) === null || _a === void 0 ? void 0 : _a.initData) !== null && _b !== void 0 ? _b : [];
|
|
687
|
+
var _loop_1 = function (i) {
|
|
688
|
+
if (initData.type === undefined ||
|
|
689
|
+
segmentProtections[i].type === initData.type) {
|
|
690
|
+
var containedInitData = initData.values.getFormattedValues()
|
|
691
|
+
.every(function (undecipherableVal) {
|
|
692
|
+
return segmentProtections[i].values.some(function (currVal) {
|
|
693
|
+
return (undecipherableVal.systemId === undefined ||
|
|
694
|
+
currVal.systemId === undecipherableVal.systemId) &&
|
|
695
|
+
areArraysOfNumbersEqual(currVal.data, undecipherableVal.data);
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
if (containedInitData) {
|
|
699
|
+
return { value: false };
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
for (var i = 0; i < segmentProtections.length; i++) {
|
|
704
|
+
var state_1 = _loop_1(i);
|
|
705
|
+
if (typeof state_1 === "object")
|
|
706
|
+
return state_1.value;
|
|
707
|
+
}
|
|
708
|
+
return representation.decipherable;
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
/** Enumeration of the various "state" the `ContentDecryptor` can be in. */
|
|
712
|
+
export var ContentDecryptorState;
|
|
713
|
+
(function (ContentDecryptorState) {
|
|
714
|
+
/**
|
|
715
|
+
* The `ContentDecryptor` is not yet ready to create key sessions and request
|
|
716
|
+
* licenses.
|
|
717
|
+
* This is is the initial state of the ContentDecryptor.
|
|
718
|
+
*/
|
|
719
|
+
ContentDecryptorState[ContentDecryptorState["Initializing"] = 0] = "Initializing";
|
|
720
|
+
/**
|
|
721
|
+
* The `ContentDecryptor` has been initialized.
|
|
722
|
+
* You should now called the `attach` method when you want to add decryption
|
|
723
|
+
* capabilities to the HTMLMediaElement. The ContentDecryptor won't go to the
|
|
724
|
+
* `ReadyForContent` state until `attach` is called.
|
|
725
|
+
*
|
|
726
|
+
* For compatibility reasons, this should be done after the HTMLMediaElement's
|
|
727
|
+
* src attribute is set.
|
|
728
|
+
*
|
|
729
|
+
* It is also from when this state is reached that the `ContentDecryptor`'s
|
|
730
|
+
* `systemId` property may be known.
|
|
731
|
+
*
|
|
732
|
+
* This state is always coming after the `Initializing` state.
|
|
733
|
+
*/
|
|
734
|
+
ContentDecryptorState[ContentDecryptorState["WaitingForAttachment"] = 1] = "WaitingForAttachment";
|
|
735
|
+
/**
|
|
736
|
+
* Content (encrypted or not) can begin to be pushed on the HTMLMediaElement
|
|
737
|
+
* (this state was needed because some browser quirks sometimes forces us to
|
|
738
|
+
* call EME API before this can be done).
|
|
739
|
+
*
|
|
740
|
+
* This state is always coming after the `WaitingForAttachment` state.
|
|
741
|
+
*/
|
|
742
|
+
ContentDecryptorState[ContentDecryptorState["ReadyForContent"] = 2] = "ReadyForContent";
|
|
743
|
+
/**
|
|
744
|
+
* The `ContentDecryptor` has encountered a fatal error and has been stopped.
|
|
745
|
+
* It is now unusable.
|
|
746
|
+
*/
|
|
747
|
+
ContentDecryptorState[ContentDecryptorState["Error"] = 3] = "Error";
|
|
748
|
+
/** The `ContentDecryptor` has been disposed of and is now unusable. */
|
|
749
|
+
ContentDecryptorState[ContentDecryptorState["Disposed"] = 4] = "Disposed";
|
|
750
|
+
})(ContentDecryptorState || (ContentDecryptorState = {}));
|
|
751
|
+
/**
|
|
752
|
+
* Returns information on all keys - explicit or implicit - that are linked to
|
|
753
|
+
* a loaded license.
|
|
754
|
+
*
|
|
755
|
+
* In the RxPlayer, there is a concept of "explicit" key ids, which are key ids
|
|
756
|
+
* found in a license whose status can be known through the `keyStatuses`
|
|
757
|
+
* property from a `MediaKeySession`, and of "implicit" key ids, which are key
|
|
758
|
+
* ids which were expected to be in a fetched license, but apparently weren't.
|
|
759
|
+
* @param {Object} initializationData
|
|
760
|
+
* @param {string|undefined} singleLicensePer
|
|
761
|
+
* @param {Array.<Uint8Array>} usableKeyIds
|
|
762
|
+
* @param {Array.<Uint8Array>} unusableKeyIds
|
|
763
|
+
* @returns {Object}
|
|
764
|
+
*/
|
|
765
|
+
function getFetchedLicenseKeysInfo(initializationData, singleLicensePer, usableKeyIds, unusableKeyIds) {
|
|
766
|
+
var _a;
|
|
767
|
+
/**
|
|
768
|
+
* Every key id associated with the MediaKeySession, starting with
|
|
769
|
+
* whitelisted ones.
|
|
770
|
+
*/
|
|
771
|
+
var associatedKeyIds = __spreadArray(__spreadArray([], usableKeyIds, true), unusableKeyIds, true);
|
|
772
|
+
if (singleLicensePer !== undefined && singleLicensePer !== "init-data") {
|
|
773
|
+
// We want to add the current key ids in the blacklist if it is
|
|
774
|
+
// not already there.
|
|
775
|
+
//
|
|
776
|
+
// We only do that when `singleLicensePer` is set to something
|
|
777
|
+
// else than the default `"init-data"` because this logic:
|
|
778
|
+
// 1. might result in a quality fallback, which is a v3.x.x
|
|
779
|
+
// breaking change if some APIs (like `singleLicensePer`)
|
|
780
|
+
// aren't used.
|
|
781
|
+
// 2. Rely on the EME spec regarding key statuses being well
|
|
782
|
+
// implemented on all supported devices, which we're not
|
|
783
|
+
// sure yet. Because in any other `singleLicensePer`, we
|
|
784
|
+
// need a good implementation anyway, it doesn't matter
|
|
785
|
+
// there.
|
|
786
|
+
var expectedKeyIds = initializationData.keyIds, content = initializationData.content;
|
|
787
|
+
if (expectedKeyIds !== undefined) {
|
|
788
|
+
var missingKeyIds = expectedKeyIds.filter(function (expected) {
|
|
789
|
+
return !associatedKeyIds.some(function (k) { return areKeyIdsEqual(k, expected); });
|
|
790
|
+
});
|
|
791
|
+
if (missingKeyIds.length > 0) {
|
|
792
|
+
associatedKeyIds.push.apply(associatedKeyIds, missingKeyIds);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (content !== undefined) {
|
|
796
|
+
if (singleLicensePer === "content") {
|
|
797
|
+
// Put it in a Set to automatically filter out duplicates (by ref)
|
|
798
|
+
var contentKeys = new Set();
|
|
799
|
+
var manifest = content.manifest;
|
|
800
|
+
for (var _i = 0, _b = manifest.periods; _i < _b.length; _i++) {
|
|
801
|
+
var period = _b[_i];
|
|
802
|
+
addKeyIdsFromPeriod(contentKeys, period);
|
|
803
|
+
}
|
|
804
|
+
mergeKeyIdSetIntoArray(contentKeys, associatedKeyIds);
|
|
805
|
+
}
|
|
806
|
+
else if (singleLicensePer === "periods") {
|
|
807
|
+
var manifest = content.manifest;
|
|
808
|
+
for (var _c = 0, _d = manifest.periods; _c < _d.length; _c++) {
|
|
809
|
+
var period = _d[_c];
|
|
810
|
+
var periodKeys = new Set();
|
|
811
|
+
addKeyIdsFromPeriod(periodKeys, period);
|
|
812
|
+
if (((_a = initializationData.content) === null || _a === void 0 ? void 0 : _a.period.id) === period.id) {
|
|
813
|
+
mergeKeyIdSetIntoArray(periodKeys, associatedKeyIds);
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
var periodKeysArr = Array.from(periodKeys);
|
|
817
|
+
var _loop_2 = function (kid) {
|
|
818
|
+
var isFound = associatedKeyIds.some(function (k) { return areKeyIdsEqual(k, kid); });
|
|
819
|
+
if (isFound) {
|
|
820
|
+
mergeKeyIdSetIntoArray(periodKeys, associatedKeyIds);
|
|
821
|
+
return "break";
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
for (var _e = 0, periodKeysArr_3 = periodKeysArr; _e < periodKeysArr_3.length; _e++) {
|
|
825
|
+
var kid = periodKeysArr_3[_e];
|
|
826
|
+
var state_2 = _loop_2(kid);
|
|
827
|
+
if (state_2 === "break")
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return { whitelisted: usableKeyIds,
|
|
836
|
+
/** associatedKeyIds starts with the whitelisted one. */
|
|
837
|
+
blacklisted: associatedKeyIds.slice(usableKeyIds.length) };
|
|
838
|
+
}
|
|
839
|
+
function mergeKeyIdSetIntoArray(set, arr) {
|
|
840
|
+
var setArr = Array.from(set.values());
|
|
841
|
+
var _loop_3 = function (kid) {
|
|
842
|
+
var isFound = arr.some(function (k) { return areKeyIdsEqual(k, kid); });
|
|
843
|
+
if (!isFound) {
|
|
844
|
+
arr.push(kid);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
for (var _i = 0, setArr_1 = setArr; _i < setArr_1.length; _i++) {
|
|
848
|
+
var kid = setArr_1[_i];
|
|
849
|
+
_loop_3(kid);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
function addKeyIdsFromPeriod(set, period) {
|
|
853
|
+
for (var _i = 0, _a = period.getAdaptations(); _i < _a.length; _i++) {
|
|
854
|
+
var adaptation = _a[_i];
|
|
855
|
+
for (var _b = 0, _c = adaptation.representations; _b < _c.length; _b++) {
|
|
856
|
+
var representation = _c[_b];
|
|
857
|
+
if (representation.contentProtections !== undefined &&
|
|
858
|
+
representation.contentProtections.keyIds.length >= -1) {
|
|
859
|
+
for (var _d = 0, _e = representation.contentProtections.keyIds; _d < _e.length; _d++) {
|
|
860
|
+
var kidInf = _e[_d];
|
|
861
|
+
set.add(kidInf.keyId);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|