rx-player 3.33.0 → 3.33.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.
Files changed (819) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/core/api/public_api.js +2 -2
  4. package/dist/_esm5.processed/manifest/manifest.js +1 -0
  5. package/dist/_esm5.processed/utils/retry_promise_with_backoff.d.ts +11 -0
  6. package/dist/_esm5.processed/utils/retry_promise_with_backoff.js +18 -4
  7. package/dist/mpd-parser.wasm +0 -0
  8. package/dist/rx-player.d.ts +1 -1
  9. package/dist/rx-player.js +24 -9
  10. package/dist/rx-player.min.d.ts +1 -1
  11. package/dist/rx-player.min.js +1 -1
  12. package/package.json +6 -6
  13. package/.editorconfig +0 -22
  14. package/.eslintrc.js +0 -406
  15. package/.github/workflows/checks.yml +0 -101
  16. package/.github/workflows/perfs.yml +0 -22
  17. package/.github/workflows/sonarcloud_analysis.yml +0 -20
  18. package/CONTRIBUTING.md +0 -272
  19. package/FILES.md +0 -283
  20. package/jest.config.js +0 -73
  21. package/manifest.mpd +0 -149
  22. package/scripts/README.md +0 -11
  23. package/scripts/build/constants.d.ts +0 -53
  24. package/scripts/build/generate_build.js +0 -190
  25. package/scripts/build/templates/experimental/features/index.d.ts +0 -16
  26. package/scripts/build/templates/experimental/features/index.js +0 -16
  27. package/scripts/build/templates/experimental/index.d.ts +0 -16
  28. package/scripts/build/templates/experimental/index.js +0 -16
  29. package/scripts/build/templates/experimental/tools/VideoThumbnailLoader/index.d.ts +0 -18
  30. package/scripts/build/templates/experimental/tools/VideoThumbnailLoader/index.js +0 -18
  31. package/scripts/build/templates/experimental/tools/index.d.ts +0 -16
  32. package/scripts/build/templates/experimental/tools/index.js +0 -16
  33. package/scripts/build/templates/features/index.d.ts +0 -16
  34. package/scripts/build/templates/features/index.js +0 -16
  35. package/scripts/build/templates/logger/index.d.ts +0 -17
  36. package/scripts/build/templates/logger/index.js +0 -17
  37. package/scripts/build/templates/minimal/index.d.ts +0 -17
  38. package/scripts/build/templates/minimal/index.js +0 -17
  39. package/scripts/build/templates/tools/TextTrackRenderer.d.ts +0 -18
  40. package/scripts/build/templates/tools/TextTrackRenderer.js +0 -18
  41. package/scripts/build/templates/tools/index.d.ts +0 -16
  42. package/scripts/build/templates/tools/index.js +0 -16
  43. package/scripts/build/templates/tools/string-utils.d.ts +0 -18
  44. package/scripts/build/templates/tools/string-utils.js +0 -18
  45. package/scripts/build/templates/types/index.d.ts +0 -16
  46. package/scripts/build/templates/types/index.js +0 -15
  47. package/scripts/canal-release.patch +0 -316
  48. package/scripts/check_nodejs_import_compatibility.js +0 -60
  49. package/scripts/deploy_new_demo +0 -123
  50. package/scripts/fast_demo_build.js +0 -129
  51. package/scripts/generate_certificate +0 -19
  52. package/scripts/generate_demo_list.js +0 -105
  53. package/scripts/generate_documentation_list.js +0 -109
  54. package/scripts/generate_full_demo.js +0 -201
  55. package/scripts/generate_standalone_demo.js +0 -82
  56. package/scripts/launch_static_server.js +0 -163
  57. package/scripts/list-npm-scripts.js +0 -207
  58. package/scripts/make-dev-releases +0 -90
  59. package/scripts/report_build_sizes +0 -96
  60. package/scripts/run_standalone_demo.js +0 -27
  61. package/scripts/start_demo_web_server.js +0 -44
  62. package/scripts/update-version +0 -48
  63. package/scripts/update_gh-pages_demo +0 -132
  64. package/scripts/update_gh-pages_doc +0 -106
  65. package/scripts/utils/display_webpack_errors.js +0 -33
  66. package/scripts/utils/get_human_readable_hours.js +0 -14
  67. package/scripts/wasm-strip.js +0 -359
  68. package/sonar-project.properties +0 -7
  69. package/src/README.md +0 -136
  70. package/src/compat/README.md +0 -29
  71. package/src/compat/__tests__/add_text_track.test.ts +0 -176
  72. package/src/compat/__tests__/browser_compatibility_types.test.ts +0 -152
  73. package/src/compat/__tests__/browser_version.test.ts +0 -84
  74. package/src/compat/__tests__/can_patch_isobmff.test.ts +0 -50
  75. package/src/compat/__tests__/can_rely_on_video_visibility_and_size.test.ts +0 -78
  76. package/src/compat/__tests__/can_reuse_media_keys.test.ts +0 -31
  77. package/src/compat/__tests__/change_source_buffer_type.test.ts +0 -60
  78. package/src/compat/__tests__/clear_element_src.test.ts +0 -252
  79. package/src/compat/__tests__/enable_audio_track.test.ts +0 -341
  80. package/src/compat/__tests__/fullscreen.test.ts +0 -286
  81. package/src/compat/__tests__/is_codec_supported.test.ts +0 -78
  82. package/src/compat/__tests__/is_offline.test.ts +0 -65
  83. package/src/compat/__tests__/is_seeking_approximate.test.ts +0 -48
  84. package/src/compat/__tests__/is_vtt_cue.test.ts +0 -71
  85. package/src/compat/__tests__/make_vtt_cue.test.ts +0 -97
  86. package/src/compat/__tests__/patch_webkit_source_buffer.test.ts +0 -144
  87. package/src/compat/__tests__/remove_cue.test.ts +0 -229
  88. package/src/compat/__tests__/should_favour_custom_safari_EME.test.ts +0 -128
  89. package/src/compat/__tests__/should_reload_media_source_on_decipherability_update.test.ts +0 -50
  90. package/src/compat/__tests__/should_renew_media_key_system_access.test.ts +0 -55
  91. package/src/compat/__tests__/should_unset_media_keys.test.ts +0 -53
  92. package/src/compat/__tests__/should_validate_metadata.test.ts +0 -53
  93. package/src/compat/__tests__/should_wait_for_data_before_loaded.test.ts +0 -121
  94. package/src/compat/__tests__/should_wait_for_have_enough_data.test.ts +0 -36
  95. package/src/compat/add_class_name.ts +0 -41
  96. package/src/compat/add_text_track.ts +0 -58
  97. package/src/compat/browser_compatibility_types.ts +0 -222
  98. package/src/compat/browser_detection.ts +0 -172
  99. package/src/compat/browser_version.ts +0 -44
  100. package/src/compat/can_patch_isobmff.ts +0 -30
  101. package/src/compat/can_rely_on_video_visibility_and_size.ts +0 -52
  102. package/src/compat/can_reuse_media_keys.ts +0 -20
  103. package/src/compat/change_source_buffer_type.ts +0 -66
  104. package/src/compat/clear_element_src.ts +0 -55
  105. package/src/compat/eme/close_session.ts +0 -111
  106. package/src/compat/eme/constants.ts +0 -21
  107. package/src/compat/eme/custom_key_system_access.ts +0 -67
  108. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +0 -186
  109. package/src/compat/eme/custom_media_keys/index.ts +0 -28
  110. package/src/compat/eme/custom_media_keys/moz_media_keys_constructor.ts +0 -88
  111. package/src/compat/eme/custom_media_keys/ms_media_keys_constructor.ts +0 -69
  112. package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +0 -235
  113. package/src/compat/eme/custom_media_keys/types.ts +0 -67
  114. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +0 -308
  115. package/src/compat/eme/custom_media_keys/webkit_media_keys_constructor.ts +0 -50
  116. package/src/compat/eme/eme-api-implementation.ts +0 -318
  117. package/src/compat/eme/generate_key_request.ts +0 -162
  118. package/src/compat/eme/get_init_data.ts +0 -159
  119. package/src/compat/eme/get_uuid_kid_from_keystatus_kid.ts +0 -37
  120. package/src/compat/eme/get_webkit_fairplay_initdata.ts +0 -75
  121. package/src/compat/eme/index.ts +0 -47
  122. package/src/compat/eme/load_session.ts +0 -67
  123. package/src/compat/enable_audio_track.ts +0 -33
  124. package/src/compat/event_listeners.ts +0 -566
  125. package/src/compat/fullscreen.ts +0 -87
  126. package/src/compat/get_start_date.ts +0 -48
  127. package/src/compat/has_issues_with_high_media_source_duration.ts +0 -27
  128. package/src/compat/index.ts +0 -87
  129. package/src/compat/is_codec_supported.ts +0 -40
  130. package/src/compat/is_debug_mode_enabled.ts +0 -12
  131. package/src/compat/is_node.ts +0 -18
  132. package/src/compat/is_offline.ts +0 -44
  133. package/src/compat/is_seeking_approximate.ts +0 -32
  134. package/src/compat/is_vtt_cue.ts +0 -30
  135. package/src/compat/make_vtt_cue.ts +0 -51
  136. package/src/compat/on_height_width_change.ts +0 -119
  137. package/src/compat/patch_webkit_source_buffer.ts +0 -89
  138. package/src/compat/remove_cue.ts +0 -64
  139. package/src/compat/should_favour_custom_safari_EME.ts +0 -34
  140. package/src/compat/should_prevent_seeking_at_0_initially.ts +0 -19
  141. package/src/compat/should_reload_media_source_on_decipherability_update.ts +0 -32
  142. package/src/compat/should_renew_media_key_system_access.ts +0 -26
  143. package/src/compat/should_unset_media_keys.ts +0 -27
  144. package/src/compat/should_validate_metadata.ts +0 -27
  145. package/src/compat/should_wait_for_data_before_loaded.ts +0 -35
  146. package/src/compat/should_wait_for_have_enough_data.ts +0 -17
  147. package/src/config.ts +0 -32
  148. package/src/core/README.md +0 -56
  149. package/src/core/adaptive/README.md +0 -147
  150. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +0 -548
  151. package/src/core/adaptive/adaptive_representation_selector.ts +0 -916
  152. package/src/core/adaptive/buffer_based_chooser.ts +0 -264
  153. package/src/core/adaptive/guess_based_chooser.ts +0 -309
  154. package/src/core/adaptive/index.ts +0 -45
  155. package/src/core/adaptive/network_analyzer.ts +0 -419
  156. package/src/core/adaptive/utils/__tests__/bandwith_estimator.test.ts +0 -134
  157. package/src/core/adaptive/utils/__tests__/ewma.test.ts +0 -79
  158. package/src/core/adaptive/utils/__tests__/filter_by_bitrate.test.ts +0 -56
  159. package/src/core/adaptive/utils/__tests__/filter_by_width.test.ts +0 -60
  160. package/src/core/adaptive/utils/__tests__/get_buffer_levels.test.ts +0 -48
  161. package/src/core/adaptive/utils/__tests__/select_optimal_representation.test.ts +0 -243
  162. package/src/core/adaptive/utils/bandwidth_estimator.ts +0 -88
  163. package/src/core/adaptive/utils/ewma.ts +0 -59
  164. package/src/core/adaptive/utils/filter_by_bitrate.ts +0 -46
  165. package/src/core/adaptive/utils/filter_by_width.ts +0 -49
  166. package/src/core/adaptive/utils/get_buffer_levels.ts +0 -50
  167. package/src/core/adaptive/utils/last_estimate_storage.ts +0 -79
  168. package/src/core/adaptive/utils/pending_requests_store.ts +0 -147
  169. package/src/core/adaptive/utils/representation_score_calculator.ts +0 -168
  170. package/src/core/adaptive/utils/select_optimal_representation.ts +0 -54
  171. package/src/core/api/README.md +0 -36
  172. package/src/core/api/__tests__/option_utils.test.ts +0 -1668
  173. package/src/core/api/__tests__/public_api.test.ts +0 -857
  174. package/src/core/api/__tests__/utils.test.ts +0 -195
  175. package/src/core/api/debug/buffer_graph.ts +0 -244
  176. package/src/core/api/debug/buffer_size_graph.ts +0 -130
  177. package/src/core/api/debug/constants.ts +0 -2
  178. package/src/core/api/debug/index.ts +0 -3
  179. package/src/core/api/debug/modules/general_info.ts +0 -213
  180. package/src/core/api/debug/modules/segment_buffer_content.ts +0 -155
  181. package/src/core/api/debug/modules/segment_buffer_size.ts +0 -48
  182. package/src/core/api/debug/render.ts +0 -40
  183. package/src/core/api/debug/utils.ts +0 -103
  184. package/src/core/api/index.ts +0 -27
  185. package/src/core/api/option_utils.ts +0 -700
  186. package/src/core/api/playback_observer.ts +0 -994
  187. package/src/core/api/public_api.ts +0 -3247
  188. package/src/core/api/tracks_management/__tests__/media_element_track_choice_manager.test.ts +0 -184
  189. package/src/core/api/tracks_management/media_element_track_choice_manager.ts +0 -975
  190. package/src/core/api/tracks_management/track_choice_manager.ts +0 -1280
  191. package/src/core/api/utils.ts +0 -216
  192. package/src/core/decrypt/README.md +0 -22
  193. package/src/core/decrypt/__tests__/__global__/get_license.test.ts +0 -422
  194. package/src/core/decrypt/__tests__/__global__/init_data.test.ts +0 -677
  195. package/src/core/decrypt/__tests__/__global__/media_key_system_access.test.ts +0 -528
  196. package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +0 -343
  197. package/src/core/decrypt/__tests__/__global__/server_certificate.test.ts +0 -264
  198. package/src/core/decrypt/__tests__/__global__/utils.ts +0 -491
  199. package/src/core/decrypt/attach_media_keys.ts +0 -121
  200. package/src/core/decrypt/clear_on_stop.ts +0 -47
  201. package/src/core/decrypt/content_decryptor.ts +0 -1246
  202. package/src/core/decrypt/create_or_load_session.ts +0 -133
  203. package/src/core/decrypt/create_session.ts +0 -214
  204. package/src/core/decrypt/dispose_decryption_resources.ts +0 -54
  205. package/src/core/decrypt/find_key_system.ts +0 -376
  206. package/src/core/decrypt/get_key_system_configuration.ts +0 -51
  207. package/src/core/decrypt/get_media_keys.ts +0 -147
  208. package/src/core/decrypt/index.ts +0 -36
  209. package/src/core/decrypt/init_media_keys.ts +0 -60
  210. package/src/core/decrypt/session_events_listener.ts +0 -386
  211. package/src/core/decrypt/set_server_certificate.ts +0 -105
  212. package/src/core/decrypt/types.ts +0 -404
  213. package/src/core/decrypt/utils/__tests__/are_init_values_compatible.test.ts +0 -261
  214. package/src/core/decrypt/utils/__tests__/clean_old_loaded_sessions.test.ts +0 -158
  215. package/src/core/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +0 -133
  216. package/src/core/decrypt/utils/are_init_values_compatible.ts +0 -140
  217. package/src/core/decrypt/utils/check_key_statuses.ts +0 -193
  218. package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +0 -45
  219. package/src/core/decrypt/utils/clean_old_stored_persistent_info.ts +0 -48
  220. package/src/core/decrypt/utils/get_drm_system_id.ts +0 -42
  221. package/src/core/decrypt/utils/init_data_values_container.ts +0 -119
  222. package/src/core/decrypt/utils/is_session_usable.ts +0 -62
  223. package/src/core/decrypt/utils/key_id_comparison.ts +0 -57
  224. package/src/core/decrypt/utils/key_session_record.ts +0 -174
  225. package/src/core/decrypt/utils/loaded_sessions_store.ts +0 -505
  226. package/src/core/decrypt/utils/media_keys_infos_store.ts +0 -85
  227. package/src/core/decrypt/utils/persistent_sessions_store.ts +0 -358
  228. package/src/core/decrypt/utils/serializable_bytes.ts +0 -59
  229. package/src/core/decrypt/utils/server_certificate_store.ts +0 -133
  230. package/src/core/fetchers/README.md +0 -84
  231. package/src/core/fetchers/cdn_prioritizer.ts +0 -207
  232. package/src/core/fetchers/index.ts +0 -38
  233. package/src/core/fetchers/manifest/index.ts +0 -28
  234. package/src/core/fetchers/manifest/manifest_fetcher.ts +0 -798
  235. package/src/core/fetchers/segment/__tests__/task_prioritizer.test.ts +0 -763
  236. package/src/core/fetchers/segment/index.ts +0 -28
  237. package/src/core/fetchers/segment/prioritized_segment_fetcher.ts +0 -113
  238. package/src/core/fetchers/segment/segment_fetcher.ts +0 -482
  239. package/src/core/fetchers/segment/segment_fetcher_creator.ts +0 -129
  240. package/src/core/fetchers/segment/task_prioritizer.ts +0 -455
  241. package/src/core/fetchers/utils/error_selector.ts +0 -38
  242. package/src/core/fetchers/utils/schedule_request.ts +0 -493
  243. package/src/core/init/README.md +0 -81
  244. package/src/core/init/directfile_content_initializer.ts +0 -310
  245. package/src/core/init/index.ts +0 -22
  246. package/src/core/init/media_source_content_initializer.ts +0 -878
  247. package/src/core/init/types.ts +0 -266
  248. package/src/core/init/utils/__tests__/are_same_stream_events.test.ts +0 -84
  249. package/src/core/init/utils/__tests__/refresh_scheduled_events_list.test.ts +0 -94
  250. package/src/core/init/utils/content_time_boundaries_observer.ts +0 -646
  251. package/src/core/init/utils/create_media_source.ts +0 -139
  252. package/src/core/init/utils/create_stream_playback_observer.ts +0 -132
  253. package/src/core/init/utils/end_of_stream.ts +0 -108
  254. package/src/core/init/utils/get_initial_time.ts +0 -165
  255. package/src/core/init/utils/get_loaded_reference.ts +0 -82
  256. package/src/core/init/utils/initial_seek_and_play.ts +0 -237
  257. package/src/core/init/utils/initialize_content_decryption.ts +0 -172
  258. package/src/core/init/utils/media_source_duration_updater.ts +0 -349
  259. package/src/core/init/utils/rebuffering_controller.ts +0 -642
  260. package/src/core/init/utils/stream_events_emitter/are_same_stream_events.ts +0 -42
  261. package/src/core/init/utils/stream_events_emitter/index.ts +0 -22
  262. package/src/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.ts +0 -74
  263. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +0 -252
  264. package/src/core/init/utils/stream_events_emitter/types.ts +0 -46
  265. package/src/core/init/utils/throw_on_media_error.ts +0 -74
  266. package/src/core/segment_buffers/README.md +0 -219
  267. package/src/core/segment_buffers/garbage_collector.ts +0 -177
  268. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +0 -650
  269. package/src/core/segment_buffers/implementations/audio_video/index.ts +0 -18
  270. package/src/core/segment_buffers/implementations/image/image_segment_buffer.ts +0 -152
  271. package/src/core/segment_buffers/implementations/image/index.ts +0 -18
  272. package/src/core/segment_buffers/implementations/index.ts +0 -20
  273. package/src/core/segment_buffers/implementations/text/html/__tests__/utils.test.ts +0 -343
  274. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +0 -527
  275. package/src/core/segment_buffers/implementations/text/html/index.ts +0 -24
  276. package/src/core/segment_buffers/implementations/text/html/parsers.ts +0 -49
  277. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +0 -391
  278. package/src/core/segment_buffers/implementations/text/html/types.ts +0 -23
  279. package/src/core/segment_buffers/implementations/text/html/update_proportional_elements.ts +0 -93
  280. package/src/core/segment_buffers/implementations/text/html/utils.ts +0 -139
  281. package/src/core/segment_buffers/implementations/text/native/index.ts +0 -19
  282. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +0 -340
  283. package/src/core/segment_buffers/implementations/text/native/parsers.ts +0 -47
  284. package/src/core/segment_buffers/implementations/types.ts +0 -386
  285. package/src/core/segment_buffers/implementations/utils/manual_time_ranges.ts +0 -80
  286. package/src/core/segment_buffers/index.ts +0 -67
  287. package/src/core/segment_buffers/inventory/buffered_history.ts +0 -131
  288. package/src/core/segment_buffers/inventory/index.ts +0 -30
  289. package/src/core/segment_buffers/inventory/segment_inventory.ts +0 -1111
  290. package/src/core/segment_buffers/inventory/types.ts +0 -35
  291. package/src/core/segment_buffers/segment_buffers_store.ts +0 -383
  292. package/src/core/stream/README.md +0 -59
  293. package/src/core/stream/adaptation/adaptation_stream.ts +0 -378
  294. package/src/core/stream/adaptation/index.ts +0 -20
  295. package/src/core/stream/adaptation/types.ts +0 -199
  296. package/src/core/stream/adaptation/utils/create_representation_estimator.ts +0 -114
  297. package/src/core/stream/index.ts +0 -38
  298. package/src/core/stream/orchestrator/README.md +0 -349
  299. package/src/core/stream/orchestrator/get_time_ranges_for_content.ts +0 -70
  300. package/src/core/stream/orchestrator/index.ts +0 -30
  301. package/src/core/stream/orchestrator/stream_orchestrator.ts +0 -664
  302. package/src/core/stream/period/index.ts +0 -20
  303. package/src/core/stream/period/period_stream.ts +0 -469
  304. package/src/core/stream/period/types.ts +0 -132
  305. package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +0 -287
  306. package/src/core/stream/representation/README.md +0 -16
  307. package/src/core/stream/representation/index.ts +0 -20
  308. package/src/core/stream/representation/representation_stream.ts +0 -474
  309. package/src/core/stream/representation/types.ts +0 -292
  310. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +0 -77
  311. package/src/core/stream/representation/utils/check_for_discontinuity.ts +0 -305
  312. package/src/core/stream/representation/utils/downloading_queue.ts +0 -603
  313. package/src/core/stream/representation/utils/force_garbage_collection.ts +0 -113
  314. package/src/core/stream/representation/utils/get_buffer_status.ts +0 -322
  315. package/src/core/stream/representation/utils/get_needed_segments.ts +0 -617
  316. package/src/core/stream/representation/utils/get_segment_priority.ts +0 -43
  317. package/src/core/stream/representation/utils/push_init_segment.ts +0 -85
  318. package/src/core/stream/representation/utils/push_media_segment.ts +0 -113
  319. package/src/default_config.ts +0 -1293
  320. package/src/errors/README.md +0 -6
  321. package/src/errors/__tests__/assertion_error.test.ts +0 -26
  322. package/src/errors/__tests__/encrypted_media_error.test.ts +0 -45
  323. package/src/errors/__tests__/error_message.test.ts +0 -23
  324. package/src/errors/__tests__/format_error.test.ts +0 -62
  325. package/src/errors/__tests__/is_known_error.test.ts +0 -65
  326. package/src/errors/__tests__/media_error.test.ts +0 -55
  327. package/src/errors/__tests__/network_error.test.ts +0 -84
  328. package/src/errors/__tests__/other_error.test.ts +0 -53
  329. package/src/errors/__tests__/request_error.test.ts +0 -45
  330. package/src/errors/assertion_error.ts +0 -40
  331. package/src/errors/custom_loader_error.ts +0 -57
  332. package/src/errors/encrypted_media_error.ts +0 -71
  333. package/src/errors/error_codes.ts +0 -149
  334. package/src/errors/error_message.ts +0 -30
  335. package/src/errors/format_error.ts +0 -39
  336. package/src/errors/index.ts +0 -52
  337. package/src/errors/is_known_error.ts +0 -35
  338. package/src/errors/media_error.ts +0 -118
  339. package/src/errors/network_error.ts +0 -74
  340. package/src/errors/other_error.ts +0 -50
  341. package/src/errors/request_error.ts +0 -76
  342. package/src/experimental/README.md +0 -16
  343. package/src/experimental/features/__tests__/dash_wasm.test.ts +0 -44
  344. package/src/experimental/features/__tests__/debug_element.test.ts +0 -12
  345. package/src/experimental/features/__tests__/index.test.ts +0 -19
  346. package/src/experimental/features/__tests__/local.test.ts +0 -35
  347. package/src/experimental/features/__tests__/metaplaylist.test.ts +0 -35
  348. package/src/experimental/features/dash_wasm.ts +0 -41
  349. package/src/experimental/features/debug_element.ts +0 -13
  350. package/src/experimental/features/index.ts +0 -20
  351. package/src/experimental/features/local.ts +0 -28
  352. package/src/experimental/features/metaplaylist.ts +0 -28
  353. package/src/experimental/index.ts +0 -5
  354. package/src/experimental/tools/VideoThumbnailLoader/features/dash.ts +0 -23
  355. package/src/experimental/tools/VideoThumbnailLoader/features/metaplaylist.ts +0 -23
  356. package/src/experimental/tools/VideoThumbnailLoader/index.ts +0 -25
  357. package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +0 -77
  358. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +0 -75
  359. package/src/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.ts +0 -54
  360. package/src/experimental/tools/VideoThumbnailLoader/types.ts +0 -39
  361. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +0 -423
  362. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.ts +0 -34
  363. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +0 -141
  364. package/src/experimental/tools/createMetaplaylist/index.ts +0 -72
  365. package/src/experimental/tools/index.ts +0 -27
  366. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/capabilities.test.ts +0 -37
  367. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +0 -140
  368. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +0 -153
  369. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/decodingInfos.test.ts +0 -405
  370. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/defaultCodecFinder.test.ts +0 -136
  371. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaContentType.test.ts +0 -294
  372. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +0 -189
  373. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/utils.test.ts +0 -361
  374. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +0 -184
  375. package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +0 -136
  376. package/src/experimental/tools/mediaCapabilitiesProber/capabilities.ts +0 -169
  377. package/src/experimental/tools/mediaCapabilitiesProber/index.ts +0 -18
  378. package/src/experimental/tools/mediaCapabilitiesProber/log.ts +0 -21
  379. package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +0 -67
  380. package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +0 -89
  381. package/src/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.ts +0 -100
  382. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +0 -66
  383. package/src/experimental/tools/mediaCapabilitiesProber/probers/index.ts +0 -44
  384. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +0 -66
  385. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.ts +0 -100
  386. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.ts +0 -105
  387. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +0 -54
  388. package/src/experimental/tools/mediaCapabilitiesProber/types.ts +0 -75
  389. package/src/experimental/tools/mediaCapabilitiesProber/utils.ts +0 -107
  390. package/src/experimental/tools/parseBIFThumbnails.ts +0 -39
  391. package/src/features/README.md +0 -11
  392. package/src/features/__tests__/add_features.test.ts +0 -69
  393. package/src/features/__tests__/initialize_features.test.ts +0 -674
  394. package/src/features/add_features.ts +0 -37
  395. package/src/features/features_object.ts +0 -37
  396. package/src/features/index.ts +0 -40
  397. package/src/features/initialize_features.ts +0 -136
  398. package/src/features/list/__tests__/bif_parser.test.ts +0 -30
  399. package/src/features/list/__tests__/dash.test.ts +0 -41
  400. package/src/features/list/__tests__/directfile.test.ts +0 -35
  401. package/src/features/list/__tests__/eme.test.ts +0 -28
  402. package/src/features/list/__tests__/html_sami_parser.test.ts +0 -33
  403. package/src/features/list/__tests__/html_srt_parser.test.ts +0 -33
  404. package/src/features/list/__tests__/html_text_buffer.test.ts +0 -29
  405. package/src/features/list/__tests__/html_ttml_parser.test.ts +0 -33
  406. package/src/features/list/__tests__/html_vtt_parser.test.ts +0 -33
  407. package/src/features/list/__tests__/image_buffer.test.ts +0 -28
  408. package/src/features/list/__tests__/index.test.ts +0 -55
  409. package/src/features/list/__tests__/native_sami_parser.test.ts +0 -33
  410. package/src/features/list/__tests__/native_srt_parser.test.ts +0 -33
  411. package/src/features/list/__tests__/native_text_buffer.test.ts +0 -29
  412. package/src/features/list/__tests__/native_ttml_parser.test.ts +0 -33
  413. package/src/features/list/__tests__/native_vtt_parser.test.ts +0 -33
  414. package/src/features/list/__tests__/smooth.test.ts +0 -36
  415. package/src/features/list/bif_parser.ts +0 -31
  416. package/src/features/list/dash.ts +0 -36
  417. package/src/features/list/directfile.ts +0 -35
  418. package/src/features/list/eme.ts +0 -29
  419. package/src/features/list/html_sami_parser.ts +0 -31
  420. package/src/features/list/html_srt_parser.ts +0 -31
  421. package/src/features/list/html_text_buffer.ts +0 -29
  422. package/src/features/list/html_ttml_parser.ts +0 -31
  423. package/src/features/list/html_vtt_parser.ts +0 -31
  424. package/src/features/list/image_buffer.ts +0 -29
  425. package/src/features/list/index.ts +0 -32
  426. package/src/features/list/native_sami_parser.ts +0 -32
  427. package/src/features/list/native_srt_parser.ts +0 -32
  428. package/src/features/list/native_text_buffer.ts +0 -30
  429. package/src/features/list/native_ttml_parser.ts +0 -32
  430. package/src/features/list/native_vtt_parser.ts +0 -32
  431. package/src/features/list/smooth.ts +0 -32
  432. package/src/features/types.ts +0 -183
  433. package/src/index.ts +0 -38
  434. package/src/log.ts +0 -22
  435. package/src/manifest/README.md +0 -55
  436. package/src/manifest/__tests__/adaptation.test.ts +0 -485
  437. package/src/manifest/__tests__/manifest.test.ts +0 -428
  438. package/src/manifest/__tests__/period.test.ts +0 -769
  439. package/src/manifest/__tests__/representation.test.ts +0 -297
  440. package/src/manifest/__tests__/update_period_in_place.test.ts +0 -1074
  441. package/src/manifest/__tests__/update_periods.test.ts +0 -845
  442. package/src/manifest/adaptation.ts +0 -294
  443. package/src/manifest/index.ts +0 -67
  444. package/src/manifest/manifest.ts +0 -811
  445. package/src/manifest/period.ts +0 -211
  446. package/src/manifest/representation.ts +0 -451
  447. package/src/manifest/representation_index/__tests__/static.test.ts +0 -74
  448. package/src/manifest/representation_index/index.ts +0 -31
  449. package/src/manifest/representation_index/static.ts +0 -158
  450. package/src/manifest/representation_index/types.ts +0 -433
  451. package/src/manifest/types.ts +0 -33
  452. package/src/manifest/update_period_in_place.ts +0 -142
  453. package/src/manifest/update_periods.ts +0 -201
  454. package/src/manifest/utils.ts +0 -60
  455. package/src/minimal.ts +0 -34
  456. package/src/parsers/README.md +0 -12
  457. package/src/parsers/containers/isobmff/constants.ts +0 -24
  458. package/src/parsers/containers/isobmff/create_box.ts +0 -81
  459. package/src/parsers/containers/isobmff/drm/index.ts +0 -17
  460. package/src/parsers/containers/isobmff/drm/playready.ts +0 -45
  461. package/src/parsers/containers/isobmff/get_box.ts +0 -278
  462. package/src/parsers/containers/isobmff/index.ts +0 -51
  463. package/src/parsers/containers/isobmff/read.ts +0 -105
  464. package/src/parsers/containers/isobmff/take_pssh_out.ts +0 -101
  465. package/src/parsers/containers/isobmff/utils.ts +0 -555
  466. package/src/parsers/containers/matroska/index.ts +0 -21
  467. package/src/parsers/containers/matroska/utils.ts +0 -313
  468. package/src/parsers/images/bif.ts +0 -128
  469. package/src/parsers/manifest/dash/common/__tests__/attach_trickmode_track.test.ts +0 -65
  470. package/src/parsers/manifest/dash/common/__tests__/convert_supplemental_codecs.test.ts +0 -37
  471. package/src/parsers/manifest/dash/common/__tests__/flatten_overlapping_period.test.ts +0 -162
  472. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +0 -65
  473. package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +0 -165
  474. package/src/parsers/manifest/dash/common/__tests__/get_periods_time_infos.test.ts +0 -118
  475. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +0 -290
  476. package/src/parsers/manifest/dash/common/__tests__/parse_availability_start_time.test.ts +0 -63
  477. package/src/parsers/manifest/dash/common/attach_trickmode_track.ts +0 -55
  478. package/src/parsers/manifest/dash/common/convert_supplemental_codecs.ts +0 -32
  479. package/src/parsers/manifest/dash/common/flatten_overlapping_periods.ts +0 -87
  480. package/src/parsers/manifest/dash/common/get_clock_offset.ts +0 -41
  481. package/src/parsers/manifest/dash/common/get_hdr_information.ts +0 -94
  482. package/src/parsers/manifest/dash/common/get_http_utc-timing_url.ts +0 -46
  483. package/src/parsers/manifest/dash/common/get_minimum_and_maximum_positions.ts +0 -39
  484. package/src/parsers/manifest/dash/common/get_periods_time_infos.ts +0 -91
  485. package/src/parsers/manifest/dash/common/index.ts +0 -40
  486. package/src/parsers/manifest/dash/common/indexes/__tests__/tokens.test.ts +0 -60
  487. package/src/parsers/manifest/dash/common/indexes/base.ts +0 -444
  488. package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +0 -55
  489. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +0 -148
  490. package/src/parsers/manifest/dash/common/indexes/index.ts +0 -39
  491. package/src/parsers/manifest/dash/common/indexes/list.ts +0 -338
  492. package/src/parsers/manifest/dash/common/indexes/template.ts +0 -652
  493. package/src/parsers/manifest/dash/common/indexes/timeline/__tests__/parse_s_element.test.ts +0 -115
  494. package/src/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.ts +0 -54
  495. package/src/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.ts +0 -102
  496. package/src/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.ts +0 -66
  497. package/src/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.ts +0 -153
  498. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +0 -21
  499. package/src/parsers/manifest/dash/common/indexes/timeline/parse_s_element.ts +0 -72
  500. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +0 -1049
  501. package/src/parsers/manifest/dash/common/indexes/tokens.ts +0 -127
  502. package/src/parsers/manifest/dash/common/indexes/utils.ts +0 -32
  503. package/src/parsers/manifest/dash/common/infer_adaptation_type.ts +0 -142
  504. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +0 -165
  505. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +0 -569
  506. package/src/parsers/manifest/dash/common/parse_availability_start_time.ts +0 -35
  507. package/src/parsers/manifest/dash/common/parse_mpd.ts +0 -399
  508. package/src/parsers/manifest/dash/common/parse_periods.ts +0 -363
  509. package/src/parsers/manifest/dash/common/parse_representation_index.ts +0 -199
  510. package/src/parsers/manifest/dash/common/parse_representations.ts +0 -352
  511. package/src/parsers/manifest/dash/common/resolve_base_urls.ts +0 -58
  512. package/src/parsers/manifest/dash/index.ts +0 -22
  513. package/src/parsers/manifest/dash/js-parser/__tests__/parse_from_document.test.ts +0 -45
  514. package/src/parsers/manifest/dash/js-parser/index.ts +0 -18
  515. package/src/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.ts +0 -381
  516. package/src/parsers/manifest/dash/js-parser/node_parsers/BaseURL.ts +0 -35
  517. package/src/parsers/manifest/dash/js-parser/node_parsers/ContentComponent.ts +0 -49
  518. package/src/parsers/manifest/dash/js-parser/node_parsers/ContentProtection.ts +0 -94
  519. package/src/parsers/manifest/dash/js-parser/node_parsers/EventStream.ts +0 -117
  520. package/src/parsers/manifest/dash/js-parser/node_parsers/Initialization.ts +0 -48
  521. package/src/parsers/manifest/dash/js-parser/node_parsers/MPD.ts +0 -180
  522. package/src/parsers/manifest/dash/js-parser/node_parsers/Period.ts +0 -152
  523. package/src/parsers/manifest/dash/js-parser/node_parsers/Representation.ts +0 -234
  524. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.ts +0 -112
  525. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentList.ts +0 -50
  526. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.ts +0 -98
  527. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentTimeline.ts +0 -35
  528. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.ts +0 -63
  529. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/AdaptationSet.test.ts +0 -407
  530. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentComponent.test.ts +0 -67
  531. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +0 -223
  532. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +0 -139
  533. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentTimeline.test.ts +0 -119
  534. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +0 -205
  535. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/utils.test.ts +0 -218
  536. package/src/parsers/manifest/dash/js-parser/node_parsers/utils.ts +0 -384
  537. package/src/parsers/manifest/dash/js-parser/parse_from_document.ts +0 -129
  538. package/src/parsers/manifest/dash/node_parser_types.ts +0 -431
  539. package/src/parsers/manifest/dash/parsers_types.ts +0 -91
  540. package/src/parsers/manifest/dash/wasm-parser/Cargo.lock +0 -25
  541. package/src/parsers/manifest/dash/wasm-parser/Cargo.toml +0 -16
  542. package/src/parsers/manifest/dash/wasm-parser/README.md +0 -267
  543. package/src/parsers/manifest/dash/wasm-parser/index.ts +0 -21
  544. package/src/parsers/manifest/dash/wasm-parser/rs/errors.rs +0 -28
  545. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +0 -373
  546. package/src/parsers/manifest/dash/wasm-parser/rs/lib.rs +0 -85
  547. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +0 -414
  548. package/src/parsers/manifest/dash/wasm-parser/rs/processor/mod.rs +0 -472
  549. package/src/parsers/manifest/dash/wasm-parser/rs/processor/s_element.rs +0 -72
  550. package/src/parsers/manifest/dash/wasm-parser/rs/reader.rs +0 -17
  551. package/src/parsers/manifest/dash/wasm-parser/rs/reportable.rs +0 -147
  552. package/src/parsers/manifest/dash/wasm-parser/rs/utils.rs +0 -217
  553. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +0 -477
  554. package/src/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.ts +0 -343
  555. package/src/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.ts +0 -38
  556. package/src/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.ts +0 -53
  557. package/src/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.ts +0 -62
  558. package/src/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.ts +0 -144
  559. package/src/parsers/manifest/dash/wasm-parser/ts/generators/MPD.ts +0 -183
  560. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Period.ts +0 -180
  561. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +0 -215
  562. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.ts +0 -44
  563. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.ts +0 -115
  564. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentList.ts +0 -61
  565. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.ts +0 -133
  566. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.ts +0 -70
  567. package/src/parsers/manifest/dash/wasm-parser/ts/generators/XLink.ts +0 -66
  568. package/src/parsers/manifest/dash/wasm-parser/ts/generators/index.ts +0 -17
  569. package/src/parsers/manifest/dash/wasm-parser/ts/generators/root.ts +0 -66
  570. package/src/parsers/manifest/dash/wasm-parser/ts/parsers_stack.ts +0 -80
  571. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +0 -298
  572. package/src/parsers/manifest/dash/wasm-parser/ts/utils.ts +0 -47
  573. package/src/parsers/manifest/index.ts +0 -17
  574. package/src/parsers/manifest/local/index.ts +0 -25
  575. package/src/parsers/manifest/local/parse_local_manifest.ts +0 -164
  576. package/src/parsers/manifest/local/representation_index.ts +0 -246
  577. package/src/parsers/manifest/local/types.ts +0 -291
  578. package/src/parsers/manifest/metaplaylist/index.ts +0 -28
  579. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +0 -335
  580. package/src/parsers/manifest/metaplaylist/representation_index.ts +0 -251
  581. package/src/parsers/manifest/smooth/create_parser.ts +0 -699
  582. package/src/parsers/manifest/smooth/get_codecs.ts +0 -55
  583. package/src/parsers/manifest/smooth/index.ts +0 -26
  584. package/src/parsers/manifest/smooth/parse_C_nodes.ts +0 -69
  585. package/src/parsers/manifest/smooth/parse_protection_node.ts +0 -72
  586. package/src/parsers/manifest/smooth/representation_index.ts +0 -704
  587. package/src/parsers/manifest/smooth/utils/add_segment_infos.ts +0 -77
  588. package/src/parsers/manifest/smooth/utils/parseBoolean.ts +0 -31
  589. package/src/parsers/manifest/smooth/utils/reduceChildren.ts +0 -36
  590. package/src/parsers/manifest/smooth/utils/tokens.ts +0 -46
  591. package/src/parsers/manifest/types.ts +0 -395
  592. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +0 -161
  593. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +0 -161
  594. package/src/parsers/manifest/utils/__tests__/index_helpers.test.ts +0 -55
  595. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +0 -546
  596. package/src/parsers/manifest/utils/check_manifest_ids.ts +0 -83
  597. package/src/parsers/manifest/utils/clear_timeline_from_position.ts +0 -74
  598. package/src/parsers/manifest/utils/get_first_time_from_adaptation.ts +0 -48
  599. package/src/parsers/manifest/utils/get_last_time_from_adaptation.ts +0 -50
  600. package/src/parsers/manifest/utils/get_maximum_positions.ts +0 -87
  601. package/src/parsers/manifest/utils/get_minimum_position.ts +0 -80
  602. package/src/parsers/manifest/utils/index_helpers.ts +0 -204
  603. package/src/parsers/manifest/utils/update_segment_timeline.ts +0 -141
  604. package/src/parsers/texttracks/index.ts +0 -21
  605. package/src/parsers/texttracks/sami/html.ts +0 -219
  606. package/src/parsers/texttracks/sami/native.ts +0 -192
  607. package/src/parsers/texttracks/srt/__tests__/find_end_of_cue_block.test.ts +0 -99
  608. package/src/parsers/texttracks/srt/__tests__/get_cue_blocks.test.ts +0 -119
  609. package/src/parsers/texttracks/srt/__tests__/parse_cue.test.ts +0 -123
  610. package/src/parsers/texttracks/srt/__tests__/parse_timestamp.test.ts +0 -36
  611. package/src/parsers/texttracks/srt/find_end_of_cue_block.ts +0 -46
  612. package/src/parsers/texttracks/srt/get_cue_blocks.ts +0 -49
  613. package/src/parsers/texttracks/srt/html.ts +0 -182
  614. package/src/parsers/texttracks/srt/native.ts +0 -74
  615. package/src/parsers/texttracks/srt/parse_cue.ts +0 -76
  616. package/src/parsers/texttracks/srt/parse_timestamp.ts +0 -37
  617. package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +0 -248
  618. package/src/parsers/texttracks/ttml/get_parameters.ts +0 -106
  619. package/src/parsers/texttracks/ttml/get_styling.ts +0 -146
  620. package/src/parsers/texttracks/ttml/get_time_delimiters.ts +0 -49
  621. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.test.ts +0 -190
  622. package/src/parsers/texttracks/ttml/html/__tests__/generate_css_test_outline.test.ts +0 -32
  623. package/src/parsers/texttracks/ttml/html/__tests__/ttml_color_to_css_color.test.ts +0 -62
  624. package/src/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.ts +0 -67
  625. package/src/parsers/texttracks/ttml/html/apply_extent.ts +0 -65
  626. package/src/parsers/texttracks/ttml/html/apply_font_size.ts +0 -62
  627. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +0 -50
  628. package/src/parsers/texttracks/ttml/html/apply_origin.ts +0 -64
  629. package/src/parsers/texttracks/ttml/html/apply_padding.ts +0 -141
  630. package/src/parsers/texttracks/ttml/html/create_element.ts +0 -549
  631. package/src/parsers/texttracks/ttml/html/generate_css_test_outline.ts +0 -46
  632. package/src/parsers/texttracks/ttml/html/index.ts +0 -23
  633. package/src/parsers/texttracks/ttml/html/parse_cue.ts +0 -65
  634. package/src/parsers/texttracks/ttml/html/parse_ttml_to_div.ts +0 -58
  635. package/src/parsers/texttracks/ttml/html/ttml_color_to_css_color.ts +0 -68
  636. package/src/parsers/texttracks/ttml/native/index.ts +0 -23
  637. package/src/parsers/texttracks/ttml/native/parse_cue.ts +0 -245
  638. package/src/parsers/texttracks/ttml/native/parse_ttml_to_vtt.ts +0 -39
  639. package/src/parsers/texttracks/ttml/parse_ttml.ts +0 -206
  640. package/src/parsers/texttracks/ttml/regexps.ts +0 -65
  641. package/src/parsers/texttracks/ttml/resolve_styles_inheritance.ts +0 -84
  642. package/src/parsers/texttracks/ttml/time_parsing.ts +0 -156
  643. package/src/parsers/texttracks/ttml/xml_utils.ts +0 -166
  644. package/src/parsers/texttracks/types.ts +0 -34
  645. package/src/parsers/texttracks/webvtt/__tests__/get_cue_blocks.test.ts +0 -218
  646. package/src/parsers/texttracks/webvtt/__tests__/get_style_blocks.test.ts +0 -65
  647. package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +0 -249
  648. package/src/parsers/texttracks/webvtt/__tests__/parse_timestamp.test.ts +0 -39
  649. package/src/parsers/texttracks/webvtt/__tests__/utils.test.ts +0 -401
  650. package/src/parsers/texttracks/webvtt/get_cue_blocks.ts +0 -51
  651. package/src/parsers/texttracks/webvtt/get_style_blocks.ts +0 -56
  652. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +0 -106
  653. package/src/parsers/texttracks/webvtt/html/__tests__/create_default_style_elements.test.ts +0 -44
  654. package/src/parsers/texttracks/webvtt/html/__tests__/create_style_attribute.test.ts +0 -139
  655. package/src/parsers/texttracks/webvtt/html/__tests__/create_styled_element.test.ts +0 -140
  656. package/src/parsers/texttracks/webvtt/html/__tests__/parse_style_block.test.ts +0 -345
  657. package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +0 -181
  658. package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +0 -234
  659. package/src/parsers/texttracks/webvtt/html/convert_payload_to_html.ts +0 -46
  660. package/src/parsers/texttracks/webvtt/html/create_default_style_elements.ts +0 -26
  661. package/src/parsers/texttracks/webvtt/html/create_style_attribute.ts +0 -222
  662. package/src/parsers/texttracks/webvtt/html/create_styled_element.ts +0 -95
  663. package/src/parsers/texttracks/webvtt/html/index.ts +0 -25
  664. package/src/parsers/texttracks/webvtt/html/parse_style_block.ts +0 -76
  665. package/src/parsers/texttracks/webvtt/html/parse_webvtt_to_div.ts +0 -67
  666. package/src/parsers/texttracks/webvtt/html/to_html.ts +0 -96
  667. package/src/parsers/texttracks/webvtt/native/index.ts +0 -23
  668. package/src/parsers/texttracks/webvtt/native/parse_vtt_to_cues.ts +0 -70
  669. package/src/parsers/texttracks/webvtt/native/set_settings_on_cue.ts +0 -95
  670. package/src/parsers/texttracks/webvtt/native/to_native_cue.ts +0 -34
  671. package/src/parsers/texttracks/webvtt/parse_cue_block.ts +0 -128
  672. package/src/parsers/texttracks/webvtt/parse_timestamp.ts +0 -40
  673. package/src/parsers/texttracks/webvtt/utils.ts +0 -135
  674. package/src/public_types.ts +0 -846
  675. package/src/tools/README.md +0 -4
  676. package/src/tools/TextTrackRenderer/index.ts +0 -28
  677. package/src/tools/TextTrackRenderer/text_track_renderer.ts +0 -107
  678. package/src/tools/index.ts +0 -20
  679. package/src/tools/string_utils.ts +0 -24
  680. package/src/transports/README.md +0 -276
  681. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +0 -98
  682. package/src/transports/dash/construct_segment_url.ts +0 -28
  683. package/src/transports/dash/extract_complete_chunks.ts +0 -66
  684. package/src/transports/dash/get_events_out_of_emsgs.ts +0 -105
  685. package/src/transports/dash/image_pipelines.ts +0 -122
  686. package/src/transports/dash/index.ts +0 -23
  687. package/src/transports/dash/init_segment_loader.ts +0 -114
  688. package/src/transports/dash/low_latency_segment_loader.ts +0 -87
  689. package/src/transports/dash/manifest_parser.ts +0 -325
  690. package/src/transports/dash/pipelines.ts +0 -72
  691. package/src/transports/dash/segment_loader.ts +0 -249
  692. package/src/transports/dash/segment_parser.ts +0 -194
  693. package/src/transports/dash/text_loader.ts +0 -120
  694. package/src/transports/dash/text_parser.ts +0 -234
  695. package/src/transports/index.ts +0 -17
  696. package/src/transports/local/index.ts +0 -18
  697. package/src/transports/local/pipelines.ts +0 -100
  698. package/src/transports/local/segment_loader.ts +0 -198
  699. package/src/transports/local/segment_parser.ts +0 -101
  700. package/src/transports/local/text_parser.ts +0 -185
  701. package/src/transports/metaplaylist/README.md +0 -94
  702. package/src/transports/metaplaylist/index.ts +0 -23
  703. package/src/transports/metaplaylist/manifest_loader.ts +0 -62
  704. package/src/transports/metaplaylist/pipelines.ts +0 -425
  705. package/src/transports/smooth/extract_timings_infos.ts +0 -142
  706. package/src/transports/smooth/index.ts +0 -23
  707. package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +0 -231
  708. package/src/transports/smooth/isobmff/create_audio_init_segment.ts +0 -84
  709. package/src/transports/smooth/isobmff/create_boxes.ts +0 -481
  710. package/src/transports/smooth/isobmff/create_init_segment.ts +0 -100
  711. package/src/transports/smooth/isobmff/create_traf_box.ts +0 -40
  712. package/src/transports/smooth/isobmff/create_video_init_segment.ts +0 -78
  713. package/src/transports/smooth/isobmff/get_aaces_header.ts +0 -62
  714. package/src/transports/smooth/isobmff/index.ts +0 -32
  715. package/src/transports/smooth/isobmff/parse_tfrf.ts +0 -57
  716. package/src/transports/smooth/isobmff/parse_tfxd.ts +0 -38
  717. package/src/transports/smooth/isobmff/patch_segment.ts +0 -171
  718. package/src/transports/smooth/pipelines.ts +0 -533
  719. package/src/transports/smooth/segment_loader.ts +0 -288
  720. package/src/transports/smooth/utils.ts +0 -106
  721. package/src/transports/types.ts +0 -809
  722. package/src/transports/utils/__tests__/byte_range.test.ts +0 -35
  723. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +0 -148
  724. package/src/transports/utils/__tests__/find_complete_box.test.ts +0 -138
  725. package/src/transports/utils/__tests__/infer_segment_container.test.ts +0 -227
  726. package/src/transports/utils/byte_range.ts +0 -25
  727. package/src/transports/utils/call_custom_manifest_loader.ts +0 -147
  728. package/src/transports/utils/check_isobmff_integrity.ts +0 -50
  729. package/src/transports/utils/find_complete_box.ts +0 -63
  730. package/src/transports/utils/generate_manifest_loader.ts +0 -97
  731. package/src/transports/utils/get_isobmff_timing_infos.ts +0 -86
  732. package/src/transports/utils/infer_segment_container.ts +0 -56
  733. package/src/transports/utils/parse_text_track.ts +0 -176
  734. package/src/typings/README.md +0 -7
  735. package/src/typings/globals.d.ts +0 -83
  736. package/src/typings/next-tick.d.ts +0 -23
  737. package/src/utils/README.md +0 -5
  738. package/src/utils/__tests__/are_arrays_of_numbers_equal.test.ts +0 -86
  739. package/src/utils/__tests__/are_codecs_compatible.test.ts +0 -88
  740. package/src/utils/__tests__/array_find.test.ts +0 -113
  741. package/src/utils/__tests__/array_find_index.test.ts +0 -113
  742. package/src/utils/__tests__/array_includes.test.ts +0 -151
  743. package/src/utils/__tests__/assert.test.ts +0 -237
  744. package/src/utils/__tests__/assert_unreachable.test.ts +0 -40
  745. package/src/utils/__tests__/base64.test.ts +0 -147
  746. package/src/utils/__tests__/byte_parsing.test.ts +0 -267
  747. package/src/utils/__tests__/deep_merge.test.ts +0 -48
  748. package/src/utils/__tests__/event_emitter.test.ts +0 -579
  749. package/src/utils/__tests__/flat_map.test.ts +0 -71
  750. package/src/utils/__tests__/get_fuzzed_delay.test.ts +0 -32
  751. package/src/utils/__tests__/hash_buffer.test.ts +0 -105
  752. package/src/utils/__tests__/id_generator.test.ts +0 -80
  753. package/src/utils/__tests__/initialization_segment_cache.test.ts +0 -245
  754. package/src/utils/__tests__/is_non_empty_string.test.ts +0 -41
  755. package/src/utils/__tests__/is_null_or_undefined.test.ts +0 -33
  756. package/src/utils/__tests__/list_to_map.test.ts +0 -46
  757. package/src/utils/__tests__/logger.test.ts +0 -214
  758. package/src/utils/__tests__/noop.test.ts +0 -23
  759. package/src/utils/__tests__/object_assign.test.ts +0 -56
  760. package/src/utils/__tests__/object_values.test.ts +0 -26
  761. package/src/utils/__tests__/ranges.test.ts +0 -907
  762. package/src/utils/__tests__/resolve_url.test.ts +0 -100
  763. package/src/utils/__tests__/simple_set.test.ts +0 -57
  764. package/src/utils/__tests__/sorted_list.test.ts +0 -335
  765. package/src/utils/__tests__/starts_with.test.ts +0 -65
  766. package/src/utils/__tests__/string_parsing.test.ts +0 -267
  767. package/src/utils/__tests__/uniq.test.ts +0 -134
  768. package/src/utils/__tests__/warn_once.test.ts +0 -38
  769. package/src/utils/__tests__/weak_map_memory.test.ts +0 -188
  770. package/src/utils/are_arrays_of_numbers_equal.ts +0 -39
  771. package/src/utils/are_codecs_compatible.ts +0 -51
  772. package/src/utils/array_find.ts +0 -55
  773. package/src/utils/array_find_index.ts +0 -54
  774. package/src/utils/array_includes.ts +0 -93
  775. package/src/utils/assert.ts +0 -65
  776. package/src/utils/assert_unreachable.ts +0 -45
  777. package/src/utils/base64.ts +0 -153
  778. package/src/utils/byte_parsing.ts +0 -256
  779. package/src/utils/cancellable_sleep.ts +0 -41
  780. package/src/utils/create_cancellable_promise.ts +0 -69
  781. package/src/utils/deep_merge.ts +0 -49
  782. package/src/utils/event_emitter.ts +0 -147
  783. package/src/utils/flat_map.ts +0 -50
  784. package/src/utils/get_fuzzed_delay.ts +0 -27
  785. package/src/utils/hash_buffer.ts +0 -42
  786. package/src/utils/id_generator.ts +0 -35
  787. package/src/utils/initialization_segment_cache.ts +0 -68
  788. package/src/utils/is_non_empty_string.ts +0 -23
  789. package/src/utils/is_null_or_undefined.ts +0 -27
  790. package/src/utils/languages/ISO_639-1_to_ISO_639-3.ts +0 -207
  791. package/src/utils/languages/ISO_639-2_to_ISO_639-3.ts +0 -43
  792. package/src/utils/languages/__tests__/normalize.test.ts +0 -290
  793. package/src/utils/languages/index.ts +0 -29
  794. package/src/utils/languages/normalize.ts +0 -152
  795. package/src/utils/list_to_map.ts +0 -32
  796. package/src/utils/logger.ts +0 -100
  797. package/src/utils/noop.ts +0 -26
  798. package/src/utils/object_assign.ts +0 -60
  799. package/src/utils/object_values.ts +0 -31
  800. package/src/utils/ranges.ts +0 -499
  801. package/src/utils/reference.ts +0 -390
  802. package/src/utils/request/fetch.ts +0 -250
  803. package/src/utils/request/index.ts +0 -38
  804. package/src/utils/request/xhr.ts +0 -287
  805. package/src/utils/resolve_url.ts +0 -126
  806. package/src/utils/retry_promise_with_backoff.ts +0 -95
  807. package/src/utils/simple_set.ts +0 -67
  808. package/src/utils/sleep.ts +0 -14
  809. package/src/utils/slice_uint8array.ts +0 -53
  810. package/src/utils/sorted_list.ts +0 -240
  811. package/src/utils/starts_with.ts +0 -42
  812. package/src/utils/string_parsing.ts +0 -414
  813. package/src/utils/task_canceller.ts +0 -367
  814. package/src/utils/uniq.ts +0 -49
  815. package/src/utils/warn_once.ts +0 -34
  816. package/src/utils/weak_map_memory.ts +0 -89
  817. package/src/utils/wrapInPromise.ts +0 -24
  818. package/tsconfig.json +0 -28
  819. package/tsconfig.modules.json +0 -36
