rx-player 3.26.2 → 3.27.0-dev.20220317
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/perfs.yml +22 -0
- package/CHANGELOG.md +33 -1
- package/FILES.md +5 -4
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +4 -2
- package/dist/_esm5.processed/compat/browser_detection.js +4 -2
- package/dist/_esm5.processed/compat/eme/close_session.d.ts +11 -5
- package/dist/_esm5.processed/compat/eme/close_session.js +144 -36
- package/dist/_esm5.processed/compat/eme/custom_media_keys/index.d.ts +3 -5
- package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +27 -24
- package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +53 -34
- package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +43 -41
- package/dist/_esm5.processed/compat/eme/generate_key_request.d.ts +2 -3
- package/dist/_esm5.processed/compat/eme/generate_key_request.js +22 -26
- package/dist/_esm5.processed/compat/eme/load_session.d.ts +1 -2
- package/dist/_esm5.processed/compat/eme/load_session.js +68 -17
- package/dist/_esm5.processed/compat/event_listeners.js +2 -1
- package/dist/_esm5.processed/compat/should_favour_custom_safari_EME.js +2 -2
- package/dist/_esm5.processed/config.d.ts +166 -1080
- package/dist/_esm5.processed/config.js +17 -1119
- package/dist/_esm5.processed/core/abr/bandwidth_estimator.js +4 -1
- package/dist/_esm5.processed/core/abr/buffer_based_chooser.d.ts +28 -6
- package/dist/_esm5.processed/core/abr/buffer_based_chooser.js +63 -12
- package/dist/_esm5.processed/core/abr/network_analyzer.d.ts +1 -1
- package/dist/_esm5.processed/core/abr/network_analyzer.js +2 -1
- package/dist/_esm5.processed/core/abr/pending_requests_store.js +3 -5
- package/dist/_esm5.processed/core/abr/representation_estimator.d.ts +1 -1
- package/dist/_esm5.processed/core/abr/representation_estimator.js +2 -2
- package/dist/_esm5.processed/core/api/get_player_state.js +1 -1
- package/dist/_esm5.processed/core/api/index.d.ts +2 -1
- package/dist/_esm5.processed/core/api/media_element_track_choice_manager.d.ts +6 -0
- package/dist/_esm5.processed/core/api/media_element_track_choice_manager.js +22 -4
- package/dist/_esm5.processed/core/api/option_utils.d.ts +3 -1
- package/dist/_esm5.processed/core/api/option_utils.js +19 -6
- package/dist/_esm5.processed/core/api/playback_observer.js +5 -1
- package/dist/_esm5.processed/core/api/public_api.d.ts +82 -71
- package/dist/_esm5.processed/core/api/public_api.js +72 -33
- package/dist/_esm5.processed/core/api/track_choice_manager.d.ts +6 -6
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.d.ts +7 -51
- package/dist/_esm5.processed/core/{eme → decrypt}/__tests__/__global__/utils.js +30 -75
- package/dist/_esm5.processed/core/{eme → decrypt}/attach_media_keys.d.ts +12 -12
- package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +104 -0
- package/dist/_esm5.processed/core/{eme/clear_eme_session.d.ts → decrypt/clear_on_stop.d.ts} +3 -4
- package/dist/_esm5.processed/core/decrypt/clear_on_stop.js +41 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +216 -0
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +866 -0
- package/dist/_esm5.processed/core/{eme/get_session.d.ts → decrypt/create_or_load_session.d.ts} +28 -26
- package/dist/_esm5.processed/core/decrypt/create_or_load_session.js +124 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/create_session.d.ts +22 -19
- package/dist/_esm5.processed/core/decrypt/create_session.js +174 -0
- package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.d.ts +21 -0
- package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.js +81 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/find_key_system.d.ts +11 -14
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +300 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/get_current_key_system.d.ts +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/get_current_key_system.js +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt}/get_media_keys.d.ts +13 -5
- package/dist/_esm5.processed/core/decrypt/get_media_keys.js +153 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/index.d.ts +5 -6
- package/dist/_esm5.processed/core/{eme → decrypt}/index.js +5 -5
- package/dist/_esm5.processed/core/{eme → decrypt}/init_media_keys.d.ts +6 -4
- package/dist/_esm5.processed/core/decrypt/init_media_keys.js +82 -0
- package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +77 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/session_events_listener.js +25 -24
- package/dist/_esm5.processed/core/{eme → decrypt}/set_server_certificate.d.ts +15 -6
- package/dist/_esm5.processed/core/decrypt/set_server_certificate.js +141 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/types.d.ts +120 -242
- package/dist/_esm5.processed/core/{eme → decrypt}/types.js +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/are_init_values_compatible.d.ts +3 -3
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/are_init_values_compatible.js +5 -5
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/check_key_statuses.d.ts +2 -2
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/check_key_statuses.js +4 -3
- package/dist/_esm5.processed/core/{eme/utils/close_session.d.ts → decrypt/utils/clean_old_loaded_sessions.d.ts} +8 -7
- package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +85 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.d.ts +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.js +2 -2
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/get_drm_system_id.d.ts +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/get_drm_system_id.js +1 -1
- package/dist/_esm5.processed/core/decrypt/utils/init_data_values_container.d.ts +69 -0
- package/dist/_esm5.processed/core/decrypt/utils/init_data_values_container.js +99 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/is_session_usable.d.ts +0 -1
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/is_session_usable.js +4 -5
- package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.d.ts +44 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.js +77 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_session_record.d.ts +104 -0
- package/dist/_esm5.processed/core/decrypt/utils/key_session_record.js +155 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.d.ts +108 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +303 -0
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/media_keys_infos_store.d.ts +4 -4
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/media_keys_infos_store.js +0 -0
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/persistent_sessions_store.d.ts +8 -18
- package/dist/_esm5.processed/core/{eme → decrypt}/utils/persistent_sessions_store.js +119 -97
- package/dist/_esm5.processed/core/{eme/utils/init_data_container.d.ts → decrypt/utils/serializable_bytes.d.ts} +8 -5
- package/dist/_esm5.processed/core/{eme/utils/init_data_container.js → decrypt/utils/serializable_bytes.js} +9 -9
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/server_certificate_store.d.ts +1 -1
- package/dist/_esm5.processed/core/{eme → decrypt/utils}/server_certificate_store.js +1 -1
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +4 -4
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +3 -3
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +2 -2
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +6 -2
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
- package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +1 -1
- package/dist/_esm5.processed/core/init/get_initial_time.js +1 -1
- package/dist/_esm5.processed/core/init/initialize_directfile.d.ts +3 -3
- package/dist/_esm5.processed/core/init/initialize_directfile.js +11 -17
- package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +5 -3
- package/dist/_esm5.processed/core/init/initialize_media_source.js +18 -69
- package/dist/_esm5.processed/core/init/link_drm_and_content.d.ts +61 -0
- package/dist/_esm5.processed/core/init/link_drm_and_content.js +94 -0
- package/dist/_esm5.processed/core/init/manifest_update_scheduler.d.ts +4 -4
- package/dist/_esm5.processed/core/init/manifest_update_scheduler.js +2 -1
- package/dist/_esm5.processed/core/init/stall_avoider.js +1 -1
- package/dist/_esm5.processed/core/init/stream_events_emitter/are_same_stream_events.d.ts +4 -4
- package/dist/_esm5.processed/core/init/stream_events_emitter/stream_events_emitter.js +1 -1
- package/dist/_esm5.processed/core/init/stream_events_emitter/types.d.ts +2 -2
- package/dist/_esm5.processed/core/init/types.d.ts +2 -4
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +3 -3
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +3 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +32 -31
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +4 -4
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +17 -1
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +22 -5
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +2 -1
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +6 -3
- package/dist/_esm5.processed/core/stream/events_generators.d.ts +8 -3
- package/dist/_esm5.processed/core/stream/events_generators.js +3 -2
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +1 -0
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +3 -3
- package/dist/_esm5.processed/core/stream/period/create_empty_adaptation_stream.js +2 -1
- package/dist/_esm5.processed/core/stream/period/get_adaptation_switch_strategy.js +1 -1
- package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +2 -1
- package/dist/_esm5.processed/core/stream/period/period_stream.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/force_garbage_collection.js +5 -6
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.d.ts +6 -1
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.js +12 -9
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.d.ts +19 -14
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.js +86 -10
- package/dist/_esm5.processed/core/stream/representation/get_segment_priority.js +1 -1
- package/dist/_esm5.processed/core/stream/representation/push_media_segment.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/representation_stream.d.ts +6 -0
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +19 -8
- package/dist/_esm5.processed/core/stream/types.d.ts +1 -1
- package/dist/_esm5.processed/default_config.d.ts +1114 -0
- package/dist/_esm5.processed/default_config.js +1145 -0
- package/dist/_esm5.processed/errors/request_error.js +3 -1
- package/dist/_esm5.processed/experimental/index.d.ts +2 -0
- package/dist/_esm5.processed/experimental/index.js +2 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/push_data.d.ts +1 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.d.ts +2 -2
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.js +2 -4
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +1 -1
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +1 -1
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +1 -2
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/types.d.ts +3 -3
- package/dist/_esm5.processed/features/features_object.js +1 -1
- package/dist/_esm5.processed/features/initialize_features.js +1 -1
- package/dist/_esm5.processed/features/list/eme.d.ts +3 -3
- package/dist/_esm5.processed/features/list/eme.js +5 -5
- package/dist/_esm5.processed/features/types.d.ts +3 -3
- package/dist/_esm5.processed/manifest/adaptation.d.ts +2 -2
- package/dist/_esm5.processed/manifest/adaptation.js +3 -1
- package/dist/_esm5.processed/manifest/manifest.d.ts +10 -23
- package/dist/_esm5.processed/manifest/manifest.js +10 -74
- package/dist/_esm5.processed/manifest/period.d.ts +3 -3
- package/dist/_esm5.processed/manifest/representation.d.ts +37 -5
- package/dist/_esm5.processed/manifest/representation_index/types.d.ts +18 -18
- package/dist/_esm5.processed/manifest/types.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/get_hdr_information.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/get_periods_time_infos.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +6 -6
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/is_period_fulfilled.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +14 -14
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +17 -17
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +28 -20
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +20 -5
- package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +17 -35
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +109 -96
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +8 -8
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.d.ts +18 -27
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +25 -23
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +21 -15
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +19 -19
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.d.ts +15 -38
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +8 -8
- package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +30 -30
- package/dist/_esm5.processed/parsers/manifest/dash/parsers_types.d.ts +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +7 -7
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +1 -0
- package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +8 -8
- package/dist/_esm5.processed/parsers/manifest/types.d.ts +28 -28
- package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.d.ts +3 -2
- package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.js +15 -5
- package/dist/_esm5.processed/parsers/manifest/utils/index_helpers.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.d.ts +11 -1
- package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.js +31 -19
- package/dist/_esm5.processed/parsers/texttracks/webvtt/html/to_html.d.ts +2 -2
- package/dist/_esm5.processed/parsers/texttracks/webvtt/parse_cue_block.d.ts +1 -1
- package/dist/_esm5.processed/public_types.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +2 -1
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +4 -1
- package/dist/_esm5.processed/transports/dash/init_segment_loader.js +1 -1
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/dash/segment_parser.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/segment_parser.js +6 -3
- package/dist/_esm5.processed/transports/dash/text_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/text_loader.js +1 -1
- package/dist/_esm5.processed/transports/dash/text_parser.d.ts +1 -1
- package/dist/_esm5.processed/transports/dash/text_parser.js +8 -2
- package/dist/_esm5.processed/transports/local/segment_loader.d.ts +1 -2
- package/dist/_esm5.processed/transports/local/segment_loader.js +1 -1
- package/dist/_esm5.processed/transports/local/segment_parser.js +4 -1
- package/dist/_esm5.processed/transports/local/text_parser.js +8 -2
- package/dist/_esm5.processed/transports/metaplaylist/manifest_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +1 -1
- package/dist/_esm5.processed/transports/smooth/pipelines.js +69 -11
- package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +0 -1
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/types.d.ts +58 -30
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +1 -1
- package/dist/_esm5.processed/transports/utils/generate_manifest_loader.d.ts +1 -1
- package/dist/_esm5.processed/utils/cancellable_sleep.js +1 -1
- package/dist/_esm5.processed/utils/cast_to_observable.d.ts +1 -2
- package/dist/_esm5.processed/utils/cast_to_observable.js +1 -1
- package/dist/_esm5.processed/utils/deep_merge.d.ts +12 -0
- package/dist/_esm5.processed/utils/deep_merge.js +53 -0
- package/dist/_esm5.processed/utils/reference.d.ts +29 -0
- package/dist/_esm5.processed/utils/reference.js +72 -24
- package/dist/_esm5.processed/utils/request/fetch.d.ts +4 -5
- package/dist/_esm5.processed/utils/request/fetch.js +8 -6
- package/dist/_esm5.processed/utils/request/xhr.d.ts +6 -6
- package/dist/_esm5.processed/utils/request/xhr.js +3 -2
- package/dist/_esm5.processed/utils/rx-from_cancellable_promise.d.ts +1 -2
- package/dist/_esm5.processed/utils/rx-from_cancellable_promise.js +7 -2
- package/dist/_esm5.processed/utils/task_canceller.d.ts +5 -3
- package/dist/_esm5.processed/utils/task_canceller.js +3 -3
- package/dist/rx-player.js +5242 -3190
- package/dist/rx-player.min.js +1 -1
- package/dummy +1 -0
- package/{dist/_esm5.processed/core/eme/dispose_eme.d.ts → experimental/index.d.ts} +1 -4
- package/{dist/_esm5.processed/core/eme/dispose_media_keys.d.ts → experimental/index.js} +1 -6
- package/package.json +33 -36
- package/scripts/build/templates/experimental/index.d.ts +16 -0
- package/scripts/build/templates/experimental/index.js +16 -0
- package/scripts/doc-generator/generate_header_html.js +6 -7
- package/scripts/doc-generator/generate_page_html.js +3 -4
- package/scripts/doc-generator/generate_page_list_html.js +4 -5
- package/scripts/doc-generator/generate_sidebar_html.js +4 -7
- package/scripts/doc-generator/utils.js +0 -11
- package/scripts/generate_demo_list.js +3 -3
- package/scripts/generate_documentation_list.js +3 -3
- package/scripts/launch_static_server.js +127 -67
- package/scripts/run_standalone_demo.js +1 -0
- package/scripts/start_demo_web_server.js +1 -0
- package/sonar-project.properties +1 -1
- package/src/README.md +6 -6
- package/src/compat/__tests__/fullscreen.test.ts +7 -7
- package/src/compat/__tests__/is_vtt_cue.test.ts +1 -1
- package/src/compat/__tests__/should_favour_custom_safari_EME.test.ts +45 -5
- package/src/compat/browser_detection.ts +4 -2
- package/src/compat/eme/close_session.ts +90 -56
- package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +1 -1
- package/src/compat/eme/custom_media_keys/index.ts +28 -41
- package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +63 -46
- package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +51 -49
- package/src/compat/eme/generate_key_request.ts +25 -33
- package/src/compat/eme/load_session.ts +29 -31
- package/src/compat/event_listeners.ts +2 -1
- package/src/compat/should_favour_custom_safari_EME.ts +5 -2
- package/src/config.ts +17 -1210
- package/src/core/README.md +1 -1
- package/src/core/abr/__tests__/{get_estimate_from_buffer_levels.test.ts → buffer_based_chooser.test.ts} +94 -123
- package/src/core/abr/bandwidth_estimator.ts +4 -4
- package/src/core/abr/buffer_based_chooser.ts +85 -20
- package/src/core/abr/network_analyzer.ts +6 -7
- package/src/core/abr/pending_requests_store.ts +3 -5
- package/src/core/abr/representation_estimator.ts +6 -3
- package/src/core/api/__tests__/get_player_state.test.ts +3 -3
- package/src/core/api/__tests__/option_utils.test.ts +17 -17
- package/src/core/api/get_player_state.ts +1 -1
- package/src/core/api/index.ts +3 -0
- package/src/core/api/media_element_track_choice_manager.ts +22 -3
- package/src/core/api/option_utils.ts +37 -20
- package/src/core/api/playback_observer.ts +12 -8
- package/src/core/api/public_api.ts +152 -112
- package/src/core/api/track_choice_manager.ts +10 -9
- package/src/core/decrypt/README.md +22 -0
- package/src/core/decrypt/__tests__/__global__/get_license.test.ts +418 -0
- package/src/core/decrypt/__tests__/__global__/init_data.test.ts +675 -0
- package/src/core/{eme → decrypt}/__tests__/__global__/media_key_system_access.test.ts +99 -92
- package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +156 -0
- package/src/core/decrypt/__tests__/__global__/server_certificate.test.ts +262 -0
- package/src/core/{eme → decrypt}/__tests__/__global__/utils.ts +36 -103
- package/src/core/{eme → decrypt}/attach_media_keys.ts +49 -56
- package/src/core/decrypt/clear_on_stop.ts +48 -0
- package/src/core/decrypt/content_decryptor.ts +1158 -0
- package/src/core/decrypt/create_or_load_session.ts +130 -0
- package/src/core/decrypt/create_session.ts +175 -0
- package/src/core/decrypt/dispose_decryption_resources.ts +39 -0
- package/src/core/{eme → decrypt}/find_key_system.ts +126 -134
- package/src/core/{eme → decrypt}/get_current_key_system.ts +1 -1
- package/src/core/decrypt/get_media_keys.ts +145 -0
- package/src/core/{eme → decrypt}/index.ts +11 -8
- package/src/core/decrypt/init_media_keys.ts +51 -0
- package/src/core/{eme → decrypt}/session_events_listener.ts +93 -55
- package/src/core/decrypt/set_server_certificate.ts +104 -0
- package/src/core/{eme → decrypt}/types.ts +129 -259
- package/src/core/{eme → decrypt}/utils/__tests__/are_init_values_compatible.test.ts +1 -1
- package/src/core/{eme → decrypt/utils}/__tests__/clean_old_loaded_sessions.test.ts +29 -71
- package/src/core/{eme → decrypt/utils}/__tests__/clean_old_stored_persistent_info.test.ts +6 -6
- package/src/core/{eme → decrypt}/utils/are_init_values_compatible.ts +9 -9
- package/src/core/{eme → decrypt/utils}/check_key_statuses.ts +6 -5
- package/{dist/_esm5.processed/core/eme/clean_old_loaded_sessions.js → src/core/decrypt/utils/clean_old_loaded_sessions.ts} +20 -20
- package/src/core/{eme → decrypt/utils}/clean_old_stored_persistent_info.ts +3 -3
- package/src/core/{eme → decrypt/utils}/get_drm_system_id.ts +1 -1
- package/src/core/decrypt/utils/init_data_values_container.ts +119 -0
- package/src/core/{eme → decrypt}/utils/is_session_usable.ts +4 -5
- package/src/core/decrypt/utils/key_id_comparison.ts +82 -0
- package/src/core/decrypt/utils/key_session_record.ts +175 -0
- package/src/core/decrypt/utils/loaded_sessions_store.ts +318 -0
- package/src/core/{eme → decrypt/utils}/media_keys_infos_store.ts +4 -4
- package/src/core/{eme → decrypt}/utils/persistent_sessions_store.ts +122 -104
- package/src/core/{eme/utils/init_data_container.ts → decrypt/utils/serializable_bytes.ts} +8 -5
- package/src/core/{eme → decrypt/utils}/server_certificate_store.ts +2 -2
- package/src/core/fetchers/manifest/manifest_fetcher.ts +9 -9
- package/src/core/fetchers/segment/segment_fetcher.ts +10 -7
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +2 -2
- package/src/core/fetchers/utils/try_urls_with_backoff.ts +1 -1
- package/src/core/init/.initialize_media_source.ts.un~ +0 -0
- package/src/core/init/get_initial_time.ts +2 -1
- package/src/core/init/initialize_directfile.ts +19 -22
- package/src/core/init/initialize_media_source.ts +43 -106
- package/src/core/init/link_drm_and_content.ts +176 -0
- package/src/core/init/manifest_update_scheduler.ts +12 -10
- package/src/core/init/stall_avoider.ts +6 -5
- package/src/core/init/stream_events_emitter/are_same_stream_events.ts +4 -4
- package/src/core/init/stream_events_emitter/stream_events_emitter.ts +2 -1
- package/src/core/init/stream_events_emitter/types.ts +2 -2
- package/src/core/init/types.ts +1 -39
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +2 -1
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +6 -7
- package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +32 -31
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +4 -4
- package/src/core/segment_buffers/inventory/segment_inventory.ts +42 -8
- package/src/core/stream/adaptation/adaptation_stream.ts +7 -1
- package/src/core/stream/events_generators.ts +9 -4
- package/src/core/stream/orchestrator/stream_orchestrator.ts +9 -4
- package/src/core/stream/period/create_empty_adaptation_stream.ts +2 -1
- package/src/core/stream/period/get_adaptation_switch_strategy.ts +1 -1
- package/src/core/stream/period/period_stream.ts +5 -2
- package/src/core/stream/representation/force_garbage_collection.ts +5 -7
- package/src/core/stream/representation/get_buffer_status.ts +28 -16
- package/src/core/stream/representation/get_needed_segments.ts +124 -28
- package/src/core/stream/representation/get_segment_priority.ts +1 -2
- package/src/core/stream/representation/push_media_segment.ts +3 -2
- package/src/core/stream/representation/representation_stream.ts +30 -7
- package/src/core/stream/types.ts +1 -1
- package/src/default_config.ts +1241 -0
- package/src/errors/request_error.ts +4 -1
- package/src/experimental/index.ts +5 -0
- package/src/experimental/tools/VideoThumbnailLoader/push_data.ts +1 -0
- package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +5 -7
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +3 -10
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +4 -4
- package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
- package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +3 -3
- package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +1 -2
- package/src/experimental/tools/mediaCapabilitiesProber/types.ts +3 -3
- package/src/features/__tests__/initialize_features.test.ts +2 -2
- package/src/features/features_object.ts +1 -1
- package/src/features/initialize_features.ts +1 -1
- package/src/features/list/__tests__/eme.test.ts +5 -5
- package/src/features/list/eme.ts +5 -5
- package/src/features/types.ts +3 -10
- package/src/manifest/adaptation.ts +6 -4
- package/src/manifest/manifest.ts +16 -86
- package/src/manifest/period.ts +3 -3
- package/src/manifest/representation.ts +38 -5
- package/src/manifest/representation_index/types.ts +18 -18
- package/src/manifest/types.ts +3 -3
- package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +1 -0
- package/src/parsers/manifest/dash/common/get_hdr_information.ts +1 -1
- package/src/parsers/manifest/dash/common/get_periods_time_infos.ts +3 -3
- package/src/parsers/manifest/dash/common/indexes/base.ts +6 -6
- package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +4 -2
- package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +2 -2
- package/src/parsers/manifest/dash/common/indexes/is_period_fulfilled.ts +1 -2
- package/src/parsers/manifest/dash/common/indexes/list.ts +14 -14
- package/src/parsers/manifest/dash/common/indexes/template.ts +18 -18
- package/src/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.ts +1 -1
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +51 -23
- package/src/parsers/manifest/dash/common/infer_adaptation_type.ts +2 -2
- package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +1 -1
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +167 -134
- package/src/parsers/manifest/dash/common/parse_mpd.ts +9 -10
- package/src/parsers/manifest/dash/common/parse_periods.ts +80 -79
- package/src/parsers/manifest/dash/common/parse_representation_index.ts +83 -75
- package/src/parsers/manifest/dash/common/parse_representations.ts +44 -63
- package/src/parsers/manifest/dash/node_parser_types.ts +30 -30
- package/src/parsers/manifest/dash/parsers_types.ts +3 -3
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -1
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +4 -4
- package/src/parsers/manifest/smooth/create_parser.ts +24 -21
- package/src/parsers/manifest/smooth/representation_index.ts +14 -14
- package/src/parsers/manifest/types.ts +28 -28
- package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +31 -33
- package/src/parsers/manifest/utils/clear_timeline_from_position.ts +15 -6
- package/src/parsers/manifest/utils/index_helpers.ts +2 -2
- package/src/parsers/manifest/utils/update_segment_timeline.ts +32 -21
- package/src/parsers/texttracks/webvtt/html/__tests__/create_styled_element.test.ts +1 -0
- package/src/parsers/texttracks/webvtt/html/to_html.ts +2 -2
- package/src/parsers/texttracks/webvtt/parse_cue_block.ts +1 -1
- package/src/public_types.ts +5 -1
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +2 -2
- package/src/transports/dash/image_pipelines.ts +4 -1
- package/src/transports/dash/init_segment_loader.ts +1 -1
- package/src/transports/dash/manifest_parser.ts +1 -1
- package/src/transports/dash/segment_loader.ts +7 -7
- package/src/transports/dash/segment_parser.ts +8 -1
- package/src/transports/dash/text_loader.ts +2 -2
- package/src/transports/dash/text_parser.ts +11 -1
- package/src/transports/local/segment_loader.ts +4 -4
- package/src/transports/local/segment_parser.ts +4 -0
- package/src/transports/local/text_parser.ts +8 -0
- package/src/transports/metaplaylist/manifest_loader.ts +1 -1
- package/src/transports/metaplaylist/pipelines.ts +1 -1
- package/src/transports/smooth/pipelines.ts +29 -16
- package/src/transports/smooth/segment_loader.ts +8 -8
- package/src/transports/types.ts +59 -30
- package/src/transports/utils/call_custom_manifest_loader.ts +6 -6
- package/src/transports/utils/generate_manifest_loader.ts +1 -1
- package/src/utils/__tests__/deep_merge.test.ts +48 -0
- package/src/utils/__tests__/flat_map.test.ts +12 -7
- package/src/utils/cancellable_sleep.ts +1 -1
- package/src/utils/cast_to_observable.ts +1 -2
- package/src/utils/deep_merge.ts +46 -0
- package/src/utils/reference.ts +116 -23
- package/src/utils/request/fetch.ts +17 -15
- package/src/utils/request/xhr.ts +11 -8
- package/src/utils/rx-from_cancellable_promise.ts +8 -4
- package/src/utils/task_canceller.ts +6 -4
- package/tsconfig.json +1 -2
- package/tsconfig.modules.json +1 -2
- package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.d.ts +0 -29
- package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.js +0 -67
- package/dist/_esm5.processed/core/eme/attach_media_keys.js +0 -57
- package/dist/_esm5.processed/core/eme/clean_old_loaded_sessions.d.ts +0 -59
- package/dist/_esm5.processed/core/eme/clear_eme_session.js +0 -50
- package/dist/_esm5.processed/core/eme/create_session.js +0 -126
- package/dist/_esm5.processed/core/eme/dispose_eme.js +0 -23
- package/dist/_esm5.processed/core/eme/dispose_media_keys.js +0 -36
- package/dist/_esm5.processed/core/eme/eme_manager.d.ts +0 -31
- package/dist/_esm5.processed/core/eme/eme_manager.js +0 -278
- package/dist/_esm5.processed/core/eme/find_key_system.js +0 -243
- package/dist/_esm5.processed/core/eme/get_media_keys.js +0 -85
- package/dist/_esm5.processed/core/eme/get_session.js +0 -68
- package/dist/_esm5.processed/core/eme/init_media_keys.js +0 -66
- package/dist/_esm5.processed/core/eme/session_events_listener.d.ts +0 -41
- package/dist/_esm5.processed/core/eme/set_server_certificate.js +0 -85
- package/dist/_esm5.processed/core/eme/utils/close_session.js +0 -81
- package/dist/_esm5.processed/core/eme/utils/init_data_store.d.ts +0 -115
- package/dist/_esm5.processed/core/eme/utils/init_data_store.js +0 -181
- package/dist/_esm5.processed/core/eme/utils/loaded_sessions_store.d.ts +0 -123
- package/dist/_esm5.processed/core/eme/utils/loaded_sessions_store.js +0 -173
- package/dist/_esm5.processed/core/init/create_eme_manager.d.ts +0 -34
- package/dist/_esm5.processed/core/init/create_eme_manager.js +0 -52
- package/src/core/abr/get_estimate_from_buffer_levels.ts +0 -85
- package/src/core/eme/README.md +0 -26
- package/src/core/eme/__tests__/__global__/get_license.test.ts +0 -414
- package/src/core/eme/__tests__/__global__/init_data.test.ts +0 -908
- package/src/core/eme/__tests__/__global__/media_keys.test.ts +0 -266
- package/src/core/eme/__tests__/__global__/server_certificate.test.ts +0 -364
- package/src/core/eme/__tests__/init_media_keys.test.ts +0 -182
- package/src/core/eme/clean_old_loaded_sessions.ts +0 -96
- package/src/core/eme/clear_eme_session.ts +0 -62
- package/src/core/eme/create_session.ts +0 -187
- package/src/core/eme/dispose_eme.ts +0 -25
- package/src/core/eme/dispose_media_keys.ts +0 -46
- package/src/core/eme/eme_manager.ts +0 -387
- package/src/core/eme/get_media_keys.ts +0 -141
- package/src/core/eme/get_session.ts +0 -135
- package/src/core/eme/init_media_keys.ts +0 -106
- package/src/core/eme/set_server_certificate.ts +0 -115
- package/src/core/eme/utils/close_session.ts +0 -113
- package/src/core/eme/utils/init_data_store.ts +0 -234
- package/src/core/eme/utils/loaded_sessions_store.ts +0 -235
- package/src/core/init/create_eme_manager.ts +0 -95
|
@@ -14,18 +14,19 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
ICustomMediaKeys,
|
|
19
|
-
ICustomMediaKeySession,
|
|
20
|
-
ICustomMediaKeySystemAccess,
|
|
21
|
-
} from "../../compat";
|
|
17
|
+
import { ICustomMediaKeySession } from "../../compat";
|
|
22
18
|
import { ICustomError } from "../../errors";
|
|
23
|
-
import {
|
|
19
|
+
import Manifest, {
|
|
20
|
+
Adaptation,
|
|
21
|
+
Period,
|
|
22
|
+
Representation,
|
|
23
|
+
} from "../../manifest";
|
|
24
|
+
import InitDataValuesContainer from "./utils/init_data_values_container";
|
|
24
25
|
import LoadedSessionsStore from "./utils/loaded_sessions_store";
|
|
25
26
|
import PersistentSessionsStore from "./utils/persistent_sessions_store";
|
|
26
27
|
|
|
27
28
|
/** Information about the encryption initialization data. */
|
|
28
|
-
export interface
|
|
29
|
+
export interface IProtectionData {
|
|
29
30
|
/**
|
|
30
31
|
* The initialization data type - or the format of the `data` attribute (e.g.
|
|
31
32
|
* "cenc").
|
|
@@ -40,249 +41,51 @@ export interface IInitializationDataInfo {
|
|
|
40
41
|
* `undefined` when not known (different from an empty array - which would
|
|
41
42
|
* just mean that there's no key id involved).
|
|
42
43
|
*/
|
|
43
|
-
keyIds? : Uint8Array[];
|
|
44
|
+
keyIds? : Uint8Array[] | undefined;
|
|
45
|
+
/** The content linked to that segment protection data. */
|
|
46
|
+
content? : IContent;
|
|
44
47
|
/** Every initialization data for that type. */
|
|
45
|
-
values:
|
|
46
|
-
/**
|
|
47
|
-
* Hex encoded system id, which identifies the key system.
|
|
48
|
-
* https://dashif.org/identifiers/content_protection/
|
|
49
|
-
*
|
|
50
|
-
* If `undefined`, we don't know the system id for that initialization data.
|
|
51
|
-
* In that case, the initialization data might even be a concatenation of
|
|
52
|
-
* the initialization data from multiple system ids.
|
|
53
|
-
*/
|
|
54
|
-
systemId: string | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* The initialization data itself for that type and systemId.
|
|
57
|
-
* For example, with "cenc" initialization data found in an ISOBMFF file,
|
|
58
|
-
* this will be the whole PSSH box.
|
|
59
|
-
*/
|
|
60
|
-
data: Uint8Array;
|
|
61
|
-
}>;
|
|
48
|
+
values: IInitDataValue[];
|
|
62
49
|
}
|
|
63
50
|
|
|
64
|
-
/**
|
|
65
|
-
export interface
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Event emitted when we receive an "encrypted" event from the browser.
|
|
70
|
-
* This is usually sent when pushing an initialization segment, if it stores
|
|
71
|
-
* encryption information.
|
|
72
|
-
*/
|
|
73
|
-
export interface IEncryptedEvent { type: "encrypted-event-received";
|
|
74
|
-
value: IInitializationDataInfo; }
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Sent when a MediaKeys has been created (or is already created) for the
|
|
78
|
-
* current content.
|
|
79
|
-
* This is necessary before creating a MediaKeySession which will allow
|
|
80
|
-
* encryption keys to be communicated.
|
|
81
|
-
*
|
|
82
|
-
* It carries a shared reference (`canAttachMediaKeys`) that should be setted to
|
|
83
|
-
* `true` to indicate that RxPlayer's EME logic can start to attach the
|
|
84
|
-
* `MediaKeys` instance to the HTMLMediaElement.
|
|
85
|
-
*/
|
|
86
|
-
export interface ICreatedMediaKeysEvent {
|
|
87
|
-
type: "created-media-keys";
|
|
88
|
-
value: {
|
|
89
|
-
/** The MediaKeySystemAccess which allowed to create the MediaKeys instance. */
|
|
90
|
-
mediaKeySystemAccess: MediaKeySystemAccess |
|
|
91
|
-
ICustomMediaKeySystemAccess;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Hex-encoded identifier for the key system used.
|
|
95
|
-
* A list of available IDs can be found here:
|
|
96
|
-
* https://dashif.org/identifiers/content_protection/
|
|
97
|
-
*
|
|
98
|
-
* This ID can be used to select the encryption initialization data to send
|
|
99
|
-
* to the EMEManager.
|
|
100
|
-
*
|
|
101
|
-
* Note that this is only for optimization purposes (e.g. to not
|
|
102
|
-
* unnecessarily wait for new encryption initialization data to arrive when
|
|
103
|
-
* those linked to the right key system is already available) as sending all
|
|
104
|
-
* available encryption initialization data should also work in all cases.
|
|
105
|
-
*
|
|
106
|
-
* Can be `undefined` in two cases:
|
|
107
|
-
*
|
|
108
|
-
* - the current system ID is not known
|
|
109
|
-
*
|
|
110
|
-
* - the current system ID is known, but we don't want to communicate it
|
|
111
|
-
* to ensure all encryption initialization data is still sent.
|
|
112
|
-
* This is usually done to work-around retro-compatibility issues with
|
|
113
|
-
* older persisted decryption session.
|
|
114
|
-
*/
|
|
115
|
-
initializationDataSystemId : string | undefined;
|
|
116
|
-
|
|
117
|
-
/** The MediaKeys instance. */
|
|
118
|
-
mediaKeys : MediaKeys |
|
|
119
|
-
ICustomMediaKeys;
|
|
120
|
-
|
|
121
|
-
/** Stores allowing to cache MediaKeySession instances. */
|
|
122
|
-
stores : IMediaKeySessionStores;
|
|
123
|
-
|
|
124
|
-
/** key system options considered. */
|
|
125
|
-
options : IKeySystemOption;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Shared reference that should be set to `true` once the `MediaKeys`
|
|
129
|
-
* instance can be attached to the HTMLMediaElement.
|
|
130
|
-
*/
|
|
131
|
-
canAttachMediaKeys: ISharedReference<boolean>;
|
|
132
|
-
};
|
|
51
|
+
/** Protection initialization data actually processed by the `ContentDecryptor`. */
|
|
52
|
+
export interface IProcessedProtectionData extends Omit<IProtectionData, "values"> {
|
|
53
|
+
values: InitDataValuesContainer;
|
|
133
54
|
}
|
|
134
55
|
|
|
135
56
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* On some peculiar devices, we have to wait for that step before the first
|
|
139
|
-
* media segments are to be pushed to avoid issues.
|
|
140
|
-
* Because this event is sent after a MediaKeys is created, you will always have
|
|
141
|
-
* a "created-media-keys" event before an "attached-media-keys" event.
|
|
57
|
+
* Represent the initialization data linked to a key system that can be used to
|
|
58
|
+
* generate the license request.
|
|
142
59
|
*/
|
|
143
|
-
export interface
|
|
144
|
-
type: "attached-media-keys";
|
|
145
|
-
value: {
|
|
146
|
-
/** The MediaKeySystemAccess which allowed to create the MediaKeys instance. */
|
|
147
|
-
mediaKeySystemAccess: MediaKeySystemAccess |
|
|
148
|
-
ICustomMediaKeySystemAccess;
|
|
149
|
-
/** The MediaKeys instance. */
|
|
150
|
-
mediaKeys : MediaKeys |
|
|
151
|
-
ICustomMediaKeys;
|
|
152
|
-
stores : IMediaKeySessionStores;
|
|
153
|
-
options : IKeySystemOption;
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Emitted when the initialization data received through an encrypted event or
|
|
159
|
-
* through the EMEManager argument can already be decipherable without going
|
|
160
|
-
* through the usual license-fetching logic.
|
|
161
|
-
* This is usually because the MediaKeySession for this encryption key has
|
|
162
|
-
* already been created.
|
|
163
|
-
*/
|
|
164
|
-
export interface IInitDataIgnoredEvent {
|
|
165
|
-
type: "init-data-ignored";
|
|
166
|
-
value : { initializationData : IInitializationDataInfo };
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Emitted when a "message" event is sent.
|
|
171
|
-
* Those events generally allows the CDM to ask for data such as the license or
|
|
172
|
-
* a server certificate.
|
|
173
|
-
* As such, we will call the corresponding `getLicense` callback immediately
|
|
174
|
-
* after this event is sent.
|
|
175
|
-
*
|
|
176
|
-
* Depending on the return of the getLicense call, we will then either emit a
|
|
177
|
-
* "warning" event and retry the call (for when it failed but will be retried),
|
|
178
|
-
* throw (when it failed with no retry left and no fallback policy is set), emit
|
|
179
|
-
* a "blacklist-protection-data-event" (for when it failed with no retry left
|
|
180
|
-
* but a fallback policy is set), emit a "session-updated" event (for when the
|
|
181
|
-
* call resolved with some data) or emit a "no-update" event (for when the call
|
|
182
|
-
* resolved with `null`).
|
|
183
|
-
*/
|
|
184
|
-
export interface ISessionMessageEvent {
|
|
185
|
-
type: "session-message";
|
|
186
|
-
value : { messageType : string;
|
|
187
|
-
initializationData : IInitializationDataInfo; };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Emitted when a `getLicense` call resolves with null.
|
|
192
|
-
* In that case, we do not call `MediaKeySession.prototype.update` and no
|
|
193
|
-
* `session-updated` event will be sent.
|
|
194
|
-
*/
|
|
195
|
-
export interface INoUpdateEvent {
|
|
196
|
-
type : "no-update";
|
|
197
|
-
value : { initializationData: IInitializationDataInfo };
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Some key ids have updated their status.
|
|
202
|
-
*
|
|
203
|
-
* We put them in two different list:
|
|
204
|
-
*
|
|
205
|
-
* - `blacklistedKeyIDs`: Those key ids won't be used for decryption and the
|
|
206
|
-
* corresponding media it decrypts should not be pushed to the buffer
|
|
207
|
-
* Note that a blacklisted key id can become whitelisted in the future.
|
|
208
|
-
*
|
|
209
|
-
* - `whitelistedKeyIds`: Those key ids were found and their corresponding
|
|
210
|
-
* keys are now being considered for decryption.
|
|
211
|
-
* Note that a whitelisted key id can become blacklisted in the future.
|
|
212
|
-
*
|
|
213
|
-
* Note that each `IKeysUpdateEvent` is independent of any other.
|
|
214
|
-
*
|
|
215
|
-
* A new `IKeysUpdateEvent` does not completely replace a previously emitted
|
|
216
|
-
* one, as it can for example be linked to a whole other decryption session.
|
|
217
|
-
*
|
|
218
|
-
* However, if a key id is encountered in both an older and a newer
|
|
219
|
-
* `IKeysUpdateEvent`, only the older status should be considered.
|
|
220
|
-
*/
|
|
221
|
-
export interface IKeysUpdateEvent {
|
|
222
|
-
type: "keys-update";
|
|
223
|
-
value: IKeyUpdateValue;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** Information on key ids linked to a MediaKeySession. */
|
|
227
|
-
export interface IKeyUpdateValue {
|
|
60
|
+
export interface IInitDataValue {
|
|
228
61
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* the fact that they were part of the pushed license.
|
|
62
|
+
* Hex encoded system id, which identifies the key system.
|
|
63
|
+
* https://dashif.org/identifiers/content_protection/
|
|
232
64
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
65
|
+
* If `undefined`, we don't know the system id for that initialization data.
|
|
66
|
+
* In that case, the initialization data might even be a concatenation of
|
|
67
|
+
* the initialization data from multiple system ids.
|
|
235
68
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
* The
|
|
239
|
-
*
|
|
240
|
-
*
|
|
69
|
+
systemId: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The initialization data itself for that type and systemId.
|
|
72
|
+
* For example, with "cenc" initialization data found in an ISOBMFF file,
|
|
73
|
+
* this will be the whole PSSH box.
|
|
241
74
|
*/
|
|
242
|
-
|
|
75
|
+
data: Uint8Array;
|
|
243
76
|
}
|
|
244
77
|
|
|
245
|
-
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
* different than `null`.
|
|
249
|
-
*/
|
|
250
|
-
export interface ISessionUpdatedEvent {
|
|
251
|
-
type: "session-updated";
|
|
252
|
-
value: { session: MediaKeySession |
|
|
253
|
-
ICustomMediaKeySession;
|
|
254
|
-
license: ILicense |
|
|
255
|
-
null;
|
|
256
|
-
initializationData : IInitializationDataInfo; };
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Event Emitted when specific "protection data" cannot be deciphered and is thus
|
|
261
|
-
* blacklisted.
|
|
262
|
-
*
|
|
263
|
-
* The linked value is the initialization data linked to the content that cannot
|
|
264
|
-
* be deciphered.
|
|
265
|
-
*/
|
|
266
|
-
export interface IBlacklistProtectionDataEvent { type: "blacklist-protection-data";
|
|
267
|
-
value: IInitializationDataInfo; }
|
|
268
|
-
|
|
269
|
-
// Every event sent by the EMEManager
|
|
270
|
-
export type IEMEManagerEvent = IEMEWarningEvent | // minor error
|
|
271
|
-
IEncryptedEvent | // browser's "encrypted" event
|
|
272
|
-
ICreatedMediaKeysEvent |
|
|
273
|
-
IAttachedMediaKeysEvent |
|
|
274
|
-
IInitDataIgnoredEvent | // initData already handled
|
|
275
|
-
ISessionMessageEvent | // MediaKeySession event
|
|
276
|
-
INoUpdateEvent | // `getLicense` returned `null`
|
|
277
|
-
IKeysUpdateEvent | // Status of keys changed
|
|
278
|
-
ISessionUpdatedEvent | // `update` call resolved
|
|
279
|
-
IBlacklistProtectionDataEvent; // initData undecipherable
|
|
78
|
+
/** Event emitted when a minor - recoverable - error happened. */
|
|
79
|
+
export interface IEMEWarningEvent { type : "warning";
|
|
80
|
+
value : ICustomError; }
|
|
280
81
|
|
|
281
82
|
export type ILicense = BufferSource |
|
|
282
83
|
ArrayBuffer;
|
|
283
84
|
|
|
284
|
-
/** Segment protection sent by the RxPlayer to the
|
|
85
|
+
/** Segment protection sent by the RxPlayer to the `ContentDecryptor`. */
|
|
285
86
|
export interface IContentProtection {
|
|
87
|
+
/** The content linked to that segment protection data. */
|
|
88
|
+
content : IContent;
|
|
286
89
|
/**
|
|
287
90
|
* Initialization data type.
|
|
288
91
|
* String describing the format of the initialization data sent through this
|
|
@@ -298,7 +101,7 @@ export interface IContentProtection {
|
|
|
298
101
|
* `undefined` when not known (different from an empty array - which would
|
|
299
102
|
* just mean that there's no key id involved).
|
|
300
103
|
*/
|
|
301
|
-
keyIds
|
|
104
|
+
keyIds : Uint8Array[] | undefined;
|
|
302
105
|
/** Every initialization data for that type. */
|
|
303
106
|
values: Array<{
|
|
304
107
|
/**
|
|
@@ -315,23 +118,16 @@ export interface IContentProtection {
|
|
|
315
118
|
}>;
|
|
316
119
|
}
|
|
317
120
|
|
|
318
|
-
|
|
319
|
-
export interface
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
license: ILicense|null; }; }
|
|
329
|
-
|
|
330
|
-
// Infos indentifying a MediaKeySystemAccess
|
|
331
|
-
export interface IKeySystemAccessInfos {
|
|
332
|
-
keySystemAccess: MediaKeySystemAccess |
|
|
333
|
-
ICustomMediaKeySystemAccess;
|
|
334
|
-
keySystemOptions: IKeySystemOption;
|
|
121
|
+
/** Content linked to protection data. */
|
|
122
|
+
export interface IContent {
|
|
123
|
+
/** Manifest object associated to the protection data. */
|
|
124
|
+
manifest : Manifest;
|
|
125
|
+
/** Period object associated to the protection data. */
|
|
126
|
+
period : Period;
|
|
127
|
+
/** Adaptation object associated to the protection data. */
|
|
128
|
+
adaptation : Adaptation;
|
|
129
|
+
/** Representation object associated to the protection data. */
|
|
130
|
+
representation : Representation;
|
|
335
131
|
}
|
|
336
132
|
|
|
337
133
|
/** Stores helping to create and retrieve MediaKeySessions. */
|
|
@@ -343,19 +139,46 @@ export interface IMediaKeySessionStores {
|
|
|
343
139
|
null;
|
|
344
140
|
}
|
|
345
141
|
|
|
142
|
+
/** Enum identifying the way a new MediaKeySession has been loaded. */
|
|
143
|
+
export const enum MediaKeySessionLoadingType {
|
|
144
|
+
/**
|
|
145
|
+
* This MediaKeySession has just been created.
|
|
146
|
+
* This means that it will necessitate a new license request to be generated
|
|
147
|
+
* and performed.
|
|
148
|
+
*/
|
|
149
|
+
Created = "created-session",
|
|
150
|
+
/**
|
|
151
|
+
* This MediaKeySession was an already-opened one that is being reused.
|
|
152
|
+
* Such session had already their license loaded and pushed.
|
|
153
|
+
*/
|
|
154
|
+
LoadedOpenSession = "loaded-open-session",
|
|
155
|
+
/**
|
|
156
|
+
* This MediaKeySession was a persistent MediaKeySession that has been
|
|
157
|
+
* re-loaded.
|
|
158
|
+
* Such session are linked to a persistent license which should have already
|
|
159
|
+
* been fetched.
|
|
160
|
+
*/
|
|
161
|
+
LoadedPersistentSession = "loaded-persistent-session",
|
|
162
|
+
}
|
|
163
|
+
|
|
346
164
|
/**
|
|
347
165
|
* Data stored in a persistent MediaKeySession storage.
|
|
348
166
|
* Has to be versioned to be able to play MediaKeySessions persisted in an old
|
|
349
167
|
* RxPlayer version when in a new one.
|
|
350
168
|
*/
|
|
351
|
-
export type IPersistentSessionInfo =
|
|
169
|
+
export type IPersistentSessionInfo = IPersistentSessionInfoV4 |
|
|
170
|
+
IPersistentSessionInfoV3 |
|
|
352
171
|
IPersistentSessionInfoV2 |
|
|
353
172
|
IPersistentSessionInfoV1 |
|
|
354
173
|
IPersistentSessionInfoV0;
|
|
355
174
|
|
|
356
|
-
/** Wrap
|
|
357
|
-
interface
|
|
358
|
-
/**
|
|
175
|
+
/** Wrap an Uint8Array and allow serialization of it into base64. */
|
|
176
|
+
interface ByteArrayContainer {
|
|
177
|
+
/**
|
|
178
|
+
* The wrapped data.
|
|
179
|
+
* Here named `initData` even when it's not always initialization data for
|
|
180
|
+
* backward-compatible reasons.
|
|
181
|
+
*/
|
|
359
182
|
initData : Uint8Array;
|
|
360
183
|
|
|
361
184
|
/**
|
|
@@ -369,7 +192,53 @@ interface IInitDataContainer {
|
|
|
369
192
|
|
|
370
193
|
/**
|
|
371
194
|
* Stored information about a single persistent `MediaKeySession`, when created
|
|
372
|
-
* since the v3.
|
|
195
|
+
* since the v3.27.0 RxPlayer version included.
|
|
196
|
+
*/
|
|
197
|
+
export interface IPersistentSessionInfoV4 {
|
|
198
|
+
/** Version for this object. */
|
|
199
|
+
version : 4;
|
|
200
|
+
|
|
201
|
+
/** The persisted MediaKeySession's `id`. Used to load it at a later time. */
|
|
202
|
+
sessionId : string;
|
|
203
|
+
|
|
204
|
+
/** Type giving information about the format of the initialization data. */
|
|
205
|
+
initDataType : string | undefined;
|
|
206
|
+
|
|
207
|
+
/** All key ids linked to that `MediaKeySession`. */
|
|
208
|
+
keyIds: Array<ByteArrayContainer | string>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Every saved initialization data for that session, used as IDs.
|
|
212
|
+
* Elements are sorted in systemId alphabetical order (putting the `undefined`
|
|
213
|
+
* ones last).
|
|
214
|
+
*/
|
|
215
|
+
values: Array<{
|
|
216
|
+
/**
|
|
217
|
+
* Hex encoded system id, which identifies the key system.
|
|
218
|
+
* https://dashif.org/identifiers/content_protection/
|
|
219
|
+
*
|
|
220
|
+
* If `undefined`, we don't know the system id for that initialization data.
|
|
221
|
+
* In that case, the initialization data might even be a concatenation of
|
|
222
|
+
* the initialization data from multiple system ids.
|
|
223
|
+
*/
|
|
224
|
+
systemId : string | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* A hash of the initialization data (generated by the `hashBuffer` function,
|
|
227
|
+
* at the time of v3.20.1 at least). Allows for a faster comparison than just
|
|
228
|
+
* comparing initialization data multiple times.
|
|
229
|
+
*/
|
|
230
|
+
hash : number;
|
|
231
|
+
/**
|
|
232
|
+
* The initialization data associated to the systemId, wrapped in a
|
|
233
|
+
* container to allow efficient serialization.
|
|
234
|
+
*/
|
|
235
|
+
data : ByteArrayContainer | string;
|
|
236
|
+
}>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Stored information about a single persistent `MediaKeySession`, when created
|
|
241
|
+
* from the v3.24.0 RxPlayer version included to the v3.26.2 included.
|
|
373
242
|
*/
|
|
374
243
|
export interface IPersistentSessionInfoV3 {
|
|
375
244
|
/** Version for this object. */
|
|
@@ -406,14 +275,14 @@ export interface IPersistentSessionInfoV3 {
|
|
|
406
275
|
* The initialization data associated to the systemId, wrapped in a
|
|
407
276
|
* container to allow efficient serialization.
|
|
408
277
|
*/
|
|
409
|
-
data :
|
|
278
|
+
data : ByteArrayContainer | string;
|
|
410
279
|
}>;
|
|
411
280
|
}
|
|
412
281
|
|
|
413
282
|
/**
|
|
414
283
|
* Stored information about a single persistent `MediaKeySession`, when created
|
|
415
284
|
* between the RxPlayer versions v3.21.0 and v3.21.1 included.
|
|
416
|
-
* The previous implementation (version 1) was fine enough but did not
|
|
285
|
+
* The previous implementation (version 1) was fine enough but did not serialize
|
|
417
286
|
* well due to it containing an Uint8Array. This data is now wrapped into a
|
|
418
287
|
* container which will convert it to base64 when linearized through
|
|
419
288
|
* `JSON.stringify`.
|
|
@@ -427,7 +296,7 @@ export interface IPersistentSessionInfoV2 {
|
|
|
427
296
|
* The initialization data associated to the `MediaKeySession`, wrapped in a
|
|
428
297
|
* container to allow efficient linearization.
|
|
429
298
|
*/
|
|
430
|
-
initData :
|
|
299
|
+
initData : ByteArrayContainer;
|
|
431
300
|
/**
|
|
432
301
|
* A hash of the initialization data (generated by the `hashBuffer` function,
|
|
433
302
|
* at the time of v3.20.1 at least). Allows for a faster comparison than just
|
|
@@ -485,7 +354,7 @@ export interface IPersistentSessionInfoV0 {
|
|
|
485
354
|
/** Persistent MediaKeySession storage interface. */
|
|
486
355
|
export interface IPersistentSessionStorage {
|
|
487
356
|
/** Load persistent MediaKeySessions previously saved through the `save` callback. */
|
|
488
|
-
load() : IPersistentSessionInfo[];
|
|
357
|
+
load() : IPersistentSessionInfo[] | undefined | null;
|
|
489
358
|
/**
|
|
490
359
|
* Save new persistent MediaKeySession information.
|
|
491
360
|
* The given argument should be returned by the next `load` call.
|
|
@@ -553,6 +422,7 @@ export interface IKeySystemOption {
|
|
|
553
422
|
closeSessionsOnStop? : boolean;
|
|
554
423
|
|
|
555
424
|
singleLicensePer? : "content" |
|
|
425
|
+
"periods" |
|
|
556
426
|
"init-data";
|
|
557
427
|
/**
|
|
558
428
|
* Maximum number of `MediaKeySession` that should be created on the same
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import areInitializationValuesCompatible from "../are_init_values_compatible";
|
|
18
18
|
|
|
19
|
-
describe("
|
|
19
|
+
describe("decrypt - utils - areInitializationValuesCompatible", () => {
|
|
20
20
|
it("should return false if either initialization data is empty", () => {
|
|
21
21
|
const test1 = areInitializationValuesCompatible([], []);
|
|
22
22
|
const test2 = areInitializationValuesCompatible(
|
|
@@ -21,24 +21,23 @@
|
|
|
21
21
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
22
22
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
23
23
|
|
|
24
|
-
import { timer } from "rxjs";
|
|
25
24
|
import cleanOldLoadedSessions from "../clean_old_loaded_sessions";
|
|
26
|
-
import LoadedSessionsStore from "../
|
|
25
|
+
import LoadedSessionsStore from "../loaded_sessions_store";
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
const entry1 = { initializationData: { data: new Uint8Array([1, 6, 9]),
|
|
30
29
|
type: "test" },
|
|
31
|
-
mediaKeySession: {},
|
|
30
|
+
mediaKeySession: { sessionId: "toto" },
|
|
32
31
|
sessionType: "" };
|
|
33
32
|
|
|
34
33
|
const entry2 = { initializationData: { data: new Uint8Array([4, 8]),
|
|
35
34
|
type: "foo" },
|
|
36
|
-
mediaKeySession: {},
|
|
35
|
+
mediaKeySession: { sessionId: "titi" },
|
|
37
36
|
sessionType: "" };
|
|
38
37
|
|
|
39
38
|
const entry3 = { initializationData: { data: new Uint8Array([7, 3, 121, 87]),
|
|
40
39
|
type: "bar" },
|
|
41
|
-
mediaKeySession: {},
|
|
40
|
+
mediaKeySession: { sessionId: "tutu" },
|
|
42
41
|
sessionType: "" };
|
|
43
42
|
|
|
44
43
|
function createLoadedSessionsStore() : LoadedSessionsStore {
|
|
@@ -50,7 +49,9 @@ function createLoadedSessionsStore() : LoadedSessionsStore {
|
|
|
50
49
|
return [entry1, entry2, entry3];
|
|
51
50
|
},
|
|
52
51
|
closeSession() {
|
|
53
|
-
return
|
|
52
|
+
return new Promise((res) => {
|
|
53
|
+
setTimeout(res, Math.random() * 50);
|
|
54
|
+
});
|
|
54
55
|
},
|
|
55
56
|
} as unknown as LoadedSessionsStore;
|
|
56
57
|
}
|
|
@@ -72,82 +73,45 @@ const emptyLoadedSessionsStore = {
|
|
|
72
73
|
* @param {number} limit
|
|
73
74
|
* @param {Function} done
|
|
74
75
|
*/
|
|
75
|
-
function checkNothingHappen(
|
|
76
|
+
async function checkNothingHappen(
|
|
76
77
|
loadedSessionsStore : LoadedSessionsStore,
|
|
77
78
|
limit : number
|
|
78
79
|
) : Promise<void> {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
cleanOldLoadedSessions(loadedSessionsStore, limit).subscribe({
|
|
84
|
-
next: () => { itemNb++; },
|
|
85
|
-
error: () => { rej(new Error("The Observable should not throw")); },
|
|
86
|
-
complete: () => {
|
|
87
|
-
expect(itemNb).toEqual(0);
|
|
88
|
-
expect(closeSessionSpy).not.toHaveBeenCalled();
|
|
89
|
-
closeSessionSpy.mockRestore();
|
|
90
|
-
res();
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
});
|
|
80
|
+
const closeSessionSpy = jest.spyOn(loadedSessionsStore, "closeSession");
|
|
81
|
+
await cleanOldLoadedSessions(loadedSessionsStore, limit);
|
|
82
|
+
expect(closeSessionSpy).not.toHaveBeenCalled();
|
|
83
|
+
closeSessionSpy.mockRestore();
|
|
94
84
|
}
|
|
95
85
|
|
|
96
86
|
/**
|
|
97
87
|
* Call `cleanOldLoadedSessions` with the given loadedSessionsStore, limit and
|
|
98
88
|
* entries and make sure that:
|
|
99
89
|
* - closeSession is called on the specific entries a single time
|
|
100
|
-
* - all right events are received in the right order each a single time
|
|
101
90
|
* - it completes without an error
|
|
102
91
|
* Call `done` when done.
|
|
103
92
|
* @param {Object} loadedSessionsStore
|
|
104
93
|
* @param {number} limit
|
|
105
94
|
* @param {Array.<Object>} entries
|
|
106
|
-
* @param {Function} done
|
|
107
95
|
*/
|
|
108
|
-
function checkEntriesCleaned(
|
|
96
|
+
async function checkEntriesCleaned(
|
|
109
97
|
loadedSessionsStore : LoadedSessionsStore,
|
|
110
98
|
limit : number,
|
|
111
|
-
entries : Array<{
|
|
112
|
-
|
|
113
|
-
) {
|
|
99
|
+
entries : Array<{ sessionId: string }>
|
|
100
|
+
) : Promise<void> {
|
|
114
101
|
const closeSessionSpy = jest.spyOn(loadedSessionsStore, "closeSession");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
next: (evt) => {
|
|
119
|
-
if (evt.type === "cleaning-old-session") {
|
|
120
|
-
pendingEntries.push(evt.value);
|
|
121
|
-
}
|
|
122
|
-
itemNb++;
|
|
123
|
-
if (itemNb <= entries.length) {
|
|
124
|
-
expect(evt).toEqual({ type: "cleaning-old-session",
|
|
125
|
-
value: entries[itemNb - 1] });
|
|
126
|
-
} else if (itemNb > entries.length * 2) {
|
|
127
|
-
throw new Error("Too many received items: " + String(itemNb));
|
|
128
|
-
} else {
|
|
129
|
-
expect(evt.type).toEqual("cleaned-old-session");
|
|
130
|
-
expect(pendingEntries).not.toHaveLength(0);
|
|
131
|
-
expect(pendingEntries).toContainEqual(evt.value);
|
|
132
|
-
pendingEntries.splice(pendingEntries.indexOf(evt.value), 1);
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
error: () => { throw new Error("The Observable should not throw"); },
|
|
136
|
-
complete: () => {
|
|
137
|
-
expect(pendingEntries).toEqual([]);
|
|
138
|
-
expect(itemNb).toEqual(entries.length * 2);
|
|
139
|
-
done();
|
|
140
|
-
},
|
|
102
|
+
const prom = cleanOldLoadedSessions(loadedSessionsStore, limit).then(() => {
|
|
103
|
+
expect(closeSessionSpy).toHaveBeenCalledTimes(entries.length);
|
|
104
|
+
closeSessionSpy.mockRestore();
|
|
141
105
|
});
|
|
142
106
|
expect(closeSessionSpy).toHaveBeenCalledTimes(entries.length);
|
|
143
107
|
for (let i = 0; i < entries.length; i++) {
|
|
144
108
|
expect(closeSessionSpy)
|
|
145
|
-
.toHaveBeenNthCalledWith(i + 1, entries[i]
|
|
109
|
+
.toHaveBeenNthCalledWith(i + 1, entries[i]);
|
|
146
110
|
}
|
|
147
|
-
|
|
111
|
+
return prom;
|
|
148
112
|
}
|
|
149
113
|
|
|
150
|
-
describe("core -
|
|
114
|
+
describe("core - decrypt - cleanOldLoadedSessions", () => {
|
|
151
115
|
it("should do nothing with a negative limit", async () => {
|
|
152
116
|
await checkNothingHappen(createLoadedSessionsStore(), -1);
|
|
153
117
|
await checkNothingHappen(createLoadedSessionsStore(), -20);
|
|
@@ -181,21 +145,15 @@ describe("core - eme - cleanOldLoadedSessions", () => {
|
|
|
181
145
|
await checkNothingHappen(emptyLoadedSessionsStore, 0);
|
|
182
146
|
});
|
|
183
147
|
|
|
184
|
-
it("should remove some if the limit is inferior to the current length", (
|
|
185
|
-
checkEntriesCleaned(createLoadedSessionsStore(),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
done);
|
|
189
|
-
checkEntriesCleaned(createLoadedSessionsStore(),
|
|
190
|
-
2,
|
|
191
|
-
[ entry1 ],
|
|
192
|
-
done);
|
|
148
|
+
it("should remove some if the limit is inferior to the current length", async () => {
|
|
149
|
+
await checkEntriesCleaned(createLoadedSessionsStore(), 1, [ entry1.mediaKeySession,
|
|
150
|
+
entry2.mediaKeySession ]);
|
|
151
|
+
await checkEntriesCleaned(createLoadedSessionsStore(), 2, [ entry1.mediaKeySession ]);
|
|
193
152
|
});
|
|
194
153
|
|
|
195
|
-
it("should remove all if the limit is equal to 0", (
|
|
196
|
-
checkEntriesCleaned(createLoadedSessionsStore(),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
done);
|
|
154
|
+
it("should remove all if the limit is equal to 0", async () => {
|
|
155
|
+
await checkEntriesCleaned(createLoadedSessionsStore(), 0, [ entry1.mediaKeySession,
|
|
156
|
+
entry2.mediaKeySession,
|
|
157
|
+
entry3.mediaKeySession ]);
|
|
200
158
|
});
|
|
201
159
|
});
|