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,100 @@
|
|
|
1
|
+
import SharedReference from "../../../utils/reference";
|
|
2
|
+
import type {
|
|
3
|
+
IABREstimate,
|
|
4
|
+
IAdaptiveRepresentationSelectorArguments,
|
|
5
|
+
IRepresentationEstimator,
|
|
6
|
+
} from "../adaptive_representation_selector";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Easily create objects matching the arguments of the `AdaptiveRepresentationSelector`.
|
|
10
|
+
*/
|
|
11
|
+
export function makeAdaptiveRepresensationSelectorArgs(
|
|
12
|
+
opts: Partial<IAdaptiveRepresentationSelectorArguments> = {},
|
|
13
|
+
): IAdaptiveRepresentationSelectorArguments {
|
|
14
|
+
return {
|
|
15
|
+
initialBitrates: {},
|
|
16
|
+
lowLatencyMode: false,
|
|
17
|
+
throttlers: {
|
|
18
|
+
limitResolution: {},
|
|
19
|
+
throttleBitrate: {},
|
|
20
|
+
},
|
|
21
|
+
...opts,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Easily create objects matching the `IABREstimate` structure. */
|
|
26
|
+
export function makeAbrEstimate(opts: Partial<IABREstimate> = {}): IABREstimate {
|
|
27
|
+
return {
|
|
28
|
+
bitrate: undefined,
|
|
29
|
+
representation: null,
|
|
30
|
+
urgent: false,
|
|
31
|
+
knownStableBitrate: undefined,
|
|
32
|
+
...opts,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Object facilitation the usage of a `IRepresentationEstimator`.
|
|
38
|
+
* /!\ Do not forget to call `reset` when done to ensure no memory leak.
|
|
39
|
+
*/
|
|
40
|
+
export interface IMockedRepresentationEstimator {
|
|
41
|
+
/** The `IRepresentationEstimator` itself. */
|
|
42
|
+
estimator: IRepresentationEstimator;
|
|
43
|
+
/**
|
|
44
|
+
* Allows to trigger new estimate through **every** objects returned by
|
|
45
|
+
* `estimator`.
|
|
46
|
+
*/
|
|
47
|
+
emit: (obj: IABREstimate) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Reset `estimator` to its initial state, also removing all estimate
|
|
50
|
+
* listeners it potentially had.
|
|
51
|
+
* Intended to be called between each test to clean-up.
|
|
52
|
+
*/
|
|
53
|
+
reset: () => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Allows to create a `IRepresentationEstimator` with TypeScript typechecking
|
|
58
|
+
* and to obtain a function allowing to emit estimates.
|
|
59
|
+
* @returns {Object} res
|
|
60
|
+
*/
|
|
61
|
+
export function makeMockedRepresentationEstimator(): {
|
|
62
|
+
estimator: IRepresentationEstimator;
|
|
63
|
+
emit: (obj: IABREstimate) => void;
|
|
64
|
+
reset: () => void;
|
|
65
|
+
} {
|
|
66
|
+
let ref = new SharedReference<IABREstimate>(makeAbrEstimate());
|
|
67
|
+
const estimator: IRepresentationEstimator = () => {
|
|
68
|
+
return {
|
|
69
|
+
estimates: ref,
|
|
70
|
+
callbacks: {
|
|
71
|
+
// TODO: find out how to exploit those after writing some tests
|
|
72
|
+
addedSegment() {
|
|
73
|
+
throw new Error("Not implemented");
|
|
74
|
+
},
|
|
75
|
+
metrics() {
|
|
76
|
+
throw new Error("Not implemented");
|
|
77
|
+
},
|
|
78
|
+
requestBegin() {
|
|
79
|
+
throw new Error("Not implemented");
|
|
80
|
+
},
|
|
81
|
+
requestEnd() {
|
|
82
|
+
throw new Error("Not implemented");
|
|
83
|
+
},
|
|
84
|
+
requestProgress() {
|
|
85
|
+
throw new Error("Not implemented");
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
estimator,
|
|
92
|
+
emit(obj: IABREstimate) {
|
|
93
|
+
ref.setValue(obj);
|
|
94
|
+
},
|
|
95
|
+
reset() {
|
|
96
|
+
ref.finish();
|
|
97
|
+
ref = new SharedReference<IABREstimate>(makeAbrEstimate());
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import configHandler from "../../../config";
|
|
3
|
+
import {
|
|
4
|
+
DummyAdaptation,
|
|
5
|
+
DummyPeriod,
|
|
6
|
+
DummyRepresentation,
|
|
7
|
+
DummyManifest,
|
|
8
|
+
createSegment,
|
|
9
|
+
} from "../../../manifest/classes/__tests__/mocks";
|
|
10
|
+
import { DummyObservationPosition } from "../../../playback_observer/__tests__/mocks";
|
|
11
|
+
import { makeMockedClass } from "../../../utils/test-utils";
|
|
12
|
+
import type { IPlaybackConditionsInfo } from "../network_analyzer";
|
|
2
13
|
import NetworkAnalyzer, { estimateRequestBandwidth } from "../network_analyzer";
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
vi.mock("../../../config", () => ({
|
|
10
|
-
default: {
|
|
11
|
-
getCurrent: vi.fn(() => ({
|
|
12
|
-
ABR_STARVATION_GAP: {
|
|
13
|
-
DEFAULT: 2,
|
|
14
|
-
LOW_LATENCY: 1,
|
|
15
|
-
},
|
|
16
|
-
OUT_OF_STARVATION_GAP: {
|
|
17
|
-
DEFAULT: 3,
|
|
18
|
-
LOW_LATENCY: 1.5,
|
|
19
|
-
},
|
|
20
|
-
ABR_STARVATION_FACTOR: {
|
|
21
|
-
DEFAULT: 0.72,
|
|
22
|
-
LOW_LATENCY: 0.8,
|
|
23
|
-
},
|
|
24
|
-
ABR_REGULAR_FACTOR: {
|
|
25
|
-
DEFAULT: 0.8,
|
|
26
|
-
LOW_LATENCY: 0.85,
|
|
27
|
-
},
|
|
28
|
-
ABR_STARVATION_DURATION_DELTA: 5,
|
|
29
|
-
})),
|
|
30
|
-
},
|
|
31
|
-
}));
|
|
14
|
+
import type BandwidthEstimator from "../utils/bandwidth_estimator";
|
|
15
|
+
import type {
|
|
16
|
+
IPendingRequestStoreProgress,
|
|
17
|
+
IRequestInfo,
|
|
18
|
+
} from "../utils/pending_requests_store";
|
|
32
19
|
|
|
33
20
|
vi.mock("../../../log", () => ({
|
|
34
21
|
default: {
|
|
@@ -36,29 +23,37 @@ vi.mock("../../../log", () => ({
|
|
|
36
23
|
},
|
|
37
24
|
}));
|
|
38
25
|
|
|
39
|
-
vi.mock("../../../utils/monotonic_timestamp", () => ({
|
|
40
|
-
// eslint-disable-next-line no-restricted-properties
|
|
41
|
-
default: vi.fn(() => performance.now()),
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
26
|
function createMockRequest(
|
|
45
27
|
segmentTime: number,
|
|
46
28
|
segmentDuration: number,
|
|
47
29
|
requestTimestamp: number,
|
|
48
|
-
progress: Array<
|
|
30
|
+
progress: Array<Partial<IPendingRequestStoreProgress>> = [],
|
|
49
31
|
complete = true,
|
|
50
32
|
): IRequestInfo {
|
|
51
33
|
return {
|
|
52
34
|
content: {
|
|
53
|
-
segment: {
|
|
35
|
+
segment: createSegment({
|
|
54
36
|
time: segmentTime,
|
|
55
37
|
duration: segmentDuration,
|
|
56
38
|
complete,
|
|
57
|
-
},
|
|
39
|
+
}),
|
|
40
|
+
adaptation: new DummyAdaptation(),
|
|
41
|
+
period: new DummyPeriod(),
|
|
42
|
+
representation: new DummyRepresentation(),
|
|
43
|
+
manifest: new DummyManifest(),
|
|
58
44
|
},
|
|
59
45
|
requestTimestamp,
|
|
60
|
-
progress
|
|
61
|
-
|
|
46
|
+
progress: progress.map((p) => {
|
|
47
|
+
return {
|
|
48
|
+
size: 1000,
|
|
49
|
+
timestamp: 1000,
|
|
50
|
+
totalSize: 10000,
|
|
51
|
+
duration: 2,
|
|
52
|
+
id: "toto",
|
|
53
|
+
...p,
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
function createMockPlaybackInfo(
|
|
@@ -66,20 +61,71 @@ function createMockPlaybackInfo(
|
|
|
66
61
|
position: number,
|
|
67
62
|
speed = 1,
|
|
68
63
|
duration = 100,
|
|
69
|
-
):
|
|
64
|
+
): IPlaybackConditionsInfo {
|
|
70
65
|
return {
|
|
71
66
|
bufferGap,
|
|
72
|
-
position:
|
|
67
|
+
position: new DummyObservationPosition({
|
|
68
|
+
getWanted: () => position,
|
|
69
|
+
getPolled: () => position,
|
|
70
|
+
}),
|
|
73
71
|
speed,
|
|
74
72
|
duration,
|
|
75
73
|
};
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
function createMockBandwidthEstimator(estimate?: number):
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
function createMockBandwidthEstimator(estimate?: number): BandwidthEstimator {
|
|
77
|
+
const DummyBandwidthEstimator = makeMockedClass<BandwidthEstimator>(
|
|
78
|
+
{
|
|
79
|
+
getEstimate: vi.fn(() => estimate),
|
|
80
|
+
reset: vi.fn(),
|
|
81
|
+
addSample: vi.fn(),
|
|
82
|
+
},
|
|
83
|
+
{},
|
|
84
|
+
);
|
|
85
|
+
return new DummyBandwidthEstimator();
|
|
86
|
+
}
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
const originalConfig = configHandler.getCurrent();
|
|
89
|
+
vi.spyOn(configHandler, "getCurrent").mockReturnValue({
|
|
90
|
+
...originalConfig,
|
|
91
|
+
ABR_STARVATION_GAP: {
|
|
92
|
+
DEFAULT: 2,
|
|
93
|
+
LOW_LATENCY: 1,
|
|
94
|
+
},
|
|
95
|
+
OUT_OF_STARVATION_GAP: {
|
|
96
|
+
DEFAULT: 3,
|
|
97
|
+
LOW_LATENCY: 1.5,
|
|
98
|
+
},
|
|
99
|
+
ABR_STARVATION_FACTOR: {
|
|
100
|
+
DEFAULT: 0.72,
|
|
101
|
+
LOW_LATENCY: 0.8,
|
|
102
|
+
},
|
|
103
|
+
ABR_REGULAR_FACTOR: {
|
|
104
|
+
DEFAULT: 0.8,
|
|
105
|
+
LOW_LATENCY: 0.85,
|
|
106
|
+
},
|
|
107
|
+
ABR_STARVATION_DURATION_DELTA: 5,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
afterEach(() => {
|
|
111
|
+
vi.resetAllMocks();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
function createProgressEvents(
|
|
115
|
+
baseTime: number,
|
|
116
|
+
totalSize: number,
|
|
117
|
+
stepSize: number,
|
|
118
|
+
stepDurationMs: number,
|
|
119
|
+
): Array<{ size: number; timestamp: number; totalSize: number }> {
|
|
120
|
+
const progress = [{ size: 0, timestamp: baseTime, totalSize }];
|
|
121
|
+
let size = 0;
|
|
122
|
+
let timestamp = baseTime;
|
|
123
|
+
while (size < totalSize) {
|
|
124
|
+
size = Math.min(size + stepSize, totalSize);
|
|
125
|
+
timestamp += stepDurationMs;
|
|
126
|
+
progress.push({ size, timestamp, totalSize });
|
|
127
|
+
}
|
|
128
|
+
return progress;
|
|
83
129
|
}
|
|
84
130
|
|
|
85
131
|
describe("estimateRequestBandwidth", () => {
|
|
@@ -274,6 +320,41 @@ describe("NetworkAnalyzer", () => {
|
|
|
274
320
|
expect(result.bitrateChosen).toBe(2000000 * 0.8);
|
|
275
321
|
});
|
|
276
322
|
|
|
323
|
+
it("should allow emergency estimate before 12s for short segments", () => {
|
|
324
|
+
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
325
|
+
const bandwidthEstimator = createMockBandwidthEstimator(undefined);
|
|
326
|
+
const resetSpy = vi.spyOn(bandwidthEstimator, "reset");
|
|
327
|
+
const requestStart = 1000;
|
|
328
|
+
const now = 7000;
|
|
329
|
+
const performanceNowSpy = vi.spyOn(performance, "now").mockReturnValue(now);
|
|
330
|
+
const currentRepresentation = new DummyRepresentation({
|
|
331
|
+
bitrate: 1_200_000,
|
|
332
|
+
});
|
|
333
|
+
const currentRequests = [
|
|
334
|
+
createMockRequest(
|
|
335
|
+
10,
|
|
336
|
+
2,
|
|
337
|
+
requestStart,
|
|
338
|
+
createProgressEvents(requestStart, 1_000_000, 100_000, 100),
|
|
339
|
+
true,
|
|
340
|
+
),
|
|
341
|
+
];
|
|
342
|
+
|
|
343
|
+
const result = analyzer.getBandwidthEstimate(
|
|
344
|
+
createMockPlaybackInfo(1, 9),
|
|
345
|
+
bandwidthEstimator,
|
|
346
|
+
currentRepresentation,
|
|
347
|
+
currentRequests,
|
|
348
|
+
1_100_000,
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
expect(result.bandwidthEstimate).toBeDefined();
|
|
352
|
+
expect(result.bitrateChosen).toBeLessThan(currentRepresentation.bitrate);
|
|
353
|
+
expect(resetSpy).toHaveBeenCalled();
|
|
354
|
+
performanceNowSpy.mockRestore();
|
|
355
|
+
resetSpy.mockRestore();
|
|
356
|
+
});
|
|
357
|
+
|
|
277
358
|
it("should handle infinite buffer gap", () => {
|
|
278
359
|
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
279
360
|
const playbackInfo = createMockPlaybackInfo(Infinity, 0);
|
|
@@ -322,7 +403,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
322
403
|
it("should return false when bitrate is higher than current representation", () => {
|
|
323
404
|
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
324
405
|
const playbackInfo = createMockPlaybackInfo(5, 0);
|
|
325
|
-
const currentRepresentation = {
|
|
406
|
+
const currentRepresentation = new DummyRepresentation({
|
|
407
|
+
bitrate: 1000000,
|
|
408
|
+
});
|
|
326
409
|
|
|
327
410
|
const result = analyzer.isUrgent(2000000, currentRepresentation, [], playbackInfo);
|
|
328
411
|
|
|
@@ -332,7 +415,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
332
415
|
it("should return true in low latency mode when switching to lower bitrate", () => {
|
|
333
416
|
const analyzer = new NetworkAnalyzer(1000000, true);
|
|
334
417
|
const playbackInfo = createMockPlaybackInfo(5, 0);
|
|
335
|
-
const currentRepresentation = {
|
|
418
|
+
const currentRepresentation = new DummyRepresentation({
|
|
419
|
+
bitrate: 2000000,
|
|
420
|
+
});
|
|
336
421
|
|
|
337
422
|
const result = analyzer.isUrgent(1000000, currentRepresentation, [], playbackInfo);
|
|
338
423
|
|
|
@@ -342,7 +427,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
342
427
|
it("should return true when no pending requests for lower bitrate", () => {
|
|
343
428
|
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
344
429
|
const playbackInfo = createMockPlaybackInfo(5, 10);
|
|
345
|
-
const currentRepresentation = {
|
|
430
|
+
const currentRepresentation = new DummyRepresentation({
|
|
431
|
+
bitrate: 2000000,
|
|
432
|
+
});
|
|
346
433
|
|
|
347
434
|
const result = analyzer.isUrgent(1000000, currentRepresentation, [], playbackInfo);
|
|
348
435
|
|
|
@@ -354,7 +441,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
354
441
|
// eslint-disable-next-line no-restricted-properties
|
|
355
442
|
const now = performance.now();
|
|
356
443
|
const playbackInfo = createMockPlaybackInfo(2, 10);
|
|
357
|
-
const currentRepresentation = {
|
|
444
|
+
const currentRepresentation = new DummyRepresentation({
|
|
445
|
+
bitrate: 2000000,
|
|
446
|
+
});
|
|
358
447
|
|
|
359
448
|
const request = createMockRequest(10, 4, now - 1000, [
|
|
360
449
|
{ size: 0, timestamp: now - 1000, totalSize: 10000 },
|
|
@@ -377,7 +466,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
377
466
|
it("should handle requests with zero duration segments", () => {
|
|
378
467
|
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
379
468
|
const playbackInfo = createMockPlaybackInfo(5, 10);
|
|
380
|
-
const currentRepresentation = {
|
|
469
|
+
const currentRepresentation = new DummyRepresentation({
|
|
470
|
+
bitrate: 2000000,
|
|
471
|
+
});
|
|
381
472
|
|
|
382
473
|
// eslint-disable-next-line no-restricted-properties
|
|
383
474
|
const request = createMockRequest(10, 0, performance.now()); // Zero duration
|
|
@@ -395,7 +486,9 @@ describe("NetworkAnalyzer", () => {
|
|
|
395
486
|
it("should handle infinite buffer gap in urgency check", () => {
|
|
396
487
|
const analyzer = new NetworkAnalyzer(1000000, false);
|
|
397
488
|
const playbackInfo = createMockPlaybackInfo(Infinity, 10);
|
|
398
|
-
const currentRepresentation = {
|
|
489
|
+
const currentRepresentation = new DummyRepresentation({
|
|
490
|
+
bitrate: 2000000,
|
|
491
|
+
});
|
|
399
492
|
|
|
400
493
|
const result = analyzer.isUrgent(1000000, currentRepresentation, [], playbackInfo);
|
|
401
494
|
|
|
@@ -422,7 +515,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
422
515
|
result = analyzer.getBandwidthEstimate(
|
|
423
516
|
createMockPlaybackInfo(1.5, 20),
|
|
424
517
|
bandwidthEstimator,
|
|
425
|
-
{ bitrate: 1600000 }
|
|
518
|
+
new DummyRepresentation({ bitrate: 1600000 }),
|
|
426
519
|
[],
|
|
427
520
|
result.bitrateChosen,
|
|
428
521
|
);
|
|
@@ -432,7 +525,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
432
525
|
result = analyzer.getBandwidthEstimate(
|
|
433
526
|
createMockPlaybackInfo(4, 30),
|
|
434
527
|
bandwidthEstimator,
|
|
435
|
-
{ bitrate: 1440000 }
|
|
528
|
+
new DummyRepresentation({ bitrate: 1440000 }),
|
|
436
529
|
[],
|
|
437
530
|
result.bitrateChosen,
|
|
438
531
|
);
|
|
@@ -458,7 +551,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
458
551
|
result = analyzer.getBandwidthEstimate(
|
|
459
552
|
createMockPlaybackInfo(5, 10),
|
|
460
553
|
estimator,
|
|
461
|
-
{ bitrate: 2400000 }
|
|
554
|
+
new DummyRepresentation({ bitrate: 2400000 }),
|
|
462
555
|
[],
|
|
463
556
|
result.bitrateChosen,
|
|
464
557
|
);
|
|
@@ -469,7 +562,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
469
562
|
result = analyzer.getBandwidthEstimate(
|
|
470
563
|
createMockPlaybackInfo(5, 20),
|
|
471
564
|
estimator,
|
|
472
|
-
{ bitrate: 800000 }
|
|
565
|
+
new DummyRepresentation({ bitrate: 800000 }),
|
|
473
566
|
[],
|
|
474
567
|
result.bitrateChosen,
|
|
475
568
|
);
|
|
@@ -494,7 +587,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
494
587
|
result = analyzer.getBandwidthEstimate(
|
|
495
588
|
createMockPlaybackInfo(5, 10, 2),
|
|
496
589
|
estimator,
|
|
497
|
-
{ bitrate: normalBitrate }
|
|
590
|
+
new DummyRepresentation({ bitrate: normalBitrate }),
|
|
498
591
|
[],
|
|
499
592
|
result.bitrateChosen,
|
|
500
593
|
);
|
|
@@ -504,7 +597,7 @@ describe("NetworkAnalyzer", () => {
|
|
|
504
597
|
result = analyzer.getBandwidthEstimate(
|
|
505
598
|
createMockPlaybackInfo(5, 20, 0.5),
|
|
506
599
|
estimator,
|
|
507
|
-
{ bitrate: normalBitrate }
|
|
600
|
+
new DummyRepresentation({ bitrate: normalBitrate }),
|
|
508
601
|
[],
|
|
509
602
|
result.bitrateChosen,
|
|
510
603
|
);
|
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
} from "./utils/pending_requests_store";
|
|
30
30
|
|
|
31
31
|
/** Object describing the current playback conditions. */
|
|
32
|
-
type IPlaybackConditionsInfo = Pick<
|
|
32
|
+
export type IPlaybackConditionsInfo = Pick<
|
|
33
33
|
IRepresentationEstimatorPlaybackObservation,
|
|
34
34
|
"bufferGap" | "position" | "speed" | "duration"
|
|
35
35
|
>;
|
|
@@ -166,9 +166,9 @@ function estimateStarvationModeBitrate(
|
|
|
166
166
|
const concernedRequest = concernedRequests[0];
|
|
167
167
|
const now = getMonotonicTimeStamp();
|
|
168
168
|
|
|
169
|
-
let minimumRequestTime = concernedRequest.content.segment.duration *
|
|
170
|
-
minimumRequestTime = Math.
|
|
171
|
-
minimumRequestTime = Math.
|
|
169
|
+
let minimumRequestTime = concernedRequest.content.segment.duration * 1500;
|
|
170
|
+
minimumRequestTime = Math.max(minimumRequestTime, 3000);
|
|
171
|
+
minimumRequestTime = Math.min(minimumRequestTime, 12000);
|
|
172
172
|
if (now - concernedRequest.requestTimestamp < minimumRequestTime) {
|
|
173
173
|
return undefined;
|
|
174
174
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import
|
|
2
|
+
import { DummyRepresentation } from "../../../../manifest/classes/__tests__/mocks";
|
|
3
3
|
import filterByBitrate from "../filter_by_bitrate";
|
|
4
4
|
|
|
5
5
|
describe("ABR - filterByBitrate", () => {
|
|
6
6
|
const fakeReps = [
|
|
7
|
-
{ bitrate: 100 },
|
|
8
|
-
{ bitrate: 100 },
|
|
9
|
-
{ bitrate: 1000 },
|
|
10
|
-
{ bitrate: 10000 },
|
|
11
|
-
{ bitrate: 100000 },
|
|
7
|
+
new DummyRepresentation({ bitrate: 100 }),
|
|
8
|
+
new DummyRepresentation({ bitrate: 100 }),
|
|
9
|
+
new DummyRepresentation({ bitrate: 1000 }),
|
|
10
|
+
new DummyRepresentation({ bitrate: 10000 }),
|
|
11
|
+
new DummyRepresentation({ bitrate: 100000 }),
|
|
12
12
|
];
|
|
13
13
|
|
|
14
14
|
describe("filterByBitrate", () => {
|
|
@@ -17,25 +17,17 @@ describe("ABR - filterByBitrate", () => {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should return all representations when specified bitrate is infinite", () => {
|
|
20
|
-
expect(filterByBitrate(fakeReps
|
|
20
|
+
expect(filterByBitrate(fakeReps, Infinity)).toEqual(fakeReps);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it("should return the lowest representation when specified bitrate is 0", () => {
|
|
24
|
-
const expectedFilteredReps = [
|
|
25
|
-
expect(filterByBitrate(fakeReps
|
|
26
|
-
expectedFilteredReps,
|
|
27
|
-
);
|
|
24
|
+
const expectedFilteredReps = [fakeReps[0], fakeReps[1]];
|
|
25
|
+
expect(filterByBitrate(fakeReps, 0)).toEqual(expectedFilteredReps);
|
|
28
26
|
});
|
|
29
27
|
|
|
30
28
|
it("should filter representation when specified bitrate is 999", () => {
|
|
31
|
-
const expectedFilteredReps = [
|
|
32
|
-
|
|
33
|
-
{ bitrate: 100 },
|
|
34
|
-
{ bitrate: 1000 },
|
|
35
|
-
];
|
|
36
|
-
expect(filterByBitrate(fakeReps as IRepresentation[], 1010)).toEqual(
|
|
37
|
-
expectedFilteredReps,
|
|
38
|
-
);
|
|
29
|
+
const expectedFilteredReps = [fakeReps[0], fakeReps[1], fakeReps[2]];
|
|
30
|
+
expect(filterByBitrate(fakeReps, 1010)).toEqual(expectedFilteredReps);
|
|
39
31
|
});
|
|
40
32
|
});
|
|
41
33
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import
|
|
2
|
+
import { DummyRepresentation } from "../../../../manifest/classes/__tests__/mocks";
|
|
3
3
|
import filterByResolution from "../filter_by_resolution";
|
|
4
4
|
|
|
5
5
|
describe("ABR - filterByResolution", () => {
|
|
6
6
|
const fakeReps = [
|
|
7
|
-
{ height: 80, width: 100 },
|
|
8
|
-
{ height: 800, width: 1000 },
|
|
9
|
-
{ height: 8000, width: 10000 },
|
|
10
|
-
{ height: 80000, width: 100000 },
|
|
7
|
+
new DummyRepresentation({ height: 80, width: 100 }),
|
|
8
|
+
new DummyRepresentation({ height: 800, width: 1000 }),
|
|
9
|
+
new DummyRepresentation({ height: 8000, width: 10000 }),
|
|
10
|
+
new DummyRepresentation({ height: 80000, width: 100000 }),
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
describe("filterByResolution", () => {
|
|
14
14
|
it("should do nothing for a given `undefined` height", () => {
|
|
15
15
|
expect(
|
|
16
|
-
filterByResolution(fakeReps
|
|
16
|
+
filterByResolution(fakeReps, {
|
|
17
17
|
height: undefined,
|
|
18
18
|
width: 10,
|
|
19
19
|
pixelRatio: 1,
|
|
@@ -22,7 +22,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
22
22
|
});
|
|
23
23
|
it("should do nothing for a given `undefined` width", () => {
|
|
24
24
|
expect(
|
|
25
|
-
filterByResolution(fakeReps
|
|
25
|
+
filterByResolution(fakeReps, {
|
|
26
26
|
height: undefined,
|
|
27
27
|
width: 10,
|
|
28
28
|
pixelRatio: 1,
|
|
@@ -32,7 +32,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
32
32
|
|
|
33
33
|
it("should properly filter until a set resolution", () => {
|
|
34
34
|
expect(
|
|
35
|
-
filterByResolution(fakeReps
|
|
35
|
+
filterByResolution(fakeReps, {
|
|
36
36
|
height: 8000,
|
|
37
37
|
width: 10000,
|
|
38
38
|
pixelRatio: 1,
|
|
@@ -42,7 +42,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
42
42
|
|
|
43
43
|
it("should include the immediately superior resolution if nothing equal exist", () => {
|
|
44
44
|
expect(
|
|
45
|
-
filterByResolution(fakeReps
|
|
45
|
+
filterByResolution(fakeReps, {
|
|
46
46
|
height: 700,
|
|
47
47
|
width: 900,
|
|
48
48
|
pixelRatio: 1,
|
|
@@ -52,7 +52,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
52
52
|
|
|
53
53
|
it("should take into account the pixel ratio", () => {
|
|
54
54
|
expect(
|
|
55
|
-
filterByResolution(fakeReps
|
|
55
|
+
filterByResolution(fakeReps, {
|
|
56
56
|
height: 70,
|
|
57
57
|
width: 90,
|
|
58
58
|
pixelRatio: 10,
|
|
@@ -62,7 +62,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
62
62
|
|
|
63
63
|
it("should take higher resolution if just the height is lower", () => {
|
|
64
64
|
expect(
|
|
65
|
-
filterByResolution(fakeReps
|
|
65
|
+
filterByResolution(fakeReps, {
|
|
66
66
|
height: 801,
|
|
67
67
|
width: 900,
|
|
68
68
|
pixelRatio: 1,
|
|
@@ -72,7 +72,7 @@ describe("ABR - filterByResolution", () => {
|
|
|
72
72
|
|
|
73
73
|
it("should take higher resolution if just the width is lower", () => {
|
|
74
74
|
expect(
|
|
75
|
-
filterByResolution(fakeReps
|
|
75
|
+
filterByResolution(fakeReps, {
|
|
76
76
|
height: 799,
|
|
77
77
|
width: 1001,
|
|
78
78
|
pixelRatio: 1,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
+
import { DummyRepresentation } from "../../../../manifest/classes/__tests__/mocks";
|
|
2
3
|
import LastEstimateStorage, { ABRAlgorithmType } from "../last_estimate_storage";
|
|
3
4
|
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
7
|
-
|
|
8
5
|
describe("LastEstimateStorage", () => {
|
|
9
6
|
let storage: LastEstimateStorage;
|
|
10
7
|
|
|
@@ -28,44 +25,60 @@ describe("LastEstimateStorage", () => {
|
|
|
28
25
|
|
|
29
26
|
describe("update()", () => {
|
|
30
27
|
it("should update representation with the provided value", () => {
|
|
31
|
-
const representation = {
|
|
28
|
+
const representation = new DummyRepresentation({
|
|
29
|
+
id: "rep1",
|
|
30
|
+
bitrate: 1000,
|
|
31
|
+
});
|
|
32
32
|
storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
|
|
33
33
|
expect(storage.representation).toBe(representation);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
it("should update bandwidth with the provided value", () => {
|
|
37
|
-
const representation = {
|
|
37
|
+
const representation = new DummyRepresentation({
|
|
38
|
+
id: "rep1",
|
|
39
|
+
bitrate: 1000,
|
|
40
|
+
});
|
|
38
41
|
storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
|
|
39
42
|
expect(storage.bandwidth).toBe(500);
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
it("should update algorithmType with the provided value", () => {
|
|
43
|
-
const representation = {
|
|
46
|
+
const representation = new DummyRepresentation({
|
|
47
|
+
id: "rep1",
|
|
48
|
+
bitrate: 1000,
|
|
49
|
+
});
|
|
44
50
|
storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
|
|
45
51
|
expect(storage.algorithmType).toBe(ABRAlgorithmType.BandwidthBased);
|
|
46
52
|
});
|
|
47
53
|
|
|
48
54
|
it("should allow bandwidth to be undefined", () => {
|
|
49
|
-
const representation = {
|
|
55
|
+
const representation = new DummyRepresentation({
|
|
56
|
+
id: "rep1",
|
|
57
|
+
bitrate: 1000,
|
|
58
|
+
});
|
|
50
59
|
storage.update(representation, undefined, ABRAlgorithmType.BufferBased);
|
|
51
60
|
expect(storage.bandwidth).toBeUndefined();
|
|
52
61
|
});
|
|
53
62
|
|
|
54
63
|
it("should correctly reflect a BufferBased algorithm type", () => {
|
|
55
|
-
const representation = {
|
|
64
|
+
const representation = new DummyRepresentation({
|
|
65
|
+
id: "rep2",
|
|
66
|
+
});
|
|
56
67
|
storage.update(representation, 200, ABRAlgorithmType.BufferBased);
|
|
57
68
|
expect(storage.algorithmType).toBe(ABRAlgorithmType.BufferBased);
|
|
58
69
|
});
|
|
59
70
|
|
|
60
71
|
it("should correctly reflect a GuessBased algorithm type", () => {
|
|
61
|
-
const representation = {
|
|
72
|
+
const representation = new DummyRepresentation({
|
|
73
|
+
id: "rep3",
|
|
74
|
+
});
|
|
62
75
|
storage.update(representation, 300, ABRAlgorithmType.GuessBased);
|
|
63
76
|
expect(storage.algorithmType).toBe(ABRAlgorithmType.GuessBased);
|
|
64
77
|
});
|
|
65
78
|
|
|
66
79
|
it("should overwrite previous values on subsequent updates", () => {
|
|
67
|
-
const rep1 = { id: "rep1" }
|
|
68
|
-
const rep2 = { id: "rep2" }
|
|
80
|
+
const rep1 = new DummyRepresentation({ id: "rep1" });
|
|
81
|
+
const rep2 = new DummyRepresentation({ id: "rep2" });
|
|
69
82
|
storage.update(rep1, 100, ABRAlgorithmType.BandwidthBased);
|
|
70
83
|
storage.update(rep2, 999, ABRAlgorithmType.GuessBased);
|
|
71
84
|
expect(storage.representation).toBe(rep2);
|