rx-player 3.26.3-dev.2022021400 → 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/CHANGELOG.md +15 -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 +21 -22
- 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/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 +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/{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 +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 +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 +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.js +2 -2
- 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/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 +4 -2
- 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/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 +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 +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/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/smooth/create_parser.js +1 -0
- package/dist/_esm5.processed/public_types.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +3 -0
- package/dist/_esm5.processed/transports/dash/segment_parser.js +6 -3
- package/dist/_esm5.processed/transports/dash/text_parser.js +8 -2
- 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/smooth/pipelines.js +68 -10
- package/dist/_esm5.processed/transports/types.d.ts +22 -0
- 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 +1 -1
- 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 +5002 -3033
- 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 +32 -34
- package/scripts/build/templates/experimental/index.d.ts +16 -0
- package/scripts/build/templates/experimental/index.js +16 -0
- package/sonar-project.properties +1 -1
- package/src/README.md +6 -6
- 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/index.ts +21 -38
- 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/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 +17 -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 +37 -20
- package/src/core/api/playback_observer.ts +12 -8
- package/src/core/api/public_api.ts +151 -111
- 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 +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 +112 -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} +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 +4 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +4 -4
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +2 -2
- 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 +42 -105
- 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/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 +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 +2 -1
- 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/probers/DRMInfos.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.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/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 +5 -1
- package/src/transports/dash/image_pipelines.ts +3 -0
- package/src/transports/dash/segment_parser.ts +5 -0
- package/src/transports/dash/text_parser.ts +8 -0
- package/src/transports/local/segment_parser.ts +4 -0
- package/src/transports/local/text_parser.ts +8 -0
- package/src/transports/smooth/pipelines.ts +22 -9
- package/src/transports/types.ts +22 -0
- package/src/utils/__tests__/deep_merge.test.ts +48 -0
- 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 +2 -1
- package/src/utils/rx-from_cancellable_promise.ts +7 -2
- package/src/utils/task_canceller.ts +6 -4
- 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 -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
|
@@ -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,104 @@
|
|
|
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 PPromise from "../../utils/promise";
|
|
55
|
+
import MediaKeysInfosStore from "./utils/media_keys_infos_store";
|
|
56
|
+
/**
|
|
57
|
+
* Dispose of the MediaKeys instance attached to the given media element, if
|
|
58
|
+
* one.
|
|
59
|
+
* @param {Object} mediaElement
|
|
60
|
+
*/
|
|
61
|
+
export function disableMediaKeys(mediaElement) {
|
|
62
|
+
MediaKeysInfosStore.setState(mediaElement, null);
|
|
63
|
+
setMediaKeys(mediaElement, null);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Attach MediaKeys and its associated state to an HTMLMediaElement.
|
|
67
|
+
*
|
|
68
|
+
* /!\ Mutates heavily MediaKeysInfosStore
|
|
69
|
+
* @param {Object} mediaKeysInfos
|
|
70
|
+
* @param {HTMLMediaElement} mediaElement
|
|
71
|
+
* @returns {Observable}
|
|
72
|
+
*/
|
|
73
|
+
export default function attachMediaKeys(mediaElement, _a, cancelSignal) {
|
|
74
|
+
var keySystemOptions = _a.keySystemOptions, loadedSessionsStore = _a.loadedSessionsStore, mediaKeySystemAccess = _a.mediaKeySystemAccess, mediaKeys = _a.mediaKeys;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var previousState, closeAllSessions;
|
|
77
|
+
return __generator(this, function (_b) {
|
|
78
|
+
switch (_b.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
previousState = MediaKeysInfosStore.getState(mediaElement);
|
|
81
|
+
closeAllSessions = previousState !== null &&
|
|
82
|
+
previousState.loadedSessionsStore !== loadedSessionsStore ?
|
|
83
|
+
previousState.loadedSessionsStore.closeAllSessions() :
|
|
84
|
+
PPromise.resolve();
|
|
85
|
+
return [4 /*yield*/, closeAllSessions];
|
|
86
|
+
case 1:
|
|
87
|
+
_b.sent();
|
|
88
|
+
// If this task has been cancelled while we were closing previous sessions,
|
|
89
|
+
// stop now (and thus avoid setting the new media keys);
|
|
90
|
+
if (cancelSignal.isCancelled) {
|
|
91
|
+
throw cancelSignal.cancellationError;
|
|
92
|
+
}
|
|
93
|
+
MediaKeysInfosStore.setState(mediaElement, { keySystemOptions: keySystemOptions, mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, loadedSessionsStore: loadedSessionsStore });
|
|
94
|
+
if (mediaElement.mediaKeys === mediaKeys) {
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
log.info("DRM: Attaching MediaKeys to the media element");
|
|
98
|
+
setMediaKeys(mediaElement, mediaKeys);
|
|
99
|
+
log.info("DRM: MediaKeys attached with success");
|
|
100
|
+
return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
@@ -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,41 @@
|
|
|
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 PPromise from "../../utils/promise";
|
|
19
|
+
import disposeDecryptionResources from "./dispose_decryption_resources";
|
|
20
|
+
import MediaKeysInfosStore from "./utils/media_keys_infos_store";
|
|
21
|
+
/**
|
|
22
|
+
* Clear DRM-related resources that should be cleared when the current content
|
|
23
|
+
* stops its playback.
|
|
24
|
+
* @param {HTMLMediaElement} mediaElement
|
|
25
|
+
* @returns {Observable}
|
|
26
|
+
*/
|
|
27
|
+
export default function clearOnStop(mediaElement) {
|
|
28
|
+
log.info("DRM: Clearing-up DRM session.");
|
|
29
|
+
if (shouldUnsetMediaKeys()) {
|
|
30
|
+
log.info("DRM: disposing current MediaKeys.");
|
|
31
|
+
return disposeDecryptionResources(mediaElement);
|
|
32
|
+
}
|
|
33
|
+
var currentState = MediaKeysInfosStore.getState(mediaElement);
|
|
34
|
+
if (currentState !== null &&
|
|
35
|
+
currentState.keySystemOptions.closeSessionsOnStop === true) {
|
|
36
|
+
log.info("DRM: closing all current sessions.");
|
|
37
|
+
return currentState.loadedSessionsStore.closeAllSessions();
|
|
38
|
+
}
|
|
39
|
+
log.info("DRM: Nothing to clear. Returning right away. No state =", currentState === null);
|
|
40
|
+
return PPromise.resolve();
|
|
41
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 { ICustomError } from "../../errors";
|
|
17
|
+
import EventEmitter from "../../utils/event_emitter";
|
|
18
|
+
import { IProtectionData, IKeySystemOption } from "./types";
|
|
19
|
+
/**
|
|
20
|
+
* Module communicating with the Content Decryption Module (or CDM) to be able
|
|
21
|
+
* to decrypt contents.
|
|
22
|
+
*
|
|
23
|
+
* The `ContentDecryptor` starts communicating with the CDM, to initialize the
|
|
24
|
+
* key system, as soon as it is created.
|
|
25
|
+
*
|
|
26
|
+
* You can be notified of various events, such as fatal errors, by registering
|
|
27
|
+
* to one of its multiple events (@see IContentDecryptorEvent).
|
|
28
|
+
*
|
|
29
|
+
* @class ContentDecryptor
|
|
30
|
+
*/
|
|
31
|
+
export default class ContentDecryptor extends EventEmitter<IContentDecryptorEvent> {
|
|
32
|
+
/**
|
|
33
|
+
* Hexadecimal id identifying the currently-chosen key system.
|
|
34
|
+
* `undefined` if not known or if the key system hasn't been initialized yet.
|
|
35
|
+
*
|
|
36
|
+
* When providing protection initialization data to the ContentDecryptor, you
|
|
37
|
+
* may only provide those linked to that system id. You can also provide all
|
|
38
|
+
* available protection initialization data, in which case it will be
|
|
39
|
+
* automatically filtered.
|
|
40
|
+
*
|
|
41
|
+
* This `systemId` may only be known once the `ReadyForContent` state (@see
|
|
42
|
+
* ContentDecryptorState) is reached, and even then, it may still be unknown,
|
|
43
|
+
* in which case it will stay to `undefined`.
|
|
44
|
+
*/
|
|
45
|
+
systemId: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Set only if the `ContentDecryptor` failed on an error.
|
|
48
|
+
* The corresponding Error.
|
|
49
|
+
*/
|
|
50
|
+
error: Error | null;
|
|
51
|
+
/**
|
|
52
|
+
* State of the ContentDecryptor (@see ContentDecryptorState) and associated
|
|
53
|
+
* data.
|
|
54
|
+
*
|
|
55
|
+
* The ContentDecryptor goes into a series of steps as it is initializing.
|
|
56
|
+
* This private property stores the current state and the potentially linked
|
|
57
|
+
* data.
|
|
58
|
+
*/
|
|
59
|
+
private _stateData;
|
|
60
|
+
/**
|
|
61
|
+
* Contains information about all key sessions loaded for this current
|
|
62
|
+
* content.
|
|
63
|
+
* This object is most notably used to check which keys are already obtained,
|
|
64
|
+
* thus avoiding to perform new unnecessary license requests and CDM interactions.
|
|
65
|
+
*/
|
|
66
|
+
private _currentSessions;
|
|
67
|
+
/**
|
|
68
|
+
* Allows to dispose the resources taken by the current instance of the
|
|
69
|
+
* ContentDecryptor.
|
|
70
|
+
*/
|
|
71
|
+
private _canceller;
|
|
72
|
+
/**
|
|
73
|
+
* `true` once the `attach` method has been called`.
|
|
74
|
+
* Allows to avoid calling multiple times that function.
|
|
75
|
+
*/
|
|
76
|
+
private _wasAttachCalled;
|
|
77
|
+
/**
|
|
78
|
+
* This queue stores initialization data which hasn't been processed yet,
|
|
79
|
+
* probably because the "queue is locked" for now. (@see _stateData private
|
|
80
|
+
* property).
|
|
81
|
+
*
|
|
82
|
+
* For example, this queue stores initialization data communicated while
|
|
83
|
+
* initializing so it can be processed when the initialization is done.
|
|
84
|
+
*/
|
|
85
|
+
private _initDataQueue;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new `ContentDecryptor`, and initialize its decryption capabilities
|
|
88
|
+
* right away.
|
|
89
|
+
* Goes into the `WaitingForAttachment` state once that initialization is
|
|
90
|
+
* done, after which you should call the `attach` method when you're ready for
|
|
91
|
+
* those decryption capabilities to be attached to the HTMLMediaElement.
|
|
92
|
+
*
|
|
93
|
+
* @param {HTMLMediaElement} mediaElement - The MediaElement which will be
|
|
94
|
+
* associated to a MediaKeys object
|
|
95
|
+
* @param {Array.<Object>} ksOptions - key system configuration.
|
|
96
|
+
* The `ContentDecryptor` can be given one or multiple key system
|
|
97
|
+
* configurations. It will choose the appropriate one depending on user
|
|
98
|
+
* settings and browser support.
|
|
99
|
+
*/
|
|
100
|
+
constructor(mediaElement: HTMLMediaElement, ksOptions: IKeySystemOption[]);
|
|
101
|
+
/**
|
|
102
|
+
* Returns the current state of the ContentDecryptor.
|
|
103
|
+
* @see ContentDecryptorState
|
|
104
|
+
* @returns {Object}
|
|
105
|
+
*/
|
|
106
|
+
getState(): ContentDecryptorState;
|
|
107
|
+
/**
|
|
108
|
+
* Attach the current decryption capabilities to the HTMLMediaElement.
|
|
109
|
+
* This method should only be called once the `ContentDecryptor` is in the
|
|
110
|
+
* `WaitingForAttachment` state.
|
|
111
|
+
*
|
|
112
|
+
* You might want to first set the HTMLMediaElement's `src` attribute before
|
|
113
|
+
* calling this method, and only push data to it once the `ReadyForContent`
|
|
114
|
+
* state is reached, for compatibility reasons.
|
|
115
|
+
*/
|
|
116
|
+
attach(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Stop this `ContentDecryptor` instance:
|
|
119
|
+
* - stop listening and reacting to the various event listeners
|
|
120
|
+
* - abort all operations.
|
|
121
|
+
*
|
|
122
|
+
* Once disposed, a `ContentDecryptor` cannot be used anymore.
|
|
123
|
+
*/
|
|
124
|
+
dispose(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Method to call when new protection initialization data is encounted on the
|
|
127
|
+
* content.
|
|
128
|
+
*
|
|
129
|
+
* When called, the `ContentDecryptor` will try to obtain the decryption key
|
|
130
|
+
* if not already obtained.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} initializationData
|
|
133
|
+
*/
|
|
134
|
+
onInitializationData(initializationData: IProtectionData): void;
|
|
135
|
+
/**
|
|
136
|
+
* Async logic run each time new initialization data has to be processed.
|
|
137
|
+
* The promise return may reject, in which case a fatal error should be linked
|
|
138
|
+
* the current `ContentDecryptor`.
|
|
139
|
+
*
|
|
140
|
+
* The Promise's resolution however provides no semantic value.
|
|
141
|
+
* @param {Object} initializationData
|
|
142
|
+
* @returns {Promise.<void>}
|
|
143
|
+
*/
|
|
144
|
+
private _processInitializationData;
|
|
145
|
+
private _tryToUseAlreadyCreatedSession;
|
|
146
|
+
private _onFatalError;
|
|
147
|
+
/**
|
|
148
|
+
* Return `true` if the `ContentDecryptor` has either been disposed or
|
|
149
|
+
* encountered a fatal error which made it stop.
|
|
150
|
+
* @returns {boolean}
|
|
151
|
+
*/
|
|
152
|
+
private _isStopped;
|
|
153
|
+
private _processCurrentInitDataQueue;
|
|
154
|
+
private _lockInitDataQueue;
|
|
155
|
+
private _unlockInitDataQueue;
|
|
156
|
+
}
|
|
157
|
+
/** Events sent by the `ContentDecryptor`, in a `{ event: payload }` format. */
|
|
158
|
+
export interface IContentDecryptorEvent {
|
|
159
|
+
/**
|
|
160
|
+
* Event emitted when a major error occured which made the ContentDecryptor
|
|
161
|
+
* stopped.
|
|
162
|
+
* When that event is sent, the `ContentDecryptor` is in the `Error` state and
|
|
163
|
+
* cannot be used anymore.
|
|
164
|
+
*/
|
|
165
|
+
error: Error;
|
|
166
|
+
/**
|
|
167
|
+
* Event emitted when a minor error occured which the ContentDecryptor can
|
|
168
|
+
* recover from.
|
|
169
|
+
*/
|
|
170
|
+
warning: ICustomError;
|
|
171
|
+
/**
|
|
172
|
+
* Event emitted when the `ContentDecryptor`'s state changed.
|
|
173
|
+
* States are a central aspect of the `ContentDecryptor`, be sure to check the
|
|
174
|
+
* ContentDecryptorState type.
|
|
175
|
+
*/
|
|
176
|
+
stateChange: ContentDecryptorState;
|
|
177
|
+
}
|
|
178
|
+
/** Enumeration of the various "state" the `ContentDecryptor` can be in. */
|
|
179
|
+
export declare enum ContentDecryptorState {
|
|
180
|
+
/**
|
|
181
|
+
* The `ContentDecryptor` is not yet ready to create key sessions and request
|
|
182
|
+
* licenses.
|
|
183
|
+
* This is is the initial state of the ContentDecryptor.
|
|
184
|
+
*/
|
|
185
|
+
Initializing = 0,
|
|
186
|
+
/**
|
|
187
|
+
* The `ContentDecryptor` has been initialized.
|
|
188
|
+
* You should now called the `attach` method when you want to add decryption
|
|
189
|
+
* capabilities to the HTMLMediaElement. The ContentDecryptor won't go to the
|
|
190
|
+
* `ReadyForContent` state until `attach` is called.
|
|
191
|
+
*
|
|
192
|
+
* For compatibility reasons, this should be done after the HTMLMediaElement's
|
|
193
|
+
* src attribute is set.
|
|
194
|
+
*
|
|
195
|
+
* It is also from when this state is reached that the `ContentDecryptor`'s
|
|
196
|
+
* `systemId` property may be known.
|
|
197
|
+
*
|
|
198
|
+
* This state is always coming after the `Initializing` state.
|
|
199
|
+
*/
|
|
200
|
+
WaitingForAttachment = 1,
|
|
201
|
+
/**
|
|
202
|
+
* Content (encrypted or not) can begin to be pushed on the HTMLMediaElement
|
|
203
|
+
* (this state was needed because some browser quirks sometimes forces us to
|
|
204
|
+
* call EME API before this can be done).
|
|
205
|
+
*
|
|
206
|
+
* This state is always coming after the `WaitingForAttachment` state.
|
|
207
|
+
*/
|
|
208
|
+
ReadyForContent = 2,
|
|
209
|
+
/**
|
|
210
|
+
* The `ContentDecryptor` has encountered a fatal error and has been stopped.
|
|
211
|
+
* It is now unusable.
|
|
212
|
+
*/
|
|
213
|
+
Error = 3,
|
|
214
|
+
/** The `ContentDecryptor` has been disposed of and is now unusable. */
|
|
215
|
+
Disposed = 4
|
|
216
|
+
}
|