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
|
@@ -1,253 +0,0 @@
|
|
|
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 { catchError, defer as observableDefer, map, of as observableOf, throwError as observableThrow, } from "rxjs";
|
|
17
|
-
import { requestMediaKeySystemAccess, shouldRenewMediaKeys, } from "../../compat";
|
|
18
|
-
import config from "../../config";
|
|
19
|
-
import { EncryptedMediaError } from "../../errors";
|
|
20
|
-
import log from "../../log";
|
|
21
|
-
import arrayIncludes from "../../utils/array_includes";
|
|
22
|
-
import flatMap from "../../utils/flat_map";
|
|
23
|
-
import MediaKeysInfosStore from "./media_keys_infos_store";
|
|
24
|
-
var EME_DEFAULT_WIDEVINE_ROBUSTNESSES = config.EME_DEFAULT_WIDEVINE_ROBUSTNESSES, EME_KEY_SYSTEMS = config.EME_KEY_SYSTEMS;
|
|
25
|
-
/**
|
|
26
|
-
* @param {Array.<Object>} keySystems
|
|
27
|
-
* @param {MediaKeySystemAccess} currentKeySystemAccess
|
|
28
|
-
* @param {Object} currentKeySystemOptions
|
|
29
|
-
* @returns {null|Object}
|
|
30
|
-
*/
|
|
31
|
-
function checkCachedMediaKeySystemAccess(keySystems, currentKeySystemAccess, currentKeySystemOptions) {
|
|
32
|
-
var mksConfiguration = currentKeySystemAccess.getConfiguration();
|
|
33
|
-
if (shouldRenewMediaKeys() || mksConfiguration == null) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
var firstCompatibleOption = keySystems.filter(function (ks) {
|
|
37
|
-
// TODO Do it with MediaKeySystemAccess.prototype.keySystem instead
|
|
38
|
-
if (ks.type !== currentKeySystemOptions.type) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if ((ks.persistentLicense === true || ks.persistentStateRequired === true) &&
|
|
42
|
-
mksConfiguration.persistentState !== "required") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
if (ks.distinctiveIdentifierRequired === true &&
|
|
46
|
-
mksConfiguration.distinctiveIdentifier !== "required") {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
})[0];
|
|
51
|
-
if (firstCompatibleOption != null) {
|
|
52
|
-
return { keySystemOptions: firstCompatibleOption,
|
|
53
|
-
keySystemAccess: currentKeySystemAccess };
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Find key system canonical name from key system type.
|
|
59
|
-
* @param {string} ksType - Obtained via inversion
|
|
60
|
-
* @returns {string|undefined} - Either the canonical name, or undefined.
|
|
61
|
-
*/
|
|
62
|
-
function findKeySystemCanonicalName(ksType) {
|
|
63
|
-
for (var _i = 0, _a = Object.keys(EME_KEY_SYSTEMS); _i < _a.length; _i++) {
|
|
64
|
-
var ksName = _a[_i];
|
|
65
|
-
if (arrayIncludes(EME_KEY_SYSTEMS[ksName], ksType)) {
|
|
66
|
-
return ksName;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Build configuration for the requestMediaKeySystemAccess EME API, based
|
|
73
|
-
* on the current keySystem object.
|
|
74
|
-
* @param {string} [ksName] - Generic name for the key system. e.g. "clearkey",
|
|
75
|
-
* "widevine", "playready". Can be used to make exceptions depending on it.
|
|
76
|
-
* @param {Object} keySystem
|
|
77
|
-
* @returns {Array.<Object>} - Configuration to give to the
|
|
78
|
-
* requestMediaKeySystemAccess API.
|
|
79
|
-
*/
|
|
80
|
-
function buildKeySystemConfigurations(ksName, keySystem) {
|
|
81
|
-
var sessionTypes = ["temporary"];
|
|
82
|
-
var persistentState = "optional";
|
|
83
|
-
var distinctiveIdentifier = "optional";
|
|
84
|
-
if (keySystem.persistentLicense === true) {
|
|
85
|
-
persistentState = "required";
|
|
86
|
-
sessionTypes.push("persistent-license");
|
|
87
|
-
}
|
|
88
|
-
if (keySystem.persistentStateRequired === true) {
|
|
89
|
-
persistentState = "required";
|
|
90
|
-
}
|
|
91
|
-
if (keySystem.distinctiveIdentifierRequired === true) {
|
|
92
|
-
distinctiveIdentifier = "required";
|
|
93
|
-
}
|
|
94
|
-
// Set robustness, in order of consideration:
|
|
95
|
-
// 1. the user specified its own robustnesses
|
|
96
|
-
// 2. a "widevine" key system is used, in that case set the default widevine
|
|
97
|
-
// robustnesses as defined in the config
|
|
98
|
-
// 3. set an undefined robustness
|
|
99
|
-
var videoRobustnesses = keySystem.videoRobustnesses != null ?
|
|
100
|
-
keySystem.videoRobustnesses :
|
|
101
|
-
(ksName === "widevine" ? EME_DEFAULT_WIDEVINE_ROBUSTNESSES :
|
|
102
|
-
[]);
|
|
103
|
-
var audioRobustnesses = keySystem.audioRobustnesses != null ?
|
|
104
|
-
keySystem.audioRobustnesses :
|
|
105
|
-
(ksName === "widevine" ? EME_DEFAULT_WIDEVINE_ROBUSTNESSES :
|
|
106
|
-
[]);
|
|
107
|
-
if (videoRobustnesses.length === 0) {
|
|
108
|
-
videoRobustnesses.push(undefined);
|
|
109
|
-
}
|
|
110
|
-
if (audioRobustnesses.length === 0) {
|
|
111
|
-
audioRobustnesses.push(undefined);
|
|
112
|
-
}
|
|
113
|
-
// From the W3 EME spec, we have to provide videoCapabilities and
|
|
114
|
-
// audioCapabilities.
|
|
115
|
-
// These capabilities must specify a codec (even though you can use a
|
|
116
|
-
// completely different codec afterward).
|
|
117
|
-
// It is also strongly recommended to specify the required security
|
|
118
|
-
// robustness. As we do not want to forbide any security level, we specify
|
|
119
|
-
// every existing security level from highest to lowest so that the best
|
|
120
|
-
// security level is selected.
|
|
121
|
-
// More details here:
|
|
122
|
-
// https://storage.googleapis.com/wvdocs/Chrome_EME_Changes_and_Best_Practices.pdf
|
|
123
|
-
// https://www.w3.org/TR/encrypted-media/#get-supported-configuration-and-consent
|
|
124
|
-
var videoCapabilities = flatMap(audioRobustnesses, function (robustness) {
|
|
125
|
-
return ["video/mp4;codecs=\"avc1.4d401e\"",
|
|
126
|
-
"video/mp4;codecs=\"avc1.42e01e\"",
|
|
127
|
-
"video/webm;codecs=\"vp8\""].map(function (contentType) {
|
|
128
|
-
return robustness !== undefined ? { contentType: contentType, robustness: robustness } :
|
|
129
|
-
{ contentType: contentType };
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
var audioCapabilities = flatMap(audioRobustnesses, function (robustness) {
|
|
133
|
-
return ["audio/mp4;codecs=\"mp4a.40.2\"",
|
|
134
|
-
"audio/webm;codecs=opus"].map(function (contentType) {
|
|
135
|
-
return robustness !== undefined ? { contentType: contentType, robustness: robustness } :
|
|
136
|
-
{ contentType: contentType };
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
// TODO Re-test with a set contentType but an undefined robustness on the
|
|
140
|
-
// STBs on which this problem was found.
|
|
141
|
-
//
|
|
142
|
-
// add another with no {audio,video}Capabilities for some legacy browsers.
|
|
143
|
-
// As of today's spec, this should return NotSupported but the first
|
|
144
|
-
// candidate configuration should be good, so we should have no downside
|
|
145
|
-
// doing that.
|
|
146
|
-
// initDataTypes: ["cenc"],
|
|
147
|
-
// videoCapabilities: undefined,
|
|
148
|
-
// audioCapabilities: undefined,
|
|
149
|
-
// distinctiveIdentifier,
|
|
150
|
-
// persistentState,
|
|
151
|
-
// sessionTypes,
|
|
152
|
-
return [{ initDataTypes: ["cenc"], videoCapabilities: videoCapabilities, audioCapabilities: audioCapabilities, distinctiveIdentifier: distinctiveIdentifier, persistentState: persistentState, sessionTypes: sessionTypes }];
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Try to find a compatible key system from the keySystems array given.
|
|
156
|
-
*
|
|
157
|
-
* Returns an Observable which, when subscribed to, will request a
|
|
158
|
-
* MediaKeySystemAccess based on the various keySystems provided. This
|
|
159
|
-
* Observable will:
|
|
160
|
-
* - emit the MediaKeySystemAccess and the keySystems as an object, when
|
|
161
|
-
* found. The object is under this form:
|
|
162
|
-
* {
|
|
163
|
-
* keySystemAccess {MediaKeySystemAccess}
|
|
164
|
-
* keySystem {Object}
|
|
165
|
-
* }
|
|
166
|
-
* - complete immediately after emitting.
|
|
167
|
-
* - throw if no compatible key system has been found.
|
|
168
|
-
*
|
|
169
|
-
* @param {HTMLMediaElement} mediaElement
|
|
170
|
-
* @param {Array.<Object>} keySystems - The keySystems you want to test.
|
|
171
|
-
* @returns {Observable}
|
|
172
|
-
*/
|
|
173
|
-
export default function getMediaKeySystemAccess(mediaElement, keySystemsConfigs) {
|
|
174
|
-
return observableDefer(function () {
|
|
175
|
-
log.info("EME: Searching for compatible MediaKeySystemAccess");
|
|
176
|
-
var currentState = MediaKeysInfosStore.getState(mediaElement);
|
|
177
|
-
if (currentState != null) {
|
|
178
|
-
// Fast way to find a compatible keySystem if the currently loaded
|
|
179
|
-
// one as exactly the same compatibility options.
|
|
180
|
-
var cachedKeySystemAccess = checkCachedMediaKeySystemAccess(keySystemsConfigs, currentState.mediaKeySystemAccess, currentState.keySystemOptions);
|
|
181
|
-
if (cachedKeySystemAccess !== null) {
|
|
182
|
-
log.info("EME: Found cached compatible keySystem");
|
|
183
|
-
return observableOf({
|
|
184
|
-
type: "reuse-media-key-system-access",
|
|
185
|
-
value: { mediaKeySystemAccess: cachedKeySystemAccess.keySystemAccess,
|
|
186
|
-
options: cachedKeySystemAccess.keySystemOptions },
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Array of set keySystems for this content.
|
|
192
|
-
* Each item of this array is an object containing the following keys:
|
|
193
|
-
* - keyName {string}: keySystem canonical name (e.g. "widevine")
|
|
194
|
-
* - keyType {string}: keySystem type (e.g. "com.widevine.alpha")
|
|
195
|
-
* - keySystem {Object}: the original keySystem object
|
|
196
|
-
* @type {Array.<Object>}
|
|
197
|
-
*/
|
|
198
|
-
var keySystemsType = keySystemsConfigs.reduce(function (arr, keySystemOptions) {
|
|
199
|
-
var managedRDNs = EME_KEY_SYSTEMS[keySystemOptions.type];
|
|
200
|
-
var ksType;
|
|
201
|
-
if (managedRDNs != null) {
|
|
202
|
-
ksType = managedRDNs.map(function (keyType) {
|
|
203
|
-
var keyName = keySystemOptions.type;
|
|
204
|
-
return { keyName: keyName, keyType: keyType, keySystemOptions: keySystemOptions };
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
var keyName = findKeySystemCanonicalName(keySystemOptions.type);
|
|
209
|
-
var keyType = keySystemOptions.type;
|
|
210
|
-
ksType = [{ keyName: keyName, keyType: keyType, keySystemOptions: keySystemOptions }];
|
|
211
|
-
}
|
|
212
|
-
return arr.concat(ksType);
|
|
213
|
-
}, []);
|
|
214
|
-
return recursivelyTestKeySystems(0);
|
|
215
|
-
/**
|
|
216
|
-
* Test all key system configuration stored in `keySystemsType` one by one
|
|
217
|
-
* recursively.
|
|
218
|
-
* Returns an Observable which emit the MediaKeySystemAccess if one was
|
|
219
|
-
* found compatible with one of the configurations or just throws if none
|
|
220
|
-
* were found to be compatible.
|
|
221
|
-
* @param {Number} index - The index in `keySystemsType` to start from.
|
|
222
|
-
* Should be set to `0` when calling directly.
|
|
223
|
-
* @returns {Observable}
|
|
224
|
-
*/
|
|
225
|
-
function recursivelyTestKeySystems(index) {
|
|
226
|
-
// if we iterated over the whole keySystemsType Array, quit on error
|
|
227
|
-
if (index >= keySystemsType.length) {
|
|
228
|
-
var error_1 = new EncryptedMediaError("INCOMPATIBLE_KEYSYSTEMS", "No key system compatible with your " +
|
|
229
|
-
"wanted configuration has been found " +
|
|
230
|
-
"in the current browser.");
|
|
231
|
-
return observableThrow(function () { return error_1; });
|
|
232
|
-
}
|
|
233
|
-
if (requestMediaKeySystemAccess == null) {
|
|
234
|
-
var error_2 = Error("requestMediaKeySystemAccess is not " +
|
|
235
|
-
"implemented in your browser.");
|
|
236
|
-
return observableThrow(function () { return error_2; });
|
|
237
|
-
}
|
|
238
|
-
var _a = keySystemsType[index], keyName = _a.keyName, keyType = _a.keyType, keySystemOptions = _a.keySystemOptions;
|
|
239
|
-
var keySystemConfigurations = buildKeySystemConfigurations(keyName, keySystemOptions);
|
|
240
|
-
log.debug("EME: Request keysystem access ".concat(keyType, ",") +
|
|
241
|
-
"".concat(index + 1, " of ").concat(keySystemsType.length), keySystemConfigurations);
|
|
242
|
-
return requestMediaKeySystemAccess(keyType, keySystemConfigurations).pipe(map(function (keySystemAccess) {
|
|
243
|
-
log.info("EME: Found compatible keysystem", keyType, keySystemConfigurations);
|
|
244
|
-
return { type: "create-media-key-system-access",
|
|
245
|
-
value: { options: keySystemOptions,
|
|
246
|
-
mediaKeySystemAccess: keySystemAccess } };
|
|
247
|
-
}), catchError(function () {
|
|
248
|
-
log.debug("EME: Rejected access to keysystem", keyType, keySystemConfigurations);
|
|
249
|
-
return recursivelyTestKeySystems(index + 1);
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
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 { catchError, map, mergeMap, of as observableOf, } from "rxjs";
|
|
17
|
-
import { EncryptedMediaError } from "../../errors";
|
|
18
|
-
import log from "../../log";
|
|
19
|
-
import castToObservable from "../../utils/cast_to_observable";
|
|
20
|
-
import isNullOrUndefined from "../../utils/is_null_or_undefined";
|
|
21
|
-
import tryCatch from "../../utils/rx-try_catch";
|
|
22
|
-
import getMediaKeySystemAccess from "./find_key_system";
|
|
23
|
-
import MediaKeysInfosStore from "./media_keys_infos_store";
|
|
24
|
-
import ServerCertificateStore from "./server_certificate_store";
|
|
25
|
-
import LoadedSessionsStore from "./utils/loaded_sessions_store";
|
|
26
|
-
import PersistentSessionsStore from "./utils/persistent_sessions_store";
|
|
27
|
-
/**
|
|
28
|
-
* @throws {EncryptedMediaError}
|
|
29
|
-
* @param {Object} keySystemOptions
|
|
30
|
-
* @returns {Object|null}
|
|
31
|
-
*/
|
|
32
|
-
function createPersistentSessionsStorage(keySystemOptions) {
|
|
33
|
-
if (keySystemOptions.persistentLicense !== true) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
var licenseStorage = keySystemOptions.licenseStorage;
|
|
37
|
-
if (licenseStorage == null) {
|
|
38
|
-
throw new EncryptedMediaError("INVALID_KEY_SYSTEM", "No license storage found for persistent license.");
|
|
39
|
-
}
|
|
40
|
-
log.debug("EME: Set the given license storage");
|
|
41
|
-
return new PersistentSessionsStore(licenseStorage);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @param {HTMLMediaElement} mediaElement
|
|
45
|
-
* @param {Array.<Object>} keySystemsConfigs
|
|
46
|
-
* @returns {Observable}
|
|
47
|
-
*/
|
|
48
|
-
export default function getMediaKeysInfos(mediaElement, keySystemsConfigs) {
|
|
49
|
-
return getMediaKeySystemAccess(mediaElement, keySystemsConfigs).pipe(mergeMap(function (evt) {
|
|
50
|
-
var _a = evt.value, options = _a.options, mediaKeySystemAccess = _a.mediaKeySystemAccess;
|
|
51
|
-
var currentState = MediaKeysInfosStore.getState(mediaElement);
|
|
52
|
-
var persistentSessionsStore = createPersistentSessionsStorage(options);
|
|
53
|
-
if (currentState !== null && evt.type === "reuse-media-key-system-access") {
|
|
54
|
-
var mediaKeys = currentState.mediaKeys, loadedSessionsStore = currentState.loadedSessionsStore;
|
|
55
|
-
// We might just rely on the currently attached MediaKeys instance.
|
|
56
|
-
// First check if server certificate parameters are the same than in the
|
|
57
|
-
// current MediaKeys instance. If not, re-create MediaKeys from scratch.
|
|
58
|
-
if (ServerCertificateStore.hasOne(mediaKeys) === false ||
|
|
59
|
-
(!isNullOrUndefined(options.serverCertificate) &&
|
|
60
|
-
ServerCertificateStore.has(mediaKeys, options.serverCertificate))) {
|
|
61
|
-
return observableOf({ mediaKeys: mediaKeys, mediaKeySystemAccess: mediaKeySystemAccess, stores: { loadedSessionsStore: loadedSessionsStore, persistentSessionsStore: persistentSessionsStore }, options: options });
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return createMediaKeys(mediaKeySystemAccess).pipe(map(function (mediaKeys) {
|
|
65
|
-
log.info("EME: MediaKeys created with success");
|
|
66
|
-
var loadedSessionsStore = new LoadedSessionsStore(mediaKeys);
|
|
67
|
-
return { mediaKeys: mediaKeys, mediaKeySystemAccess: mediaKeySystemAccess, stores: { loadedSessionsStore: loadedSessionsStore, persistentSessionsStore: persistentSessionsStore }, options: options };
|
|
68
|
-
}));
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create `MediaKeys` from the `MediaKeySystemAccess` given.
|
|
73
|
-
* Throws the right formatted error if it fails.
|
|
74
|
-
* @param {MediaKeySystemAccess} mediaKeySystemAccess
|
|
75
|
-
* @returns {Observable.<MediaKeys>}
|
|
76
|
-
*/
|
|
77
|
-
function createMediaKeys(mediaKeySystemAccess) {
|
|
78
|
-
log.info("EME: Calling createMediaKeys on the MediaKeySystemAccess");
|
|
79
|
-
return tryCatch(function () { return castToObservable(mediaKeySystemAccess.createMediaKeys()); }, undefined).pipe(catchError(function (error) {
|
|
80
|
-
var message = error instanceof Error ?
|
|
81
|
-
error.message :
|
|
82
|
-
"Unknown error when creating MediaKeys.";
|
|
83
|
-
throw new EncryptedMediaError("CREATE_MEDIA_KEYS_ERROR", message);
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
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 { concat as observableConcat, defer as observableDefer, map, mergeMap, of as observableOf, } from "rxjs";
|
|
17
|
-
import log from "../../log";
|
|
18
|
-
import cleanOldLoadedSessions from "./clean_old_loaded_sessions";
|
|
19
|
-
import createSession from "./create_session";
|
|
20
|
-
import isSessionUsable from "./utils/is_session_usable";
|
|
21
|
-
/**
|
|
22
|
-
* Handle MediaEncryptedEvents sent by a HTMLMediaElement:
|
|
23
|
-
* Either create a MediaKeySession, recuperate a previous MediaKeySession or
|
|
24
|
-
* load a persistent session.
|
|
25
|
-
*
|
|
26
|
-
* Some previously created MediaKeySession can be closed in this process to
|
|
27
|
-
* respect the maximum limit of concurrent MediaKeySession, as defined by the
|
|
28
|
-
* `EME_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS` config property.
|
|
29
|
-
*
|
|
30
|
-
* You can refer to the events emitted to know about the current situation.
|
|
31
|
-
* @param {Event} initializationDataInfo
|
|
32
|
-
* @param {Object} handledInitData
|
|
33
|
-
* @param {Object} mediaKeysInfos
|
|
34
|
-
* @returns {Observable}
|
|
35
|
-
*/
|
|
36
|
-
export default function getSession(initializationData, stores, wantedSessionType, maxSessionCacheSize) {
|
|
37
|
-
return observableDefer(function () {
|
|
38
|
-
/**
|
|
39
|
-
* Store previously-loaded MediaKeySession with the same initialization data, if one.
|
|
40
|
-
*/
|
|
41
|
-
var previousLoadedSession = null;
|
|
42
|
-
var loadedSessionsStore = stores.loadedSessionsStore, persistentSessionsStore = stores.persistentSessionsStore;
|
|
43
|
-
var entry = loadedSessionsStore.getAndReuse(initializationData);
|
|
44
|
-
if (entry !== null) {
|
|
45
|
-
previousLoadedSession = entry.mediaKeySession;
|
|
46
|
-
if (isSessionUsable(previousLoadedSession)) {
|
|
47
|
-
log.info("EME: Reuse loaded session", previousLoadedSession.sessionId);
|
|
48
|
-
return observableOf({ type: "loaded-open-session",
|
|
49
|
-
value: { mediaKeySession: previousLoadedSession,
|
|
50
|
-
sessionType: entry.sessionType, initializationData: initializationData } });
|
|
51
|
-
}
|
|
52
|
-
else if (persistentSessionsStore !== null) {
|
|
53
|
-
// If the session is not usable anymore, we can also remove it from the
|
|
54
|
-
// PersistentSessionsStore.
|
|
55
|
-
// TODO Are we sure this is always what we want?
|
|
56
|
-
persistentSessionsStore.delete(initializationData);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return (previousLoadedSession != null ?
|
|
60
|
-
loadedSessionsStore.closeSession(initializationData) :
|
|
61
|
-
observableOf(null)).pipe(mergeMap(function () {
|
|
62
|
-
return observableConcat(cleanOldLoadedSessions(loadedSessionsStore, maxSessionCacheSize), createSession(stores, initializationData, wantedSessionType)
|
|
63
|
-
.pipe(map(function (evt) { return ({ type: evt.type,
|
|
64
|
-
value: { mediaKeySession: evt.value.mediaKeySession,
|
|
65
|
-
sessionType: evt.value.sessionType, initializationData: initializationData } }); })));
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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 { filter, mapTo, mergeMap, of as observableOf, startWith, take, } from "rxjs";
|
|
17
|
-
import log from "../../log";
|
|
18
|
-
import isNullOrUndefined from "../../utils/is_null_or_undefined";
|
|
19
|
-
import createSharedReference from "../../utils/reference";
|
|
20
|
-
import attachMediaKeys, { disableMediaKeys, } from "./attach_media_keys";
|
|
21
|
-
import getDrmSystemId from "./get_drm_system_id";
|
|
22
|
-
import getMediaKeysInfos from "./get_media_keys";
|
|
23
|
-
/**
|
|
24
|
-
* Get media keys infos from key system configs then attach media keys to media element.
|
|
25
|
-
* @param {HTMLMediaElement} mediaElement
|
|
26
|
-
* @param {Array.<Object>} keySystemsConfigs
|
|
27
|
-
* @returns {Observable}
|
|
28
|
-
*/
|
|
29
|
-
export default function initMediaKeys(mediaElement, keySystemsConfigs) {
|
|
30
|
-
return getMediaKeysInfos(mediaElement, keySystemsConfigs)
|
|
31
|
-
.pipe(mergeMap(function (_a) {
|
|
32
|
-
var mediaKeys = _a.mediaKeys, mediaKeySystemAccess = _a.mediaKeySystemAccess, stores = _a.stores, options = _a.options;
|
|
33
|
-
/**
|
|
34
|
-
* String identifying the key system, allowing the rest of the code to
|
|
35
|
-
* only advertise the required initialization data for license requests.
|
|
36
|
-
*
|
|
37
|
-
* Note that we only set this value if retro-compatibility to older
|
|
38
|
-
* persistent logic in the RxPlayer is not important, as the optimizations
|
|
39
|
-
* this property unlocks can break the loading of MediaKeySessions
|
|
40
|
-
* persisted in older RxPlayer's versions.
|
|
41
|
-
*/
|
|
42
|
-
var initializationDataSystemId;
|
|
43
|
-
if (isNullOrUndefined(options.licenseStorage) ||
|
|
44
|
-
options.licenseStorage.disableRetroCompatibility === true) {
|
|
45
|
-
initializationDataSystemId = getDrmSystemId(mediaKeySystemAccess.keySystem);
|
|
46
|
-
}
|
|
47
|
-
var canAttachMediaKeys = createSharedReference(false);
|
|
48
|
-
var shouldDisableOldMediaKeys = mediaElement.mediaKeys !== null &&
|
|
49
|
-
mediaElement.mediaKeys !== undefined &&
|
|
50
|
-
mediaKeys !== mediaElement.mediaKeys;
|
|
51
|
-
var disableOldMediaKeys$ = observableOf(null);
|
|
52
|
-
if (shouldDisableOldMediaKeys) {
|
|
53
|
-
log.debug("EME: Disabling old MediaKeys");
|
|
54
|
-
disableOldMediaKeys$ = disableMediaKeys(mediaElement);
|
|
55
|
-
}
|
|
56
|
-
return disableOldMediaKeys$.pipe(mergeMap(function () {
|
|
57
|
-
log.debug("EME: Attaching current MediaKeys");
|
|
58
|
-
return canAttachMediaKeys.asObservable().pipe(filter(function (canAttach) { return canAttach; }), mergeMap(function () {
|
|
59
|
-
var stateToAttatch = { loadedSessionsStore: stores.loadedSessionsStore, mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, keySystemOptions: options };
|
|
60
|
-
return attachMediaKeys(mediaElement, stateToAttatch);
|
|
61
|
-
}), take(1), mapTo({ type: "attached-media-keys",
|
|
62
|
-
value: { mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, stores: stores, options: options } }), startWith({ type: "created-media-keys",
|
|
63
|
-
value: { mediaKeySystemAccess: mediaKeySystemAccess, initializationDataSystemId: initializationDataSystemId, mediaKeys: mediaKeys, stores: stores, options: options, canAttachMediaKeys: canAttachMediaKeys } }));
|
|
64
|
-
}));
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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 { Observable } from "rxjs";
|
|
17
|
-
import { ICustomMediaKeySession } from "../../compat";
|
|
18
|
-
import { ICustomError } from "../../errors";
|
|
19
|
-
import { IInitializationDataInfo, IEMEWarningEvent, IKeySystemOption, IKeysUpdateEvent, INoUpdateEvent, ISessionMessageEvent, ISessionUpdatedEvent } from "./types";
|
|
20
|
-
/**
|
|
21
|
-
* Error thrown when the MediaKeySession is blacklisted.
|
|
22
|
-
* Such MediaKeySession should not be re-used but other MediaKeySession for the
|
|
23
|
-
* same content can still be used.
|
|
24
|
-
* @class BlacklistedSessionError
|
|
25
|
-
* @extends Error
|
|
26
|
-
*/
|
|
27
|
-
export declare class BlacklistedSessionError extends Error {
|
|
28
|
-
sessionError: ICustomError;
|
|
29
|
-
constructor(sessionError: ICustomError);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* listen to various events from a MediaKeySession and react accordingly
|
|
33
|
-
* depending on the configuration given.
|
|
34
|
-
* @param {MediaKeySession} session - The MediaKeySession concerned.
|
|
35
|
-
* @param {Object} keySystemOptions - The key system options.
|
|
36
|
-
* @param {String} keySystem - The configuration keySystem used for deciphering
|
|
37
|
-
* @param {Object} initializationData - The initialization data linked to that
|
|
38
|
-
* session.
|
|
39
|
-
* @returns {Observable}
|
|
40
|
-
*/
|
|
41
|
-
export default function SessionEventsListener(session: MediaKeySession | ICustomMediaKeySession, keySystemOptions: IKeySystemOption, keySystem: string, initializationData: IInitializationDataInfo): Observable<IEMEWarningEvent | ISessionMessageEvent | INoUpdateEvent | IKeysUpdateEvent | ISessionUpdatedEvent>;
|
|
@@ -1,85 +0,0 @@
|
|
|
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 { catchError, defer as observableDefer, EMPTY, ignoreElements, tap, of as observableOf, } from "rxjs";
|
|
17
|
-
import { EncryptedMediaError } from "../../errors";
|
|
18
|
-
import log from "../../log";
|
|
19
|
-
import castToObservable from "../../utils/cast_to_observable";
|
|
20
|
-
import tryCatch from "../../utils/rx-try_catch";
|
|
21
|
-
import ServerCertificateStore from "./server_certificate_store";
|
|
22
|
-
/**
|
|
23
|
-
* Call the setServerCertificate API with the given certificate.
|
|
24
|
-
* Complete observable on success, throw when failed.
|
|
25
|
-
*
|
|
26
|
-
* TODO Handle returned value?
|
|
27
|
-
* From the spec:
|
|
28
|
-
* - setServerCertificate resolves with true if everything worked
|
|
29
|
-
* - it resolves with false if the CDM does not support server
|
|
30
|
-
* certificates.
|
|
31
|
-
*
|
|
32
|
-
* @param {MediaKeys} mediaKeys
|
|
33
|
-
* @param {ArrayBuffer} serverCertificate
|
|
34
|
-
* @returns {Observable}
|
|
35
|
-
*/
|
|
36
|
-
function setServerCertificate(mediaKeys, serverCertificate) {
|
|
37
|
-
return observableDefer(function () {
|
|
38
|
-
return tryCatch(function () {
|
|
39
|
-
return castToObservable(mediaKeys.setServerCertificate(serverCertificate));
|
|
40
|
-
}, undefined).pipe(catchError(function (error) {
|
|
41
|
-
log.warn("EME: mediaKeys.setServerCertificate returned an error", error);
|
|
42
|
-
var reason = error instanceof Error ? error.toString() :
|
|
43
|
-
"`setServerCertificate` error";
|
|
44
|
-
throw new EncryptedMediaError("LICENSE_SERVER_CERTIFICATE_ERROR", reason);
|
|
45
|
-
}));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Call the setCertificate API. If it fails just emit the error as warning
|
|
50
|
-
* and complete.
|
|
51
|
-
* @param {MediaKeys} mediaKeys
|
|
52
|
-
* @param {ArrayBuffer} serverCertificate
|
|
53
|
-
* @returns {Observable}
|
|
54
|
-
*/
|
|
55
|
-
export default function trySettingServerCertificate(mediaKeys, serverCertificate) {
|
|
56
|
-
return observableDefer(function () {
|
|
57
|
-
if (typeof mediaKeys.setServerCertificate !== "function") {
|
|
58
|
-
log.warn("EME: Could not set the server certificate." +
|
|
59
|
-
" mediaKeys.setServerCertificate is not a function");
|
|
60
|
-
return EMPTY;
|
|
61
|
-
}
|
|
62
|
-
if (ServerCertificateStore.hasOne(mediaKeys) === true) {
|
|
63
|
-
log.info("EME: The MediaKeys already has a server certificate, skipping...");
|
|
64
|
-
return EMPTY;
|
|
65
|
-
}
|
|
66
|
-
log.info("EME: Setting server certificate on the MediaKeys");
|
|
67
|
-
// Because of browser errors, or a user action that can lead to interrupting
|
|
68
|
-
// server certificate setting, we might be left in a status where we don't
|
|
69
|
-
// know if we attached the server certificate or not.
|
|
70
|
-
// Calling `prepare` allow to invalidate temporarily that status.
|
|
71
|
-
ServerCertificateStore.prepare(mediaKeys);
|
|
72
|
-
return setServerCertificate(mediaKeys, serverCertificate).pipe(tap(function () { ServerCertificateStore.set(mediaKeys, serverCertificate); }),
|
|
73
|
-
// NOTE As of now (RxJS 7.4.0), RxJS defines `ignoreElements` default
|
|
74
|
-
// first type parameter as `any` instead of the perfectly fine `unknown`,
|
|
75
|
-
// leading to linter issues, as it forbids the usage of `any`.
|
|
76
|
-
// This is why we're disabling the eslint rule.
|
|
77
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
78
|
-
ignoreElements(), catchError(function (error) { return observableOf({
|
|
79
|
-
type: "warning",
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
81
|
-
value: error,
|
|
82
|
-
}); }));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
export { trySettingServerCertificate, setServerCertificate, };
|