rx-player 4.0.0-beta.0 → 4.0.0-beta.2
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/.eslintrc.js +8 -0
- package/CHANGELOG.md +93 -0
- package/CONTRIBUTING.md +48 -168
- package/FILES.md +40 -92
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +25 -12
- package/dist/_esm5.processed/compat/browser_detection.js +85 -38
- package/dist/_esm5.processed/compat/can_reuse_media_keys.js +2 -2
- package/dist/_esm5.processed/compat/eme/close_session.js +2 -2
- package/dist/_esm5.processed/compat/eme/load_session.js +1 -1
- package/dist/_esm5.processed/compat/event_listeners.js +1 -1
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.d.ts +21 -0
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.js +26 -0
- package/dist/_esm5.processed/config.d.ts +4 -0
- package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +9 -6
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +18 -1
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +106 -25
- package/dist/_esm5.processed/core/adaptive/guess_based_chooser.js +6 -6
- package/dist/_esm5.processed/core/adaptive/network_analyzer.js +8 -5
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.d.ts +19 -1
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.js +1 -1
- package/dist/_esm5.processed/core/api/debug/buffer_graph.d.ts +28 -0
- package/dist/_esm5.processed/core/api/debug/buffer_graph.js +175 -0
- package/dist/_esm5.processed/core/api/debug/buffer_size_graph.d.ts +10 -0
- package/dist/_esm5.processed/core/api/debug/buffer_size_graph.js +104 -0
- package/dist/_esm5.processed/core/api/debug/constants.d.ts +2 -0
- package/dist/_esm5.processed/core/api/debug/constants.js +2 -0
- package/dist/_esm5.processed/core/api/debug/index.d.ts +2 -0
- package/dist/_esm5.processed/core/api/debug/index.js +2 -0
- package/dist/_esm5.processed/core/api/debug/modules/general_info.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/modules/general_info.js +180 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.d.ts +4 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +121 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +35 -0
- package/dist/_esm5.processed/core/api/debug/render.d.ts +3 -0
- package/dist/_esm5.processed/core/api/debug/render.js +32 -0
- package/dist/_esm5.processed/core/api/debug/utils.d.ts +39 -0
- package/dist/_esm5.processed/core/api/debug/utils.js +57 -0
- package/dist/_esm5.processed/core/api/playback_observer.js +4 -2
- package/dist/_esm5.processed/core/api/public_api.d.ts +60 -3
- package/dist/_esm5.processed/core/api/public_api.js +280 -60
- package/dist/_esm5.processed/core/api/track_management/media_element_tracks_store.js +10 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +13 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +30 -15
- package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +3 -1
- package/dist/_esm5.processed/core/api/track_management/tracks_store.js +67 -152
- package/dist/_esm5.processed/core/api/utils.d.ts +10 -0
- package/dist/_esm5.processed/core/api/utils.js +23 -3
- package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +27 -8
- package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +28 -7
- package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +1 -1
- package/dist/_esm5.processed/core/decrypt/content_decryptor.js +1 -1
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +29 -6
- package/dist/_esm5.processed/core/decrypt/session_events_listener.js +42 -32
- package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +4 -0
- package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +2 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +5 -1
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +17 -8
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +10 -6
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +5 -4
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +22 -5
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +37 -21
- package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +21 -23
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +17 -7
- package/dist/_esm5.processed/core/init/directfile_content_initializer.js +2 -2
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +74 -41
- package/dist/_esm5.processed/core/init/types.d.ts +9 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +28 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +24 -11
- package/dist/_esm5.processed/core/init/utils/create_media_source.js +3 -12
- package/dist/_esm5.processed/core/init/utils/end_of_stream.js +6 -3
- package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +2 -1
- package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +9 -5
- package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +2 -1
- package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.d.ts +58 -0
- package/dist/_esm5.processed/core/init/utils/{media_duration_updater.js → media_source_duration_updater.js} +87 -86
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +36 -2
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +83 -3
- package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +6 -4
- package/dist/_esm5.processed/core/init/utils/throw_on_media_error.js +1 -1
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +18 -7
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +38 -50
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +16 -2
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +12 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +11 -4
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +13 -9
- package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +30 -16
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts +47 -0
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +70 -0
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +41 -20
- package/dist/_esm5.processed/core/stream/period/period_stream.js +12 -11
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +37 -28
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.d.ts +4 -2
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +3 -3
- package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +16 -6
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +3 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +8 -8
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +2 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +2 -3
- package/dist/_esm5.processed/core/stream/utils/create_reload_request.js +1 -1
- package/dist/_esm5.processed/default_config.d.ts +41 -0
- package/dist/_esm5.processed/default_config.js +46 -2
- package/dist/_esm5.processed/errors/index.d.ts +2 -2
- package/dist/_esm5.processed/errors/media_error.d.ts +23 -1
- package/dist/_esm5.processed/errors/media_error.js +18 -5
- package/dist/_esm5.processed/experimental/features/debug_element.d.ts +8 -0
- package/dist/_esm5.processed/experimental/features/debug_element.js +10 -0
- package/dist/_esm5.processed/experimental/features/index.d.ts +1 -0
- package/dist/_esm5.processed/experimental/features/index.js +1 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +1 -1
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +8 -7
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +7 -4
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +24 -12
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/index.js +0 -2
- package/dist/_esm5.processed/features/features_object.js +1 -0
- package/dist/_esm5.processed/features/initialize_features.js +13 -10
- package/dist/_esm5.processed/features/types.d.ts +3 -0
- package/dist/_esm5.processed/manifest/adaptation.d.ts +21 -2
- package/dist/_esm5.processed/manifest/adaptation.js +80 -1
- package/dist/_esm5.processed/manifest/manifest.js +2 -0
- package/dist/_esm5.processed/manifest/period.js +2 -2
- package/dist/_esm5.processed/manifest/representation.d.ts +33 -2
- package/dist/_esm5.processed/manifest/representation.js +32 -4
- package/dist/_esm5.processed/manifest/utils.js +1 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +105 -137
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +25 -5
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -0
- package/dist/_esm5.processed/public_types.d.ts +13 -3
- package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +1 -1
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +15 -11
- package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
- package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -4
- package/dist/_esm5.processed/transports/local/segment_loader.js +13 -26
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.d.ts +4 -6
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.js +4 -6
- package/dist/_esm5.processed/transports/smooth/segment_loader.js +4 -4
- package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
- package/dist/_esm5.processed/utils/cancellable_sleep.js +4 -10
- package/dist/_esm5.processed/utils/create_cancellable_promise.d.ts +26 -0
- package/dist/_esm5.processed/utils/create_cancellable_promise.js +52 -0
- package/dist/_esm5.processed/utils/is_null_or_undefined.d.ts +1 -1
- package/dist/_esm5.processed/utils/is_null_or_undefined.js +1 -1
- package/dist/_esm5.processed/utils/reference.js +6 -0
- package/dist/_esm5.processed/utils/request/xhr.js +1 -1
- package/dist/_esm5.processed/utils/task_canceller.d.ts +34 -15
- package/dist/_esm5.processed/utils/task_canceller.js +55 -22
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +5424 -4712
- package/dist/rx-player.min.js +1 -1
- package/jest.config.js +1 -5
- package/package.json +44 -40
- package/scripts/build/constants.d.ts +1 -0
- package/scripts/build/generate_build.js +1 -1
- package/scripts/fast_demo_build.js +40 -40
- package/scripts/generate_full_demo.js +1 -1
- package/sonar-project.properties +1 -1
- package/src/compat/browser_detection.ts +105 -52
- package/src/compat/can_reuse_media_keys.ts +5 -2
- package/src/compat/eme/close_session.ts +2 -2
- package/src/compat/eme/load_session.ts +1 -1
- package/src/compat/event_listeners.ts +1 -1
- package/src/compat/has_issues_with_high_media_source_duration.ts +27 -0
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +147 -48
- package/src/core/adaptive/adaptive_representation_selector.ts +11 -6
- package/src/core/adaptive/buffer_based_chooser.ts +144 -26
- package/src/core/adaptive/guess_based_chooser.ts +9 -8
- package/src/core/adaptive/network_analyzer.ts +9 -4
- package/src/core/adaptive/utils/representation_score_calculator.ts +22 -2
- package/src/core/api/debug/buffer_graph.ts +247 -0
- package/src/core/api/debug/buffer_size_graph.ts +130 -0
- package/src/core/api/debug/constants.ts +2 -0
- package/src/core/api/debug/index.ts +3 -0
- package/src/core/api/debug/modules/general_info.ts +184 -0
- package/src/core/api/debug/modules/segment_buffer_content.ts +155 -0
- package/src/core/api/debug/modules/segment_buffer_size.ts +48 -0
- package/src/core/api/debug/render.ts +40 -0
- package/src/core/api/debug/utils.ts +103 -0
- package/src/core/api/playback_observer.ts +5 -2
- package/src/core/api/public_api.ts +334 -73
- package/src/core/api/track_management/media_element_tracks_store.ts +17 -8
- package/src/core/api/track_management/track_dispatcher.ts +37 -14
- package/src/core/api/track_management/tracks_store.ts +77 -167
- package/src/core/api/utils.ts +29 -3
- package/src/core/decrypt/__tests__/__global__/utils.ts +61 -40
- package/src/core/decrypt/attach_media_keys.ts +1 -1
- package/src/core/decrypt/content_decryptor.ts +1 -1
- package/src/core/decrypt/find_key_system.ts +25 -11
- package/src/core/decrypt/session_events_listener.ts +45 -39
- package/src/core/decrypt/utils/check_key_statuses.ts +6 -0
- package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +2 -1
- package/src/core/decrypt/utils/loaded_sessions_store.ts +8 -1
- package/src/core/fetchers/cdn_prioritizer.ts +18 -9
- package/src/core/fetchers/manifest/manifest_fetcher.ts +5 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +36 -14
- package/src/core/fetchers/segment/task_prioritizer.ts +25 -30
- package/src/core/fetchers/utils/schedule_request.ts +18 -7
- package/src/core/init/directfile_content_initializer.ts +2 -1
- package/src/core/init/media_source_content_initializer.ts +89 -50
- package/src/core/init/types.ts +9 -1
- package/src/core/init/utils/content_time_boundaries_observer.ts +48 -12
- package/src/core/init/utils/create_media_source.ts +4 -16
- package/src/core/init/utils/end_of_stream.ts +6 -3
- package/src/core/init/utils/get_loaded_reference.ts +2 -1
- package/src/core/init/utils/initial_seek_and_play.ts +9 -5
- package/src/core/init/utils/initialize_content_decryption.ts +2 -1
- package/src/core/init/utils/{media_duration_updater.ts → media_source_duration_updater.ts} +103 -110
- package/src/core/init/utils/rebuffering_controller.ts +115 -4
- package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +6 -4
- package/src/core/init/utils/throw_on_media_error.ts +1 -1
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +63 -66
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +20 -2
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +16 -0
- package/src/core/segment_buffers/implementations/types.ts +16 -4
- package/src/core/segment_buffers/index.ts +2 -0
- package/src/core/segment_buffers/segment_buffers_store.ts +16 -13
- package/src/core/stream/adaptation/adaptation_stream.ts +33 -19
- package/src/core/stream/adaptation/utils/create_representation_estimator.ts +114 -0
- package/src/core/stream/orchestrator/stream_orchestrator.ts +42 -20
- package/src/core/stream/period/period_stream.ts +13 -11
- package/src/core/stream/representation/representation_stream.ts +49 -37
- package/src/core/stream/representation/utils/append_segment_to_buffer.ts +9 -4
- package/src/core/stream/representation/utils/downloading_queue.ts +16 -4
- package/src/core/stream/representation/utils/push_init_segment.ts +11 -6
- package/src/core/stream/representation/utils/push_media_segment.ts +3 -3
- package/src/core/stream/utils/create_reload_request.ts +1 -1
- package/src/default_config.ts +59 -11
- package/src/errors/__tests__/media_error.test.ts +6 -6
- package/src/errors/index.ts +4 -1
- package/src/errors/media_error.ts +67 -1
- package/src/experimental/features/__tests__/debug_element.test.ts +26 -0
- package/src/experimental/features/debug_element.ts +13 -0
- package/src/experimental/features/index.ts +1 -0
- package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +10 -7
- package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +7 -4
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +25 -10
- package/src/experimental/tools/mediaCapabilitiesProber/index.ts +0 -4
- package/src/features/__tests__/initialize_features.test.ts +11 -0
- package/src/features/features_object.ts +1 -0
- package/src/features/initialize_features.ts +15 -10
- package/src/features/types.ts +9 -0
- package/src/manifest/__tests__/manifest.test.ts +7 -7
- package/src/manifest/__tests__/period.test.ts +90 -45
- package/src/manifest/adaptation.ts +96 -1
- package/src/manifest/manifest.ts +4 -0
- package/src/manifest/period.ts +4 -2
- package/src/manifest/representation.ts +77 -5
- package/src/manifest/utils.ts +1 -3
- package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +116 -151
- package/src/parsers/manifest/dash/common/parse_representations.ts +21 -4
- package/src/parsers/manifest/dash/js-parser/parse_from_document.ts +1 -1
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -0
- package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
- package/src/public_types.ts +16 -1
- package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -1
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +31 -22
- package/src/transports/dash/low_latency_segment_loader.ts +2 -2
- package/src/transports/dash/manifest_parser.ts +1 -1
- package/src/transports/dash/segment_loader.ts +4 -4
- package/src/transports/local/segment_loader.ts +14 -30
- package/src/transports/smooth/isobmff/create_boxes.ts +4 -6
- package/src/transports/smooth/segment_loader.ts +4 -4
- package/src/transports/utils/call_custom_manifest_loader.ts +3 -3
- package/src/typings/globals.d.ts +21 -19
- package/src/utils/cancellable_sleep.ts +5 -14
- package/src/utils/create_cancellable_promise.ts +69 -0
- package/src/utils/is_null_or_undefined.ts +1 -1
- package/src/utils/reference.ts +6 -0
- package/src/utils/request/xhr.ts +1 -1
- package/src/utils/task_canceller.ts +63 -34
- package/tsconfig.json +1 -1
- package/tsconfig.modules.json +1 -1
- package/dist/_esm5.processed/core/init/utils/media_duration_updater.d.ts +0 -56
- package/locked_reps.js +0 -46
- package/scripts/doc-generator/construct_table_of_contents.js +0 -76
- package/scripts/doc-generator/convert_MD_to_HMTL.js +0 -26
- package/scripts/doc-generator/create_documentation.js +0 -331
- package/scripts/doc-generator/create_documentation_page.js +0 -209
- package/scripts/doc-generator/create_page.js +0 -210
- package/scripts/doc-generator/generate_header_html.js +0 -147
- package/scripts/doc-generator/generate_page_html.js +0 -115
- package/scripts/doc-generator/generate_page_list_html.js +0 -92
- package/scripts/doc-generator/generate_sidebar_html.js +0 -85
- package/scripts/doc-generator/get_search_data_for_content.js +0 -137
- package/scripts/doc-generator/index.js +0 -34
- package/scripts/doc-generator/parse_doc_configs.js +0 -327
- package/scripts/doc-generator/scripts/lunr.js +0 -10
- package/scripts/doc-generator/scripts/script.js +0 -451
- package/scripts/doc-generator/styles/code.css +0 -99
- package/scripts/doc-generator/styles/style.css +0 -835
- package/scripts/doc-generator/utils.js +0 -74
|
@@ -49,16 +49,25 @@ export default class AudioVideoSegmentBuffer extends SegmentBuffer {
|
|
|
49
49
|
*/
|
|
50
50
|
private _pendingTask;
|
|
51
51
|
/**
|
|
52
|
-
* Keep track of the of the latest init segment
|
|
53
|
-
* SourceBuffer.
|
|
52
|
+
* Keep track of the unique identifier of the of the latest init segment
|
|
53
|
+
* pushed to the linked SourceBuffer.
|
|
54
54
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* Such identifiers are first declared through the `declareInitSegment`
|
|
56
|
+
* method and the corresponding initialization segment is then pushed through
|
|
57
|
+
* the `pushChunk` method.
|
|
58
|
+
*
|
|
59
|
+
* Keeping track of this allows to be sure the right initialization segment is
|
|
60
|
+
* pushed before any chunk is.
|
|
57
61
|
*
|
|
58
62
|
* `null` if no initialization segment have been pushed to the
|
|
59
63
|
* `AudioVideoSegmentBuffer` yet.
|
|
60
64
|
*/
|
|
61
|
-
private
|
|
65
|
+
private _lastInitSegmentUniqueId;
|
|
66
|
+
/**
|
|
67
|
+
* Link unique identifiers for initialization segments (as communicated by
|
|
68
|
+
* `declareInitSegment`) to the corresponding initialization data.
|
|
69
|
+
*/
|
|
70
|
+
private _initSegmentsMap;
|
|
62
71
|
/**
|
|
63
72
|
* @constructor
|
|
64
73
|
* @param {string} bufferType
|
|
@@ -66,6 +75,8 @@ export default class AudioVideoSegmentBuffer extends SegmentBuffer {
|
|
|
66
75
|
* @param {MediaSource} mediaSource
|
|
67
76
|
*/
|
|
68
77
|
constructor(bufferType: "audio" | "video", codec: string, mediaSource: MediaSource);
|
|
78
|
+
declareInitSegment(uniqueId: string, initSegmentData: unknown): void;
|
|
79
|
+
freeInitSegment(uniqueId: string): void;
|
|
69
80
|
/**
|
|
70
81
|
* Push a chunk of the media segment given to the attached SourceBuffer, in a
|
|
71
82
|
* FIFO queue.
|
|
@@ -162,9 +173,9 @@ export default class AudioVideoSegmentBuffer extends SegmentBuffer {
|
|
|
162
173
|
*/
|
|
163
174
|
private _preparePushOperation;
|
|
164
175
|
/**
|
|
165
|
-
* Return `true` if the given `
|
|
176
|
+
* Return `true` if the given `uniqueId` is the identifier of the last
|
|
166
177
|
* initialization segment pushed to the `AudioVideoSegmentBuffer`.
|
|
167
|
-
* @param {
|
|
178
|
+
* @param {string} uniqueId
|
|
168
179
|
* @returns {boolean}
|
|
169
180
|
*/
|
|
170
181
|
private _isLastInitSegment;
|
|
@@ -32,10 +32,8 @@ import { tryToChangeSourceBufferType, } from "../../../../compat";
|
|
|
32
32
|
import config from "../../../../config";
|
|
33
33
|
import log from "../../../../log";
|
|
34
34
|
import { getLoggableSegmentId } from "../../../../manifest";
|
|
35
|
-
import areArraysOfNumbersEqual from "../../../../utils/are_arrays_of_numbers_equal";
|
|
36
35
|
import assertUnreachable from "../../../../utils/assert_unreachable";
|
|
37
|
-
import
|
|
38
|
-
import hashBuffer from "../../../../utils/hash_buffer";
|
|
36
|
+
import createCancellablePromise from "../../../../utils/create_cancellable_promise";
|
|
39
37
|
import noop from "../../../../utils/noop";
|
|
40
38
|
import objectAssign from "../../../../utils/object_assign";
|
|
41
39
|
import TaskCanceller, { CancellationError, } from "../../../../utils/task_canceller";
|
|
@@ -67,8 +65,9 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
67
65
|
_this._sourceBuffer = sourceBuffer;
|
|
68
66
|
_this._queue = [];
|
|
69
67
|
_this._pendingTask = null;
|
|
70
|
-
_this.
|
|
68
|
+
_this._lastInitSegmentUniqueId = null;
|
|
71
69
|
_this.codec = codec;
|
|
70
|
+
_this._initSegmentsMap = new Map();
|
|
72
71
|
var onError = _this._onPendingTaskError.bind(_this);
|
|
73
72
|
var reCheck = _this._flush.bind(_this);
|
|
74
73
|
// Some browsers (happened with firefox 66) sometimes "forget" to send us
|
|
@@ -88,6 +87,13 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
88
87
|
});
|
|
89
88
|
return _this;
|
|
90
89
|
}
|
|
90
|
+
AudioVideoSegmentBuffer.prototype.declareInitSegment = function (uniqueId, initSegmentData) {
|
|
91
|
+
assertDataIsBufferSource(initSegmentData);
|
|
92
|
+
this._initSegmentsMap.set(uniqueId, initSegmentData);
|
|
93
|
+
};
|
|
94
|
+
AudioVideoSegmentBuffer.prototype.freeInitSegment = function (uniqueId) {
|
|
95
|
+
this._initSegmentsMap.delete(uniqueId);
|
|
96
|
+
};
|
|
91
97
|
/**
|
|
92
98
|
* Push a chunk of the media segment given to the attached SourceBuffer, in a
|
|
93
99
|
* FIFO queue.
|
|
@@ -116,7 +122,7 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
116
122
|
* @returns {Promise}
|
|
117
123
|
*/
|
|
118
124
|
AudioVideoSegmentBuffer.prototype.pushChunk = function (infos, cancellationSignal) {
|
|
119
|
-
|
|
125
|
+
assertDataIsBufferSource(infos.data.chunk);
|
|
120
126
|
log.debug("AVSB: receiving order to push data to the SourceBuffer", this.bufferType, getLoggableSegmentId(infos.inventoryInfos));
|
|
121
127
|
return this._addToQueue({ type: SegmentBufferOperation.Push,
|
|
122
128
|
value: infos }, cancellationSignal);
|
|
@@ -210,7 +216,7 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
210
216
|
* @param {Event} err
|
|
211
217
|
*/
|
|
212
218
|
AudioVideoSegmentBuffer.prototype._onPendingTaskError = function (err) {
|
|
213
|
-
this.
|
|
219
|
+
this._lastInitSegmentUniqueId = null; // initialize init segment as a security
|
|
214
220
|
if (this._pendingTask !== null) {
|
|
215
221
|
var error = err instanceof Error ?
|
|
216
222
|
err :
|
|
@@ -227,15 +233,15 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
227
233
|
*/
|
|
228
234
|
AudioVideoSegmentBuffer.prototype._addToQueue = function (operation, cancellationSignal) {
|
|
229
235
|
var _this = this;
|
|
230
|
-
return
|
|
231
|
-
if (cancellationSignal.cancellationError !== null) {
|
|
232
|
-
return reject(cancellationSignal.cancellationError);
|
|
233
|
-
}
|
|
236
|
+
return createCancellablePromise(cancellationSignal, function (resolve, reject) {
|
|
234
237
|
var shouldRestartQueue = _this._queue.length === 0 &&
|
|
235
238
|
_this._pendingTask === null;
|
|
236
239
|
var queueItem = objectAssign({ resolve: resolve, reject: reject }, operation);
|
|
237
240
|
_this._queue.push(queueItem);
|
|
238
|
-
|
|
241
|
+
if (shouldRestartQueue) {
|
|
242
|
+
_this._flush();
|
|
243
|
+
}
|
|
244
|
+
return function () {
|
|
239
245
|
// Remove the corresponding element from the AudioVideoSegmentBuffer's
|
|
240
246
|
// queue.
|
|
241
247
|
// If the operation was a pending task, it should still continue to not
|
|
@@ -246,11 +252,7 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
246
252
|
}
|
|
247
253
|
queueItem.resolve = noop;
|
|
248
254
|
queueItem.reject = noop;
|
|
249
|
-
|
|
250
|
-
});
|
|
251
|
-
if (shouldRestartQueue) {
|
|
252
|
-
_this._flush();
|
|
253
|
-
}
|
|
255
|
+
};
|
|
254
256
|
});
|
|
255
257
|
};
|
|
256
258
|
/**
|
|
@@ -307,7 +309,7 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
307
309
|
var error = e instanceof Error ?
|
|
308
310
|
e :
|
|
309
311
|
new Error("An unknown error occured when preparing a push operation");
|
|
310
|
-
this.
|
|
312
|
+
this._lastInitSegmentUniqueId = null; // initialize init segment as a security
|
|
311
313
|
nextItem.reject(error);
|
|
312
314
|
return;
|
|
313
315
|
}
|
|
@@ -395,14 +397,16 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
395
397
|
else if (appendWindow[1] !== this._sourceBuffer.appendWindowEnd) {
|
|
396
398
|
this._sourceBuffer.appendWindowEnd = appendWindow[1];
|
|
397
399
|
}
|
|
398
|
-
if (data.
|
|
399
|
-
(hasUpdatedSourceBufferType ||
|
|
400
|
+
if (data.initSegmentUniqueId !== null &&
|
|
401
|
+
(hasUpdatedSourceBufferType ||
|
|
402
|
+
!this._isLastInitSegment(data.initSegmentUniqueId))) {
|
|
400
403
|
// Push initialization segment before the media segment
|
|
401
|
-
var segmentData = data.
|
|
404
|
+
var segmentData = this._initSegmentsMap.get(data.initSegmentUniqueId);
|
|
405
|
+
if (segmentData === undefined) {
|
|
406
|
+
throw new Error("Invalid initialization segment uniqueId");
|
|
407
|
+
}
|
|
402
408
|
dataToPush.push(segmentData);
|
|
403
|
-
|
|
404
|
-
this._lastInitSegment = { data: initU8,
|
|
405
|
-
hash: hashBuffer(initU8) };
|
|
409
|
+
this._lastInitSegmentUniqueId = data.initSegmentUniqueId;
|
|
406
410
|
}
|
|
407
411
|
if (data.chunk !== null) {
|
|
408
412
|
dataToPush.push(data.chunk);
|
|
@@ -410,27 +414,16 @@ var AudioVideoSegmentBuffer = /** @class */ (function (_super) {
|
|
|
410
414
|
return dataToPush;
|
|
411
415
|
};
|
|
412
416
|
/**
|
|
413
|
-
* Return `true` if the given `
|
|
417
|
+
* Return `true` if the given `uniqueId` is the identifier of the last
|
|
414
418
|
* initialization segment pushed to the `AudioVideoSegmentBuffer`.
|
|
415
|
-
* @param {
|
|
419
|
+
* @param {string} uniqueId
|
|
416
420
|
* @returns {boolean}
|
|
417
421
|
*/
|
|
418
|
-
AudioVideoSegmentBuffer.prototype._isLastInitSegment = function (
|
|
419
|
-
if (this.
|
|
422
|
+
AudioVideoSegmentBuffer.prototype._isLastInitSegment = function (uniqueId) {
|
|
423
|
+
if (this._lastInitSegmentUniqueId === null) {
|
|
420
424
|
return false;
|
|
421
425
|
}
|
|
422
|
-
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
var oldInit = this._lastInitSegment.data;
|
|
426
|
-
if (oldInit.byteLength === segmentData.byteLength) {
|
|
427
|
-
var newInitU8 = toUint8Array(segmentData);
|
|
428
|
-
if (hashBuffer(newInitU8) === this._lastInitSegment.hash &&
|
|
429
|
-
areArraysOfNumbersEqual(oldInit, newInitU8)) {
|
|
430
|
-
return true;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return false;
|
|
426
|
+
return this._lastInitSegmentUniqueId === uniqueId;
|
|
434
427
|
};
|
|
435
428
|
return AudioVideoSegmentBuffer;
|
|
436
429
|
}(SegmentBuffer));
|
|
@@ -439,21 +432,16 @@ export default AudioVideoSegmentBuffer;
|
|
|
439
432
|
* Throw if the given input is not in the expected format.
|
|
440
433
|
* Allows to enforce runtime type-checking as compile-time type-checking here is
|
|
441
434
|
* difficult to enforce.
|
|
442
|
-
* @param {Object}
|
|
435
|
+
* @param {Object} data
|
|
443
436
|
*/
|
|
444
|
-
function
|
|
437
|
+
function assertDataIsBufferSource(data) {
|
|
445
438
|
if (0 /* __ENVIRONMENT__.CURRENT_ENV */ === 0 /* __ENVIRONMENT__.PRODUCTION */) {
|
|
446
439
|
return;
|
|
447
440
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
!(chunk instanceof ArrayBuffer) &&
|
|
453
|
-
!(chunk.buffer instanceof ArrayBuffer)) ||
|
|
454
|
-
(initSegment !== null &&
|
|
455
|
-
!(initSegment instanceof ArrayBuffer) &&
|
|
456
|
-
!(initSegment.buffer instanceof ArrayBuffer))) {
|
|
441
|
+
if (typeof data !== "object" ||
|
|
442
|
+
(data !== null &&
|
|
443
|
+
!(data instanceof ArrayBuffer) &&
|
|
444
|
+
!(data.buffer instanceof ArrayBuffer))) {
|
|
457
445
|
throw new Error("Invalid data given to the AudioVideoSegmentBuffer");
|
|
458
446
|
}
|
|
459
447
|
}
|
|
@@ -47,6 +47,14 @@ export default class HTMLTextSegmentBuffer extends SegmentBuffer {
|
|
|
47
47
|
* @param {HTMLElement} textTrackElement
|
|
48
48
|
*/
|
|
49
49
|
constructor(videoElement: HTMLMediaElement, textTrackElement: HTMLElement);
|
|
50
|
+
/**
|
|
51
|
+
* @param {string} uniqueId
|
|
52
|
+
*/
|
|
53
|
+
declareInitSegment(uniqueId: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} uniqueId
|
|
56
|
+
*/
|
|
57
|
+
freeInitSegment(uniqueId: string): void;
|
|
50
58
|
/**
|
|
51
59
|
* Push text segment to the HTMLTextSegmentBuffer.
|
|
52
60
|
* @param {Object} infos
|
|
@@ -93,6 +93,18 @@ var HTMLTextSegmentBuffer = /** @class */ (function (_super) {
|
|
|
93
93
|
_this.autoRefreshSubtitles(_this._canceller.signal);
|
|
94
94
|
return _this;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} uniqueId
|
|
98
|
+
*/
|
|
99
|
+
HTMLTextSegmentBuffer.prototype.declareInitSegment = function (uniqueId) {
|
|
100
|
+
log.warn("ISB: Declaring initialization segment for image SegmentBuffer", uniqueId);
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} uniqueId
|
|
104
|
+
*/
|
|
105
|
+
HTMLTextSegmentBuffer.prototype.freeInitSegment = function (uniqueId) {
|
|
106
|
+
log.warn("ISB: Freeing initialization segment for image SegmentBuffer", uniqueId);
|
|
107
|
+
};
|
|
96
108
|
/**
|
|
97
109
|
* Push text segment to the HTMLTextSegmentBuffer.
|
|
98
110
|
* @param {Object} infos
|
|
@@ -272,7 +284,8 @@ var HTMLTextSegmentBuffer = /** @class */ (function (_super) {
|
|
|
272
284
|
var proportionalCues = this._currentCues
|
|
273
285
|
.filter(function (cue) { return cue.resolution !== null; });
|
|
274
286
|
if (proportionalCues.length > 0) {
|
|
275
|
-
this._sizeUpdateCanceller = new TaskCanceller(
|
|
287
|
+
this._sizeUpdateCanceller = new TaskCanceller();
|
|
288
|
+
this._sizeUpdateCanceller.linkToSignal(this._canceller.signal);
|
|
276
289
|
var TEXT_TRACK_SIZE_CHECKS_INTERVAL = config.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL;
|
|
277
290
|
// update propertionally-sized elements periodically
|
|
278
291
|
var heightWidthRef = onHeightWidthChange(this._textTrackElement, TEXT_TRACK_SIZE_CHECKS_INTERVAL, this._sizeUpdateCanceller.signal);
|
|
@@ -297,7 +310,8 @@ var HTMLTextSegmentBuffer = /** @class */ (function (_super) {
|
|
|
297
310
|
var MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL = config.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL;
|
|
298
311
|
var startAutoRefresh = function () {
|
|
299
312
|
stopAutoRefresh();
|
|
300
|
-
autoRefreshCanceller = new TaskCanceller(
|
|
313
|
+
autoRefreshCanceller = new TaskCanceller();
|
|
314
|
+
autoRefreshCanceller.linkToSignal(cancellationSignal);
|
|
301
315
|
var intervalId = setInterval(function () { return _this.refreshSubtitles(); }, MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL);
|
|
302
316
|
autoRefreshCanceller.signal.register(function () {
|
|
303
317
|
clearInterval(intervalId);
|
|
@@ -31,6 +31,14 @@ export default class NativeTextSegmentBuffer extends SegmentBuffer {
|
|
|
31
31
|
* @param {HTMLMediaElement} videoElement
|
|
32
32
|
*/
|
|
33
33
|
constructor(videoElement: HTMLMediaElement);
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} uniqueId
|
|
36
|
+
*/
|
|
37
|
+
declareInitSegment(uniqueId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} uniqueId
|
|
40
|
+
*/
|
|
41
|
+
freeInitSegment(uniqueId: string): void;
|
|
34
42
|
/**
|
|
35
43
|
* @param {Object} infos
|
|
36
44
|
* @returns {Promise}
|
|
@@ -57,6 +57,18 @@ var NativeTextSegmentBuffer = /** @class */ (function (_super) {
|
|
|
57
57
|
_this._trackElement = trackElement;
|
|
58
58
|
return _this;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* @param {string} uniqueId
|
|
62
|
+
*/
|
|
63
|
+
NativeTextSegmentBuffer.prototype.declareInitSegment = function (uniqueId) {
|
|
64
|
+
log.warn("ISB: Declaring initialization segment for image SegmentBuffer", uniqueId);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} uniqueId
|
|
68
|
+
*/
|
|
69
|
+
NativeTextSegmentBuffer.prototype.freeInitSegment = function (uniqueId) {
|
|
70
|
+
log.warn("ISB: Freeing initialization segment for image SegmentBuffer", uniqueId);
|
|
71
|
+
};
|
|
60
72
|
/**
|
|
61
73
|
* @param {Object} infos
|
|
62
74
|
* @returns {Promise}
|
|
@@ -68,6 +68,8 @@ export declare abstract class SegmentBuffer {
|
|
|
68
68
|
*/
|
|
69
69
|
codec: string | undefined;
|
|
70
70
|
constructor();
|
|
71
|
+
abstract declareInitSegment(uniqueId: string, initSegmentData: unknown): void;
|
|
72
|
+
abstract freeInitSegment(uniqueId: string): void;
|
|
71
73
|
/**
|
|
72
74
|
* Push a chunk of the media segment given to the attached buffer, in a
|
|
73
75
|
* FIFO queue.
|
|
@@ -77,7 +79,8 @@ export declare abstract class SegmentBuffer {
|
|
|
77
79
|
* pushed.
|
|
78
80
|
*
|
|
79
81
|
* Depending on the type of data appended, the pushed chunk might rely on an
|
|
80
|
-
* initialization segment,
|
|
82
|
+
* initialization segment, which had to be previously declared through the
|
|
83
|
+
* `declareInitSegment` method.
|
|
81
84
|
*
|
|
82
85
|
* Such initialization segment will be first pushed to the buffer if the
|
|
83
86
|
* last pushed segment was associated to another initialization segment.
|
|
@@ -87,7 +90,7 @@ export declare abstract class SegmentBuffer {
|
|
|
87
90
|
* reference).
|
|
88
91
|
*
|
|
89
92
|
* If you don't need any initialization segment to push the wanted chunk, you
|
|
90
|
-
* can just set
|
|
93
|
+
* can just set the corresponding property to `null`.
|
|
91
94
|
*
|
|
92
95
|
* You can also only push an initialization segment by setting the
|
|
93
96
|
* `data.chunk` argument to null.
|
|
@@ -177,12 +180,16 @@ export type IBufferType = "audio" | "video" | "text";
|
|
|
177
180
|
*/
|
|
178
181
|
export interface IPushedChunkData<T> {
|
|
179
182
|
/**
|
|
180
|
-
* The
|
|
183
|
+
* The `uniqueId` of the initialization segment linked to the data you want to
|
|
181
184
|
* push.
|
|
185
|
+
*
|
|
186
|
+
* That identifier should previously have been declared through the
|
|
187
|
+
* `declareInitSegment` method and not freed.
|
|
188
|
+
*
|
|
182
189
|
* To set to `null` either if no initialization data is needed, or if you are
|
|
183
190
|
* confident that the last pushed one is compatible.
|
|
184
191
|
*/
|
|
185
|
-
|
|
192
|
+
initSegmentUniqueId: string | null;
|
|
186
193
|
/**
|
|
187
194
|
* Chunk you want to push.
|
|
188
195
|
* This can be the whole decodable segment's data or just a decodable sub-part
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import BufferGarbageCollector from "./garbage_collector";
|
|
17
17
|
import { IBufferType, IEndOfSegmentInfos, IEndOfSegmentOperation, IPushChunkInfos, IPushedChunkData, IPushOperation, IRemoveOperation, ISBOperation, SegmentBuffer, SegmentBufferOperation } from "./implementations";
|
|
18
|
-
import { IBufferedChunk, IChunkContext, getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod } from "./inventory";
|
|
18
|
+
import { IBufferedChunk, IChunkContext, IInsertedChunkInfos, getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod } from "./inventory";
|
|
19
19
|
import SegmentBuffersStore, { ISegmentBufferOptions, ITextTrackSegmentBufferOptions } from "./segment_buffers_store";
|
|
20
20
|
export default SegmentBuffersStore;
|
|
21
|
-
export { BufferGarbageCollector, ISegmentBufferOptions, ITextTrackSegmentBufferOptions, SegmentBuffer, IBufferType, IBufferedChunk, IChunkContext, IPushChunkInfos, IPushedChunkData, IEndOfSegmentInfos, SegmentBufferOperation, ISBOperation, IEndOfSegmentOperation, IPushOperation, IRemoveOperation, getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod, };
|
|
21
|
+
export { BufferGarbageCollector, ISegmentBufferOptions, ITextTrackSegmentBufferOptions, SegmentBuffer, IBufferType, IBufferedChunk, IChunkContext, IInsertedChunkInfos, IPushChunkInfos, IPushedChunkData, IEndOfSegmentInfos, SegmentBufferOperation, ISBOperation, IEndOfSegmentOperation, IPushOperation, IRemoveOperation, getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod, };
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { MediaError } from "../../errors";
|
|
17
17
|
import features from "../../features";
|
|
18
18
|
import log from "../../log";
|
|
19
|
+
import createCancellablePromise from "../../utils/create_cancellable_promise";
|
|
19
20
|
import { AudioVideoSegmentBuffer, } from "./implementations";
|
|
20
21
|
var POSSIBLE_BUFFER_TYPES = ["audio",
|
|
21
22
|
"video",
|
|
@@ -137,20 +138,23 @@ var SegmentBuffersStore = /** @class */ (function () {
|
|
|
137
138
|
if (this._areNativeBuffersUsable()) {
|
|
138
139
|
return Promise.resolve();
|
|
139
140
|
}
|
|
140
|
-
return
|
|
141
|
-
|
|
141
|
+
return createCancellablePromise(cancelWaitSignal, function (res) {
|
|
142
|
+
/* eslint-disable-next-line prefer-const */
|
|
143
|
+
var onAddedOrDisabled;
|
|
144
|
+
var removeCallback = function () {
|
|
145
|
+
var indexOf = _this._onNativeBufferAddedOrDisabled.indexOf(onAddedOrDisabled);
|
|
146
|
+
if (indexOf >= 0) {
|
|
147
|
+
_this._onNativeBufferAddedOrDisabled.splice(indexOf, 1);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
onAddedOrDisabled = function () {
|
|
142
151
|
if (_this._areNativeBuffersUsable()) {
|
|
152
|
+
removeCallback();
|
|
143
153
|
res();
|
|
144
154
|
}
|
|
145
155
|
};
|
|
146
156
|
_this._onNativeBufferAddedOrDisabled.push(onAddedOrDisabled);
|
|
147
|
-
|
|
148
|
-
var indexOf = _this._onNativeBufferAddedOrDisabled.indexOf(onAddedOrDisabled);
|
|
149
|
-
if (indexOf >= 0) {
|
|
150
|
-
_this._onNativeBufferAddedOrDisabled.splice(indexOf, 1);
|
|
151
|
-
}
|
|
152
|
-
rej(error);
|
|
153
|
-
});
|
|
157
|
+
return removeCallback;
|
|
154
158
|
});
|
|
155
159
|
};
|
|
156
160
|
/**
|
|
@@ -38,6 +38,8 @@ import config from "../../../config";
|
|
|
38
38
|
import { formatError } from "../../../errors";
|
|
39
39
|
import log from "../../../log";
|
|
40
40
|
import assertUnreachable from "../../../utils/assert_unreachable";
|
|
41
|
+
import cancellableSleep from "../../../utils/cancellable_sleep";
|
|
42
|
+
import noop from "../../../utils/noop";
|
|
41
43
|
import objectAssign from "../../../utils/object_assign";
|
|
42
44
|
import { createMappedReference, createSharedReference, } from "../../../utils/reference";
|
|
43
45
|
import TaskCanceller from "../../../utils/task_canceller";
|
|
@@ -78,7 +80,8 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
78
80
|
var playbackObserver = _a.playbackObserver, content = _a.content, options = _a.options, representationEstimator = _a.representationEstimator, segmentBuffer = _a.segmentBuffer, segmentFetcherCreator = _a.segmentFetcherCreator, wantedBufferAhead = _a.wantedBufferAhead, maxVideoBufferSize = _a.maxVideoBufferSize;
|
|
79
81
|
var manifest = content.manifest, period = content.period, adaptation = content.adaptation;
|
|
80
82
|
/** Allows to cancel everything the `AdaptationStream` is doing. */
|
|
81
|
-
var adapStreamCanceller = new TaskCanceller(
|
|
83
|
+
var adapStreamCanceller = new TaskCanceller();
|
|
84
|
+
adapStreamCanceller.linkToSignal(parentCancelSignal);
|
|
82
85
|
/**
|
|
83
86
|
* The buffer goal ratio base itself on the value given by `wantedBufferAhead`
|
|
84
87
|
* to determine a more dynamic buffer goal for a given Representation.
|
|
@@ -133,9 +136,10 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
133
136
|
cancelCurrentStreams.cancel();
|
|
134
137
|
}
|
|
135
138
|
representationsList.setValueIfChanged(val.representations);
|
|
136
|
-
cancelCurrentStreams = new TaskCanceller(
|
|
139
|
+
cancelCurrentStreams = new TaskCanceller();
|
|
140
|
+
cancelCurrentStreams.linkToSignal(adapStreamCanceller.signal);
|
|
137
141
|
onRepresentationsChoiceChange(val, cancelCurrentStreams.signal).catch(function (err) {
|
|
138
|
-
if ((cancelCurrentStreams === null || cancelCurrentStreams === void 0 ? void 0 : cancelCurrentStreams.isUsed) === true &&
|
|
142
|
+
if ((cancelCurrentStreams === null || cancelCurrentStreams === void 0 ? void 0 : cancelCurrentStreams.isUsed()) === true &&
|
|
139
143
|
TaskCanceller.isCancellationError(err)) {
|
|
140
144
|
return;
|
|
141
145
|
}
|
|
@@ -187,7 +191,7 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
187
191
|
return [4 /*yield*/, segmentBuffer.removeBuffer(range.start, range.end, fnCancelSignal)];
|
|
188
192
|
case 5:
|
|
189
193
|
_c.sent();
|
|
190
|
-
if (fnCancelSignal.isCancelled) {
|
|
194
|
+
if (fnCancelSignal.isCancelled()) {
|
|
191
195
|
return [2 /*return*/];
|
|
192
196
|
}
|
|
193
197
|
_c.label = 6;
|
|
@@ -197,7 +201,7 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
197
201
|
case 7:
|
|
198
202
|
if (switchStrat.type === "flush-buffer") {
|
|
199
203
|
callbacks.needsBufferFlush();
|
|
200
|
-
if (fnCancelSignal.isCancelled) {
|
|
204
|
+
if (fnCancelSignal.isCancelled()) {
|
|
201
205
|
return [2 /*return*/];
|
|
202
206
|
}
|
|
203
207
|
}
|
|
@@ -226,7 +230,8 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
226
230
|
* terminating and as such the next one might be immediately created
|
|
227
231
|
* recursively.
|
|
228
232
|
*/
|
|
229
|
-
var repStreamTerminatingCanceller = new TaskCanceller(
|
|
233
|
+
var repStreamTerminatingCanceller = new TaskCanceller();
|
|
234
|
+
repStreamTerminatingCanceller.linkToSignal(fnCancelSignal);
|
|
230
235
|
var representation = estimateRef.getValue().representation;
|
|
231
236
|
if (representation === null) {
|
|
232
237
|
return;
|
|
@@ -254,11 +259,11 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
254
259
|
}, { clearSignal: repStreamTerminatingCanceller.signal, emitCurrentValue: true });
|
|
255
260
|
var repInfo = { type: adaptation.type, period: period, representation: representation };
|
|
256
261
|
currentRepresentation.setValue(representation);
|
|
257
|
-
if (adapStreamCanceller.isUsed) {
|
|
262
|
+
if (adapStreamCanceller.isUsed()) {
|
|
258
263
|
return; // previous callback has stopped everything by side-effect
|
|
259
264
|
}
|
|
260
265
|
callbacks.representationChange(repInfo);
|
|
261
|
-
if (adapStreamCanceller.isUsed) {
|
|
266
|
+
if (adapStreamCanceller.isUsed()) {
|
|
262
267
|
return; // previous callback has stopped everything by side-effect
|
|
263
268
|
}
|
|
264
269
|
var representationStreamCallbacks = {
|
|
@@ -274,13 +279,13 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
274
279
|
},
|
|
275
280
|
addedSegment: function (segmentInfo) {
|
|
276
281
|
abrCallbacks.addedSegment(segmentInfo);
|
|
277
|
-
if (adapStreamCanceller.isUsed) {
|
|
282
|
+
if (adapStreamCanceller.isUsed()) {
|
|
278
283
|
return;
|
|
279
284
|
}
|
|
280
285
|
callbacks.addedSegment(segmentInfo);
|
|
281
286
|
},
|
|
282
287
|
terminating: function () {
|
|
283
|
-
if (repStreamTerminatingCanceller.isUsed) {
|
|
288
|
+
if (repStreamTerminatingCanceller.isUsed()) {
|
|
284
289
|
return; // Already handled
|
|
285
290
|
}
|
|
286
291
|
repStreamTerminatingCanceller.cancel();
|
|
@@ -302,7 +307,8 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
302
307
|
* anything this function is doing and free allocated resources.
|
|
303
308
|
*/
|
|
304
309
|
function createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal) {
|
|
305
|
-
var bufferGoalCanceller = new TaskCanceller(
|
|
310
|
+
var bufferGoalCanceller = new TaskCanceller();
|
|
311
|
+
bufferGoalCanceller.linkToSignal(fnCancelSignal);
|
|
306
312
|
var bufferGoal = createMappedReference(wantedBufferAhead, function (prev) {
|
|
307
313
|
return prev * getBufferGoalRatio(representation);
|
|
308
314
|
}, bufferGoalCanceller.signal);
|
|
@@ -317,16 +323,24 @@ export default function AdaptationStream(_a, callbacks, parentCancelSignal) {
|
|
|
317
323
|
defaultCode: "NONE",
|
|
318
324
|
defaultReason: "Unknown `RepresentationStream` error",
|
|
319
325
|
});
|
|
320
|
-
if (formattedError.code
|
|
326
|
+
if (formattedError.code !== "BUFFER_FULL_ERROR") {
|
|
327
|
+
representationStreamCallbacks.error(err);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
321
330
|
var wba = wantedBufferAhead.getValue();
|
|
322
331
|
var lastBufferGoalRatio = (_a = bufferGoalRatioMap.get(representation.id)) !== null && _a !== void 0 ? _a : 1;
|
|
323
|
-
|
|
332
|
+
// 70%, 49%, 34.3%, 24%, 16.81%, 11.76%, 8.24% and 5.76%
|
|
333
|
+
var newBufferGoalRatio = lastBufferGoalRatio * 0.7;
|
|
334
|
+
if (newBufferGoalRatio <= 0.05 || wba * newBufferGoalRatio <= 2) {
|
|
324
335
|
throw formattedError;
|
|
325
336
|
}
|
|
326
|
-
bufferGoalRatioMap.set(representation.id,
|
|
327
|
-
|
|
337
|
+
bufferGoalRatioMap.set(representation.id, newBufferGoalRatio);
|
|
338
|
+
// We wait 4 seconds to let the situation evolve by itself before
|
|
339
|
+
// retrying loading segments with a lower buffer goal
|
|
340
|
+
cancellableSleep(4000, adapStreamCanceller.signal).then(function () {
|
|
341
|
+
return createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal);
|
|
342
|
+
}).catch(noop);
|
|
328
343
|
}
|
|
329
|
-
representationStreamCallbacks.error(err);
|
|
330
344
|
},
|
|
331
345
|
terminating: function () {
|
|
332
346
|
bufferGoalCanceller.cancel();
|
package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import Manifest, { Adaptation, Period, Representation } from "../../../../manifest";
|
|
17
|
+
import { IPlayerError } from "../../../../public_types";
|
|
18
|
+
import { IReadOnlySharedReference } from "../../../../utils/reference";
|
|
19
|
+
import { CancellationSignal } from "../../../../utils/task_canceller";
|
|
20
|
+
import { IABREstimate, IRepresentationEstimatorPlaybackObservation, IRepresentationEstimator, IRepresentationEstimatorCallbacks } from "../../../adaptive";
|
|
21
|
+
import { IReadOnlyPlaybackObserver } from "../../../api";
|
|
22
|
+
/**
|
|
23
|
+
* Produce estimates to know which Representation should be played.
|
|
24
|
+
* @param {Object} content - The Manifest, Period and Adaptation wanted.
|
|
25
|
+
* @param {Object} representationEstimator - `IRepresentationEstimator` which
|
|
26
|
+
* will produce Representation estimates.
|
|
27
|
+
* @param {Object} currentRepresentation - Reference emitting the
|
|
28
|
+
* currently-loaded Representation.
|
|
29
|
+
* @param {Object} playbackObserver - Allows to observe the current playback
|
|
30
|
+
* conditions.
|
|
31
|
+
* @param {Function} onFatalError - Callback called when a fatal error was
|
|
32
|
+
* thrown. Once this callback is called, no estimate will be produced.
|
|
33
|
+
* @param {Object} cancellationSignal - `CancellationSignal` allowing to abort
|
|
34
|
+
* the production of estimates (and clean-up all linked resources).
|
|
35
|
+
* @returns {Object} - Returns an object with the following properties:
|
|
36
|
+
* - `estimateRef`: Reference emitting the last estimate
|
|
37
|
+
* - `abrCallbacks`: Callbacks allowing to report back network and playback
|
|
38
|
+
* activities to improve the estimates given.
|
|
39
|
+
*/
|
|
40
|
+
export default function getRepresentationEstimate(content: {
|
|
41
|
+
manifest: Manifest;
|
|
42
|
+
period: Period;
|
|
43
|
+
adaptation: Adaptation;
|
|
44
|
+
}, representationEstimator: IRepresentationEstimator, currentRepresentation: IReadOnlySharedReference<Representation | null>, playbackObserver: IReadOnlyPlaybackObserver<IRepresentationEstimatorPlaybackObservation>, onFatalError: (err: IPlayerError) => void, cancellationSignal: CancellationSignal): {
|
|
45
|
+
estimateRef: IReadOnlySharedReference<IABREstimate>;
|
|
46
|
+
abrCallbacks: IRepresentationEstimatorCallbacks;
|
|
47
|
+
};
|