rx-player 4.5.0-dev.2026033100 → 4.5.0-dev.2026043000
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 +25 -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/content_time_boundaries_observer.d.ts.map +1 -1
- package/dist/commonjs/core/entry/content_time_boundaries_observer.js +18 -4
- 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/errors/index.d.ts +2 -2
- package/dist/commonjs/errors/index.d.ts.map +1 -1
- package/dist/commonjs/errors/index.js +2 -1
- package/dist/commonjs/errors/media_error.d.ts +19 -4
- package/dist/commonjs/errors/media_error.d.ts.map +1 -1
- package/dist/commonjs/errors/media_error.js +29 -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 +59 -54
- 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/content_time_boundaries_observer.d.ts.map +1 -1
- package/dist/es2017/core/entry/content_time_boundaries_observer.js +18 -4
- 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/errors/index.d.ts +2 -2
- package/dist/es2017/errors/index.d.ts.map +1 -1
- package/dist/es2017/errors/index.js +2 -2
- package/dist/es2017/errors/media_error.d.ts +19 -4
- package/dist/es2017/errors/media_error.d.ts.map +1 -1
- package/dist/es2017/errors/media_error.js +28 -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 +60 -55
- 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 +5 -3
- 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__/content_time_boundaries_observer.test.ts +5 -0
- 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/content_time_boundaries_observer.ts +18 -4
- 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/errors/__tests__/media_error.test.ts +106 -3
- package/src/errors/index.ts +2 -1
- package/src/errors/media_error.ts +63 -7
- 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 +72 -60
- 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
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
import config from "../../../../config";
|
|
18
18
|
import type { IManifestMetadata } from "../../../../manifest";
|
|
19
|
-
import { SeekingState } from "../../../../playback_observer";
|
|
20
19
|
import type {
|
|
21
20
|
IPlaybackObservation,
|
|
22
21
|
IReadOnlyPlaybackObserver,
|
|
23
22
|
} from "../../../../playback_observer";
|
|
23
|
+
import { SeekingState } from "../../../../playback_observer";
|
|
24
24
|
import EventEmitter from "../../../../utils/event_emitter";
|
|
25
25
|
import SharedReference from "../../../../utils/reference";
|
|
26
26
|
import type { CancellationSignal } from "../../../../utils/task_canceller";
|
|
@@ -42,27 +42,34 @@ interface IStreamEventsEmitterEvent {
|
|
|
42
42
|
* Get events from manifest and emit each time an event has to be emitted
|
|
43
43
|
*/
|
|
44
44
|
export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitterEvent> {
|
|
45
|
-
|
|
45
|
+
/** Regularly emit playback metrics such as the position. */
|
|
46
46
|
private _playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>;
|
|
47
|
+
/** Current stream events tracked for the whole content. */
|
|
47
48
|
private _scheduledEventsRef: SharedReference<
|
|
48
49
|
Array<IStreamEventPayload | INonFiniteStreamEventPayload>
|
|
49
50
|
>;
|
|
51
|
+
/** Events currently considered active, to only emit their enter/exit once. */
|
|
50
52
|
private _eventsBeingPlayed: WeakMap<
|
|
51
53
|
IStreamEventPayload | INonFiniteStreamEventPayload,
|
|
52
54
|
true
|
|
53
55
|
>;
|
|
56
|
+
/** Whether event evaluation is temporarily suspended, e.g. during a reload. */
|
|
57
|
+
private _isPaused: boolean;
|
|
58
|
+
/** Last observation used as comparison point for the next event check. */
|
|
59
|
+
private _previousObservation: {
|
|
60
|
+
/** Media position that is being played. */
|
|
61
|
+
currentTime: number;
|
|
62
|
+
/** If `true`, we're currently seeking in the media. */
|
|
63
|
+
isSeeking: boolean;
|
|
64
|
+
} | null;
|
|
65
|
+
/** Cancels the current emitter lifecycle. */
|
|
54
66
|
private _canceller: TaskCanceller | null;
|
|
55
67
|
|
|
56
68
|
/**
|
|
57
|
-
* @param {Object} manifest
|
|
58
69
|
* @param {Object} playbackObserver
|
|
59
70
|
*/
|
|
60
|
-
constructor(
|
|
61
|
-
manifest: IManifestMetadata,
|
|
62
|
-
playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>,
|
|
63
|
-
) {
|
|
71
|
+
constructor(playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>) {
|
|
64
72
|
super();
|
|
65
|
-
this._manifest = manifest;
|
|
66
73
|
this._playbackObserver = playbackObserver;
|
|
67
74
|
this._canceller = null;
|
|
68
75
|
this._scheduledEventsRef = new SharedReference<
|
|
@@ -72,22 +79,36 @@ export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitt
|
|
|
72
79
|
IStreamEventPayload | INonFiniteStreamEventPayload,
|
|
73
80
|
true
|
|
74
81
|
>();
|
|
82
|
+
this._isPaused = true;
|
|
83
|
+
this._previousObservation = null;
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Initialize the emitter for the given content manifest.
|
|
88
|
+
*
|
|
89
|
+
* The emitter starts in a paused state so the caller can resume it only once
|
|
90
|
+
* the corresponding media instance is actually ready.
|
|
91
|
+
* @param {Object} manifest
|
|
92
|
+
*/
|
|
93
|
+
public start(manifest: IManifestMetadata): void {
|
|
78
94
|
if (this._canceller !== null) {
|
|
79
95
|
return;
|
|
80
96
|
}
|
|
81
97
|
this._canceller = new TaskCanceller("StreamEventsEmitter");
|
|
82
98
|
|
|
83
99
|
const cancelSignal = this._canceller.signal;
|
|
84
|
-
|
|
100
|
+
this._isPaused = true;
|
|
101
|
+
this._previousObservation = null;
|
|
102
|
+
this._eventsBeingPlayed = new WeakMap<
|
|
103
|
+
IStreamEventPayload | INonFiniteStreamEventPayload,
|
|
104
|
+
true
|
|
105
|
+
>();
|
|
85
106
|
|
|
86
107
|
let isPollingEvents = false;
|
|
87
108
|
let cancelCurrentPolling = new TaskCanceller("StreamEventsEmitter Polling");
|
|
88
109
|
cancelCurrentPolling.linkToSignal(cancelSignal);
|
|
89
110
|
|
|
90
|
-
this._scheduledEventsRef.setValue(refreshScheduledEventsList([],
|
|
111
|
+
this._scheduledEventsRef.setValue(refreshScheduledEventsList([], manifest));
|
|
91
112
|
|
|
92
113
|
this._scheduledEventsRef.onUpdate(
|
|
93
114
|
({ length: scheduledEventsLength }) => {
|
|
@@ -103,16 +124,22 @@ export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitt
|
|
|
103
124
|
return;
|
|
104
125
|
}
|
|
105
126
|
isPollingEvents = true;
|
|
106
|
-
let oldObservation = constructObservation();
|
|
107
127
|
const checkStreamEvents = () => {
|
|
108
|
-
|
|
128
|
+
if (this._isPaused) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const newObservation = this._constructObservation();
|
|
132
|
+
if (this._previousObservation === null) {
|
|
133
|
+
this._previousObservation = newObservation;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
109
136
|
this._emitStreamEvents(
|
|
110
137
|
this._scheduledEventsRef.getValue(),
|
|
111
|
-
|
|
138
|
+
this._previousObservation,
|
|
112
139
|
newObservation,
|
|
113
140
|
cancelCurrentPolling.signal,
|
|
114
141
|
);
|
|
115
|
-
|
|
142
|
+
this._previousObservation = newObservation;
|
|
116
143
|
};
|
|
117
144
|
|
|
118
145
|
const { STREAM_EVENT_EMITTER_POLL_INTERVAL } = config.getCurrent();
|
|
@@ -120,7 +147,7 @@ export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitt
|
|
|
120
147
|
checkStreamEvents,
|
|
121
148
|
STREAM_EVENT_EMITTER_POLL_INTERVAL,
|
|
122
149
|
);
|
|
123
|
-
|
|
150
|
+
this._playbackObserver.listen(checkStreamEvents, {
|
|
124
151
|
includeLastObservation: false,
|
|
125
152
|
clearSignal: cancelCurrentPolling.signal,
|
|
126
153
|
});
|
|
@@ -128,20 +155,34 @@ export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitt
|
|
|
128
155
|
cancelCurrentPolling.signal.register(() => {
|
|
129
156
|
clearInterval(intervalId);
|
|
130
157
|
});
|
|
131
|
-
|
|
132
|
-
function constructObservation() {
|
|
133
|
-
const lastObservation = playbackObserver.getReference().getValue();
|
|
134
|
-
const currentTime =
|
|
135
|
-
playbackObserver.getCurrentTime() ??
|
|
136
|
-
playbackObserver.getReference().getValue().position.getPolled();
|
|
137
|
-
const isSeeking = lastObservation.seeking !== SeekingState.None;
|
|
138
|
-
return { currentTime, isSeeking };
|
|
139
|
-
}
|
|
140
158
|
},
|
|
141
159
|
{ emitCurrentValue: true, clearSignal: cancelSignal },
|
|
142
160
|
);
|
|
143
161
|
}
|
|
144
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Suspend event evaluation until `resume` has been called.
|
|
165
|
+
*
|
|
166
|
+
* To use when playback metrics should be temporarily ignored, for example
|
|
167
|
+
* while reloading a content.
|
|
168
|
+
*/
|
|
169
|
+
public pause(): void {
|
|
170
|
+
this._isPaused = true;
|
|
171
|
+
this._previousObservation = null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Resume event evaluation from the current playback state.
|
|
176
|
+
*/
|
|
177
|
+
public resume(): void {
|
|
178
|
+
this._isPaused = false;
|
|
179
|
+
|
|
180
|
+
// Take a snapshot right now to avoid comparing a post-reload position
|
|
181
|
+
// with a stale pre-reload observation.
|
|
182
|
+
this._previousObservation = this._constructObservation();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Refresh the tracked stream-event list after a manifest update. */
|
|
145
186
|
public onManifestUpdate(man: IManifestMetadata) {
|
|
146
187
|
const prev = this._scheduledEventsRef.getValue();
|
|
147
188
|
this._scheduledEventsRef.setValue(refreshScheduledEventsList(prev, man));
|
|
@@ -156,12 +197,35 @@ export default class StreamEventsEmitter extends EventEmitter<IStreamEventsEmitt
|
|
|
156
197
|
if (this._canceller !== null) {
|
|
157
198
|
this._canceller.cancel(reason ?? "StreamEventsEmitter stop");
|
|
158
199
|
this._canceller = null;
|
|
200
|
+
this._previousObservation = null;
|
|
201
|
+
this._eventsBeingPlayed = new WeakMap<
|
|
202
|
+
IStreamEventPayload | INonFiniteStreamEventPayload,
|
|
203
|
+
true
|
|
204
|
+
>();
|
|
159
205
|
}
|
|
160
206
|
}
|
|
161
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Construct observation object relied on by the `StreamEventsEmitted` by
|
|
210
|
+
* generating it from this instance's `PlaybackObserver`.
|
|
211
|
+
*/
|
|
212
|
+
private _constructObservation(): {
|
|
213
|
+
/** Current media position that is being played. */
|
|
214
|
+
currentTime: number;
|
|
215
|
+
/** If `true`, we're currently seeking in the media. */
|
|
216
|
+
isSeeking: boolean;
|
|
217
|
+
} {
|
|
218
|
+
const lastObservation = this._playbackObserver.getReference().getValue();
|
|
219
|
+
const currentTime =
|
|
220
|
+
this._playbackObserver.getCurrentTime() ??
|
|
221
|
+
this._playbackObserver.getReference().getValue().position.getPolled();
|
|
222
|
+
const isSeeking = lastObservation.seeking !== SeekingState.None;
|
|
223
|
+
return { currentTime, isSeeking };
|
|
224
|
+
}
|
|
225
|
+
|
|
162
226
|
/**
|
|
163
227
|
* Examine playback situation from playback observations to emit stream events and
|
|
164
|
-
* prepare
|
|
228
|
+
* prepare `onExit` callbacks if needed.
|
|
165
229
|
* @param {Array.<Object>} scheduledEvents
|
|
166
230
|
* @param {Object} oldObservation
|
|
167
231
|
* @param {Object} newObservation
|
|
@@ -218,6 +218,10 @@ export default async function renderThumbnail(
|
|
|
218
218
|
);
|
|
219
219
|
throw error;
|
|
220
220
|
}
|
|
221
|
+
if (srcError instanceof ThumbnailRenderingError) {
|
|
222
|
+
onFinished();
|
|
223
|
+
throw srcError;
|
|
224
|
+
}
|
|
221
225
|
const formattedErr = formatError(srcError, {
|
|
222
226
|
defaultCode: "NONE",
|
|
223
227
|
defaultReason: "Unknown error",
|
|
@@ -16,6 +16,18 @@ curtains.
|
|
|
16
16
|
|
|
17
17
|
## `TracksStore`
|
|
18
18
|
|
|
19
|
+
`TracksStore` is the main implementation used for Manifest-based contents. It centralizes
|
|
20
|
+
the currently chosen tracks and qualities and exposes simple operations for the API to
|
|
21
|
+
switch them.
|
|
22
|
+
|
|
19
23
|
## `TrackDispatcher`
|
|
20
24
|
|
|
25
|
+
`TrackDispatcher` links track decisions to the underlying streaming logic for a given
|
|
26
|
+
type. It is responsible for propagating updated choices and constraints when the selected
|
|
27
|
+
track or representations change.
|
|
28
|
+
|
|
21
29
|
## `MediaElementTracksStore`
|
|
30
|
+
|
|
31
|
+
`MediaElementTracksStore` is the directfile-oriented counterpart. It relies on the media
|
|
32
|
+
element's native track APIs (`audioTracks`, `videoTracks`, `textTracks`) instead of the
|
|
33
|
+
Manifest-based track model used by `TracksStore`.
|
|
@@ -3,24 +3,27 @@ import type { IMediaElement } from "../../../compat/browser_compatibility_types"
|
|
|
3
3
|
import assert from "../../../utils/assert";
|
|
4
4
|
import MediaElementTracksStore from "../media_element_tracks_store";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
function createFakeMediaElement(): IMediaElement {
|
|
7
|
+
return {
|
|
8
|
+
audioTracks: [
|
|
9
|
+
{ language: "en", enabled: false },
|
|
10
|
+
{ language: "fr", enabled: true },
|
|
11
|
+
{ language: "el", enabled: false },
|
|
12
|
+
{ language: "pt-BR", enabled: false },
|
|
13
|
+
],
|
|
14
|
+
textTracks: [
|
|
15
|
+
{ language: "en", mode: "hidden" },
|
|
16
|
+
{ language: "fr", mode: "showing" },
|
|
17
|
+
{ language: "el", mode: "hidden" },
|
|
18
|
+
{ language: "pt-BR", mode: "hidden" },
|
|
19
|
+
],
|
|
20
|
+
videoTracks: [{ language: "", selected: true }],
|
|
21
|
+
} as unknown as IMediaElement;
|
|
22
|
+
}
|
|
21
23
|
|
|
22
24
|
describe("API - MediaElementTracksStore", () => {
|
|
23
25
|
it("should returns correct results for getter", () => {
|
|
26
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
24
27
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
25
28
|
const audioTracks = trackManager.getAvailableAudioTracks();
|
|
26
29
|
const textTracks = trackManager.getAvailableTextTracks();
|
|
@@ -54,6 +57,7 @@ describe("API - MediaElementTracksStore", () => {
|
|
|
54
57
|
});
|
|
55
58
|
});
|
|
56
59
|
it("should returns correct results for setters", () => {
|
|
60
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
57
61
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
58
62
|
|
|
59
63
|
trackManager.setAudioTrackById("gen_audio_en_1");
|
|
@@ -80,6 +84,7 @@ describe("API - MediaElementTracksStore", () => {
|
|
|
80
84
|
});
|
|
81
85
|
});
|
|
82
86
|
it("should emit available tracks change when changing text contents", () => {
|
|
87
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
83
88
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
84
89
|
|
|
85
90
|
return new Promise<void>((res) => {
|
|
@@ -107,6 +112,7 @@ describe("API - MediaElementTracksStore", () => {
|
|
|
107
112
|
});
|
|
108
113
|
|
|
109
114
|
it("should emit available tracks change when changing video contents", () => {
|
|
115
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
110
116
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
111
117
|
return new Promise<void>((res) => {
|
|
112
118
|
trackManager.addEventListener("availableVideoTracksChange", (tracks) => {
|
|
@@ -129,6 +135,7 @@ describe("API - MediaElementTracksStore", () => {
|
|
|
129
135
|
});
|
|
130
136
|
|
|
131
137
|
it("should emit available tracks change when changing audio contents", () => {
|
|
138
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
132
139
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
133
140
|
return new Promise<void>((res) => {
|
|
134
141
|
trackManager.addEventListener("availableAudioTracksChange", (tracks) => {
|
|
@@ -154,18 +161,18 @@ describe("API - MediaElementTracksStore", () => {
|
|
|
154
161
|
});
|
|
155
162
|
|
|
156
163
|
it("should emit chosen track when changing text content", () => {
|
|
164
|
+
const fakeMediaElement = createFakeMediaElement();
|
|
157
165
|
const trackManager = new MediaElementTracksStore(fakeMediaElement);
|
|
158
166
|
|
|
159
167
|
return new Promise<void>((res) => {
|
|
160
168
|
trackManager.addEventListener("textTrackChange", (chosenTrack) => {
|
|
161
|
-
expect(chosenTrack?.id).toBe("
|
|
169
|
+
expect(chosenTrack?.id).toBe("gen_text_en_1");
|
|
162
170
|
res();
|
|
163
171
|
});
|
|
164
172
|
|
|
165
|
-
trackManager.setTextTrackById("
|
|
173
|
+
trackManager.setTextTrackById("gen_text_en_1");
|
|
166
174
|
|
|
167
175
|
// Fake browser behavior
|
|
168
|
-
fakeMediaElement.textTracks[0].mode = "hidden";
|
|
169
176
|
(
|
|
170
177
|
fakeMediaElement.textTracks as {
|
|
171
178
|
onchange: ((arg: Event) => void) | undefined;
|
|
@@ -627,6 +627,7 @@ export default class MediaElementTracksStore extends EventEmitter<IMediaElementT
|
|
|
627
627
|
const newAudioTracks = createAudioTracks(this._nativeAudioTracks);
|
|
628
628
|
if (areTrackArraysDifferent(this._audioTracks, newAudioTracks)) {
|
|
629
629
|
this._audioTracks = newAudioTracks;
|
|
630
|
+
this._setPreviouslyLockedAudioTrack();
|
|
630
631
|
this.trigger("availableAudioTracksChange", this.getAvailableAudioTracks());
|
|
631
632
|
const chosenAudioTrack = this._getCurrentAudioTrack();
|
|
632
633
|
if (chosenAudioTrack?.nativeTrack !== this._lastEmittedNativeAudioTrack) {
|
|
@@ -1153,7 +1153,7 @@ export default class TracksStore extends EventEmitter<ITracksStoreEvents> {
|
|
|
1153
1153
|
* Period.
|
|
1154
1154
|
*
|
|
1155
1155
|
* Returns `null` is the the current audio track is disabled or not
|
|
1156
|
-
* set yet.
|
|
1156
|
+
* set yet.
|
|
1157
1157
|
*
|
|
1158
1158
|
* Returns `undefined` if the given Period's id is not currently found in the
|
|
1159
1159
|
* `TracksStore`. The cause being most probably that the corresponding
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains "dummy" versions of the exported classes imported from
|
|
3
|
+
* this location:
|
|
4
|
+
*
|
|
5
|
+
* - They respect the same API (e.g. a `DummyRepresentation` is a
|
|
6
|
+
* `Representation`-compliant type).
|
|
7
|
+
*
|
|
8
|
+
* - They're doing no side-effect.
|
|
9
|
+
*
|
|
10
|
+
* - All of their methods throw an error immediately on call (you have to
|
|
11
|
+
* implement the ones you want, generally through testing tools).
|
|
12
|
+
*/
|
|
13
|
+
import type { IRepresentationIndex, ISegment } from "../..";
|
|
14
|
+
import { makeMockedClass } from "../../../utils/test-utils";
|
|
15
|
+
import { ManifestMetadataFormat } from "../../types";
|
|
16
|
+
import type Adaptation from "../adaptation";
|
|
17
|
+
import type Manifest from "../manifest";
|
|
18
|
+
import type Period from "../period";
|
|
19
|
+
import type Representation from "../representation";
|
|
20
|
+
|
|
21
|
+
export const DummyManifest = makeMockedClass<Manifest>(
|
|
22
|
+
{
|
|
23
|
+
addEventListener: notImplemented("addEventListener"),
|
|
24
|
+
removeEventListener: notImplemented("removeEventListener"),
|
|
25
|
+
updateCodecSupport: notImplemented("updateCodecSupport"),
|
|
26
|
+
getPeriod: notImplemented("getPeriod"),
|
|
27
|
+
getPeriodForTime: notImplemented("getPeriodForTime"),
|
|
28
|
+
getNextPeriod: notImplemented("getNextPeriod"),
|
|
29
|
+
getPeriodAfter: notImplemented("getPeriodAfter"),
|
|
30
|
+
getUrls: notImplemented("getUrls"),
|
|
31
|
+
replace: notImplemented("replace"),
|
|
32
|
+
update: notImplemented("update"),
|
|
33
|
+
getMinimumSafePosition: notImplemented("getMinimumSafePosition"),
|
|
34
|
+
getLivePosition: notImplemented("getLivePosition"),
|
|
35
|
+
getMaximumSafePosition: notImplemented("getMaximumSafePosition"),
|
|
36
|
+
updateCodecSupportList: notImplemented("updateCodecSupportList"),
|
|
37
|
+
updateRepresentationsDeciperability: notImplemented(
|
|
38
|
+
"updateRepresentationsDecipherability",
|
|
39
|
+
),
|
|
40
|
+
addRepresentationsToAvoid: notImplemented("addRepresentationsToAvoid"),
|
|
41
|
+
getAdaptations: notImplemented("getAdaptations"),
|
|
42
|
+
getAdaptation: notImplemented("getAdaptation"),
|
|
43
|
+
getAdaptationsForType: notImplemented("getAdaptationsForType"),
|
|
44
|
+
getMetadataSnapshot: notImplemented("getMetadataSnapshot"),
|
|
45
|
+
getCodecsWithUnknownSupport: notImplemented("getCodecsWithUnknownSupport"),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "n/a",
|
|
49
|
+
manifestFormat: ManifestMetadataFormat.Class,
|
|
50
|
+
transport: "test",
|
|
51
|
+
periods: [],
|
|
52
|
+
expired: null,
|
|
53
|
+
adaptations: {},
|
|
54
|
+
isDynamic: false,
|
|
55
|
+
isLive: false,
|
|
56
|
+
isLastPeriodKnown: true,
|
|
57
|
+
uris: [],
|
|
58
|
+
updateUrl: undefined,
|
|
59
|
+
suggestedPresentationDelay: undefined,
|
|
60
|
+
lifetime: undefined,
|
|
61
|
+
availabilityStartTime: undefined,
|
|
62
|
+
publishTime: undefined,
|
|
63
|
+
clockOffset: undefined,
|
|
64
|
+
timeBounds: {
|
|
65
|
+
minimumSafePosition: undefined,
|
|
66
|
+
timeshiftDepth: null,
|
|
67
|
+
maximumTimeData: {
|
|
68
|
+
livePosition: undefined,
|
|
69
|
+
isLinear: false,
|
|
70
|
+
maximumSafePosition: Number.MAX_SAFE_INTEGER,
|
|
71
|
+
time: 0,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
export const DummyPeriod = makeMockedClass<Period>(
|
|
78
|
+
{
|
|
79
|
+
getAdaptations: notImplemented("getAdaptations"),
|
|
80
|
+
getAdaptation: notImplemented("getAdaptation"),
|
|
81
|
+
getAdaptationsForType: notImplemented("getAdaptationsForType"),
|
|
82
|
+
getSupportedAdaptations: notImplemented("getSupportedAdaptations"),
|
|
83
|
+
getMetadataSnapshot: notImplemented("getMetadataSnapshot"),
|
|
84
|
+
containsTime: notImplemented("containsTime"),
|
|
85
|
+
refreshCodecSupport: notImplemented("refreshCodecSupport"),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "n/a",
|
|
89
|
+
start: 0,
|
|
90
|
+
adaptations: {},
|
|
91
|
+
streamEvents: [],
|
|
92
|
+
thumbnailTracks: [],
|
|
93
|
+
duration: undefined,
|
|
94
|
+
end: undefined,
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const DummyAdaptation = makeMockedClass<Adaptation>(
|
|
99
|
+
{
|
|
100
|
+
getRepresentation: notImplemented("getRepresentation"),
|
|
101
|
+
getMetadataSnapshot: notImplemented("getMetadataSnapshot"),
|
|
102
|
+
refreshCodecSupport: notImplemented("refreshCodecSupport"),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "n/a",
|
|
106
|
+
type: "video",
|
|
107
|
+
representations: [],
|
|
108
|
+
supportStatus: {
|
|
109
|
+
hasCodecWithUndefinedSupport: false,
|
|
110
|
+
hasSupportedCodec: true,
|
|
111
|
+
isDecipherable: undefined,
|
|
112
|
+
},
|
|
113
|
+
isDub: undefined,
|
|
114
|
+
label: undefined,
|
|
115
|
+
language: undefined,
|
|
116
|
+
manuallyAdded: undefined,
|
|
117
|
+
isClosedCaption: undefined,
|
|
118
|
+
trickModeTracks: undefined,
|
|
119
|
+
isTrickModeTrack: undefined,
|
|
120
|
+
isForcedSubtitles: undefined,
|
|
121
|
+
isSignInterpreted: undefined,
|
|
122
|
+
isAudioDescription: undefined,
|
|
123
|
+
normalizedLanguage: undefined,
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
export const DummyRepresentationIndex = makeMockedClass<IRepresentationIndex>(
|
|
128
|
+
{
|
|
129
|
+
getLastAvailablePosition: notImplemented("getLastAvailablePosition"),
|
|
130
|
+
addPredictedSegments: notImplemented("addPredictedSegments"),
|
|
131
|
+
getFirstAvailablePosition: notImplemented("getFirstAvailablePosition"),
|
|
132
|
+
getTargetSegmentDuration: notImplemented("getTargetSegmentDuration"),
|
|
133
|
+
getSegments: notImplemented("getSegments"),
|
|
134
|
+
getEnd: notImplemented("getEnd"),
|
|
135
|
+
getInitSegment: notImplemented("getInitSegment"),
|
|
136
|
+
shouldRefresh: notImplemented("shouldRefresh"),
|
|
137
|
+
isInitialized: notImplemented("isInitialized"),
|
|
138
|
+
isSegmentStillAvailable: notImplemented("isSegmentStillAvailable"),
|
|
139
|
+
initialize: notImplemented("initialize"),
|
|
140
|
+
isStillAwaitingFutureSegments: notImplemented("isStillAwaitingFutureSegments"),
|
|
141
|
+
canBeOutOfSyncError: notImplemented("canBeOutOfSyncError"),
|
|
142
|
+
checkDiscontinuity: notImplemented("checkDiscontinuity"),
|
|
143
|
+
awaitSegmentBetween: notImplemented("awaitSegmentBetween"),
|
|
144
|
+
_replace: notImplemented("_replace"),
|
|
145
|
+
_update: notImplemented("_update"),
|
|
146
|
+
},
|
|
147
|
+
{},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
export const DummyRepresentation = makeMockedClass<Representation>(
|
|
151
|
+
{
|
|
152
|
+
isPlayable: notImplemented("isPlayable"),
|
|
153
|
+
addProtectionData: notImplemented("addProtectionData"),
|
|
154
|
+
getMimeTypeString: notImplemented("getMimeTypeString"),
|
|
155
|
+
getEncryptionData: notImplemented("getEncryptionData"),
|
|
156
|
+
getAllEncryptionData: notImplemented("getAllEncryptionData"),
|
|
157
|
+
getMetadataSnapshot: notImplemented("getMetadataSnapshot"),
|
|
158
|
+
refreshCodecSupport: notImplemented("refreshCodecSupport"),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "n/a",
|
|
162
|
+
isSupported: undefined,
|
|
163
|
+
index: new DummyRepresentationIndex(),
|
|
164
|
+
chosenCodec: undefined,
|
|
165
|
+
baseCodecs: [],
|
|
166
|
+
bitrate: 1000,
|
|
167
|
+
uniqueId: "n/a",
|
|
168
|
+
decipherable: undefined,
|
|
169
|
+
isSpatialAudio: undefined,
|
|
170
|
+
shouldBeAvoided: false,
|
|
171
|
+
isCodecSupportedInWebWorker: undefined,
|
|
172
|
+
trackType: "video",
|
|
173
|
+
cdnMetadata: null,
|
|
174
|
+
width: undefined,
|
|
175
|
+
height: undefined,
|
|
176
|
+
mimeType: undefined,
|
|
177
|
+
frameRate: undefined,
|
|
178
|
+
hdrInfo: undefined,
|
|
179
|
+
contentProtections: undefined,
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
export function createSegment(props: Partial<ISegment> = {}): ISegment {
|
|
184
|
+
return {
|
|
185
|
+
id: "n/a",
|
|
186
|
+
isInit: false,
|
|
187
|
+
time: 0,
|
|
188
|
+
end: 2,
|
|
189
|
+
duration: 2,
|
|
190
|
+
timescale: 1,
|
|
191
|
+
complete: true,
|
|
192
|
+
url: null,
|
|
193
|
+
privateInfos: {},
|
|
194
|
+
...props,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function notImplemented(name: string): () => never {
|
|
199
|
+
return () => {
|
|
200
|
+
throw new Error(`${name} not implemented`);
|
|
201
|
+
};
|
|
202
|
+
}
|