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
|
@@ -137,8 +137,35 @@ export interface IRepresentationFilterRepresentation {
|
|
|
137
137
|
/** String identifying the Representation, unique per Adaptation. */
|
|
138
138
|
id: string;
|
|
139
139
|
bitrate?: number | undefined;
|
|
140
|
-
/**
|
|
141
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Codec(s) relied on by the media segments of that Representation.
|
|
142
|
+
*
|
|
143
|
+
* For the great majority of cases, this value will be set to either
|
|
144
|
+
* `undefined` (meaning the codec is unknown) or to an array with a
|
|
145
|
+
* single element which will be the actual codec relied on when the
|
|
146
|
+
* corresponding Representation will be played.
|
|
147
|
+
*
|
|
148
|
+
* However in some very rare scenarios, this value might be set to an array
|
|
149
|
+
* with multiple codecs, itself being a list of its candidate codecs from the
|
|
150
|
+
* most wanted to the most compatible.
|
|
151
|
+
* The conditions for this more complex format are very specific:
|
|
152
|
+
*
|
|
153
|
+
* - It can only happen if the `representationFilter` callback is called in
|
|
154
|
+
* an environment where it hasn't yet been possible for the RxPlayer to
|
|
155
|
+
* check for codec support (mainly when running through the RxPlayer's
|
|
156
|
+
* `MULTI_THREAD` feature in a browser without MSE-in-worker
|
|
157
|
+
* capabilities).
|
|
158
|
+
*
|
|
159
|
+
* - The corresponding Representation is compatible to a restrictive codec
|
|
160
|
+
* yet also retro-compatible to a less restrictive one.
|
|
161
|
+
*
|
|
162
|
+
* The main example being Dolby Vision Representations which are
|
|
163
|
+
* retro-compatible to HDR10 HEVC codecs.
|
|
164
|
+
* In that very specific case, we could have an array with two elements:
|
|
165
|
+
* 1. The Dolby Vision codec
|
|
166
|
+
* 2. The base HDR10 codec
|
|
167
|
+
*/
|
|
168
|
+
codecs?: string[] | undefined;
|
|
142
169
|
/**
|
|
143
170
|
* This property makes the most sense for video Representations.
|
|
144
171
|
* It defines the height of the video, in pixels.
|
|
@@ -203,10 +230,20 @@ export type IStartAtOption = {
|
|
|
203
230
|
percentage: number;
|
|
204
231
|
} | {
|
|
205
232
|
/**
|
|
206
|
-
* If set, we should begin at this position relative to the content's
|
|
207
|
-
* in seconds.
|
|
233
|
+
* If set, we should begin at this position relative to the content's maximum
|
|
234
|
+
* seekable position, in seconds.
|
|
208
235
|
*/
|
|
209
236
|
fromLastPosition: number;
|
|
237
|
+
} | {
|
|
238
|
+
/**
|
|
239
|
+
* If set, we should begin at this position relative to the content's live
|
|
240
|
+
* edge if it makes sense, in seconds.
|
|
241
|
+
*
|
|
242
|
+
* If the live edge is unknown or if it does not make sense for the current
|
|
243
|
+
* content, that position is relative to the content's maximum position
|
|
244
|
+
* instead.
|
|
245
|
+
*/
|
|
246
|
+
fromLivePosition: number;
|
|
210
247
|
} | {
|
|
211
248
|
/**
|
|
212
249
|
* If set, we should begin at this position relative to the content's start,
|
|
@@ -214,40 +251,37 @@ export type IStartAtOption = {
|
|
|
214
251
|
*/
|
|
215
252
|
fromFirstPosition: number;
|
|
216
253
|
};
|
|
254
|
+
export interface RequestRetryParameters {
|
|
255
|
+
/**
|
|
256
|
+
* The amount of time maximum we should retry a request before failing on Error.
|
|
257
|
+
* Set to `Infinity` for an infinite number of requests.
|
|
258
|
+
*/
|
|
259
|
+
maxRetry?: number | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* Amount of time, in milliseconds, after which a request should be
|
|
262
|
+
* aborted and optionally retried, depending on the maxRetry configuration.
|
|
263
|
+
*
|
|
264
|
+
* Setting it to `-1` allows to disable any timeout.
|
|
265
|
+
* `undefined` means that a default, large, timeout will be used instead.
|
|
266
|
+
*/
|
|
267
|
+
timeout?: number | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* Amount of time, in milliseconds, after which a request that hasn't receive
|
|
270
|
+
* the headers and status code should be aborted and optionnaly retried,
|
|
271
|
+
* depending on the maxRetry configuration.
|
|
272
|
+
*/
|
|
273
|
+
connectionTimeout?: number | undefined;
|
|
274
|
+
}
|
|
217
275
|
/** Value for the `requestConfig` option of the `loadVideo` method. */
|
|
218
276
|
export interface IRequestConfig {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
* Amount of time, in milliseconds, after which a manifest request should be
|
|
228
|
-
* aborted and optionally retried, depending on the current configuration.
|
|
229
|
-
*
|
|
230
|
-
* Setting it to `-1` allows to disable any timeout.
|
|
231
|
-
* `undefined` means that a default, large, timeout will be used instead.
|
|
232
|
-
*/
|
|
233
|
-
timeout?: number | undefined;
|
|
234
|
-
} | undefined;
|
|
235
|
-
segment?: {
|
|
236
|
-
/**
|
|
237
|
-
* The amount of time maximum we should retry a segment or segment-related
|
|
238
|
-
* request before failing on Error.
|
|
239
|
-
* Set to `Infinity` for an infinite number of requests.
|
|
240
|
-
*/
|
|
241
|
-
maxRetry?: number | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Amount of time, in milliseconds, after which a segment request should be
|
|
244
|
-
* aborted and optionally retried, depending on the current configuration.
|
|
245
|
-
*
|
|
246
|
-
* Setting it to `-1` allows to disable any timeout.
|
|
247
|
-
* `undefined` means that a default, large, timeout will be used instead.
|
|
248
|
-
*/
|
|
249
|
-
timeout?: number | undefined;
|
|
250
|
-
} | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Defines the retry parameters when requesting manifest
|
|
279
|
+
*/
|
|
280
|
+
manifest?: RequestRetryParameters | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* Defines the retry parameters when requesting a segment
|
|
283
|
+
*/
|
|
284
|
+
segment?: RequestRetryParameters | undefined;
|
|
251
285
|
}
|
|
252
286
|
export type ISegmentLoader = (
|
|
253
287
|
/** Information on the segment to request */
|
|
@@ -808,18 +842,55 @@ export interface ILockedAudioRepresentationsSettings {
|
|
|
808
842
|
switchingMode?: IAudioRepresentationsSwitchingMode | undefined;
|
|
809
843
|
}
|
|
810
844
|
export interface IAudioTrackSetting {
|
|
845
|
+
/** `id` of the audio track you want to set. */
|
|
811
846
|
trackId: string;
|
|
847
|
+
/**
|
|
848
|
+
* `id` of the Period for which you want that setting applied.
|
|
849
|
+
* Keeping it undefined means it will apply to the currently-playing Period.
|
|
850
|
+
*/
|
|
812
851
|
periodId?: string | undefined;
|
|
852
|
+
/**
|
|
853
|
+
* Behavior wanted when replacing an audio track / Adaptation by another.
|
|
854
|
+
* @see IAudioTrackSwitchingMode
|
|
855
|
+
*
|
|
856
|
+
* Keeping it undefined means that the RxPlayer will automatically select
|
|
857
|
+
* the most adapted choice.
|
|
858
|
+
*/
|
|
813
859
|
switchingMode?: IAudioTrackSwitchingMode | undefined;
|
|
860
|
+
/**
|
|
861
|
+
* Representations (a.k.a. qualities) you want to play in that new track.
|
|
862
|
+
* Keeping it undefined means that all compatible qualities may be played.
|
|
863
|
+
*/
|
|
814
864
|
lockedRepresentations?: string[] | undefined;
|
|
815
865
|
}
|
|
816
866
|
export interface IVideoTrackSetting {
|
|
867
|
+
/** `id` of the video track you want to set. */
|
|
817
868
|
trackId: string;
|
|
869
|
+
/**
|
|
870
|
+
* `id` of the Period for which you want that setting applied.
|
|
871
|
+
* Keeping it undefined means it will apply to the currently-playing Period.
|
|
872
|
+
*/
|
|
818
873
|
periodId?: string | undefined;
|
|
874
|
+
/**
|
|
875
|
+
* Behavior wanted when replacing an video track / Adaptation by another.
|
|
876
|
+
* @see IVideoTrackSwitchingMode
|
|
877
|
+
*
|
|
878
|
+
* Keeping it undefined means that the RxPlayer will automatically select
|
|
879
|
+
* the most adapted choice.
|
|
880
|
+
*/
|
|
819
881
|
switchingMode?: IVideoTrackSwitchingMode | undefined;
|
|
882
|
+
/**
|
|
883
|
+
* Representations (a.k.a. qualities) you want to play in that new track.
|
|
884
|
+
* Keeping it undefined means that all compatible qualities may be played.
|
|
885
|
+
*/
|
|
820
886
|
lockedRepresentations?: string[] | undefined;
|
|
821
887
|
}
|
|
822
888
|
export interface ITextTrackSetting {
|
|
889
|
+
/** `id` of the text track you want to set. */
|
|
823
890
|
trackId: string;
|
|
891
|
+
/**
|
|
892
|
+
* `id` of the Period for which you want that setting applied.
|
|
893
|
+
* Keeping it undefined means it will apply to the currently-playing Period.
|
|
894
|
+
*/
|
|
824
895
|
periodId?: string | undefined;
|
|
825
896
|
}
|
|
@@ -46,14 +46,16 @@ var byte_range_1 = require("../utils/byte_range");
|
|
|
46
46
|
function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
|
|
47
47
|
if (segment.range === undefined) {
|
|
48
48
|
return (0, request_1.default)({ url: url, responseType: "arraybuffer",
|
|
49
|
-
timeout: options.timeout,
|
|
49
|
+
timeout: options.timeout,
|
|
50
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
50
51
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
51
52
|
resultData: data }); });
|
|
52
53
|
}
|
|
53
54
|
if (segment.indexRange === undefined) {
|
|
54
55
|
return (0, request_1.default)({ url: url, headers: { Range: (0, byte_range_1.default)(segment.range) },
|
|
55
56
|
responseType: "arraybuffer",
|
|
56
|
-
timeout: options.timeout,
|
|
57
|
+
timeout: options.timeout,
|
|
58
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
57
59
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
58
60
|
resultData: data }); });
|
|
59
61
|
}
|
|
@@ -62,16 +64,19 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
|
|
|
62
64
|
return (0, request_1.default)({ url: url, headers: { Range: (0, byte_range_1.default)([segment.range[0],
|
|
63
65
|
segment.indexRange[1]]) },
|
|
64
66
|
responseType: "arraybuffer",
|
|
65
|
-
timeout: options.timeout,
|
|
67
|
+
timeout: options.timeout,
|
|
68
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
66
69
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
67
70
|
resultData: data }); });
|
|
68
71
|
}
|
|
69
72
|
var rangeRequest$ = (0, request_1.default)({ url: url, headers: { Range: (0, byte_range_1.default)(segment.range) },
|
|
70
73
|
responseType: "arraybuffer",
|
|
71
|
-
timeout: options.timeout,
|
|
74
|
+
timeout: options.timeout,
|
|
75
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress });
|
|
72
76
|
var indexRequest$ = (0, request_1.default)({ url: url, headers: { Range: (0, byte_range_1.default)(segment.indexRange) },
|
|
73
77
|
responseType: "arraybuffer",
|
|
74
|
-
timeout: options.timeout,
|
|
78
|
+
timeout: options.timeout,
|
|
79
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress });
|
|
75
80
|
return Promise.all([rangeRequest$, indexRequest$])
|
|
76
81
|
.then(function (_a) {
|
|
77
82
|
var _b = __read(_a, 2), initData = _b[0], indexData = _b[1];
|
|
@@ -109,12 +109,15 @@ function generateManifestParser(options) {
|
|
|
109
109
|
var externalResources = value.urls.map(function (resourceUrl) {
|
|
110
110
|
return scheduleRequest(function () {
|
|
111
111
|
var defaultTimeout = config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT;
|
|
112
|
+
var defaultConnectionTimeout = config_1.default.getCurrent().DEFAULT_CONNECTION_TIMEOUT;
|
|
112
113
|
return value.format === "string" ? (0, request_1.default)({ url: resourceUrl,
|
|
113
114
|
responseType: "text",
|
|
114
|
-
timeout: defaultTimeout,
|
|
115
|
+
timeout: defaultTimeout,
|
|
116
|
+
connectionTimeout: defaultConnectionTimeout, cancelSignal: cancelSignal }) :
|
|
115
117
|
(0, request_1.default)({ url: resourceUrl,
|
|
116
118
|
responseType: "arraybuffer",
|
|
117
|
-
timeout: defaultTimeout,
|
|
119
|
+
timeout: defaultTimeout,
|
|
120
|
+
connectionTimeout: defaultConnectionTimeout, cancelSignal: cancelSignal });
|
|
118
121
|
}).then(function (res) {
|
|
119
122
|
if (value.format === "string") {
|
|
120
123
|
if (typeof res.responseData !== "string") {
|
|
@@ -54,7 +54,8 @@ function regularSegmentLoader(url, context, lowLatencyMode, options, callbacks,
|
|
|
54
54
|
headers: segment.range !== undefined ?
|
|
55
55
|
{ Range: (0, byte_range_1.default)(segment.range) } :
|
|
56
56
|
undefined,
|
|
57
|
-
timeout: options.timeout,
|
|
57
|
+
timeout: options.timeout,
|
|
58
|
+
connectionTimeout: options.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
58
59
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
59
60
|
resultData: data }); });
|
|
60
61
|
}
|
|
@@ -68,6 +68,7 @@ function generateTextTrackLoader(_a) {
|
|
|
68
68
|
{ Range: (0, byte_range_1.default)(range) } :
|
|
69
69
|
null,
|
|
70
70
|
timeout: options.timeout,
|
|
71
|
+
connectionTimeout: options.connectionTimeout,
|
|
71
72
|
onProgress: callbacks.onProgress, cancelSignal: cancelSignal })
|
|
72
73
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
73
74
|
resultData: data }); });
|
|
@@ -77,6 +78,7 @@ function generateTextTrackLoader(_a) {
|
|
|
77
78
|
{ Range: (0, byte_range_1.default)(range) } :
|
|
78
79
|
null,
|
|
79
80
|
timeout: options.timeout,
|
|
81
|
+
connectionTimeout: options.connectionTimeout,
|
|
80
82
|
onProgress: callbacks.onProgress, cancelSignal: cancelSignal })
|
|
81
83
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
82
84
|
resultData: data }); });
|
|
@@ -28,7 +28,8 @@ function regularManifestLoader(url, loaderOptions, cancelSignal) {
|
|
|
28
28
|
throw new Error("Cannot perform HTTP(s) request. URL not known");
|
|
29
29
|
}
|
|
30
30
|
return (0, request_1.default)({ url: url, responseType: "text",
|
|
31
|
-
timeout: loaderOptions.timeout,
|
|
31
|
+
timeout: loaderOptions.timeout,
|
|
32
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal });
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* Generate a manifest loader for the application
|
|
@@ -117,7 +117,10 @@ function default_1(options) {
|
|
|
117
117
|
* Whether a ManifestLoader's timeout should be relied on here
|
|
118
118
|
* is ambiguous.
|
|
119
119
|
*/
|
|
120
|
-
var manOpts = {
|
|
120
|
+
var manOpts = {
|
|
121
|
+
timeout: config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT,
|
|
122
|
+
connectionTimeout: config_1.default.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
|
|
123
|
+
};
|
|
121
124
|
return transport.manifest.loadManifest(resource.url, manOpts, cancelSignal);
|
|
122
125
|
}
|
|
123
126
|
});
|
|
@@ -139,13 +139,15 @@ function default_1(transportOptions) {
|
|
|
139
139
|
var isMP4 = (0, is_mp4_embedded_track_1.default)(context.mimeType);
|
|
140
140
|
if (!isMP4) {
|
|
141
141
|
return (0, request_1.default)({ url: url, responseType: "text",
|
|
142
|
-
timeout: loaderOptions.timeout,
|
|
142
|
+
timeout: loaderOptions.timeout,
|
|
143
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
143
144
|
.then(function (data) { return ({ resultType: "segment-loaded",
|
|
144
145
|
resultData: data }); });
|
|
145
146
|
}
|
|
146
147
|
else {
|
|
147
148
|
return (0, request_1.default)({ url: url, responseType: "arraybuffer",
|
|
148
|
-
timeout: loaderOptions.timeout,
|
|
149
|
+
timeout: loaderOptions.timeout,
|
|
150
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
149
151
|
.then(function (data) {
|
|
150
152
|
if (transportOptions.checkMediaSegmentIntegrity !== true) {
|
|
151
153
|
return { resultType: "segment-loaded",
|
|
@@ -49,7 +49,8 @@ function regularSegmentLoader(url, context, callbacks, loaderOptions, cancelSign
|
|
|
49
49
|
if (Array.isArray(range)) {
|
|
50
50
|
headers = { Range: (0, byte_range_1.default)(range) };
|
|
51
51
|
}
|
|
52
|
-
return (0, request_1.default)({ url: url, responseType: "arraybuffer", headers: headers, timeout: loaderOptions.timeout,
|
|
52
|
+
return (0, request_1.default)({ url: url, responseType: "arraybuffer", headers: headers, timeout: loaderOptions.timeout,
|
|
53
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal, onProgress: callbacks.onProgress })
|
|
53
54
|
.then(function (data) {
|
|
54
55
|
var isMP4 = (0, is_mp4_embedded_track_1.default)(context.mimeType);
|
|
55
56
|
if (!isMP4 || checkMediaSegmentIntegrity !== true) {
|
|
@@ -135,6 +135,12 @@ export interface IManifestLoaderOptions {
|
|
|
135
135
|
* `undefined` means that no timeout will be enforced.
|
|
136
136
|
*/
|
|
137
137
|
timeout?: number | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Connection timeout, in milliseconds, after which the request is canceled
|
|
140
|
+
* if the responses headers has not being received.
|
|
141
|
+
* Do not set or set to "undefined" to disable it.
|
|
142
|
+
*/
|
|
143
|
+
connectionTimeout?: number | undefined;
|
|
138
144
|
}
|
|
139
145
|
/** Functions allowing to load and parse segments of any type. */
|
|
140
146
|
export interface ISegmentPipeline<TLoadedFormat, TParsedSegmentDataFormat> {
|
|
@@ -168,6 +174,12 @@ export interface ISegmentLoaderOptions {
|
|
|
168
174
|
* `undefined` means that no timeout will be enforced.
|
|
169
175
|
*/
|
|
170
176
|
timeout?: number | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Connection timeout, in milliseconds, after which the request is canceled
|
|
179
|
+
* if the responses headers has not being received.
|
|
180
|
+
* Do not set or set to "undefined" to disable it.
|
|
181
|
+
*/
|
|
182
|
+
connectionTimeout?: number | undefined;
|
|
171
183
|
}
|
|
172
184
|
/**
|
|
173
185
|
* Segment parser function, allowing to parse a chunk (which may be a sub-part
|
|
@@ -34,13 +34,16 @@ function generateRegularManifestLoader(preferredType) {
|
|
|
34
34
|
switch (preferredType) {
|
|
35
35
|
case "arraybuffer":
|
|
36
36
|
return (0, request_1.default)({ url: url, responseType: "arraybuffer",
|
|
37
|
-
timeout: loaderOptions.timeout,
|
|
37
|
+
timeout: loaderOptions.timeout,
|
|
38
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal });
|
|
38
39
|
case "text":
|
|
39
40
|
return (0, request_1.default)({ url: url, responseType: "text",
|
|
40
|
-
timeout: loaderOptions.timeout,
|
|
41
|
+
timeout: loaderOptions.timeout,
|
|
42
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal });
|
|
41
43
|
case "document":
|
|
42
44
|
return (0, request_1.default)({ url: url, responseType: "document",
|
|
43
|
-
timeout: loaderOptions.timeout,
|
|
45
|
+
timeout: loaderOptions.timeout,
|
|
46
|
+
connectionTimeout: loaderOptions.connectionTimeout, cancelSignal: cancelSignal });
|
|
44
47
|
default:
|
|
45
48
|
(0, assert_unreachable_1.default)(preferredType);
|
|
46
49
|
}
|
|
@@ -67,6 +67,12 @@ export interface IFetchOptions {
|
|
|
67
67
|
* if not all data has been received yet.
|
|
68
68
|
*/
|
|
69
69
|
timeout?: number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Optional connection timeout, in milliseconds, after which the request is canceled
|
|
72
|
+
* if the responses headers has not being received.
|
|
73
|
+
* Do not set or set to "undefined" to disable it.
|
|
74
|
+
*/
|
|
75
|
+
connectionTimeout?: number | undefined;
|
|
70
76
|
}
|
|
71
77
|
export default function fetchRequest(options: IFetchOptions): Promise<IFetchedStreamComplete>;
|
|
72
78
|
/**
|
|
@@ -79,7 +79,8 @@ function fetchRequest(options) {
|
|
|
79
79
|
}
|
|
80
80
|
log_1.default.debug("Fetch: Called with URL", options.url);
|
|
81
81
|
var cancellation = null;
|
|
82
|
-
var
|
|
82
|
+
var isTimedOut = false;
|
|
83
|
+
var isConnectionTimedOut = false;
|
|
83
84
|
var sendingTime = (0, monotonic_timestamp_1.default)();
|
|
84
85
|
var abortController = !(0, is_null_or_undefined_1.default)(_AbortController) ? new _AbortController() :
|
|
85
86
|
null;
|
|
@@ -94,13 +95,26 @@ function fetchRequest(options) {
|
|
|
94
95
|
}
|
|
95
96
|
abortController.abort();
|
|
96
97
|
}
|
|
97
|
-
var
|
|
98
|
+
var timeoutId;
|
|
98
99
|
if (options.timeout !== undefined) {
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
timeoutId = setTimeout(function () {
|
|
101
|
+
isTimedOut = true;
|
|
102
|
+
if (connectionTimeoutId !== undefined) {
|
|
103
|
+
clearTimeout(connectionTimeoutId);
|
|
104
|
+
}
|
|
101
105
|
abortFetch();
|
|
102
106
|
}, options.timeout);
|
|
103
107
|
}
|
|
108
|
+
var connectionTimeoutId;
|
|
109
|
+
if (options.connectionTimeout !== undefined) {
|
|
110
|
+
connectionTimeoutId = setTimeout(function () {
|
|
111
|
+
isConnectionTimedOut = true;
|
|
112
|
+
if (timeoutId !== undefined) {
|
|
113
|
+
clearTimeout(timeoutId);
|
|
114
|
+
}
|
|
115
|
+
abortFetch();
|
|
116
|
+
}, options.connectionTimeout);
|
|
117
|
+
}
|
|
104
118
|
var deregisterCancelLstnr = options.cancelSignal
|
|
105
119
|
.register(function abortRequest(err) {
|
|
106
120
|
cancellation = err;
|
|
@@ -113,8 +127,8 @@ function fetchRequest(options) {
|
|
|
113
127
|
fetchOpts.signal = !(0, is_null_or_undefined_1.default)(abortController) ? abortController.signal :
|
|
114
128
|
null;
|
|
115
129
|
return fetch(options.url, fetchOpts).then(function (response) {
|
|
116
|
-
if (
|
|
117
|
-
clearTimeout(
|
|
130
|
+
if (connectionTimeoutId !== undefined) {
|
|
131
|
+
clearTimeout(connectionTimeoutId);
|
|
118
132
|
}
|
|
119
133
|
if (response.status >= 300) {
|
|
120
134
|
log_1.default.warn("Fetch: Request HTTP Error", response.status, response.url);
|
|
@@ -147,6 +161,9 @@ function fetchRequest(options) {
|
|
|
147
161
|
return [2 /*return*/, readBufferAndSendEvents()];
|
|
148
162
|
}
|
|
149
163
|
else if (data.done) {
|
|
164
|
+
if (timeoutId !== undefined) {
|
|
165
|
+
clearTimeout(timeoutId);
|
|
166
|
+
}
|
|
150
167
|
deregisterCancelLstnr();
|
|
151
168
|
receivedTime = (0, monotonic_timestamp_1.default)();
|
|
152
169
|
requestDuration = receivedTime - sendingTime;
|
|
@@ -163,8 +180,12 @@ function fetchRequest(options) {
|
|
|
163
180
|
throw cancellation;
|
|
164
181
|
}
|
|
165
182
|
deregisterCancelLstnr();
|
|
166
|
-
if (
|
|
167
|
-
log_1.default.warn("Fetch: Request
|
|
183
|
+
if (isTimedOut) {
|
|
184
|
+
log_1.default.warn("Fetch: Request timed out.");
|
|
185
|
+
throw new errors_1.RequestError(options.url, 0, errors_1.NetworkErrorTypes.TIMEOUT);
|
|
186
|
+
}
|
|
187
|
+
else if (isConnectionTimedOut) {
|
|
188
|
+
log_1.default.warn("Fetch: Request connection timed out.");
|
|
168
189
|
throw new errors_1.RequestError(options.url, 0, errors_1.NetworkErrorTypes.TIMEOUT);
|
|
169
190
|
}
|
|
170
191
|
else if (err instanceof errors_1.RequestError) {
|
|
@@ -18,14 +18,14 @@ import { CancellationSignal } from "../task_canceller";
|
|
|
18
18
|
* Perform an HTTP request, according to the options given.
|
|
19
19
|
*
|
|
20
20
|
* Several errors can be rejected. Namely:
|
|
21
|
-
* -
|
|
22
|
-
*
|
|
23
|
-
* -
|
|
21
|
+
* - NetworkErrorTypes.TIMEOUT: the request timed out (took too long)
|
|
22
|
+
*
|
|
23
|
+
* - NetworkErrorTypes.PARSE_ERROR: the browser APIs used to parse the
|
|
24
24
|
* data failed.
|
|
25
|
-
* -
|
|
25
|
+
* - NetworkErrorTypes.ERROR_HTTP_CODE: the HTTP code at the time of reception
|
|
26
26
|
* was not in the 200-299 (included)
|
|
27
27
|
* range.
|
|
28
|
-
* -
|
|
28
|
+
* - NetworkErrorTypes.ERROR_EVENT: The XHR had an error event before the
|
|
29
29
|
* response could be fetched.
|
|
30
30
|
* @param {Object} options
|
|
31
31
|
* @returns {Promise.<Object>}
|
|
@@ -50,6 +50,12 @@ export interface IRequestOptions<ResponseType> {
|
|
|
50
50
|
* To not set or to set to `undefined` for disable.
|
|
51
51
|
*/
|
|
52
52
|
timeout?: number | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Optional connection timeout, in milliseconds, after which the request is canceled
|
|
55
|
+
* if the responses headers has not being received.
|
|
56
|
+
* Do not set or set to "undefined" to disable it.
|
|
57
|
+
*/
|
|
58
|
+
connectionTimeout?: number | undefined;
|
|
53
59
|
/**
|
|
54
60
|
* "Cancelation token" used to be able to cancel the request.
|
|
55
61
|
* When this token is "cancelled", the request will be aborted and the Promise
|
|
@@ -27,10 +27,11 @@ function request(options) {
|
|
|
27
27
|
responseType: (0, is_null_or_undefined_1.default)(options.responseType) ? DEFAULT_RESPONSE_TYPE :
|
|
28
28
|
options.responseType,
|
|
29
29
|
timeout: options.timeout,
|
|
30
|
+
connectionTimeout: options.connectionTimeout,
|
|
30
31
|
};
|
|
31
32
|
return new Promise(function (resolve, reject) {
|
|
32
33
|
var onProgress = options.onProgress, cancelSignal = options.cancelSignal;
|
|
33
|
-
var url = requestOptions.url, headers = requestOptions.headers, responseType = requestOptions.responseType, timeout = requestOptions.timeout;
|
|
34
|
+
var url = requestOptions.url, headers = requestOptions.headers, responseType = requestOptions.responseType, timeout = requestOptions.timeout, connectionTimeout = requestOptions.connectionTimeout;
|
|
34
35
|
var xhr = new XMLHttpRequest();
|
|
35
36
|
xhr.open("GET", url, true);
|
|
36
37
|
var timeoutId;
|
|
@@ -44,9 +45,19 @@ function request(options) {
|
|
|
44
45
|
// is more precise, it might also be more efficient.
|
|
45
46
|
timeoutId = setTimeout(function () {
|
|
46
47
|
clearCancellingProcess();
|
|
47
|
-
reject(new errors_1.RequestError(url, xhr.status,
|
|
48
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.TIMEOUT));
|
|
48
49
|
}, timeout + 3000);
|
|
49
50
|
}
|
|
51
|
+
var connectionTimeoutId;
|
|
52
|
+
if (connectionTimeout !== undefined) {
|
|
53
|
+
connectionTimeoutId = setTimeout(function () {
|
|
54
|
+
clearCancellingProcess();
|
|
55
|
+
if (xhr.readyState !== XMLHttpRequest.DONE) {
|
|
56
|
+
xhr.abort();
|
|
57
|
+
}
|
|
58
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.TIMEOUT));
|
|
59
|
+
}, connectionTimeout);
|
|
60
|
+
}
|
|
50
61
|
xhr.responseType = responseType;
|
|
51
62
|
if (xhr.responseType === "document") {
|
|
52
63
|
xhr.overrideMimeType("text/xml");
|
|
@@ -66,7 +77,7 @@ function request(options) {
|
|
|
66
77
|
deregisterCancellationListener = cancelSignal
|
|
67
78
|
.register(function abortRequest(err) {
|
|
68
79
|
clearCancellingProcess();
|
|
69
|
-
if (
|
|
80
|
+
if (xhr.readyState !== XMLHttpRequest.DONE) {
|
|
70
81
|
xhr.abort();
|
|
71
82
|
}
|
|
72
83
|
reject(err);
|
|
@@ -77,12 +88,19 @@ function request(options) {
|
|
|
77
88
|
}
|
|
78
89
|
xhr.onerror = function onXHRError() {
|
|
79
90
|
clearCancellingProcess();
|
|
80
|
-
reject(new errors_1.RequestError(url, xhr.status,
|
|
91
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.ERROR_EVENT));
|
|
81
92
|
};
|
|
82
93
|
xhr.ontimeout = function onXHRTimeout() {
|
|
83
94
|
clearCancellingProcess();
|
|
84
|
-
reject(new errors_1.RequestError(url, xhr.status,
|
|
95
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.TIMEOUT));
|
|
85
96
|
};
|
|
97
|
+
if (connectionTimeout !== undefined) {
|
|
98
|
+
xhr.onreadystatechange = function clearConnectionTimeout() {
|
|
99
|
+
if (xhr.readyState >= XMLHttpRequest.HEADERS_RECEIVED) {
|
|
100
|
+
clearTimeout(connectionTimeoutId);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
86
104
|
if (onProgress !== undefined) {
|
|
87
105
|
xhr.onprogress = function onXHRProgress(event) {
|
|
88
106
|
var currentTime = (0, monotonic_timestamp_1.default)();
|
|
@@ -91,7 +109,7 @@ function request(options) {
|
|
|
91
109
|
};
|
|
92
110
|
}
|
|
93
111
|
xhr.onload = function onXHRLoad(event) {
|
|
94
|
-
if (xhr.readyState ===
|
|
112
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
95
113
|
clearCancellingProcess();
|
|
96
114
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
97
115
|
var receivedTime = (0, monotonic_timestamp_1.default)();
|
|
@@ -115,7 +133,7 @@ function request(options) {
|
|
|
115
133
|
responseData = xhr.response;
|
|
116
134
|
}
|
|
117
135
|
if ((0, is_null_or_undefined_1.default)(responseData)) {
|
|
118
|
-
reject(new errors_1.RequestError(url, xhr.status,
|
|
136
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.PARSE_ERROR));
|
|
119
137
|
return;
|
|
120
138
|
}
|
|
121
139
|
resolve({ status: status_1, url: _url,
|
|
@@ -123,7 +141,7 @@ function request(options) {
|
|
|
123
141
|
size: totalSize, responseData: responseData });
|
|
124
142
|
}
|
|
125
143
|
else {
|
|
126
|
-
reject(new errors_1.RequestError(url, xhr.status,
|
|
144
|
+
reject(new errors_1.RequestError(url, xhr.status, errors_1.NetworkErrorTypes.ERROR_HTTP_CODE));
|
|
127
145
|
}
|
|
128
146
|
}
|
|
129
147
|
};
|
|
@@ -135,6 +153,9 @@ function request(options) {
|
|
|
135
153
|
if (timeoutId !== undefined) {
|
|
136
154
|
clearTimeout(timeoutId);
|
|
137
155
|
}
|
|
156
|
+
if (connectionTimeoutId !== undefined) {
|
|
157
|
+
clearTimeout(connectionTimeoutId);
|
|
158
|
+
}
|
|
138
159
|
if (deregisterCancellationListener !== null) {
|
|
139
160
|
deregisterCancellationListener();
|
|
140
161
|
}
|
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { MediaSource_ } from "./browser_compatibility_types";
|
|
17
|
+
/**
|
|
18
|
+
* Setting this value limit the number of entries in the support map
|
|
19
|
+
* preventing important memory usage, value is arbitrary
|
|
20
|
+
*/
|
|
21
|
+
const MAX_SUPPORT_MAP_ENTRIES = 200;
|
|
22
|
+
/**
|
|
23
|
+
* caching the codec support reduce the amount of call to `isTypeSupported`
|
|
24
|
+
* and help for performance especially on low-end devices.
|
|
25
|
+
*/
|
|
26
|
+
const supportMap = new Map();
|
|
17
27
|
/**
|
|
18
28
|
* Returns true if the given codec is supported by the browser's MediaSource
|
|
19
29
|
* implementation.
|
|
@@ -30,7 +40,18 @@ export default function isCodecSupported(mimeType) {
|
|
|
30
40
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
31
41
|
if (typeof MediaSource_.isTypeSupported === "function") {
|
|
32
42
|
/* eslint-enable @typescript-eslint/unbound-method */
|
|
33
|
-
|
|
43
|
+
const cachedSupport = supportMap.get(mimeType);
|
|
44
|
+
if (cachedSupport !== undefined) {
|
|
45
|
+
return cachedSupport;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const isSupported = MediaSource_.isTypeSupported(mimeType);
|
|
49
|
+
if (supportMap.size >= MAX_SUPPORT_MAP_ENTRIES) {
|
|
50
|
+
supportMap.clear();
|
|
51
|
+
}
|
|
52
|
+
supportMap.set(mimeType, isSupported);
|
|
53
|
+
return isSupported;
|
|
54
|
+
}
|
|
34
55
|
}
|
|
35
56
|
return true;
|
|
36
57
|
}
|