rx-player 4.0.0-dev.2023111400 → 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 +20 -60
- package/FILES.md +1 -1
- package/README.md +2 -33
- package/VERSION +1 -1
- package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
- package/dist/_esm5.processed/core/api/debug/modules/general_info.js +20 -10
- package/dist/_esm5.processed/core/api/option_utils.d.ts +0 -2
- package/dist/_esm5.processed/core/api/option_utils.js +0 -6
- package/dist/_esm5.processed/core/api/public_api.d.ts +1 -2
- package/dist/_esm5.processed/core/api/public_api.js +9 -17
- package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +3 -14
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
- 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.js +1 -1
- 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.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +2 -2
- 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/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/parsers/texttracks/ttml/html/apply_extent.js +1 -8
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
- package/dist/_esm5.processed/public_types.d.ts +2 -0
- package/dist/commonjs/compat/is_codec_supported.js +22 -1
- package/dist/commonjs/config.d.ts +2 -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/debug/buffer_graph.js +2 -6
- package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
- package/dist/commonjs/core/api/index.d.ts +1 -1
- package/dist/commonjs/core/api/option_utils.d.ts +2 -0
- package/dist/commonjs/core/api/option_utils.js +2 -3
- 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.d.ts +9 -0
- package/dist/commonjs/core/api/public_api.js +41 -16
- package/dist/commonjs/core/api/utils.js +1 -1
- package/dist/commonjs/core/decrypt/get_media_keys.js +2 -6
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
- package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
- package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
- package/dist/commonjs/core/init/directfile_content_initializer.js +29 -8
- package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
- package/dist/commonjs/core/init/media_source_content_initializer.js +32 -20
- package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
- package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +17 -19
- 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/get_initial_time.d.ts +17 -3
- package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
- 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 +4 -4
- package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/commonjs/default_config.d.ts +12 -16
- package/dist/commonjs/default_config.js +21 -16
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
- package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
- package/dist/commonjs/manifest/adaptation.js +2 -1
- package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
- package/dist/commonjs/manifest/representation_index/static.js +2 -2
- package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
- package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
- package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
- package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
- package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
- package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
- package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
- package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
- package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
- package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +7 -3
- package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
- package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
- package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
- package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
- package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
- package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/commonjs/public_types.d.ts +107 -36
- package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
- package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
- package/dist/commonjs/transports/dash/segment_loader.js +2 -1
- package/dist/commonjs/transports/dash/text_loader.js +2 -0
- package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
- package/dist/commonjs/transports/smooth/pipelines.js +4 -2
- package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
- package/dist/commonjs/transports/types.d.ts +12 -0
- package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
- package/dist/commonjs/utils/request/fetch.d.ts +6 -0
- package/dist/commonjs/utils/request/fetch.js +29 -8
- package/dist/commonjs/utils/request/xhr.d.ts +11 -5
- package/dist/commonjs/utils/request/xhr.js +29 -8
- package/dist/es2017/compat/is_codec_supported.js +22 -1
- package/dist/es2017/config.d.ts +2 -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/debug/buffer_graph.js +2 -6
- package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
- package/dist/es2017/core/api/index.d.ts +1 -1
- package/dist/es2017/core/api/option_utils.d.ts +2 -0
- package/dist/es2017/core/api/option_utils.js +2 -3
- 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.d.ts +9 -0
- package/dist/es2017/core/api/public_api.js +40 -15
- package/dist/es2017/core/api/utils.js +1 -1
- package/dist/es2017/core/decrypt/get_media_keys.js +2 -6
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
- package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
- package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
- package/dist/es2017/core/init/directfile_content_initializer.js +31 -8
- package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
- package/dist/es2017/core/init/media_source_content_initializer.js +34 -22
- package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
- package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +17 -17
- 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/get_initial_time.d.ts +17 -3
- package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
- 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 +4 -4
- package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
- package/dist/es2017/default_config.d.ts +12 -16
- package/dist/es2017/default_config.js +21 -16
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
- package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
- package/dist/es2017/manifest/adaptation.js +2 -1
- package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
- package/dist/es2017/manifest/representation_index/static.js +2 -2
- package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
- package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
- package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
- package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
- package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
- package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
- package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
- package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
- package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +7 -3
- package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
- package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
- package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
- package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
- package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
- package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
- package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
- package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
- package/dist/es2017/public_types.d.ts +107 -36
- package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
- package/dist/es2017/transports/dash/manifest_parser.js +3 -0
- package/dist/es2017/transports/dash/segment_loader.js +1 -0
- package/dist/es2017/transports/dash/text_loader.js +2 -0
- package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
- package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
- package/dist/es2017/transports/smooth/pipelines.js +2 -0
- package/dist/es2017/transports/smooth/segment_loader.js +1 -0
- package/dist/es2017/transports/types.d.ts +12 -0
- package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
- package/dist/es2017/utils/request/fetch.d.ts +6 -0
- package/dist/es2017/utils/request/fetch.js +29 -8
- package/dist/es2017/utils/request/xhr.d.ts +11 -5
- package/dist/es2017/utils/request/xhr.js +30 -9
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +1335 -812
- package/dist/rx-player.min.js +1 -1
- package/package.json +7 -4
- package/scripts/canal-release.patch +78 -0
- package/scripts/make-dev-releases +65 -0
- package/scripts/update-version +7 -0
- package/sonar-project.properties +1 -1
- package/src/compat/is_codec_supported.ts +23 -1
- package/src/core/adaptive/adaptive_representation_selector.ts +4 -21
- package/src/core/adaptive/network_analyzer.ts +3 -3
- package/src/core/api/debug/buffer_graph.ts +2 -5
- package/src/core/api/debug/modules/general_info.ts +15 -10
- package/src/core/api/index.ts +1 -0
- package/src/core/api/option_utils.ts +3 -3
- package/src/core/api/playback_observer.ts +327 -107
- package/src/core/api/public_api.ts +42 -14
- package/src/core/api/utils.ts +3 -1
- package/src/core/decrypt/get_media_keys.ts +2 -8
- package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
- package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
- package/src/core/fetchers/utils/schedule_request.ts +1 -1
- package/src/core/init/directfile_content_initializer.ts +31 -15
- package/src/core/init/media_source_content_initializer.ts +40 -27
- package/src/core/init/utils/content_time_boundaries_observer.ts +24 -23
- package/src/core/init/utils/create_stream_playback_observer.ts +19 -20
- package/src/core/init/utils/get_initial_time.ts +25 -12
- 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 +5 -4
- package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
- package/src/default_config.ts +22 -17
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
- package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
- package/src/manifest/adaptation.ts +2 -1
- package/src/manifest/representation_index/static.ts +2 -2
- package/src/manifest/representation_index/types.ts +4 -4
- package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
- package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
- package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
- package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
- package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
- package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
- package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
- package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
- package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
- package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
- package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
- package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
- package/src/parsers/manifest/local/representation_index.ts +3 -3
- package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
- package/src/parsers/manifest/smooth/representation_index.ts +23 -9
- package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
- package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
- package/src/parsers/manifest/utils/index_helpers.ts +1 -1
- package/src/parsers/texttracks/ttml/html/apply_line_height.ts +3 -1
- package/src/public_types.ts +108 -36
- package/src/transports/dash/init_segment_loader.ts +5 -0
- package/src/transports/dash/manifest_parser.ts +6 -0
- package/src/transports/dash/segment_loader.ts +1 -0
- package/src/transports/dash/text_loader.ts +2 -0
- package/src/transports/metaplaylist/manifest_loader.ts +1 -0
- package/src/transports/metaplaylist/pipelines.ts +4 -1
- package/src/transports/smooth/pipelines.ts +2 -0
- package/src/transports/smooth/segment_loader.ts +1 -0
- package/src/transports/types.ts +12 -0
- package/src/transports/utils/generate_manifest_loader.ts +3 -0
- package/src/utils/request/fetch.ts +35 -8
- package/src/utils/request/xhr.ts +45 -14
- package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
- package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
- package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
- package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
- package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
- package/src/typings/object-assign.d.ts +0 -48
|
@@ -96,7 +96,9 @@ export default class SegmentInventory {
|
|
|
96
96
|
log.debug(`SI: ${numberOfSegmentToDelete} segments GCed.`, bufferType);
|
|
97
97
|
const removed = inventory.splice(indexBefore, numberOfSegmentToDelete);
|
|
98
98
|
for (const seg of removed) {
|
|
99
|
-
if (seg.bufferedStart === undefined &&
|
|
99
|
+
if (seg.bufferedStart === undefined &&
|
|
100
|
+
seg.bufferedEnd === undefined &&
|
|
101
|
+
seg.status !== 2 /* ChunkStatus.Failed */) {
|
|
100
102
|
this._bufferedHistory.addBufferedSegment(seg.infos, null);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -154,7 +156,9 @@ export default class SegmentInventory {
|
|
|
154
156
|
log.debug("SI: last segments have been GCed", bufferType, inventoryIndex, inventory.length);
|
|
155
157
|
const removed = inventory.splice(inventoryIndex, inventory.length - inventoryIndex);
|
|
156
158
|
for (const seg of removed) {
|
|
157
|
-
if (seg.bufferedStart === undefined &&
|
|
159
|
+
if (seg.bufferedStart === undefined &&
|
|
160
|
+
seg.bufferedEnd === undefined &&
|
|
161
|
+
seg.status !== 2 /* ChunkStatus.Failed */) {
|
|
158
162
|
this._bufferedHistory.addBufferedSegment(seg.infos, null);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
@@ -171,7 +175,7 @@ export default class SegmentInventory {
|
|
|
171
175
|
* segment have been inserted, you should call the `completeSegment` method.
|
|
172
176
|
* @param {Object} chunkInformation
|
|
173
177
|
*/
|
|
174
|
-
insertChunk({ period, adaptation, representation, segment, chunkSize, start, end }) {
|
|
178
|
+
insertChunk({ period, adaptation, representation, segment, chunkSize, start, end }, succeed) {
|
|
175
179
|
if (segment.isInit) {
|
|
176
180
|
return;
|
|
177
181
|
}
|
|
@@ -181,7 +185,8 @@ export default class SegmentInventory {
|
|
|
181
185
|
return;
|
|
182
186
|
}
|
|
183
187
|
const inventory = this._inventory;
|
|
184
|
-
const newSegment = {
|
|
188
|
+
const newSegment = { status: succeed ? 0 /* ChunkStatus.PartiallyPushed */ :
|
|
189
|
+
2 /* ChunkStatus.Failed */,
|
|
185
190
|
chunkSize,
|
|
186
191
|
splitted: false,
|
|
187
192
|
start,
|
|
@@ -379,7 +384,7 @@ export default class SegmentInventory {
|
|
|
379
384
|
// newSegment : |====|
|
|
380
385
|
// ===> : |--|====|-|
|
|
381
386
|
log.warn("SI: Segment pushed is contained in a previous one", bufferType, start, end, segmentI.start, segmentI.end);
|
|
382
|
-
const nextSegment = {
|
|
387
|
+
const nextSegment = { status: segmentI.status,
|
|
383
388
|
/**
|
|
384
389
|
* Note: this sadly means we're doing as if
|
|
385
390
|
* that chunk is present two times.
|
|
@@ -537,7 +542,9 @@ export default class SegmentInventory {
|
|
|
537
542
|
this._inventory.splice(firstI + 1, length);
|
|
538
543
|
i -= length;
|
|
539
544
|
}
|
|
540
|
-
this._inventory[firstI].
|
|
545
|
+
if (this._inventory[firstI].status === 0 /* ChunkStatus.PartiallyPushed */) {
|
|
546
|
+
this._inventory[firstI].status = 1 /* ChunkStatus.Complete */;
|
|
547
|
+
}
|
|
541
548
|
this._inventory[firstI].chunkSize = segmentSize;
|
|
542
549
|
this._inventory[firstI].end = lastEnd;
|
|
543
550
|
this._inventory[firstI].bufferedEnd = lastBufferedEnd;
|
|
@@ -552,8 +559,10 @@ export default class SegmentInventory {
|
|
|
552
559
|
this.synchronizeBuffered(newBuffered);
|
|
553
560
|
for (const seg of resSegments) {
|
|
554
561
|
if (seg.bufferedStart !== undefined && seg.bufferedEnd !== undefined) {
|
|
555
|
-
|
|
556
|
-
|
|
562
|
+
if (seg.status !== 2 /* ChunkStatus.Failed */) {
|
|
563
|
+
this._bufferedHistory.addBufferedSegment(seg.infos, { start: seg.bufferedStart,
|
|
564
|
+
end: seg.bufferedEnd });
|
|
565
|
+
}
|
|
557
566
|
}
|
|
558
567
|
else {
|
|
559
568
|
log.debug("SI: buffered range not known after sync. Skipping history.", seg.start, seg.end);
|
|
@@ -596,7 +605,7 @@ export default class SegmentInventory {
|
|
|
596
605
|
*/
|
|
597
606
|
function bufferedStartLooksCoherent(thisSegment) {
|
|
598
607
|
if (thisSegment.bufferedStart === undefined ||
|
|
599
|
-
thisSegment.
|
|
608
|
+
thisSegment.status !== 1 /* ChunkStatus.Complete */) {
|
|
600
609
|
return false;
|
|
601
610
|
}
|
|
602
611
|
const { start, end } = thisSegment;
|
|
@@ -617,7 +626,7 @@ function bufferedStartLooksCoherent(thisSegment) {
|
|
|
617
626
|
*/
|
|
618
627
|
function bufferedEndLooksCoherent(thisSegment) {
|
|
619
628
|
if (thisSegment.bufferedEnd === undefined ||
|
|
620
|
-
thisSegment.
|
|
629
|
+
thisSegment.status !== 1 /* ChunkStatus.Complete */) {
|
|
621
630
|
return false;
|
|
622
631
|
}
|
|
623
632
|
const { start, end } = thisSegment;
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
import { Adaptation, Period } from "../../../manifest";
|
|
17
17
|
import { IReadOnlyPlaybackObserver } from "../../api";
|
|
18
18
|
import { SegmentBuffer } from "../../segment_buffers";
|
|
19
|
-
import { IRepresentationsChoice } from "../representation";
|
|
20
|
-
export default function getRepresentationsSwitchingStrategy(period: Period, adaptation: Adaptation, settings: IRepresentationsChoice, segmentBuffer: SegmentBuffer, playbackObserver: IReadOnlyPlaybackObserver<
|
|
19
|
+
import { IRepresentationStreamPlaybackObservation, IRepresentationsChoice } from "../representation";
|
|
20
|
+
export default function getRepresentationsSwitchingStrategy(period: Period, adaptation: Adaptation, settings: IRepresentationsChoice, segmentBuffer: SegmentBuffer, playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>): IRepresentationSwitchStrategy;
|
|
21
21
|
export type IRepresentationSwitchStrategy = {
|
|
22
22
|
type: "continue";
|
|
23
23
|
value: undefined;
|
|
@@ -45,16 +45,22 @@ export default function getRepresentationsSwitchingStrategy(period, adaptation,
|
|
|
45
45
|
if (unwantedRange.length === 0) {
|
|
46
46
|
return { type: "continue", value: undefined };
|
|
47
47
|
}
|
|
48
|
-
const currentTime = playbackObserver.getCurrentTime();
|
|
49
48
|
const readyState = playbackObserver.getReadyState();
|
|
50
|
-
if (settings.switchingMode === "reload" &&
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
if (settings.switchingMode === "reload" && readyState > 1) {
|
|
50
|
+
const lastObservation = playbackObserver.getReference().getValue();
|
|
51
|
+
if (lastObservation.position.isAwaitingFuturePosition()) {
|
|
52
|
+
// We are not at the position we want to reach (e.g. initial seek, tizen
|
|
53
|
+
// seek-back...), just reload as checks here would be too complex
|
|
54
|
+
return { type: "needs-reload", value: undefined };
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const currentTime = playbackObserver.getCurrentTime();
|
|
58
|
+
if (isTimeInRange({ start, end }, currentTime) &&
|
|
59
|
+
// We're not playing the current wanted video Adaptation
|
|
60
|
+
!isTimeInRanges(rangesWithReps, currentTime)) {
|
|
61
|
+
return { type: "needs-reload", value: undefined };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
// From here, clean-up data from the previous Adaptation, if one
|
|
60
66
|
const shouldFlush = settings.switchingMode === "direct";
|
|
@@ -85,6 +91,7 @@ export default function getRepresentationsSwitchingStrategy(period, adaptation,
|
|
|
85
91
|
if (paddingAfter == null) {
|
|
86
92
|
paddingAfter = 0;
|
|
87
93
|
}
|
|
94
|
+
const currentTime = playbackObserver.getCurrentTime();
|
|
88
95
|
rangesToExclude.push({ start: currentTime - paddingBefore,
|
|
89
96
|
end: currentTime + paddingAfter });
|
|
90
97
|
}
|
|
@@ -69,22 +69,23 @@ import getTimeRangesForContent from "./get_time_ranges_for_content";
|
|
|
69
69
|
export default function StreamOrchestrator(content, playbackObserver, representationEstimator, segmentBuffersStore, segmentFetcherCreator, options, callbacks, orchestratorCancelSignal) {
|
|
70
70
|
const { manifest, initialPeriod } = content;
|
|
71
71
|
const { maxBufferAhead, maxBufferBehind, wantedBufferAhead, maxVideoBufferSize } = options;
|
|
72
|
-
const { MAXIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_BEHIND } = config.getCurrent();
|
|
72
|
+
const { MINIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_BEHIND } = config.getCurrent();
|
|
73
73
|
// Keep track of a unique BufferGarbageCollector created per
|
|
74
74
|
// SegmentBuffer.
|
|
75
75
|
const garbageCollectors = new WeakMapMemory((segmentBuffer) => {
|
|
76
|
+
var _a, _b;
|
|
76
77
|
const { bufferType } = segmentBuffer;
|
|
77
|
-
const defaultMaxBehind = MAXIMUM_MAX_BUFFER_BEHIND[bufferType]
|
|
78
|
-
|
|
79
|
-
Infinity;
|
|
80
|
-
const defaultMaxAhead = MAXIMUM_MAX_BUFFER_AHEAD[bufferType] != null ?
|
|
81
|
-
MAXIMUM_MAX_BUFFER_AHEAD[bufferType] :
|
|
82
|
-
Infinity;
|
|
78
|
+
const defaultMaxBehind = (_a = MAXIMUM_MAX_BUFFER_BEHIND[bufferType]) !== null && _a !== void 0 ? _a : Infinity;
|
|
79
|
+
const maxAheadHigherBound = (_b = MAXIMUM_MAX_BUFFER_AHEAD[bufferType]) !== null && _b !== void 0 ? _b : Infinity;
|
|
83
80
|
return (gcCancelSignal) => {
|
|
84
81
|
BufferGarbageCollector({ segmentBuffer,
|
|
85
82
|
playbackObserver,
|
|
86
83
|
maxBufferBehind: createMappedReference(maxBufferBehind, (val) => Math.min(val, defaultMaxBehind), gcCancelSignal),
|
|
87
|
-
maxBufferAhead: createMappedReference(maxBufferAhead, (val) =>
|
|
84
|
+
maxBufferAhead: createMappedReference(maxBufferAhead, (val) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const lowerBound = Math.max(val, (_a = MINIMUM_MAX_BUFFER_AHEAD[bufferType]) !== null && _a !== void 0 ? _a : 0);
|
|
87
|
+
return Math.min(lowerBound, maxAheadHigherBound);
|
|
88
|
+
}, gcCancelSignal) }, gcCancelSignal);
|
|
88
89
|
};
|
|
89
90
|
});
|
|
90
91
|
// Create automatically the right `PeriodStream` for every possible types
|
|
@@ -117,8 +118,8 @@ export default function StreamOrchestrator(content, playbackObserver, representa
|
|
|
117
118
|
// Restart the current Stream when the wanted time is in another period
|
|
118
119
|
// than the ones already considered
|
|
119
120
|
playbackObserver.listen(({ position }) => {
|
|
120
|
-
var _a
|
|
121
|
-
const time =
|
|
121
|
+
var _a;
|
|
122
|
+
const time = position.getWanted();
|
|
122
123
|
if (!enableOutOfBoundsCheck || !isOutOfPeriodList(time)) {
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
@@ -132,7 +133,7 @@ export default function StreamOrchestrator(content, playbackObserver, representa
|
|
|
132
133
|
currentCanceller.cancel();
|
|
133
134
|
currentCanceller = new TaskCanceller();
|
|
134
135
|
currentCanceller.linkToSignal(orchestratorCancelSignal);
|
|
135
|
-
const nextPeriod = (
|
|
136
|
+
const nextPeriod = (_a = manifest.getPeriodForTime(time)) !== null && _a !== void 0 ? _a : manifest.getNextPeriod(time);
|
|
136
137
|
if (nextPeriod === undefined) {
|
|
137
138
|
log.warn("Stream: The wanted position is not found in the Manifest.");
|
|
138
139
|
return;
|
|
@@ -266,7 +267,6 @@ export default function StreamOrchestrator(content, playbackObserver, representa
|
|
|
266
267
|
// to reduce the risk of race conditions where the next observation
|
|
267
268
|
// was going to be emitted synchronously.
|
|
268
269
|
queueMicrotask(() => {
|
|
269
|
-
var _a;
|
|
270
270
|
if (orchestratorCancelSignal.isCancelled()) {
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
@@ -284,7 +284,7 @@ export default function StreamOrchestrator(content, playbackObserver, representa
|
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
const lastPosition =
|
|
287
|
+
const lastPosition = observation.position.getWanted();
|
|
288
288
|
const newInitialPeriod = manifest.getPeriodForTime(lastPosition);
|
|
289
289
|
if (newInitialPeriod == null) {
|
|
290
290
|
callbacks.error(new MediaError("MEDIA_TIME_NOT_FOUND", "The wanted position is not found in the Manifest."));
|
|
@@ -338,10 +338,8 @@ export default function StreamOrchestrator(content, playbackObserver, representa
|
|
|
338
338
|
// Stop current PeriodStream when the current position goes over the end of
|
|
339
339
|
// that Period.
|
|
340
340
|
playbackObserver.listen(({ position }, stopListeningObservations) => {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
((_a = position.pending) !== null && _a !== void 0 ? _a : position.last) >= basePeriod.end) {
|
|
344
|
-
log.info("Stream: Destroying PeriodStream as the current playhead moved above it", bufferType, basePeriod.start, (_b = position.pending) !== null && _b !== void 0 ? _b : position.last, basePeriod.end);
|
|
341
|
+
if (basePeriod.end !== undefined && position.getWanted() >= basePeriod.end) {
|
|
342
|
+
log.info("Stream: Destroying PeriodStream as the current playhead moved above it", bufferType, basePeriod.start, position.getWanted(), basePeriod.end);
|
|
345
343
|
stopListeningObservations();
|
|
346
344
|
consecutivePeriodStreamCb.periodStreamCleared({ type: bufferType,
|
|
347
345
|
manifest,
|
|
@@ -476,7 +474,7 @@ function needsFlushingAfterClean(observation, cleanedRanges) {
|
|
|
476
474
|
if (cleanedRanges.length === 0) {
|
|
477
475
|
return false;
|
|
478
476
|
}
|
|
479
|
-
const curPos = observation.position.
|
|
477
|
+
const curPos = observation.position.getPolled();
|
|
480
478
|
// Based on the playback direction, we just check whether we may encounter
|
|
481
479
|
// the corresponding ranges, without seeking or re-switching playback
|
|
482
480
|
// direction which is expected to lead to a low-level flush anyway.
|
|
@@ -152,11 +152,8 @@ export default function PeriodStream({ bufferType, content, garbageCollectors, p
|
|
|
152
152
|
if (streamCanceller.isUsed()) {
|
|
153
153
|
return; // Previous call has provoken cancellation by side-effect
|
|
154
154
|
}
|
|
155
|
-
const readyState = playbackObserver.getReadyState();
|
|
156
155
|
const segmentBuffer = createOrReuseSegmentBuffer(segmentBuffersStore, bufferType, adaptation, options);
|
|
157
|
-
const
|
|
158
|
-
readyState };
|
|
159
|
-
const strategy = getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, choice.switchingMode, playbackInfos, options);
|
|
156
|
+
const strategy = getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, choice.switchingMode, playbackObserver, options);
|
|
160
157
|
if (strategy.type === "needs-reload") {
|
|
161
158
|
return askForMediaSourceReload(relativePosAfterSwitch, true, streamCanceller.signal);
|
|
162
159
|
}
|
|
@@ -315,7 +312,7 @@ function createAdaptationStreamPlaybackObserver(initialPlaybackObserver, segment
|
|
|
315
312
|
function constructAdaptationStreamPlaybackObservation() {
|
|
316
313
|
const baseObservation = observationRef.getValue();
|
|
317
314
|
const buffered = segmentBuffer.getBufferedRanges();
|
|
318
|
-
const bufferGap = getLeftSizeOfBufferedTimeRange(buffered, baseObservation.position.
|
|
315
|
+
const bufferGap = getLeftSizeOfBufferedTimeRange(buffered, baseObservation.position.getWanted());
|
|
319
316
|
return objectAssign({}, baseObservation, { bufferGap });
|
|
320
317
|
}
|
|
321
318
|
function emitAdaptationStreamPlaybackObservation() {
|
|
@@ -343,15 +340,15 @@ function createEmptyAdaptationStream(playbackObserver, wantedBufferAhead, buffer
|
|
|
343
340
|
function sendStatus() {
|
|
344
341
|
const observation = playbackObserver.getReference().getValue();
|
|
345
342
|
const wba = wantedBufferAhead.getValue();
|
|
346
|
-
const position = observation.position.
|
|
343
|
+
const position = observation.position.getWanted();
|
|
347
344
|
if (period.end !== undefined && position + wba >= period.end) {
|
|
348
345
|
log.debug("Stream: full \"empty\" AdaptationStream", bufferType);
|
|
349
346
|
hasFinishedLoading = true;
|
|
350
347
|
}
|
|
351
348
|
callbacks.streamStatusUpdate({ period,
|
|
352
349
|
bufferType,
|
|
353
|
-
position,
|
|
354
350
|
imminentDiscontinuity: null,
|
|
351
|
+
position,
|
|
355
352
|
isEmptyStream: true,
|
|
356
353
|
hasFinishedLoading,
|
|
357
354
|
neededSegments: [] });
|
|
@@ -3,11 +3,10 @@ import SharedReference, { IReadOnlySharedReference } from "../../../utils/refere
|
|
|
3
3
|
import { CancellationSignal } from "../../../utils/task_canceller";
|
|
4
4
|
import WeakMapMemory from "../../../utils/weak_map_memory";
|
|
5
5
|
import { IRepresentationEstimator } from "../../adaptive";
|
|
6
|
-
import { IReadOnlyPlaybackObserver } from "../../api";
|
|
6
|
+
import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
|
|
7
7
|
import { SegmentFetcherCreator } from "../../fetchers";
|
|
8
8
|
import SegmentBuffersStore, { IBufferType, ITextTrackSegmentBufferOptions, SegmentBuffer } from "../../segment_buffers";
|
|
9
9
|
import { IAdaptationChoice, IAdaptationStreamCallbacks, IAdaptationStreamOptions, IPausedPlaybackObservation } from "../adaptation";
|
|
10
|
-
import { IPositionPlaybackObservation } from "../representation";
|
|
11
10
|
/** Callbacks called by the `AdaptationStream` on various events. */
|
|
12
11
|
export interface IPeriodStreamCallbacks extends IAdaptationStreamCallbacks {
|
|
13
12
|
/**
|
|
@@ -65,7 +64,7 @@ export interface IPeriodStreamPlaybackObservation {
|
|
|
65
64
|
* Information on the current media position in seconds at the time of the
|
|
66
65
|
* Observation.
|
|
67
66
|
*/
|
|
68
|
-
position:
|
|
67
|
+
position: IObservationPosition;
|
|
69
68
|
/** `duration` property of the HTMLMediaElement. */
|
|
70
69
|
duration: number;
|
|
71
70
|
/** `readyState` property of the HTMLMediaElement. */
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Adaptation, Period } from "../../../../manifest";
|
|
17
|
+
import { IReadOnlyPlaybackObserver } from "../../../api";
|
|
17
18
|
import { SegmentBuffer } from "../../../segment_buffers";
|
|
18
19
|
import { ITrackSwitchingMode } from "../../adaptation";
|
|
20
|
+
import { IPeriodStreamPlaybackObservation } from "../types";
|
|
19
21
|
export type IAdaptationSwitchStrategy =
|
|
20
22
|
/** Do nothing special. */
|
|
21
23
|
{
|
|
@@ -59,10 +61,7 @@ export interface IAdaptationSwitchOptions {
|
|
|
59
61
|
* @param {Object} segmentBuffer
|
|
60
62
|
* @param {Object} period
|
|
61
63
|
* @param {Object} adaptation
|
|
62
|
-
* @param {Object}
|
|
64
|
+
* @param {Object} playbackObserver
|
|
63
65
|
* @returns {Object}
|
|
64
66
|
*/
|
|
65
|
-
export default function getAdaptationSwitchStrategy(segmentBuffer: SegmentBuffer, period: Period, adaptation: Adaptation, switchingMode: ITrackSwitchingMode,
|
|
66
|
-
currentTime: number;
|
|
67
|
-
readyState: number;
|
|
68
|
-
}, options: IAdaptationSwitchOptions): IAdaptationSwitchStrategy;
|
|
67
|
+
export default function getAdaptationSwitchStrategy(segmentBuffer: SegmentBuffer, period: Period, adaptation: Adaptation, switchingMode: ITrackSwitchingMode, playbackObserver: IReadOnlyPlaybackObserver<IPeriodStreamPlaybackObservation>, options: IAdaptationSwitchOptions): IAdaptationSwitchStrategy;
|
|
@@ -23,10 +23,10 @@ import { getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod, } from "../../.
|
|
|
23
23
|
* @param {Object} segmentBuffer
|
|
24
24
|
* @param {Object} period
|
|
25
25
|
* @param {Object} adaptation
|
|
26
|
-
* @param {Object}
|
|
26
|
+
* @param {Object} playbackObserver
|
|
27
27
|
* @returns {Object}
|
|
28
28
|
*/
|
|
29
|
-
export default function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode,
|
|
29
|
+
export default function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode, playbackObserver, options) {
|
|
30
30
|
if (segmentBuffer.codec !== undefined &&
|
|
31
31
|
options.onCodecSwitch === "reload" &&
|
|
32
32
|
!hasCompatibleCodec(adaptation, segmentBuffer.codec)) {
|
|
@@ -62,16 +62,20 @@ export default function getAdaptationSwitchStrategy(segmentBuffer, period, adapt
|
|
|
62
62
|
if (unwantedRange.length === 0) {
|
|
63
63
|
return { type: "continue", value: undefined };
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
const currentTime = playbackObserver.getCurrentTime();
|
|
66
|
+
const readyState = playbackObserver.getReadyState();
|
|
67
|
+
if (switchingMode === "reload" && readyState > 1) {
|
|
68
|
+
const lastObservation = playbackObserver.getReference().getValue();
|
|
69
|
+
if (lastObservation.position.isAwaitingFuturePosition()) {
|
|
70
|
+
// We are not at the position we want to reach (e.g. initial seek, tizen
|
|
71
|
+
// seek-back...), just reload as checks here would be too complex
|
|
72
|
+
return { type: "needs-reload", value: undefined };
|
|
73
|
+
}
|
|
74
|
+
else if (isTimeInRange({ start, end }, currentTime) &&
|
|
75
|
+
// We're not playing the current wanted video Adaptation
|
|
76
|
+
!isTimeInRanges(adaptationInBuffer, currentTime)) {
|
|
77
|
+
return { type: "needs-reload", value: undefined };
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
80
|
// From here, clean-up data from the previous Adaptation, if one
|
|
77
81
|
const shouldCleanAll = switchingMode === "direct";
|
|
@@ -139,7 +143,7 @@ function hasCompatibleCodec(adaptation, segmentBufferCodec) {
|
|
|
139
143
|
/**
|
|
140
144
|
* Returns buffered ranges of what we know correspond to the given `adaptation`
|
|
141
145
|
* in the SegmentBuffer.
|
|
142
|
-
* @param {Object}
|
|
146
|
+
* @param {Array.<Object>} inventory
|
|
143
147
|
* @param {Object} period
|
|
144
148
|
* @param {Object} adaptation
|
|
145
149
|
* @returns {Array.<Object>}
|
|
@@ -183,12 +183,11 @@ export default function RepresentationStream({ content, options, playbackObserve
|
|
|
183
183
|
* issues at the current time, calling the right callbacks if necessary.
|
|
184
184
|
*/
|
|
185
185
|
function checkStatus() {
|
|
186
|
-
var _a, _b;
|
|
187
186
|
if (segmentsLoadingCanceller.isUsed()) {
|
|
188
187
|
return; // Stop all buffer status checking if load operations are stopped
|
|
189
188
|
}
|
|
190
189
|
const observation = playbackObserver.getReference().getValue();
|
|
191
|
-
const initialWantedTime =
|
|
190
|
+
const initialWantedTime = observation.position.getWanted();
|
|
192
191
|
const status = getBufferStatus(content, initialWantedTime, playbackObserver, fastSwitchThreshold.getValue(), bufferGoal.getValue(), maxBufferSize.getValue(), segmentBuffer);
|
|
193
192
|
const { neededSegments } = status;
|
|
194
193
|
let neededInitSegment = null;
|
|
@@ -202,7 +201,7 @@ export default function RepresentationStream({ content, options, playbackObserve
|
|
|
202
201
|
"initialization segment");
|
|
203
202
|
}
|
|
204
203
|
else {
|
|
205
|
-
const wantedStart =
|
|
204
|
+
const wantedStart = observation.position.getWanted();
|
|
206
205
|
neededInitSegment = { segment: initSegmentState.segment,
|
|
207
206
|
priority: getSegmentPriority(period.start, wantedStart) };
|
|
208
207
|
}
|
|
@@ -253,7 +252,7 @@ export default function RepresentationStream({ content, options, playbackObserve
|
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
callbacks.streamStatusUpdate({ period,
|
|
256
|
-
position: observation.position.
|
|
255
|
+
position: observation.position.getWanted(),
|
|
257
256
|
bufferType,
|
|
258
257
|
imminentDiscontinuity: status.imminentDiscontinuity,
|
|
259
258
|
isEmptyStream: false,
|
|
@@ -2,7 +2,7 @@ import Manifest, { Adaptation, ISegment, Period, Representation } from "../../..
|
|
|
2
2
|
import { IEMSG } from "../../../parsers/containers/isobmff";
|
|
3
3
|
import { IAudioRepresentationsSwitchingMode, IPlayerError, IVideoRepresentationsSwitchingMode } from "../../../public_types";
|
|
4
4
|
import { IReadOnlySharedReference } from "../../../utils/reference";
|
|
5
|
-
import { IReadOnlyPlaybackObserver } from "../../api";
|
|
5
|
+
import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
|
|
6
6
|
import { IContentProtection } from "../../decrypt";
|
|
7
7
|
import { IPrioritizedSegmentFetcher } from "../../fetchers";
|
|
8
8
|
import { IBufferType, SegmentBuffer } from "../../segment_buffers";
|
|
@@ -163,7 +163,7 @@ export interface IRepresentationStreamPlaybackObservation {
|
|
|
163
163
|
* Information on the current media position in seconds at the time of a
|
|
164
164
|
* Playback Observation.
|
|
165
165
|
*/
|
|
166
|
-
position:
|
|
166
|
+
position: IObservationPosition;
|
|
167
167
|
}
|
|
168
168
|
/** Position-related information linked to an emitted Playback observation. */
|
|
169
169
|
export interface IPositionPlaybackObservation {
|
|
@@ -30,7 +30,6 @@ import forceGarbageCollection from "./force_garbage_collection";
|
|
|
30
30
|
* @returns {Promise}
|
|
31
31
|
*/
|
|
32
32
|
export default async function appendSegmentToBuffer(playbackObserver, segmentBuffer, dataInfos, cancellationSignal) {
|
|
33
|
-
var _a;
|
|
34
33
|
try {
|
|
35
34
|
await segmentBuffer.pushChunk(dataInfos, cancellationSignal);
|
|
36
35
|
}
|
|
@@ -46,7 +45,7 @@ export default async function appendSegmentToBuffer(playbackObserver, segmentBuf
|
|
|
46
45
|
throw new MediaError("BUFFER_APPEND_ERROR", reason, { adaptations: [dataInfos.inventoryInfos.adaptation] });
|
|
47
46
|
}
|
|
48
47
|
const { position } = playbackObserver.getReference().getValue();
|
|
49
|
-
const currentPos =
|
|
48
|
+
const currentPos = position.getWanted();
|
|
50
49
|
try {
|
|
51
50
|
await forceGarbageCollection(currentPos, segmentBuffer, cancellationSignal);
|
|
52
51
|
await segmentBuffer.pushChunk(dataInfos, cancellationSignal);
|
|
@@ -74,7 +74,7 @@ export default function getBufferStatus(content, initialWantedTime, playbackObse
|
|
|
74
74
|
* needed segments for this Representation until the end of the Period.
|
|
75
75
|
*/
|
|
76
76
|
const hasFinishedLoading = representation.index.isInitialized() &&
|
|
77
|
-
representation.index.
|
|
77
|
+
!representation.index.isStillAwaitingFutureSegments() &&
|
|
78
78
|
neededRange.hasReachedPeriodEnd &&
|
|
79
79
|
prioritizedNeededSegments.length === 0 &&
|
|
80
80
|
segmentsOnHold.length === 0;
|
|
@@ -128,7 +128,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
|
|
|
128
128
|
SegmentBuffersStore.isNative(content.adaptation.type) &&
|
|
129
129
|
initialWantedTime >= lastIndexPosition &&
|
|
130
130
|
representationIndex.isInitialized() &&
|
|
131
|
-
representationIndex.
|
|
131
|
+
!representationIndex.isStillAwaitingFutureSegments() &&
|
|
132
132
|
isPeriodTheCurrentAndLastOne(manifest, period, initialWantedTime)) {
|
|
133
133
|
wantedStartPosition = lastIndexPosition - 1;
|
|
134
134
|
}
|
|
@@ -138,7 +138,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
|
|
|
138
138
|
const wantedEndPosition = wantedStartPosition + bufferGoal;
|
|
139
139
|
let hasReachedPeriodEnd;
|
|
140
140
|
if (!representation.index.isInitialized() ||
|
|
141
|
-
|
|
141
|
+
representation.index.isStillAwaitingFutureSegments() ||
|
|
142
142
|
period.end === undefined) {
|
|
143
143
|
hasReachedPeriodEnd = false;
|
|
144
144
|
}
|
|
@@ -194,7 +194,7 @@ function getPlayableBufferedSegments(neededRange, segmentInventory) {
|
|
|
194
194
|
for (let i = segmentInventory.length - 1; i >= 0; i--) {
|
|
195
195
|
const eltInventory = segmentInventory[i];
|
|
196
196
|
const { representation } = eltInventory.infos;
|
|
197
|
-
if (
|
|
197
|
+
if (eltInventory.status === 1 /* ChunkStatus.Complete */ &&
|
|
198
198
|
representation.decipherable !== false &&
|
|
199
199
|
representation.isSupported) {
|
|
200
200
|
const inventorySegment = eltInventory.infos.segment;
|
|
@@ -320,7 +320,7 @@ function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
|
|
|
320
320
|
}
|
|
321
321
|
if (minimumEndTime > currentSeg.bufferedEnd &&
|
|
322
322
|
currentSeg.end - currentSeg.bufferedEnd > MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT) {
|
|
323
|
-
log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.
|
|
323
|
+
log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.end, currentSeg.bufferedEnd);
|
|
324
324
|
return true;
|
|
325
325
|
}
|
|
326
326
|
return false;
|
|
@@ -21,6 +21,11 @@ declare const DEFAULT_CONFIG: {
|
|
|
21
21
|
* @type {Number}
|
|
22
22
|
*/
|
|
23
23
|
DEFAULT_REQUEST_TIMEOUT: number;
|
|
24
|
+
/**
|
|
25
|
+
* Default connection time after which a request will timeout, in ms.
|
|
26
|
+
* @type {Number}
|
|
27
|
+
*/
|
|
28
|
+
DEFAULT_CONNECTION_TIMEOUT: number;
|
|
24
29
|
/**
|
|
25
30
|
* Can be either:
|
|
26
31
|
* - "native": Subtitles are all displayed in a <track> element
|
|
@@ -141,6 +146,13 @@ declare const DEFAULT_CONFIG: {
|
|
|
141
146
|
* @type {Object}
|
|
142
147
|
*/
|
|
143
148
|
MAXIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "text", number>>;
|
|
149
|
+
/**
|
|
150
|
+
* Minimum possible buffer ahead for each type of buffer, to avoid Garbage
|
|
151
|
+
* Collecting too much data when it would have adverse effects.
|
|
152
|
+
* Equal to `0` if not defined here.
|
|
153
|
+
* @type {Object}
|
|
154
|
+
*/
|
|
155
|
+
MINIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "image" | "text", number>>;
|
|
144
156
|
/**
|
|
145
157
|
* Maximum possible buffer behind for each type of buffer, to avoid too much
|
|
146
158
|
* memory usage when playing for a long time.
|
|
@@ -203,22 +215,6 @@ declare const DEFAULT_CONFIG: {
|
|
|
203
215
|
* @type {Number}
|
|
204
216
|
*/
|
|
205
217
|
BUFFER_DISCONTINUITY_THRESHOLD: number;
|
|
206
|
-
/**
|
|
207
|
-
* When encountering small discontinuities, the RxPlayer may want, in specific
|
|
208
|
-
* conditions, ignore those and let the browser seek over them iself (this
|
|
209
|
-
* allows for example to avoid conflicts when both the browser and the
|
|
210
|
-
* RxPlayer want to seek at a different position, sometimes leading to a
|
|
211
|
-
* seeking loop).
|
|
212
|
-
* In this case, we however still want to seek it ourselves if the browser
|
|
213
|
-
* doesn't take the opportunity soon enough.
|
|
214
|
-
*
|
|
215
|
-
* This value specifies a delay after which a discontinuity ignored by the
|
|
216
|
-
* RxPlayer is finally considered.
|
|
217
|
-
* We want to maintain high enough to be sure the browser will not seek yet
|
|
218
|
-
* small enough so this (arguably rare) situation won't lead to too much
|
|
219
|
-
* waiting time.
|
|
220
|
-
*/
|
|
221
|
-
FORCE_DISCONTINUITY_SEEK_DELAY: number;
|
|
222
218
|
/**
|
|
223
219
|
* Ratio used to know if an already loaded segment should be re-buffered.
|
|
224
220
|
* We re-load the given segment if the current one times that ratio is
|
|
@@ -21,6 +21,11 @@ const DEFAULT_CONFIG = {
|
|
|
21
21
|
* @type {Number}
|
|
22
22
|
*/
|
|
23
23
|
DEFAULT_REQUEST_TIMEOUT: 30 * 1000,
|
|
24
|
+
/**
|
|
25
|
+
* Default connection time after which a request will timeout, in ms.
|
|
26
|
+
* @type {Number}
|
|
27
|
+
*/
|
|
28
|
+
DEFAULT_CONNECTION_TIMEOUT: 15 * 1000,
|
|
24
29
|
/**
|
|
25
30
|
* Can be either:
|
|
26
31
|
* - "native": Subtitles are all displayed in a <track> element
|
|
@@ -144,6 +149,22 @@ const DEFAULT_CONFIG = {
|
|
|
144
149
|
},
|
|
145
150
|
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
146
151
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
152
|
+
/**
|
|
153
|
+
* Minimum possible buffer ahead for each type of buffer, to avoid Garbage
|
|
154
|
+
* Collecting too much data when it would have adverse effects.
|
|
155
|
+
* Equal to `0` if not defined here.
|
|
156
|
+
* @type {Object}
|
|
157
|
+
*/
|
|
158
|
+
MINIMUM_MAX_BUFFER_AHEAD: {
|
|
159
|
+
// Text segments are both much lighter on resources and might
|
|
160
|
+
// actually be much larger than other types of segments in terms
|
|
161
|
+
// of duration. Let's make an exception here by authorizing a
|
|
162
|
+
// larger text buffer ahead, to avoid unnecesarily reloading the
|
|
163
|
+
// same text track.
|
|
164
|
+
text: 2 * 60,
|
|
165
|
+
},
|
|
166
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
167
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
147
168
|
/**
|
|
148
169
|
* Maximum possible buffer behind for each type of buffer, to avoid too much
|
|
149
170
|
* memory usage when playing for a long time.
|
|
@@ -209,22 +230,6 @@ const DEFAULT_CONFIG = {
|
|
|
209
230
|
* @type {Number}
|
|
210
231
|
*/
|
|
211
232
|
BUFFER_DISCONTINUITY_THRESHOLD: 0.2,
|
|
212
|
-
/**
|
|
213
|
-
* When encountering small discontinuities, the RxPlayer may want, in specific
|
|
214
|
-
* conditions, ignore those and let the browser seek over them iself (this
|
|
215
|
-
* allows for example to avoid conflicts when both the browser and the
|
|
216
|
-
* RxPlayer want to seek at a different position, sometimes leading to a
|
|
217
|
-
* seeking loop).
|
|
218
|
-
* In this case, we however still want to seek it ourselves if the browser
|
|
219
|
-
* doesn't take the opportunity soon enough.
|
|
220
|
-
*
|
|
221
|
-
* This value specifies a delay after which a discontinuity ignored by the
|
|
222
|
-
* RxPlayer is finally considered.
|
|
223
|
-
* We want to maintain high enough to be sure the browser will not seek yet
|
|
224
|
-
* small enough so this (arguably rare) situation won't lead to too much
|
|
225
|
-
* waiting time.
|
|
226
|
-
*/
|
|
227
|
-
FORCE_DISCONTINUITY_SEEK_DELAY: 5000,
|
|
228
233
|
/**
|
|
229
234
|
* Ratio used to know if an already loaded segment should be re-buffered.
|
|
230
235
|
* We re-load the given segment if the current one times that ratio is
|
|
@@ -128,7 +128,9 @@ export default class VideoThumbnailLoader {
|
|
|
128
128
|
{}, { baseDelay: 0,
|
|
129
129
|
maxDelay: 0,
|
|
130
130
|
maxRetry: 0,
|
|
131
|
-
requestTimeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT
|
|
131
|
+
requestTimeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
|
|
132
|
+
connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
|
|
133
|
+
});
|
|
132
134
|
const initSegment = content.representation.index.getInitSegment();
|
|
133
135
|
const initSegmentUniqueId = initSegment !== null ?
|
|
134
136
|
content.representation.uniqueId :
|
|
@@ -69,6 +69,7 @@ async function getDurationFromManifest(url, transport) {
|
|
|
69
69
|
url,
|
|
70
70
|
responseType: "document",
|
|
71
71
|
timeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
|
|
72
|
+
connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
|
|
72
73
|
// We won't cancel
|
|
73
74
|
cancelSignal: new TaskCanceller().signal,
|
|
74
75
|
});
|
|
@@ -106,6 +107,7 @@ async function getDurationFromManifest(url, transport) {
|
|
|
106
107
|
url,
|
|
107
108
|
responseType: "text",
|
|
108
109
|
timeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
|
|
110
|
+
connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
|
|
109
111
|
// We won't cancel
|
|
110
112
|
cancelSignal: new TaskCanceller().signal,
|
|
111
113
|
});
|
|
@@ -78,7 +78,8 @@ export default class Adaptation {
|
|
|
78
78
|
const reprObject = {
|
|
79
79
|
id: representation.id,
|
|
80
80
|
bitrate: representation.bitrate,
|
|
81
|
-
|
|
81
|
+
codecs: representation.codec === undefined ? [] :
|
|
82
|
+
[representation.codec],
|
|
82
83
|
height: representation.height,
|
|
83
84
|
width: representation.width,
|
|
84
85
|
frameRate: representation.frameRate,
|