rx-player 4.5.0-dev.2026033100 → 4.5.0-dev.2026041501
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 +22 -5
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/compat/can_patch_out_pssh.d.ts +42 -0
- package/dist/commonjs/compat/can_patch_out_pssh.d.ts.map +1 -0
- package/dist/commonjs/compat/can_patch_out_pssh.js +53 -0
- package/dist/commonjs/compat/env_detector.d.ts +2 -0
- package/dist/commonjs/compat/env_detector.d.ts.map +1 -1
- package/dist/commonjs/compat/env_detector.js +5 -0
- package/dist/commonjs/core/adaptive/network_analyzer.d.ts +1 -2
- package/dist/commonjs/core/adaptive/network_analyzer.d.ts.map +1 -1
- package/dist/commonjs/core/adaptive/network_analyzer.js +3 -3
- package/dist/commonjs/core/adaptive/utils/representation_score_calculator.js +2 -2
- package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
- package/dist/commonjs/core/cmcd/cmcd_data_builder.js +9 -3
- package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -1
- package/dist/commonjs/core/entry/content_preparer.js +5 -7
- package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -1
- package/dist/commonjs/core/entry/core_entry.js +6 -2
- package/dist/commonjs/core/entry/core_text_displayer_interface.js +3 -3
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +12 -0
- package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +1 -1
- package/dist/commonjs/core/fetchers/utils/schedule_request.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/utils/schedule_request.js +4 -3
- package/dist/commonjs/core/segment_sinks/garbage_collector.d.ts +0 -2
- package/dist/commonjs/core/segment_sinks/garbage_collector.d.ts.map +1 -1
- package/dist/commonjs/core/segment_sinks/garbage_collector.js +0 -3
- package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_sink.d.ts +1 -1
- package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_sink.d.ts.map +1 -1
- package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_sink.js +2 -2
- package/dist/commonjs/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
- package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +6 -6
- package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.d.ts.map +1 -1
- package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +37 -40
- package/dist/commonjs/default_config.d.ts +5 -0
- package/dist/commonjs/default_config.d.ts.map +1 -1
- package/dist/commonjs/default_config.js +5 -0
- package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/commonjs/main_thread/api/public_api.js +23 -16
- package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
- package/dist/commonjs/main_thread/decrypt/content_decryptor.js +4 -1
- package/dist/commonjs/main_thread/decrypt/session_events_listener.js +1 -1
- package/dist/commonjs/main_thread/decrypt/set_server_certificate.d.ts +2 -0
- package/dist/commonjs/main_thread/decrypt/set_server_certificate.d.ts.map +1 -1
- package/dist/commonjs/main_thread/decrypt/set_server_certificate.js +4 -0
- package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts +0 -8
- package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/media_source_content_initializer.js +58 -50
- package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +35 -5
- package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.js +60 -19
- package/dist/commonjs/main_thread/render_thumbnail.d.ts.map +1 -1
- package/dist/commonjs/main_thread/render_thumbnail.js +4 -0
- package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.d.ts.map +1 -1
- package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.js +1 -0
- package/dist/commonjs/main_thread/tracks_store/tracks_store.d.ts +1 -1
- package/dist/commonjs/main_thread/tracks_store/tracks_store.js +1 -1
- package/dist/{es2017/parsers/containers/isobmff/take_pssh_out.d.ts → commonjs/parsers/containers/isobmff/extract_pssh.d.ts} +6 -4
- package/dist/commonjs/parsers/containers/isobmff/extract_pssh.d.ts.map +1 -0
- package/dist/commonjs/parsers/containers/isobmff/{take_pssh_out.js → extract_pssh.js} +22 -17
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -2
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/index.js +4 -4
- package/dist/commonjs/playback_observer/core_playback_observer.d.ts +4 -4
- package/dist/commonjs/playback_observer/core_playback_observer.d.ts.map +1 -1
- package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts +1 -2
- package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/segment_parser.js +1 -1
- package/dist/commonjs/transports/local/segment_parser.js +1 -1
- package/dist/commonjs/utils/test-utils.d.ts +30 -0
- package/dist/commonjs/utils/test-utils.d.ts.map +1 -0
- package/dist/commonjs/utils/test-utils.js +79 -0
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/compat/can_patch_out_pssh.d.ts +42 -0
- package/dist/es2017/compat/can_patch_out_pssh.d.ts.map +1 -0
- package/dist/es2017/compat/can_patch_out_pssh.js +50 -0
- package/dist/es2017/compat/env_detector.d.ts +2 -0
- package/dist/es2017/compat/env_detector.d.ts.map +1 -1
- package/dist/es2017/compat/env_detector.js +5 -0
- package/dist/es2017/core/adaptive/network_analyzer.d.ts +1 -2
- package/dist/es2017/core/adaptive/network_analyzer.d.ts.map +1 -1
- package/dist/es2017/core/adaptive/network_analyzer.js +3 -3
- package/dist/es2017/core/adaptive/utils/representation_score_calculator.js +2 -2
- package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
- package/dist/es2017/core/cmcd/cmcd_data_builder.js +9 -3
- package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -1
- package/dist/es2017/core/entry/content_preparer.js +3 -5
- package/dist/es2017/core/entry/core_entry.d.ts.map +1 -1
- package/dist/es2017/core/entry/core_entry.js +6 -2
- package/dist/es2017/core/entry/core_text_displayer_interface.js +3 -3
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +12 -0
- package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +1 -1
- package/dist/es2017/core/fetchers/utils/schedule_request.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/utils/schedule_request.js +2 -3
- package/dist/es2017/core/segment_sinks/garbage_collector.d.ts +0 -2
- package/dist/es2017/core/segment_sinks/garbage_collector.d.ts.map +1 -1
- package/dist/es2017/core/segment_sinks/garbage_collector.js +0 -3
- package/dist/es2017/core/segment_sinks/implementations/text/text_segment_sink.d.ts +1 -1
- package/dist/es2017/core/segment_sinks/implementations/text/text_segment_sink.d.ts.map +1 -1
- package/dist/es2017/core/segment_sinks/implementations/text/text_segment_sink.js +2 -2
- package/dist/es2017/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
- package/dist/es2017/core/stream/adaptation/adaptation_stream.js +6 -6
- package/dist/es2017/core/stream/orchestrator/stream_orchestrator.d.ts.map +1 -1
- package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +40 -39
- package/dist/es2017/default_config.d.ts +5 -0
- package/dist/es2017/default_config.d.ts.map +1 -1
- package/dist/es2017/default_config.js +5 -0
- package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/es2017/main_thread/api/public_api.js +20 -13
- package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
- package/dist/es2017/main_thread/decrypt/content_decryptor.js +4 -1
- package/dist/es2017/main_thread/decrypt/session_events_listener.js +1 -1
- package/dist/es2017/main_thread/decrypt/set_server_certificate.d.ts +2 -0
- package/dist/es2017/main_thread/decrypt/set_server_certificate.d.ts.map +1 -1
- package/dist/es2017/main_thread/decrypt/set_server_certificate.js +4 -0
- package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts +0 -8
- package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/media_source_content_initializer.js +58 -50
- package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +35 -5
- package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.js +60 -19
- package/dist/es2017/main_thread/render_thumbnail.d.ts.map +1 -1
- package/dist/es2017/main_thread/render_thumbnail.js +4 -0
- package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.d.ts.map +1 -1
- package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.js +1 -0
- package/dist/es2017/main_thread/tracks_store/tracks_store.d.ts +1 -1
- package/dist/es2017/main_thread/tracks_store/tracks_store.js +1 -1
- package/dist/{commonjs/parsers/containers/isobmff/take_pssh_out.d.ts → es2017/parsers/containers/isobmff/extract_pssh.d.ts} +6 -4
- package/dist/es2017/parsers/containers/isobmff/extract_pssh.d.ts.map +1 -0
- package/dist/es2017/parsers/containers/isobmff/{take_pssh_out.js → extract_pssh.js} +21 -16
- package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -2
- package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/index.js +2 -2
- package/dist/es2017/playback_observer/core_playback_observer.d.ts +4 -4
- package/dist/es2017/playback_observer/core_playback_observer.d.ts.map +1 -1
- package/dist/es2017/playback_observer/media_element_playback_observer.d.ts +1 -2
- package/dist/es2017/playback_observer/media_element_playback_observer.d.ts.map +1 -1
- package/dist/es2017/transports/dash/segment_parser.js +2 -2
- package/dist/es2017/transports/local/segment_parser.js +2 -2
- package/dist/es2017/utils/test-utils.d.ts +30 -0
- package/dist/es2017/utils/test-utils.d.ts.map +1 -0
- package/dist/es2017/utils/test-utils.js +36 -0
- package/dist/mpd-parser.wasm +0 -0
- package/dist/worker.js +6 -6
- package/package.json +4 -2
- package/src/README.md +7 -7
- package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/can_patch_out_pssh.test.ts +40 -0
- package/src/compat/can_patch_out_pssh.ts +53 -0
- package/src/compat/env_detector.ts +4 -0
- package/src/core/README.md +1 -1
- package/src/core/adaptive/README.md +3 -3
- package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +181 -110
- package/src/core/adaptive/__tests__/guess_based_chooser.test.ts +229 -123
- package/src/core/adaptive/__tests__/mocks.ts +100 -0
- package/src/core/adaptive/__tests__/network_analyzer.test.ts +152 -59
- package/src/core/adaptive/network_analyzer.ts +4 -4
- package/src/core/adaptive/utils/__tests__/filter_by_bitrate.test.ts +11 -19
- package/src/core/adaptive/utils/__tests__/filter_by_resolution.test.ts +12 -12
- package/src/core/adaptive/utils/__tests__/last_estimate_storage.test.ts +25 -12
- package/src/core/adaptive/utils/__tests__/pending_requests_store.test.ts +13 -9
- package/src/core/adaptive/utils/__tests__/representation_score_calculator.test.ts +11 -11
- package/src/core/adaptive/utils/__tests__/select_optimal_representation.test.ts +13 -23
- package/src/core/adaptive/utils/representation_score_calculator.ts +2 -2
- package/src/core/cmcd/__tests__/cmcd_data_builder.test.ts +60 -15
- package/src/core/cmcd/cmcd_data_builder.ts +9 -3
- package/src/core/entry/README.md +2 -2
- package/src/core/entry/__tests__/core_text_displayer_interface.test.ts +20 -0
- package/src/core/entry/content_preparer.ts +2 -5
- package/src/core/entry/core_entry.ts +6 -2
- package/src/core/entry/core_text_displayer_interface.ts +3 -3
- package/src/core/fetchers/manifest/__tests__/manifest_fetcher.test.ts +52 -3
- package/src/core/fetchers/manifest/manifest_fetcher.ts +12 -0
- package/src/core/fetchers/thumbnails/__tests__/thumbnail_fetcher.test.ts +70 -0
- package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +1 -1
- package/src/core/fetchers/utils/schedule_request.ts +5 -3
- package/src/core/segment_sinks/__tests__/garbage_collector.test.ts +434 -0
- package/src/core/segment_sinks/__tests__/mocks.ts +49 -0
- package/src/core/segment_sinks/garbage_collector.ts +0 -3
- package/src/core/segment_sinks/implementations/text/__tests__/text_segment_sink.test.ts +177 -0
- package/src/core/segment_sinks/implementations/text/text_segment_sink.ts +2 -2
- package/src/core/segment_sinks/inventory/__tests__/buffered_history.test.ts +215 -0
- package/src/core/segment_sinks/inventory/__tests__/segment_inventory.test.ts +448 -0
- package/src/core/stream/adaptation/__tests__/adaptation_stream.test.ts +973 -0
- package/src/core/stream/adaptation/__tests__/get_representations_switch_strategy.test.ts +283 -374
- package/src/core/stream/adaptation/adaptation_stream.ts +6 -8
- package/src/core/stream/orchestrator/README.md +4 -4
- package/src/core/stream/orchestrator/__tests__/stream_orchestrator.test.ts +707 -0
- package/src/core/stream/orchestrator/stream_orchestrator.ts +41 -46
- package/src/core/stream/period/utils/__tests__/get_adaptation_switch_strategy.test.ts +290 -220
- package/src/core/stream/representation/__tests__/encryption_data_notifier.test.ts +93 -63
- package/src/core/stream/representation/utils/__tests__/append_segment_to_buffer.test.ts +106 -63
- package/src/core/stream/representation/utils/__tests__/check_for_discontinuity.test.ts +179 -204
- package/src/core/stream/representation/utils/__tests__/get_segment_priority.test.ts +7 -7
- package/src/core/stream/representation/utils/__tests__/push_init_segment.test.ts +103 -60
- package/src/core/stream/representation/utils/__tests__/push_media_segment.test.ts +231 -165
- package/src/default_config.ts +6 -0
- package/src/experimental/README.md +1 -1
- package/src/features/README.md +3 -3
- package/src/main_thread/api/README.md +6 -7
- package/src/main_thread/api/public_api.ts +16 -10
- package/src/main_thread/decrypt/README.md +4 -4
- package/src/main_thread/decrypt/__tests__/__global__/content_decryptor.test.ts +135 -0
- package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +70 -0
- package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +44 -0
- package/src/main_thread/decrypt/__tests__/__global__/utils.ts +2 -2
- package/src/main_thread/decrypt/content_decryptor.ts +6 -1
- package/src/main_thread/decrypt/session_events_listener.ts +1 -1
- package/src/main_thread/decrypt/set_server_certificate.ts +5 -0
- package/src/main_thread/init/media_source_content_initializer.ts +69 -55
- package/src/main_thread/init/utils/__tests__/stream_events_emitter.test.ts +175 -0
- package/src/main_thread/init/utils/stream_events_emitter/stream_events_emitter.ts +90 -26
- package/src/main_thread/render_thumbnail.ts +4 -0
- package/src/main_thread/tracks_store/README.md +12 -0
- package/src/main_thread/tracks_store/__tests__/media_element_tracks_store.test.ts +25 -18
- package/src/main_thread/tracks_store/media_element_tracks_store.ts +1 -0
- package/src/main_thread/tracks_store/tracks_store.ts +1 -1
- package/src/manifest/classes/__tests__/mocks.ts +202 -0
- package/src/parsers/containers/isobmff/__tests__/extract_pssh.test.ts +199 -0
- package/src/parsers/containers/isobmff/{take_pssh_out.ts → extract_pssh.ts} +21 -17
- package/src/parsers/containers/isobmff/index.ts +2 -2
- package/src/parsers/manifest/dash/wasm-parser/README.md +9 -9
- package/src/playback_observer/__tests__/mocks.ts +152 -0
- package/src/playback_observer/core_playback_observer.ts +4 -4
- package/src/playback_observer/media_element_playback_observer.ts +1 -1
- package/src/tools/README.md +2 -2
- package/src/transports/README.md +5 -5
- package/src/transports/dash/segment_parser.ts +2 -2
- package/src/transports/local/segment_parser.ts +2 -2
- package/src/transports/metaplaylist/README.md +4 -4
- package/src/utils/README.md +3 -3
- package/src/utils/test-utils.ts +50 -0
- package/dist/commonjs/core/entry/synchronize_sinks_on_observation.d.ts +0 -11
- package/dist/commonjs/core/entry/synchronize_sinks_on_observation.d.ts.map +0 -1
- package/dist/commonjs/core/entry/synchronize_sinks_on_observation.js +0 -20
- package/dist/commonjs/parsers/containers/isobmff/take_pssh_out.d.ts.map +0 -1
- package/dist/es2017/core/entry/synchronize_sinks_on_observation.d.ts +0 -11
- package/dist/es2017/core/entry/synchronize_sinks_on_observation.d.ts.map +0 -1
- package/dist/es2017/core/entry/synchronize_sinks_on_observation.js +0 -17
- package/dist/es2017/parsers/containers/isobmff/take_pssh_out.d.ts.map +0 -1
- package/src/core/adaptive/utils/__tests__/bandwith_estimator.test.ts +0 -117
- package/src/core/entry/synchronize_sinks_on_observation.ts +0 -22
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import SharedReference from "../../utils/reference";
|
|
2
|
+
import type { CancellationSignal } from "../../utils/task_canceller";
|
|
3
|
+
import { makeMockedClass } from "../../utils/test-utils";
|
|
4
|
+
import type CorePlaybackObserver from "../core_playback_observer";
|
|
5
|
+
import type MediaElementPlaybackObserver from "../media_element_playback_observer";
|
|
6
|
+
import type { IReadOnlyPlaybackObserver } from "../types";
|
|
7
|
+
import type ObservationPosition from "../utils/observation_position";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Construct a class implementing the `MediaElementPlaybackObserver` interface.
|
|
11
|
+
* @class DummyMediaElementPlaybackObserver
|
|
12
|
+
*/
|
|
13
|
+
export const DummyMediaElementPlaybackObserver =
|
|
14
|
+
makeMockedClass<MediaElementPlaybackObserver>(
|
|
15
|
+
{
|
|
16
|
+
attachMediaElement: notImplemented("attachMediaElement"),
|
|
17
|
+
getCurrentTime: notImplemented("getCurrentTime"),
|
|
18
|
+
getIsPaused: notImplemented("getIsPaused"),
|
|
19
|
+
getPendingSeekInformation: notImplemented("getPendingSeekInformation"),
|
|
20
|
+
getPlaybackRate: notImplemented("getPlaybackRate"),
|
|
21
|
+
getReadyState: notImplemented("getReadyState"),
|
|
22
|
+
getReference: notImplemented("getReference"),
|
|
23
|
+
stop: notImplemented("stop"),
|
|
24
|
+
blockSeeking: notImplemented("blockSeeking"),
|
|
25
|
+
unblockSeeking: notImplemented("unblockSeeking"),
|
|
26
|
+
isSeekingBlocked: notImplemented("isSeekingBlocked"),
|
|
27
|
+
setCurrentTime: notImplemented("setCurrentTime"),
|
|
28
|
+
setPlaybackRate: notImplemented("setPlaybackRate"),
|
|
29
|
+
listen: notImplemented("listen"),
|
|
30
|
+
deriveReadOnlyObserver: notImplemented("deriveReadOnlyObserver"),
|
|
31
|
+
},
|
|
32
|
+
{},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Construct a class implementing the `CorePlaybackObserver` interface.
|
|
37
|
+
* @class DummyCorePlaybackObserver
|
|
38
|
+
*/
|
|
39
|
+
export const DummyCorePlaybackObserver = makeMockedClass<CorePlaybackObserver>(
|
|
40
|
+
{
|
|
41
|
+
getCurrentTime: notImplemented("getCurrentTime"),
|
|
42
|
+
getIsPaused: notImplemented("getIsPaused"),
|
|
43
|
+
getPlaybackRate: notImplemented("getPlaybackRate"),
|
|
44
|
+
getReadyState: notImplemented("getReadyState"),
|
|
45
|
+
getReference: notImplemented("getReference"),
|
|
46
|
+
setPlaybackRate: notImplemented("setPlaybackRate"),
|
|
47
|
+
listen: notImplemented("listen"),
|
|
48
|
+
deriveReadOnlyObserver: notImplemented("deriveReadOnlyObserver"),
|
|
49
|
+
},
|
|
50
|
+
{},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Object facilitation the usage of a IReadOnlyPlaybackObserver`.
|
|
55
|
+
* /!\ Do not forget to call `reset` when done to ensure no memory leak.
|
|
56
|
+
*/
|
|
57
|
+
export interface IMockedReadOnlyPlaybackObserver<TObservationData> {
|
|
58
|
+
/**
|
|
59
|
+
* The `IReadOnlyPlaybackObserver` itself.
|
|
60
|
+
*/
|
|
61
|
+
observer: IReadOnlyPlaybackObserver<TObservationData>;
|
|
62
|
+
/**
|
|
63
|
+
* Allows to trigger new observations through `observer`.
|
|
64
|
+
*/
|
|
65
|
+
emit: (data: TObservationData) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Reset `observer` to its initial observation, also removing all observation
|
|
68
|
+
* listener it potentially had.
|
|
69
|
+
*
|
|
70
|
+
* Intended to be called between each test to clean-up.
|
|
71
|
+
*/
|
|
72
|
+
reset: () => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Allows to create any `IReadOnlyPlaybackObserver` with TypeScript typechecking
|
|
77
|
+
* and to obtain a function to emit new observations.
|
|
78
|
+
* @param {Object} initialData - The initial observation emitted.
|
|
79
|
+
* @returns {Object} res
|
|
80
|
+
* @returns {IReadOnlyPlaybackObserver} res.observer - The
|
|
81
|
+
* `IReadOnlyPlaybackObserver` instance.
|
|
82
|
+
* @returns {Function} res.emit - A function allowing to emit new observations.
|
|
83
|
+
* @returns {Function} res.reset - Reset the playback observer to its initial
|
|
84
|
+
* state, also removing all its listeners. Call this between tests.
|
|
85
|
+
*/
|
|
86
|
+
export function makeReadyOnlyPlaybackObserver<TObservationData>(
|
|
87
|
+
initialData: TObservationData,
|
|
88
|
+
): IMockedReadOnlyPlaybackObserver<TObservationData> {
|
|
89
|
+
let ref = new SharedReference<TObservationData>(initialData);
|
|
90
|
+
const ret = {
|
|
91
|
+
observer: makeObserver(),
|
|
92
|
+
emit: (data: TObservationData) => {
|
|
93
|
+
ref.setValue(data);
|
|
94
|
+
},
|
|
95
|
+
reset: () => {
|
|
96
|
+
ref.finish();
|
|
97
|
+
ref = new SharedReference<TObservationData>(initialData);
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
return ret;
|
|
101
|
+
|
|
102
|
+
function makeObserver(): IReadOnlyPlaybackObserver<TObservationData> {
|
|
103
|
+
const klass = makeMockedClass<IReadOnlyPlaybackObserver<TObservationData>>(
|
|
104
|
+
{
|
|
105
|
+
getCurrentTime: notImplemented("getCurrentTime"),
|
|
106
|
+
getIsPaused: notImplemented("getIsPaused"),
|
|
107
|
+
getPlaybackRate: notImplemented("getPlaybackRate"),
|
|
108
|
+
getReadyState: notImplemented("getReadyState"),
|
|
109
|
+
getReference: () => ref,
|
|
110
|
+
listen(
|
|
111
|
+
cb: (observation: TObservationData, stopListening: () => void) => void,
|
|
112
|
+
params: {
|
|
113
|
+
includeLastObservation?: boolean | undefined;
|
|
114
|
+
clearSignal: CancellationSignal;
|
|
115
|
+
},
|
|
116
|
+
) {
|
|
117
|
+
if (params.clearSignal.isCancelled()) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
ref.onUpdate(cb, {
|
|
121
|
+
clearSignal: params.clearSignal,
|
|
122
|
+
emitCurrentValue: params.includeLastObservation,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
deriveReadOnlyObserver: notImplemented("deriveReadOnlyObserver"),
|
|
126
|
+
},
|
|
127
|
+
{},
|
|
128
|
+
);
|
|
129
|
+
return new klass();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Construct a class implementing the `ObservationPosition` interface.
|
|
135
|
+
* @class DummyObservationPosition
|
|
136
|
+
*/
|
|
137
|
+
export const DummyObservationPosition = makeMockedClass<ObservationPosition>(
|
|
138
|
+
{
|
|
139
|
+
serialize: notImplemented("serialize"),
|
|
140
|
+
getPolled: notImplemented("getPolled"),
|
|
141
|
+
getWanted: notImplemented("getWanted"),
|
|
142
|
+
forceWantedPosition: notImplemented("forceWantedPosition"),
|
|
143
|
+
isAwaitingFuturePosition: notImplemented("isAwaitingFuturePosition"),
|
|
144
|
+
},
|
|
145
|
+
{},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
function notImplemented(name: string): () => never {
|
|
149
|
+
return () => {
|
|
150
|
+
throw new Error(`${name} not implemented`);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -93,15 +93,15 @@ export default class CorePlaybackObserver
|
|
|
93
93
|
this._cancelSignal = cancellationSignal;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
public getCurrentTime():
|
|
96
|
+
public getCurrentTime(): undefined {
|
|
97
97
|
return undefined;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
public getReadyState():
|
|
100
|
+
public getReadyState(): undefined {
|
|
101
101
|
return undefined;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
public getIsPaused():
|
|
104
|
+
public getIsPaused(): undefined {
|
|
105
105
|
return undefined;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -117,7 +117,7 @@ export default class CorePlaybackObserver
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
public getPlaybackRate():
|
|
120
|
+
public getPlaybackRate(): undefined {
|
|
121
121
|
return undefined;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -1106,7 +1106,7 @@ function getInitialObservation(mediaElement: IMediaElement | null): IPlaybackObs
|
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
|
-
interface IPendingSeekInformation {
|
|
1109
|
+
export interface IPendingSeekInformation {
|
|
1110
1110
|
/** Position to seek to. */
|
|
1111
1111
|
position: number;
|
|
1112
1112
|
/** If `true`, the seek was performed by the RxPlayer's internal logic. */
|
package/src/tools/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Tools
|
|
2
2
|
|
|
3
|
-
This directory
|
|
3
|
+
This directory regroups tools, which are functions and classes exported by this library
|
|
4
4
|
which are not part of the `RxPlayer` class.
|
|
5
5
|
|
|
6
|
-
Note that tools NEED to be declared in their own directory, with their inner `index.
|
|
6
|
+
Note that tools NEED to be declared in their own directory, with their inner `index.ts`
|
|
7
7
|
file exporting them, as that's a requirement from our exporting strategy.
|
package/src/transports/README.md
CHANGED
|
@@ -19,8 +19,8 @@ As such, most network request needed by the player are directly performed by the
|
|
|
19
19
|
`transports` code.
|
|
20
20
|
|
|
21
21
|
Note: the only HTTP request which might be done elsewhere would be the request for a
|
|
22
|
-
`directfile` content. That request is not done
|
|
23
|
-
|
|
22
|
+
`directfile` content. That request is not done explicitly with a JavaScript API but
|
|
23
|
+
implicitly by the browser (through the `src` attribute).
|
|
24
24
|
|
|
25
25
|
## Implementation
|
|
26
26
|
|
|
@@ -184,7 +184,7 @@ It receives information linked to the segment you want to download:
|
|
|
184
184
|
- The `Representation` it is linked to
|
|
185
185
|
- The `Segment` object it is linked to
|
|
186
186
|
|
|
187
|
-
It then
|
|
187
|
+
It then returns a Promise resolving when the segment is loaded.
|
|
188
188
|
|
|
189
189
|
```
|
|
190
190
|
INPUT: OUTPUT:
|
|
@@ -226,8 +226,8 @@ way.
|
|
|
226
226
|
A segment parser is a function whose role is to extract some information from the
|
|
227
227
|
segment's data:
|
|
228
228
|
|
|
229
|
-
- what its
|
|
230
|
-
- whether the segment should be
|
|
229
|
+
- what its precise start time and duration is
|
|
230
|
+
- whether the segment should be offset when decoded and by what amount
|
|
231
231
|
- the decodable data (which can be wrapped in a container e.g. subtitles in an ISOBMFF
|
|
232
232
|
container).
|
|
233
233
|
- the attached protection information and data to be able to decrypt that segment.
|
|
@@ -19,7 +19,7 @@ import logger from "../../log";
|
|
|
19
19
|
import {
|
|
20
20
|
getMDHDTimescale,
|
|
21
21
|
getSegmentsFromSidx,
|
|
22
|
-
|
|
22
|
+
extractPssh,
|
|
23
23
|
removeDolbyVisionConfigData,
|
|
24
24
|
} from "../../parsers/containers/isobmff";
|
|
25
25
|
import {
|
|
@@ -96,7 +96,7 @@ export default function generateAudioVideoSegmentParser({
|
|
|
96
96
|
|
|
97
97
|
const protectionData: IProtectionDataInfo[] = [];
|
|
98
98
|
if (seemsToBeMP4) {
|
|
99
|
-
const psshInfo =
|
|
99
|
+
const psshInfo = extractPssh(chunkData);
|
|
100
100
|
let keyId;
|
|
101
101
|
if (segment.isInit) {
|
|
102
102
|
keyId = getKeyIdFromInitSegment(chunkData) ?? undefined;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { getMDHDTimescale,
|
|
17
|
+
import { getMDHDTimescale, extractPssh } from "../../parsers/containers/isobmff";
|
|
18
18
|
import { getKeyIdFromInitSegment } from "../../parsers/containers/isobmff/utils";
|
|
19
19
|
import { getTimeCodeScale } from "../../parsers/containers/matroska";
|
|
20
20
|
import type {
|
|
@@ -68,7 +68,7 @@ export default function segmentParser(
|
|
|
68
68
|
const seemsToBeMP4 = containerType === "mp4" || containerType === undefined;
|
|
69
69
|
const protectionData: IProtectionDataInfo[] = [];
|
|
70
70
|
if (seemsToBeMP4) {
|
|
71
|
-
const psshInfo =
|
|
71
|
+
const psshInfo = extractPssh(chunkData);
|
|
72
72
|
let keyId;
|
|
73
73
|
if (segment.isInit) {
|
|
74
74
|
keyId = getKeyIdFromInitSegment(chunkData) ?? undefined;
|
|
@@ -50,15 +50,15 @@ To illustrate, it kind of goes like this:
|
|
|
50
50
|
| | ---------------------------------------> | |
|
|
51
51
|
| | | |
|
|
52
52
|
| | <--------------------------------------- | |
|
|
53
|
-
| | 4. Gives segment infos asked (
|
|
53
|
+
| | 4. Gives segment infos asked (offset) | |
|
|
54
54
|
| | | |
|
|
55
55
|
| CORE | | METAPLAYLIST |
|
|
56
56
|
| | | WRAPPER |
|
|
57
|
-
| | 5. Ask to download segment (
|
|
57
|
+
| | 5. Ask to download segment (offset) | |
|
|
58
58
|
| | ---------------------------------------> | |
|
|
59
59
|
| | | |
|
|
60
60
|
| | <--------------------------------------- | |
|
|
61
|
-
+----------------+
|
|
61
|
+
+----------------+ 8. Gives segment (offset) +--------------+
|
|
62
62
|
| ^ | ^
|
|
63
63
|
| | | |
|
|
64
64
|
| | | |
|
|
@@ -73,7 +73,7 @@ To illustrate, it kind of goes like this:
|
|
|
73
73
|
| | HSS | | | |
|
|
74
74
|
| | | | | |
|
|
75
75
|
| +-------+ | | |
|
|
76
|
-
| +-------+ |
|
|
76
|
+
| +-------+ | 6. Ask to download non-offset (normal) segments | |
|
|
77
77
|
| | | | <--------------------------------------------------+ |
|
|
78
78
|
| | ... | | |
|
|
79
79
|
| | | | 7. Gives normal segment |
|
package/src/utils/README.md
CHANGED
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
This directory regroups
|
|
11
|
-
on any outside code, beside dependencies) functions that might be used by any part of
|
|
12
|
-
RxPlayer's code.
|
|
10
|
+
This directory regroups utility functions, which are small stand-alone (they shouldn't
|
|
11
|
+
rely on any outside code, beside dependencies) functions that might be used by any part of
|
|
12
|
+
the RxPlayer's code.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Util useful to create mocked versions of classes with each of their methods
|
|
3
|
+
* and properties replaced, while being properly checked by TypeScript.
|
|
4
|
+
* @param {Object} methods - Each of this class' methods (key is the method
|
|
5
|
+
* name, value is the implementation).
|
|
6
|
+
* @param {Object} properties - Each of this class' property (key is the
|
|
7
|
+
* property name, value is the implementation).
|
|
8
|
+
* @returns {*} - The mocked class, which should respect its public API.
|
|
9
|
+
*/
|
|
10
|
+
export function makeMockedClass<T>(
|
|
11
|
+
methods: MethodsMap<T>,
|
|
12
|
+
properties: PropertiesMap<T>,
|
|
13
|
+
): { new (opts?: Partial<T>): T; prototype: IPrototype<T> } {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
15
|
+
class Dummy {
|
|
16
|
+
constructor(opts: Partial<T> = {}) {
|
|
17
|
+
// Apply default property values
|
|
18
|
+
for (const key in properties) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) {
|
|
20
|
+
// @ts-expect-error dynamic assignment
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22
|
+
this[key] = properties[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Override with any provided opts
|
|
26
|
+
for (const key in opts) {
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(opts, key)) {
|
|
28
|
+
// @ts-expect-error dynamic assignment
|
|
29
|
+
this[key] = opts[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const [name, fn] of Object.entries(methods)) {
|
|
35
|
+
// @ts-expect-error dynamic assignment
|
|
36
|
+
Dummy.prototype[name as keyof typeof Dummy.prototype] = fn;
|
|
37
|
+
}
|
|
38
|
+
return Dummy as unknown as { new (opts?: Partial<T>): T; prototype: IPrototype<T> };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-restricted-types */
|
|
42
|
+
type IPrototype<T> = { [K in keyof T as T[K] extends Function ? K : never]: T[K] };
|
|
43
|
+
|
|
44
|
+
// Splits T's keys into method keys and property keys
|
|
45
|
+
type MethodKeys<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
|
46
|
+
type PropertyKeys<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
|
|
47
|
+
/* eslint-enable @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-restricted-types */
|
|
48
|
+
|
|
49
|
+
type MethodsMap<T> = { [K in MethodKeys<T>]: T[K] };
|
|
50
|
+
type PropertiesMap<T> = { [K in PropertyKeys<T>]: T[K] };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ICorePlaybackObservation } from "../../main_thread/init/utils/create_core_playback_observer";
|
|
2
|
-
import type SegmentSinksStore from "../segment_sinks";
|
|
3
|
-
/**
|
|
4
|
-
* Synchronize SegmentSinks with what has been buffered.
|
|
5
|
-
* @param {Object} observation - The just-received playback observation,
|
|
6
|
-
* including what has been buffered on lower-level buffers
|
|
7
|
-
* @param {Object} segmentSinksStore - Interface allowing to interact
|
|
8
|
-
* with `SegmentSink`s, so their inventory can be updated accordingly.
|
|
9
|
-
*/
|
|
10
|
-
export default function synchronizeSegmentSinksOnObservation(observation: ICorePlaybackObservation, segmentSinksStore: SegmentSinksStore): void;
|
|
11
|
-
//# sourceMappingURL=synchronize_sinks_on_observation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize_sinks_on_observation.d.ts","sourceRoot":"","sources":["../../../../src/core/entry/synchronize_sinks_on_observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAC3G,OAAO,KAAK,iBAAiB,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,oCAAoC,CAC1D,WAAW,EAAE,wBAAwB,EACrC,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAQN"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = synchronizeSegmentSinksOnObservation;
|
|
4
|
-
/**
|
|
5
|
-
* Synchronize SegmentSinks with what has been buffered.
|
|
6
|
-
* @param {Object} observation - The just-received playback observation,
|
|
7
|
-
* including what has been buffered on lower-level buffers
|
|
8
|
-
* @param {Object} segmentSinksStore - Interface allowing to interact
|
|
9
|
-
* with `SegmentSink`s, so their inventory can be updated accordingly.
|
|
10
|
-
*/
|
|
11
|
-
function synchronizeSegmentSinksOnObservation(observation, segmentSinksStore) {
|
|
12
|
-
// Synchronize SegmentSinks with what has been buffered.
|
|
13
|
-
["video", "audio", "text"].forEach(function (tType) {
|
|
14
|
-
var _a;
|
|
15
|
-
var segmentSinkStatus = segmentSinksStore.getStatus(tType);
|
|
16
|
-
if (segmentSinkStatus.type === "initialized") {
|
|
17
|
-
segmentSinkStatus.value.synchronizeInventory((_a = observation.buffered[tType]) !== null && _a !== void 0 ? _a : []);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"take_pssh_out.d.ts","sourceRoot":"","sources":["../../../../../src/parsers/containers/isobmff/take_pssh_out.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,yCAAyC;AACzC,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,gBAAgB,EAAE,CAkCrF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,iBAAiB,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CAWpB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ICorePlaybackObservation } from "../../main_thread/init/utils/create_core_playback_observer";
|
|
2
|
-
import type SegmentSinksStore from "../segment_sinks";
|
|
3
|
-
/**
|
|
4
|
-
* Synchronize SegmentSinks with what has been buffered.
|
|
5
|
-
* @param {Object} observation - The just-received playback observation,
|
|
6
|
-
* including what has been buffered on lower-level buffers
|
|
7
|
-
* @param {Object} segmentSinksStore - Interface allowing to interact
|
|
8
|
-
* with `SegmentSink`s, so their inventory can be updated accordingly.
|
|
9
|
-
*/
|
|
10
|
-
export default function synchronizeSegmentSinksOnObservation(observation: ICorePlaybackObservation, segmentSinksStore: SegmentSinksStore): void;
|
|
11
|
-
//# sourceMappingURL=synchronize_sinks_on_observation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize_sinks_on_observation.d.ts","sourceRoot":"","sources":["../../../../src/core/entry/synchronize_sinks_on_observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAC3G,OAAO,KAAK,iBAAiB,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,oCAAoC,CAC1D,WAAW,EAAE,wBAAwB,EACrC,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAQN"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Synchronize SegmentSinks with what has been buffered.
|
|
3
|
-
* @param {Object} observation - The just-received playback observation,
|
|
4
|
-
* including what has been buffered on lower-level buffers
|
|
5
|
-
* @param {Object} segmentSinksStore - Interface allowing to interact
|
|
6
|
-
* with `SegmentSink`s, so their inventory can be updated accordingly.
|
|
7
|
-
*/
|
|
8
|
-
export default function synchronizeSegmentSinksOnObservation(observation, segmentSinksStore) {
|
|
9
|
-
// Synchronize SegmentSinks with what has been buffered.
|
|
10
|
-
["video", "audio", "text"].forEach((tType) => {
|
|
11
|
-
var _a;
|
|
12
|
-
const segmentSinkStatus = segmentSinksStore.getStatus(tType);
|
|
13
|
-
if (segmentSinkStatus.type === "initialized") {
|
|
14
|
-
segmentSinkStatus.value.synchronizeInventory((_a = observation.buffered[tType]) !== null && _a !== void 0 ? _a : []);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"take_pssh_out.d.ts","sourceRoot":"","sources":["../../../../../src/parsers/containers/isobmff/take_pssh_out.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,yCAAyC;AACzC,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,gBAAgB,EAAE,CAkCrF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,iBAAiB,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CAWpB"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import BandwidthEstimator from "../bandwidth_estimator";
|
|
3
|
-
|
|
4
|
-
describe("ABR - BandwidthEstimator", () => {
|
|
5
|
-
it("should return undefined if no sample has been added yet", () => {
|
|
6
|
-
const bwEstimator = new BandwidthEstimator();
|
|
7
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should return undefined if not enough bytes has been received", () => {
|
|
11
|
-
const bwEstimator = new BandwidthEstimator();
|
|
12
|
-
bwEstimator.addSample(800, 10);
|
|
13
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
14
|
-
bwEstimator.addSample(800, 10);
|
|
15
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
16
|
-
bwEstimator.addSample(800, 10);
|
|
17
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
18
|
-
bwEstimator.addSample(80000000, 1000000);
|
|
19
|
-
expect(bwEstimator.getEstimate()).toBe(100);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should calculate bitrate in function of consecutive request' durations and size", () => {
|
|
23
|
-
const bwEstimator = new BandwidthEstimator();
|
|
24
|
-
bwEstimator.addSample(8000, 1000000);
|
|
25
|
-
expect(bwEstimator.getEstimate()).toBe(1000000);
|
|
26
|
-
bwEstimator.addSample(4000, 1000000);
|
|
27
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
|
|
28
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1400000);
|
|
29
|
-
bwEstimator.addSample(1000, 1000000);
|
|
30
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(3000000);
|
|
31
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(2000000);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should reset the estimation when reset is called", () => {
|
|
35
|
-
const bwEstimator = new BandwidthEstimator();
|
|
36
|
-
bwEstimator.addSample(8000, 1000000);
|
|
37
|
-
bwEstimator.addSample(4000, 1000000);
|
|
38
|
-
bwEstimator.addSample(1000, 1000000);
|
|
39
|
-
|
|
40
|
-
bwEstimator.reset();
|
|
41
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
42
|
-
bwEstimator.addSample(8000, 1000000);
|
|
43
|
-
expect(bwEstimator.getEstimate()).toBe(1000000);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should estimate a low bitrate quicker than a higher one", () => {
|
|
47
|
-
const bwEstimator = new BandwidthEstimator();
|
|
48
|
-
|
|
49
|
-
// 1st test:
|
|
50
|
-
// we raise the bitrate from 1 mega to 2 mega
|
|
51
|
-
// we should slowly go toward 2 megas as an estimate
|
|
52
|
-
bwEstimator.addSample(8000, 1000000); // 1 mega
|
|
53
|
-
bwEstimator.addSample(4000, 1000000); // 2 mega
|
|
54
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
|
|
55
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1400000);
|
|
56
|
-
bwEstimator.addSample(4000, 1000000);
|
|
57
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1700000);
|
|
58
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1600000);
|
|
59
|
-
bwEstimator.addSample(4000, 1000000);
|
|
60
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1800000);
|
|
61
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1700000);
|
|
62
|
-
bwEstimator.addSample(4000, 1000000);
|
|
63
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1900000);
|
|
64
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1800000);
|
|
65
|
-
bwEstimator.addSample(4000, 1000000);
|
|
66
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1900000);
|
|
67
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1800000);
|
|
68
|
-
bwEstimator.addSample(4000, 1000000); // 6 iterations for 1900000+
|
|
69
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(2000000);
|
|
70
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1900000);
|
|
71
|
-
|
|
72
|
-
bwEstimator.reset();
|
|
73
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
74
|
-
|
|
75
|
-
// 2st test:
|
|
76
|
-
// we decrease the bitrate from 2 mega to 1 mega
|
|
77
|
-
// we should quickly go to 1 mega
|
|
78
|
-
bwEstimator.addSample(4000, 1000000); // 2 mega
|
|
79
|
-
bwEstimator.addSample(8000, 1000000); // 1 mega - only 1 iteration for sub 1100000!
|
|
80
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1100000);
|
|
81
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1000000);
|
|
82
|
-
|
|
83
|
-
bwEstimator.reset();
|
|
84
|
-
expect(bwEstimator.getEstimate()).toBe(undefined);
|
|
85
|
-
|
|
86
|
-
// 3rd test:
|
|
87
|
-
// we both go up and down, from 5 mega to 10 then to 1 and come back to 10.
|
|
88
|
-
// the 1 mega estimate should have a very perceptible influence, even when
|
|
89
|
-
// going back to 10
|
|
90
|
-
bwEstimator.addSample(2000, 1250000); // 5 mega
|
|
91
|
-
expect(bwEstimator.getEstimate()).toBe(5000000);
|
|
92
|
-
bwEstimator.addSample(2000, 1250100); // 5 mega
|
|
93
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(5000000);
|
|
94
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(5010000);
|
|
95
|
-
bwEstimator.addSample(1000, 1250700); // 10 mega
|
|
96
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(6000000);
|
|
97
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(6500000);
|
|
98
|
-
bwEstimator.addSample(1000, 1251000); // 10 mega
|
|
99
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(6500000);
|
|
100
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(7000000);
|
|
101
|
-
bwEstimator.addSample(10000, 1251000); // 1 mega
|
|
102
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(1000000);
|
|
103
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
|
|
104
|
-
bwEstimator.addSample(1000, 1250000); // 10 mega
|
|
105
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(3000000);
|
|
106
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(3500000);
|
|
107
|
-
bwEstimator.addSample(1000, 1250100); // 10 mega
|
|
108
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(3500000);
|
|
109
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(4000000);
|
|
110
|
-
bwEstimator.addSample(1000, 1250100); // 10 mega
|
|
111
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(4000000);
|
|
112
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(4500000);
|
|
113
|
-
bwEstimator.addSample(1000, 1250100); // 10 mega
|
|
114
|
-
expect(bwEstimator.getEstimate()).toBeGreaterThan(4500000);
|
|
115
|
-
expect(bwEstimator.getEstimate()).toBeLessThan(5000000);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ICorePlaybackObservation } from "../../main_thread/init/utils/create_core_playback_observer";
|
|
2
|
-
import type SegmentSinksStore from "../segment_sinks";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Synchronize SegmentSinks with what has been buffered.
|
|
6
|
-
* @param {Object} observation - The just-received playback observation,
|
|
7
|
-
* including what has been buffered on lower-level buffers
|
|
8
|
-
* @param {Object} segmentSinksStore - Interface allowing to interact
|
|
9
|
-
* with `SegmentSink`s, so their inventory can be updated accordingly.
|
|
10
|
-
*/
|
|
11
|
-
export default function synchronizeSegmentSinksOnObservation(
|
|
12
|
-
observation: ICorePlaybackObservation,
|
|
13
|
-
segmentSinksStore: SegmentSinksStore,
|
|
14
|
-
): void {
|
|
15
|
-
// Synchronize SegmentSinks with what has been buffered.
|
|
16
|
-
["video" as const, "audio" as const, "text" as const].forEach((tType) => {
|
|
17
|
-
const segmentSinkStatus = segmentSinksStore.getStatus(tType);
|
|
18
|
-
if (segmentSinkStatus.type === "initialized") {
|
|
19
|
-
segmentSinkStatus.value.synchronizeInventory(observation.buffered[tType] ?? []);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|