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
|
@@ -47,7 +47,6 @@ import constructTimelineFromElements from "./construct_timeline_from_elements";
|
|
|
47
47
|
// eslint-disable-next-line max-len
|
|
48
48
|
import constructTimelineFromPreviousTimeline from "./construct_timeline_from_previous_timeline";
|
|
49
49
|
|
|
50
|
-
const { MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY } = config;
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
52
|
* Index property defined for a SegmentTimeline RepresentationIndex
|
|
@@ -58,7 +57,7 @@ export interface ITimelineIndex {
|
|
|
58
57
|
/** If `false`, the last segment anounced might be still incomplete. */
|
|
59
58
|
availabilityTimeComplete : boolean;
|
|
60
59
|
/** Byte range for a possible index of segments in the server. */
|
|
61
|
-
indexRange?: [number, number];
|
|
60
|
+
indexRange?: [number, number] | undefined;
|
|
62
61
|
/**
|
|
63
62
|
* Temporal offset, in the current timescale (see timescale), to add to the
|
|
64
63
|
* presentation time (time a segment has at decoding time) to obtain the
|
|
@@ -77,15 +76,15 @@ export interface ITimelineIndex {
|
|
|
77
76
|
/** URLs to access the initialization segment. */
|
|
78
77
|
mediaURLs: string[] | null;
|
|
79
78
|
/** possible byte range to request it. */
|
|
80
|
-
range?: [number, number];
|
|
81
|
-
};
|
|
79
|
+
range?: [number, number] | undefined;
|
|
80
|
+
} | undefined;
|
|
82
81
|
/**
|
|
83
82
|
* Base URL(s) to access any segment. Can contain tokens to replace to convert
|
|
84
83
|
* it to real URLs.
|
|
85
84
|
*/
|
|
86
85
|
mediaURLs : string[] | null ;
|
|
87
86
|
/** Number from which the first segments in this index starts with. */
|
|
88
|
-
startNumber? : number;
|
|
87
|
+
startNumber? : number | undefined;
|
|
89
88
|
/**
|
|
90
89
|
* Every segments defined in this index.
|
|
91
90
|
* `null` at the beginning as this property is parsed lazily (only when first
|
|
@@ -117,11 +116,13 @@ export interface ITimelineIndex {
|
|
|
117
116
|
* Most of the properties here are already defined in ITimelineIndex.
|
|
118
117
|
*/
|
|
119
118
|
export interface ITimelineIndexIndexArgument {
|
|
120
|
-
indexRange?: [number, number];
|
|
121
|
-
initialization? : { media? : string
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
indexRange?: [number, number] | undefined;
|
|
120
|
+
initialization? : { media? : string | undefined;
|
|
121
|
+
range?: [number, number] | undefined; } |
|
|
122
|
+
undefined;
|
|
123
|
+
media? : string | undefined;
|
|
124
|
+
startNumber? : number | undefined;
|
|
125
|
+
timescale? : number | undefined;
|
|
125
126
|
/**
|
|
126
127
|
* Offset present in the index to convert from the mediaTime (time declared in
|
|
127
128
|
* the media segments and in this index) to the presentationTime (time wanted
|
|
@@ -136,10 +137,10 @@ export interface ITimelineIndexIndexArgument {
|
|
|
136
137
|
* The time given here is in the current
|
|
137
138
|
* timescale (see timescale)
|
|
138
139
|
*/
|
|
139
|
-
presentationTimeOffset? : number;
|
|
140
|
+
presentationTimeOffset? : number | undefined;
|
|
140
141
|
|
|
141
|
-
timelineParser? : () => HTMLCollection;
|
|
142
|
-
timeline? : ISegmentTimelineElement[];
|
|
142
|
+
timelineParser? : (() => HTMLCollection) | undefined;
|
|
143
|
+
timeline? : ISegmentTimelineElement[] | undefined;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/** Aditional context needed by a SegmentTimeline RepresentationIndex. */
|
|
@@ -148,9 +149,9 @@ export interface ITimelineIndexContextArgument {
|
|
|
148
149
|
availabilityTimeComplete : boolean;
|
|
149
150
|
/** Allows to obtain the minimum and maximum positions of a content. */
|
|
150
151
|
manifestBoundsCalculator : ManifestBoundsCalculator;
|
|
151
|
-
/** Start of the period
|
|
152
|
+
/** Start of the period linked to this RepresentationIndex, in seconds. */
|
|
152
153
|
periodStart : number;
|
|
153
|
-
/** End of the period
|
|
154
|
+
/** End of the period linked to this RepresentationIndex, in seconds. */
|
|
154
155
|
periodEnd : number|undefined;
|
|
155
156
|
/** Whether the corresponding Manifest can be updated and changed. */
|
|
156
157
|
isDynamic : boolean;
|
|
@@ -158,13 +159,13 @@ export interface ITimelineIndexContextArgument {
|
|
|
158
159
|
* Time (in terms of `performance.now`) at which the XML file containing this
|
|
159
160
|
* index was received
|
|
160
161
|
*/
|
|
161
|
-
receivedTime? : number;
|
|
162
|
+
receivedTime? : number | undefined;
|
|
162
163
|
/** Base URL for the Representation concerned. */
|
|
163
164
|
representationBaseURLs : IResolvedBaseUrl[];
|
|
164
165
|
/** ID of the Representation concerned. */
|
|
165
|
-
representationId? : string;
|
|
166
|
+
representationId? : string | undefined;
|
|
166
167
|
/** Bitrate of the Representation concerned. */
|
|
167
|
-
representationBitrate? : number;
|
|
168
|
+
representationBitrate? : number | undefined;
|
|
168
169
|
/**
|
|
169
170
|
* The parser should take this previous version of the
|
|
170
171
|
* `TimelineRepresentationIndex` - which was from the same Representation
|
|
@@ -174,13 +175,18 @@ export interface ITimelineIndexContextArgument {
|
|
|
174
175
|
* Use with moderation.
|
|
175
176
|
*/
|
|
176
177
|
unsafelyBaseOnPreviousRepresentation : Representation | null;
|
|
177
|
-
|
|
178
|
+
/** Function that tells if an EMSG is whitelisted by the manifest */
|
|
178
179
|
isEMSGWhitelisted: (inbandEvent: IEMSG) => boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Set to `true` if the linked Period is the chronologically last one in the
|
|
182
|
+
* Manifest.
|
|
183
|
+
*/
|
|
184
|
+
isLastPeriod : boolean;
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
export interface ILastSegmentInformation {
|
|
182
188
|
/** End of the timeline on `time`, timescaled. */
|
|
183
|
-
lastPosition? : number;
|
|
189
|
+
lastPosition? : number | undefined;
|
|
184
190
|
|
|
185
191
|
/** Defines the time at which `lastPosition` was last calculated. */
|
|
186
192
|
time : number;
|
|
@@ -224,6 +230,9 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
224
230
|
/* Function that tells if an EMSG is whitelisted by the manifest */
|
|
225
231
|
private _isEMSGWhitelisted: (inbandEvent: IEMSG) => boolean;
|
|
226
232
|
|
|
233
|
+
/** `true` if the linked Period is the chronologically last one in the Manifest. */
|
|
234
|
+
private _isLastPeriod: boolean;
|
|
235
|
+
|
|
227
236
|
/**
|
|
228
237
|
* @param {Object} index
|
|
229
238
|
* @param {Object} context
|
|
@@ -239,6 +248,7 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
239
248
|
const { availabilityTimeComplete,
|
|
240
249
|
manifestBoundsCalculator,
|
|
241
250
|
isDynamic,
|
|
251
|
+
isLastPeriod,
|
|
242
252
|
representationBaseURLs,
|
|
243
253
|
representationId,
|
|
244
254
|
representationBitrate,
|
|
@@ -257,6 +267,7 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
257
267
|
this._manifestBoundsCalculator = manifestBoundsCalculator;
|
|
258
268
|
|
|
259
269
|
this._isEMSGWhitelisted = isEMSGWhitelisted;
|
|
270
|
+
this._isLastPeriod = isLastPeriod;
|
|
260
271
|
this._lastUpdate = context.receivedTime == null ?
|
|
261
272
|
performance.now() :
|
|
262
273
|
context.receivedTime;
|
|
@@ -454,6 +465,7 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
454
465
|
this._scaledPeriodEnd = newIndex._scaledPeriodEnd;
|
|
455
466
|
this._lastUpdate = newIndex._lastUpdate;
|
|
456
467
|
this._manifestBoundsCalculator = newIndex._manifestBoundsCalculator;
|
|
468
|
+
this._isLastPeriod = newIndex._isLastPeriod;
|
|
457
469
|
}
|
|
458
470
|
|
|
459
471
|
/**
|
|
@@ -468,11 +480,16 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
468
480
|
if (newIndex._index.timeline === null) {
|
|
469
481
|
newIndex._index.timeline = newIndex._getTimeline();
|
|
470
482
|
}
|
|
471
|
-
updateSegmentTimeline(this._index.timeline,
|
|
483
|
+
const hasReplaced = updateSegmentTimeline(this._index.timeline,
|
|
484
|
+
newIndex._index.timeline);
|
|
485
|
+
if (hasReplaced) {
|
|
486
|
+
this._index.startNumber = newIndex._index.startNumber;
|
|
487
|
+
}
|
|
472
488
|
this._isDynamic = newIndex._isDynamic;
|
|
473
489
|
this._scaledPeriodStart = newIndex._scaledPeriodStart;
|
|
474
490
|
this._scaledPeriodEnd = newIndex._scaledPeriodEnd;
|
|
475
491
|
this._lastUpdate = newIndex._lastUpdate;
|
|
492
|
+
this._isLastPeriod = newIndex._isLastPeriod;
|
|
476
493
|
}
|
|
477
494
|
|
|
478
495
|
/**
|
|
@@ -482,7 +499,13 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
482
499
|
* @returns {Boolean}
|
|
483
500
|
*/
|
|
484
501
|
isFinished() : boolean {
|
|
485
|
-
if (!this._isDynamic) {
|
|
502
|
+
if (!this._isDynamic || !this._isLastPeriod) {
|
|
503
|
+
// Either the content is not dynamic, in which case no new segment will
|
|
504
|
+
// be generated, either it is but this index is not linked to the current
|
|
505
|
+
// last Period in the MPD, in which case it is inferred that it has been
|
|
506
|
+
// completely generated. Note that this second condition might break very
|
|
507
|
+
// very rare use cases where old Periods are still being generated, yet it
|
|
508
|
+
// should fix more cases than it breaks.
|
|
486
509
|
return true;
|
|
487
510
|
}
|
|
488
511
|
|
|
@@ -531,7 +554,11 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
531
554
|
return; // we don't know yet
|
|
532
555
|
}
|
|
533
556
|
const scaledFirstPosition = toIndexTime(firstPosition, this._index);
|
|
534
|
-
clearTimelineFromPosition(this._index.timeline,
|
|
557
|
+
const nbEltsRemoved = clearTimelineFromPosition(this._index.timeline,
|
|
558
|
+
scaledFirstPosition);
|
|
559
|
+
if (this._index.startNumber !== undefined) {
|
|
560
|
+
this._index.startNumber += nbEltsRemoved;
|
|
561
|
+
}
|
|
535
562
|
}
|
|
536
563
|
|
|
537
564
|
static getIndexEnd(timeline : IIndexSegment[],
|
|
@@ -578,6 +605,7 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
|
|
|
578
605
|
const newElements = this._parseTimeline();
|
|
579
606
|
this._parseTimeline = null; // Free memory
|
|
580
607
|
|
|
608
|
+
const { MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY } = config.getCurrent();
|
|
581
609
|
if (this._unsafelyBaseOnPreviousIndex === null ||
|
|
582
610
|
newElements.length < MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY)
|
|
583
611
|
{
|
|
@@ -30,8 +30,8 @@ const SUPPORTED_TEXT_TYPES = ["subtitle", "caption"];
|
|
|
30
30
|
|
|
31
31
|
/** Structure of a parsed "scheme-like" element in the MPD. */
|
|
32
32
|
interface IScheme {
|
|
33
|
-
schemeIdUri? : string;
|
|
34
|
-
value? : string;
|
|
33
|
+
schemeIdUri? : string | undefined;
|
|
34
|
+
value? : string | undefined;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -47,7 +47,7 @@ export default class ManifestBoundsCalculator {
|
|
|
47
47
|
/**
|
|
48
48
|
* @param {Object} args
|
|
49
49
|
*/
|
|
50
|
-
constructor(args : { timeShiftBufferDepth
|
|
50
|
+
constructor(args : { timeShiftBufferDepth : number | undefined;
|
|
51
51
|
isDynamic : boolean; }
|
|
52
52
|
) {
|
|
53
53
|
this._isDynamic = args.isDynamic;
|
|
@@ -15,14 +15,18 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import log from "../../../../log";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
IAdaptationType,
|
|
20
|
+
Period,
|
|
21
|
+
SUPPORTED_ADAPTATIONS_TYPE,
|
|
22
|
+
} from "../../../../manifest";
|
|
19
23
|
import arrayFind from "../../../../utils/array_find";
|
|
24
|
+
import arrayFindIndex from "../../../../utils/array_find_index";
|
|
20
25
|
import arrayIncludes from "../../../../utils/array_includes";
|
|
21
26
|
import isNonEmptyString from "../../../../utils/is_non_empty_string";
|
|
22
27
|
import {
|
|
23
28
|
IParsedAdaptation,
|
|
24
29
|
IParsedAdaptations,
|
|
25
|
-
IParsedAdaptationType,
|
|
26
30
|
} from "../../types";
|
|
27
31
|
import {
|
|
28
32
|
IAdaptationSetIntermediateRepresentation,
|
|
@@ -31,52 +35,10 @@ import {
|
|
|
31
35
|
import attachTrickModeTrack from "./attach_trickmode_track";
|
|
32
36
|
// eslint-disable-next-line max-len
|
|
33
37
|
import inferAdaptationType from "./infer_adaptation_type";
|
|
34
|
-
import ManifestBoundsCalculator from "./manifest_bounds_calculator";
|
|
35
38
|
import parseRepresentations, {
|
|
36
|
-
|
|
39
|
+
IRepresentationContext,
|
|
37
40
|
} from "./parse_representations";
|
|
38
|
-
import resolveBaseURLs
|
|
39
|
-
IResolvedBaseUrl,
|
|
40
|
-
} from "./resolve_base_urls";
|
|
41
|
-
|
|
42
|
-
/** Context needed when calling `parseAdaptationSets`. */
|
|
43
|
-
export interface IAdaptationSetsContextInfos {
|
|
44
|
-
/** Whether we should request new segments even if they are not yet finished. */
|
|
45
|
-
aggressiveMode : boolean;
|
|
46
|
-
availabilityTimeComplete: boolean;
|
|
47
|
-
/** availabilityTimeOffset of the concerned period. */
|
|
48
|
-
availabilityTimeOffset: number;
|
|
49
|
-
/** Eventual URLs from which every relative URL will be based on. */
|
|
50
|
-
baseURLs : IResolvedBaseUrl[];
|
|
51
|
-
/** Allows to obtain the first available position of a content. */
|
|
52
|
-
manifestBoundsCalculator : ManifestBoundsCalculator;
|
|
53
|
-
/* End time of the current period, in seconds. */
|
|
54
|
-
end? : number;
|
|
55
|
-
/** Whether the Manifest can evolve with time. */
|
|
56
|
-
isDynamic : boolean;
|
|
57
|
-
/** Manifest DASH profiles used for signaling some features */
|
|
58
|
-
manifestProfiles?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Time (in terms of `performance.now`) at which the XML file containing
|
|
61
|
-
* this AdaptationSet was received.
|
|
62
|
-
*/
|
|
63
|
-
receivedTime? : number;
|
|
64
|
-
/** SegmentTemplate parsed in the Period, if found. */
|
|
65
|
-
segmentTemplate? : ISegmentTemplateIntermediateRepresentation;
|
|
66
|
-
/** Start time of the current period, in seconds. */
|
|
67
|
-
start : number;
|
|
68
|
-
/** Depth of the buffer for the whole content, in seconds. */
|
|
69
|
-
timeShiftBufferDepth? : number;
|
|
70
|
-
/**
|
|
71
|
-
* The parser should take this Period - which is from a previously parsed
|
|
72
|
-
* Manifest for the same dynamic content - as a base to speed-up the parsing
|
|
73
|
-
* process.
|
|
74
|
-
* /!\ If unexpected differences exist between both, there is a risk of
|
|
75
|
-
* de-synchronization with what is actually on the server,
|
|
76
|
-
* Use with moderation.
|
|
77
|
-
*/
|
|
78
|
-
unsafelyBaseOnPreviousPeriod : Period | null;
|
|
79
|
-
}
|
|
41
|
+
import resolveBaseURLs from "./resolve_base_urls";
|
|
80
42
|
|
|
81
43
|
/**
|
|
82
44
|
* Supplementary information for "switchable" AdaptationSets of the same Period.
|
|
@@ -121,9 +83,11 @@ interface IAdaptationSwitchingInfos {
|
|
|
121
83
|
* @returns {Boolean}
|
|
122
84
|
*/
|
|
123
85
|
function isVisuallyImpaired(
|
|
124
|
-
accessibility
|
|
86
|
+
accessibility : { schemeIdUri? : string | undefined;
|
|
87
|
+
value? : string | undefined; } |
|
|
88
|
+
undefined
|
|
125
89
|
) : boolean {
|
|
126
|
-
if (accessibility
|
|
90
|
+
if (accessibility === undefined) {
|
|
127
91
|
return false;
|
|
128
92
|
}
|
|
129
93
|
|
|
@@ -148,9 +112,11 @@ function isVisuallyImpaired(
|
|
|
148
112
|
* @returns {Boolean}
|
|
149
113
|
*/
|
|
150
114
|
function isHardOfHearing(
|
|
151
|
-
accessibility
|
|
115
|
+
accessibility : { schemeIdUri? : string | undefined;
|
|
116
|
+
value? : string | undefined; } |
|
|
117
|
+
undefined
|
|
152
118
|
) : boolean {
|
|
153
|
-
if (accessibility
|
|
119
|
+
if (accessibility === undefined) {
|
|
154
120
|
return false;
|
|
155
121
|
}
|
|
156
122
|
|
|
@@ -166,9 +132,11 @@ function isHardOfHearing(
|
|
|
166
132
|
* @returns {Boolean}
|
|
167
133
|
*/
|
|
168
134
|
function hasSignLanguageInterpretation(
|
|
169
|
-
accessibility
|
|
135
|
+
accessibility : { schemeIdUri? : string | undefined;
|
|
136
|
+
value? : string | undefined; } |
|
|
137
|
+
undefined
|
|
170
138
|
) : boolean {
|
|
171
|
-
if (accessibility
|
|
139
|
+
if (accessibility === undefined) {
|
|
172
140
|
return false;
|
|
173
141
|
}
|
|
174
142
|
|
|
@@ -264,37 +232,38 @@ function getAdaptationSetSwitchingIDs(
|
|
|
264
232
|
* Note that the AdaptationSets returned are sorted by priority (from the most
|
|
265
233
|
* priority to the least one).
|
|
266
234
|
* @param {Array.<Object>} adaptationsIR
|
|
267
|
-
* @param {Object}
|
|
235
|
+
* @param {Object} context
|
|
268
236
|
* @returns {Array.<Object>}
|
|
269
237
|
*/
|
|
270
238
|
export default function parseAdaptationSets(
|
|
271
239
|
adaptationsIR : IAdaptationSetIntermediateRepresentation[],
|
|
272
|
-
|
|
240
|
+
context : IAdaptationSetContext
|
|
273
241
|
): IParsedAdaptations {
|
|
274
|
-
const parsedAdaptations :
|
|
242
|
+
const parsedAdaptations : Record<
|
|
243
|
+
IAdaptationType,
|
|
244
|
+
Array<[ IParsedAdaptation,
|
|
245
|
+
IAdaptationSetOrderingData ]>
|
|
246
|
+
> = { video: [],
|
|
247
|
+
audio: [],
|
|
248
|
+
text: [],
|
|
249
|
+
image: [] };
|
|
275
250
|
const trickModeAdaptations: Array<{ adaptation: IParsedAdaptation;
|
|
276
251
|
trickModeAttachedAdaptationIds: string[]; }> = [];
|
|
277
252
|
const adaptationSwitchingInfos : IAdaptationSwitchingInfos = {};
|
|
253
|
+
|
|
278
254
|
const parsedAdaptationsIDs : string[] = [];
|
|
279
255
|
|
|
280
256
|
/**
|
|
281
|
-
* Index of the last parsed AdaptationSet with a Role set as "main" in
|
|
282
|
-
* `parsedAdaptations
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
257
|
+
* Index of the last parsed Video AdaptationSet with a Role set as "main" in
|
|
258
|
+
* `parsedAdaptations.video`.
|
|
259
|
+
* `-1` if not yet encountered.
|
|
260
|
+
* Used as we merge all main video AdaptationSet due to a comprehension of the
|
|
261
|
+
* DASH-IF IOP.
|
|
286
262
|
*/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// first sort AdaptationSets by absolute priority.
|
|
290
|
-
adaptationsIR.sort((a, b) => {
|
|
291
|
-
/* As of DASH-IF 4.3, `1` is the default value. */
|
|
292
|
-
const priority1 = a.attributes.selectionPriority ?? 1;
|
|
293
|
-
const priority2 = b.attributes.selectionPriority ?? 1;
|
|
294
|
-
return priority2 - priority1;
|
|
295
|
-
});
|
|
263
|
+
let lastMainVideoAdapIdx = -1;
|
|
296
264
|
|
|
297
|
-
for (
|
|
265
|
+
for (let adaptationIdx = 0; adaptationIdx < adaptationsIR.length; adaptationIdx++) {
|
|
266
|
+
const adaptation = adaptationsIR[adaptationIdx];
|
|
298
267
|
const adaptationChildren = adaptation.children;
|
|
299
268
|
const { essentialProperties,
|
|
300
269
|
roles } = adaptationChildren;
|
|
@@ -306,10 +275,10 @@ export default function parseAdaptationSets(
|
|
|
306
275
|
const representationsIR = adaptation.children.representations;
|
|
307
276
|
const availabilityTimeComplete =
|
|
308
277
|
adaptation.attributes.availabilityTimeComplete ??
|
|
309
|
-
|
|
278
|
+
context.availabilityTimeComplete;
|
|
310
279
|
const availabilityTimeOffset =
|
|
311
280
|
(adaptation.attributes.availabilityTimeOffset ?? 0) +
|
|
312
|
-
|
|
281
|
+
context.availabilityTimeOffset;
|
|
313
282
|
|
|
314
283
|
const adaptationMimeType = adaptation.attributes.mimeType;
|
|
315
284
|
const adaptationCodecs = adaptation.attributes.codecs;
|
|
@@ -327,30 +296,32 @@ export default function parseAdaptationSets(
|
|
|
327
296
|
continue;
|
|
328
297
|
}
|
|
329
298
|
|
|
299
|
+
const priority = adaptation.attributes.selectionPriority ?? 1;
|
|
330
300
|
const originalID = adaptation.attributes.id;
|
|
331
301
|
let newID : string;
|
|
332
302
|
const adaptationSetSwitchingIDs = getAdaptationSetSwitchingIDs(adaptation);
|
|
333
303
|
const parentSegmentTemplates = [];
|
|
334
|
-
if (
|
|
335
|
-
parentSegmentTemplates.push(
|
|
304
|
+
if (context.segmentTemplate !== undefined) {
|
|
305
|
+
parentSegmentTemplates.push(context.segmentTemplate);
|
|
336
306
|
}
|
|
337
307
|
if (adaptation.children.segmentTemplate !== undefined) {
|
|
338
308
|
parentSegmentTemplates.push(adaptation.children.segmentTemplate);
|
|
339
309
|
}
|
|
340
310
|
|
|
341
|
-
const
|
|
342
|
-
aggressiveMode:
|
|
311
|
+
const reprCtxt : IRepresentationContext = {
|
|
312
|
+
aggressiveMode: context.aggressiveMode,
|
|
343
313
|
availabilityTimeComplete,
|
|
344
314
|
availabilityTimeOffset,
|
|
345
|
-
baseURLs: resolveBaseURLs(
|
|
346
|
-
manifestBoundsCalculator:
|
|
347
|
-
end:
|
|
348
|
-
isDynamic:
|
|
349
|
-
|
|
315
|
+
baseURLs: resolveBaseURLs(context.baseURLs, adaptationChildren.baseURLs),
|
|
316
|
+
manifestBoundsCalculator: context.manifestBoundsCalculator,
|
|
317
|
+
end: context.end,
|
|
318
|
+
isDynamic: context.isDynamic,
|
|
319
|
+
isLastPeriod: context.isLastPeriod,
|
|
320
|
+
manifestProfiles: context.manifestProfiles,
|
|
350
321
|
parentSegmentTemplates,
|
|
351
|
-
receivedTime:
|
|
352
|
-
start:
|
|
353
|
-
timeShiftBufferDepth:
|
|
322
|
+
receivedTime: context.receivedTime,
|
|
323
|
+
start: context.start,
|
|
324
|
+
timeShiftBufferDepth: context.timeShiftBufferDepth,
|
|
354
325
|
unsafelyBaseOnPreviousAdaptation: null,
|
|
355
326
|
};
|
|
356
327
|
|
|
@@ -369,19 +340,16 @@ export default function parseAdaptationSets(
|
|
|
369
340
|
|
|
370
341
|
if (type === "video" &&
|
|
371
342
|
isMainAdaptation &&
|
|
372
|
-
|
|
373
|
-
parsedAdaptations.video.length >
|
|
374
|
-
lastMainAdaptationIndex.video !== undefined &&
|
|
343
|
+
lastMainVideoAdapIdx >= 0 &&
|
|
344
|
+
parsedAdaptations.video.length > lastMainVideoAdapIdx &&
|
|
375
345
|
!isTrickModeTrack)
|
|
376
346
|
{
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const videoMainAdaptation = parsedAdaptations.video[lastMainAdaptationIndex.video];
|
|
380
|
-
adaptationInfos.unsafelyBaseOnPreviousAdaptation = periodInfos
|
|
347
|
+
const videoMainAdaptation = parsedAdaptations.video[lastMainVideoAdapIdx][0];
|
|
348
|
+
reprCtxt.unsafelyBaseOnPreviousAdaptation = context
|
|
381
349
|
.unsafelyBaseOnPreviousPeriod?.getAdaptation(videoMainAdaptation.id) ?? null;
|
|
382
350
|
const representations = parseRepresentations(representationsIR,
|
|
383
351
|
adaptation,
|
|
384
|
-
|
|
352
|
+
reprCtxt);
|
|
385
353
|
videoMainAdaptation.representations.push(...representations);
|
|
386
354
|
newID = videoMainAdaptation.id;
|
|
387
355
|
} else {
|
|
@@ -430,12 +398,12 @@ export default function parseAdaptationSets(
|
|
|
430
398
|
newID = adaptationID;
|
|
431
399
|
parsedAdaptationsIDs.push(adaptationID);
|
|
432
400
|
|
|
433
|
-
|
|
401
|
+
reprCtxt.unsafelyBaseOnPreviousAdaptation = context
|
|
434
402
|
.unsafelyBaseOnPreviousPeriod?.getAdaptation(adaptationID) ?? null;
|
|
435
403
|
|
|
436
404
|
const representations = parseRepresentations(representationsIR,
|
|
437
405
|
adaptation,
|
|
438
|
-
|
|
406
|
+
reprCtxt);
|
|
439
407
|
const parsedAdaptationSet : IParsedAdaptation =
|
|
440
408
|
{ id: adaptationID,
|
|
441
409
|
representations,
|
|
@@ -457,65 +425,56 @@ export default function parseAdaptationSets(
|
|
|
457
425
|
parsedAdaptationSet.isSignInterpreted = true;
|
|
458
426
|
}
|
|
459
427
|
|
|
460
|
-
const adaptationsOfTheSameType = parsedAdaptations[type];
|
|
461
428
|
if (trickModeAttachedAdaptationIds !== undefined) {
|
|
462
429
|
trickModeAdaptations.push({ adaptation: parsedAdaptationSet,
|
|
463
430
|
trickModeAttachedAdaptationIds });
|
|
464
|
-
} else if (adaptationsOfTheSameType === undefined) {
|
|
465
|
-
parsedAdaptations[type] = [parsedAdaptationSet];
|
|
466
|
-
if (isMainAdaptation) {
|
|
467
|
-
lastMainAdaptationIndex[type] = 0;
|
|
468
|
-
}
|
|
469
431
|
} else {
|
|
470
|
-
let mergedInto : IParsedAdaptation|null = null;
|
|
471
432
|
|
|
472
433
|
// look if we have to merge this into another Adaptation
|
|
434
|
+
let mergedIntoIdx = -1;
|
|
473
435
|
for (const id of adaptationSetSwitchingIDs) {
|
|
474
436
|
const switchingInfos = adaptationSwitchingInfos[id];
|
|
475
|
-
if (switchingInfos
|
|
437
|
+
if (switchingInfos !== undefined &&
|
|
476
438
|
switchingInfos.newID !== newID &&
|
|
477
439
|
arrayIncludes(switchingInfos.adaptationSetSwitchingIDs, originalID))
|
|
478
440
|
{
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
441
|
+
mergedIntoIdx = arrayFindIndex(parsedAdaptations[type],
|
|
442
|
+
(a) => a[0].id === id);
|
|
443
|
+
const mergedInto = parsedAdaptations[type][mergedIntoIdx];
|
|
444
|
+
if (mergedInto !== undefined &&
|
|
445
|
+
mergedInto[0].audioDescription ===
|
|
483
446
|
parsedAdaptationSet.audioDescription &&
|
|
484
|
-
|
|
447
|
+
mergedInto[0].closedCaption ===
|
|
485
448
|
parsedAdaptationSet.closedCaption &&
|
|
486
|
-
|
|
449
|
+
mergedInto[0].language === parsedAdaptationSet.language)
|
|
487
450
|
{
|
|
488
451
|
log.info("DASH Parser: merging \"switchable\" AdaptationSets",
|
|
489
452
|
originalID, id);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
453
|
+
mergedInto[0].representations.push(...parsedAdaptationSet.representations);
|
|
454
|
+
if (type === "video" &&
|
|
455
|
+
isMainAdaptation &&
|
|
456
|
+
!mergedInto[1].isMainAdaptation)
|
|
457
|
+
{
|
|
458
|
+
lastMainVideoAdapIdx = Math.max(lastMainVideoAdapIdx, mergedIntoIdx);
|
|
459
|
+
}
|
|
460
|
+
mergedInto[1] = {
|
|
461
|
+
priority: Math.max(priority, mergedInto[1].priority),
|
|
462
|
+
isMainAdaptation: isMainAdaptation ||
|
|
463
|
+
mergedInto[1].isMainAdaptation,
|
|
464
|
+
indexInMpd: Math.min(adaptationIdx, mergedInto[1].indexInMpd),
|
|
465
|
+
};
|
|
493
466
|
}
|
|
494
467
|
}
|
|
495
468
|
}
|
|
496
469
|
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
lastMainAdaptationIndex[type] = newLastMainIdx;
|
|
505
|
-
} else {
|
|
506
|
-
const indexOf = adaptationsOfTheSameType.indexOf(mergedInto);
|
|
507
|
-
if (indexOf < 0) { // Weird, not found
|
|
508
|
-
adaptationsOfTheSameType.splice(newLastMainIdx, 0, parsedAdaptationSet);
|
|
509
|
-
lastMainAdaptationIndex[type] = newLastMainIdx;
|
|
510
|
-
} else if (oldLastMainIdx === undefined || indexOf > oldLastMainIdx) {
|
|
511
|
-
// Found but was not main
|
|
512
|
-
adaptationsOfTheSameType.splice(indexOf, 1);
|
|
513
|
-
adaptationsOfTheSameType.splice(newLastMainIdx, 0, mergedInto);
|
|
514
|
-
lastMainAdaptationIndex[type] = newLastMainIdx;
|
|
515
|
-
}
|
|
470
|
+
if (mergedIntoIdx < 0) {
|
|
471
|
+
parsedAdaptations[type].push([ parsedAdaptationSet,
|
|
472
|
+
{ priority,
|
|
473
|
+
isMainAdaptation,
|
|
474
|
+
indexInMpd: adaptationIdx }]);
|
|
475
|
+
if (type === "video" && isMainAdaptation) {
|
|
476
|
+
lastMainVideoAdapIdx = parsedAdaptations.video.length - 1;
|
|
516
477
|
}
|
|
517
|
-
} else if (mergedInto === null) {
|
|
518
|
-
adaptationsOfTheSameType.push(parsedAdaptationSet);
|
|
519
478
|
}
|
|
520
479
|
}
|
|
521
480
|
}
|
|
@@ -525,6 +484,80 @@ export default function parseAdaptationSets(
|
|
|
525
484
|
adaptationSetSwitchingIDs };
|
|
526
485
|
}
|
|
527
486
|
}
|
|
528
|
-
|
|
529
|
-
|
|
487
|
+
|
|
488
|
+
const adaptationsPerType = SUPPORTED_ADAPTATIONS_TYPE
|
|
489
|
+
.reduce((acc : IParsedAdaptations, adaptationType : IAdaptationType) => {
|
|
490
|
+
const adaptationsParsedForType = parsedAdaptations[adaptationType];
|
|
491
|
+
if (adaptationsParsedForType.length > 0) {
|
|
492
|
+
adaptationsParsedForType.sort(compareAdaptations);
|
|
493
|
+
acc[adaptationType] = adaptationsParsedForType
|
|
494
|
+
.map(([parsedAdaptation]) => parsedAdaptation);
|
|
495
|
+
}
|
|
496
|
+
return acc;
|
|
497
|
+
}, {});
|
|
498
|
+
parsedAdaptations.video.sort(compareAdaptations);
|
|
499
|
+
attachTrickModeTrack(adaptationsPerType, trickModeAdaptations);
|
|
500
|
+
return adaptationsPerType;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Metadata allowing to order AdaptationSets between one another. */
|
|
504
|
+
interface IAdaptationSetOrderingData {
|
|
505
|
+
/**
|
|
506
|
+
* If `true`, this AdaptationSet is considered as a "main" one (e.g. it had a
|
|
507
|
+
* Role set to "main").
|
|
508
|
+
*/
|
|
509
|
+
isMainAdaptation : boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Set to the `selectionPriority` attribute of the corresponding AdaptationSet
|
|
512
|
+
* or to `1` by default.
|
|
513
|
+
*/
|
|
514
|
+
priority : number;
|
|
515
|
+
/** Index of this AdaptationSet in the original MPD, starting from `0`. */
|
|
516
|
+
indexInMpd : number;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Compare groups of parsed AdaptationSet, alongside some ordering metadata,
|
|
521
|
+
* allowing to easily sort them through JavaScript's `Array.prototype.sort`
|
|
522
|
+
* method.
|
|
523
|
+
* @param {Array.<Object>} a
|
|
524
|
+
* @param {Array.<Object>} b
|
|
525
|
+
* @returns {number}
|
|
526
|
+
*/
|
|
527
|
+
function compareAdaptations(
|
|
528
|
+
a : [IParsedAdaptation, IAdaptationSetOrderingData],
|
|
529
|
+
b : [IParsedAdaptation, IAdaptationSetOrderingData]
|
|
530
|
+
) : number {
|
|
531
|
+
const priorityDiff = b[1].priority - a[1].priority;
|
|
532
|
+
if (priorityDiff !== 0) {
|
|
533
|
+
return priorityDiff;
|
|
534
|
+
}
|
|
535
|
+
if (a[1].isMainAdaptation !== b[1].isMainAdaptation) {
|
|
536
|
+
return a[1].isMainAdaptation ? -1 :
|
|
537
|
+
1;
|
|
538
|
+
}
|
|
539
|
+
return a[1].indexInMpd - b[1].indexInMpd;
|
|
530
540
|
}
|
|
541
|
+
|
|
542
|
+
/** Context needed when calling `parseAdaptationSets`. */
|
|
543
|
+
export interface IAdaptationSetContext extends IInheritedRepresentationContext {
|
|
544
|
+
/** SegmentTemplate parsed in the Period, if found. */
|
|
545
|
+
segmentTemplate? : ISegmentTemplateIntermediateRepresentation | undefined;
|
|
546
|
+
/**
|
|
547
|
+
* The parser should take this Period - which is from a previously parsed
|
|
548
|
+
* Manifest for the same dynamic content - as a base to speed-up the parsing
|
|
549
|
+
* process.
|
|
550
|
+
* /!\ If unexpected differences exist between both, there is a risk of
|
|
551
|
+
* de-synchronization with what is actually on the server,
|
|
552
|
+
* Use with moderation.
|
|
553
|
+
*/
|
|
554
|
+
unsafelyBaseOnPreviousPeriod : Period | null;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Supplementary context needed to parse a Representation common with
|
|
559
|
+
* `IRepresentationContext`.
|
|
560
|
+
*/
|
|
561
|
+
type IInheritedRepresentationContext = Omit<IRepresentationContext,
|
|
562
|
+
"unsafelyBaseOnPreviousAdaptation" |
|
|
563
|
+
"parentSegmentTemplates">;
|