rx-player 4.4.1-dev.2025101500 → 4.4.1
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 +3 -1
- package/README.md +111 -50
- 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/core/{entry → main/common}/FreezeResolver.d.ts +3 -3
- package/dist/commonjs/core/main/common/FreezeResolver.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/common}/FreezeResolver.js +3 -3
- package/dist/commonjs/core/{entry → main/common}/content_time_boundaries_observer.d.ts +5 -5
- package/dist/commonjs/core/main/common/content_time_boundaries_observer.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/common}/content_time_boundaries_observer.js +6 -6
- package/dist/{es2017/core/entry → commonjs/core/main/common}/create_content_time_boundaries_observer.d.ts +6 -6
- package/dist/commonjs/core/main/common/create_content_time_boundaries_observer.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/common}/create_content_time_boundaries_observer.js +1 -1
- package/dist/{es2017/core/entry → commonjs/core/main/common}/get_buffered_data_per_media_buffer.d.ts +4 -4
- package/dist/commonjs/core/main/common/get_buffered_data_per_media_buffer.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/common}/get_buffered_data_per_media_buffer.js +1 -1
- package/dist/{es2017/core/entry → commonjs/core/main/common}/get_thumbnail_data.d.ts +3 -3
- package/dist/commonjs/core/main/common/get_thumbnail_data.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/common}/get_thumbnail_data.js +2 -2
- package/dist/{es2017/core/entry → commonjs/core/main/common}/synchronize_sinks_on_observation.d.ts +2 -2
- package/dist/commonjs/core/main/common/synchronize_sinks_on_observation.d.ts.map +1 -0
- package/dist/{es2017/core/entry → commonjs/core/main/worker}/content_preparer.d.ts +15 -22
- package/dist/commonjs/core/main/worker/content_preparer.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/worker}/content_preparer.js +64 -62
- package/dist/commonjs/core/main/worker/globals.d.ts +14 -0
- package/dist/commonjs/core/main/worker/globals.d.ts.map +1 -0
- package/dist/commonjs/core/main/worker/globals.js +26 -0
- package/dist/commonjs/core/main/worker/index.d.ts +3 -0
- package/dist/commonjs/core/main/worker/index.d.ts.map +1 -0
- package/dist/commonjs/core/main/worker/index.js +4 -0
- package/dist/commonjs/core/main/worker/send_message.d.ts +4 -0
- package/dist/commonjs/core/main/worker/send_message.d.ts.map +1 -0
- package/dist/commonjs/core/main/worker/send_message.js +23 -0
- package/dist/{es2017/core/entry → commonjs/core/main/worker}/track_choice_setter.d.ts +4 -4
- package/dist/commonjs/core/main/worker/track_choice_setter.d.ts.map +1 -0
- package/dist/commonjs/core/{entry → main/worker}/track_choice_setter.js +4 -4
- package/dist/commonjs/core/main/worker/worker_main.d.ts +2 -0
- package/dist/commonjs/core/main/worker/worker_main.d.ts.map +1 -0
- package/dist/commonjs/core/{entry/core_entry.js → main/worker/worker_main.js} +153 -192
- package/dist/commonjs/core/{entry/core_text_displayer_interface.d.ts → main/worker/worker_text_displayer_interface.d.ts} +11 -11
- package/dist/commonjs/core/main/worker/worker_text_displayer_interface.d.ts.map +1 -0
- package/dist/commonjs/core/{entry/core_text_displayer_interface.js → main/worker/worker_text_displayer_interface.js} +22 -22
- package/dist/commonjs/core/types.d.ts +1 -519
- package/dist/commonjs/core/types.d.ts.map +1 -1
- package/dist/commonjs/core/types.js +0 -1
- package/dist/commonjs/experimental/features/local.d.ts.map +1 -1
- package/dist/commonjs/experimental/features/local.js +1 -7
- package/dist/commonjs/experimental/features/metaplaylist.d.ts.map +1 -1
- package/dist/commonjs/experimental/features/metaplaylist.js +1 -7
- package/dist/commonjs/experimental/features/multi_thread.d.ts.map +1 -1
- package/dist/commonjs/experimental/features/multi_thread.js +2 -6
- package/dist/commonjs/features/features_object.js +1 -1
- package/dist/commonjs/features/list/dash.d.ts.map +1 -1
- package/dist/commonjs/features/list/dash.js +1 -7
- package/dist/commonjs/features/list/dash_wasm.d.ts.map +1 -1
- package/dist/commonjs/features/list/dash_wasm.js +1 -7
- package/dist/commonjs/features/list/media_source_main.d.ts.map +1 -1
- package/dist/commonjs/features/list/media_source_main.js +1 -7
- package/dist/commonjs/features/list/smooth.d.ts.map +1 -1
- package/dist/commonjs/features/list/smooth.js +1 -7
- package/dist/commonjs/features/types.d.ts +4 -20
- package/dist/commonjs/features/types.d.ts.map +1 -1
- package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/commonjs/main_thread/api/public_api.js +44 -40
- package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts +108 -166
- 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 +918 -1491
- package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +308 -0
- package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -0
- package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +1713 -0
- package/dist/commonjs/main_thread/init/send_message.d.ts +3 -0
- package/dist/commonjs/main_thread/init/send_message.d.ts.map +1 -0
- package/dist/commonjs/main_thread/init/send_message.js +13 -0
- package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.js +1 -2
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts +1 -1
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/commonjs/main_thread/types.d.ts +0 -537
- package/dist/commonjs/main_thread/types.d.ts.map +1 -1
- package/dist/commonjs/manifest/utils.d.ts.map +1 -1
- package/dist/commonjs/manifest/utils.js +4 -18
- package/dist/commonjs/mse/worker_media_source_interface.d.ts +2 -2
- package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/mse/worker_media_source_interface.js +12 -12
- package/dist/commonjs/multithread_types.d.ts +915 -0
- package/dist/commonjs/multithread_types.d.ts.map +1 -0
- package/dist/commonjs/multithread_types.js +7 -0
- package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/smooth/create_parser.js +27 -31
- package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.d.ts +2 -3
- package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.js +7 -16
- package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.d.ts +2 -3
- package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.js +6 -37
- package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.d.ts +2 -3
- package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.js +5 -28
- package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts +28 -8
- package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts.map +1 -1
- package/dist/commonjs/playback_observer/media_element_playback_observer.js +146 -64
- package/dist/{es2017/playback_observer/core_playback_observer.d.ts → commonjs/playback_observer/worker_playback_observer.d.ts} +8 -8
- package/dist/commonjs/playback_observer/worker_playback_observer.d.ts.map +1 -0
- package/dist/commonjs/playback_observer/{core_playback_observer.js → worker_playback_observer.js} +13 -13
- package/dist/commonjs/transports/smooth/pipelines.d.ts.map +1 -1
- package/dist/commonjs/transports/smooth/pipelines.js +3 -25
- package/dist/commonjs/worker_entry_point.js +2 -62
- 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/core/{entry → main/common}/FreezeResolver.d.ts +3 -3
- package/dist/es2017/core/main/common/FreezeResolver.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/common}/FreezeResolver.js +3 -3
- package/dist/es2017/core/{entry → main/common}/content_time_boundaries_observer.d.ts +5 -5
- package/dist/es2017/core/main/common/content_time_boundaries_observer.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/common}/content_time_boundaries_observer.js +6 -6
- package/dist/{commonjs/core/entry → es2017/core/main/common}/create_content_time_boundaries_observer.d.ts +6 -6
- package/dist/es2017/core/main/common/create_content_time_boundaries_observer.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/common}/create_content_time_boundaries_observer.js +1 -1
- package/dist/{commonjs/core/entry → es2017/core/main/common}/get_buffered_data_per_media_buffer.d.ts +4 -4
- package/dist/es2017/core/main/common/get_buffered_data_per_media_buffer.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/common}/get_buffered_data_per_media_buffer.js +1 -1
- package/dist/{commonjs/core/entry → es2017/core/main/common}/get_thumbnail_data.d.ts +3 -3
- package/dist/es2017/core/main/common/get_thumbnail_data.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/common}/get_thumbnail_data.js +2 -2
- package/dist/{commonjs/core/entry → es2017/core/main/common}/synchronize_sinks_on_observation.d.ts +2 -2
- package/dist/es2017/core/main/common/synchronize_sinks_on_observation.d.ts.map +1 -0
- package/dist/{commonjs/core/entry → es2017/core/main/worker}/content_preparer.d.ts +15 -22
- package/dist/es2017/core/main/worker/content_preparer.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/worker}/content_preparer.js +55 -53
- package/dist/es2017/core/main/worker/globals.d.ts +14 -0
- package/dist/es2017/core/main/worker/globals.d.ts.map +1 -0
- package/dist/es2017/core/main/worker/globals.js +18 -0
- package/dist/es2017/core/main/worker/index.d.ts +3 -0
- package/dist/es2017/core/main/worker/index.d.ts.map +1 -0
- package/dist/es2017/core/main/worker/index.js +2 -0
- package/dist/es2017/core/main/worker/send_message.d.ts +4 -0
- package/dist/es2017/core/main/worker/send_message.d.ts.map +1 -0
- package/dist/es2017/core/main/worker/send_message.js +19 -0
- package/dist/{commonjs/core/entry → es2017/core/main/worker}/track_choice_setter.d.ts +4 -4
- package/dist/es2017/core/main/worker/track_choice_setter.d.ts.map +1 -0
- package/dist/es2017/core/{entry → main/worker}/track_choice_setter.js +4 -4
- package/dist/es2017/core/main/worker/worker_main.d.ts +2 -0
- package/dist/es2017/core/main/worker/worker_main.d.ts.map +1 -0
- package/dist/es2017/core/{entry/core_entry.js → main/worker/worker_main.js} +114 -153
- package/dist/es2017/core/{entry/core_text_displayer_interface.d.ts → main/worker/worker_text_displayer_interface.d.ts} +11 -11
- package/dist/es2017/core/main/worker/worker_text_displayer_interface.d.ts.map +1 -0
- package/dist/es2017/core/{entry/core_text_displayer_interface.js → main/worker/worker_text_displayer_interface.js} +10 -10
- package/dist/es2017/core/types.d.ts +1 -519
- package/dist/es2017/core/types.d.ts.map +1 -1
- package/dist/es2017/core/types.js +0 -1
- package/dist/es2017/experimental/features/local.d.ts.map +1 -1
- package/dist/es2017/experimental/features/local.js +1 -7
- package/dist/es2017/experimental/features/metaplaylist.d.ts.map +1 -1
- package/dist/es2017/experimental/features/metaplaylist.js +1 -7
- package/dist/es2017/experimental/features/multi_thread.d.ts.map +1 -1
- package/dist/es2017/experimental/features/multi_thread.js +2 -6
- package/dist/es2017/features/features_object.js +1 -1
- package/dist/es2017/features/list/dash.d.ts.map +1 -1
- package/dist/es2017/features/list/dash.js +1 -7
- package/dist/es2017/features/list/dash_wasm.d.ts.map +1 -1
- package/dist/es2017/features/list/dash_wasm.js +1 -7
- package/dist/es2017/features/list/media_source_main.d.ts.map +1 -1
- package/dist/es2017/features/list/media_source_main.js +1 -7
- package/dist/es2017/features/list/smooth.d.ts.map +1 -1
- package/dist/es2017/features/list/smooth.js +1 -7
- package/dist/es2017/features/types.d.ts +4 -20
- package/dist/es2017/features/types.d.ts.map +1 -1
- package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/es2017/main_thread/api/public_api.js +45 -41
- package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts +108 -166
- 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 +760 -1405
- package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +308 -0
- package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -0
- package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +1559 -0
- package/dist/es2017/main_thread/init/send_message.d.ts +3 -0
- package/dist/es2017/main_thread/init/send_message.d.ts.map +1 -0
- package/dist/es2017/main_thread/init/send_message.js +10 -0
- package/dist/es2017/main_thread/init/utils/create_core_playback_observer.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/create_core_playback_observer.js +1 -2
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts +1 -1
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/es2017/main_thread/types.d.ts +0 -537
- package/dist/es2017/main_thread/types.d.ts.map +1 -1
- package/dist/es2017/manifest/utils.d.ts.map +1 -1
- package/dist/es2017/manifest/utils.js +4 -16
- package/dist/es2017/mse/worker_media_source_interface.d.ts +2 -2
- package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/mse/worker_media_source_interface.js +12 -12
- package/dist/es2017/multithread_types.d.ts +915 -0
- package/dist/es2017/multithread_types.d.ts.map +1 -0
- package/dist/es2017/multithread_types.js +6 -0
- package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts +1 -1
- package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/smooth/create_parser.js +27 -31
- package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.d.ts +2 -3
- package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.js +7 -16
- package/dist/es2017/parsers/manifest/smooth/parse_protection_node.d.ts +2 -3
- package/dist/es2017/parsers/manifest/smooth/parse_protection_node.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/smooth/parse_protection_node.js +6 -15
- package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
- package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.d.ts +2 -3
- package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.js +5 -6
- package/dist/es2017/playback_observer/media_element_playback_observer.d.ts +28 -8
- package/dist/es2017/playback_observer/media_element_playback_observer.d.ts.map +1 -1
- package/dist/es2017/playback_observer/media_element_playback_observer.js +144 -64
- package/dist/{commonjs/playback_observer/core_playback_observer.d.ts → es2017/playback_observer/worker_playback_observer.d.ts} +8 -8
- package/dist/es2017/playback_observer/worker_playback_observer.d.ts.map +1 -0
- package/dist/es2017/playback_observer/{core_playback_observer.js → worker_playback_observer.js} +2 -2
- package/dist/es2017/transports/smooth/pipelines.d.ts.map +1 -1
- package/dist/es2017/transports/smooth/pipelines.js +3 -25
- package/dist/es2017/worker_entry_point.js +2 -62
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +19165 -21886
- package/dist/rx-player.min.js +20 -20
- package/dist/worker.js +8 -8
- package/eslint.config.mjs +647 -348
- package/package.json +6 -6
- package/src/README.md +198 -88
- package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/core/{entry → main}/README.md +1 -1
- package/src/core/{entry → main/common}/FreezeResolver.ts +7 -7
- package/src/core/{entry → main/common}/content_time_boundaries_observer.ts +10 -10
- package/src/core/{entry → main/common}/create_content_time_boundaries_observer.ts +7 -7
- package/src/core/{entry → main/common}/get_buffered_data_per_media_buffer.ts +6 -6
- package/src/core/{entry → main/common}/get_thumbnail_data.ts +5 -5
- package/src/core/{entry → main/common}/synchronize_sinks_on_observation.ts +2 -2
- package/src/core/{entry → main/worker}/content_preparer.ts +76 -77
- package/src/core/main/worker/globals.ts +38 -0
- package/src/core/main/worker/index.ts +2 -0
- package/src/core/main/worker/send_message.ts +28 -0
- package/src/core/{entry → main/worker}/track_choice_setter.ts +7 -7
- package/src/core/{entry/core_entry.ts → main/worker/worker_main.ts} +149 -223
- package/src/core/{entry/core_text_displayer_interface.ts → main/worker/worker_text_displayer_interface.ts} +26 -26
- package/src/core/types.ts +3 -631
- package/src/experimental/features/__tests__/local.test.ts +2 -11
- package/src/experimental/features/__tests__/metaplaylist.test.ts +2 -11
- package/src/experimental/features/__tests__/multi_thread.test.ts +3 -8
- package/src/experimental/features/local.ts +1 -7
- package/src/experimental/features/metaplaylist.ts +1 -7
- package/src/experimental/features/multi_thread.ts +2 -6
- package/src/features/features_object.ts +1 -1
- package/src/features/list/__tests__/dash.test.ts +3 -12
- package/src/features/list/__tests__/smooth.test.ts +2 -11
- package/src/features/list/dash.ts +1 -7
- package/src/features/list/dash_wasm.ts +1 -7
- package/src/features/list/media_source_main.ts +1 -7
- package/src/features/list/smooth.ts +1 -7
- package/src/features/types.ts +4 -23
- package/src/main_thread/README.md +0 -8
- package/src/main_thread/api/public_api.ts +51 -47
- package/src/main_thread/init/media_source_content_initializer.ts +1164 -2046
- package/src/main_thread/init/multi_thread_content_initializer.ts +2330 -0
- package/src/main_thread/init/send_message.ts +15 -0
- package/src/main_thread/init/utils/create_core_playback_observer.ts +1 -2
- package/src/main_thread/init/utils/update_manifest_codec_support.ts +1 -1
- package/src/main_thread/types.ts +0 -610
- package/src/manifest/utils.ts +4 -20
- package/src/mse/worker_media_source_interface.ts +35 -35
- package/src/multithread_types.ts +1095 -0
- package/src/parsers/manifest/smooth/create_parser.ts +34 -40
- package/src/parsers/manifest/smooth/parse_C_nodes.ts +8 -19
- package/src/parsers/manifest/smooth/parse_protection_node.ts +9 -17
- package/src/parsers/manifest/smooth/utils/parseBoolean.ts +1 -1
- package/src/parsers/manifest/smooth/utils/reduceChildren.ts +7 -10
- package/src/playback_observer/media_element_playback_observer.ts +177 -73
- package/src/playback_observer/{core_playback_observer.ts → worker_playback_observer.ts} +13 -13
- package/src/transports/smooth/pipelines.ts +5 -25
- package/src/worker_entry_point.ts +2 -71
- package/dist/commonjs/core/entry/FreezeResolver.d.ts.map +0 -1
- package/dist/commonjs/core/entry/content_preparer.d.ts.map +0 -1
- package/dist/commonjs/core/entry/content_time_boundaries_observer.d.ts.map +0 -1
- package/dist/commonjs/core/entry/core_entry.d.ts +0 -36
- package/dist/commonjs/core/entry/core_entry.d.ts.map +0 -1
- package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +0 -1
- package/dist/commonjs/core/entry/create_content_time_boundaries_observer.d.ts.map +0 -1
- package/dist/commonjs/core/entry/get_buffered_data_per_media_buffer.d.ts.map +0 -1
- package/dist/commonjs/core/entry/get_thumbnail_data.d.ts.map +0 -1
- package/dist/commonjs/core/entry/index.d.ts +0 -5
- package/dist/commonjs/core/entry/index.d.ts.map +0 -1
- package/dist/commonjs/core/entry/index.js +0 -4
- package/dist/commonjs/core/entry/synchronize_sinks_on_observation.d.ts.map +0 -1
- package/dist/commonjs/core/entry/track_choice_setter.d.ts.map +0 -1
- package/dist/commonjs/core/entry/utils.d.ts +0 -3
- package/dist/commonjs/core/entry/utils.d.ts.map +0 -1
- package/dist/commonjs/core/entry/utils.js +0 -11
- package/dist/commonjs/main_thread/core_interface/base.d.ts +0 -13
- package/dist/commonjs/main_thread/core_interface/base.d.ts.map +0 -1
- package/dist/commonjs/main_thread/core_interface/base.js +0 -32
- package/dist/commonjs/main_thread/core_interface/monothread.d.ts +0 -13
- package/dist/commonjs/main_thread/core_interface/monothread.d.ts.map +0 -1
- package/dist/commonjs/main_thread/core_interface/monothread.js +0 -56
- package/dist/commonjs/main_thread/core_interface/multithread.d.ts +0 -25
- package/dist/commonjs/main_thread/core_interface/multithread.d.ts.map +0 -1
- package/dist/commonjs/main_thread/core_interface/multithread.js +0 -67
- package/dist/commonjs/main_thread/core_interface/types.d.ts +0 -6
- package/dist/commonjs/main_thread/core_interface/types.d.ts.map +0 -1
- package/dist/commonjs/main_thread/core_interface/types.js +0 -2
- package/dist/commonjs/playback_observer/core_playback_observer.d.ts.map +0 -1
- package/dist/es2017/core/entry/FreezeResolver.d.ts.map +0 -1
- package/dist/es2017/core/entry/content_preparer.d.ts.map +0 -1
- package/dist/es2017/core/entry/content_time_boundaries_observer.d.ts.map +0 -1
- package/dist/es2017/core/entry/core_entry.d.ts +0 -36
- package/dist/es2017/core/entry/core_entry.d.ts.map +0 -1
- package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +0 -1
- package/dist/es2017/core/entry/create_content_time_boundaries_observer.d.ts.map +0 -1
- package/dist/es2017/core/entry/get_buffered_data_per_media_buffer.d.ts.map +0 -1
- package/dist/es2017/core/entry/get_thumbnail_data.d.ts.map +0 -1
- package/dist/es2017/core/entry/index.d.ts +0 -5
- package/dist/es2017/core/entry/index.d.ts.map +0 -1
- package/dist/es2017/core/entry/index.js +0 -2
- package/dist/es2017/core/entry/synchronize_sinks_on_observation.d.ts.map +0 -1
- package/dist/es2017/core/entry/track_choice_setter.d.ts.map +0 -1
- package/dist/es2017/core/entry/utils.d.ts +0 -3
- package/dist/es2017/core/entry/utils.d.ts.map +0 -1
- package/dist/es2017/core/entry/utils.js +0 -8
- package/dist/es2017/main_thread/core_interface/base.d.ts +0 -13
- package/dist/es2017/main_thread/core_interface/base.d.ts.map +0 -1
- package/dist/es2017/main_thread/core_interface/base.js +0 -28
- package/dist/es2017/main_thread/core_interface/monothread.d.ts +0 -13
- package/dist/es2017/main_thread/core_interface/monothread.d.ts.map +0 -1
- package/dist/es2017/main_thread/core_interface/monothread.js +0 -32
- package/dist/es2017/main_thread/core_interface/multithread.d.ts +0 -25
- package/dist/es2017/main_thread/core_interface/multithread.d.ts.map +0 -1
- package/dist/es2017/main_thread/core_interface/multithread.js +0 -45
- package/dist/es2017/main_thread/core_interface/types.d.ts +0 -6
- package/dist/es2017/main_thread/core_interface/types.d.ts.map +0 -1
- package/dist/es2017/main_thread/core_interface/types.js +0 -1
- package/dist/es2017/playback_observer/core_playback_observer.d.ts.map +0 -1
- package/src/core/entry/index.ts +0 -4
- package/src/core/entry/utils.ts +0 -11
- package/src/main_thread/core_interface/README.md +0 -22
- package/src/main_thread/core_interface/base.ts +0 -36
- package/src/main_thread/core_interface/monothread.ts +0 -46
- package/src/main_thread/core_interface/multithread.ts +0 -49
- package/src/main_thread/core_interface/types.ts +0 -5
- /package/dist/commonjs/core/{entry → main/common}/synchronize_sinks_on_observation.js +0 -0
- /package/dist/es2017/core/{entry → main/common}/synchronize_sinks_on_observation.js +0 -0
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2015 CANAL+ Group
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
2
17
|
var __extends = (this && this.__extends) || (function () {
|
|
3
18
|
var extendStatics = function (d, b) {
|
|
4
19
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -61,31 +76,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
76
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
77
|
}
|
|
63
78
|
};
|
|
64
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
-
if (!m) return o;
|
|
67
|
-
var i = m.call(o), r, ar = [], e;
|
|
68
|
-
try {
|
|
69
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
-
}
|
|
71
|
-
catch (error) { e = { error: error }; }
|
|
72
|
-
finally {
|
|
73
|
-
try {
|
|
74
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
-
}
|
|
76
|
-
finally { if (e) throw e.error; }
|
|
77
|
-
}
|
|
78
|
-
return ar;
|
|
79
|
-
};
|
|
80
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
81
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
-
if (ar || !(i in from)) {
|
|
83
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
84
|
-
ar[i] = from[i];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
88
|
-
};
|
|
89
79
|
var __values = (this && this.__values) || function(o) {
|
|
90
80
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
91
81
|
if (m) return m.call(o);
|
|
@@ -98,21 +88,29 @@ var __values = (this && this.__values) || function(o) {
|
|
|
98
88
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
99
89
|
};
|
|
100
90
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
101
|
-
var
|
|
91
|
+
var is_codec_supported_1 = require("../../compat/is_codec_supported");
|
|
102
92
|
var may_media_element_fail_on_undecipherable_data_1 = require("../../compat/may_media_element_fail_on_undecipherable_data");
|
|
103
93
|
var should_reload_media_source_on_decipherability_update_1 = require("../../compat/should_reload_media_source_on_decipherability_update");
|
|
94
|
+
var config_1 = require("../../config");
|
|
95
|
+
var adaptive_1 = require("../../core/adaptive");
|
|
96
|
+
var cmcd_1 = require("../../core/cmcd");
|
|
97
|
+
var fetchers_1 = require("../../core/fetchers");
|
|
98
|
+
var create_content_time_boundaries_observer_1 = require("../../core/main/common/create_content_time_boundaries_observer");
|
|
99
|
+
var FreezeResolver_1 = require("../../core/main/common/FreezeResolver");
|
|
100
|
+
var get_thumbnail_data_1 = require("../../core/main/common/get_thumbnail_data");
|
|
101
|
+
var synchronize_sinks_on_observation_1 = require("../../core/main/common/synchronize_sinks_on_observation");
|
|
102
|
+
var segment_sinks_1 = require("../../core/segment_sinks");
|
|
103
|
+
var stream_1 = require("../../core/stream");
|
|
104
104
|
var errors_1 = require("../../errors");
|
|
105
105
|
var features_1 = require("../../features");
|
|
106
106
|
var log_1 = require("../../log");
|
|
107
|
-
var
|
|
108
|
-
var main_media_source_interface_1 = require("../../mse/main_media_source_interface");
|
|
109
|
-
var array_find_1 = require("../../utils/array_find");
|
|
107
|
+
var are_arrays_of_numbers_equal_1 = require("../../utils/are_arrays_of_numbers_equal");
|
|
110
108
|
var assert_1 = require("../../utils/assert");
|
|
111
|
-
var
|
|
109
|
+
var create_cancellable_promise_1 = require("../../utils/create_cancellable_promise");
|
|
112
110
|
var is_null_or_undefined_1 = require("../../utils/is_null_or_undefined");
|
|
111
|
+
var noop_1 = require("../../utils/noop");
|
|
113
112
|
var object_assign_1 = require("../../utils/object_assign");
|
|
114
|
-
var
|
|
115
|
-
var request_1 = require("../../utils/request");
|
|
113
|
+
var sync_or_async_1 = require("../../utils/sync_or_async");
|
|
116
114
|
var task_canceller_1 = require("../../utils/task_canceller");
|
|
117
115
|
var decrypt_1 = require("../decrypt");
|
|
118
116
|
var types_1 = require("./types");
|
|
@@ -121,12 +119,20 @@ var create_media_source_1 = require("./utils/create_media_source");
|
|
|
121
119
|
var get_initial_time_1 = require("./utils/get_initial_time");
|
|
122
120
|
var get_loaded_reference_1 = require("./utils/get_loaded_reference");
|
|
123
121
|
var initial_seek_and_play_1 = require("./utils/initial_seek_and_play");
|
|
122
|
+
var initialize_content_decryption_1 = require("./utils/initialize_content_decryption");
|
|
123
|
+
var main_thread_text_displayer_interface_1 = require("./utils/main_thread_text_displayer_interface");
|
|
124
124
|
var rebuffering_controller_1 = require("./utils/rebuffering_controller");
|
|
125
|
-
var stream_events_emitter_1 = require("./utils/stream_events_emitter
|
|
125
|
+
var stream_events_emitter_1 = require("./utils/stream_events_emitter");
|
|
126
126
|
var throw_on_media_error_1 = require("./utils/throw_on_media_error");
|
|
127
|
-
var update_manifest_codec_support_1 = require("./utils/update_manifest_codec_support");
|
|
128
|
-
var generateContentId = (0, id_generator_1.default)();
|
|
129
127
|
/**
|
|
128
|
+
* Allows to load a new content thanks to the MediaSource Extensions (a.k.a. MSE)
|
|
129
|
+
* Web APIs.
|
|
130
|
+
*
|
|
131
|
+
* Through this `ContentInitializer`, a Manifest will be fetched (and depending
|
|
132
|
+
* on the situation, refreshed), a `MediaSource` instance will be linked to the
|
|
133
|
+
* wanted `HTMLMediaElement` and chunks of media data, called segments, will be
|
|
134
|
+
* pushed on buffers associated to this `MediaSource` instance.
|
|
135
|
+
*
|
|
130
136
|
* @class MediaSourceContentInitializer
|
|
131
137
|
*/
|
|
132
138
|
var MediaSourceContentInitializer = /** @class */ (function (_super) {
|
|
@@ -138,148 +144,58 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
|
|
|
138
144
|
*/
|
|
139
145
|
function MediaSourceContentInitializer(settings) {
|
|
140
146
|
var _this = _super.call(this) || this;
|
|
141
|
-
_this.
|
|
147
|
+
_this._initSettings = settings;
|
|
142
148
|
_this._initCanceller = new task_canceller_1.default();
|
|
143
|
-
_this.
|
|
144
|
-
_this.
|
|
145
|
-
|
|
146
|
-
_this.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
pendingThumbnailFetching: new Map(),
|
|
150
|
-
};
|
|
151
|
-
_this._queuedCoreMessages = null;
|
|
149
|
+
_this._manifest = null;
|
|
150
|
+
_this._decryptionCapabilities = { status: "uninitialized", value: null };
|
|
151
|
+
var urls = settings.url === undefined ? undefined : [settings.url];
|
|
152
|
+
_this._cmcdDataBuilder =
|
|
153
|
+
settings.cmcd === undefined ? null : new cmcd_1.default(settings.cmcd);
|
|
154
|
+
_this._manifestFetcher = new fetchers_1.ManifestFetcher(urls, settings.transport, __assign(__assign({}, settings.manifestRequestSettings), { lowLatencyMode: settings.lowLatencyMode, cmcdDataBuilder: _this._cmcdDataBuilder }));
|
|
152
155
|
return _this;
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
158
|
* Perform non-destructive preparation steps, to prepare a future content.
|
|
159
|
+
* For now, this mainly mean loading the Manifest document.
|
|
156
160
|
*/
|
|
157
161
|
MediaSourceContentInitializer.prototype.prepare = function () {
|
|
158
162
|
var _this = this;
|
|
159
|
-
|
|
160
|
-
if (this._currentContentInfo !== null || this._initCanceller.isUsed()) {
|
|
163
|
+
if (this._manifest !== null) {
|
|
161
164
|
return;
|
|
162
165
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var initialVideoBitrate = adaptiveOptions.initialBitrates.video;
|
|
167
|
-
var initialAudioBitrate = adaptiveOptions.initialBitrates.audio;
|
|
168
|
-
this._currentContentInfo = {
|
|
169
|
-
contentId: contentId,
|
|
170
|
-
contentDecryptor: null,
|
|
171
|
-
manifest: null,
|
|
172
|
-
mediaSourceInfo: null,
|
|
173
|
-
rebufferingController: null,
|
|
174
|
-
streamEventsEmitter: null,
|
|
175
|
-
initialTime: undefined,
|
|
176
|
-
autoPlay: undefined,
|
|
177
|
-
initialPlayPerformed: null,
|
|
178
|
-
useMseInWorker: useMseInWorker,
|
|
179
|
-
};
|
|
180
|
-
coreInterface.sendMessage({
|
|
181
|
-
type: "prepare" /* MainThreadMessageType.PrepareContent */,
|
|
182
|
-
value: {
|
|
183
|
-
contentId: contentId,
|
|
184
|
-
cmcd: this._settings.cmcd,
|
|
185
|
-
enableRepresentationAvoidance: this._settings.enableRepresentationAvoidance,
|
|
186
|
-
url: this._settings.url,
|
|
187
|
-
hasText: this._hasTextBufferFeature(),
|
|
188
|
-
transport: transport,
|
|
189
|
-
transportOptions: transportOptions,
|
|
190
|
-
initialVideoBitrate: initialVideoBitrate,
|
|
191
|
-
initialAudioBitrate: initialAudioBitrate,
|
|
192
|
-
manifestRetryOptions: __assign(__assign({}, this._settings.manifestRequestSettings), { lowLatencyMode: this._settings.lowLatencyMode }),
|
|
193
|
-
segmentRetryOptions: this._settings.segmentRequestOptions,
|
|
194
|
-
useMseInWorker: useMseInWorker,
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
this._initCanceller.signal.register(function () {
|
|
198
|
-
coreInterface.sendMessage({
|
|
199
|
-
type: "stop" /* MainThreadMessageType.StopContent */,
|
|
200
|
-
contentId: contentId,
|
|
201
|
-
value: null,
|
|
166
|
+
this._manifest = sync_or_async_1.default.createAsync((0, create_cancellable_promise_1.default)(this._initCanceller.signal, function (res, rej) {
|
|
167
|
+
_this._manifestFetcher.addEventListener("warning", function (err) {
|
|
168
|
+
return _this.trigger("warning", err);
|
|
202
169
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
var type = msgData.type;
|
|
214
|
-
switch (type) {
|
|
215
|
-
case "log" /* CoreMessageType.LogMessage */: {
|
|
216
|
-
var formatted = msgData.value.logs.map(function (l) {
|
|
217
|
-
switch (typeof l) {
|
|
218
|
-
case "string":
|
|
219
|
-
case "number":
|
|
220
|
-
case "boolean":
|
|
221
|
-
case "undefined":
|
|
222
|
-
return l;
|
|
223
|
-
case "object":
|
|
224
|
-
if (l === null) {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
return formatSentLogObject(l);
|
|
228
|
-
default:
|
|
229
|
-
(0, assert_1.assertUnreachable)(l);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
switch (msgData.value.logLevel) {
|
|
233
|
-
case "NONE":
|
|
234
|
-
break;
|
|
235
|
-
case "ERROR":
|
|
236
|
-
log_1.default.error.apply(log_1.default, __spreadArray([msgData.value.namespace], __read(formatted), false));
|
|
237
|
-
break;
|
|
238
|
-
case "WARNING":
|
|
239
|
-
log_1.default.warn.apply(log_1.default, __spreadArray([msgData.value.namespace], __read(formatted), false));
|
|
240
|
-
break;
|
|
241
|
-
case "INFO":
|
|
242
|
-
log_1.default.info.apply(log_1.default, __spreadArray([msgData.value.namespace], __read(formatted), false));
|
|
243
|
-
break;
|
|
244
|
-
case "DEBUG":
|
|
245
|
-
log_1.default.debug.apply(log_1.default, __spreadArray([msgData.value.namespace], __read(formatted), false));
|
|
246
|
-
break;
|
|
247
|
-
default:
|
|
248
|
-
(0, assert_1.assertUnreachable)(msgData.value.logLevel);
|
|
249
|
-
}
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
default:
|
|
253
|
-
if (_this._queuedCoreMessages !== null) {
|
|
254
|
-
_this._queuedCoreMessages.push(msgData);
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
this._settings.coreInterface.addMessageListener(onmessage);
|
|
260
|
-
var onmessageerror = function () {
|
|
261
|
-
log_1.default.error("Init", "Error when receiving message from core.");
|
|
262
|
-
};
|
|
263
|
-
this._settings.coreInterface.addErrorListener(onmessageerror);
|
|
170
|
+
_this._manifestFetcher.addEventListener("error", function (err) {
|
|
171
|
+
_this.trigger("error", err);
|
|
172
|
+
rej(err);
|
|
173
|
+
});
|
|
174
|
+
_this._manifestFetcher.addEventListener("manifestReady", function (manifest) {
|
|
175
|
+
res(manifest);
|
|
176
|
+
});
|
|
177
|
+
}));
|
|
178
|
+
this._manifestFetcher.start();
|
|
264
179
|
this._initCanceller.signal.register(function () {
|
|
265
|
-
|
|
266
|
-
_this._settings.coreInterface.removeMessageListener(onmessage);
|
|
267
|
-
_this._settings.coreInterface.removeErrorListener(onmessageerror);
|
|
180
|
+
_this._manifestFetcher.dispose();
|
|
268
181
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* @param {HTMLMediaElement} mediaElement
|
|
185
|
+
* @param {Object} playbackObserver
|
|
186
|
+
*/
|
|
187
|
+
MediaSourceContentInitializer.prototype.start = function (mediaElement, playbackObserver) {
|
|
188
|
+
var _this = this;
|
|
189
|
+
this.prepare(); // Load Manifest if not already done
|
|
190
|
+
/** Translate errors coming from the media element into RxPlayer errors. */
|
|
191
|
+
(0, throw_on_media_error_1.default)(mediaElement, function (error) { return _this._onFatalError(error); }, this._initCanceller.signal);
|
|
192
|
+
this._setupInitialMediaSourceAndDecryption(mediaElement)
|
|
193
|
+
.then(function (initResult) {
|
|
194
|
+
return _this._onInitialMediaSourceReady(mediaElement, initResult.mediaSource, playbackObserver, initResult.drmSystemId, initResult.unlinkMediaSource);
|
|
195
|
+
})
|
|
196
|
+
.catch(function (err) {
|
|
197
|
+
_this._onFatalError(err);
|
|
276
198
|
});
|
|
277
|
-
limitVideoResolution.onUpdate(function (newVal) {
|
|
278
|
-
coreInterface.sendMessage({
|
|
279
|
-
type: "ref-update" /* MainThreadMessageType.ReferenceUpdate */,
|
|
280
|
-
value: { name: "limitVideoResolution", newVal: newVal },
|
|
281
|
-
});
|
|
282
|
-
}, { clearSignal: this._initCanceller.signal, emitCurrentValue: true });
|
|
283
199
|
};
|
|
284
200
|
/**
|
|
285
201
|
* Update URL of the Manifest.
|
|
@@ -289,1069 +205,664 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
|
|
|
289
205
|
* DASH's MPD) will be refreshed immediately.
|
|
290
206
|
*/
|
|
291
207
|
MediaSourceContentInitializer.prototype.updateContentUrls = function (urls, refreshNow) {
|
|
292
|
-
|
|
208
|
+
this._manifestFetcher.updateContentUrls(urls, refreshNow);
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Stop content and free all resources linked to this
|
|
212
|
+
* `MediaSourceContentInitializer`.
|
|
213
|
+
*/
|
|
214
|
+
MediaSourceContentInitializer.prototype.dispose = function () {
|
|
215
|
+
this._initCanceller.cancel();
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Callback called when an error interrupting playback arised.
|
|
219
|
+
* @param {*} err
|
|
220
|
+
*/
|
|
221
|
+
MediaSourceContentInitializer.prototype._onFatalError = function (err) {
|
|
222
|
+
if (this._initCanceller.isUsed()) {
|
|
293
223
|
return;
|
|
294
224
|
}
|
|
295
|
-
this.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
225
|
+
this._initCanceller.cancel();
|
|
226
|
+
this.trigger("error", err);
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Initialize decryption mechanisms if needed and begin creating and relying
|
|
230
|
+
* on the initial `MediaSourceInterface` for this content.
|
|
231
|
+
* @param {HTMLMediaElement|null} mediaElement
|
|
232
|
+
* @returns {Promise.<Object>}
|
|
233
|
+
*/
|
|
234
|
+
MediaSourceContentInitializer.prototype._setupInitialMediaSourceAndDecryption = function (mediaElement) {
|
|
235
|
+
var _this = this;
|
|
236
|
+
var initCanceller = this._initCanceller;
|
|
237
|
+
return (0, create_cancellable_promise_1.default)(initCanceller.signal, function (resolve) {
|
|
238
|
+
var keySystems = _this._initSettings.keySystems;
|
|
239
|
+
/** Initialize decryption capabilities. */
|
|
240
|
+
var _a = (0, initialize_content_decryption_1.default)(mediaElement, keySystems, {
|
|
241
|
+
onWarning: function (err) { return _this.trigger("warning", err); },
|
|
242
|
+
onError: function (err) { return _this._onFatalError(err); },
|
|
243
|
+
onBlackListProtectionData: function (val) {
|
|
244
|
+
// Ugly IIFE workaround to allow async event listener
|
|
245
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
246
|
+
var manifest, _a;
|
|
247
|
+
var _b;
|
|
248
|
+
return __generator(this, function (_c) {
|
|
249
|
+
switch (_c.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
if (this._manifest === null) {
|
|
252
|
+
return [2 /*return*/];
|
|
253
|
+
}
|
|
254
|
+
if (!((_b = this._manifest.syncValue) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
255
|
+
_a = _b;
|
|
256
|
+
return [3 /*break*/, 3];
|
|
257
|
+
case 1: return [4 /*yield*/, this._manifest.getValueAsAsync()];
|
|
258
|
+
case 2:
|
|
259
|
+
_a = (_c.sent());
|
|
260
|
+
_c.label = 3;
|
|
261
|
+
case 3:
|
|
262
|
+
manifest = _a;
|
|
263
|
+
blackListProtectionDataOnManifest(manifest, val);
|
|
264
|
+
return [2 /*return*/];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}); })().catch(noop_1.default);
|
|
268
|
+
},
|
|
269
|
+
onKeyIdsCompatibilityUpdate: function (updates) {
|
|
270
|
+
// Ugly IIFE workaround to allow async event listener
|
|
271
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
272
|
+
var manifest, _a;
|
|
273
|
+
var _b;
|
|
274
|
+
return __generator(this, function (_c) {
|
|
275
|
+
switch (_c.label) {
|
|
276
|
+
case 0:
|
|
277
|
+
if (this._manifest === null) {
|
|
278
|
+
return [2 /*return*/];
|
|
279
|
+
}
|
|
280
|
+
if (!((_b = this._manifest.syncValue) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
281
|
+
_a = _b;
|
|
282
|
+
return [3 /*break*/, 3];
|
|
283
|
+
case 1: return [4 /*yield*/, this._manifest.getValueAsAsync()];
|
|
284
|
+
case 2:
|
|
285
|
+
_a = (_c.sent());
|
|
286
|
+
_c.label = 3;
|
|
287
|
+
case 3:
|
|
288
|
+
manifest = _a;
|
|
289
|
+
updateKeyIdsDecipherabilityOnManifest(manifest, updates.whitelistedKeyIds, updates.blacklistedKeyIds, updates.delistedKeyIds);
|
|
290
|
+
return [2 /*return*/];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}); })().catch(noop_1.default);
|
|
294
|
+
},
|
|
295
|
+
onCodecSupportUpdate: function () {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
var syncManifest = (_a = _this._manifest) === null || _a === void 0 ? void 0 : _a.syncValue;
|
|
298
|
+
if ((0, is_null_or_undefined_1.default)(syncManifest)) {
|
|
299
|
+
// The Manifest is not yet fetched, but we will be able to check
|
|
300
|
+
// the codecs once it is the case
|
|
301
|
+
(_b = _this._manifest) === null || _b === void 0 ? void 0 : _b.getValueAsAsync().then(function (loadedManifest) {
|
|
302
|
+
if (_this._initCanceller.isUsed()) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
_this._refreshManifestCodecSupport(loadedManifest, mediaElement);
|
|
306
|
+
}, noop_1.default);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
_this._refreshManifestCodecSupport(syncManifest, mediaElement);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
}, initCanceller.signal), drmInitRef = _a.statusRef, contentDecryptor = _a.contentDecryptor;
|
|
313
|
+
if (contentDecryptor.enabled) {
|
|
314
|
+
_this._decryptionCapabilities = {
|
|
315
|
+
status: "enabled",
|
|
316
|
+
value: contentDecryptor.value,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
_this._decryptionCapabilities = {
|
|
321
|
+
status: "disabled",
|
|
322
|
+
value: contentDecryptor.value,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
drmInitRef.onUpdate(function (drmStatus, stopListeningToDrmUpdates) {
|
|
326
|
+
if (drmStatus.initializationState.type === "uninitialized") {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
stopListeningToDrmUpdates();
|
|
330
|
+
var mediaSourceCanceller = new task_canceller_1.default();
|
|
331
|
+
mediaSourceCanceller.linkToSignal(initCanceller.signal);
|
|
332
|
+
(0, create_media_source_1.default)(mediaElement, mediaSourceCanceller.signal)
|
|
333
|
+
.then(function (mediaSource) {
|
|
334
|
+
var lastDrmStatus = drmInitRef.getValue();
|
|
335
|
+
if (lastDrmStatus.initializationState.type === "awaiting-media-link") {
|
|
336
|
+
lastDrmStatus.initializationState.value.isMediaLinked.setValue(true);
|
|
337
|
+
drmInitRef.onUpdate(function (newDrmStatus, stopListeningToDrmUpdatesAgain) {
|
|
338
|
+
if (newDrmStatus.initializationState.type === "initialized") {
|
|
339
|
+
stopListeningToDrmUpdatesAgain();
|
|
340
|
+
resolve({
|
|
341
|
+
mediaSource: mediaSource,
|
|
342
|
+
drmSystemId: newDrmStatus.drmSystemId,
|
|
343
|
+
unlinkMediaSource: mediaSourceCanceller,
|
|
344
|
+
});
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
}, { emitCurrentValue: true, clearSignal: initCanceller.signal });
|
|
348
|
+
}
|
|
349
|
+
else if (drmStatus.initializationState.type === "initialized") {
|
|
350
|
+
resolve({
|
|
351
|
+
mediaSource: mediaSource,
|
|
352
|
+
drmSystemId: drmStatus.drmSystemId,
|
|
353
|
+
unlinkMediaSource: mediaSourceCanceller,
|
|
354
|
+
});
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
.catch(function (err) {
|
|
359
|
+
if (mediaSourceCanceller.isUsed()) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
_this._onFatalError(err);
|
|
363
|
+
});
|
|
364
|
+
}, { emitCurrentValue: true, clearSignal: initCanceller.signal });
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
MediaSourceContentInitializer.prototype._onInitialMediaSourceReady = function (mediaElement, initialMediaSource, playbackObserver, drmSystemId, initialMediaSourceCanceller) {
|
|
368
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
369
|
+
var _a, adaptiveOptions, autoPlay, bufferOptions, lowLatencyMode, segmentRequestOptions, speed, startAt, textTrackOptions, transport, initCanceller, manifest, _b, _e_1, initialTime, representationEstimator, subBufferOptions, cdnPrioritizer, segmentQueueCreator;
|
|
370
|
+
var _this = this;
|
|
371
|
+
var _c;
|
|
372
|
+
return __generator(this, function (_d) {
|
|
373
|
+
switch (_d.label) {
|
|
374
|
+
case 0:
|
|
375
|
+
_a = this._initSettings, adaptiveOptions = _a.adaptiveOptions, autoPlay = _a.autoPlay, bufferOptions = _a.bufferOptions, lowLatencyMode = _a.lowLatencyMode, segmentRequestOptions = _a.segmentRequestOptions, speed = _a.speed, startAt = _a.startAt, textTrackOptions = _a.textTrackOptions, transport = _a.transport;
|
|
376
|
+
initCanceller = this._initCanceller;
|
|
377
|
+
(0, assert_1.default)(this._manifest !== null);
|
|
378
|
+
_d.label = 1;
|
|
379
|
+
case 1:
|
|
380
|
+
_d.trys.push([1, 5, , 6]);
|
|
381
|
+
if (!((_c = this._manifest.syncValue) !== null && _c !== void 0)) return [3 /*break*/, 2];
|
|
382
|
+
_b = _c;
|
|
383
|
+
return [3 /*break*/, 4];
|
|
384
|
+
case 2: return [4 /*yield*/, this._manifest.getValueAsAsync()];
|
|
385
|
+
case 3:
|
|
386
|
+
_b = (_d.sent());
|
|
387
|
+
_d.label = 4;
|
|
388
|
+
case 4:
|
|
389
|
+
manifest = _b;
|
|
390
|
+
return [3 /*break*/, 6];
|
|
391
|
+
case 5:
|
|
392
|
+
_e_1 = _d.sent();
|
|
393
|
+
return [2 /*return*/]; // The error should already have been processed through an event listener
|
|
394
|
+
case 6:
|
|
395
|
+
manifest.addEventListener("manifestUpdate", function (updates) {
|
|
396
|
+
_this.trigger("manifestUpdate", updates);
|
|
397
|
+
_this._refreshManifestCodecSupport(manifest, mediaElement);
|
|
398
|
+
}, initCanceller.signal);
|
|
399
|
+
manifest.addEventListener("decipherabilityUpdate", function (elts) {
|
|
400
|
+
_this.trigger("decipherabilityUpdate", elts);
|
|
401
|
+
}, initCanceller.signal);
|
|
402
|
+
manifest.addEventListener("supportUpdate", function () {
|
|
403
|
+
_this.trigger("codecSupportUpdate", null);
|
|
404
|
+
}, initCanceller.signal);
|
|
405
|
+
log_1.default.debug("Init", "Calculating initial time");
|
|
406
|
+
initialTime = (0, get_initial_time_1.default)(manifest, lowLatencyMode, startAt);
|
|
407
|
+
log_1.default.debug("Init", "Initial time calculated", { initialTime: initialTime });
|
|
408
|
+
representationEstimator = (0, adaptive_1.default)(adaptiveOptions);
|
|
409
|
+
subBufferOptions = (0, object_assign_1.default)({ textTrackOptions: textTrackOptions, drmSystemId: drmSystemId }, bufferOptions);
|
|
410
|
+
cdnPrioritizer = new fetchers_1.CdnPrioritizer(initCanceller.signal);
|
|
411
|
+
segmentQueueCreator = new fetchers_1.SegmentQueueCreator(transport, cdnPrioritizer, this._cmcdDataBuilder, segmentRequestOptions);
|
|
412
|
+
this._refreshManifestCodecSupport(manifest, mediaElement);
|
|
413
|
+
this.trigger("manifestReady", manifest);
|
|
414
|
+
if (initCanceller.isUsed()) {
|
|
415
|
+
return [2 /*return*/];
|
|
416
|
+
}
|
|
417
|
+
// handle initial load and reloads
|
|
418
|
+
this._setupContentWithNewMediaSource({
|
|
419
|
+
mediaElement: mediaElement,
|
|
420
|
+
playbackObserver: playbackObserver,
|
|
421
|
+
mediaSource: initialMediaSource,
|
|
422
|
+
initialTime: initialTime,
|
|
423
|
+
autoPlay: autoPlay,
|
|
424
|
+
manifest: manifest,
|
|
425
|
+
representationEstimator: representationEstimator,
|
|
426
|
+
cdnPrioritizer: cdnPrioritizer,
|
|
427
|
+
segmentQueueCreator: segmentQueueCreator,
|
|
428
|
+
speed: speed,
|
|
429
|
+
bufferOptions: subBufferOptions,
|
|
430
|
+
}, initialMediaSourceCanceller);
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
}
|
|
433
|
+
});
|
|
299
434
|
});
|
|
300
435
|
};
|
|
301
436
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
437
|
+
* Load the content defined by the Manifest in the mediaSource given at the
|
|
438
|
+
* given position and playing status.
|
|
439
|
+
* This function recursively re-call itself when a MediaSource reload is
|
|
440
|
+
* wanted.
|
|
441
|
+
* @param {Object} args
|
|
442
|
+
* @param {Object} currentCanceller
|
|
304
443
|
*/
|
|
305
|
-
MediaSourceContentInitializer.prototype.
|
|
306
|
-
|
|
444
|
+
MediaSourceContentInitializer.prototype._setupContentWithNewMediaSource = function (args, currentCanceller) {
|
|
445
|
+
this._startLoadingContentOnMediaSource(args, this._createReloadMediaSourceCallback(args, currentCanceller), currentCanceller.signal);
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Create `IReloadMediaSourceCallback` allowing to handle reload orders.
|
|
449
|
+
* @param {Object} args
|
|
450
|
+
* @param {Object} currentCanceller
|
|
451
|
+
*/
|
|
452
|
+
MediaSourceContentInitializer.prototype._createReloadMediaSourceCallback = function (args, currentCanceller) {
|
|
307
453
|
var _this = this;
|
|
308
|
-
this.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
454
|
+
var initCanceller = this._initCanceller;
|
|
455
|
+
return function (reloadOrder) {
|
|
456
|
+
currentCanceller.cancel();
|
|
457
|
+
if (initCanceller.isUsed()) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
_this.trigger("reloadingMediaSource", reloadOrder);
|
|
461
|
+
if (initCanceller.isUsed()) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
var newCanceller = new task_canceller_1.default();
|
|
465
|
+
newCanceller.linkToSignal(initCanceller.signal);
|
|
466
|
+
(0, create_media_source_1.default)(args.mediaElement, newCanceller.signal)
|
|
467
|
+
.then(function (newMediaSource) {
|
|
468
|
+
_this._setupContentWithNewMediaSource(__assign(__assign({}, args), { mediaSource: newMediaSource, initialTime: reloadOrder.position, autoPlay: reloadOrder.autoPlay }), newCanceller);
|
|
469
|
+
})
|
|
470
|
+
.catch(function (err) {
|
|
471
|
+
if (newCanceller.isUsed()) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
_this._onFatalError(err);
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Buffer the content on the given MediaSource.
|
|
480
|
+
* @param {Object} args
|
|
481
|
+
* @param {function} onReloadOrder
|
|
482
|
+
* @param {Object} cancelSignal
|
|
483
|
+
*/
|
|
484
|
+
MediaSourceContentInitializer.prototype._startLoadingContentOnMediaSource = function (args, onReloadOrder, cancelSignal) {
|
|
485
|
+
var _this = this;
|
|
486
|
+
var _a, _b;
|
|
487
|
+
var autoPlay = args.autoPlay, bufferOptions = args.bufferOptions, initialTime = args.initialTime, manifest = args.manifest, mediaElement = args.mediaElement, mediaSource = args.mediaSource, playbackObserver = args.playbackObserver, representationEstimator = args.representationEstimator, cdnPrioritizer = args.cdnPrioritizer, segmentQueueCreator = args.segmentQueueCreator, speed = args.speed;
|
|
488
|
+
var transport = this._initSettings.transport;
|
|
489
|
+
var initialPeriod = (_a = manifest.getPeriodForTime(initialTime)) !== null && _a !== void 0 ? _a : manifest.getNextPeriod(initialTime);
|
|
490
|
+
if (initialPeriod === undefined) {
|
|
491
|
+
var error = new errors_1.MediaError("MEDIA_STARTING_TIME_NOT_FOUND", "Wanted starting time not found in the Manifest.");
|
|
492
|
+
return this._onFatalError(error);
|
|
321
493
|
}
|
|
322
|
-
|
|
323
|
-
|
|
494
|
+
var textDisplayerInterface = null;
|
|
495
|
+
var textDisplayer = createTextDisplayer(mediaElement, this._initSettings.textTrackOptions);
|
|
496
|
+
if (textDisplayer !== null) {
|
|
497
|
+
var sender_1 = new main_thread_text_displayer_interface_1.default(textDisplayer);
|
|
498
|
+
textDisplayerInterface = sender_1;
|
|
499
|
+
cancelSignal.register(function () {
|
|
500
|
+
sender_1.stop();
|
|
501
|
+
textDisplayer === null || textDisplayer === void 0 ? void 0 : textDisplayer.stop();
|
|
502
|
+
});
|
|
324
503
|
}
|
|
325
|
-
|
|
326
|
-
|
|
504
|
+
/** Interface to create media buffers. */
|
|
505
|
+
var segmentSinksStore = new segment_sinks_1.default(mediaSource, mediaElement.nodeName === "VIDEO", textDisplayerInterface);
|
|
506
|
+
cancelSignal.register(function () {
|
|
507
|
+
segmentSinksStore.disposeAll();
|
|
327
508
|
});
|
|
328
|
-
|
|
329
|
-
(0, throw_on_media_error_1.default)(mediaElement, function (error) { return _this._onFatalError(error); }, this._initCanceller.signal);
|
|
330
|
-
/**
|
|
331
|
-
* Send content protection initialization data.
|
|
332
|
-
* TODO remove and use ContentDecryptor directly when possible.
|
|
333
|
-
*/
|
|
334
|
-
var lastContentProtection = new reference_1.default(null);
|
|
335
|
-
var mediaSourceStatus = new reference_1.default(0 /* MediaSourceInitializationStatus.Nothing */);
|
|
336
|
-
var _b = this._initializeContentDecryption(mediaElement, lastContentProtection, mediaSourceStatus, function () { return notifyAndStartMediaSourceReload(0, undefined, undefined); }, this._initCanceller.signal), drmInitializationStatus = _b.statusRef, contentDecryptor = _b.contentDecryptor;
|
|
337
|
-
var contentInfo = this._currentContentInfo;
|
|
338
|
-
if (contentInfo !== null) {
|
|
339
|
-
contentInfo.contentDecryptor = contentDecryptor;
|
|
340
|
-
}
|
|
341
|
-
var playbackStartParams = {
|
|
509
|
+
var _c = (0, initial_seek_and_play_1.default)({
|
|
342
510
|
mediaElement: mediaElement,
|
|
343
|
-
textDisplayer: textDisplayer,
|
|
344
511
|
playbackObserver: playbackObserver,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (reloadingContentInfo === null) {
|
|
373
|
-
log_1.default.warn("Init", "Asked to reload when no content is loaded.");
|
|
374
|
-
return;
|
|
512
|
+
startTime: initialTime,
|
|
513
|
+
mustAutoPlay: autoPlay,
|
|
514
|
+
onWarning: function (err) {
|
|
515
|
+
_this.trigger("warning", err);
|
|
516
|
+
},
|
|
517
|
+
isDirectfile: false,
|
|
518
|
+
}, cancelSignal), autoPlayResult = _c.autoPlayResult, initialPlayPerformed = _c.initialPlayPerformed;
|
|
519
|
+
if (cancelSignal.isCancelled()) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
initialPlayPerformed.onUpdate(function (isPerformed, stopListening) {
|
|
523
|
+
if (isPerformed) {
|
|
524
|
+
stopListening();
|
|
525
|
+
var streamEventsEmitter_1 = new stream_events_emitter_1.default(manifest, playbackObserver);
|
|
526
|
+
manifest.addEventListener("manifestUpdate", function () {
|
|
527
|
+
streamEventsEmitter_1.onManifestUpdate(manifest);
|
|
528
|
+
}, cancelSignal);
|
|
529
|
+
streamEventsEmitter_1.addEventListener("event", function (payload) {
|
|
530
|
+
_this.trigger("streamEvent", payload);
|
|
531
|
+
}, cancelSignal);
|
|
532
|
+
streamEventsEmitter_1.addEventListener("eventSkip", function (payload) {
|
|
533
|
+
_this.trigger("streamEventSkip", payload);
|
|
534
|
+
}, cancelSignal);
|
|
535
|
+
streamEventsEmitter_1.start();
|
|
536
|
+
cancelSignal.register(function () {
|
|
537
|
+
streamEventsEmitter_1.stop();
|
|
538
|
+
});
|
|
375
539
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
540
|
+
}, { clearSignal: cancelSignal, emitCurrentValue: true });
|
|
541
|
+
var coreObserver = (0, create_core_playback_observer_1.default)(playbackObserver, {
|
|
542
|
+
autoPlay: autoPlay,
|
|
543
|
+
manifest: manifest,
|
|
544
|
+
mediaSource: mediaSource,
|
|
545
|
+
textDisplayer: textDisplayer,
|
|
546
|
+
initialPlayPerformed: initialPlayPerformed,
|
|
547
|
+
speed: speed,
|
|
548
|
+
}, cancelSignal);
|
|
549
|
+
(_b = this._cmcdDataBuilder) === null || _b === void 0 ? void 0 : _b.startMonitoringPlayback(coreObserver);
|
|
550
|
+
cancelSignal.register(function () {
|
|
551
|
+
var _a;
|
|
552
|
+
(_a = _this._cmcdDataBuilder) === null || _a === void 0 ? void 0 : _a.stopMonitoringPlayback();
|
|
553
|
+
});
|
|
554
|
+
var rebufferingController = this._createRebufferingController(playbackObserver, manifest, speed, cancelSignal);
|
|
555
|
+
var freezeResolver = new FreezeResolver_1.default(segmentSinksStore);
|
|
556
|
+
if ((0, may_media_element_fail_on_undecipherable_data_1.default)()) {
|
|
557
|
+
// On some devices, just reload immediately when data become undecipherable
|
|
558
|
+
manifest.addEventListener("decipherabilityUpdate", function (elts) {
|
|
559
|
+
if (elts.some(function (e) { return e.representation.decipherable !== true; })) {
|
|
560
|
+
reloadMediaSource(0, undefined, undefined);
|
|
561
|
+
}
|
|
562
|
+
}, cancelSignal);
|
|
563
|
+
}
|
|
564
|
+
coreObserver.listen(function (observation) {
|
|
565
|
+
(0, synchronize_sinks_on_observation_1.default)(observation, segmentSinksStore);
|
|
566
|
+
var freezeResolution = freezeResolver.onNewObservation(observation);
|
|
567
|
+
if (freezeResolution === null) {
|
|
379
568
|
return;
|
|
380
569
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
570
|
+
// TODO: The following method looks generic, we may be able to factorize
|
|
571
|
+
// it with other reload handlers after some work.
|
|
572
|
+
var triggerReload = function () {
|
|
573
|
+
var _a;
|
|
574
|
+
var lastObservation = playbackObserver.getReference().getValue();
|
|
575
|
+
var position = lastObservation.position.isAwaitingFuturePosition()
|
|
576
|
+
? lastObservation.position.getWanted()
|
|
577
|
+
: ((_a = coreObserver.getCurrentTime()) !== null && _a !== void 0 ? _a : lastObservation.position.getPolled());
|
|
578
|
+
var autoplay = initialPlayPerformed.getValue()
|
|
579
|
+
? !playbackObserver.getIsPaused()
|
|
580
|
+
: autoPlay;
|
|
581
|
+
onReloadOrder({ position: position, autoPlay: autoplay });
|
|
582
|
+
};
|
|
583
|
+
handleFreezeResolution(freezeResolution, {
|
|
584
|
+
enableRepresentationAvoidance: _this._initSettings.enableRepresentationAvoidance,
|
|
585
|
+
manifest: manifest,
|
|
586
|
+
triggerReload: triggerReload,
|
|
587
|
+
playbackObserver: playbackObserver,
|
|
388
588
|
});
|
|
389
|
-
|
|
390
|
-
|
|
589
|
+
}, { clearSignal: cancelSignal });
|
|
590
|
+
var contentTimeBoundariesObserver = (0, create_content_time_boundaries_observer_1.default)(manifest, mediaSource, coreObserver, segmentSinksStore, {
|
|
591
|
+
onWarning: function (err) { return _this.trigger("warning", err); },
|
|
592
|
+
onPeriodChanged: function (period) {
|
|
593
|
+
return _this.trigger("activePeriodChanged", { period: period });
|
|
594
|
+
},
|
|
595
|
+
}, cancelSignal);
|
|
391
596
|
/**
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* `notifyAndStartMediaSourceReload` instead.
|
|
396
|
-
* @param {number} deltaPosition - Position you want to seek to after
|
|
397
|
-
* reloading, as a delta in seconds from the last polled playing position.
|
|
398
|
-
* @param {number|undefined} minimumPosition - If set, minimum time bound
|
|
399
|
-
* in seconds after `deltaPosition` has been applied.
|
|
400
|
-
* @param {number|undefined} maximumPosition - If set, minimum time bound
|
|
401
|
-
* in seconds after `deltaPosition` has been applied.
|
|
597
|
+
* Emit a "loaded" events once the initial play has been performed and the
|
|
598
|
+
* media can begin playback.
|
|
599
|
+
* Also emits warning events if issues arise when doing so.
|
|
402
600
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
601
|
+
autoPlayResult
|
|
602
|
+
.then(function () {
|
|
603
|
+
(0, get_loaded_reference_1.default)(playbackObserver, false, cancelSignal).onUpdate(function (isLoaded, stopListening) {
|
|
604
|
+
if (isLoaded) {
|
|
605
|
+
var fetchThumbnails_1 = (0, fetchers_1.createThumbnailFetcher)(transport.thumbnails, cdnPrioritizer);
|
|
606
|
+
stopListening();
|
|
607
|
+
_this.trigger("loaded", {
|
|
608
|
+
getSegmentSinkMetrics: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
609
|
+
return __generator(this, function (_a) {
|
|
610
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
611
|
+
return resolve(segmentSinksStore.getSegmentSinksMetrics());
|
|
612
|
+
})];
|
|
613
|
+
});
|
|
614
|
+
}); },
|
|
615
|
+
getThumbnailData: function (periodId, thumbnailTrackId, time) { return __awaiter(_this, void 0, void 0, function () {
|
|
616
|
+
return __generator(this, function (_a) {
|
|
617
|
+
return [2 /*return*/, (0, get_thumbnail_data_1.default)(fetchThumbnails_1, manifest, periodId, thumbnailTrackId, time)];
|
|
618
|
+
});
|
|
619
|
+
}); },
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
}, { emitCurrentValue: true, clearSignal: cancelSignal });
|
|
623
|
+
})
|
|
624
|
+
.catch(function (err) {
|
|
625
|
+
if (cancelSignal.isCancelled()) {
|
|
626
|
+
return; // Current loading cancelled, no need to trigger the error
|
|
422
627
|
}
|
|
423
|
-
_this.
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
628
|
+
_this._onFatalError(err);
|
|
629
|
+
});
|
|
630
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
631
|
+
var self = this;
|
|
632
|
+
(0, stream_1.default)({ manifest: manifest, initialPeriod: initialPeriod }, coreObserver, representationEstimator, segmentSinksStore, segmentQueueCreator, bufferOptions, handleStreamOrchestratorCallbacks(), cancelSignal);
|
|
633
|
+
/**
|
|
634
|
+
* Returns Object handling the callbacks from a `StreamOrchestrator`, which
|
|
635
|
+
* are basically how it communicates about events.
|
|
636
|
+
* @returns {Object}
|
|
637
|
+
*/
|
|
638
|
+
function handleStreamOrchestratorCallbacks() {
|
|
639
|
+
return {
|
|
640
|
+
needsBufferFlush: function (payload) {
|
|
641
|
+
var _a;
|
|
642
|
+
var wantedSeekingTime;
|
|
643
|
+
var lastObservation = playbackObserver.getReference().getValue();
|
|
644
|
+
var currentTime = lastObservation.position.isAwaitingFuturePosition()
|
|
645
|
+
? lastObservation.position.getWanted()
|
|
646
|
+
: mediaElement.currentTime;
|
|
647
|
+
var relativeResumingPosition = (_a = payload === null || payload === void 0 ? void 0 : payload.relativeResumingPosition) !== null && _a !== void 0 ? _a : 0;
|
|
648
|
+
var canBeApproximateSeek = Boolean(payload === null || payload === void 0 ? void 0 : payload.relativePosHasBeenDefaulted);
|
|
649
|
+
if (relativeResumingPosition === 0 && canBeApproximateSeek) {
|
|
650
|
+
// in case relativeResumingPosition is 0, we still perform
|
|
651
|
+
// a tiny seek to be sure that the browser will correclty reload the video.
|
|
652
|
+
wantedSeekingTime = currentTime + 0.001;
|
|
431
653
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.dispose();
|
|
435
|
-
}
|
|
436
|
-
_this._currentContentInfo.mediaSourceInfo = {
|
|
437
|
-
type: "core",
|
|
438
|
-
mediaSourceId: msgData.mediaSourceId,
|
|
439
|
-
};
|
|
654
|
+
else {
|
|
655
|
+
wantedSeekingTime = currentTime + relativeResumingPosition;
|
|
440
656
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
657
|
+
playbackObserver.setCurrentTime(wantedSeekingTime);
|
|
658
|
+
// Seek again once data begins to be buffered.
|
|
659
|
+
// This is sadly necessary on some browsers to avoid decoding
|
|
660
|
+
// issues after a flush.
|
|
661
|
+
//
|
|
662
|
+
// NOTE: there's in theory a potential race condition in the following
|
|
663
|
+
// logic as the callback could be called when media data is still
|
|
664
|
+
// being removed by the browser - which is an asynchronous process.
|
|
665
|
+
// The following condition checking for buffered data could thus lead
|
|
666
|
+
// to a false positive where we're actually checking previous data.
|
|
667
|
+
// For now, such scenario is avoided by setting the
|
|
668
|
+
// `includeLastObservation` option to `false` and calling
|
|
669
|
+
// `needsBufferFlush` once MSE media removal operations have been
|
|
670
|
+
// explicitely validated by the browser, but that's a complex and easy
|
|
671
|
+
// to break system.
|
|
672
|
+
playbackObserver.listen(function (obs, stopListening) {
|
|
673
|
+
if (
|
|
674
|
+
// Data is buffered around the current position
|
|
675
|
+
obs.currentRange !== null ||
|
|
676
|
+
// Or, for whatever reason, we have no buffer but we're already advancing
|
|
677
|
+
obs.position.getPolled() > wantedSeekingTime + 0.1) {
|
|
444
678
|
stopListening();
|
|
445
|
-
|
|
446
|
-
if (mediaSourceLink_1.type === "handle") {
|
|
447
|
-
mediaElement.srcObject = mediaSourceLink_1.value;
|
|
448
|
-
_this._currentMediaSourceCanceller.signal.register(function () {
|
|
449
|
-
mediaElement.srcObject = null;
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
mediaElement.src = mediaSourceLink_1.value;
|
|
454
|
-
_this._currentMediaSourceCanceller.signal.register(function () {
|
|
455
|
-
(0, create_media_source_1.resetMediaElement)(mediaElement, mediaSourceLink_1.value);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
(0, create_media_source_1.disableRemotePlaybackOnManagedMediaSource)(mediaElement, _this._currentMediaSourceCanceller.signal);
|
|
459
|
-
mediaSourceStatus.setValue(2 /* MediaSourceInitializationStatus.Attached */);
|
|
679
|
+
playbackObserver.setCurrentTime(obs.position.getWanted() + 0.001);
|
|
460
680
|
}
|
|
461
|
-
}, {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
msgData.mediaSourceId) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
487
|
-
mediaSource.addSourceBuffer(msgData.value.sourceBufferType, msgData.value.codec);
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
case "source-buffer-append" /* CoreMessageType.SourceBufferAppend */:
|
|
491
|
-
{
|
|
492
|
-
if (((_h = (_g = _this._currentContentInfo) === null || _g === void 0 ? void 0 : _g.mediaSourceInfo) === null || _h === void 0 ? void 0 : _h.type) !== "main" ||
|
|
493
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
494
|
-
msgData.mediaSourceId) {
|
|
495
|
-
return;
|
|
681
|
+
}, { includeLastObservation: false, clearSignal: cancelSignal });
|
|
682
|
+
},
|
|
683
|
+
streamStatusUpdate: function (value) {
|
|
684
|
+
// Announce discontinuities if found
|
|
685
|
+
var period = value.period, bufferType = value.bufferType, imminentDiscontinuity = value.imminentDiscontinuity, position = value.position;
|
|
686
|
+
rebufferingController.updateDiscontinuityInfo({
|
|
687
|
+
period: period,
|
|
688
|
+
bufferType: bufferType,
|
|
689
|
+
discontinuity: imminentDiscontinuity,
|
|
690
|
+
position: position,
|
|
691
|
+
});
|
|
692
|
+
if (cancelSignal.isCancelled()) {
|
|
693
|
+
return; // Previous call has stopped streams due to a side-effect
|
|
694
|
+
}
|
|
695
|
+
// If the status for the last Period indicates that segments are all loaded
|
|
696
|
+
// or on the contrary that the loading resumed, announce it to the
|
|
697
|
+
// ContentTimeBoundariesObserver.
|
|
698
|
+
if (manifest.isLastPeriodKnown &&
|
|
699
|
+
value.period.id === manifest.periods[manifest.periods.length - 1].id) {
|
|
700
|
+
var hasFinishedLoadingLastPeriod = value.hasFinishedLoading || value.isEmptyStream;
|
|
701
|
+
if (hasFinishedLoadingLastPeriod) {
|
|
702
|
+
contentTimeBoundariesObserver.onLastSegmentFinishedLoading(value.bufferType);
|
|
496
703
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (sourceBuffer_1 === undefined) {
|
|
500
|
-
return;
|
|
704
|
+
else {
|
|
705
|
+
contentTimeBoundariesObserver.onLastSegmentLoadingResume(value.bufferType);
|
|
501
706
|
}
|
|
502
|
-
sourceBuffer_1
|
|
503
|
-
.appendBuffer(msgData.value.data, msgData.value.params)
|
|
504
|
-
.then(function (buffered) {
|
|
505
|
-
_this._settings.coreInterface.sendMessage({
|
|
506
|
-
type: "sb-success" /* MainThreadMessageType.SourceBufferSuccess */,
|
|
507
|
-
mediaSourceId: mediaSource_1.id,
|
|
508
|
-
sourceBufferType: sourceBuffer_1.type,
|
|
509
|
-
operationId: msgData.operationId,
|
|
510
|
-
value: { buffered: buffered },
|
|
511
|
-
});
|
|
512
|
-
})
|
|
513
|
-
.catch(function (error) {
|
|
514
|
-
_this._settings.coreInterface.sendMessage({
|
|
515
|
-
type: "sb-error" /* MainThreadMessageType.SourceBufferError */,
|
|
516
|
-
mediaSourceId: mediaSource_1.id,
|
|
517
|
-
sourceBufferType: sourceBuffer_1.type,
|
|
518
|
-
operationId: msgData.operationId,
|
|
519
|
-
value: error instanceof task_canceller_1.CancellationError
|
|
520
|
-
? { errorName: "CancellationError" }
|
|
521
|
-
: formatSourceBufferError(error).serialize(),
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
707
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
{
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
msgData.mediaSourceId) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
var mediaSource_2 = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
534
|
-
var sourceBuffer_2 = (0, array_find_1.default)(mediaSource_2.sourceBuffers, function (s) { return s.type === msgData.sourceBufferType; });
|
|
535
|
-
if (sourceBuffer_2 === undefined) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
sourceBuffer_2
|
|
539
|
-
.remove(msgData.value.start, msgData.value.end)
|
|
540
|
-
.then(function (buffered) {
|
|
541
|
-
_this._settings.coreInterface.sendMessage({
|
|
542
|
-
type: "sb-success" /* MainThreadMessageType.SourceBufferSuccess */,
|
|
543
|
-
mediaSourceId: mediaSource_2.id,
|
|
544
|
-
sourceBufferType: sourceBuffer_2.type,
|
|
545
|
-
operationId: msgData.operationId,
|
|
546
|
-
value: { buffered: buffered },
|
|
547
|
-
});
|
|
548
|
-
})
|
|
549
|
-
.catch(function (error) {
|
|
550
|
-
_this._settings.coreInterface.sendMessage({
|
|
551
|
-
type: "sb-error" /* MainThreadMessageType.SourceBufferError */,
|
|
552
|
-
mediaSourceId: mediaSource_2.id,
|
|
553
|
-
sourceBufferType: sourceBuffer_2.type,
|
|
554
|
-
operationId: msgData.operationId,
|
|
555
|
-
value: error instanceof task_canceller_1.CancellationError
|
|
556
|
-
? { errorName: "CancellationError" }
|
|
557
|
-
: formatSourceBufferError(error).serialize(),
|
|
558
|
-
});
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
break;
|
|
562
|
-
case "abort-source-buffer" /* CoreMessageType.AbortSourceBuffer */:
|
|
563
|
-
{
|
|
564
|
-
if (((_m = (_l = _this._currentContentInfo) === null || _l === void 0 ? void 0 : _l.mediaSourceInfo) === null || _m === void 0 ? void 0 : _m.type) !== "main" ||
|
|
565
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
566
|
-
msgData.mediaSourceId) {
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
570
|
-
var sourceBuffer = (0, array_find_1.default)(mediaSource.sourceBuffers, function (s) { return s.type === msgData.sourceBufferType; });
|
|
571
|
-
if (sourceBuffer === undefined) {
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
sourceBuffer.abort();
|
|
575
|
-
}
|
|
576
|
-
break;
|
|
577
|
-
case "update-media-source-duration" /* CoreMessageType.UpdateMediaSourceDuration */:
|
|
578
|
-
{
|
|
579
|
-
if (((_p = (_o = _this._currentContentInfo) === null || _o === void 0 ? void 0 : _o.mediaSourceInfo) === null || _p === void 0 ? void 0 : _p.type) !== "main" ||
|
|
580
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
581
|
-
msgData.mediaSourceId) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
585
|
-
if ((mediaSource === null || mediaSource === void 0 ? void 0 : mediaSource.id) !== msgData.mediaSourceId) {
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
mediaSource.setDuration(msgData.value.duration, msgData.value.isRealEndKnown);
|
|
589
|
-
}
|
|
590
|
-
break;
|
|
591
|
-
case "stop-media-source-duration" /* CoreMessageType.InterruptMediaSourceDurationUpdate */:
|
|
592
|
-
{
|
|
593
|
-
if (((_r = (_q = _this._currentContentInfo) === null || _q === void 0 ? void 0 : _q.mediaSourceInfo) === null || _r === void 0 ? void 0 : _r.type) !== "main" ||
|
|
594
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
595
|
-
msgData.mediaSourceId) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
599
|
-
if ((mediaSource === null || mediaSource === void 0 ? void 0 : mediaSource.id) !== msgData.mediaSourceId) {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
mediaSource.interruptDurationSetting();
|
|
603
|
-
}
|
|
604
|
-
break;
|
|
605
|
-
case "end-of-stream" /* CoreMessageType.EndOfStream */:
|
|
606
|
-
{
|
|
607
|
-
if (((_t = (_s = _this._currentContentInfo) === null || _s === void 0 ? void 0 : _s.mediaSourceInfo) === null || _t === void 0 ? void 0 : _t.type) !== "main" ||
|
|
608
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
609
|
-
msgData.mediaSourceId) {
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
613
|
-
mediaSource.maintainEndOfStream();
|
|
614
|
-
}
|
|
615
|
-
break;
|
|
616
|
-
case "stop-end-of-stream" /* CoreMessageType.InterruptEndOfStream */:
|
|
617
|
-
{
|
|
618
|
-
if (((_v = (_u = _this._currentContentInfo) === null || _u === void 0 ? void 0 : _u.mediaSourceInfo) === null || _v === void 0 ? void 0 : _v.type) !== "main" ||
|
|
619
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
620
|
-
msgData.mediaSourceId) {
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
624
|
-
mediaSource.stopEndOfStream();
|
|
625
|
-
}
|
|
626
|
-
break;
|
|
627
|
-
case "dispose-media-source" /* CoreMessageType.DisposeMediaSource */:
|
|
628
|
-
{
|
|
629
|
-
if (((_x = (_w = _this._currentContentInfo) === null || _w === void 0 ? void 0 : _w.mediaSourceInfo) === null || _x === void 0 ? void 0 : _x.type) !== "main" ||
|
|
630
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.id !==
|
|
631
|
-
msgData.mediaSourceId) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
var mediaSource = _this._currentContentInfo.mediaSourceInfo.mediaSource;
|
|
635
|
-
mediaSource.dispose();
|
|
636
|
-
}
|
|
637
|
-
break;
|
|
638
|
-
case "needs-buffer-flush" /* CoreMessageType.NeedsBufferFlush */: {
|
|
639
|
-
if (((_y = _this._currentContentInfo) === null || _y === void 0 ? void 0 : _y.contentId) !== msgData.contentId) {
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
var lastObservation = playbackObserver.getReference().getValue();
|
|
643
|
-
var currentTime = lastObservation.position.isAwaitingFuturePosition()
|
|
644
|
-
? lastObservation.position.getWanted()
|
|
645
|
-
: mediaElement.currentTime;
|
|
646
|
-
var relativeResumingPosition = (_0 = (_z = msgData.value) === null || _z === void 0 ? void 0 : _z.relativeResumingPosition) !== null && _0 !== void 0 ? _0 : 0;
|
|
647
|
-
var canBeApproximateSeek = Boolean((_1 = msgData.value) === null || _1 === void 0 ? void 0 : _1.relativePosHasBeenDefaulted);
|
|
648
|
-
var wantedSeekingTime = void 0;
|
|
649
|
-
if (relativeResumingPosition === 0 && canBeApproximateSeek) {
|
|
650
|
-
// in case relativeResumingPosition is 0, we still perform
|
|
651
|
-
// a tiny seek to be sure that the browser will correclty reload the video.
|
|
652
|
-
wantedSeekingTime = currentTime + 0.001;
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
wantedSeekingTime = currentTime + relativeResumingPosition;
|
|
656
|
-
}
|
|
657
|
-
playbackObserver.setCurrentTime(wantedSeekingTime);
|
|
658
|
-
break;
|
|
659
|
-
}
|
|
660
|
-
case "active-period-changed" /* CoreMessageType.ActivePeriodChanged */: {
|
|
661
|
-
if (((_2 = _this._currentContentInfo) === null || _2 === void 0 ? void 0 : _2.contentId) !== msgData.contentId ||
|
|
662
|
-
_this._currentContentInfo.manifest === null) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
var period = (0, array_find_1.default)(_this._currentContentInfo.manifest.periods, function (p) { return p.id === msgData.value.periodId; });
|
|
666
|
-
if (period !== undefined) {
|
|
667
|
-
_this.trigger("activePeriodChanged", { period: period });
|
|
668
|
-
}
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
case "adaptation-changed" /* CoreMessageType.AdaptationChanged */: {
|
|
672
|
-
if (((_3 = _this._currentContentInfo) === null || _3 === void 0 ? void 0 : _3.contentId) !== msgData.contentId ||
|
|
673
|
-
_this._currentContentInfo.manifest === null) {
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
var period = (0, array_find_1.default)(_this._currentContentInfo.manifest.periods, function (p) { return p.id === msgData.value.periodId; });
|
|
677
|
-
if (period === undefined) {
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
if (msgData.value.adaptationId === null) {
|
|
681
|
-
_this.trigger("adaptationChange", {
|
|
682
|
-
period: period,
|
|
683
|
-
adaptation: null,
|
|
684
|
-
type: msgData.value.type,
|
|
685
|
-
});
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
var adaptations = (_4 = period.adaptations[msgData.value.type]) !== null && _4 !== void 0 ? _4 : [];
|
|
689
|
-
var adaptation = (0, array_find_1.default)(adaptations, function (a) { return a.id === msgData.value.adaptationId; });
|
|
690
|
-
if (adaptation !== undefined) {
|
|
691
|
-
_this.trigger("adaptationChange", {
|
|
692
|
-
period: period,
|
|
693
|
-
adaptation: adaptation,
|
|
694
|
-
type: msgData.value.type,
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
case "representation-changed" /* CoreMessageType.RepresentationChanged */: {
|
|
700
|
-
if (((_5 = _this._currentContentInfo) === null || _5 === void 0 ? void 0 : _5.contentId) !== msgData.contentId ||
|
|
701
|
-
_this._currentContentInfo.manifest === null) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
var period = (0, array_find_1.default)(_this._currentContentInfo.manifest.periods, function (p) { return p.id === msgData.value.periodId; });
|
|
705
|
-
if (period === undefined) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
if (msgData.value.representationId === null) {
|
|
709
|
-
_this.trigger("representationChange", {
|
|
710
|
-
period: period,
|
|
711
|
-
type: msgData.value.type,
|
|
712
|
-
representation: null,
|
|
713
|
-
});
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
var adaptations = (_6 = period.adaptations[msgData.value.type]) !== null && _6 !== void 0 ? _6 : [];
|
|
717
|
-
var adaptation = (0, array_find_1.default)(adaptations, function (a) { return a.id === msgData.value.adaptationId; });
|
|
718
|
-
if (adaptation === undefined) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
var representation = (0, array_find_1.default)(adaptation.representations, function (r) { return r.id === msgData.value.representationId; });
|
|
722
|
-
if (representation !== undefined) {
|
|
723
|
-
_this.trigger("representationChange", {
|
|
724
|
-
period: period,
|
|
725
|
-
type: msgData.value.type,
|
|
726
|
-
representation: representation,
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
break;
|
|
730
|
-
}
|
|
731
|
-
case "encryption-data-encountered" /* CoreMessageType.EncryptionDataEncountered */:
|
|
732
|
-
if (((_7 = _this._currentContentInfo) === null || _7 === void 0 ? void 0 : _7.contentId) !== msgData.contentId) {
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
lastContentProtection.setValue(msgData.value);
|
|
736
|
-
break;
|
|
737
|
-
case "manifest-ready" /* CoreMessageType.ManifestReady */: {
|
|
738
|
-
if (((_8 = _this._currentContentInfo) === null || _8 === void 0 ? void 0 : _8.contentId) !== msgData.contentId) {
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
var manifest = msgData.value.manifest;
|
|
742
|
-
_this._currentContentInfo.manifest = manifest;
|
|
743
|
-
_this._updateCodecSupport(manifest, mediaElement);
|
|
744
|
-
_this._startPlaybackIfReady(playbackStartParams);
|
|
745
|
-
break;
|
|
746
|
-
}
|
|
747
|
-
case "manifest-update" /* CoreMessageType.ManifestUpdate */: {
|
|
748
|
-
if (((_9 = _this._currentContentInfo) === null || _9 === void 0 ? void 0 : _9.contentId) !== msgData.contentId) {
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
var manifest = (_10 = _this._currentContentInfo) === null || _10 === void 0 ? void 0 : _10.manifest;
|
|
752
|
-
if ((0, is_null_or_undefined_1.default)(manifest)) {
|
|
753
|
-
log_1.default.error("Init", "Manifest update but no Manifest loaded");
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
(0, manifest_1.replicateUpdatesOnManifestMetadata)(manifest, msgData.value.manifest, msgData.value.updates);
|
|
757
|
-
(_12 = (_11 = _this._currentContentInfo) === null || _11 === void 0 ? void 0 : _11.streamEventsEmitter) === null || _12 === void 0 ? void 0 : _12.onManifestUpdate(manifest);
|
|
758
|
-
_this._updateCodecSupport(manifest, mediaElement);
|
|
759
|
-
_this.trigger("manifestUpdate", msgData.value.updates);
|
|
760
|
-
break;
|
|
761
|
-
}
|
|
762
|
-
case "update-playback-rate" /* CoreMessageType.UpdatePlaybackRate */:
|
|
763
|
-
if (((_13 = _this._currentContentInfo) === null || _13 === void 0 ? void 0 : _13.contentId) !== msgData.contentId) {
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
playbackObserver.setPlaybackRate(msgData.value);
|
|
767
|
-
break;
|
|
768
|
-
case "bitrate-estimate-change" /* CoreMessageType.BitrateEstimateChange */:
|
|
769
|
-
if (((_14 = _this._currentContentInfo) === null || _14 === void 0 ? void 0 : _14.contentId) !== msgData.contentId) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
_this.trigger("bitrateEstimateChange", {
|
|
773
|
-
type: msgData.value.bufferType,
|
|
774
|
-
bitrate: msgData.value.bitrate,
|
|
775
|
-
});
|
|
776
|
-
break;
|
|
777
|
-
case "inband-event" /* CoreMessageType.InbandEvent */:
|
|
778
|
-
if (((_15 = _this._currentContentInfo) === null || _15 === void 0 ? void 0 : _15.contentId) !== msgData.contentId) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
_this.trigger("inbandEvents", msgData.value);
|
|
782
|
-
break;
|
|
783
|
-
case "locked-stream" /* CoreMessageType.LockedStream */: {
|
|
784
|
-
if (((_16 = _this._currentContentInfo) === null || _16 === void 0 ? void 0 : _16.contentId) !== msgData.contentId ||
|
|
785
|
-
_this._currentContentInfo.manifest === null) {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
var period = (0, array_find_1.default)(_this._currentContentInfo.manifest.periods, function (p) { return p.id === msgData.value.periodId; });
|
|
789
|
-
if (period === undefined) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
(_17 = _this._currentContentInfo.rebufferingController) === null || _17 === void 0 ? void 0 : _17.onLockedStream(msgData.value.bufferType, period);
|
|
793
|
-
break;
|
|
794
|
-
}
|
|
795
|
-
case "period-stream-ready" /* CoreMessageType.PeriodStreamReady */: {
|
|
796
|
-
if (((_18 = _this._currentContentInfo) === null || _18 === void 0 ? void 0 : _18.contentId) !== msgData.contentId ||
|
|
797
|
-
_this._currentContentInfo.manifest === null) {
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
var period = (0, array_find_1.default)(_this._currentContentInfo.manifest.periods, function (p) { return p.id === msgData.value.periodId; });
|
|
801
|
-
if (period === undefined) {
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
var ref_1 = new reference_1.default(undefined);
|
|
805
|
-
ref_1.onUpdate(function (adapChoice) {
|
|
806
|
-
if (_this._currentContentInfo === null) {
|
|
807
|
-
ref_1.finish();
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
if (!(0, is_null_or_undefined_1.default)(adapChoice)) {
|
|
811
|
-
adapChoice.representations.onUpdate(function (repChoice, stopListening) {
|
|
812
|
-
if (_this._currentContentInfo === null) {
|
|
813
|
-
stopListening();
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
_this._settings.coreInterface.sendMessage({
|
|
817
|
-
type: "rep-update" /* MainThreadMessageType.RepresentationUpdate */,
|
|
818
|
-
contentId: _this._currentContentInfo.contentId,
|
|
819
|
-
value: {
|
|
820
|
-
periodId: msgData.value.periodId,
|
|
821
|
-
adaptationId: adapChoice.adaptationId,
|
|
822
|
-
bufferType: msgData.value.bufferType,
|
|
823
|
-
choice: repChoice,
|
|
824
|
-
},
|
|
825
|
-
});
|
|
826
|
-
}, { clearSignal: _this._initCanceller.signal });
|
|
827
|
-
}
|
|
828
|
-
_this._settings.coreInterface.sendMessage({
|
|
829
|
-
type: "track-update" /* MainThreadMessageType.TrackUpdate */,
|
|
830
|
-
contentId: _this._currentContentInfo.contentId,
|
|
831
|
-
value: {
|
|
832
|
-
periodId: msgData.value.periodId,
|
|
833
|
-
bufferType: msgData.value.bufferType,
|
|
834
|
-
choice: (0, is_null_or_undefined_1.default)(adapChoice)
|
|
835
|
-
? adapChoice
|
|
836
|
-
: {
|
|
837
|
-
adaptationId: adapChoice.adaptationId,
|
|
838
|
-
switchingMode: adapChoice.switchingMode,
|
|
839
|
-
initialRepresentations: adapChoice.representations.getValue(),
|
|
840
|
-
relativeResumingPosition: adapChoice.relativeResumingPosition,
|
|
841
|
-
},
|
|
842
|
-
},
|
|
843
|
-
});
|
|
844
|
-
}, { clearSignal: _this._initCanceller.signal });
|
|
845
|
-
_this.trigger("periodStreamReady", {
|
|
846
|
-
period: period,
|
|
847
|
-
type: msgData.value.bufferType,
|
|
848
|
-
adaptationRef: ref_1,
|
|
708
|
+
},
|
|
709
|
+
needsManifestRefresh: function () {
|
|
710
|
+
return self._manifestFetcher.scheduleManualRefresh({
|
|
711
|
+
enablePartialRefresh: true,
|
|
712
|
+
canUseUnsafeMode: true,
|
|
849
713
|
});
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
_this.trigger("periodStreamCleared", {
|
|
858
|
-
periodId: msgData.value.periodId,
|
|
859
|
-
type: msgData.value.bufferType,
|
|
714
|
+
},
|
|
715
|
+
manifestMightBeOufOfSync: function () {
|
|
716
|
+
var OUT_OF_SYNC_MANIFEST_REFRESH_DELAY = config_1.default.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;
|
|
717
|
+
self._manifestFetcher.scheduleManualRefresh({
|
|
718
|
+
enablePartialRefresh: false,
|
|
719
|
+
canUseUnsafeMode: false,
|
|
720
|
+
delay: OUT_OF_SYNC_MANIFEST_REFRESH_DELAY,
|
|
860
721
|
});
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
722
|
+
},
|
|
723
|
+
lockedStream: function (value) {
|
|
724
|
+
return rebufferingController.onLockedStream(value.bufferType, value.period);
|
|
725
|
+
},
|
|
726
|
+
adaptationChange: function (value) {
|
|
727
|
+
self.trigger("adaptationChange", value);
|
|
728
|
+
if (cancelSignal.isCancelled()) {
|
|
729
|
+
return; // Previous call has stopped streams due to a side-effect
|
|
867
730
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
return;
|
|
731
|
+
contentTimeBoundariesObserver.onAdaptationChange(value.type, value.period, value.adaptation);
|
|
732
|
+
},
|
|
733
|
+
representationChange: function (value) {
|
|
734
|
+
self.trigger("representationChange", value);
|
|
735
|
+
if (cancelSignal.isCancelled()) {
|
|
736
|
+
return; // Previous call has stopped streams due to a side-effect
|
|
874
737
|
}
|
|
875
|
-
(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
738
|
+
contentTimeBoundariesObserver.onRepresentationChange(value.type, value.period);
|
|
739
|
+
},
|
|
740
|
+
inbandEvent: function (value) { return self.trigger("inbandEvents", value); },
|
|
741
|
+
warning: function (value) { return self.trigger("warning", value); },
|
|
742
|
+
periodStreamReady: function (value) { return self.trigger("periodStreamReady", value); },
|
|
743
|
+
periodStreamCleared: function (value) {
|
|
744
|
+
contentTimeBoundariesObserver.onPeriodCleared(value.type, value.period);
|
|
745
|
+
if (cancelSignal.isCancelled()) {
|
|
746
|
+
return; // Previous call has stopped streams due to a side-effect
|
|
747
|
+
}
|
|
748
|
+
self.trigger("periodStreamCleared", {
|
|
749
|
+
type: value.type,
|
|
750
|
+
periodId: value.period.id,
|
|
880
751
|
});
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
var message = err instanceof Error ? err.message : "Unknown error";
|
|
901
|
-
_this._settings.coreInterface.sendMessage({
|
|
902
|
-
type: "push-text-error" /* MainThreadMessageType.PushTextDataError */,
|
|
903
|
-
contentId: msgData.contentId,
|
|
904
|
-
value: { message: message },
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
break;
|
|
909
|
-
}
|
|
910
|
-
case "remove-text-data" /* CoreMessageType.RemoveTextData */: {
|
|
911
|
-
if (((_23 = _this._currentContentInfo) === null || _23 === void 0 ? void 0 : _23.contentId) !== msgData.contentId) {
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
|
-
if (textDisplayer === null) {
|
|
915
|
-
log_1.default.warn("text", "Received RemoveTextData message but no text displayer exists");
|
|
752
|
+
},
|
|
753
|
+
bitrateEstimateChange: function (value) {
|
|
754
|
+
var _a;
|
|
755
|
+
(_a = self._cmcdDataBuilder) === null || _a === void 0 ? void 0 : _a.updateThroughput(value.type, value.bitrate);
|
|
756
|
+
self.trigger("bitrateEstimateChange", value);
|
|
757
|
+
},
|
|
758
|
+
needsMediaSourceReload: function (payload) {
|
|
759
|
+
reloadMediaSource(payload.timeOffset, payload.minimumPosition, payload.maximumPosition);
|
|
760
|
+
},
|
|
761
|
+
needsDecipherabilityFlush: function () {
|
|
762
|
+
var _a, _b, _c, _d;
|
|
763
|
+
var keySystem = (0, decrypt_1.getKeySystemConfiguration)(mediaElement);
|
|
764
|
+
if ((0, should_reload_media_source_on_decipherability_update_1.default)(keySystem === null || keySystem === void 0 ? void 0 : keySystem[0])) {
|
|
765
|
+
var lastObservation = coreObserver.getReference().getValue();
|
|
766
|
+
var position = lastObservation.position.isAwaitingFuturePosition()
|
|
767
|
+
? lastObservation.position.getWanted()
|
|
768
|
+
: ((_a = coreObserver.getCurrentTime()) !== null && _a !== void 0 ? _a : lastObservation.position.getPolled());
|
|
769
|
+
var isPaused = (_c = (_b = lastObservation.paused.pending) !== null && _b !== void 0 ? _b : coreObserver.getIsPaused()) !== null && _c !== void 0 ? _c : lastObservation.paused.last;
|
|
770
|
+
onReloadOrder({ position: position, autoPlay: !isPaused });
|
|
916
771
|
}
|
|
917
772
|
else {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
773
|
+
var lastObservation = coreObserver.getReference().getValue();
|
|
774
|
+
var position = lastObservation.position.isAwaitingFuturePosition()
|
|
775
|
+
? lastObservation.position.getWanted()
|
|
776
|
+
: ((_d = coreObserver.getCurrentTime()) !== null && _d !== void 0 ? _d : lastObservation.position.getPolled());
|
|
777
|
+
// simple seek close to the current position
|
|
778
|
+
// to flush the buffers
|
|
779
|
+
if (position + 0.001 < lastObservation.duration) {
|
|
780
|
+
playbackObserver.setCurrentTime(mediaElement.currentTime + 0.001);
|
|
925
781
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
_this._settings.coreInterface.sendMessage({
|
|
929
|
-
type: "remove-text-error" /* MainThreadMessageType.RemoveTextDataError */,
|
|
930
|
-
contentId: msgData.contentId,
|
|
931
|
-
value: { message: message },
|
|
932
|
-
});
|
|
782
|
+
else {
|
|
783
|
+
playbackObserver.setCurrentTime(position);
|
|
933
784
|
}
|
|
934
785
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
if (
|
|
786
|
+
},
|
|
787
|
+
encryptionDataEncountered: function (value) {
|
|
788
|
+
var e_1, _a;
|
|
789
|
+
if (self._decryptionCapabilities.status === "disabled") {
|
|
790
|
+
self._onFatalError(self._decryptionCapabilities.value);
|
|
939
791
|
return;
|
|
940
792
|
}
|
|
941
|
-
if (
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
else {
|
|
945
|
-
textDisplayer.reset();
|
|
946
|
-
}
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
case "stop-text-displayer" /* CoreMessageType.StopTextDisplayer */: {
|
|
950
|
-
if (((_25 = _this._currentContentInfo) === null || _25 === void 0 ? void 0 : _25.contentId) !== msgData.contentId) {
|
|
793
|
+
else if (self._decryptionCapabilities.status === "uninitialized") {
|
|
794
|
+
// Should never happen
|
|
795
|
+
log_1.default.error("Init", "received encryption data without known decryption capabilities");
|
|
951
796
|
return;
|
|
952
797
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
break;
|
|
960
|
-
}
|
|
961
|
-
case "reloading-media-source" /* CoreMessageType.ReloadingMediaSource */:
|
|
962
|
-
{
|
|
963
|
-
if (_this._currentContentInfo === null ||
|
|
964
|
-
_this._currentContentInfo.mediaSourceInfo === null) {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
var mediaSourceId = _this._currentContentInfo.mediaSourceInfo.type === "main"
|
|
968
|
-
? _this._currentContentInfo.mediaSourceInfo.mediaSource.id
|
|
969
|
-
: _this._currentContentInfo.mediaSourceInfo.mediaSourceId;
|
|
970
|
-
if (mediaSourceId !== msgData.mediaSourceId) {
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
reloadMediaSource(msgData.value.timeOffset, msgData.value.minimumPosition, msgData.value.maximumPosition);
|
|
974
|
-
}
|
|
975
|
-
break;
|
|
976
|
-
case "needs-decipherability-flush" /* CoreMessageType.NeedsDecipherabilityFlush */:
|
|
977
|
-
{
|
|
978
|
-
if (((_26 = _this._currentContentInfo) === null || _26 === void 0 ? void 0 : _26.contentId) !== msgData.contentId) {
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
var keySystem = (0, decrypt_1.getKeySystemConfiguration)(mediaElement);
|
|
982
|
-
if ((0, should_reload_media_source_on_decipherability_update_1.default)(keySystem === null || keySystem === void 0 ? void 0 : keySystem[0])) {
|
|
983
|
-
notifyAndStartMediaSourceReload(0, undefined, undefined);
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
var lastObservation = playbackObserver.getReference().getValue();
|
|
987
|
-
var currentPosition = lastObservation.position.getWanted();
|
|
988
|
-
// simple seek close to the current position
|
|
989
|
-
// to flush the buffers
|
|
990
|
-
if (currentPosition + 0.001 < lastObservation.duration) {
|
|
991
|
-
playbackObserver.setCurrentTime(mediaElement.currentTime + 0.001);
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
playbackObserver.setCurrentTime(currentPosition);
|
|
798
|
+
try {
|
|
799
|
+
for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
800
|
+
var protectionData = value_1_1.value;
|
|
801
|
+
self._decryptionCapabilities.value.onInitializationData(protectionData);
|
|
802
|
+
if (cancelSignal.isCancelled()) {
|
|
803
|
+
return; // Previous call has stopped streams due to a side-effect
|
|
995
804
|
}
|
|
996
805
|
}
|
|
997
806
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
var sinkObj = _this._awaitingRequests.pendingSinkMetrics.get(msgData.value.requestId);
|
|
1004
|
-
if (sinkObj !== undefined) {
|
|
1005
|
-
sinkObj.resolve(msgData.value.segmentSinkMetrics);
|
|
1006
|
-
}
|
|
1007
|
-
else {
|
|
1008
|
-
log_1.default.error("Init", "Failed to send segment sink store update");
|
|
1009
|
-
}
|
|
1010
|
-
break;
|
|
1011
|
-
}
|
|
1012
|
-
case "init-success" /* CoreMessageType.InitSuccess */:
|
|
1013
|
-
case "init-error" /* CoreMessageType.InitError */:
|
|
1014
|
-
// Should already be handled by the API
|
|
1015
|
-
break;
|
|
1016
|
-
case "log" /* CoreMessageType.LogMessage */:
|
|
1017
|
-
// Already handled by prepare's handler
|
|
1018
|
-
break;
|
|
1019
|
-
case "thumbnail-response" /* CoreMessageType.ThumbnailDataResponse */: {
|
|
1020
|
-
if (((_28 = _this._currentContentInfo) === null || _28 === void 0 ? void 0 : _28.contentId) !== msgData.contentId) {
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
var tObj = _this._awaitingRequests.pendingThumbnailFetching.get(msgData.value.requestId);
|
|
1024
|
-
if (tObj !== undefined) {
|
|
1025
|
-
if (msgData.value.status === "error") {
|
|
1026
|
-
tObj.reject(formatCoreError(msgData.value.error));
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
tObj.resolve(msgData.value.data);
|
|
807
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
808
|
+
finally {
|
|
809
|
+
try {
|
|
810
|
+
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
1030
811
|
}
|
|
812
|
+
finally { if (e_1) throw e_1.error; }
|
|
1031
813
|
}
|
|
1032
|
-
else {
|
|
1033
|
-
log_1.default.error("Init", "Failed to send segment sink store update");
|
|
1034
|
-
}
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
default:
|
|
1038
|
-
(0, assert_1.assertUnreachable)(msgData);
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
log_1.default.debug("Init", "addEventListener for core message");
|
|
1042
|
-
if (this._queuedCoreMessages !== null) {
|
|
1043
|
-
var bufferedMessages = this._queuedCoreMessages.slice();
|
|
1044
|
-
log_1.default.debug("Init", "Processing buffered messages", {
|
|
1045
|
-
ammount: bufferedMessages.length,
|
|
1046
|
-
});
|
|
1047
|
-
try {
|
|
1048
|
-
for (var bufferedMessages_1 = __values(bufferedMessages), bufferedMessages_1_1 = bufferedMessages_1.next(); !bufferedMessages_1_1.done; bufferedMessages_1_1 = bufferedMessages_1.next()) {
|
|
1049
|
-
var message = bufferedMessages_1_1.value;
|
|
1050
|
-
onmessage(message);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1054
|
-
finally {
|
|
1055
|
-
try {
|
|
1056
|
-
if (bufferedMessages_1_1 && !bufferedMessages_1_1.done && (_a = bufferedMessages_1.return)) _a.call(bufferedMessages_1);
|
|
1057
|
-
}
|
|
1058
|
-
finally { if (e_1) throw e_1.error; }
|
|
1059
|
-
}
|
|
1060
|
-
this._queuedCoreMessages = null;
|
|
1061
|
-
}
|
|
1062
|
-
this._settings.coreInterface.addMessageListener(onmessage);
|
|
1063
|
-
this._initCanceller.signal.register(function () {
|
|
1064
|
-
log_1.default.debug("Init", "removeEventListener for core message");
|
|
1065
|
-
_this._settings.coreInterface.removeMessageListener(onmessage);
|
|
1066
|
-
});
|
|
1067
|
-
};
|
|
1068
|
-
MediaSourceContentInitializer.prototype.dispose = function () {
|
|
1069
|
-
var _a;
|
|
1070
|
-
this._initCanceller.cancel();
|
|
1071
|
-
if (this._currentContentInfo !== null) {
|
|
1072
|
-
if (((_a = this._currentContentInfo.mediaSourceInfo) === null || _a === void 0 ? void 0 : _a.type) === "main") {
|
|
1073
|
-
this._currentContentInfo.mediaSourceInfo.mediaSource.dispose();
|
|
1074
|
-
}
|
|
1075
|
-
this._currentContentInfo = null;
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
MediaSourceContentInitializer.prototype._onFatalError = function (err) {
|
|
1079
|
-
if (this._initCanceller.isUsed()) {
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
this._initCanceller.cancel();
|
|
1083
|
-
this.trigger("error", err);
|
|
1084
|
-
};
|
|
1085
|
-
MediaSourceContentInitializer.prototype._initializeContentDecryption = function (mediaElement, lastContentProtection, mediaSourceStatus, reloadMediaSource, cancelSignal) {
|
|
1086
|
-
var _this = this;
|
|
1087
|
-
var _a;
|
|
1088
|
-
var keySystems = this._settings.keySystems;
|
|
1089
|
-
// TODO private?
|
|
1090
|
-
var createEmeDisabledReference = function (errMsg) {
|
|
1091
|
-
mediaSourceStatus.setValue(1 /* MediaSourceInitializationStatus.AttachNow */);
|
|
1092
|
-
lastContentProtection.onUpdate(function (data, stopListening) {
|
|
1093
|
-
if (data === null) {
|
|
1094
|
-
// initial value
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
stopListening();
|
|
1098
|
-
var err = new errors_1.EncryptedMediaError("MEDIA_IS_ENCRYPTED_ERROR", errMsg, {
|
|
1099
|
-
keyStatuses: undefined,
|
|
1100
|
-
keySystemConfiguration: undefined,
|
|
1101
|
-
keySystem: undefined,
|
|
1102
|
-
});
|
|
1103
|
-
_this._onFatalError(err);
|
|
1104
|
-
}, { clearSignal: cancelSignal });
|
|
1105
|
-
var ref = new reference_1.default({
|
|
1106
|
-
initializationState: {
|
|
1107
|
-
type: "initialized",
|
|
1108
|
-
value: null,
|
|
1109
814
|
},
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
});
|
|
1113
|
-
ref.finish(); // We know that no new value will be triggered
|
|
1114
|
-
return { statusRef: ref, contentDecryptor: null };
|
|
1115
|
-
};
|
|
1116
|
-
if (keySystems.length === 0) {
|
|
1117
|
-
return createEmeDisabledReference("No `keySystems` option given.");
|
|
1118
|
-
}
|
|
1119
|
-
else if (features_1.default.decrypt === null) {
|
|
1120
|
-
return createEmeDisabledReference("EME feature not activated.");
|
|
1121
|
-
}
|
|
1122
|
-
var emeApi = (_a = mediaElement.FORCED_EME_API) !== null && _a !== void 0 ? _a : (0, eme_1.default)("auto");
|
|
1123
|
-
if (emeApi === null) {
|
|
1124
|
-
return createEmeDisabledReference("EME API not available on the current page.");
|
|
815
|
+
error: function (err) { return self._onFatalError(err); },
|
|
816
|
+
};
|
|
1125
817
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
contentDecryptor.addEventListener("keyIdsCompatibilityUpdate", function (updates) {
|
|
1146
|
-
if (_this._currentContentInfo === null ||
|
|
1147
|
-
_this._currentContentInfo.manifest === null) {
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
var manUpdates = (0, manifest_1.updateDecipherabilityFromKeyIds)(_this._currentContentInfo.manifest, updates);
|
|
1151
|
-
if ((0, may_media_element_fail_on_undecipherable_data_1.default)() &&
|
|
1152
|
-
manUpdates.some(function (e) { return e.representation.decipherable !== true; })) {
|
|
1153
|
-
reloadMediaSource();
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
_this._settings.coreInterface.sendMessage({
|
|
1157
|
-
type: "decipherability-update" /* MainThreadMessageType.DecipherabilityStatusUpdate */,
|
|
1158
|
-
contentId: _this._currentContentInfo.contentId,
|
|
1159
|
-
value: manUpdates.map(function (s) { return ({
|
|
1160
|
-
representationUniqueId: s.representation.uniqueId,
|
|
1161
|
-
decipherable: s.representation.decipherable,
|
|
1162
|
-
}); }),
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
_this.trigger("decipherabilityUpdate", manUpdates);
|
|
1166
|
-
});
|
|
1167
|
-
contentDecryptor.addEventListener("blackListProtectionData", function (protData) {
|
|
1168
|
-
if (_this._currentContentInfo === null ||
|
|
1169
|
-
_this._currentContentInfo.manifest === null) {
|
|
1170
|
-
return;
|
|
1171
|
-
}
|
|
1172
|
-
var manUpdates = (0, manifest_1.updateDecipherabilityFromProtectionData)(_this._currentContentInfo.manifest, protData);
|
|
1173
|
-
if ((0, may_media_element_fail_on_undecipherable_data_1.default)() &&
|
|
1174
|
-
manUpdates.some(function (e) { return e.representation.decipherable !== true; })) {
|
|
1175
|
-
reloadMediaSource();
|
|
1176
|
-
}
|
|
1177
|
-
else {
|
|
1178
|
-
_this._settings.coreInterface.sendMessage({
|
|
1179
|
-
type: "decipherability-update" /* MainThreadMessageType.DecipherabilityStatusUpdate */,
|
|
1180
|
-
contentId: _this._currentContentInfo.contentId,
|
|
1181
|
-
value: manUpdates.map(function (s) { return ({
|
|
1182
|
-
representationUniqueId: s.representation.uniqueId,
|
|
1183
|
-
decipherable: s.representation.decipherable,
|
|
1184
|
-
}); }),
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
_this.trigger("decipherabilityUpdate", manUpdates);
|
|
1188
|
-
});
|
|
1189
|
-
contentDecryptor.addEventListener("stateChange", function (state) {
|
|
1190
|
-
if (state === decrypt_1.ContentDecryptorState.WaitingForAttachment) {
|
|
1191
|
-
mediaSourceStatus.onUpdate(function (currStatus, stopListening) {
|
|
1192
|
-
if (currStatus === 0 /* MediaSourceInitializationStatus.Nothing */) {
|
|
1193
|
-
mediaSourceStatus.setValue(1 /* MediaSourceInitializationStatus.AttachNow */);
|
|
1194
|
-
}
|
|
1195
|
-
else if (currStatus === 2 /* MediaSourceInitializationStatus.Attached */) {
|
|
1196
|
-
stopListening();
|
|
1197
|
-
if (state === decrypt_1.ContentDecryptorState.WaitingForAttachment) {
|
|
1198
|
-
contentDecryptor.attach();
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}, { clearSignal: cancelSignal, emitCurrentValue: true });
|
|
1202
|
-
}
|
|
1203
|
-
else if (state === decrypt_1.ContentDecryptorState.ReadyForContent) {
|
|
1204
|
-
drmStatusRef.setValue({
|
|
1205
|
-
initializationState: { type: "initialized", value: null },
|
|
1206
|
-
drmSystemId: contentDecryptor.systemId,
|
|
1207
|
-
});
|
|
1208
|
-
contentDecryptor.removeEventListener("stateChange");
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
contentDecryptor.addEventListener("error", function (error) {
|
|
1212
|
-
_this._onFatalError(error);
|
|
1213
|
-
});
|
|
1214
|
-
contentDecryptor.addEventListener("warning", function (error) {
|
|
1215
|
-
_this.trigger("warning", error);
|
|
1216
|
-
});
|
|
1217
|
-
lastContentProtection.onUpdate(function (data) {
|
|
1218
|
-
if (data === null) {
|
|
1219
|
-
return;
|
|
818
|
+
/**
|
|
819
|
+
* Callback allowing to reload the current content.
|
|
820
|
+
* @param {number} deltaPosition - Position you want to seek to after
|
|
821
|
+
* reloading, as a delta in seconds from the last polled playing position.
|
|
822
|
+
* @param {number|undefined} minimumPosition - If set, minimum time bound
|
|
823
|
+
* in seconds after `deltaPosition` has been applied.
|
|
824
|
+
* @param {number|undefined} maximumPosition - If set, minimum time bound
|
|
825
|
+
* in seconds after `deltaPosition` has been applied.
|
|
826
|
+
*/
|
|
827
|
+
function reloadMediaSource(deltaPosition, minimumPosition, maximumPosition) {
|
|
828
|
+
var _a, _b, _c;
|
|
829
|
+
var lastObservation = coreObserver.getReference().getValue();
|
|
830
|
+
var currentPosition = lastObservation.position.isAwaitingFuturePosition()
|
|
831
|
+
? lastObservation.position.getWanted()
|
|
832
|
+
: ((_a = coreObserver.getCurrentTime()) !== null && _a !== void 0 ? _a : lastObservation.position.getPolled());
|
|
833
|
+
var isPaused = (_c = (_b = lastObservation.paused.pending) !== null && _b !== void 0 ? _b : coreObserver.getIsPaused()) !== null && _c !== void 0 ? _c : lastObservation.paused.last;
|
|
834
|
+
var position = currentPosition + deltaPosition;
|
|
835
|
+
if (minimumPosition !== undefined) {
|
|
836
|
+
position = Math.max(minimumPosition, position);
|
|
1220
837
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
cancelSignal.register(function () {
|
|
1224
|
-
contentDecryptor.dispose();
|
|
1225
|
-
});
|
|
1226
|
-
return { statusRef: drmStatusRef, contentDecryptor: contentDecryptor };
|
|
1227
|
-
};
|
|
1228
|
-
/**
|
|
1229
|
-
* Retrieves all unknown codecs from the current manifest, checks these unknown codecs
|
|
1230
|
-
* to determine if they are supported, updates the manifest with the support
|
|
1231
|
-
* status of these codecs, and forwards the list of supported codecs to core.
|
|
1232
|
-
* @param manifest
|
|
1233
|
-
*/
|
|
1234
|
-
MediaSourceContentInitializer.prototype._updateCodecSupport = function (manifest, mediaElement) {
|
|
1235
|
-
var _a, _b, _c, _d;
|
|
1236
|
-
try {
|
|
1237
|
-
var updatedCodecs = (0, update_manifest_codec_support_1.updateManifestCodecSupport)(manifest, (_b = (_a = this._currentContentInfo) === null || _a === void 0 ? void 0 : _a.contentDecryptor) !== null && _b !== void 0 ? _b : null, mediaElement, (_d = (_c = this._currentContentInfo) === null || _c === void 0 ? void 0 : _c.useMseInWorker) !== null && _d !== void 0 ? _d : false);
|
|
1238
|
-
if (updatedCodecs.length > 0) {
|
|
1239
|
-
this._settings.coreInterface.sendMessage({
|
|
1240
|
-
type: "codec-support-update" /* MainThreadMessageType.CodecSupportUpdate */,
|
|
1241
|
-
value: updatedCodecs,
|
|
1242
|
-
});
|
|
1243
|
-
// TODO what if one day the core updates codec support by itself?
|
|
1244
|
-
// We wouldn't know...
|
|
1245
|
-
this.trigger("codecSupportUpdate", null);
|
|
838
|
+
if (maximumPosition !== undefined) {
|
|
839
|
+
position = Math.min(maximumPosition, position);
|
|
1246
840
|
}
|
|
841
|
+
onReloadOrder({ position: position, autoPlay: !isPaused });
|
|
1247
842
|
}
|
|
1248
|
-
catch (err) {
|
|
1249
|
-
this._onFatalError(err);
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
MediaSourceContentInitializer.prototype._hasTextBufferFeature = function () {
|
|
1253
|
-
return ((this._settings.textTrackOptions.textTrackMode === "html" &&
|
|
1254
|
-
features_1.default.htmlTextDisplayer !== null) ||
|
|
1255
|
-
features_1.default.nativeTextDisplayer !== null);
|
|
1256
|
-
};
|
|
1257
|
-
MediaSourceContentInitializer.prototype._reload = function (mediaElement, textDisplayer, playbackObserver, mediaSourceStatus, position, autoPlay) {
|
|
1258
|
-
var _this = this;
|
|
1259
|
-
this._currentMediaSourceCanceller.cancel();
|
|
1260
|
-
this._currentMediaSourceCanceller = new task_canceller_1.default();
|
|
1261
|
-
this._currentMediaSourceCanceller.linkToSignal(this._initCanceller.signal);
|
|
1262
|
-
mediaSourceStatus.setValue(1 /* MediaSourceInitializationStatus.AttachNow */);
|
|
1263
|
-
this.trigger("reloadingMediaSource", { position: position, autoPlay: autoPlay });
|
|
1264
|
-
mediaSourceStatus.onUpdate(function (status, stopListeningMSStatusUpdates) {
|
|
1265
|
-
if (status !== 2 /* MediaSourceInitializationStatus.Attached */) {
|
|
1266
|
-
return;
|
|
1267
|
-
}
|
|
1268
|
-
stopListeningMSStatusUpdates();
|
|
1269
|
-
var corePlaybackObserver = _this._setUpModulesOnNewMediaSource({
|
|
1270
|
-
initialTime: position,
|
|
1271
|
-
autoPlay: autoPlay,
|
|
1272
|
-
mediaElement: mediaElement,
|
|
1273
|
-
textDisplayer: textDisplayer,
|
|
1274
|
-
playbackObserver: playbackObserver,
|
|
1275
|
-
}, _this._currentMediaSourceCanceller.signal);
|
|
1276
|
-
if (!_this._currentMediaSourceCanceller.isUsed() &&
|
|
1277
|
-
corePlaybackObserver !== null &&
|
|
1278
|
-
_this._currentContentInfo !== null) {
|
|
1279
|
-
var contentId_1 = _this._currentContentInfo.contentId;
|
|
1280
|
-
corePlaybackObserver.listen(function (obs) {
|
|
1281
|
-
_this._settings.coreInterface.sendMessage({
|
|
1282
|
-
type: "observation" /* MainThreadMessageType.PlaybackObservation */,
|
|
1283
|
-
contentId: contentId_1,
|
|
1284
|
-
value: (0, object_assign_1.default)(obs, {
|
|
1285
|
-
position: obs.position.serialize(),
|
|
1286
|
-
}),
|
|
1287
|
-
});
|
|
1288
|
-
}, {
|
|
1289
|
-
includeLastObservation: true,
|
|
1290
|
-
clearSignal: _this._currentMediaSourceCanceller.signal,
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
}, {
|
|
1294
|
-
clearSignal: this._currentMediaSourceCanceller.signal,
|
|
1295
|
-
emitCurrentValue: true,
|
|
1296
|
-
});
|
|
1297
843
|
};
|
|
1298
844
|
/**
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1301
|
-
* manifest is known.
|
|
845
|
+
* Creates a `RebufferingController`, a class trying to avoid various stalling
|
|
846
|
+
* situations (such as rebuffering periods), and returns it.
|
|
1302
847
|
*
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
848
|
+
* Various methods from that class need then to be called at various events
|
|
849
|
+
* (see `RebufferingController` definition).
|
|
1305
850
|
*
|
|
1306
|
-
*
|
|
851
|
+
* This function also handles the `RebufferingController`'s events:
|
|
852
|
+
* - emit "stalled" events when stalling situations cannot be prevented,
|
|
853
|
+
* - emit "unstalled" events when we could get out of one,
|
|
854
|
+
* - emit "warning" on various rebuffering-related minor issues
|
|
855
|
+
* like discontinuity skipping.
|
|
856
|
+
* @param {Object} playbackObserver
|
|
857
|
+
* @param {Object} manifest
|
|
858
|
+
* @param {Object} speed
|
|
1307
859
|
* @param {Object} cancelSignal
|
|
1308
|
-
* @returns {Object
|
|
1309
|
-
* only if playback initialization failed (most likely because it has been
|
|
1310
|
-
* cancelled).
|
|
860
|
+
* @returns {Object}
|
|
1311
861
|
*/
|
|
1312
|
-
MediaSourceContentInitializer.prototype.
|
|
862
|
+
MediaSourceContentInitializer.prototype._createRebufferingController = function (playbackObserver, manifest, speed, cancelSignal) {
|
|
1313
863
|
var _this = this;
|
|
1314
|
-
if (cancelSignal.isCancelled()) {
|
|
1315
|
-
return null;
|
|
1316
|
-
}
|
|
1317
|
-
if (this._currentContentInfo === null) {
|
|
1318
|
-
log_1.default.error("Init", "Setting up modules without a contentId");
|
|
1319
|
-
return null;
|
|
1320
|
-
}
|
|
1321
|
-
if (this._currentContentInfo.manifest === null) {
|
|
1322
|
-
log_1.default.error("Init", "Setting up modules without a loaded Manifest");
|
|
1323
|
-
return null;
|
|
1324
|
-
}
|
|
1325
|
-
var _a = this._currentContentInfo, manifest = _a.manifest, mediaSourceInfo = _a.mediaSourceInfo;
|
|
1326
|
-
var speed = this._settings.speed;
|
|
1327
|
-
var initialTime = parameters.initialTime, autoPlay = parameters.autoPlay, mediaElement = parameters.mediaElement, textDisplayer = parameters.textDisplayer, playbackObserver = parameters.playbackObserver;
|
|
1328
|
-
this._currentContentInfo.initialTime = initialTime;
|
|
1329
|
-
this._currentContentInfo.autoPlay = autoPlay;
|
|
1330
|
-
var _b = (0, initial_seek_and_play_1.default)({
|
|
1331
|
-
mediaElement: mediaElement,
|
|
1332
|
-
playbackObserver: playbackObserver,
|
|
1333
|
-
startTime: initialTime,
|
|
1334
|
-
mustAutoPlay: autoPlay,
|
|
1335
|
-
onWarning: function (err) { return _this.trigger("warning", err); },
|
|
1336
|
-
isDirectfile: false,
|
|
1337
|
-
}, cancelSignal), autoPlayResult = _b.autoPlayResult, initialPlayPerformed = _b.initialPlayPerformed;
|
|
1338
|
-
this._currentContentInfo.initialPlayPerformed = initialPlayPerformed;
|
|
1339
|
-
var corePlaybackObserver = (0, create_core_playback_observer_1.default)(playbackObserver, {
|
|
1340
|
-
autoPlay: autoPlay,
|
|
1341
|
-
initialPlayPerformed: initialPlayPerformed,
|
|
1342
|
-
manifest: manifest,
|
|
1343
|
-
mediaSource: (mediaSourceInfo === null || mediaSourceInfo === void 0 ? void 0 : mediaSourceInfo.type) === "main" ? mediaSourceInfo.mediaSource : null,
|
|
1344
|
-
speed: speed,
|
|
1345
|
-
textDisplayer: textDisplayer,
|
|
1346
|
-
}, cancelSignal);
|
|
1347
|
-
if (cancelSignal.isCancelled()) {
|
|
1348
|
-
return null;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Class trying to avoid various stalling situations, emitting "stalled"
|
|
1352
|
-
* events when it cannot, as well as "unstalled" events when it get out of one.
|
|
1353
|
-
*/
|
|
1354
864
|
var rebufferingController = new rebuffering_controller_1.default(playbackObserver, manifest, speed);
|
|
865
|
+
// Bubble-up events
|
|
1355
866
|
rebufferingController.addEventListener("stalled", function (evt) {
|
|
1356
867
|
return _this.trigger("stalled", evt);
|
|
1357
868
|
});
|
|
@@ -1361,355 +872,271 @@ var MediaSourceContentInitializer = /** @class */ (function (_super) {
|
|
|
1361
872
|
rebufferingController.addEventListener("warning", function (err) {
|
|
1362
873
|
return _this.trigger("warning", err);
|
|
1363
874
|
});
|
|
1364
|
-
cancelSignal.register(function () {
|
|
1365
|
-
rebufferingController.destroy();
|
|
1366
|
-
});
|
|
875
|
+
cancelSignal.register(function () { return rebufferingController.destroy(); });
|
|
1367
876
|
rebufferingController.start();
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
877
|
+
return rebufferingController;
|
|
878
|
+
};
|
|
879
|
+
/**
|
|
880
|
+
* Evaluates a list of codecs to determine their support status.
|
|
881
|
+
*
|
|
882
|
+
* @param {Array} codecsToCheck - The list of codecs to check.
|
|
883
|
+
* @returns {Array} - The list of evaluated codecs with their support status updated.
|
|
884
|
+
*/
|
|
885
|
+
MediaSourceContentInitializer.prototype.getCodecsSupportInfo = function (codecsToCheck, mediaElement) {
|
|
886
|
+
var _this = this;
|
|
887
|
+
var codecsSupportInfo = codecsToCheck.map(function (codecToCheck) {
|
|
888
|
+
var _a;
|
|
889
|
+
var inputCodec = "".concat(codecToCheck.mimeType, ";codecs=\"").concat(codecToCheck.codec, "\"");
|
|
890
|
+
var isSupported = (0, is_codec_supported_1.default)(mediaElement, inputCodec);
|
|
891
|
+
if (!isSupported) {
|
|
892
|
+
return {
|
|
893
|
+
mimeType: codecToCheck.mimeType,
|
|
894
|
+
codec: codecToCheck.codec,
|
|
895
|
+
supported: false,
|
|
896
|
+
supportedIfEncrypted: false,
|
|
897
|
+
};
|
|
1385
898
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
_this._awaitingRequests.pendingSinkMetrics.delete(requestId);
|
|
1407
|
-
resolve(value);
|
|
1408
|
-
},
|
|
1409
|
-
});
|
|
1410
|
-
cancelSignal.register(rejectFn);
|
|
1411
|
-
})];
|
|
1412
|
-
});
|
|
1413
|
-
}); };
|
|
1414
|
-
var _getThumbnailsData = function (periodId, thumbnailTrackId, time) { return __awaiter(_this, void 0, void 0, function () {
|
|
1415
|
-
var requestId;
|
|
1416
|
-
var _this = this;
|
|
1417
|
-
return __generator(this, function (_a) {
|
|
1418
|
-
if (this._currentContentInfo === null) {
|
|
1419
|
-
return [2 /*return*/, Promise.reject(new Error("Cannot fetch thumbnails: No content loaded."))];
|
|
1420
|
-
}
|
|
1421
|
-
this._awaitingRequests.nextRequestId++;
|
|
1422
|
-
requestId = this._awaitingRequests.nextRequestId;
|
|
1423
|
-
this._settings.coreInterface.sendMessage({
|
|
1424
|
-
type: "thumbnail-request" /* MainThreadMessageType.ThumbnailDataRequest */,
|
|
1425
|
-
contentId: this._currentContentInfo.contentId,
|
|
1426
|
-
value: { requestId: requestId, periodId: periodId, thumbnailTrackId: thumbnailTrackId, time: time },
|
|
1427
|
-
});
|
|
1428
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
1429
|
-
var rejectFn = function (err) {
|
|
1430
|
-
cleanUp();
|
|
1431
|
-
reject(err);
|
|
1432
|
-
};
|
|
1433
|
-
var cleanUp = function () {
|
|
1434
|
-
cancelSignal.deregister(rejectFn);
|
|
1435
|
-
_this._awaitingRequests.pendingThumbnailFetching.delete(requestId);
|
|
1436
|
-
};
|
|
1437
|
-
_this._awaitingRequests.pendingThumbnailFetching.set(requestId, {
|
|
1438
|
-
resolve: function (value) {
|
|
1439
|
-
cleanUp();
|
|
1440
|
-
resolve(value);
|
|
1441
|
-
},
|
|
1442
|
-
reject: function (value) {
|
|
1443
|
-
cleanUp();
|
|
1444
|
-
reject(value);
|
|
1445
|
-
},
|
|
1446
|
-
});
|
|
1447
|
-
cancelSignal.register(rejectFn);
|
|
1448
|
-
})];
|
|
1449
|
-
});
|
|
1450
|
-
}); };
|
|
1451
|
-
/**
|
|
1452
|
-
* Emit a "loaded" events once the initial play has been performed and the
|
|
1453
|
-
* media can begin playback.
|
|
1454
|
-
* Also emits warning events if issues arise when doing so.
|
|
1455
|
-
*/
|
|
1456
|
-
autoPlayResult
|
|
1457
|
-
.then(function () {
|
|
1458
|
-
(0, get_loaded_reference_1.default)(playbackObserver, false, cancelSignal).onUpdate(function (isLoaded, stopListening) {
|
|
1459
|
-
if (isLoaded) {
|
|
1460
|
-
stopListening();
|
|
1461
|
-
_this.trigger("loaded", {
|
|
1462
|
-
getSegmentSinkMetrics: _getSegmentSinkMetrics,
|
|
1463
|
-
getThumbnailData: _getThumbnailsData,
|
|
1464
|
-
});
|
|
899
|
+
/**
|
|
900
|
+
* `true` if the codec is supported when encrypted, `false` if it is not
|
|
901
|
+
* supported, or `undefined` if we cannot obtain that information.
|
|
902
|
+
*/
|
|
903
|
+
var supportedIfEncrypted;
|
|
904
|
+
if (_this._decryptionCapabilities.status === "uninitialized") {
|
|
905
|
+
supportedIfEncrypted = undefined;
|
|
906
|
+
}
|
|
907
|
+
else if (_this._decryptionCapabilities.status === "disabled") {
|
|
908
|
+
// It's ambiguous here, but let's say that no ContentDecryptor means that
|
|
909
|
+
// the codec is supported by it.
|
|
910
|
+
supportedIfEncrypted = true;
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
var contentDecryptor = _this._decryptionCapabilities.value;
|
|
914
|
+
if (contentDecryptor.getState() !== decrypt_1.ContentDecryptorState.Initializing) {
|
|
915
|
+
// No information is available regarding the support status.
|
|
916
|
+
// Defaulting to assume the codec is supported.
|
|
917
|
+
supportedIfEncrypted =
|
|
918
|
+
(_a = contentDecryptor.isCodecSupported(codecToCheck.mimeType, codecToCheck.codec)) !== null && _a !== void 0 ? _a : true;
|
|
1465
919
|
}
|
|
1466
|
-
}, { emitCurrentValue: true, clearSignal: cancelSignal });
|
|
1467
|
-
})
|
|
1468
|
-
.catch(function (err) {
|
|
1469
|
-
if (cancelSignal.isCancelled()) {
|
|
1470
|
-
return;
|
|
1471
920
|
}
|
|
1472
|
-
|
|
921
|
+
return {
|
|
922
|
+
mimeType: codecToCheck.mimeType,
|
|
923
|
+
codec: codecToCheck.codec,
|
|
924
|
+
supported: isSupported,
|
|
925
|
+
supportedIfEncrypted: supportedIfEncrypted,
|
|
926
|
+
};
|
|
1473
927
|
});
|
|
1474
|
-
return
|
|
928
|
+
return codecsSupportInfo;
|
|
1475
929
|
};
|
|
1476
930
|
/**
|
|
1477
|
-
*
|
|
1478
|
-
* - The Manifest is fetched and stored in `this._currentContentInfo`.
|
|
1479
|
-
* - `drmInitializationStatus` indicates that DRM matters are initialized.
|
|
1480
|
-
* - `mediaSourceStatus` indicates that the MediaSource is attached to the
|
|
1481
|
-
* `mediaElement`.
|
|
1482
|
-
*
|
|
1483
|
-
* In other cases, this method will do nothing.
|
|
931
|
+
* Update the support status of all Representations in the Manifest.
|
|
1484
932
|
*
|
|
1485
|
-
* To call
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1488
|
-
* @param {Object} parameters
|
|
1489
|
-
* @returns {boolean} - Returns `true` if all conditions where met for
|
|
1490
|
-
* playback start.
|
|
933
|
+
* To call anytime either the Manifest is linked to new codecs or new means
|
|
934
|
+
* to test for codec support are available.
|
|
935
|
+
* @param {Object} manifest
|
|
1491
936
|
*/
|
|
1492
|
-
MediaSourceContentInitializer.prototype.
|
|
1493
|
-
var
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
if (msInitStatus !== 2 /* MediaSourceInitializationStatus.Attached */) {
|
|
1503
|
-
return false;
|
|
1504
|
-
}
|
|
1505
|
-
var _a = this._currentContentInfo, contentId = _a.contentId, manifest = _a.manifest;
|
|
1506
|
-
log_1.default.debug("Init", "Calculating initial time");
|
|
1507
|
-
var initialTime = (0, get_initial_time_1.default)(manifest, this._settings.lowLatencyMode, this._settings.startAt);
|
|
1508
|
-
log_1.default.debug("Init", "Initial time calculated", { initialTime: initialTime });
|
|
1509
|
-
var _b = this._settings.bufferOptions, enableFastSwitching = _b.enableFastSwitching, onCodecSwitch = _b.onCodecSwitch;
|
|
1510
|
-
var corePlaybackObserver = this._setUpModulesOnNewMediaSource({
|
|
1511
|
-
initialTime: initialTime,
|
|
1512
|
-
autoPlay: this._settings.autoPlay,
|
|
1513
|
-
mediaElement: parameters.mediaElement,
|
|
1514
|
-
textDisplayer: parameters.textDisplayer,
|
|
1515
|
-
playbackObserver: parameters.playbackObserver,
|
|
1516
|
-
}, this._currentMediaSourceCanceller.signal);
|
|
1517
|
-
if (this._currentMediaSourceCanceller.isUsed() || corePlaybackObserver === null) {
|
|
1518
|
-
return true;
|
|
937
|
+
MediaSourceContentInitializer.prototype._refreshManifestCodecSupport = function (manifest, mediaElement) {
|
|
938
|
+
var codecsToTest = manifest.getCodecsWithUnknownSupport();
|
|
939
|
+
var codecsSupportInfo = this.getCodecsSupportInfo(codecsToTest, mediaElement);
|
|
940
|
+
if (codecsSupportInfo.length > 0) {
|
|
941
|
+
try {
|
|
942
|
+
manifest.updateCodecSupport(codecsSupportInfo);
|
|
943
|
+
}
|
|
944
|
+
catch (err) {
|
|
945
|
+
this._onFatalError(err);
|
|
946
|
+
}
|
|
1519
947
|
}
|
|
1520
|
-
var initialObservation = corePlaybackObserver.getReference().getValue();
|
|
1521
|
-
var sentInitialObservation = (0, object_assign_1.default)(initialObservation, {
|
|
1522
|
-
position: initialObservation.position.serialize(),
|
|
1523
|
-
});
|
|
1524
|
-
this._settings.coreInterface.sendMessage({
|
|
1525
|
-
type: "start" /* MainThreadMessageType.StartPreparedContent */,
|
|
1526
|
-
contentId: contentId,
|
|
1527
|
-
value: {
|
|
1528
|
-
initialTime: initialTime,
|
|
1529
|
-
initialObservation: sentInitialObservation,
|
|
1530
|
-
drmSystemId: drmInitStatus.drmSystemId,
|
|
1531
|
-
enableFastSwitching: enableFastSwitching,
|
|
1532
|
-
onCodecSwitch: onCodecSwitch,
|
|
1533
|
-
},
|
|
1534
|
-
});
|
|
1535
|
-
corePlaybackObserver.listen(function (obs) {
|
|
1536
|
-
_this._settings.coreInterface.sendMessage({
|
|
1537
|
-
type: "observation" /* MainThreadMessageType.PlaybackObservation */,
|
|
1538
|
-
contentId: contentId,
|
|
1539
|
-
value: (0, object_assign_1.default)(obs, { position: obs.position.serialize() }),
|
|
1540
|
-
});
|
|
1541
|
-
}, {
|
|
1542
|
-
includeLastObservation: false,
|
|
1543
|
-
clearSignal: this._currentMediaSourceCanceller.signal,
|
|
1544
|
-
});
|
|
1545
|
-
this.trigger("manifestReady", manifest);
|
|
1546
|
-
return true;
|
|
1547
948
|
};
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
949
|
+
return MediaSourceContentInitializer;
|
|
950
|
+
}(types_1.ContentInitializer));
|
|
951
|
+
exports.default = MediaSourceContentInitializer;
|
|
952
|
+
function createTextDisplayer(mediaElement, textTrackOptions) {
|
|
953
|
+
if (textTrackOptions.textTrackMode === "html" && features_1.default.htmlTextDisplayer !== null) {
|
|
954
|
+
return new features_1.default.htmlTextDisplayer(mediaElement, textTrackOptions.textTrackElement);
|
|
955
|
+
}
|
|
956
|
+
else if (features_1.default.nativeTextDisplayer !== null) {
|
|
957
|
+
return new features_1.default.nativeTextDisplayer(mediaElement);
|
|
958
|
+
}
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Change the decipherability of Representations which have their key id in one
|
|
963
|
+
* of the given Arrays:
|
|
964
|
+
*
|
|
965
|
+
* - Those who have a key id listed in `whitelistedKeyIds` will have their
|
|
966
|
+
* decipherability updated to `true`
|
|
967
|
+
*
|
|
968
|
+
* - Those who have a key id listed in `blacklistedKeyIds` will have their
|
|
969
|
+
* decipherability updated to `false`
|
|
970
|
+
*
|
|
971
|
+
* - Those who have a key id listed in `delistedKeyIds` will have their
|
|
972
|
+
* decipherability updated to `undefined`.
|
|
973
|
+
*
|
|
974
|
+
* @param {Object} manifest
|
|
975
|
+
* @param {Array.<Uint8Array>} whitelistedKeyIds
|
|
976
|
+
* @param {Array.<Uint8Array>} blacklistedKeyIds
|
|
977
|
+
* @param {Array.<Uint8Array>} delistedKeyIds
|
|
978
|
+
*/
|
|
979
|
+
function updateKeyIdsDecipherabilityOnManifest(manifest, whitelistedKeyIds, blacklistedKeyIds, delistedKeyIds) {
|
|
980
|
+
manifest.updateRepresentationsDeciperability(function (ctx) {
|
|
981
|
+
var e_2, _a, e_3, _b, e_4, _c, e_5, _d;
|
|
982
|
+
var representation = ctx.representation;
|
|
983
|
+
if (representation.contentProtections === undefined) {
|
|
984
|
+
return representation.decipherable;
|
|
1560
985
|
}
|
|
1561
|
-
|
|
1562
|
-
|
|
986
|
+
var contentKIDs = representation.contentProtections.keyIds;
|
|
987
|
+
if (contentKIDs !== undefined) {
|
|
1563
988
|
try {
|
|
1564
|
-
|
|
1565
|
-
var
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
989
|
+
for (var contentKIDs_1 = __values(contentKIDs), contentKIDs_1_1 = contentKIDs_1.next(); !contentKIDs_1_1.done; contentKIDs_1_1 = contentKIDs_1.next()) {
|
|
990
|
+
var elt = contentKIDs_1_1.value;
|
|
991
|
+
try {
|
|
992
|
+
for (var blacklistedKeyIds_1 = (e_3 = void 0, __values(blacklistedKeyIds)), blacklistedKeyIds_1_1 = blacklistedKeyIds_1.next(); !blacklistedKeyIds_1_1.done; blacklistedKeyIds_1_1 = blacklistedKeyIds_1.next()) {
|
|
993
|
+
var blacklistedKeyId = blacklistedKeyIds_1_1.value;
|
|
994
|
+
if ((0, are_arrays_of_numbers_equal_1.default)(blacklistedKeyId, elt)) {
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
1569
998
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
: undefined);
|
|
1575
|
-
if (((_a = _this._currentContentInfo.mediaSourceInfo) === null || _a === void 0 ? void 0 : _a.type) === "main") {
|
|
1576
|
-
_this._currentContentInfo.mediaSourceInfo.mediaSource.dispose();
|
|
999
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1000
|
+
finally {
|
|
1001
|
+
try {
|
|
1002
|
+
if (blacklistedKeyIds_1_1 && !blacklistedKeyIds_1_1.done && (_b = blacklistedKeyIds_1.return)) _b.call(blacklistedKeyIds_1);
|
|
1577
1003
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
value: "open",
|
|
1587
|
-
});
|
|
1588
|
-
});
|
|
1589
|
-
mediaSource_3.addEventListener("mediaSourceEnded", function () {
|
|
1590
|
-
coreInterface.sendMessage({
|
|
1591
|
-
type: "media-source-ready-state-change" /* MainThreadMessageType.MediaSourceReadyStateChange */,
|
|
1592
|
-
mediaSourceId: mediaSourceId_1,
|
|
1593
|
-
value: "ended",
|
|
1594
|
-
});
|
|
1595
|
-
});
|
|
1596
|
-
mediaSource_3.addEventListener("mediaSourceClose", function () {
|
|
1597
|
-
coreInterface.sendMessage({
|
|
1598
|
-
type: "media-source-ready-state-change" /* MainThreadMessageType.MediaSourceReadyStateChange */,
|
|
1599
|
-
mediaSourceId: mediaSourceId_1,
|
|
1600
|
-
value: "closed",
|
|
1601
|
-
});
|
|
1602
|
-
});
|
|
1603
|
-
var url_1 = null;
|
|
1604
|
-
if (mediaSource_3.handle.type === "handle") {
|
|
1605
|
-
mediaElement.srcObject = mediaSource_3.handle.value;
|
|
1004
|
+
finally { if (e_3) throw e_3.error; }
|
|
1005
|
+
}
|
|
1006
|
+
try {
|
|
1007
|
+
for (var whitelistedKeyIds_1 = (e_4 = void 0, __values(whitelistedKeyIds)), whitelistedKeyIds_1_1 = whitelistedKeyIds_1.next(); !whitelistedKeyIds_1_1.done; whitelistedKeyIds_1_1 = whitelistedKeyIds_1.next()) {
|
|
1008
|
+
var whitelistedKeyId = whitelistedKeyIds_1_1.value;
|
|
1009
|
+
if ((0, are_arrays_of_numbers_equal_1.default)(whitelistedKeyId, elt)) {
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1606
1012
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1013
|
+
}
|
|
1014
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1015
|
+
finally {
|
|
1016
|
+
try {
|
|
1017
|
+
if (whitelistedKeyIds_1_1 && !whitelistedKeyIds_1_1.done && (_c = whitelistedKeyIds_1.return)) _c.call(whitelistedKeyIds_1);
|
|
1610
1018
|
}
|
|
1611
|
-
|
|
1612
|
-
mediaSource_3.dispose();
|
|
1613
|
-
(0, create_media_source_1.resetMediaElement)(mediaElement, url_1);
|
|
1614
|
-
});
|
|
1615
|
-
mediaSourceStatus.setValue(2 /* MediaSourceInitializationStatus.Attached */);
|
|
1616
|
-
(0, create_media_source_1.disableRemotePlaybackOnManagedMediaSource)(mediaElement, _this._currentMediaSourceCanceller.signal);
|
|
1019
|
+
finally { if (e_4) throw e_4.error; }
|
|
1617
1020
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1021
|
+
try {
|
|
1022
|
+
for (var delistedKeyIds_1 = (e_5 = void 0, __values(delistedKeyIds)), delistedKeyIds_1_1 = delistedKeyIds_1.next(); !delistedKeyIds_1_1.done; delistedKeyIds_1_1 = delistedKeyIds_1.next()) {
|
|
1023
|
+
var delistedKeyId = delistedKeyIds_1_1.value;
|
|
1024
|
+
if ((0, are_arrays_of_numbers_equal_1.default)(delistedKeyId, elt)) {
|
|
1025
|
+
return undefined;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1030
|
+
finally {
|
|
1031
|
+
try {
|
|
1032
|
+
if (delistedKeyIds_1_1 && !delistedKeyIds_1_1.done && (_d = delistedKeyIds_1.return)) _d.call(delistedKeyIds_1);
|
|
1033
|
+
}
|
|
1034
|
+
finally { if (e_5) throw e_5.error; }
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1622
1037
|
}
|
|
1623
|
-
catch (
|
|
1624
|
-
|
|
1625
|
-
|
|
1038
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1039
|
+
finally {
|
|
1040
|
+
try {
|
|
1041
|
+
if (contentKIDs_1_1 && !contentKIDs_1_1.done && (_a = contentKIDs_1.return)) _a.call(contentKIDs_1);
|
|
1042
|
+
}
|
|
1043
|
+
finally { if (e_2) throw e_2.error; }
|
|
1626
1044
|
}
|
|
1627
1045
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
1645
|
-
value: { name: ref[1], newVal: newVal },
|
|
1646
|
-
});
|
|
1647
|
-
}, { clearSignal: cancellationSignal, emitCurrentValue: true });
|
|
1648
|
-
};
|
|
1649
|
-
try {
|
|
1650
|
-
for (var refs_1 = __values(refs), refs_1_1 = refs_1.next(); !refs_1_1.done; refs_1_1 = refs_1.next()) {
|
|
1651
|
-
var ref = refs_1_1.value;
|
|
1652
|
-
_loop_1(ref);
|
|
1046
|
+
return representation.decipherable;
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Update decipherability to `false` to any Representation which is linked to
|
|
1051
|
+
* the given initialization data.
|
|
1052
|
+
* @param {Object} manifest
|
|
1053
|
+
* @param {Object} initData
|
|
1054
|
+
*/
|
|
1055
|
+
function blackListProtectionDataOnManifest(manifest, initData) {
|
|
1056
|
+
manifest.updateRepresentationsDeciperability(function (ctx) {
|
|
1057
|
+
var e_6, _a;
|
|
1058
|
+
var _b, _c;
|
|
1059
|
+
var rep = ctx.representation;
|
|
1060
|
+
if (rep.decipherable === false) {
|
|
1061
|
+
return false;
|
|
1653
1062
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1063
|
+
var segmentProtections = (_c = (_b = rep.contentProtections) === null || _b === void 0 ? void 0 : _b.initData) !== null && _c !== void 0 ? _c : [];
|
|
1064
|
+
var _loop_1 = function (protection) {
|
|
1065
|
+
if (initData.type === undefined || protection.type === initData.type) {
|
|
1066
|
+
var containedInitData = initData.values
|
|
1067
|
+
.getFormattedValues()
|
|
1068
|
+
.every(function (undecipherableVal) {
|
|
1069
|
+
return protection.values.some(function (currVal) {
|
|
1070
|
+
return ((undecipherableVal.systemId === undefined ||
|
|
1071
|
+
currVal.systemId === undecipherableVal.systemId) &&
|
|
1072
|
+
(0, are_arrays_of_numbers_equal_1.default)(currVal.data, undecipherableVal.data));
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
if (containedInitData) {
|
|
1076
|
+
return { value: false };
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1657
1080
|
try {
|
|
1658
|
-
|
|
1081
|
+
for (var segmentProtections_1 = __values(segmentProtections), segmentProtections_1_1 = segmentProtections_1.next(); !segmentProtections_1_1.done; segmentProtections_1_1 = segmentProtections_1.next()) {
|
|
1082
|
+
var protection = segmentProtections_1_1.value;
|
|
1083
|
+
var state_1 = _loop_1(protection);
|
|
1084
|
+
if (typeof state_1 === "object")
|
|
1085
|
+
return state_1.value;
|
|
1086
|
+
}
|
|
1659
1087
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
return new errors_1.MediaError(sentError.code, sentError.reason, {
|
|
1670
|
-
tracks: sentError.tracks,
|
|
1671
|
-
});
|
|
1672
|
-
case "EncryptedMediaError":
|
|
1673
|
-
// We assume that everything have already been checked Worker-side here
|
|
1674
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1675
|
-
return new errors_1.EncryptedMediaError(sentError.code, sentError.reason, {
|
|
1676
|
-
keyStatuses: sentError.keyStatuses,
|
|
1677
|
-
keySystemConfiguration: sentError.keySystemConfiguration,
|
|
1678
|
-
keySystem: sentError.keySystem,
|
|
1679
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1680
|
-
});
|
|
1681
|
-
case "OtherError":
|
|
1682
|
-
return new errors_1.OtherError(sentError.code, sentError.reason);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
function formatSourceBufferError(error) {
|
|
1686
|
-
if (error instanceof errors_1.SourceBufferError) {
|
|
1687
|
-
return error;
|
|
1688
|
-
}
|
|
1689
|
-
else if (error instanceof Error) {
|
|
1690
|
-
return new errors_1.SourceBufferError(error.name, error.message, error.name === "QuotaExceededError");
|
|
1691
|
-
}
|
|
1692
|
-
else {
|
|
1693
|
-
return new errors_1.SourceBufferError("Error", "Unknown SourceBufferError Error", false);
|
|
1694
|
-
}
|
|
1088
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1089
|
+
finally {
|
|
1090
|
+
try {
|
|
1091
|
+
if (segmentProtections_1_1 && !segmentProtections_1_1.done && (_a = segmentProtections_1.return)) _a.call(segmentProtections_1);
|
|
1092
|
+
}
|
|
1093
|
+
finally { if (e_6) throw e_6.error; }
|
|
1094
|
+
}
|
|
1095
|
+
return rep.decipherable;
|
|
1096
|
+
});
|
|
1695
1097
|
}
|
|
1696
1098
|
/**
|
|
1697
|
-
*
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
* @param {
|
|
1705
|
-
*
|
|
1099
|
+
* Handle accordingly an `IFreezeResolution` object.
|
|
1100
|
+
* @param {Object|null} freezeResolution - The `IFreezeResolution` suggested.
|
|
1101
|
+
* @param {Object} param - Parameters that might be needed to implement the
|
|
1102
|
+
* resolution.
|
|
1103
|
+
* @param {Object} param.manifest - The current content's Manifest object.
|
|
1104
|
+
* @param {Object} param.playbackObserver - Object regularly emitting playback
|
|
1105
|
+
* conditions.
|
|
1106
|
+
* @param {Function} param.triggerReload - Function to call if we need to ask
|
|
1107
|
+
* for a "MediaSource reload".
|
|
1108
|
+
* @param {Boolean} param.enableRepresentationAvoidance - If `true`, this
|
|
1109
|
+
* function is authorized to mark `Representation` as "to avoid" if the
|
|
1110
|
+
* `IFreezeResolution` object suggest it.
|
|
1706
1111
|
*/
|
|
1707
|
-
function
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1112
|
+
function handleFreezeResolution(freezeResolution, _a) {
|
|
1113
|
+
var playbackObserver = _a.playbackObserver, enableRepresentationAvoidance = _a.enableRepresentationAvoidance, manifest = _a.manifest, triggerReload = _a.triggerReload;
|
|
1114
|
+
switch (freezeResolution.type) {
|
|
1115
|
+
case "reload": {
|
|
1116
|
+
log_1.default.info("Init", "Planning reload due to freeze");
|
|
1117
|
+
triggerReload();
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
case "flush": {
|
|
1121
|
+
log_1.default.info("Init", "Flushing buffer due to freeze");
|
|
1122
|
+
var observation = playbackObserver.getReference().getValue();
|
|
1123
|
+
var currentTime = observation.position.isAwaitingFuturePosition()
|
|
1124
|
+
? observation.position.getWanted()
|
|
1125
|
+
: playbackObserver.getCurrentTime();
|
|
1126
|
+
var relativeResumingPosition = freezeResolution.value.relativeSeek;
|
|
1127
|
+
var wantedSeekingTime = currentTime + relativeResumingPosition;
|
|
1128
|
+
playbackObserver.setCurrentTime(wantedSeekingTime);
|
|
1129
|
+
break;
|
|
1130
|
+
}
|
|
1131
|
+
case "avoid-representations": {
|
|
1132
|
+
var contents = freezeResolution.value;
|
|
1133
|
+
if (enableRepresentationAvoidance) {
|
|
1134
|
+
manifest.addRepresentationsToAvoid(contents);
|
|
1135
|
+
}
|
|
1136
|
+
triggerReload();
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
default:
|
|
1140
|
+
(0, assert_1.assertUnreachable)(freezeResolution);
|
|
1713
1141
|
}
|
|
1714
|
-
return arg;
|
|
1715
1142
|
}
|