rx-player 3.26.3-dev.2022021400 → 3.27.0-dev.2022032100
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/.eslintrc.js +0 -4
- package/CHANGELOG.md +17 -2
- 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 +143 -36
- package/dist/_esm5.processed/compat/eme/custom_key_system_access.d.ts +15 -0
- package/dist/_esm5.processed/compat/eme/custom_key_system_access.js +1 -17
- package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.js +6 -7
- 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 +20 -22
- package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +58 -40
- package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +49 -48
- 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 +67 -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/network_analyzer.js +2 -1
- 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.js +2 -1
- package/dist/_esm5.processed/core/api/option_utils.d.ts +6 -3
- package/dist/_esm5.processed/core/api/option_utils.js +21 -7
- 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 +73 -35
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.d.ts +7 -49
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.js +25 -65
- package/dist/_esm5.processed/core/{eme → decrypt}/attach_media_keys.d.ts +12 -12
- package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +103 -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 +40 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +216 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +865 -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 +173 -0
- package/dist/_esm5.processed/core/{eme/dispose_media_keys.d.ts → decrypt/dispose_decryption_resources.d.ts} +4 -4
- 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 +299 -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 +119 -241
- 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 +84 -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 +302 -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.js +3 -5
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +1 -1
- 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 +2 -3
- package/dist/_esm5.processed/core/init/get_initial_time.js +1 -1
- package/dist/_esm5.processed/core/init/initialize_directfile.d.ts +1 -1
- package/dist/_esm5.processed/core/init/initialize_directfile.js +11 -17
- package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +6 -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.js +2 -1
- package/dist/_esm5.processed/core/init/stall_avoider.js +1 -1
- package/dist/_esm5.processed/core/init/stream_events_emitter/stream_events_emitter.js +1 -1
- 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.js +3 -1
- 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/index.d.ts +1 -0
- 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.d.ts +15 -11
- package/dist/_esm5.processed/core/stream/period/get_adaptation_switch_strategy.js +6 -3
- package/dist/_esm5.processed/core/stream/period/index.d.ts +1 -0
- package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +5 -12
- package/dist/_esm5.processed/core/stream/period/period_stream.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/force_garbage_collection.js +2 -2
- 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/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.js +6 -7
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.js +2 -3
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +15 -0
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +3 -5
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +3 -5
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +1 -2
- 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/manifest.d.ts +1 -14
- package/dist/_esm5.processed/manifest/manifest.js +10 -74
- package/dist/_esm5.processed/manifest/representation.d.ts +35 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/is_period_fulfilled.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +87 -75
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +4 -5
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +1 -0
- package/dist/_esm5.processed/public_types.d.ts +3 -2
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +1 -2
- package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +4 -3
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +60 -11
- package/dist/_esm5.processed/transports/dash/init_segment_loader.js +1 -2
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
- package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.js +3 -4
- package/dist/_esm5.processed/transports/dash/segment_parser.js +6 -3
- package/dist/_esm5.processed/transports/dash/text_loader.js +1 -2
- package/dist/_esm5.processed/transports/dash/text_parser.js +8 -2
- package/dist/_esm5.processed/transports/local/segment_loader.js +2 -3
- 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/pipelines.js +2 -3
- package/dist/_esm5.processed/transports/smooth/pipelines.js +71 -14
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +3 -4
- package/dist/_esm5.processed/transports/types.d.ts +22 -0
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +1 -2
- package/dist/_esm5.processed/utils/cancellable_sleep.js +1 -2
- package/dist/_esm5.processed/utils/cast_to_observable.js +1 -3
- 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.js +1 -2
- package/dist/_esm5.processed/utils/request/xhr.js +2 -3
- 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 +4936 -3340
- package/dist/rx-player.min.js +1 -1
- package/dummy +1 -0
- package/{dist/_esm5.processed/utils/promise.d.ts → experimental/index.d.ts} +1 -2
- package/{dist/_esm5.processed/utils/promise.js → experimental/index.js} +1 -3
- package/package.json +32 -35
- package/{src/typings/pinkie.d.ts → scripts/build/templates/experimental/index.d.ts} +1 -4
- package/scripts/build/templates/experimental/index.js +16 -0
- package/scripts/update-version +2 -2
- package/sonar-project.properties +1 -1
- package/src/README.md +6 -6
- package/src/compat/__tests__/play.test.ts +2 -4
- 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 +89 -56
- package/src/compat/eme/custom_key_system_access.ts +1 -2
- package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +6 -7
- package/src/compat/eme/custom_media_keys/index.ts +20 -38
- package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +68 -52
- package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +57 -56
- package/src/compat/eme/generate_key_request.ts +25 -33
- package/src/compat/eme/load_session.ts +28 -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/bandwidth_estimator.ts +4 -4
- package/src/core/abr/network_analyzer.ts +5 -6
- package/src/core/api/__tests__/get_player_state.test.ts +3 -3
- package/src/core/api/__tests__/option_utils.test.ts +29 -17
- package/src/core/api/get_player_state.ts +1 -1
- package/src/core/api/index.ts +3 -0
- package/src/core/api/option_utils.ts +42 -23
- package/src/core/api/playback_observer.ts +12 -8
- package/src/core/api/public_api.ts +152 -113
- 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 +31 -93
- package/src/core/{eme → decrypt}/attach_media_keys.ts +48 -56
- package/src/core/decrypt/clear_on_stop.ts +47 -0
- package/src/core/decrypt/content_decryptor.ts +1157 -0
- package/src/core/decrypt/create_or_load_session.ts +130 -0
- package/src/core/decrypt/create_session.ts +174 -0
- package/src/core/decrypt/dispose_decryption_resources.ts +39 -0
- package/src/core/{eme → decrypt}/find_key_system.ts +111 -122
- 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 +128 -258
- 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} +19 -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 +317 -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 +5 -7
- package/src/core/fetchers/segment/segment_fetcher.ts +4 -4
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +2 -2
- package/src/core/fetchers/utils/try_urls_with_backoff.ts +2 -3
- 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 +17 -20
- package/src/core/init/initialize_media_source.ts +44 -106
- package/src/core/init/link_drm_and_content.ts +176 -0
- package/src/core/init/manifest_update_scheduler.ts +5 -3
- package/src/core/init/stall_avoider.ts +6 -5
- package/src/core/init/stream_events_emitter/stream_events_emitter.ts +2 -1
- 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 +3 -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/index.ts +1 -0
- 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 +25 -15
- package/src/core/stream/period/index.ts +1 -0
- package/src/core/stream/period/period_stream.ts +10 -16
- package/src/core/stream/representation/force_garbage_collection.ts +2 -2
- 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/experimental/index.ts +5 -0
- package/src/experimental/tools/VideoThumbnailLoader/push_data.ts +1 -0
- package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +7 -7
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +3 -10
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +9 -10
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/decodingInfos.test.ts +2 -4
- package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +2 -3
- package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +3 -5
- package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +3 -5
- package/src/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +1 -2
- 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/manifest.ts +6 -76
- package/src/manifest/representation.ts +36 -3
- package/src/parsers/manifest/dash/common/indexes/is_period_fulfilled.ts +1 -2
- package/src/parsers/manifest/dash/common/indexes/template.ts +1 -2
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +1 -1
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +109 -64
- package/src/parsers/manifest/dash/common/parse_mpd.ts +1 -2
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +4 -5
- package/src/parsers/manifest/smooth/create_parser.ts +1 -0
- package/src/parsers/texttracks/webvtt/html/__tests__/create_styled_element.test.ts +1 -0
- package/src/public_types.ts +6 -1
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +1 -2
- package/src/transports/dash/image_pipelines.ts +15 -14
- package/src/transports/dash/init_segment_loader.ts +1 -2
- package/src/transports/dash/manifest_parser.ts +2 -3
- package/src/transports/dash/segment_loader.ts +4 -5
- package/src/transports/dash/segment_parser.ts +5 -0
- package/src/transports/dash/text_loader.ts +2 -3
- package/src/transports/dash/text_parser.ts +8 -0
- package/src/transports/local/segment_loader.ts +2 -3
- package/src/transports/local/segment_parser.ts +4 -0
- package/src/transports/local/text_parser.ts +8 -0
- package/src/transports/metaplaylist/pipelines.ts +2 -3
- package/src/transports/smooth/pipelines.ts +26 -14
- package/src/transports/smooth/segment_loader.ts +5 -6
- package/src/transports/types.ts +22 -0
- package/src/transports/utils/call_custom_manifest_loader.ts +1 -2
- package/src/utils/__tests__/deep_merge.test.ts +48 -0
- package/src/utils/cancellable_sleep.ts +1 -2
- package/src/utils/cast_to_observable.ts +0 -2
- package/src/utils/deep_merge.ts +46 -0
- package/src/utils/reference.ts +116 -23
- package/src/utils/request/fetch.ts +1 -2
- package/src/utils/request/xhr.ts +3 -3
- package/src/utils/rx-from_cancellable_promise.ts +7 -2
- package/src/utils/task_canceller.ts +6 -4
- package/tsconfig.json +0 -1
- package/tsconfig.modules.json +0 -1
- 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.d.ts +0 -19
- 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 -253
- 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/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
- package/src/utils/__tests__/promise.test.ts +0 -23
- package/src/utils/promise.ts +0 -20
|
@@ -56,11 +56,10 @@ import areArraysOfNumbersEqual from "../../utils/are_arrays_of_numbers_equal";
|
|
|
56
56
|
import EventEmitter, { fromEvent, } from "../../utils/event_emitter";
|
|
57
57
|
import isNullOrUndefined from "../../utils/is_null_or_undefined";
|
|
58
58
|
import objectAssign from "../../utils/object_assign";
|
|
59
|
-
import PPromise from "../../utils/promise";
|
|
60
59
|
import { getLeftSizeOfRange, getPlayedSizeOfRange, getSizeOfRange, } from "../../utils/ranges";
|
|
61
60
|
import createSharedReference from "../../utils/reference";
|
|
62
61
|
import warnOnce from "../../utils/warn_once";
|
|
63
|
-
import {
|
|
62
|
+
import { clearOnStop, disposeDecryptionResources, getCurrentKeySystem, } from "../decrypt";
|
|
64
63
|
import { ManifestFetcher, SegmentFetcherCreator, } from "../fetchers";
|
|
65
64
|
import initializeMediaSourcePlayback from "../init";
|
|
66
65
|
import emitSeekEvents from "./emit_seek_events";
|
|
@@ -69,7 +68,6 @@ import { checkReloadOptions, parseConstructorOptions, parseLoadVideoOptions, } f
|
|
|
69
68
|
import PlaybackObserver from "./playback_observer";
|
|
70
69
|
import TrackChoiceManager from "./track_choice_manager";
|
|
71
70
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
72
|
-
var DEFAULT_UNMUTED_VOLUME = config.DEFAULT_UNMUTED_VOLUME;
|
|
73
71
|
var isPageActive = events.isPageActive, isVideoVisible = events.isVideoVisible, onEnded$ = events.onEnded$, onFullscreenChange$ = events.onFullscreenChange$, onPlayPause$ = events.onPlayPause$, onPictureInPictureEvent$ = events.onPictureInPictureEvent$, onSeeking$ = events.onSeeking$, onTextTrackChanges$ = events.onTextTrackChanges$, videoWidth$ = events.videoWidth$;
|
|
74
72
|
/**
|
|
75
73
|
* @class Player
|
|
@@ -84,11 +82,12 @@ var Player = /** @class */ (function (_super) {
|
|
|
84
82
|
function Player(options) {
|
|
85
83
|
if (options === void 0) { options = {}; }
|
|
86
84
|
var _this = _super.call(this) || this;
|
|
87
|
-
var _a = parseConstructorOptions(options), initialAudioBitrate = _a.initialAudioBitrate, initialVideoBitrate = _a.initialVideoBitrate, limitVideoWidth = _a.limitVideoWidth, minAudioBitrate = _a.minAudioBitrate, minVideoBitrate = _a.minVideoBitrate, maxAudioBitrate = _a.maxAudioBitrate, maxBufferAhead = _a.maxBufferAhead, maxBufferBehind = _a.maxBufferBehind, maxVideoBitrate = _a.maxVideoBitrate, preferredAudioTracks = _a.preferredAudioTracks, preferredTextTracks = _a.preferredTextTracks, preferredVideoTracks = _a.preferredVideoTracks, throttleWhenHidden = _a.throttleWhenHidden, throttleVideoBitrateWhenHidden = _a.throttleVideoBitrateWhenHidden, videoElement = _a.videoElement, wantedBufferAhead = _a.wantedBufferAhead, stopAtEnd = _a.stopAtEnd;
|
|
85
|
+
var _a = parseConstructorOptions(options), initialAudioBitrate = _a.initialAudioBitrate, initialVideoBitrate = _a.initialVideoBitrate, limitVideoWidth = _a.limitVideoWidth, minAudioBitrate = _a.minAudioBitrate, minVideoBitrate = _a.minVideoBitrate, maxAudioBitrate = _a.maxAudioBitrate, maxBufferAhead = _a.maxBufferAhead, maxBufferBehind = _a.maxBufferBehind, maxVideoBitrate = _a.maxVideoBitrate, preferredAudioTracks = _a.preferredAudioTracks, preferredTextTracks = _a.preferredTextTracks, preferredVideoTracks = _a.preferredVideoTracks, throttleWhenHidden = _a.throttleWhenHidden, throttleVideoBitrateWhenHidden = _a.throttleVideoBitrateWhenHidden, videoElement = _a.videoElement, wantedBufferAhead = _a.wantedBufferAhead, maxVideoBufferSize = _a.maxVideoBufferSize, stopAtEnd = _a.stopAtEnd;
|
|
86
|
+
var DEFAULT_UNMUTED_VOLUME = config.getCurrent().DEFAULT_UNMUTED_VOLUME;
|
|
88
87
|
// Workaround to support Firefox autoplay on FF 42.
|
|
89
88
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
|
|
90
89
|
videoElement.preload = "auto";
|
|
91
|
-
_this.version = /* PLAYER_VERSION */ "3.
|
|
90
|
+
_this.version = /* PLAYER_VERSION */ "3.27.0-dev.2022032100";
|
|
92
91
|
_this.log = log;
|
|
93
92
|
_this.state = "STOPPED";
|
|
94
93
|
_this.videoElement = videoElement;
|
|
@@ -138,6 +137,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
138
137
|
wantedBufferAhead: createSharedReference(wantedBufferAhead),
|
|
139
138
|
maxBufferAhead: createSharedReference(maxBufferAhead),
|
|
140
139
|
maxBufferBehind: createSharedReference(maxBufferBehind),
|
|
140
|
+
maxVideoBufferSize: createSharedReference(maxVideoBufferSize),
|
|
141
141
|
};
|
|
142
142
|
_this._priv_bitrateInfos = {
|
|
143
143
|
lastBitrates: { audio: initialAudioBitrate,
|
|
@@ -224,8 +224,13 @@ var Player = /** @class */ (function (_super) {
|
|
|
224
224
|
// free resources linked to the loaded content
|
|
225
225
|
this.stop();
|
|
226
226
|
if (this.videoElement !== null) {
|
|
227
|
-
// free resources used for
|
|
228
|
-
|
|
227
|
+
// free resources used for decryption management
|
|
228
|
+
disposeDecryptionResources(this.videoElement)
|
|
229
|
+
.catch(function (err) {
|
|
230
|
+
var message = err instanceof Error ? err.message :
|
|
231
|
+
"Unknown error";
|
|
232
|
+
log.error("API: Could not dispose decryption resources: " + message);
|
|
233
|
+
});
|
|
229
234
|
}
|
|
230
235
|
// free Observables linked to the Player instance
|
|
231
236
|
this._priv_destroy$.next();
|
|
@@ -236,6 +241,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
236
241
|
this._priv_speed.finish();
|
|
237
242
|
this._priv_contentLock.finish();
|
|
238
243
|
this._priv_bufferOptions.wantedBufferAhead.finish();
|
|
244
|
+
this._priv_bufferOptions.maxVideoBufferSize.finish();
|
|
239
245
|
this._priv_bufferOptions.maxBufferAhead.finish();
|
|
240
246
|
this._priv_bufferOptions.maxBufferBehind.finish();
|
|
241
247
|
this._priv_bitrateInfos.manualBitrates.video.finish();
|
|
@@ -527,18 +533,23 @@ var Player = /** @class */ (function (_super) {
|
|
|
527
533
|
}));
|
|
528
534
|
/** Emit all player "state" updates. */
|
|
529
535
|
var playerState$ = observableConcat(observableOf(PLAYER_STATES.LOADING), // Begin with LOADING
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
536
|
+
loaded$.pipe(switchMap(function (_, i) {
|
|
537
|
+
var isFirstLoad = i === 0;
|
|
538
|
+
return observableMerge(
|
|
539
|
+
// Purposely subscribed first so a RELOADING triggered synchronously
|
|
540
|
+
// after a LOADED state is catched.
|
|
541
|
+
reloading$.pipe(map(function () { return PLAYER_STATES.RELOADING; })),
|
|
542
|
+
// Only switch to LOADED state for the first (i.e. non-RELOADING) load
|
|
543
|
+
isFirstLoad ? observableOf(PLAYER_STATES.LOADED) :
|
|
544
|
+
EMPTY,
|
|
545
|
+
// Purposely put last so any other state change happens after we've
|
|
546
|
+
// already switched to LOADED
|
|
547
|
+
loadedStateUpdates$.pipe(takeUntil(reloading$),
|
|
548
|
+
// For the first load, we prefer staying at the LOADED state over
|
|
549
|
+
// PAUSED when autoPlay is disabled.
|
|
550
|
+
// For consecutive loads however, there's no LOADED state.
|
|
551
|
+
skipWhile(function (state) { return isFirstLoad && state === PLAYER_STATES.PAUSED; })));
|
|
552
|
+
}))).pipe(distinctUntilChanged());
|
|
542
553
|
var playbackSubscription;
|
|
543
554
|
stopContent$
|
|
544
555
|
.pipe(take(1))
|
|
@@ -794,7 +805,22 @@ var Player = /** @class */ (function (_super) {
|
|
|
794
805
|
}
|
|
795
806
|
var _a = this._priv_contentInfos, isDirectFile = _a.isDirectFile, manifest = _a.manifest;
|
|
796
807
|
if (isDirectFile) {
|
|
797
|
-
|
|
808
|
+
// Calculating the "wall-clock time" necessitate to obtain first an offset,
|
|
809
|
+
// and then adding that offset to the HTMLMediaElement's current position.
|
|
810
|
+
// That offset is in most case present inside the Manifest file, yet in
|
|
811
|
+
// directfile mode, the RxPlayer won't parse that file, the browser does it.
|
|
812
|
+
//
|
|
813
|
+
// Thankfully Safari declares a `getStartDate` method allowing to obtain
|
|
814
|
+
// that offset when available. This logic is thus mainly useful when
|
|
815
|
+
// playing HLS contents in directfile mode on Safari.
|
|
816
|
+
var mediaElement = this.videoElement;
|
|
817
|
+
if (typeof mediaElement.getStartDate === "function") {
|
|
818
|
+
var startDate = mediaElement.getStartDate();
|
|
819
|
+
if (typeof startDate === "number" && !isNaN(startDate)) {
|
|
820
|
+
return startDate + mediaElement.currentTime;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return mediaElement.currentTime;
|
|
798
824
|
}
|
|
799
825
|
if (manifest !== null) {
|
|
800
826
|
var currentTime = this.videoElement.currentTime;
|
|
@@ -1018,7 +1044,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
1018
1044
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
1019
1045
|
if (isNullOrUndefined(playPromise) || typeof playPromise.catch !== "function") {
|
|
1020
1046
|
/* eslint-enable @typescript-eslint/unbound-method */
|
|
1021
|
-
return
|
|
1047
|
+
return Promise.resolve();
|
|
1022
1048
|
}
|
|
1023
1049
|
return playPromise.catch(function (error) {
|
|
1024
1050
|
if (error.name === "NotAllowedError") {
|
|
@@ -1173,6 +1199,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
1173
1199
|
* If the volume was set to 0, set a default volume instead (see config).
|
|
1174
1200
|
*/
|
|
1175
1201
|
Player.prototype.unMute = function () {
|
|
1202
|
+
var DEFAULT_UNMUTED_VOLUME = config.getCurrent().DEFAULT_UNMUTED_VOLUME;
|
|
1176
1203
|
var vol = this.getVolume();
|
|
1177
1204
|
if (vol === 0) {
|
|
1178
1205
|
this.setVolume(this._priv_mutedMemory === 0 ? DEFAULT_UNMUTED_VOLUME :
|
|
@@ -1271,6 +1298,14 @@ var Player = /** @class */ (function (_super) {
|
|
|
1271
1298
|
Player.prototype.setWantedBufferAhead = function (sizeInSeconds) {
|
|
1272
1299
|
this._priv_bufferOptions.wantedBufferAhead.setValue(sizeInSeconds);
|
|
1273
1300
|
};
|
|
1301
|
+
/**
|
|
1302
|
+
* Set the max buffer size the buffer should take in memory
|
|
1303
|
+
* The player . will stop downloading chunks when this size is reached.
|
|
1304
|
+
* @param {Number} sizeInKBytes
|
|
1305
|
+
*/
|
|
1306
|
+
Player.prototype.setMaxVideoBufferSize = function (sizeInKBytes) {
|
|
1307
|
+
this._priv_bufferOptions.maxVideoBufferSize.setValue(sizeInKBytes);
|
|
1308
|
+
};
|
|
1274
1309
|
/**
|
|
1275
1310
|
* Returns the max buffer size for the buffer behind the current position.
|
|
1276
1311
|
* @returns {Number}
|
|
@@ -1292,6 +1327,13 @@ var Player = /** @class */ (function (_super) {
|
|
|
1292
1327
|
Player.prototype.getWantedBufferAhead = function () {
|
|
1293
1328
|
return this._priv_bufferOptions.wantedBufferAhead.getValue();
|
|
1294
1329
|
};
|
|
1330
|
+
/**
|
|
1331
|
+
* Returns the max buffer memory size for the buffer in kilobytes
|
|
1332
|
+
* @returns {Number}
|
|
1333
|
+
*/
|
|
1334
|
+
Player.prototype.getMaxVideoBufferSize = function () {
|
|
1335
|
+
return this._priv_bufferOptions.maxVideoBufferSize.getValue();
|
|
1336
|
+
};
|
|
1295
1337
|
/**
|
|
1296
1338
|
* Returns type of current keysystem (e.g. playready, widevine) if the content
|
|
1297
1339
|
* is encrypted. null otherwise.
|
|
@@ -1712,24 +1754,20 @@ var Player = /** @class */ (function (_super) {
|
|
|
1712
1754
|
(_a = this._priv_mediaElementTrackChoiceManager) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
1713
1755
|
this._priv_mediaElementTrackChoiceManager = null;
|
|
1714
1756
|
this._priv_contentEventsMemory = {};
|
|
1715
|
-
//
|
|
1757
|
+
// DRM-related clean-up
|
|
1716
1758
|
var freeUpContentLock = function () {
|
|
1717
1759
|
log.debug("Unlocking `contentLock`. Next content can begin.");
|
|
1718
1760
|
_this._priv_contentLock.setValue(false);
|
|
1719
1761
|
};
|
|
1720
1762
|
if (!isNullOrUndefined(this.videoElement)) {
|
|
1721
|
-
|
|
1722
|
-
.
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
complete: function () {
|
|
1730
|
-
log.debug("API: EME session cleaned-up with success!");
|
|
1731
|
-
freeUpContentLock();
|
|
1732
|
-
},
|
|
1763
|
+
clearOnStop(this.videoElement).then(function () {
|
|
1764
|
+
log.debug("API: DRM session cleaned-up with success!");
|
|
1765
|
+
freeUpContentLock();
|
|
1766
|
+
}, function (err) {
|
|
1767
|
+
log.error("API: An error arised when trying to clean-up the DRM session:" +
|
|
1768
|
+
(err instanceof Error ? err.toString() :
|
|
1769
|
+
"Unknown Error"));
|
|
1770
|
+
freeUpContentLock();
|
|
1733
1771
|
});
|
|
1734
1772
|
}
|
|
1735
1773
|
else {
|
|
@@ -2264,5 +2302,5 @@ var Player = /** @class */ (function (_super) {
|
|
|
2264
2302
|
};
|
|
2265
2303
|
return Player;
|
|
2266
2304
|
}(EventEmitter));
|
|
2267
|
-
Player.version = /* PLAYER_VERSION */ "3.
|
|
2305
|
+
Player.version = /* PLAYER_VERSION */ "3.27.0-dev.2022032100";
|
|
2268
2306
|
export default Player;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
/// <reference types="jest" />
|
|
17
|
-
import {
|
|
17
|
+
import { Subject } from "rxjs";
|
|
18
18
|
import { IEncryptedEventData } from "../../../../compat/eme";
|
|
19
19
|
import EventEmitter from "../../../../utils/event_emitter";
|
|
20
20
|
/** Default MediaKeySystemAccess configuration used by the RxPlayer. */
|
|
@@ -97,7 +97,7 @@ export declare class MediaKeySystemAccessImpl {
|
|
|
97
97
|
createMediaKeys(): Promise<MediaKeysImpl>;
|
|
98
98
|
getConfiguration(): MediaKeySystemConfiguration[];
|
|
99
99
|
}
|
|
100
|
-
export declare function requestMediaKeySystemAccessImpl(keySystem: string, config: MediaKeySystemConfiguration[]):
|
|
100
|
+
export declare function requestMediaKeySystemAccessImpl(keySystem: string, config: MediaKeySystemConfiguration[]): Promise<MediaKeySystemAccessImpl>;
|
|
101
101
|
/**
|
|
102
102
|
* Mock functions coming from the compat directory.
|
|
103
103
|
*/
|
|
@@ -109,15 +109,13 @@ export declare function mockCompat(exportedFunctions?: {}): {
|
|
|
109
109
|
triggerKeyError: Subject<unknown>;
|
|
110
110
|
triggerKeyStatusesChange: Subject<unknown>;
|
|
111
111
|
};
|
|
112
|
-
requestMediaKeySystemAccessSpy: jest.Mock<
|
|
112
|
+
requestMediaKeySystemAccessSpy: jest.Mock<Promise<MediaKeySystemAccessImpl>, [keySystem: string, config: MediaKeySystemConfiguration[]]>;
|
|
113
113
|
getInitDataSpy: jest.Mock<IEncryptedEventData, [encryptedEvent: IEncryptedEventData]>;
|
|
114
|
-
setMediaKeysSpy: jest.Mock<
|
|
115
|
-
generateKeyRequestSpy: jest.Mock<
|
|
114
|
+
setMediaKeysSpy: jest.Mock<any, any>;
|
|
115
|
+
generateKeyRequestSpy: jest.Mock<Promise<void>, [mks: MediaKeySessionImpl, initializationDataType: any, initializationData: any]>;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
-
* Check that the
|
|
119
|
-
* directly without any event emitted.
|
|
120
|
-
*
|
|
118
|
+
* Check that the ContentDecryptor, when called with those arguments, throws.
|
|
121
119
|
* If that's the case, resolve with the corresponding error.
|
|
122
120
|
* Else, reject.
|
|
123
121
|
* @param {HTMLMediaElement} mediaElement
|
|
@@ -125,47 +123,7 @@ export declare function mockCompat(exportedFunctions?: {}): {
|
|
|
125
123
|
* @param {Observable} contentProtections$
|
|
126
124
|
* @returns {Promise}
|
|
127
125
|
*/
|
|
128
|
-
export declare function
|
|
129
|
-
/**
|
|
130
|
-
* Check that the event received corresponds to the session-message event for a
|
|
131
|
-
* license request.
|
|
132
|
-
* @param {Object} evt
|
|
133
|
-
* @param {Object} initDataVal
|
|
134
|
-
*/
|
|
135
|
-
export declare function expectLicenseRequestMessage(evt: {
|
|
136
|
-
type: string;
|
|
137
|
-
value: any;
|
|
138
|
-
}, initDataVal: {
|
|
139
|
-
type: string | undefined;
|
|
140
|
-
values: Array<{
|
|
141
|
-
systemId: string | unknown;
|
|
142
|
-
data: Uint8Array;
|
|
143
|
-
}>;
|
|
144
|
-
}): void;
|
|
145
|
-
/**
|
|
146
|
-
* @param {Object} evt
|
|
147
|
-
* @param {Uint8Array} initData
|
|
148
|
-
* @param {string|undefined} initDataType
|
|
149
|
-
*/
|
|
150
|
-
export declare function expectInitDataIgnored(evt: {
|
|
151
|
-
type: string;
|
|
152
|
-
value: any;
|
|
153
|
-
}, initDataVal: {
|
|
154
|
-
type: string | undefined;
|
|
155
|
-
values: Array<{
|
|
156
|
-
systemId: string | undefined;
|
|
157
|
-
data: Uint8Array;
|
|
158
|
-
}>;
|
|
159
|
-
}): void;
|
|
160
|
-
/**
|
|
161
|
-
* @param {Object} evt
|
|
162
|
-
* @param {Uint8Array} initData
|
|
163
|
-
* @param {string|undefined} initDataType
|
|
164
|
-
*/
|
|
165
|
-
export declare function expectEncryptedEventReceived(evt: {
|
|
166
|
-
type: string;
|
|
167
|
-
value: any;
|
|
168
|
-
}, initData: IEncryptedEventData): void;
|
|
126
|
+
export declare function testContentDecryptorError(ContentDecryptor: any, mediaElement: HTMLMediaElement, keySystemsConfigs: unknown[]): Promise<unknown>;
|
|
169
127
|
/**
|
|
170
128
|
* Does the reverse operation than what `formatFakeChallengeFromInitData` does:
|
|
171
129
|
* Retrieve initialization data from a fake challenge done in our tests
|
|
@@ -46,10 +46,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
46
46
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
47
47
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
48
48
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
49
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
50
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
51
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
49
52
|
/* eslint-disable no-restricted-properties */
|
|
50
|
-
import {
|
|
53
|
+
import { Subject } from "rxjs";
|
|
51
54
|
import { base64ToBytes, bytesToBase64, } from "../../../../utils/base64";
|
|
52
|
-
import castToObservable from "../../../../utils/cast_to_observable";
|
|
53
55
|
import EventEmitter, { fromEvent } from "../../../../utils/event_emitter";
|
|
54
56
|
import flatMap from "../../../../utils/flat_map";
|
|
55
57
|
import { strToUtf8, utf8ToStr, } from "../../../../utils/string_parsing";
|
|
@@ -155,13 +157,16 @@ var MediaKeySessionImpl = /** @class */ (function (_super) {
|
|
|
155
157
|
return Promise.resolve();
|
|
156
158
|
};
|
|
157
159
|
MediaKeySessionImpl.prototype.generateRequest = function (initDataType, initData) {
|
|
160
|
+
var _this = this;
|
|
158
161
|
var msg = formatFakeChallengeFromInitData(initData, initDataType);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
setTimeout(function () {
|
|
163
|
+
var event = Object.assign(new CustomEvent("message"), { message: msg.buffer,
|
|
164
|
+
messageType: "license-request" });
|
|
165
|
+
_this.trigger("message", event);
|
|
166
|
+
if (_this.onmessage !== null && _this.onmessage !== undefined) {
|
|
167
|
+
_this.onmessage(event);
|
|
168
|
+
}
|
|
169
|
+
}, 5);
|
|
165
170
|
return Promise.resolve();
|
|
166
171
|
};
|
|
167
172
|
MediaKeySessionImpl.prototype.load = function (_sessionId) {
|
|
@@ -220,7 +225,7 @@ var MediaKeySystemAccessImpl = /** @class */ (function () {
|
|
|
220
225
|
}());
|
|
221
226
|
export { MediaKeySystemAccessImpl };
|
|
222
227
|
export function requestMediaKeySystemAccessImpl(keySystem, config) {
|
|
223
|
-
return
|
|
228
|
+
return Promise.resolve(new MediaKeySystemAccessImpl(keySystem, config));
|
|
224
229
|
}
|
|
225
230
|
/**
|
|
226
231
|
* Mock functions coming from the compat directory.
|
|
@@ -245,11 +250,9 @@ export function mockCompat(exportedFunctions) {
|
|
|
245
250
|
}),
|
|
246
251
|
};
|
|
247
252
|
var rmksaSpy = jest.fn(requestMediaKeySystemAccessImpl);
|
|
248
|
-
var setMediaKeysSpy = jest.fn(
|
|
253
|
+
var setMediaKeysSpy = jest.fn();
|
|
249
254
|
var generateKeyRequestSpy = jest.fn(function (mks, initializationDataType, initializationData) {
|
|
250
|
-
return
|
|
251
|
-
return castToObservable(mks.generateRequest(initializationDataType, initializationData));
|
|
252
|
-
});
|
|
255
|
+
return mks.generateRequest(initializationDataType, initializationData);
|
|
253
256
|
});
|
|
254
257
|
var getInitDataSpy = jest.fn(function (encryptedEvent) {
|
|
255
258
|
return encryptedEvent;
|
|
@@ -259,9 +262,7 @@ export function mockCompat(exportedFunctions) {
|
|
|
259
262
|
requestMediaKeySystemAccessSpy: rmksaSpy, getInitDataSpy: getInitDataSpy, setMediaKeysSpy: setMediaKeysSpy, generateKeyRequestSpy: generateKeyRequestSpy };
|
|
260
263
|
}
|
|
261
264
|
/**
|
|
262
|
-
* Check that the
|
|
263
|
-
* directly without any event emitted.
|
|
264
|
-
*
|
|
265
|
+
* Check that the ContentDecryptor, when called with those arguments, throws.
|
|
265
266
|
* If that's the case, resolve with the corresponding error.
|
|
266
267
|
* Else, reject.
|
|
267
268
|
* @param {HTMLMediaElement} mediaElement
|
|
@@ -269,58 +270,17 @@ export function mockCompat(exportedFunctions) {
|
|
|
269
270
|
* @param {Observable} contentProtections$
|
|
270
271
|
* @returns {Promise}
|
|
271
272
|
*/
|
|
272
|
-
export function
|
|
273
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
274
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
276
|
-
EMEManager,
|
|
277
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
278
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
279
|
-
mediaElement, keySystemsConfigs, contentProtections$) {
|
|
273
|
+
export function testContentDecryptorError(ContentDecryptor, mediaElement, keySystemsConfigs) {
|
|
280
274
|
return new Promise(function (res, rej) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
275
|
+
var contentDecryptor = new ContentDecryptor(mediaElement, keySystemsConfigs);
|
|
276
|
+
contentDecryptor.addEventListener("error", function (error) {
|
|
277
|
+
res(error);
|
|
278
|
+
});
|
|
279
|
+
setTimeout(function () {
|
|
280
|
+
rej(new Error("Timeout exceeded"));
|
|
281
|
+
}, 10);
|
|
287
282
|
});
|
|
288
283
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Check that the event received corresponds to the session-message event for a
|
|
291
|
-
* license request.
|
|
292
|
-
* @param {Object} evt
|
|
293
|
-
* @param {Object} initDataVal
|
|
294
|
-
*/
|
|
295
|
-
export function expectLicenseRequestMessage(
|
|
296
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
297
|
-
evt, initDataVal) {
|
|
298
|
-
expect(evt.type).toEqual("session-message");
|
|
299
|
-
expect(evt.value.messageType).toEqual("license-request");
|
|
300
|
-
expect(evt.value.initializationData).toEqual(initDataVal);
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* @param {Object} evt
|
|
304
|
-
* @param {Uint8Array} initData
|
|
305
|
-
* @param {string|undefined} initDataType
|
|
306
|
-
*/
|
|
307
|
-
export function expectInitDataIgnored(
|
|
308
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
309
|
-
evt, initDataVal) {
|
|
310
|
-
expect(evt.type).toEqual("init-data-ignored");
|
|
311
|
-
expect(evt.value.initializationData).toEqual(initDataVal);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* @param {Object} evt
|
|
315
|
-
* @param {Uint8Array} initData
|
|
316
|
-
* @param {string|undefined} initDataType
|
|
317
|
-
*/
|
|
318
|
-
export function expectEncryptedEventReceived(
|
|
319
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
|
-
evt, initData) {
|
|
321
|
-
expect(evt.type).toEqual("encrypted-event-received");
|
|
322
|
-
expect(evt.value).toEqual(initData);
|
|
323
|
-
}
|
|
324
284
|
/**
|
|
325
285
|
* Does the reverse operation than what `formatFakeChallengeFromInitData` does:
|
|
326
286
|
* Retrieve initialization data from a fake challenge done in our tests
|
|
@@ -13,16 +13,25 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Observable } from "rxjs";
|
|
17
16
|
import { ICustomMediaKeys, ICustomMediaKeySystemAccess } from "../../compat";
|
|
17
|
+
import { CancellationSignal } from "../../utils/task_canceller";
|
|
18
18
|
import { IKeySystemOption } from "./types";
|
|
19
19
|
import LoadedSessionsStore from "./utils/loaded_sessions_store";
|
|
20
20
|
/**
|
|
21
|
-
* Dispose the
|
|
21
|
+
* Dispose of the MediaKeys instance attached to the given media element, if
|
|
22
|
+
* one.
|
|
22
23
|
* @param {Object} mediaElement
|
|
24
|
+
*/
|
|
25
|
+
export declare function disableMediaKeys(mediaElement: HTMLMediaElement): void;
|
|
26
|
+
/**
|
|
27
|
+
* Attach MediaKeys and its associated state to an HTMLMediaElement.
|
|
28
|
+
*
|
|
29
|
+
* /!\ Mutates heavily MediaKeysInfosStore
|
|
30
|
+
* @param {Object} mediaKeysInfos
|
|
31
|
+
* @param {HTMLMediaElement} mediaElement
|
|
23
32
|
* @returns {Observable}
|
|
24
33
|
*/
|
|
25
|
-
export
|
|
34
|
+
export default function attachMediaKeys(mediaElement: HTMLMediaElement, { keySystemOptions, loadedSessionsStore, mediaKeySystemAccess, mediaKeys }: IMediaKeysState, cancelSignal: CancellationSignal): Promise<void>;
|
|
26
35
|
/** MediaKeys and associated state attached to a media element. */
|
|
27
36
|
export interface IMediaKeysState {
|
|
28
37
|
/** Options set when the MediaKeys has been attached. */
|
|
@@ -34,12 +43,3 @@ export interface IMediaKeysState {
|
|
|
34
43
|
/** The MediaKeys instance to attach to the media element. */
|
|
35
44
|
mediaKeys: MediaKeys | ICustomMediaKeys;
|
|
36
45
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Attach MediaKeys and its associated state to an HTMLMediaElement.
|
|
39
|
-
*
|
|
40
|
-
* /!\ Mutates heavily MediaKeysInfosStore
|
|
41
|
-
* @param {Object} mediaKeysInfos
|
|
42
|
-
* @param {HTMLMediaElement} mediaElement
|
|
43
|
-
* @returns {Observable}
|
|
44
|
-
*/
|
|
45
|
-
export default function attachMediaKeys(mediaElement: HTMLMediaElement, { keySystemOptions, loadedSessionsStore, mediaKeySystemAccess, mediaKeys }: IMediaKeysState): Observable<unknown>;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (_) try {
|
|
32
|
+
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;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
import { setMediaKeys, } from "../../compat";
|
|
53
|
+
import log from "../../log";
|
|
54
|
+
import MediaKeysInfosStore from "./utils/media_keys_infos_store";
|
|
55
|
+
/**
|
|
56
|
+
* Dispose of the MediaKeys instance attached to the given media element, if
|
|
57
|
+
* one.
|
|
58
|
+
* @param {Object} mediaElement
|
|
59
|
+
*/
|
|
60
|
+
export function disableMediaKeys(mediaElement) {
|
|
61
|
+
MediaKeysInfosStore.setState(mediaElement, null);
|
|
62
|
+
setMediaKeys(mediaElement, null);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Attach MediaKeys and its associated state to an HTMLMediaElement.
|
|
66
|
+
*
|
|
67
|
+
* /!\ Mutates heavily MediaKeysInfosStore
|
|
68
|
+
* @param {Object} mediaKeysInfos
|
|
69
|
+
* @param {HTMLMediaElement} mediaElement
|
|
70
|
+
* @returns {Observable}
|
|
71
|
+
*/
|
|
72
|
+
export default function attachMediaKeys(mediaElement, _a, cancelSignal) {
|
|
73
|
+
var keySystemOptions = _a.keySystemOptions, loadedSessionsStore = _a.loadedSessionsStore, mediaKeySystemAccess = _a.mediaKeySystemAccess, mediaKeys = _a.mediaKeys;
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var previousState, closeAllSessions;
|
|
76
|
+
return __generator(this, function (_b) {
|
|
77
|
+
switch (_b.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
previousState = MediaKeysInfosStore.getState(mediaElement);
|
|
80
|
+
closeAllSessions = previousState !== null &&
|
|
81
|
+
previousState.loadedSessionsStore !== loadedSessionsStore ?
|
|
82
|
+
previousState.loadedSessionsStore.closeAllSessions() :
|
|
83
|
+
Promise.resolve();
|
|
84
|
+
return [4 /*yield*/, closeAllSessions];
|
|
85
|
+
case 1:
|
|
86
|
+
_b.sent();
|
|
87
|
+
// If this task has been cancelled while we were closing previous sessions,
|
|
88
|
+
// stop now (and thus avoid setting the new media keys);
|
|
89
|
+
if (cancelSignal.isCancelled) {
|
|
90
|
+
throw cancelSignal.cancellationError;
|
|
91
|
+
}
|
|
92
|
+
MediaKeysInfosStore.setState(mediaElement, { keySystemOptions: keySystemOptions, mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, loadedSessionsStore: loadedSessionsStore });
|
|
93
|
+
if (mediaElement.mediaKeys === mediaKeys) {
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
log.info("DRM: Attaching MediaKeys to the media element");
|
|
97
|
+
setMediaKeys(mediaElement, mediaKeys);
|
|
98
|
+
log.info("DRM: MediaKeys attached with success");
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -13,11 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Observable } from "rxjs";
|
|
17
16
|
/**
|
|
18
|
-
* Clear
|
|
19
|
-
* its playback.
|
|
17
|
+
* Clear DRM-related resources that should be cleared when the current content
|
|
18
|
+
* stops its playback.
|
|
20
19
|
* @param {HTMLMediaElement} mediaElement
|
|
21
20
|
* @returns {Observable}
|
|
22
21
|
*/
|
|
23
|
-
export default function
|
|
22
|
+
export default function clearOnStop(mediaElement: HTMLMediaElement): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
import { shouldUnsetMediaKeys } from "../../compat/";
|
|
17
|
+
import log from "../../log";
|
|
18
|
+
import disposeDecryptionResources from "./dispose_decryption_resources";
|
|
19
|
+
import MediaKeysInfosStore from "./utils/media_keys_infos_store";
|
|
20
|
+
/**
|
|
21
|
+
* Clear DRM-related resources that should be cleared when the current content
|
|
22
|
+
* stops its playback.
|
|
23
|
+
* @param {HTMLMediaElement} mediaElement
|
|
24
|
+
* @returns {Observable}
|
|
25
|
+
*/
|
|
26
|
+
export default function clearOnStop(mediaElement) {
|
|
27
|
+
log.info("DRM: Clearing-up DRM session.");
|
|
28
|
+
if (shouldUnsetMediaKeys()) {
|
|
29
|
+
log.info("DRM: disposing current MediaKeys.");
|
|
30
|
+
return disposeDecryptionResources(mediaElement);
|
|
31
|
+
}
|
|
32
|
+
var currentState = MediaKeysInfosStore.getState(mediaElement);
|
|
33
|
+
if (currentState !== null &&
|
|
34
|
+
currentState.keySystemOptions.closeSessionsOnStop === true) {
|
|
35
|
+
log.info("DRM: closing all current sessions.");
|
|
36
|
+
return currentState.loadedSessionsStore.closeAllSessions();
|
|
37
|
+
}
|
|
38
|
+
log.info("DRM: Nothing to clear. Returning right away. No state =", currentState === null);
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|