rx-player 4.0.0-dev.2023120600 → 4.0.0-dev.2023121900
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -2
- package/README.md +2 -33
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/add_text_track.d.ts +3 -1
- package/dist/_esm5.processed/compat/add_text_track.js +7 -4
- package/dist/_esm5.processed/compat/browser_compatibility_types.d.ts +7 -0
- package/dist/_esm5.processed/compat/event_listeners.d.ts +15 -2
- package/dist/_esm5.processed/compat/event_listeners.js +37 -2
- package/dist/_esm5.processed/compat/fullscreen.d.ts +32 -0
- package/dist/_esm5.processed/compat/fullscreen.js +78 -0
- package/dist/_esm5.processed/compat/index.d.ts +3 -1
- package/dist/_esm5.processed/compat/index.js +3 -1
- package/dist/_esm5.processed/compat/is_offline.d.ts +39 -0
- package/dist/_esm5.processed/compat/is_offline.js +43 -0
- package/dist/_esm5.processed/config.d.ts +21 -9
- package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.d.ts +58 -0
- package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +54 -14
- package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.d.ts +8 -2
- package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.js +11 -2
- package/dist/_esm5.processed/core/api/debug/modules/general_info.js +46 -17
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +1 -1
- package/dist/_esm5.processed/core/api/option_utils.d.ts +35 -14
- package/dist/_esm5.processed/core/api/option_utils.js +230 -47
- package/dist/_esm5.processed/core/api/public_api.d.ts +266 -92
- package/dist/_esm5.processed/core/api/public_api.js +802 -444
- package/dist/_esm5.processed/core/api/{track_management/media_element_tracks_store.d.ts → tracks_management/media_element_track_choice_manager.d.ts} +75 -15
- package/dist/_esm5.processed/core/api/{track_management/media_element_tracks_store.js → tracks_management/media_element_track_choice_manager.js} +193 -74
- package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +258 -0
- package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +989 -0
- package/dist/_esm5.processed/core/api/utils.d.ts +0 -1
- package/dist/_esm5.processed/core/api/utils.js +11 -28
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +3 -3
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +71 -83
- package/dist/_esm5.processed/core/decrypt/get_media_keys.js +5 -6
- package/dist/_esm5.processed/core/decrypt/session_events_listener.js +72 -10
- package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +4 -4
- package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +4 -6
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +3 -1
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +26 -7
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +9 -3
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +9 -16
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +3 -1
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +6 -1
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +41 -4
- package/dist/_esm5.processed/core/init/media_source_content_initializer.d.ts +8 -1
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +5 -2
- package/dist/_esm5.processed/core/init/types.d.ts +15 -5
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +75 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +133 -0
- package/dist/_esm5.processed/core/{api/track_management → segment_buffers/implementations/image}/index.d.ts +2 -3
- package/dist/_esm5.processed/core/{api/track_management → segment_buffers/implementations/image}/index.js +2 -3
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +2 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +4 -3
- package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/index.js +1 -2
- package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +2 -3
- package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +0 -1
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.d.ts +1 -0
- package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +16 -2
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +15 -0
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +93 -183
- package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +13 -27
- package/dist/_esm5.processed/core/stream/index.d.ts +3 -2
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +0 -2
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +7 -5
- package/dist/_esm5.processed/core/stream/period/period_stream.js +12 -13
- package/dist/_esm5.processed/core/stream/period/types.d.ts +14 -5
- package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -2
- package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +46 -10
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +23 -29
- package/dist/_esm5.processed/core/stream/representation/types.d.ts +1 -11
- package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +1 -1
- package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/_esm5.processed/default_config.d.ts +98 -35
- package/dist/_esm5.processed/default_config.js +113 -36
- package/dist/_esm5.processed/errors/custom_loader_error.d.ts +3 -1
- package/dist/_esm5.processed/errors/custom_loader_error.js +3 -1
- package/dist/_esm5.processed/errors/media_error.js +2 -2
- package/dist/_esm5.processed/errors/network_error.d.ts +1 -0
- package/dist/_esm5.processed/errors/network_error.js +1 -0
- package/dist/_esm5.processed/errors/request_error.d.ts +3 -2
- package/dist/_esm5.processed/errors/request_error.js +5 -2
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -3
- package/dist/_esm5.processed/features/features_object.js +2 -0
- package/dist/_esm5.processed/{transports/smooth/is_mp4_embedded_track.js → features/list/bif_parser.d.ts} +6 -7
- package/dist/_esm5.processed/features/list/bif_parser.js +27 -0
- package/dist/_esm5.processed/features/list/directfile.js +5 -2
- package/dist/_esm5.processed/features/list/image_buffer.d.ts +23 -0
- package/dist/_esm5.processed/features/list/image_buffer.js +25 -0
- package/dist/_esm5.processed/features/list/index.d.ts +2 -0
- package/dist/_esm5.processed/features/list/index.js +2 -0
- package/dist/_esm5.processed/features/types.d.ts +27 -3
- package/dist/_esm5.processed/manifest/adaptation.d.ts +11 -9
- package/dist/_esm5.processed/manifest/adaptation.js +30 -41
- package/dist/_esm5.processed/manifest/index.d.ts +4 -3
- package/dist/_esm5.processed/manifest/manifest.d.ts +54 -5
- package/dist/_esm5.processed/manifest/manifest.js +110 -5
- package/dist/_esm5.processed/manifest/period.d.ts +5 -4
- package/dist/_esm5.processed/manifest/representation.d.ts +5 -10
- package/dist/_esm5.processed/manifest/representation.js +5 -15
- package/dist/_esm5.processed/manifest/representation_index/index.d.ts +2 -2
- package/dist/_esm5.processed/manifest/representation_index/static.d.ts +0 -2
- package/dist/_esm5.processed/manifest/representation_index/static.js +0 -6
- package/dist/_esm5.processed/manifest/representation_index/types.d.ts +21 -42
- package/dist/_esm5.processed/manifest/types.d.ts +2 -0
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +31 -17
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +19 -26
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +0 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +1 -7
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +6 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +8 -11
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +0 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +0 -6
- package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +6 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +5 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +2 -0
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +2 -0
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +2 -2
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +6 -10
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +2 -4
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +1 -10
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +2 -18
- package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +4 -4
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +6 -3
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +2 -1
- package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +0 -2
- package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +0 -6
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +6 -6
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +3 -12
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +2 -11
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +1 -0
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +17 -11
- package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +83 -21
- package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +125 -53
- package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.d.ts +6 -3
- package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +4 -4
- package/dist/_esm5.processed/parsers/manifest/types.d.ts +3 -3
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/_esm5.processed/public_types.d.ts +310 -396
- package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.d.ts +4 -5
- package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +4 -5
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +4 -4
- package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +38 -0
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +129 -0
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +3 -2
- package/dist/_esm5.processed/transports/dash/pipelines.js +4 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
- package/dist/_esm5.processed/transports/dash/segment_loader.js +20 -26
- package/dist/_esm5.processed/transports/dash/segment_parser.js +24 -19
- package/dist/_esm5.processed/transports/dash/text_loader.js +5 -5
- package/dist/_esm5.processed/transports/dash/text_parser.js +33 -28
- package/dist/_esm5.processed/transports/local/pipelines.js +10 -1
- package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/local/segment_parser.d.ts +1 -1
- package/dist/_esm5.processed/transports/local/segment_parser.js +10 -10
- package/dist/_esm5.processed/transports/local/text_parser.d.ts +2 -2
- package/dist/_esm5.processed/transports/local/text_parser.js +23 -23
- package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +52 -34
- package/dist/_esm5.processed/transports/smooth/pipelines.js +190 -33
- package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +1 -1
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +22 -28
- package/dist/_esm5.processed/transports/smooth/utils.d.ts +26 -1
- package/dist/_esm5.processed/transports/smooth/utils.js +55 -1
- package/dist/_esm5.processed/transports/types.d.ts +89 -94
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
- package/dist/_esm5.processed/transports/utils/infer_segment_container.d.ts +3 -3
- package/dist/_esm5.processed/transports/utils/infer_segment_container.js +7 -5
- package/dist/_esm5.processed/transports/utils/parse_text_track.d.ts +12 -8
- package/dist/_esm5.processed/transports/utils/parse_text_track.js +21 -19
- package/dist/_esm5.processed/utils/array_includes.d.ts +1 -2
- package/dist/_esm5.processed/utils/array_includes.js +28 -30
- package/dist/_esm5.processed/{transports/smooth/is_mp4_embedded_track.d.ts → utils/list_to_map.d.ts} +5 -5
- package/dist/_esm5.processed/utils/list_to_map.js +28 -0
- package/dist/_esm5.processed/utils/request/xhr.js +5 -5
- package/dist/_esm5.processed/utils/simple_set.d.ts +51 -0
- package/dist/_esm5.processed/utils/simple_set.js +57 -0
- package/dist/_esm5.processed/utils/uniq.d.ts +36 -0
- package/dist/_esm5.processed/utils/uniq.js +43 -0
- package/dist/commonjs/config.d.ts +1 -1
- package/dist/commonjs/core/adaptive/adaptive_representation_selector.d.ts +2 -19
- package/dist/commonjs/core/adaptive/adaptive_representation_selector.js +2 -2
- package/dist/commonjs/core/adaptive/network_analyzer.js +3 -3
- package/dist/commonjs/core/api/index.d.ts +1 -1
- package/dist/commonjs/core/api/playback_observer.d.ts +128 -8
- package/dist/commonjs/core/api/playback_observer.js +217 -64
- package/dist/commonjs/core/api/public_api.js +9 -9
- package/dist/commonjs/core/api/utils.js +1 -1
- package/dist/commonjs/core/decrypt/get_media_keys.js +2 -6
- package/dist/commonjs/core/init/directfile_content_initializer.js +5 -1
- package/dist/commonjs/core/init/media_source_content_initializer.js +28 -14
- package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +1 -2
- package/dist/commonjs/core/init/utils/create_stream_playback_observer.d.ts +1 -5
- package/dist/commonjs/core/init/utils/create_stream_playback_observer.js +16 -14
- package/dist/commonjs/core/init/utils/initial_seek_and_play.d.ts +9 -11
- package/dist/commonjs/core/init/utils/initial_seek_and_play.js +121 -91
- package/dist/commonjs/core/init/utils/rebuffering_controller.js +27 -70
- package/dist/commonjs/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
- package/dist/commonjs/core/segment_buffers/garbage_collector.js +1 -2
- package/dist/commonjs/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/commonjs/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/commonjs/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
- package/dist/commonjs/core/segment_buffers/index.d.ts +2 -2
- package/dist/commonjs/core/segment_buffers/inventory/index.d.ts +2 -2
- package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
- package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
- package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +14 -18
- package/dist/commonjs/core/stream/period/period_stream.js +5 -8
- package/dist/commonjs/core/stream/period/types.d.ts +2 -3
- package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
- package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
- package/dist/commonjs/core/stream/representation/representation_stream.js +3 -4
- package/dist/commonjs/core/stream/representation/types.d.ts +2 -2
- package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +11 -12
- package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +1 -1
- package/dist/commonjs/default_config.d.ts +7 -16
- package/dist/commonjs/default_config.js +16 -16
- package/dist/commonjs/manifest/adaptation.js +2 -1
- package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/commonjs/public_types.d.ts +29 -2
- package/dist/es2017/config.d.ts +1 -1
- package/dist/es2017/core/adaptive/adaptive_representation_selector.d.ts +2 -19
- package/dist/es2017/core/adaptive/adaptive_representation_selector.js +2 -2
- package/dist/es2017/core/adaptive/network_analyzer.js +3 -3
- package/dist/es2017/core/api/index.d.ts +1 -1
- package/dist/es2017/core/api/playback_observer.d.ts +128 -8
- package/dist/es2017/core/api/playback_observer.js +217 -66
- package/dist/es2017/core/api/public_api.js +9 -9
- package/dist/es2017/core/api/utils.js +1 -1
- package/dist/es2017/core/decrypt/get_media_keys.js +2 -6
- package/dist/es2017/core/init/directfile_content_initializer.js +7 -1
- package/dist/es2017/core/init/media_source_content_initializer.js +30 -16
- package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +1 -2
- package/dist/es2017/core/init/utils/create_stream_playback_observer.d.ts +1 -5
- package/dist/es2017/core/init/utils/create_stream_playback_observer.js +16 -14
- package/dist/es2017/core/init/utils/initial_seek_and_play.d.ts +9 -11
- package/dist/es2017/core/init/utils/initial_seek_and_play.js +120 -91
- package/dist/es2017/core/init/utils/rebuffering_controller.js +27 -70
- package/dist/es2017/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
- package/dist/es2017/core/segment_buffers/garbage_collector.js +1 -2
- package/dist/es2017/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
- package/dist/es2017/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
- package/dist/es2017/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
- package/dist/es2017/core/segment_buffers/index.d.ts +2 -2
- package/dist/es2017/core/segment_buffers/inventory/index.d.ts +2 -2
- package/dist/es2017/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
- package/dist/es2017/core/segment_buffers/inventory/segment_inventory.js +19 -10
- package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
- package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
- package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +16 -18
- package/dist/es2017/core/stream/period/period_stream.js +4 -7
- package/dist/es2017/core/stream/period/types.d.ts +2 -3
- package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
- package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
- package/dist/es2017/core/stream/representation/representation_stream.js +3 -4
- package/dist/es2017/core/stream/representation/types.d.ts +2 -2
- package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +1 -2
- package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +1 -1
- package/dist/es2017/default_config.d.ts +7 -16
- package/dist/es2017/default_config.js +16 -16
- package/dist/es2017/manifest/adaptation.js +2 -1
- package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/es2017/public_types.d.ts +29 -2
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +614 -438
- package/dist/rx-player.min.js +1 -1
- package/package.json +5 -1
- package/scripts/canal-release.patch +78 -0
- package/scripts/make-dev-releases +65 -0
- package/scripts/update-version +5 -0
- package/sonar-project.properties +1 -1
- package/src/core/adaptive/adaptive_representation_selector.ts +4 -21
- package/src/core/adaptive/network_analyzer.ts +3 -3
- package/src/core/api/index.ts +1 -0
- package/src/core/api/playback_observer.ts +327 -107
- package/src/core/api/public_api.ts +9 -9
- package/src/core/api/utils.ts +3 -1
- package/src/core/decrypt/get_media_keys.ts +2 -8
- package/src/core/init/directfile_content_initializer.ts +8 -8
- package/src/core/init/media_source_content_initializer.ts +27 -20
- package/src/core/init/utils/content_time_boundaries_observer.ts +1 -1
- package/src/core/init/utils/create_stream_playback_observer.ts +19 -20
- package/src/core/init/utils/initial_seek_and_play.ts +140 -108
- package/src/core/init/utils/rebuffering_controller.ts +32 -77
- package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +5 -2
- package/src/core/segment_buffers/garbage_collector.ts +1 -1
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +10 -2
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +1 -1
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +1 -1
- package/src/core/segment_buffers/index.ts +2 -0
- package/src/core/segment_buffers/inventory/index.ts +2 -0
- package/src/core/segment_buffers/inventory/segment_inventory.ts +49 -17
- package/src/core/stream/adaptation/get_representations_switch_strategy.ts +21 -12
- package/src/core/stream/orchestrator/stream_orchestrator.ts +14 -19
- package/src/core/stream/period/period_stream.ts +7 -8
- package/src/core/stream/period/types.ts +2 -3
- package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +21 -15
- package/src/core/stream/representation/representation_stream.ts +3 -5
- package/src/core/stream/representation/types.ts +2 -2
- package/src/core/stream/representation/utils/append_segment_to_buffer.ts +1 -1
- package/src/core/stream/representation/utils/get_buffer_status.ts +2 -1
- package/src/default_config.ts +17 -17
- package/src/manifest/adaptation.ts +2 -1
- package/src/parsers/texttracks/ttml/html/apply_line_height.ts +3 -1
- package/src/public_types.ts +29 -2
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +0 -84
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +0 -158
- package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +0 -406
- package/dist/_esm5.processed/core/api/track_management/tracks_store.js +0 -932
- package/dist/_esm5.processed/core/segment_buffers/inventory/utils.d.ts +0 -33
- package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +0 -49
- package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.d.ts +0 -39
- package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +0 -133
- package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +0 -119
- package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +0 -159
|
@@ -221,18 +221,15 @@ export default function PeriodStream(
|
|
|
221
221
|
return; // Previous call has provoken cancellation by side-effect
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
const readyState = playbackObserver.getReadyState();
|
|
225
224
|
const segmentBuffer = createOrReuseSegmentBuffer(segmentBuffersStore,
|
|
226
225
|
bufferType,
|
|
227
226
|
adaptation,
|
|
228
227
|
options);
|
|
229
|
-
const playbackInfos = { currentTime: playbackObserver.getCurrentTime(),
|
|
230
|
-
readyState };
|
|
231
228
|
const strategy = getAdaptationSwitchStrategy(segmentBuffer,
|
|
232
229
|
period,
|
|
233
230
|
adaptation,
|
|
234
231
|
choice.switchingMode,
|
|
235
|
-
|
|
232
|
+
playbackObserver,
|
|
236
233
|
options);
|
|
237
234
|
if (strategy.type === "needs-reload") {
|
|
238
235
|
return askForMediaSourceReload(relativePosAfterSwitch,
|
|
@@ -444,8 +441,10 @@ function createAdaptationStreamPlaybackObserver(
|
|
|
444
441
|
) : IAdaptationStreamPlaybackObservation {
|
|
445
442
|
const baseObservation = observationRef.getValue();
|
|
446
443
|
const buffered = segmentBuffer.getBufferedRanges();
|
|
447
|
-
const bufferGap = getLeftSizeOfBufferedTimeRange(
|
|
448
|
-
|
|
444
|
+
const bufferGap = getLeftSizeOfBufferedTimeRange(
|
|
445
|
+
buffered,
|
|
446
|
+
baseObservation.position.getWanted()
|
|
447
|
+
);
|
|
449
448
|
return objectAssign({}, baseObservation, { bufferGap });
|
|
450
449
|
}
|
|
451
450
|
|
|
@@ -486,15 +485,15 @@ function createEmptyAdaptationStream(
|
|
|
486
485
|
function sendStatus() : void {
|
|
487
486
|
const observation = playbackObserver.getReference().getValue();
|
|
488
487
|
const wba = wantedBufferAhead.getValue();
|
|
489
|
-
const position = observation.position.
|
|
488
|
+
const position = observation.position.getWanted();
|
|
490
489
|
if (period.end !== undefined && position + wba >= period.end) {
|
|
491
490
|
log.debug("Stream: full \"empty\" AdaptationStream", bufferType);
|
|
492
491
|
hasFinishedLoading = true;
|
|
493
492
|
}
|
|
494
493
|
callbacks.streamStatusUpdate({ period,
|
|
495
494
|
bufferType,
|
|
496
|
-
position,
|
|
497
495
|
imminentDiscontinuity: null,
|
|
496
|
+
position,
|
|
498
497
|
isEmptyStream: true,
|
|
499
498
|
hasFinishedLoading,
|
|
500
499
|
neededSegments: [] });
|
|
@@ -8,7 +8,7 @@ import SharedReference, {
|
|
|
8
8
|
import { CancellationSignal } from "../../../utils/task_canceller";
|
|
9
9
|
import WeakMapMemory from "../../../utils/weak_map_memory";
|
|
10
10
|
import { IRepresentationEstimator } from "../../adaptive";
|
|
11
|
-
import { IReadOnlyPlaybackObserver } from "../../api";
|
|
11
|
+
import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
|
|
12
12
|
import { SegmentFetcherCreator } from "../../fetchers";
|
|
13
13
|
import SegmentBuffersStore, {
|
|
14
14
|
IBufferType,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
IAdaptationStreamOptions,
|
|
22
22
|
IPausedPlaybackObservation,
|
|
23
23
|
} from "../adaptation";
|
|
24
|
-
import { IPositionPlaybackObservation } from "../representation";
|
|
25
24
|
|
|
26
25
|
/** Callbacks called by the `AdaptationStream` on various events. */
|
|
27
26
|
export interface IPeriodStreamCallbacks extends
|
|
@@ -86,7 +85,7 @@ export interface IPeriodStreamPlaybackObservation {
|
|
|
86
85
|
* Information on the current media position in seconds at the time of the
|
|
87
86
|
* Observation.
|
|
88
87
|
*/
|
|
89
|
-
position :
|
|
88
|
+
position : IObservationPosition;
|
|
90
89
|
/** `duration` property of the HTMLMediaElement. */
|
|
91
90
|
duration : number;
|
|
92
91
|
/** `readyState` property of the HTMLMediaElement. */
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
isTimeInRanges,
|
|
29
29
|
keepRangeIntersection,
|
|
30
30
|
} from "../../../../utils/ranges";
|
|
31
|
+
import { IReadOnlyPlaybackObserver } from "../../../api";
|
|
31
32
|
import {
|
|
32
33
|
getFirstSegmentAfterPeriod,
|
|
33
34
|
getLastSegmentBeforePeriod,
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
SegmentBuffer,
|
|
36
37
|
} from "../../../segment_buffers";
|
|
37
38
|
import { ITrackSwitchingMode } from "../../adaptation";
|
|
39
|
+
import { IPeriodStreamPlaybackObservation } from "../types";
|
|
38
40
|
|
|
39
41
|
export type IAdaptationSwitchStrategy =
|
|
40
42
|
/** Do nothing special. */
|
|
@@ -63,7 +65,7 @@ export interface IAdaptationSwitchOptions {
|
|
|
63
65
|
* @param {Object} segmentBuffer
|
|
64
66
|
* @param {Object} period
|
|
65
67
|
* @param {Object} adaptation
|
|
66
|
-
* @param {Object}
|
|
68
|
+
* @param {Object} playbackObserver
|
|
67
69
|
* @returns {Object}
|
|
68
70
|
*/
|
|
69
71
|
export default function getAdaptationSwitchStrategy(
|
|
@@ -71,7 +73,9 @@ export default function getAdaptationSwitchStrategy(
|
|
|
71
73
|
period : Period,
|
|
72
74
|
adaptation : Adaptation,
|
|
73
75
|
switchingMode : ITrackSwitchingMode,
|
|
74
|
-
|
|
76
|
+
playbackObserver : IReadOnlyPlaybackObserver<
|
|
77
|
+
IPeriodStreamPlaybackObservation
|
|
78
|
+
>,
|
|
75
79
|
options : IAdaptationSwitchOptions
|
|
76
80
|
) : IAdaptationSwitchStrategy {
|
|
77
81
|
if (segmentBuffer.codec !== undefined &&
|
|
@@ -119,18 +123,20 @@ export default function getAdaptationSwitchStrategy(
|
|
|
119
123
|
return { type: "continue", value: undefined };
|
|
120
124
|
}
|
|
121
125
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
const currentTime = playbackObserver.getCurrentTime();
|
|
127
|
+
const readyState = playbackObserver.getReadyState();
|
|
128
|
+
if (switchingMode === "reload" && readyState > 1) {
|
|
129
|
+
const lastObservation = playbackObserver.getReference().getValue();
|
|
130
|
+
if (lastObservation.position.isAwaitingFuturePosition()) {
|
|
131
|
+
// We are not at the position we want to reach (e.g. initial seek, tizen
|
|
132
|
+
// seek-back...), just reload as checks here would be too complex
|
|
133
|
+
return { type: "needs-reload", value: undefined };
|
|
134
|
+
} else if (isTimeInRange({ start, end }, currentTime) &&
|
|
135
|
+
// We're not playing the current wanted video Adaptation
|
|
136
|
+
!isTimeInRanges(adaptationInBuffer, currentTime))
|
|
137
|
+
{
|
|
138
|
+
return { type: "needs-reload", value: undefined };
|
|
139
|
+
}
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
// From here, clean-up data from the previous Adaptation, if one
|
|
@@ -216,7 +222,7 @@ function hasCompatibleCodec(
|
|
|
216
222
|
/**
|
|
217
223
|
* Returns buffered ranges of what we know correspond to the given `adaptation`
|
|
218
224
|
* in the SegmentBuffer.
|
|
219
|
-
* @param {Object}
|
|
225
|
+
* @param {Array.<Object>} inventory
|
|
220
226
|
* @param {Object} period
|
|
221
227
|
* @param {Object} adaptation
|
|
222
228
|
* @returns {Array.<Object>}
|
|
@@ -230,8 +230,7 @@ export default function RepresentationStream<TSegmentDataType>(
|
|
|
230
230
|
return ; // Stop all buffer status checking if load operations are stopped
|
|
231
231
|
}
|
|
232
232
|
const observation = playbackObserver.getReference().getValue();
|
|
233
|
-
const initialWantedTime = observation.position.
|
|
234
|
-
observation.position.last;
|
|
233
|
+
const initialWantedTime = observation.position.getWanted();
|
|
235
234
|
const status = getBufferStatus(content,
|
|
236
235
|
initialWantedTime,
|
|
237
236
|
playbackObserver,
|
|
@@ -251,8 +250,7 @@ export default function RepresentationStream<TSegmentDataType>(
|
|
|
251
250
|
log.warn("Stream: Uninitialized index with an already loaded " +
|
|
252
251
|
"initialization segment");
|
|
253
252
|
} else {
|
|
254
|
-
const wantedStart = observation.position.
|
|
255
|
-
observation.position.last;
|
|
253
|
+
const wantedStart = observation.position.getWanted();
|
|
256
254
|
neededInitSegment = { segment: initSegmentState.segment,
|
|
257
255
|
priority: getSegmentPriority(period.start,
|
|
258
256
|
wantedStart) };
|
|
@@ -307,7 +305,7 @@ export default function RepresentationStream<TSegmentDataType>(
|
|
|
307
305
|
}
|
|
308
306
|
|
|
309
307
|
callbacks.streamStatusUpdate({ period,
|
|
310
|
-
position: observation.position.
|
|
308
|
+
position: observation.position.getWanted(),
|
|
311
309
|
bufferType,
|
|
312
310
|
imminentDiscontinuity: status.imminentDiscontinuity,
|
|
313
311
|
isEmptyStream: false,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
IVideoRepresentationsSwitchingMode,
|
|
12
12
|
} from "../../../public_types";
|
|
13
13
|
import { IReadOnlySharedReference } from "../../../utils/reference";
|
|
14
|
-
import { IReadOnlyPlaybackObserver } from "../../api";
|
|
14
|
+
import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
|
|
15
15
|
import { IContentProtection } from "../../decrypt";
|
|
16
16
|
import { IPrioritizedSegmentFetcher } from "../../fetchers";
|
|
17
17
|
import {
|
|
@@ -180,7 +180,7 @@ export interface IRepresentationStreamPlaybackObservation {
|
|
|
180
180
|
* Information on the current media position in seconds at the time of a
|
|
181
181
|
* Playback Observation.
|
|
182
182
|
*/
|
|
183
|
-
position :
|
|
183
|
+
position : IObservationPosition;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/** Position-related information linked to an emitted Playback observation. */
|
|
@@ -61,7 +61,7 @@ export default async function appendSegmentToBuffer<T>(
|
|
|
61
61
|
{ adaptations: [dataInfos.inventoryInfos.adaptation] });
|
|
62
62
|
}
|
|
63
63
|
const { position } = playbackObserver.getReference().getValue();
|
|
64
|
-
const currentPos = position.
|
|
64
|
+
const currentPos = position.getWanted();
|
|
65
65
|
try {
|
|
66
66
|
await forceGarbageCollection(currentPos, segmentBuffer, cancellationSignal);
|
|
67
67
|
await segmentBuffer.pushChunk(dataInfos, cancellationSignal);
|
|
@@ -23,6 +23,7 @@ import Manifest, {
|
|
|
23
23
|
import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
|
|
24
24
|
import { IReadOnlyPlaybackObserver } from "../../../api";
|
|
25
25
|
import SegmentBuffersStore, {
|
|
26
|
+
ChunkStatus,
|
|
26
27
|
IBufferedChunk,
|
|
27
28
|
IEndOfSegmentOperation,
|
|
28
29
|
SegmentBuffer,
|
|
@@ -299,7 +300,7 @@ function getPlayableBufferedSegments(
|
|
|
299
300
|
const eltInventory = segmentInventory[i];
|
|
300
301
|
|
|
301
302
|
const { representation } = eltInventory.infos;
|
|
302
|
-
if (
|
|
303
|
+
if (eltInventory.status === ChunkStatus.Complete &&
|
|
303
304
|
representation.decipherable !== false &&
|
|
304
305
|
representation.isSupported)
|
|
305
306
|
{
|
package/src/default_config.ts
CHANGED
|
@@ -163,6 +163,23 @@ const DEFAULT_CONFIG = {
|
|
|
163
163
|
} as Partial<Record<"audio"|"video"|"text", number>>,
|
|
164
164
|
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
165
165
|
|
|
166
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
167
|
+
/**
|
|
168
|
+
* Minimum possible buffer ahead for each type of buffer, to avoid Garbage
|
|
169
|
+
* Collecting too much data when it would have adverse effects.
|
|
170
|
+
* Equal to `0` if not defined here.
|
|
171
|
+
* @type {Object}
|
|
172
|
+
*/
|
|
173
|
+
MINIMUM_MAX_BUFFER_AHEAD: {
|
|
174
|
+
// Text segments are both much lighter on resources and might
|
|
175
|
+
// actually be much larger than other types of segments in terms
|
|
176
|
+
// of duration. Let's make an exception here by authorizing a
|
|
177
|
+
// larger text buffer ahead, to avoid unnecesarily reloading the
|
|
178
|
+
// same text track.
|
|
179
|
+
text: 2 * 60,
|
|
180
|
+
} as Partial<Record<"audio"|"video"|"image"|"text", number>>,
|
|
181
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
182
|
+
|
|
166
183
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
167
184
|
/**
|
|
168
185
|
* Maximum possible buffer behind for each type of buffer, to avoid too much
|
|
@@ -236,23 +253,6 @@ const DEFAULT_CONFIG = {
|
|
|
236
253
|
*/
|
|
237
254
|
BUFFER_DISCONTINUITY_THRESHOLD: 0.2,
|
|
238
255
|
|
|
239
|
-
/**
|
|
240
|
-
* When encountering small discontinuities, the RxPlayer may want, in specific
|
|
241
|
-
* conditions, ignore those and let the browser seek over them iself (this
|
|
242
|
-
* allows for example to avoid conflicts when both the browser and the
|
|
243
|
-
* RxPlayer want to seek at a different position, sometimes leading to a
|
|
244
|
-
* seeking loop).
|
|
245
|
-
* In this case, we however still want to seek it ourselves if the browser
|
|
246
|
-
* doesn't take the opportunity soon enough.
|
|
247
|
-
*
|
|
248
|
-
* This value specifies a delay after which a discontinuity ignored by the
|
|
249
|
-
* RxPlayer is finally considered.
|
|
250
|
-
* We want to maintain high enough to be sure the browser will not seek yet
|
|
251
|
-
* small enough so this (arguably rare) situation won't lead to too much
|
|
252
|
-
* waiting time.
|
|
253
|
-
*/
|
|
254
|
-
FORCE_DISCONTINUITY_SEEK_DELAY: 5000,
|
|
255
|
-
|
|
256
256
|
/**
|
|
257
257
|
* Ratio used to know if an already loaded segment should be re-buffered.
|
|
258
258
|
* We re-load the given segment if the current one times that ratio is
|
|
@@ -157,7 +157,8 @@ export default class Adaptation {
|
|
|
157
157
|
const reprObject : IRepresentationFilterRepresentation = {
|
|
158
158
|
id: representation.id,
|
|
159
159
|
bitrate: representation.bitrate,
|
|
160
|
-
|
|
160
|
+
codecs: representation.codec === undefined ? [] :
|
|
161
|
+
[representation.codec],
|
|
161
162
|
height: representation.height,
|
|
162
163
|
width: representation.width,
|
|
163
164
|
frameRate: representation.frameRate,
|
|
@@ -27,10 +27,12 @@ export default function applyLineHeight(
|
|
|
27
27
|
lineHeight : string
|
|
28
28
|
) : void {
|
|
29
29
|
const trimmedLineHeight = lineHeight.trim();
|
|
30
|
+
const splittedLineHeight = trimmedLineHeight.split(" ");
|
|
31
|
+
|
|
30
32
|
if (trimmedLineHeight === "auto") {
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
const firstLineHeight = REGXP_LENGTH.exec(
|
|
35
|
+
const firstLineHeight = REGXP_LENGTH.exec(splittedLineHeight[0]);
|
|
34
36
|
if (firstLineHeight === null) {
|
|
35
37
|
return;
|
|
36
38
|
}
|
package/src/public_types.ts
CHANGED
|
@@ -186,8 +186,35 @@ export interface IRepresentationFilterRepresentation {
|
|
|
186
186
|
/** String identifying the Representation, unique per Adaptation. */
|
|
187
187
|
id : string;
|
|
188
188
|
bitrate? : number | undefined;
|
|
189
|
-
/**
|
|
190
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Codec(s) relied on by the media segments of that Representation.
|
|
191
|
+
*
|
|
192
|
+
* For the great majority of cases, this value will be set to either
|
|
193
|
+
* `undefined` (meaning the codec is unknown) or to an array with a
|
|
194
|
+
* single element which will be the actual codec relied on when the
|
|
195
|
+
* corresponding Representation will be played.
|
|
196
|
+
*
|
|
197
|
+
* However in some very rare scenarios, this value might be set to an array
|
|
198
|
+
* with multiple codecs, itself being a list of its candidate codecs from the
|
|
199
|
+
* most wanted to the most compatible.
|
|
200
|
+
* The conditions for this more complex format are very specific:
|
|
201
|
+
*
|
|
202
|
+
* - It can only happen if the `representationFilter` callback is called in
|
|
203
|
+
* an environment where it hasn't yet been possible for the RxPlayer to
|
|
204
|
+
* check for codec support (mainly when running through the RxPlayer's
|
|
205
|
+
* `MULTI_THREAD` feature in a browser without MSE-in-worker
|
|
206
|
+
* capabilities).
|
|
207
|
+
*
|
|
208
|
+
* - The corresponding Representation is compatible to a restrictive codec
|
|
209
|
+
* yet also retro-compatible to a less restrictive one.
|
|
210
|
+
*
|
|
211
|
+
* The main example being Dolby Vision Representations which are
|
|
212
|
+
* retro-compatible to HDR10 HEVC codecs.
|
|
213
|
+
* In that very specific case, we could have an array with two elements:
|
|
214
|
+
* 1. The Dolby Vision codec
|
|
215
|
+
* 2. The base HDR10 codec
|
|
216
|
+
*/
|
|
217
|
+
codecs? : string[] | undefined;
|
|
191
218
|
/**
|
|
192
219
|
* This property makes the most sense for video Representations.
|
|
193
220
|
* It defines the height of the video, in pixels.
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import Manifest, { Adaptation } from "../../../manifest";
|
|
2
|
-
import EventEmitter from "../../../utils/event_emitter";
|
|
3
|
-
import SharedReference, { IReadOnlySharedReference } from "../../../utils/reference";
|
|
4
|
-
import { IAdaptationChoice, IRepresentationsChoice, ITrackSwitchingMode } from "../../stream";
|
|
5
|
-
/**
|
|
6
|
-
* Class handling track changes and quality locking for a single Period and
|
|
7
|
-
* Adaptation type.
|
|
8
|
-
* @class TrackDispatcher
|
|
9
|
-
*/
|
|
10
|
-
export default class TrackDispatcher extends EventEmitter<ITrackDispatcherEvent> {
|
|
11
|
-
/**
|
|
12
|
-
* `Manifest` object linked to the current content handled by the
|
|
13
|
-
* `TrackDispatcher`.
|
|
14
|
-
* Needed to subscribe to various events.
|
|
15
|
-
*/
|
|
16
|
-
private readonly _manifest;
|
|
17
|
-
/**
|
|
18
|
-
* Reference through which the wanted track will be emitted.
|
|
19
|
-
* `null` is emitted if no track for that type is wanted.
|
|
20
|
-
*/
|
|
21
|
-
private readonly _adaptationRef;
|
|
22
|
-
/**
|
|
23
|
-
* Last values emitted through `adaptationRef`.
|
|
24
|
-
* This value is mutated just before `adaptationRef` is "nexted".
|
|
25
|
-
*
|
|
26
|
-
* Storing this information allows to detect if some potential
|
|
27
|
-
* side-effects already led to the "nexting" of `adaptationRef` with the wanted
|
|
28
|
-
* settings, preventing the the `TrackDispatcher` from doing it again.
|
|
29
|
-
*/
|
|
30
|
-
private _lastEmitted;
|
|
31
|
-
/** Interface allowing to clean-up resources when they are not needed anymore. */
|
|
32
|
-
private _canceller;
|
|
33
|
-
/**
|
|
34
|
-
* Create a new `TrackDispatcher` by giving its Reference and an initial track
|
|
35
|
-
* setting.
|
|
36
|
-
* This constructor will update the Reference with the right preferences
|
|
37
|
-
* synchronously.
|
|
38
|
-
* @param {Object} manifest
|
|
39
|
-
* @param {Object} adaptationRef
|
|
40
|
-
* @param {Object|null} initialTrackInfo
|
|
41
|
-
*/
|
|
42
|
-
constructor(manifest: Manifest, adaptationRef: SharedReference<IAdaptationChoice | null | undefined>, initialTrackInfo: ITrackSetting | null);
|
|
43
|
-
/**
|
|
44
|
-
* Update the wanted track on the Reference linked to this `TrackDispatcher`.
|
|
45
|
-
* @param {Object|null} newTrackInfo
|
|
46
|
-
*/
|
|
47
|
-
updateTrack(newTrackInfo: ITrackSetting | null): void;
|
|
48
|
-
/**
|
|
49
|
-
* Create a shared reference which will emit the wanted locked Representations
|
|
50
|
-
* based on the current capabilities and the last user settings.
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} trackInfo
|
|
53
|
-
* @returns {Object}
|
|
54
|
-
*/
|
|
55
|
-
private _constructLockedRepresentationsReference;
|
|
56
|
-
/**
|
|
57
|
-
* Free the resources (e.g. `Manifest` event listeners) linked to this
|
|
58
|
-
* `TrackDispatcher`.
|
|
59
|
-
*/
|
|
60
|
-
dispose(): void;
|
|
61
|
-
}
|
|
62
|
-
export interface ITrackDispatcherEvent {
|
|
63
|
-
/**
|
|
64
|
-
* Event sent when given locked Representations cannot be respected because
|
|
65
|
-
* none of them are currently "playable".
|
|
66
|
-
*/
|
|
67
|
-
noPlayableLockedRepresentation: null;
|
|
68
|
-
}
|
|
69
|
-
/** Define a new Track preference given to the `TrackDispatcher`. */
|
|
70
|
-
export interface ITrackSetting {
|
|
71
|
-
/** Contains the `Adaptation` wanted by the user. */
|
|
72
|
-
adaptation: Adaptation;
|
|
73
|
-
/** "Switching mode" in which the track switch should happen. */
|
|
74
|
-
switchingMode: ITrackSwitchingMode;
|
|
75
|
-
/**
|
|
76
|
-
* Contains the last locked `Representation`s for this `Adaptation` wanted
|
|
77
|
-
* by the user.
|
|
78
|
-
* `null` if no Representation is locked.
|
|
79
|
-
*
|
|
80
|
-
* Can be updated continuously while the `TrackDispatcher` is in possession
|
|
81
|
-
* of this shared reference.
|
|
82
|
-
*/
|
|
83
|
-
lockedRepresentations: IReadOnlySharedReference<IRepresentationsChoice | null>;
|
|
84
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
import { MediaError } from "../../../errors";
|
|
17
|
-
import EventEmitter from "../../../utils/event_emitter";
|
|
18
|
-
import SharedReference from "../../../utils/reference";
|
|
19
|
-
import TaskCanceller from "../../../utils/task_canceller";
|
|
20
|
-
/**
|
|
21
|
-
* Class handling track changes and quality locking for a single Period and
|
|
22
|
-
* Adaptation type.
|
|
23
|
-
* @class TrackDispatcher
|
|
24
|
-
*/
|
|
25
|
-
var TrackDispatcher = /** @class */ (function (_super) {
|
|
26
|
-
__extends(TrackDispatcher, _super);
|
|
27
|
-
/**
|
|
28
|
-
* Create a new `TrackDispatcher` by giving its Reference and an initial track
|
|
29
|
-
* setting.
|
|
30
|
-
* This constructor will update the Reference with the right preferences
|
|
31
|
-
* synchronously.
|
|
32
|
-
* @param {Object} manifest
|
|
33
|
-
* @param {Object} adaptationRef
|
|
34
|
-
* @param {Object|null} initialTrackInfo
|
|
35
|
-
*/
|
|
36
|
-
function TrackDispatcher(manifest, adaptationRef, initialTrackInfo) {
|
|
37
|
-
var _this = _super.call(this) || this;
|
|
38
|
-
_this._canceller = new TaskCanceller();
|
|
39
|
-
_this._manifest = manifest;
|
|
40
|
-
_this._adaptationRef = adaptationRef;
|
|
41
|
-
if (initialTrackInfo === null) {
|
|
42
|
-
_this._lastEmitted = initialTrackInfo;
|
|
43
|
-
adaptationRef.setValue(null);
|
|
44
|
-
return _this;
|
|
45
|
-
}
|
|
46
|
-
var reference = _this._constructLockedRepresentationsReference(initialTrackInfo);
|
|
47
|
-
_this._lastEmitted = { adaptation: initialTrackInfo.adaptation,
|
|
48
|
-
switchingMode: initialTrackInfo.switchingMode,
|
|
49
|
-
lockedRepresentations: null };
|
|
50
|
-
adaptationRef.setValue({ adaptation: initialTrackInfo.adaptation,
|
|
51
|
-
switchingMode: initialTrackInfo.switchingMode,
|
|
52
|
-
representations: reference });
|
|
53
|
-
return _this;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Update the wanted track on the Reference linked to this `TrackDispatcher`.
|
|
57
|
-
* @param {Object|null} newTrackInfo
|
|
58
|
-
*/
|
|
59
|
-
TrackDispatcher.prototype.updateTrack = function (newTrackInfo) {
|
|
60
|
-
if (newTrackInfo === null) {
|
|
61
|
-
if (this._lastEmitted === null) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this._canceller.cancel();
|
|
65
|
-
// has no point but let's still create one for simplicity sake
|
|
66
|
-
this._canceller = new TaskCanceller();
|
|
67
|
-
this._lastEmitted = null;
|
|
68
|
-
this._adaptationRef.setValue(null);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
var adaptation = newTrackInfo.adaptation, switchingMode = newTrackInfo.switchingMode;
|
|
72
|
-
this._canceller.cancel();
|
|
73
|
-
this._canceller = new TaskCanceller();
|
|
74
|
-
var reference = this._constructLockedRepresentationsReference(newTrackInfo);
|
|
75
|
-
this._lastEmitted = { adaptation: adaptation, switchingMode: switchingMode, lockedRepresentations: null };
|
|
76
|
-
this._adaptationRef.setValue({ adaptation: adaptation, switchingMode: switchingMode, representations: reference });
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Create a shared reference which will emit the wanted locked Representations
|
|
80
|
-
* based on the current capabilities and the last user settings.
|
|
81
|
-
*
|
|
82
|
-
* @param {Object} trackInfo
|
|
83
|
-
* @returns {Object}
|
|
84
|
-
*/
|
|
85
|
-
TrackDispatcher.prototype._constructLockedRepresentationsReference = function (trackInfo) {
|
|
86
|
-
var manifest = this._manifest;
|
|
87
|
-
/* Initialize it. Will be at its true value at the end of the function. */
|
|
88
|
-
var reference = new SharedReference({
|
|
89
|
-
representations: [],
|
|
90
|
-
switchingMode: "lazy",
|
|
91
|
-
});
|
|
92
|
-
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
|
93
|
-
var self = this;
|
|
94
|
-
manifest.addEventListener("decipherabilityUpdate", updateReferenceIfNeeded);
|
|
95
|
-
manifest.addEventListener("manifestUpdate", updateReferenceIfNeeded);
|
|
96
|
-
this._canceller.signal.register(removeListeners);
|
|
97
|
-
trackInfo.lockedRepresentations.onUpdate(updateReferenceIfNeeded, {
|
|
98
|
-
clearSignal: this._canceller.signal,
|
|
99
|
-
emitCurrentValue: false,
|
|
100
|
-
});
|
|
101
|
-
updateReferenceIfNeeded();
|
|
102
|
-
return reference;
|
|
103
|
-
function updateReferenceIfNeeded() {
|
|
104
|
-
var repSettings = trackInfo.lockedRepresentations.getValue();
|
|
105
|
-
var switchingMode;
|
|
106
|
-
/** Representations for which a `RepresentationStream` can be created. */
|
|
107
|
-
var playableRepresentations;
|
|
108
|
-
if (repSettings === null) { // unlocking
|
|
109
|
-
playableRepresentations = trackInfo.adaptation.getPlayableRepresentations();
|
|
110
|
-
// No need to remove the previous content when unlocking
|
|
111
|
-
switchingMode = "lazy";
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
var representations = repSettings.representations;
|
|
115
|
-
switchingMode = repSettings.switchingMode;
|
|
116
|
-
playableRepresentations = representations.filter(function (r) { return r.isPlayable(); });
|
|
117
|
-
if (playableRepresentations.length === 0) {
|
|
118
|
-
self.trigger("noPlayableLockedRepresentation", null);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (playableRepresentations.length <= 0) {
|
|
123
|
-
var adaptationType = trackInfo.adaptation.type;
|
|
124
|
-
var noRepErr = new MediaError("NO_PLAYABLE_REPRESENTATION", "No Representation in the chosen " +
|
|
125
|
-
adaptationType + " Adaptation can be played", { adaptation: trackInfo.adaptation });
|
|
126
|
-
throw noRepErr;
|
|
127
|
-
}
|
|
128
|
-
// Check if Locked Representations have changed
|
|
129
|
-
var oldRef = reference.getValue();
|
|
130
|
-
var sortedReps = playableRepresentations.slice().sort();
|
|
131
|
-
if (sortedReps.length !== oldRef.representations.length) {
|
|
132
|
-
reference.setValue({ representations: sortedReps, switchingMode: switchingMode });
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
for (var i = 0; i < sortedReps.length; i++) {
|
|
136
|
-
if (oldRef.representations[i].id !== sortedReps[i].id) {
|
|
137
|
-
reference.setValue({ representations: sortedReps, switchingMode: switchingMode });
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function removeListeners() {
|
|
143
|
-
manifest.removeEventListener("decipherabilityUpdate", updateReferenceIfNeeded);
|
|
144
|
-
manifest.removeEventListener("manifestUpdate", updateReferenceIfNeeded);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Free the resources (e.g. `Manifest` event listeners) linked to this
|
|
149
|
-
* `TrackDispatcher`.
|
|
150
|
-
*/
|
|
151
|
-
TrackDispatcher.prototype.dispose = function () {
|
|
152
|
-
this.removeEventListener();
|
|
153
|
-
this._canceller.cancel();
|
|
154
|
-
this._adaptationRef.finish();
|
|
155
|
-
};
|
|
156
|
-
return TrackDispatcher;
|
|
157
|
-
}(EventEmitter));
|
|
158
|
-
export default TrackDispatcher;
|