@@ -1,1280 +0,0 @@
1
- /**
2
- * Copyright 2015 CANAL+ Group
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- /**
18
- * This file is used to abstract the notion of text, audio and video tracks
19
- * switching for an easier API management.
20
- */
21
-
22
- import log from "../../../log";
23
- import {
24
- Adaptation,
25
- Period,
26
- Representation,
27
- } from "../../../manifest";
28
- import {
29
- IAudioTrack,
30
- IAudioTrackPreference,
31
- IAvailableAudioTrack,
32
- IAvailableTextTrack,
33
- IAvailableVideoTrack,
34
- ITextTrack,
35
- ITextTrackPreference,
36
- IVideoTrack,
37
- IVideoTrackPreference,
38
- } from "../../../public_types";
39
- import arrayFind from "../../../utils/array_find";
40
- import arrayIncludes from "../../../utils/array_includes";
41
- import isNullOrUndefined from "../../../utils/is_null_or_undefined";
42
- import normalizeLanguage from "../../../utils/languages";
43
- import objectAssign from "../../../utils/object_assign";
44
- import SharedReference from "../../../utils/reference";
45
- import SortedList from "../../../utils/sorted_list";
46
-
47
- /** Audio information stored for a single Period. */
48
- interface ITMPeriodAudioInfos {
49
- adaptations : Adaptation[];
50
- adaptationRef : SharedReference<Adaptation|null|undefined>;
51
- }
52
-
53
- /** Text information stored for a single Period. */
54
- interface ITMPeriodTextInfos {
55
- adaptations : Adaptation[];
56
- adaptationRef : SharedReference<Adaptation|null|undefined>;
57
- }
58
-
59
- /** Video information stored for a single Period. */
60
- interface ITMPeriodVideoInfos {
61
- adaptations : Adaptation[];
62
- adaptationRef : SharedReference<Adaptation|null|undefined>;
63
- }
64
-
65
- /** Every information stored for a single Period. */
66
- interface ITMPeriodInfos {
67
- period : Period;
68
- audio? : ITMPeriodAudioInfos;
69
- text? : ITMPeriodTextInfos;
70
- video? : ITMPeriodVideoInfos;
71
- }
72
-
73
- /** Audio track preference once normalized by the TrackChoiceManager. */
74
- type INormalizedPreferredAudioTrack = null |
75
- INormalizedPreferredAudioTrackObject;
76
-
77
- /** Audio track preference when it is not set to `null`. */
78
- interface INormalizedPreferredAudioTrackObject {
79
- normalized? : string | undefined;
80
- audioDescription? : boolean | undefined;
81
- codec? : { all: boolean;
82
- test: RegExp; } |
83
- undefined;
84
- }
85
-
86
- /** Text track preference once normalized by the TrackChoiceManager. */
87
- type INormalizedPreferredTextTrack = null |
88
- INormalizedPreferredTextTrackObject;
89
-
90
- /** Text track preference when it is not set to `null`. */
91
- interface INormalizedPreferredTextTrackObject {
92
- normalized : string;
93
- forced : boolean | undefined;
94
- closedCaption : boolean;
95
- }
96
-
97
- /**
98
- * Transform an array of IAudioTrackPreference into an array of
99
- * INormalizedPreferredAudioTrack to be exploited by the TrackChoiceManager.
100
- * @param {Array.<Object|null>} tracks
101
- * @returns {Array.<Object|null>}
102
- */
103
- function normalizeAudioTracks(
104
- tracks : IAudioTrackPreference[]
105
- ) : INormalizedPreferredAudioTrack[] {
106
- return tracks.map(t => t === null ?
107
- t :
108
- { normalized: t.language === undefined ? undefined :
109
- normalizeLanguage(t.language),
110
- audioDescription: t.audioDescription,
111
- codec: t.codec });
112
- }
113
-
114
- /**
115
- * Transform an array of ITextTrackPreference into an array of
116
- * INormalizedPreferredTextTrack to be exploited by the TrackChoiceManager.
117
- * @param {Array.<Object|null>} tracks
118
- * @returns {Array.<Object|null>}
119
- */
120
- function normalizeTextTracks(
121
- tracks : ITextTrackPreference[]
122
- ) : INormalizedPreferredTextTrack[] {
123
- return tracks.map(t => t === null ?
124
- t :
125
- { normalized: normalizeLanguage(t.language),
126
- forced: t.forced,
127
- closedCaption: t.closedCaption });
128
- }
129
-
130
- /**
131
- * Manage audio and text tracks for all active periods.
132
- * Choose the audio and text tracks for each period and record this choice.
133
- * @class TrackChoiceManager
134
- */
135
- export default class TrackChoiceManager {
136
- /**
137
- * Current Periods considered by the TrackChoiceManager.
138
- * Sorted by start time ascending
139
- */
140
- private _periods : SortedList<ITMPeriodInfos>;
141
-
142
- /**
143
- * Array of preferred settings for audio tracks.
144
- * Sorted by order of preference descending.
145
- */
146
- private _preferredAudioTracks : IAudioTrackPreference[];
147
-
148
- /**
149
- * Array of preferred languages for text tracks.
150
- * Sorted by order of preference descending.
151
- */
152
- private _preferredTextTracks : ITextTrackPreference[];
153
-
154
- /**
155
- * Array of preferred settings for video tracks.
156
- * Sorted by order of preference descending.
157
- */
158
- private _preferredVideoTracks : IVideoTrackPreference[];
159
-
160
- /** Memorization of the previously-chosen audio Adaptation for each Period. */
161
- private _audioChoiceMemory : WeakMap<Period, Adaptation|null>;
162
-
163
- /** Memorization of the previously-chosen text Adaptation for each Period. */
164
- private _textChoiceMemory : WeakMap<Period, Adaptation|null>;
165
-
166
- /** Memorization of the previously-chosen video Adaptation for each Period. */
167
- private _videoChoiceMemory : WeakMap<
168
- Period,
169
- {
170
- /**
171
- * The "base" Adaptation (if a trickmode track was chosen, this is the
172
- * Adaptation the trickmode track is linked to, and not the trickmode
173
- * track itself).
174
- */
175
- baseAdaptation : Adaptation;
176
- /**
177
- * The chosen Adaptation itself (may be different from `baseAdaptation`
178
- * when a trickmode track is chosen, in which case `baseAdaptation` is
179
- * the Adaptation the trickmode track is linked to and `adaptation` is the
180
- * trickmode track).
181
- */
182
- adaptation : Adaptation;
183
- } |
184
- /** Set to `null` when no video track was chosen. */
185
- null
186
- >;
187
-
188
- /** Tells if trick mode has been enabled by the RxPlayer user */
189
- public trickModeTrackEnabled: boolean;
190
-
191
- constructor(
192
- args : { preferTrickModeTracks: boolean }
193
- ) {
194
- this._periods = new SortedList((a, b) => a.period.start - b.period.start);
195
-
196
- this._audioChoiceMemory = new WeakMap();
197
- this._textChoiceMemory = new WeakMap();
198
- this._videoChoiceMemory = new WeakMap();
199
-
200
- this._preferredAudioTracks = [];
201
- this._preferredTextTracks = [];
202
- this._preferredVideoTracks = [];
203
- this.trickModeTrackEnabled = args.preferTrickModeTracks;
204
- }
205
-
206
- /**
207
- * Set the list of preferred audio tracks, in preference order.
208
- * @param {Array.<Object>} preferredAudioTracks
209
- * @param {boolean} shouldApply - `true` if those preferences should be
210
- * applied on the currently loaded Period. `false` if it should only
211
- * be applied to new content.
212
- */
213
- public setPreferredAudioTracks(
214
- preferredAudioTracks : IAudioTrackPreference[],
215
- shouldApply : boolean
216
- ) : void {
217
- this._preferredAudioTracks = preferredAudioTracks;
218
- if (shouldApply) {
219
- this._applyAudioPreferences();
220
- }
221
- }
222
-
223
- /**
224
- * Set the list of preferred text tracks, in preference order.
225
- * @param {Array.<Object>} preferredTextTracks
226
- * @param {boolean} shouldApply - `true` if those preferences should be
227
- * applied on the currently loaded Periods. `false` if it should only
228
- * be applied to new content.
229
- */
230
- public setPreferredTextTracks(
231
- preferredTextTracks : ITextTrackPreference[],
232
- shouldApply : boolean
233
- ) : void {
234
- this._preferredTextTracks = preferredTextTracks;
235
- if (shouldApply) {
236
- this._applyTextPreferences();
237
- }
238
- }
239
-
240
- /**
241
- * Set the list of preferred text tracks, in preference order.
242
- * @param {Array.<Object>} preferredVideoTracks
243
- * @param {boolean} shouldApply - `true` if those preferences should be
244
- * applied on the currently loaded Period. `false` if it should only
245
- * be applied to new content.
246
- */
247
- public setPreferredVideoTracks(
248
- preferredVideoTracks : IVideoTrackPreference[],
249
- shouldApply : boolean
250
- ) : void {
251
- this._preferredVideoTracks = preferredVideoTracks;
252
- if (shouldApply) {
253
- this._applyVideoPreferences();
254
- }
255
- }
256
-
257
- /**
258
- * Add shared reference to choose Adaptation for new "audio" or "text" Period.
259
- * @param {string} bufferType - The concerned buffer type
260
- * @param {Period} period - The concerned Period.
261
- * @param {Object} adaptationRef
262
- */
263
- public addPeriod(
264
- bufferType : "audio" | "text"| "video",
265
- period : Period,
266
- adaptationRef : SharedReference<Adaptation|null|undefined>
267
- ) : void {
268
- const periodItem = getPeriodItem(this._periods, period);
269
- const adaptations = period.getSupportedAdaptations(bufferType);
270
- if (periodItem !== undefined) {
271
- if (periodItem[bufferType] !== undefined) {
272
- log.warn(`TrackChoiceManager: ${bufferType} already added for period`,
273
- period.start);
274
- return;
275
- } else {
276
- periodItem[bufferType] = { adaptations, adaptationRef };
277
- }
278
- } else {
279
- this._periods.add({ period,
280
- [bufferType]: { adaptations, adaptationRef } });
281
- }
282
- }
283
-
284
- /**
285
- * Remove shared reference to choose an "audio", "video" or "text" Adaptation
286
- * for a Period.
287
- * @param {string} bufferType - The concerned buffer type
288
- * @param {Period} period - The concerned Period.
289
- */
290
- public removePeriod(
291
- bufferType : "audio" | "text" | "video",
292
- period : Period
293
- ) : void {
294
- const periodIndex = findPeriodIndex(this._periods, period);
295
- if (periodIndex === undefined) {
296
- log.warn(`TrackChoiceManager: ${bufferType} not found for period`,
297
- period.start);
298
- return;
299
- }
300
-
301
- const periodItem = this._periods.get(periodIndex);
302
- if (periodItem[bufferType] === undefined) {
303
- log.warn(`TrackChoiceManager: ${bufferType} already removed for period`,
304
- period.start);
305
- return;
306
- }
307
- delete periodItem[bufferType];
308
- if (periodItem.audio === undefined &&
309
- periodItem.text === undefined &&
310
- periodItem.video === undefined)
311
- {
312
- this._periods.removeElement(periodItem);
313
- }
314
- }
315
-
316
- public resetPeriods() : void {
317
- while (this._periods.length() > 0) {
318
- this._periods.pop();
319
- }
320
- }
321
-
322
- /**
323
- * Update the choice of all added Periods based on:
324
- * 1. What was the last chosen adaptation
325
- * 2. If not found, the preferences
326
- */
327
- public update() : void {
328
- this._resetChosenAudioTracks();
329
- this._resetChosenTextTracks();
330
- this._resetChosenVideoTracks();
331
- }
332
-
333
- /**
334
- * Emit initial audio Adaptation through the given shared reference based on:
335
- * - the preferred audio tracks
336
- * - the last choice for this period, if one
337
- * @param {Period} period - The concerned Period.
338
- */
339
- public setInitialAudioTrack(period : Period) : void {
340
- const periodItem = getPeriodItem(this._periods, period);
341
- const audioInfos = periodItem !== undefined ? periodItem.audio :
342
- null;
343
- if (isNullOrUndefined(audioInfos) || periodItem === undefined) {
344
- throw new Error("TrackChoiceManager: Given Period not found.");
345
- }
346
-
347
- const audioAdaptations = period.getSupportedAdaptations("audio");
348
- const chosenAudioAdaptation = this._audioChoiceMemory.get(period);
349
-
350
- if (chosenAudioAdaptation === null) {
351
- // If the Period was previously without audio, keep it that way
352
- audioInfos.adaptationRef.setValue(null);
353
- } else if (chosenAudioAdaptation === undefined ||
354
- !arrayIncludes(audioAdaptations, chosenAudioAdaptation)
355
- ) {
356
- // Find the optimal audio Adaptation
357
- const preferredAudioTracks = this._preferredAudioTracks;
358
- const normalizedPref = normalizeAudioTracks(preferredAudioTracks);
359
- const optimalAdaptation = findFirstOptimalAudioAdaptation(audioAdaptations,
360
- normalizedPref);
361
-
362
- this._audioChoiceMemory.set(period, optimalAdaptation);
363
- audioInfos.adaptationRef.setValue(optimalAdaptation);
364
- } else {
365
- audioInfos.adaptationRef.setValue(chosenAudioAdaptation); // set last one
366
- }
367
- }
368
-
369
- /**
370
- * Emit initial text Adaptation through the given shared reference based on:
371
- * - the preferred text tracks
372
- * - the last choice for this period, if one
373
- * @param {Period} period - The concerned Period.
374
- */
375
- public setInitialTextTrack(period : Period) : void {
376
- const periodItem = getPeriodItem(this._periods, period);
377
- const textInfos = periodItem !== undefined ? periodItem.text :
378
- null;
379
- if (isNullOrUndefined(textInfos) || periodItem === undefined) {
380
- throw new Error("TrackChoiceManager: Given Period not found.");
381
- }
382
-
383
- const textAdaptations = period.getSupportedAdaptations("text");
384
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
385
- if (chosenTextAdaptation === null) {
386
- // If the Period was previously without text, keep it that way
387
- textInfos.adaptationRef.setValue(null);
388
- } else if (chosenTextAdaptation === undefined ||
389
- !arrayIncludes(textAdaptations, chosenTextAdaptation)
390
- ) {
391
- // Find the optimal text Adaptation
392
- const preferredTextTracks = this._preferredTextTracks;
393
- const normalizedPref = normalizeTextTracks(preferredTextTracks);
394
- const optimalAdaptation = findFirstOptimalTextAdaptation(
395
- textAdaptations,
396
- normalizedPref,
397
- this._audioChoiceMemory.get(period));
398
- this._textChoiceMemory.set(period, optimalAdaptation);
399
- textInfos.adaptationRef.setValue(optimalAdaptation);
400
- } else {
401
- textInfos.adaptationRef.setValue(chosenTextAdaptation); // set last one
402
- }
403
- }
404
-
405
- /**
406
- * Emit initial video Adaptation through the given shared reference based on:
407
- * - the preferred video tracks
408
- * - the last choice for this period, if one
409
- * @param {Period} period - The concerned Period.
410
- */
411
- public setInitialVideoTrack(period : Period) : void {
412
- const periodItem = getPeriodItem(this._periods, period);
413
- const videoInfos = periodItem !== undefined ? periodItem.video :
414
- null;
415
- if (isNullOrUndefined(videoInfos) || periodItem === undefined) {
416
- throw new Error("TrackChoiceManager: Given Period not found.");
417
- }
418
-
419
- const videoAdaptations = period.getSupportedAdaptations("video");
420
-
421
- const prevVideoAdaptation = this._videoChoiceMemory.get(period);
422
- let newBaseAdaptation : Adaptation | null;
423
-
424
- if (prevVideoAdaptation === null) {
425
- newBaseAdaptation = null;
426
- } else if (prevVideoAdaptation !== undefined &&
427
- arrayIncludes(videoAdaptations, prevVideoAdaptation.baseAdaptation))
428
- {
429
- // still exists, re-select it
430
- newBaseAdaptation = prevVideoAdaptation.baseAdaptation;
431
- } else {
432
- // If that Adaptation does not exist (e.g. no choice has been made or it
433
- // is not in the Manifest anymore), look at preferences
434
- const preferredVideoTracks = this._preferredVideoTracks;
435
- newBaseAdaptation = findFirstOptimalVideoAdaptation(videoAdaptations,
436
- preferredVideoTracks);
437
- }
438
-
439
- if (newBaseAdaptation === null) {
440
- this._videoChoiceMemory.set(period, null);
441
- videoInfos.adaptationRef.setValue(null);
442
- return;
443
- }
444
-
445
- const newVideoAdaptation = getRightVideoTrack(newBaseAdaptation,
446
- this.trickModeTrackEnabled);
447
- this._videoChoiceMemory.set(period, { baseAdaptation: newBaseAdaptation,
448
- adaptation: newVideoAdaptation });
449
- videoInfos.adaptationRef.setValue(newVideoAdaptation);
450
- }
451
-
452
- /**
453
- * Set audio track based on the ID of its adaptation for a given added Period.
454
- * @param {Period} period - The concerned Period.
455
- * @param {string} wantedId - adaptation id of the wanted track
456
- */
457
- public setAudioTrackByID(period : Period, wantedId : string) : void {
458
- const periodItem = getPeriodItem(this._periods, period);
459
- const audioInfos = periodItem !== undefined ? periodItem.audio :
460
- null;
461
- if (isNullOrUndefined(audioInfos)) {
462
- throw new Error("TrackChoiceManager: Given Period not found.");
463
- }
464
-
465
- const wantedAdaptation = arrayFind(audioInfos.adaptations,
466
- ({ id }) => id === wantedId);
467
-
468
- if (wantedAdaptation === undefined) {
469
- throw new Error("Audio Track not found.");
470
- }
471
- const chosenAudioAdaptation = this._audioChoiceMemory.get(period);
472
- if (chosenAudioAdaptation === wantedAdaptation) {
473
- return;
474
- }
475
-
476
- this._audioChoiceMemory.set(period, wantedAdaptation);
477
- audioInfos.adaptationRef.setValue(wantedAdaptation);
478
- }
479
-
480
- /**
481
- * Set text track based on the ID of its adaptation for a given added Period.
482
- * @param {Period} period - The concerned Period.
483
- * @param {string} wantedId - adaptation id of the wanted track
484
- */
485
- public setTextTrackByID(period : Period, wantedId : string) : void {
486
- const periodItem = getPeriodItem(this._periods, period);
487
- const textInfos = periodItem !== undefined ? periodItem.text :
488
- null;
489
- if (isNullOrUndefined(textInfos)) {
490
- throw new Error("TrackChoiceManager: Given Period not found.");
491
- }
492
- const wantedAdaptation = arrayFind(textInfos.adaptations,
493
- ({ id }) => id === wantedId);
494
-
495
- if (wantedAdaptation === undefined) {
496
- throw new Error("Text Track not found.");
497
- }
498
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
499
- if (chosenTextAdaptation === wantedAdaptation) {
500
- return;
501
- }
502
-
503
- this._textChoiceMemory.set(period, wantedAdaptation);
504
- textInfos.adaptationRef.setValue(wantedAdaptation);
505
- }
506
-
507
- /**
508
- * Set video track based on the ID of its adaptation for a given added Period.
509
- * @param {Period} period - The concerned Period.
510
- * @param {string} wantedId - adaptation id of the wanted track
511
- *
512
- * @throws Error - Throws if the period given has not been added
513
- * @throws Error - Throws if the given id is not found in any video adaptation
514
- * of the given Period.
515
- */
516
- public setVideoTrackByID(period : Period, wantedId : string) : void {
517
- const periodItem = getPeriodItem(this._periods, period);
518
- const videoInfos = periodItem !== undefined ? periodItem.video :
519
- null;
520
- if (isNullOrUndefined(videoInfos)) {
521
- throw new Error("LanguageManager: Given Period not found.");
522
- }
523
-
524
- const wantedBaseAdaptation = arrayFind(videoInfos.adaptations,
525
- ({ id }) => id === wantedId);
526
-
527
- if (wantedBaseAdaptation === undefined) {
528
- throw new Error("Video Track not found.");
529
- }
530
-
531
- const newVideoAdaptation = getRightVideoTrack(wantedBaseAdaptation,
532
- this.trickModeTrackEnabled);
533
- this._videoChoiceMemory.set(period, { baseAdaptation: wantedBaseAdaptation,
534
- adaptation: newVideoAdaptation });
535
- videoInfos.adaptationRef.setValue(newVideoAdaptation);
536
- }
537
-
538
- /**
539
- * Disable the current text track for a given period.
540
- *
541
- * @param {Period} period - The concerned Period.
542
- *
543
- * @throws Error - Throws if the period given has not been added
544
- */
545
- public disableTextTrack(period : Period) : void {
546
- const periodItem = getPeriodItem(this._periods, period);
547
- const textInfos = periodItem !== undefined ? periodItem.text :
548
- null;
549
- if (isNullOrUndefined(textInfos)) {
550
- throw new Error("TrackChoiceManager: Given Period not found.");
551
- }
552
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
553
- if (chosenTextAdaptation === null) {
554
- return;
555
- }
556
-
557
- this._textChoiceMemory.set(period, null);
558
- textInfos.adaptationRef.setValue(null);
559
- }
560
-
561
- /**
562
- * Disable the current video track for a given period.
563
- * @param {Object} period
564
- * @throws Error - Throws if the period given has not been added
565
- */
566
- public disableVideoTrack(period : Period) : void {
567
- const periodItem = getPeriodItem(this._periods, period);
568
- const videoInfos = periodItem?.video;
569
- if (videoInfos === undefined) {
570
- throw new Error("TrackManager: Given Period not found.");
571
- }
572
- const chosenVideoAdaptation = this._videoChoiceMemory.get(period);
573
- if (chosenVideoAdaptation === null) {
574
- return;
575
- }
576
- this._videoChoiceMemory.set(period, null);
577
- videoInfos.adaptationRef.setValue(null);
578
- }
579
-
580
- public disableVideoTrickModeTracks(): void {
581
- this.trickModeTrackEnabled = false;
582
- this._resetChosenVideoTracks();
583
- }
584
-
585
- public enableVideoTrickModeTracks() : void {
586
- this.trickModeTrackEnabled = true;
587
- this._resetChosenVideoTracks();
588
- }
589
-
590
- /**
591
- * @returns {boolean}
592
- */
593
- public isTrickModeEnabled() : boolean {
594
- return this.trickModeTrackEnabled;
595
- }
596
-
597
- /**
598
- * Returns an object describing the chosen audio track for the given audio
599
- * Period.
600
- *
601
- * Returns null is the the current audio track is disabled or not
602
- * set yet.
603
- *
604
- * @param {Period} period - The concerned Period.
605
- * @returns {Object|null} - The audio track chosen for this Period
606
- */
607
- public getChosenAudioTrack(period : Period) : IAudioTrack|null {
608
- const periodItem = getPeriodItem(this._periods, period);
609
- const audioInfos = periodItem !== undefined ? periodItem.audio :
610
- null;
611
- if (isNullOrUndefined(audioInfos)) {
612
- return null;
613
- }
614
-
615
- const chosenTrack = this._audioChoiceMemory.get(period);
616
- if (isNullOrUndefined(chosenTrack)) {
617
- return null;
618
- }
619
- return chosenTrack.toAudioTrack();
620
- }
621
-
622
- /**
623
- * Returns an object describing the chosen text track for the given text
624
- * Period.
625
- *
626
- * Returns null is the the current text track is disabled or not
627
- * set yet.
628
- *
629
- * @param {Period} period - The concerned Period.
630
- * @returns {Object|null} - The text track chosen for this Period
631
- */
632
- public getChosenTextTrack(period : Period) : ITextTrack|null {
633
- const periodItem = getPeriodItem(this._periods, period);
634
- const textInfos = periodItem !== undefined ? periodItem.text :
635
- null;
636
- if (isNullOrUndefined(textInfos)) {
637
- return null;
638
- }
639
-
640
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
641
- if (isNullOrUndefined(chosenTextAdaptation)) {
642
- return null;
643
- }
644
- return chosenTextAdaptation.toTextTrack();
645
- }
646
-
647
- /**
648
- * Returns an object describing the chosen video track for the given video
649
- * Period.
650
- *
651
- * Returns null is the the current video track is disabled or not
652
- * set yet.
653
- *
654
- * @param {Period} period - The concerned Period.
655
- * @returns {Object|null} - The video track chosen for this Period
656
- */
657
- public getChosenVideoTrack(period : Period) : IVideoTrack|null {
658
- const periodItem = getPeriodItem(this._periods, period);
659
- const videoInfos = periodItem !== undefined ? periodItem.video :
660
- null;
661
- if (isNullOrUndefined(videoInfos)) {
662
- return null;
663
- }
664
-
665
- const chosenVideoAdaptation = this._videoChoiceMemory.get(period);
666
- if (isNullOrUndefined(chosenVideoAdaptation)) {
667
- return null;
668
- }
669
- const currAdaptation = chosenVideoAdaptation.adaptation;
670
- return currAdaptation.toVideoTrack();
671
- }
672
-
673
- /**
674
- * Returns all available audio tracks for a given Period, as an array of
675
- * objects.
676
- *
677
- * @returns {Array.<Object>}
678
- */
679
- public getAvailableAudioTracks(period : Period) : IAvailableAudioTrack[] {
680
- const periodItem = getPeriodItem(this._periods, period);
681
- const audioInfos = periodItem !== undefined ? periodItem.audio :
682
- null;
683
- if (isNullOrUndefined(audioInfos)) {
684
- return [];
685
- }
686
-
687
- const chosenAudioAdaptation = this._audioChoiceMemory.get(period);
688
- const currentId = !isNullOrUndefined(chosenAudioAdaptation) ?
689
- chosenAudioAdaptation.id :
690
- null;
691
-
692
- return audioInfos.adaptations
693
- .map((adaptation) => {
694
- const active = currentId === null ? false :
695
- currentId === adaptation.id;
696
- return objectAssign(adaptation.toAudioTrack(), { active });
697
- });
698
- }
699
-
700
- /**
701
- * Returns all available text tracks for a given Period, as an array of
702
- * objects.
703
- *
704
- * @param {Period} period
705
- * @returns {Array.<Object>}
706
- */
707
- public getAvailableTextTracks(period : Period) : IAvailableTextTrack[] {
708
- const periodItem = getPeriodItem(this._periods, period);
709
- const textInfos = periodItem !== undefined ? periodItem.text :
710
- null;
711
- if (isNullOrUndefined(textInfos)) {
712
- return [];
713
- }
714
-
715
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
716
- const currentId = !isNullOrUndefined(chosenTextAdaptation) ?
717
- chosenTextAdaptation.id :
718
- null;
719
-
720
- return textInfos.adaptations
721
- .map((adaptation) => {
722
- const active = currentId === null ? false :
723
- currentId === adaptation.id;
724
- return objectAssign(adaptation.toTextTrack(), { active });
725
- });
726
- }
727
-
728
- /**
729
- * Returns all available video tracks for a given Period, as an array of
730
- * objects.
731
- *
732
- * @returns {Array.<Object>}
733
- */
734
- public getAvailableVideoTracks(period : Period) : IAvailableVideoTrack[] {
735
- const periodItem = getPeriodItem(this._periods, period);
736
- const videoInfos = periodItem !== undefined ? periodItem.video :
737
- null;
738
- if (isNullOrUndefined(videoInfos)) {
739
- return [];
740
- }
741
-
742
- const chosenVideoAdaptation = this._videoChoiceMemory.get(period);
743
- const currentId = chosenVideoAdaptation === undefined ?
744
- undefined :
745
- chosenVideoAdaptation?.adaptation.id ?? undefined;
746
-
747
- return videoInfos.adaptations
748
- .map((adaptation) => {
749
- const active = currentId === null ? false :
750
- currentId === adaptation.id;
751
- const track = adaptation.toVideoTrack();
752
- const trickModeTracks = track.trickModeTracks !== undefined ?
753
- track.trickModeTracks.map((trickModeAdaptation) => {
754
- const isActive = currentId === null ? false :
755
- currentId === trickModeAdaptation.id;
756
- return objectAssign(trickModeAdaptation, { active: isActive });
757
- }) :
758
- [];
759
- const availableTrack = objectAssign(track, { active });
760
- if (trickModeTracks !== undefined) {
761
- availableTrack.trickModeTracks = trickModeTracks;
762
- }
763
- return availableTrack;
764
- });
765
- }
766
-
767
- /**
768
- * Reset all audio tracks choices to corresponds to the current preferences.
769
- */
770
- private _applyAudioPreferences() : void {
771
- // Remove all memorized choices and start over
772
- this._audioChoiceMemory = new WeakMap();
773
- this._resetChosenAudioTracks();
774
- }
775
-
776
- /**
777
- * Reset all text tracks choices to corresponds to the current preferences.
778
- */
779
- private _applyTextPreferences() : void {
780
- // Remove all memorized choices and start over
781
- this._textChoiceMemory = new WeakMap();
782
- this._resetChosenTextTracks();
783
- }
784
-
785
- /**
786
- * Reset all video tracks choices to corresponds to the current preferences.
787
- */
788
- private _applyVideoPreferences() : void {
789
- // Remove all memorized choices and start over
790
- this._videoChoiceMemory = new WeakMap();
791
- this._resetChosenVideoTracks();
792
- }
793
-
794
- /**
795
- * Choose again the best audio tracks for all current Periods.
796
- * This is based on two things:
797
- * 1. what was the track previously chosen for that Period (by checking
798
- * `this._audioChoiceMemory`).
799
- * 2. If no track were previously chosen or if it is not available anymore
800
- * we check the audio preferences.
801
- */
802
- private _resetChosenAudioTracks() {
803
- const preferredAudioTracks = this._preferredAudioTracks;
804
- const normalizedPref = normalizeAudioTracks(preferredAudioTracks);
805
-
806
- const recursiveUpdateAudioTrack = (index : number) : void => {
807
- if (index >= this._periods.length()) {
808
- // we did all audio Periods, exit
809
- return;
810
- }
811
-
812
- const periodItem = this._periods.get(index);
813
- if (isNullOrUndefined(periodItem.audio)) {
814
- // No audio choice for this period, check next one
815
- recursiveUpdateAudioTrack(index + 1);
816
- return;
817
- }
818
-
819
- const { period,
820
- audio: audioItem } = periodItem;
821
- const audioAdaptations = period.getSupportedAdaptations("audio");
822
- const chosenAudioAdaptation = this._audioChoiceMemory.get(period);
823
-
824
- if (chosenAudioAdaptation === null ||
825
- (
826
- chosenAudioAdaptation !== undefined &&
827
- arrayIncludes(audioAdaptations, chosenAudioAdaptation)
828
- )
829
- ) {
830
- // Already best audio for this Period, check next one
831
- recursiveUpdateAudioTrack(index + 1);
832
- return;
833
- }
834
-
835
- const optimalAdaptation = findFirstOptimalAudioAdaptation(audioAdaptations,
836
- normalizedPref);
837
-
838
- this._audioChoiceMemory.set(period, optimalAdaptation);
839
- audioItem.adaptationRef.setValue(optimalAdaptation);
840
-
841
- // previous "next" call could have changed everything, start over
842
- recursiveUpdateAudioTrack(0);
843
- };
844
-
845
- recursiveUpdateAudioTrack(0);
846
- }
847
-
848
- /**
849
- * Choose again the best text tracks for all current Periods.
850
- * This is based on two things:
851
- * 1. what was the track previously chosen for that Period (by checking
852
- * `this._textChoiceMemory`).
853
- * 2. If no track were previously chosen or if it is not available anymore
854
- * we check the text preferences.
855
- */
856
- private _resetChosenTextTracks() {
857
- const preferredTextTracks = this._preferredTextTracks;
858
- const normalizedPref = normalizeTextTracks(preferredTextTracks);
859
-
860
- const recursiveUpdateTextTrack = (index : number) : void => {
861
- if (index >= this._periods.length()) {
862
- // we did all text Periods, exit
863
- return;
864
- }
865
-
866
- const periodItem = this._periods.get(index);
867
- if (isNullOrUndefined(periodItem.text)) {
868
- // No text choice for this period, check next one
869
- recursiveUpdateTextTrack(index + 1);
870
- return;
871
- }
872
-
873
- const { period,
874
- text: textItem } = periodItem;
875
- const textAdaptations = period.getSupportedAdaptations("text");
876
- const chosenTextAdaptation = this._textChoiceMemory.get(period);
877
-
878
- if (chosenTextAdaptation === null ||
879
- (
880
- chosenTextAdaptation !== undefined &&
881
- arrayIncludes(textAdaptations, chosenTextAdaptation)
882
- )
883
- ) {
884
- // Already best text for this Period, check next one
885
- recursiveUpdateTextTrack(index + 1);
886
- return;
887
- }
888
-
889
- const optimalAdaptation = findFirstOptimalTextAdaptation(
890
- textAdaptations,
891
- normalizedPref,
892
- this._audioChoiceMemory.get(period));
893
-
894
- this._textChoiceMemory.set(period, optimalAdaptation);
895
- textItem.adaptationRef.setValue(optimalAdaptation);
896
-
897
- // previous "next" call could have changed everything, start over
898
- recursiveUpdateTextTrack(0);
899
- };
900
-
901
- recursiveUpdateTextTrack(0);
902
- }
903
-
904
- /**
905
- * Choose again the best video tracks for all current Periods.
906
- * This is based on two things:
907
- * 1. what was the track previously chosen for that Period (by checking
908
- * `this._videoChoiceMemory`).
909
- * 2. If no track were previously chosen or if it is not available anymore
910
- * we check the video preferences.
911
- */
912
- private _resetChosenVideoTracks() {
913
- const preferredVideoTracks = this._preferredVideoTracks;
914
- const recursiveUpdateVideoTrack = (index : number) : void => {
915
- if (index >= this._periods.length()) {
916
- // we did all video Periods, exit
917
- return;
918
- }
919
-
920
- const periodItem = this._periods.get(index);
921
- if (isNullOrUndefined(periodItem.video)) {
922
- // No video choice for this period, check next one
923
- recursiveUpdateVideoTrack(index + 1);
924
- return;
925
- }
926
-
927
- const { period, video: videoItem } = periodItem;
928
- const videoAdaptations = period.getSupportedAdaptations("video");
929
- const chosenVideoAdaptation = this._videoChoiceMemory.get(period);
930
-
931
- if (chosenVideoAdaptation === null) {
932
- // No video track for that one, so nothing to change.
933
- recursiveUpdateVideoTrack(index + 1);
934
- return;
935
- } else if (chosenVideoAdaptation !== undefined &&
936
- arrayIncludes(videoAdaptations,
937
- chosenVideoAdaptation.baseAdaptation))
938
- {
939
- // The right Base Adaptation is selected and is still available.
940
- // Check if the selected Adaptation is still right
941
- const wantedVideoAdaptation = getRightVideoTrack(
942
- chosenVideoAdaptation.baseAdaptation,
943
- this.trickModeTrackEnabled
944
- );
945
- if (wantedVideoAdaptation.id === chosenVideoAdaptation.adaptation.id) {
946
- // We're good, continue.
947
- recursiveUpdateVideoTrack(index + 1);
948
- return;
949
- } else {
950
- // select the right track
951
- this._videoChoiceMemory.set(period, {
952
- baseAdaptation: chosenVideoAdaptation.baseAdaptation,
953
- adaptation: wantedVideoAdaptation,
954
- });
955
- videoItem.adaptationRef.setValue(wantedVideoAdaptation);
956
-
957
- // previous "next" call could have changed everything, start over
958
- return recursiveUpdateVideoTrack(0);
959
- }
960
- }
961
-
962
- const optimalAdaptation = findFirstOptimalVideoAdaptation(videoAdaptations,
963
- preferredVideoTracks);
964
- if (optimalAdaptation === null) {
965
- this._videoChoiceMemory.set(period, null);
966
- videoItem.adaptationRef.setValue(null);
967
- // previous "next" call could have changed everything, start over
968
- return recursiveUpdateVideoTrack(0);
969
- }
970
-
971
- const newVideoAdaptation = getRightVideoTrack(optimalAdaptation,
972
- this.trickModeTrackEnabled);
973
- this._videoChoiceMemory.set(period, { baseAdaptation: optimalAdaptation,
974
- adaptation: newVideoAdaptation });
975
- videoItem.adaptationRef.setValue(newVideoAdaptation);
976
-
977
- // previous "next" call could have changed everything, start over
978
- return recursiveUpdateVideoTrack(0);
979
- };
980
-
981
- recursiveUpdateVideoTrack(0);
982
- }
983
- }
984
-
985
- /**
986
- * Create a function allowing to compare audio Adaptations with a given
987
- * `preferredAudioTrack` preference to see if they match.
988
- *
989
- * This function is curried to be easily and optimally used in a loop context.
990
- *
991
- * @param {Object} preferredAudioTrack - The audio track preference you want to
992
- * compare audio Adaptations to.
993
- * @returns {Function} - Function taking in argument an audio Adaptation and
994
- * returning `true` if it matches the `preferredAudioTrack` preference (and
995
- * `false` otherwise.
996
- */
997
- function createAudioPreferenceMatcher(
998
- preferredAudioTrack : INormalizedPreferredAudioTrackObject
999
- ) : (audioAdaptation : Adaptation) => boolean {
1000
- /**
1001
- * Compares an audio Adaptation to the given `preferredAudioTrack` preference.
1002
- * Returns `true` if it matches, false otherwise.
1003
- * @param {Object} audioAdaptation
1004
- * @returns {boolean}
1005
- */
1006
- return function matchAudioPreference(audioAdaptation : Adaptation) : boolean {
1007
- if (preferredAudioTrack.normalized !== undefined) {
1008
- const language = audioAdaptation.normalizedLanguage ?? "";
1009
- if (language !== preferredAudioTrack.normalized) {
1010
- return false;
1011
- }
1012
- }
1013
- if (preferredAudioTrack.audioDescription !== undefined) {
1014
- if (preferredAudioTrack.audioDescription) {
1015
- if (audioAdaptation.isAudioDescription !== true) {
1016
- return false;
1017
- }
1018
- } else if (audioAdaptation.isAudioDescription === true) {
1019
- return false;
1020
- }
1021
- }
1022
- if (preferredAudioTrack.codec === undefined) {
1023
- return true;
1024
- }
1025
- const regxp = preferredAudioTrack.codec.test;
1026
- const codecTestingFn = (rep : Representation) =>
1027
- rep.codec !== undefined && regxp.test(rep.codec);
1028
-
1029
- if (preferredAudioTrack.codec.all) {
1030
- return audioAdaptation.representations.every(codecTestingFn);
1031
- }
1032
- return audioAdaptation.representations.some(codecTestingFn);
1033
- };
1034
- }
1035
-
1036
- /**
1037
- * Find an optimal audio adaptation given their list and the array of preferred
1038
- * audio tracks sorted from the most preferred to the least preferred.
1039
- *
1040
- * `null` if the most optimal audio adaptation is no audio adaptation.
1041
- * @param {Array.<Adaptation>} audioAdaptations
1042
- * @param {Array.<Object|null>} preferredAudioTracks
1043
- * @returns {Adaptation|null}
1044
- */
1045
- function findFirstOptimalAudioAdaptation(
1046
- audioAdaptations : Adaptation[],
1047
- preferredAudioTracks : INormalizedPreferredAudioTrack[]
1048
- ) : Adaptation|null {
1049
- if (audioAdaptations.length === 0) {
1050
- return null;
1051
- }
1052
-
1053
- for (let i = 0; i < preferredAudioTracks.length; i++) {
1054
- const preferredAudioTrack = preferredAudioTracks[i];
1055
-
1056
- if (preferredAudioTrack === null) {
1057
- return null;
1058
- }
1059
-
1060
- const matchPreferredAudio = createAudioPreferenceMatcher(preferredAudioTrack);
1061
- const foundAdaptation = arrayFind(audioAdaptations, matchPreferredAudio);
1062
-
1063
- if (foundAdaptation !== undefined) {
1064
- return foundAdaptation;
1065
- }
1066
- }
1067
-
1068
- // no optimal adaptation, just return the first one
1069
- return audioAdaptations[0];
1070
- }
1071
-
1072
- /**
1073
- * Create a function allowing to compare text Adaptations with a given
1074
- * `preferredTextTrack` preference to see if they match.
1075
- *
1076
- * This function is curried to be easily and optimally used in a loop context.
1077
- *
1078
- * @param {Object} preferredTextTrack - The text track preference you want to
1079
- * compare text Adaptations to.
1080
- * @returns {Function} - Function taking in argument a text Adaptation and
1081
- * returning `true` if it matches the `preferredTextTrack` preference (and
1082
- * `false` otherwise.
1083
- */
1084
- function createTextPreferenceMatcher(
1085
- preferredTextTrack : INormalizedPreferredTextTrackObject
1086
- ) : (textAdaptation : Adaptation) => boolean {
1087
- /**
1088
- * Compares a text Adaptation to the given `preferredTextTrack` preference.
1089
- * Returns `true` if it matches, false otherwise.
1090
- * @param {Object} textAdaptation
1091
- * @returns {boolean}
1092
- */
1093
- return function matchTextPreference(textAdaptation : Adaptation) : boolean {
1094
- return (textAdaptation.normalizedLanguage ?? "") === preferredTextTrack.normalized &&
1095
- (preferredTextTrack.closedCaption ? textAdaptation.isClosedCaption === true :
1096
- textAdaptation.isClosedCaption !== true) &&
1097
- (preferredTextTrack.forced === true ? textAdaptation.isForcedSubtitles === true :
1098
- textAdaptation.isForcedSubtitles !== true);
1099
- };
1100
- }
1101
-
1102
- /**
1103
- * Find an optimal text adaptation given their list and the array of preferred
1104
- * text tracks sorted from the most preferred to the least preferred.
1105
- *
1106
- * `null` if the most optimal text adaptation is no text adaptation.
1107
- * @param {Array.<Object>} textAdaptations
1108
- * @param {Array.<Object|null>} preferredTextTracks
1109
- * @param {Object|null|undefined} chosenAudioAdaptation
1110
- * @returns {Adaptation|null}
1111
- */
1112
- function findFirstOptimalTextAdaptation(
1113
- textAdaptations : Adaptation[],
1114
- preferredTextTracks : INormalizedPreferredTextTrack[],
1115
- chosenAudioAdaptation : Adaptation | null | undefined
1116
- ) : Adaptation | null {
1117
- if (textAdaptations.length === 0) {
1118
- return null;
1119
- }
1120
-
1121
- for (let i = 0; i < preferredTextTracks.length; i++) {
1122
- const preferredTextTrack = preferredTextTracks[i];
1123
-
1124
- if (preferredTextTrack === null) {
1125
- return null;
1126
- }
1127
-
1128
- const matchPreferredText = createTextPreferenceMatcher(preferredTextTrack);
1129
- const foundAdaptation = arrayFind(textAdaptations, matchPreferredText);
1130
-
1131
- if (foundAdaptation !== undefined) {
1132
- return foundAdaptation;
1133
- }
1134
- }
1135
-
1136
- const forcedSubtitles = textAdaptations.filter((ad) => ad.isForcedSubtitles === true);
1137
- if (forcedSubtitles.length > 0) {
1138
- if (chosenAudioAdaptation !== null && chosenAudioAdaptation !== undefined) {
1139
- const sameLanguage = arrayFind(forcedSubtitles, (f) =>
1140
- f.normalizedLanguage === chosenAudioAdaptation.normalizedLanguage);
1141
- if (sameLanguage !== undefined) {
1142
- return sameLanguage;
1143
- }
1144
- }
1145
- return arrayFind(forcedSubtitles, (f) => f.normalizedLanguage === undefined) ??
1146
- null;
1147
- }
1148
-
1149
- // no optimal adaptation
1150
- return null;
1151
- }
1152
-
1153
- /**
1154
- * Create a function allowing to compare video Adaptations with a given
1155
- * `preferredVideoTrack` preference to see if they match.
1156
- *
1157
- * This function is curried to be easily and optimally used in a loop context.
1158
- *
1159
- * @param {Object} preferredVideoTrack - The video track preference you want to
1160
- * compare video Adaptations to.
1161
- * @returns {Function} - Function taking in argument a video Adaptation and
1162
- * returning `true` if it matches the `preferredVideoTrack` preference (and
1163
- * `false` otherwise.
1164
- */
1165
- function createVideoPreferenceMatcher(
1166
- preferredVideoTrack : Exclude<IVideoTrackPreference, null>
1167
- ) : (videoAdaptation : Adaptation) => boolean {
1168
- /**
1169
- * Compares a video Adaptation to the given `preferredVideoTrack` preference.
1170
- * Returns `true` if it matches, false otherwise.
1171
- * @param {Object} videoAdaptation
1172
- * @returns {boolean}
1173
- */
1174
- return function matchVideoPreference(videoAdaptation : Adaptation) : boolean {
1175
- if (preferredVideoTrack.signInterpreted !== undefined &&
1176
- preferredVideoTrack.signInterpreted !== videoAdaptation.isSignInterpreted)
1177
- {
1178
- return false;
1179
- }
1180
- if (preferredVideoTrack.codec === undefined) {
1181
- return true;
1182
- }
1183
- const regxp = preferredVideoTrack.codec.test;
1184
- const codecTestingFn = (rep : Representation) =>
1185
- rep.codec !== undefined && regxp.test(rep.codec);
1186
-
1187
- if (preferredVideoTrack.codec.all) {
1188
- return videoAdaptation.representations.every(codecTestingFn);
1189
- }
1190
- return videoAdaptation.representations.some(codecTestingFn);
1191
- };
1192
- }
1193
-
1194
- /**
1195
- * Find an optimal video adaptation given their list and the array of preferred
1196
- * video tracks sorted from the most preferred to the least preferred.
1197
- *
1198
- * `null` if the most optimal video adaptation is no video adaptation.
1199
- * @param {Array.<Adaptation>} videoAdaptations
1200
- * @param {Array.<Object|null>} preferredVideoTracks
1201
- * @returns {Adaptation|null}
1202
- */
1203
- function findFirstOptimalVideoAdaptation(
1204
- videoAdaptations : Adaptation[],
1205
- preferredVideoTracks : IVideoTrackPreference[]
1206
- ) : Adaptation|null {
1207
- if (videoAdaptations.length === 0) {
1208
- return null;
1209
- }
1210
-
1211
- for (let i = 0; i < preferredVideoTracks.length; i++) {
1212
- const preferredVideoTrack = preferredVideoTracks[i];
1213
-
1214
- if (preferredVideoTrack === null) {
1215
- return null;
1216
- }
1217
-
1218
- const matchPreferredVideo = createVideoPreferenceMatcher(preferredVideoTrack);
1219
- const foundAdaptation = arrayFind(videoAdaptations, matchPreferredVideo);
1220
-
1221
- if (foundAdaptation !== undefined) {
1222
- return foundAdaptation;
1223
- }
1224
- }
1225
-
1226
- // no optimal adaptation, just return the first one
1227
- return videoAdaptations[0];
1228
- }
1229
-
1230
- /**
1231
- * Returns the index of the given `period` in the given `periods`
1232
- * SortedList.
1233
- * Returns `undefined` if that `period` is not found.
1234
- * @param {Object} periods
1235
- * @param {Object} period
1236
- * @returns {number|undefined}
1237
- */
1238
- function findPeriodIndex(
1239
- periods : SortedList<ITMPeriodInfos>,
1240
- period : Period
1241
- ) : number|undefined {
1242
- for (let i = 0; i < periods.length(); i++) {
1243
- const periodI = periods.get(i);
1244
- if (periodI.period.id === period.id) {
1245
- return i;
1246
- }
1247
- }
1248
- }
1249
-
1250
- /**
1251
- * Returns element in the given `periods` SortedList that corresponds to the
1252
- * `period` given.
1253
- * Returns `undefined` if that `period` is not found.
1254
- * @param {Object} periods
1255
- * @param {Object} period
1256
- * @returns {Object|undefined}
1257
- */
1258
- function getPeriodItem(
1259
- periods : SortedList<ITMPeriodInfos>,
1260
- period : Period
1261
- ) : ITMPeriodInfos|undefined {
1262
- for (let i = 0; i < periods.length(); i++) {
1263
- const periodI = periods.get(i);
1264
- if (periodI.period.id === period.id) {
1265
- return periodI;
1266
- }
1267
- }
1268
- }
1269
-
1270
- function getRightVideoTrack(
1271
- adaptation : Adaptation,
1272
- isTrickModeEnabled : boolean
1273
- ) : Adaptation {
1274
- if (isTrickModeEnabled &&
1275
- adaptation.trickModeTracks?.[0] !== undefined)
1276
- {
1277
- return adaptation.trickModeTracks[0];
1278
- }
1279
- return adaptation;
1280
- }