rx-player 3.29.0 → 3.30.0-dev.2023011800

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 (439) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/compat/can_reuse_media_keys.d.ts +3 -2
  4. package/dist/_esm5.processed/compat/can_reuse_media_keys.js +5 -4
  5. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.js +16 -7
  6. package/dist/_esm5.processed/compat/event_listeners.d.ts +33 -56
  7. package/dist/_esm5.processed/compat/event_listeners.js +66 -116
  8. package/dist/_esm5.processed/compat/index.d.ts +1 -4
  9. package/dist/_esm5.processed/compat/index.js +1 -4
  10. package/dist/_esm5.processed/compat/on_height_width_change.d.ts +1 -1
  11. package/dist/_esm5.processed/compat/on_height_width_change.js +2 -2
  12. package/dist/_esm5.processed/config.d.ts +1 -0
  13. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.d.ts +3 -1
  14. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +27 -6
  15. package/dist/_esm5.processed/core/api/playback_observer.d.ts +8 -9
  16. package/dist/_esm5.processed/core/api/playback_observer.js +6 -7
  17. package/dist/_esm5.processed/core/api/public_api.d.ts +39 -41
  18. package/dist/_esm5.processed/core/api/public_api.js +569 -578
  19. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +9 -14
  20. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +73 -43
  21. package/dist/_esm5.processed/core/api/utils.d.ts +15 -10
  22. package/dist/_esm5.processed/core/api/utils.js +84 -19
  23. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +22 -5
  24. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +97 -25
  25. package/dist/_esm5.processed/core/decrypt/attach_media_keys.d.ts +3 -2
  26. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +3 -2
  27. package/dist/_esm5.processed/core/decrypt/clear_on_stop.d.ts +1 -1
  28. package/dist/_esm5.processed/core/decrypt/clear_on_stop.js +1 -1
  29. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +12 -20
  30. package/dist/_esm5.processed/core/decrypt/create_session.js +1 -1
  31. package/dist/_esm5.processed/core/decrypt/find_key_system.js +35 -13
  32. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +1 -1
  33. package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +32 -31
  34. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +291 -160
  35. package/dist/_esm5.processed/core/decrypt/set_server_certificate.d.ts +1 -1
  36. package/dist/_esm5.processed/core/decrypt/set_server_certificate.js +1 -1
  37. package/dist/_esm5.processed/core/decrypt/types.d.ts +0 -6
  38. package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.d.ts +1 -1
  39. package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +1 -1
  40. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +1 -1
  41. package/dist/_esm5.processed/core/fetchers/index.d.ts +2 -2
  42. package/dist/_esm5.processed/core/fetchers/manifest/index.d.ts +2 -2
  43. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +153 -89
  44. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +419 -144
  45. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +0 -24
  46. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +0 -24
  47. package/dist/_esm5.processed/core/init/{initialize_directfile.d.ts → directfile_content_initializer.d.ts} +13 -16
  48. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +196 -0
  49. package/dist/_esm5.processed/core/init/index.d.ts +2 -2
  50. package/dist/_esm5.processed/core/init/index.js +2 -2
  51. package/dist/_esm5.processed/core/init/media_source_content_initializer.d.ts +181 -0
  52. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +576 -0
  53. package/dist/_esm5.processed/core/init/types.d.ts +203 -64
  54. package/dist/_esm5.processed/core/init/types.js +36 -1
  55. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +164 -0
  56. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +484 -0
  57. package/dist/_esm5.processed/core/init/{create_media_source.d.ts → utils/create_media_source.d.ts} +8 -4
  58. package/dist/_esm5.processed/core/init/utils/create_media_source.js +118 -0
  59. package/dist/_esm5.processed/core/init/{create_stream_playback_observer.d.ts → utils/create_stream_playback_observer.d.ts} +4 -4
  60. package/dist/_esm5.processed/core/init/{create_stream_playback_observer.js → utils/create_stream_playback_observer.js} +2 -5
  61. package/dist/_esm5.processed/core/init/{end_of_stream.d.ts → utils/end_of_stream.d.ts} +5 -5
  62. package/dist/_esm5.processed/core/init/utils/end_of_stream.js +85 -0
  63. package/dist/_esm5.processed/core/init/{get_initial_time.d.ts → utils/get_initial_time.d.ts} +1 -1
  64. package/dist/_esm5.processed/core/init/{get_initial_time.js → utils/get_initial_time.js} +3 -3
  65. package/dist/_esm5.processed/core/init/{emit_loaded_event.d.ts → utils/get_loaded_reference.d.ts} +9 -9
  66. package/dist/_esm5.processed/core/init/{emit_loaded_event.js → utils/get_loaded_reference.js} +23 -17
  67. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.d.ts +63 -0
  68. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +124 -0
  69. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.d.ts +80 -0
  70. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +111 -0
  71. package/dist/_esm5.processed/core/init/{media_duration_updater.d.ts → utils/media_duration_updater.d.ts} +3 -3
  72. package/dist/_esm5.processed/core/init/{media_duration_updater.js → utils/media_duration_updater.js} +115 -41
  73. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +113 -0
  74. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +483 -0
  75. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/are_same_stream_events.d.ts +0 -0
  76. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/are_same_stream_events.js +0 -0
  77. package/dist/_esm5.processed/core/{stream/types.js → init/utils/stream_events_emitter/index.d.ts} +3 -1
  78. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/index.js +0 -0
  79. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/refresh_scheduled_events_list.d.ts +1 -1
  80. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/refresh_scheduled_events_list.js +0 -0
  81. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.d.ts +30 -0
  82. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +155 -0
  83. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/types.d.ts +1 -13
  84. package/dist/_esm5.processed/core/init/{stream_events_emitter → utils/stream_events_emitter}/types.js +0 -0
  85. package/dist/_esm5.processed/core/init/{throw_on_media_error.d.ts → utils/throw_on_media_error.d.ts} +5 -5
  86. package/dist/_esm5.processed/core/init/{throw_on_media_error.js → utils/throw_on_media_error.js} +19 -15
  87. package/dist/_esm5.processed/core/segment_buffers/garbage_collector.d.ts +0 -1
  88. package/dist/_esm5.processed/core/segment_buffers/garbage_collector.js +0 -1
  89. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +0 -5
  90. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +0 -5
  91. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +3 -3
  92. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +3 -3
  93. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +1 -1
  94. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  95. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +25 -130
  96. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +188 -117
  97. package/dist/_esm5.processed/core/stream/adaptation/index.d.ts +2 -2
  98. package/dist/_esm5.processed/core/stream/adaptation/index.js +1 -0
  99. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +172 -0
  100. package/dist/_esm5.processed/core/stream/adaptation/types.js +1 -0
  101. package/dist/_esm5.processed/core/stream/adaptation/{create_representation_estimator.d.ts → utils/create_representation_estimator.d.ts} +6 -6
  102. package/dist/_esm5.processed/core/stream/adaptation/{create_representation_estimator.js → utils/create_representation_estimator.js} +3 -4
  103. package/dist/_esm5.processed/core/stream/index.d.ts +4 -3
  104. package/dist/_esm5.processed/core/stream/index.js +0 -1
  105. package/dist/_esm5.processed/core/stream/orchestrator/index.d.ts +2 -2
  106. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +142 -17
  107. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +303 -229
  108. package/dist/_esm5.processed/core/stream/period/index.d.ts +2 -3
  109. package/dist/_esm5.processed/core/stream/period/index.js +1 -0
  110. package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +27 -62
  111. package/dist/_esm5.processed/core/stream/period/period_stream.js +278 -105
  112. package/dist/_esm5.processed/core/stream/period/types.d.ts +110 -0
  113. package/dist/_esm5.processed/core/stream/period/types.js +1 -0
  114. package/dist/_esm5.processed/core/stream/period/{get_adaptation_switch_strategy.d.ts → utils/get_adaptation_switch_strategy.d.ts} +3 -3
  115. package/dist/_esm5.processed/core/stream/period/{get_adaptation_switch_strategy.js → utils/get_adaptation_switch_strategy.js} +3 -3
  116. package/dist/_esm5.processed/core/stream/representation/index.d.ts +2 -2
  117. package/dist/_esm5.processed/core/stream/representation/index.js +1 -0
  118. package/dist/_esm5.processed/core/stream/representation/representation_stream.d.ts +32 -121
  119. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +210 -136
  120. package/dist/_esm5.processed/core/stream/representation/types.d.ts +267 -0
  121. package/dist/_esm5.processed/core/stream/representation/types.js +1 -0
  122. package/dist/_esm5.processed/core/stream/representation/{append_segment_to_buffer.d.ts → utils/append_segment_to_buffer.d.ts} +5 -5
  123. package/dist/_esm5.processed/core/stream/representation/{append_segment_to_buffer.js → utils/append_segment_to_buffer.js} +8 -3
  124. package/dist/_esm5.processed/core/stream/representation/{check_for_discontinuity.d.ts → utils/check_for_discontinuity.d.ts} +2 -2
  125. package/dist/_esm5.processed/core/stream/representation/{check_for_discontinuity.js → utils/check_for_discontinuity.js} +1 -1
  126. package/dist/_esm5.processed/core/stream/representation/{downloading_queue.d.ts → utils/downloading_queue.d.ts} +85 -80
  127. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +378 -0
  128. package/dist/_esm5.processed/core/stream/representation/{force_garbage_collection.d.ts → utils/force_garbage_collection.d.ts} +2 -2
  129. package/dist/_esm5.processed/core/stream/representation/{force_garbage_collection.js → utils/force_garbage_collection.js} +3 -3
  130. package/dist/_esm5.processed/core/stream/representation/{get_buffer_status.d.ts → utils/get_buffer_status.d.ts} +3 -3
  131. package/dist/_esm5.processed/core/stream/representation/{get_buffer_status.js → utils/get_buffer_status.js} +3 -3
  132. package/dist/_esm5.processed/core/stream/representation/{get_needed_segments.d.ts → utils/get_needed_segments.d.ts} +3 -3
  133. package/dist/_esm5.processed/core/stream/representation/{get_needed_segments.js → utils/get_needed_segments.js} +4 -5
  134. package/dist/_esm5.processed/core/stream/representation/{get_segment_priority.d.ts → utils/get_segment_priority.d.ts} +0 -0
  135. package/dist/_esm5.processed/core/stream/representation/{get_segment_priority.js → utils/get_segment_priority.js} +1 -1
  136. package/dist/_esm5.processed/core/stream/representation/{push_init_segment.d.ts → utils/push_init_segment.d.ts} +9 -12
  137. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +85 -0
  138. package/dist/_esm5.processed/core/stream/representation/{push_media_segment.d.ts → utils/push_media_segment.d.ts} +9 -12
  139. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +109 -0
  140. package/dist/_esm5.processed/default_config.d.ts +10 -0
  141. package/dist/_esm5.processed/default_config.js +12 -1
  142. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +1 -1
  143. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +1 -1
  144. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +1 -1
  145. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/get_duration_from_manifest.d.ts +2 -3
  146. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +107 -59
  147. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/index.js +6 -7
  148. package/dist/_esm5.processed/features/initialize_features.js +1 -1
  149. package/dist/_esm5.processed/features/list/directfile.js +1 -1
  150. package/dist/_esm5.processed/features/types.d.ts +2 -3
  151. package/dist/_esm5.processed/manifest/adaptation.d.ts +7 -0
  152. package/dist/_esm5.processed/manifest/adaptation.js +3 -0
  153. package/dist/_esm5.processed/manifest/manifest.d.ts +2 -1
  154. package/dist/_esm5.processed/manifest/manifest.js +4 -3
  155. package/dist/_esm5.processed/manifest/update_period_in_place.d.ts +26 -1
  156. package/dist/_esm5.processed/manifest/update_period_in_place.js +58 -7
  157. package/dist/_esm5.processed/manifest/update_periods.d.ts +19 -2
  158. package/dist/_esm5.processed/manifest/update_periods.js +62 -18
  159. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +3 -0
  160. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +1 -0
  161. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +1 -0
  162. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +7 -1
  163. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +16 -0
  164. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +63 -25
  165. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +3 -0
  166. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +60 -6
  167. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +39 -13
  168. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +7 -3
  169. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.js +5 -0
  170. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +3 -0
  171. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.d.ts +0 -1
  172. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +0 -1
  173. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.js +5 -0
  174. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.js +6 -0
  175. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  176. package/dist/_esm5.processed/parsers/manifest/types.d.ts +13 -2
  177. package/dist/_esm5.processed/parsers/texttracks/ttml/html/create_element.js +7 -0
  178. package/dist/_esm5.processed/public_types.d.ts +2 -0
  179. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -2
  180. package/dist/_esm5.processed/transports/dash/segment_loader.js +1 -1
  181. package/dist/_esm5.processed/transports/dash/text_parser.js +3 -3
  182. package/dist/_esm5.processed/transports/local/segment_loader.js +1 -1
  183. package/dist/_esm5.processed/utils/event_emitter.d.ts +3 -13
  184. package/dist/_esm5.processed/utils/event_emitter.js +0 -19
  185. package/dist/_esm5.processed/utils/reference.d.ts +46 -67
  186. package/dist/_esm5.processed/utils/reference.js +63 -93
  187. package/dist/_esm5.processed/utils/request/xhr.d.ts +3 -68
  188. package/dist/_esm5.processed/utils/{rx-retry_with_backoff.d.ts → retry_promise_with_backoff.d.ts} +19 -34
  189. package/dist/_esm5.processed/utils/retry_promise_with_backoff.js +119 -0
  190. package/dist/_esm5.processed/utils/sleep.d.ts +10 -0
  191. package/dist/_esm5.processed/utils/sleep.js +14 -0
  192. package/dist/_esm5.processed/utils/sorted_list.d.ts +1 -0
  193. package/dist/_esm5.processed/utils/sorted_list.js +3 -0
  194. package/dist/mpd-parser.wasm +0 -0
  195. package/dist/rx-player.js +8116 -11600
  196. package/dist/rx-player.min.js +1 -1
  197. package/dist/rx-player.min.js.LICENSE.txt +0 -15
  198. package/manifest.mpd +149 -0
  199. package/package.json +26 -26
  200. package/scripts/build/generate_build.js +1 -8
  201. package/sonar-project.properties +1 -1
  202. package/src/README.md +2 -2
  203. package/src/compat/__tests__/can_reuse_media_keys.test.ts +4 -27
  204. package/src/compat/can_reuse_media_keys.ts +5 -7
  205. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +14 -15
  206. package/src/compat/event_listeners.ts +84 -148
  207. package/src/compat/index.ts +0 -6
  208. package/src/compat/on_height_width_change.ts +2 -2
  209. package/src/core/README.md +1 -1
  210. package/src/core/adaptive/adaptive_representation_selector.ts +36 -7
  211. package/src/core/api/README.md +0 -33
  212. package/src/core/api/playback_observer.ts +20 -11
  213. package/src/core/api/public_api.ts +826 -815
  214. package/src/core/api/tracks_management/track_choice_manager.ts +97 -57
  215. package/src/core/api/utils.ts +112 -42
  216. package/src/core/decrypt/__tests__/__global__/get_license.test.ts +42 -38
  217. package/src/core/decrypt/__tests__/__global__/init_data.test.ts +15 -20
  218. package/src/core/decrypt/__tests__/__global__/media_key_system_access.test.ts +35 -47
  219. package/src/core/decrypt/__tests__/__global__/utils.ts +116 -17
  220. package/src/core/decrypt/attach_media_keys.ts +3 -2
  221. package/src/core/decrypt/clear_on_stop.ts +1 -1
  222. package/src/core/decrypt/content_decryptor.ts +19 -27
  223. package/src/core/decrypt/create_session.ts +1 -1
  224. package/src/core/decrypt/find_key_system.ts +31 -11
  225. package/src/core/decrypt/get_media_keys.ts +1 -1
  226. package/src/core/decrypt/session_events_listener.ts +259 -277
  227. package/src/core/decrypt/set_server_certificate.ts +1 -1
  228. package/src/core/decrypt/types.ts +0 -5
  229. package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +1 -1
  230. package/src/core/decrypt/utils/loaded_sessions_store.ts +1 -1
  231. package/src/core/fetchers/README.md +3 -0
  232. package/src/core/fetchers/index.ts +6 -6
  233. package/src/core/fetchers/manifest/index.ts +7 -7
  234. package/src/core/fetchers/manifest/manifest_fetcher.ts +646 -295
  235. package/src/core/fetchers/segment/segment_fetcher_creator.ts +0 -24
  236. package/src/core/init/README.md +31 -45
  237. package/src/core/init/directfile_content_initializer.ts +229 -0
  238. package/src/core/init/index.ts +3 -3
  239. package/src/core/init/media_source_content_initializer.ts +819 -0
  240. package/src/core/init/types.ts +220 -132
  241. package/src/core/init/{__tests__ → utils/__tests__}/are_same_stream_events.test.ts +0 -0
  242. package/src/core/init/{__tests__ → utils/__tests__}/refresh_scheduled_events_list.test.ts +0 -0
  243. package/src/core/init/utils/content_time_boundaries_observer.ts +609 -0
  244. package/src/core/init/{create_media_source.ts → utils/create_media_source.ts} +60 -55
  245. package/src/core/init/{create_stream_playback_observer.ts → utils/create_stream_playback_observer.ts} +7 -11
  246. package/src/core/init/utils/end_of_stream.ts +104 -0
  247. package/src/core/init/{get_initial_time.ts → utils/get_initial_time.ts} +4 -4
  248. package/src/core/init/utils/get_loaded_reference.ts +76 -0
  249. package/src/core/init/utils/initial_seek_and_play.ts +179 -0
  250. package/src/core/init/utils/initialize_content_decryption.ts +178 -0
  251. package/src/core/init/{media_duration_updater.ts → utils/media_duration_updater.ts} +166 -84
  252. package/src/core/init/{rebuffering_controller.ts → utils/rebuffering_controller.ts} +247 -226
  253. package/src/core/init/{stream_events_emitter → utils/stream_events_emitter}/are_same_stream_events.ts +0 -0
  254. package/src/core/init/{stream_events_emitter → utils/stream_events_emitter}/index.ts +1 -13
  255. package/src/core/init/{stream_events_emitter → utils/stream_events_emitter}/refresh_scheduled_events_list.ts +1 -1
  256. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +210 -0
  257. package/src/core/init/{stream_events_emitter → utils/stream_events_emitter}/types.ts +1 -19
  258. package/src/core/init/utils/throw_on_media_error.ts +74 -0
  259. package/src/core/segment_buffers/README.md +5 -4
  260. package/src/core/segment_buffers/garbage_collector.ts +0 -1
  261. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +2 -8
  262. package/src/core/segment_buffers/implementations/image/image_segment_buffer.ts +3 -3
  263. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +1 -1
  264. package/src/core/stream/README.md +1 -1
  265. package/src/core/stream/adaptation/adaptation_stream.ts +265 -330
  266. package/src/core/stream/adaptation/index.ts +2 -12
  267. package/src/core/stream/adaptation/types.ts +193 -0
  268. package/src/core/stream/adaptation/{create_representation_estimator.ts → utils/create_representation_estimator.ts} +10 -9
  269. package/src/core/stream/index.ts +9 -1
  270. package/src/core/stream/orchestrator/README.md +1 -4
  271. package/src/core/stream/orchestrator/index.ts +2 -0
  272. package/src/core/stream/orchestrator/stream_orchestrator.ts +423 -326
  273. package/src/core/stream/period/index.ts +2 -12
  274. package/src/core/stream/period/period_stream.ts +301 -238
  275. package/src/core/stream/period/types.ts +132 -0
  276. package/src/core/stream/period/{get_adaptation_switch_strategy.ts → utils/get_adaptation_switch_strategy.ts} +6 -6
  277. package/src/core/stream/representation/README.md +2 -23
  278. package/src/core/stream/representation/index.ts +2 -12
  279. package/src/core/stream/representation/representation_stream.ts +315 -415
  280. package/src/core/stream/representation/types.ts +292 -0
  281. package/src/core/stream/representation/{append_segment_to_buffer.ts → utils/append_segment_to_buffer.ts} +11 -7
  282. package/src/core/stream/representation/{check_for_discontinuity.ts → utils/check_for_discontinuity.ts} +3 -3
  283. package/src/core/stream/representation/utils/downloading_queue.ts +592 -0
  284. package/src/core/stream/representation/{force_garbage_collection.ts → utils/force_garbage_collection.ts} +5 -6
  285. package/src/core/stream/representation/{get_buffer_status.ts → utils/get_buffer_status.ts} +5 -5
  286. package/src/core/stream/representation/{get_needed_segments.ts → utils/get_needed_segments.ts} +6 -7
  287. package/src/core/stream/representation/{get_segment_priority.ts → utils/get_segment_priority.ts} +1 -2
  288. package/src/core/stream/representation/utils/push_init_segment.ts +80 -0
  289. package/src/core/stream/representation/utils/push_media_segment.ts +113 -0
  290. package/src/default_config.ts +13 -1
  291. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +1 -1
  292. package/src/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.ts +1 -1
  293. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +58 -66
  294. package/src/experimental/tools/createMetaplaylist/index.ts +29 -38
  295. package/src/features/__tests__/initialize_features.test.ts +1 -1
  296. package/src/features/initialize_features.ts +2 -1
  297. package/src/features/list/__tests__/directfile.test.ts +3 -2
  298. package/src/features/list/directfile.ts +1 -1
  299. package/src/features/types.ts +2 -7
  300. package/src/manifest/__tests__/manifest.test.ts +14 -365
  301. package/src/manifest/__tests__/update_period_in_place.test.ts +522 -57
  302. package/src/manifest/__tests__/update_periods.test.ts +254 -40
  303. package/src/manifest/adaptation.ts +11 -0
  304. package/src/manifest/manifest.ts +6 -4
  305. package/src/manifest/update_period_in_place.ts +84 -14
  306. package/src/manifest/update_periods.ts +93 -33
  307. package/src/parsers/manifest/dash/common/indexes/base.ts +4 -0
  308. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +8 -1
  309. package/src/parsers/manifest/dash/common/indexes/template.ts +76 -25
  310. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +61 -3
  311. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +46 -15
  312. package/src/parsers/manifest/dash/common/parse_representations.ts +7 -3
  313. package/src/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.ts +6 -0
  314. package/src/parsers/manifest/dash/node_parser_types.ts +3 -0
  315. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +3 -0
  316. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +4 -0
  317. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -1
  318. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.ts +6 -0
  319. package/src/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.ts +7 -0
  320. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +3 -0
  321. package/src/parsers/manifest/types.ts +13 -2
  322. package/src/parsers/texttracks/ttml/html/create_element.ts +8 -0
  323. package/src/public_types.ts +2 -0
  324. package/src/transports/README.md +15 -54
  325. package/src/transports/dash/manifest_parser.ts +2 -2
  326. package/src/transports/dash/segment_loader.ts +1 -1
  327. package/src/transports/dash/text_parser.ts +3 -3
  328. package/src/transports/local/segment_loader.ts +1 -1
  329. package/src/utils/__tests__/event_emitter.test.ts +1 -76
  330. package/src/utils/event_emitter.ts +6 -30
  331. package/src/utils/reference.ts +112 -169
  332. package/src/utils/request/xhr.ts +3 -68
  333. package/src/utils/retry_promise_with_backoff.ts +95 -0
  334. package/src/utils/sleep.ts +14 -0
  335. package/src/utils/sorted_list.ts +4 -0
  336. package/dist/_esm5.processed/compat/play.d.ts +0 -23
  337. package/dist/_esm5.processed/compat/play.js +0 -32
  338. package/dist/_esm5.processed/compat/set_element_src.d.ts +0 -26
  339. package/dist/_esm5.processed/compat/set_element_src.js +0 -37
  340. package/dist/_esm5.processed/compat/when_loaded_metadata.d.ts +0 -23
  341. package/dist/_esm5.processed/compat/when_loaded_metadata.js +0 -33
  342. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.d.ts +0 -45
  343. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.js +0 -295
  344. package/dist/_esm5.processed/core/init/create_media_source.js +0 -107
  345. package/dist/_esm5.processed/core/init/end_of_stream.js +0 -74
  346. package/dist/_esm5.processed/core/init/events_generators.d.ts +0 -88
  347. package/dist/_esm5.processed/core/init/events_generators.js +0 -87
  348. package/dist/_esm5.processed/core/init/initial_seek_and_play.d.ts +0 -81
  349. package/dist/_esm5.processed/core/init/initial_seek_and_play.js +0 -114
  350. package/dist/_esm5.processed/core/init/initialize_directfile.js +0 -120
  351. package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +0 -122
  352. package/dist/_esm5.processed/core/init/initialize_media_source.js +0 -201
  353. package/dist/_esm5.processed/core/init/link_drm_and_content.d.ts +0 -62
  354. package/dist/_esm5.processed/core/init/link_drm_and_content.js +0 -94
  355. package/dist/_esm5.processed/core/init/load_on_media_source.d.ts +0 -46
  356. package/dist/_esm5.processed/core/init/load_on_media_source.js +0 -122
  357. package/dist/_esm5.processed/core/init/manifest_update_scheduler.d.ts +0 -65
  358. package/dist/_esm5.processed/core/init/manifest_update_scheduler.js +0 -233
  359. package/dist/_esm5.processed/core/init/rebuffering_controller.d.ts +0 -81
  360. package/dist/_esm5.processed/core/init/rebuffering_controller.js +0 -439
  361. package/dist/_esm5.processed/core/init/stream_events_emitter/index.d.ts +0 -19
  362. package/dist/_esm5.processed/core/init/stream_events_emitter/stream_events_emitter.d.ts +0 -27
  363. package/dist/_esm5.processed/core/init/stream_events_emitter/stream_events_emitter.js +0 -126
  364. package/dist/_esm5.processed/core/init/update_playback_rate.d.ts +0 -0
  365. package/dist/_esm5.processed/core/init/update_playback_rate.js +0 -1
  366. package/dist/_esm5.processed/core/stream/events_generators.d.ts +0 -67
  367. package/dist/_esm5.processed/core/stream/events_generators.js +0 -112
  368. package/dist/_esm5.processed/core/stream/orchestrator/active_period_emitter.d.ts +0 -53
  369. package/dist/_esm5.processed/core/stream/orchestrator/active_period_emitter.js +0 -124
  370. package/dist/_esm5.processed/core/stream/orchestrator/are_streams_complete.d.ts +0 -35
  371. package/dist/_esm5.processed/core/stream/orchestrator/are_streams_complete.js +0 -53
  372. package/dist/_esm5.processed/core/stream/period/create_empty_adaptation_stream.d.ts +0 -36
  373. package/dist/_esm5.processed/core/stream/period/create_empty_adaptation_stream.js +0 -46
  374. package/dist/_esm5.processed/core/stream/reload_after_switch.d.ts +0 -47
  375. package/dist/_esm5.processed/core/stream/reload_after_switch.js +0 -56
  376. package/dist/_esm5.processed/core/stream/representation/downloading_queue.js +0 -371
  377. package/dist/_esm5.processed/core/stream/representation/push_init_segment.js +0 -49
  378. package/dist/_esm5.processed/core/stream/representation/push_media_segment.js +0 -76
  379. package/dist/_esm5.processed/core/stream/types.d.ts +0 -437
  380. package/dist/_esm5.processed/utils/cast_to_observable.d.ts +0 -24
  381. package/dist/_esm5.processed/utils/cast_to_observable.js +0 -35
  382. package/dist/_esm5.processed/utils/concat_map_latest.d.ts +0 -23
  383. package/dist/_esm5.processed/utils/concat_map_latest.js +0 -48
  384. package/dist/_esm5.processed/utils/defer_subscriptions.d.ts +0 -79
  385. package/dist/_esm5.processed/utils/defer_subscriptions.js +0 -89
  386. package/dist/_esm5.processed/utils/filter_map.d.ts +0 -28
  387. package/dist/_esm5.processed/utils/filter_map.js +0 -32
  388. package/dist/_esm5.processed/utils/rx-from_cancellable_promise.d.ts +0 -39
  389. package/dist/_esm5.processed/utils/rx-from_cancellable_promise.js +0 -63
  390. package/dist/_esm5.processed/utils/rx-next-tick.d.ts +0 -27
  391. package/dist/_esm5.processed/utils/rx-next-tick.js +0 -41
  392. package/dist/_esm5.processed/utils/rx-retry_with_backoff.js +0 -70
  393. package/dist/_esm5.processed/utils/rx-throttle.d.ts +0 -40
  394. package/dist/_esm5.processed/utils/rx-throttle.js +0 -47
  395. package/dist/_esm5.processed/utils/rx-try_catch.d.ts +0 -23
  396. package/dist/_esm5.processed/utils/rx-try_catch.js +0 -30
  397. package/src/compat/__tests__/play.test.ts +0 -73
  398. package/src/compat/__tests__/set_element_src.test.ts +0 -71
  399. package/src/compat/__tests__/when_loaded_metadata.test.ts +0 -109
  400. package/src/compat/play.ts +0 -37
  401. package/src/compat/set_element_src.ts +0 -47
  402. package/src/compat/when_loaded_metadata.ts +0 -40
  403. package/src/core/init/content_time_boundaries_observer.ts +0 -382
  404. package/src/core/init/emit_loaded_event.ts +0 -71
  405. package/src/core/init/end_of_stream.ts +0 -104
  406. package/src/core/init/events_generators.ts +0 -140
  407. package/src/core/init/initial_seek_and_play.ts +0 -208
  408. package/src/core/init/initialize_directfile.ts +0 -191
  409. package/src/core/init/initialize_media_source.ts +0 -389
  410. package/src/core/init/link_drm_and_content.ts +0 -176
  411. package/src/core/init/load_on_media_source.ts +0 -237
  412. package/src/core/init/manifest_update_scheduler.ts +0 -362
  413. package/src/core/init/stream_events_emitter/stream_events_emitter.ts +0 -182
  414. package/src/core/init/throw_on_media_error.ts +0 -68
  415. package/src/core/init/update_playback_rate.ts +0 -0
  416. package/src/core/stream/events_generators.ts +0 -217
  417. package/src/core/stream/orchestrator/active_period_emitter.ts +0 -146
  418. package/src/core/stream/orchestrator/are_streams_complete.ts +0 -70
  419. package/src/core/stream/period/create_empty_adaptation_stream.ts +0 -70
  420. package/src/core/stream/reload_after_switch.ts +0 -76
  421. package/src/core/stream/representation/downloading_queue.ts +0 -632
  422. package/src/core/stream/representation/push_init_segment.ts +0 -87
  423. package/src/core/stream/representation/push_media_segment.ts +0 -125
  424. package/src/core/stream/types.ts +0 -558
  425. package/src/utils/__tests__/cast_to_observable.test.ts +0 -93
  426. package/src/utils/__tests__/concat_map_latest.test.ts +0 -221
  427. package/src/utils/__tests__/defer_subscriptions.test.ts +0 -50
  428. package/src/utils/__tests__/filter_map.test.ts +0 -87
  429. package/src/utils/__tests__/rx-throttle.test.ts +0 -252
  430. package/src/utils/__tests__/rx-try_catch.test.ts +0 -100
  431. package/src/utils/cast_to_observable.ts +0 -48
  432. package/src/utils/concat_map_latest.ts +0 -61
  433. package/src/utils/defer_subscriptions.ts +0 -96
  434. package/src/utils/filter_map.ts +0 -43
  435. package/src/utils/rx-from_cancellable_promise.ts +0 -71
  436. package/src/utils/rx-next-tick.ts +0 -43
  437. package/src/utils/rx-retry_with_backoff.ts +0 -101
  438. package/src/utils/rx-throttle.ts +0 -84
  439. package/src/utils/rx-try_catch.ts +0 -37
@@ -13,13 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- /**
17
- * This file is used to abstract the notion of text, audio and video tracks
18
- * switching for an easier API management.
19
- */
20
- import { Subject } from "rxjs";
21
16
  import { Adaptation, Period } from "../../../manifest";
22
17
  import { IAudioTrack, IAudioTrackPreference, IAvailableAudioTrack, IAvailableTextTrack, IAvailableVideoTrack, ITextTrack, ITextTrackPreference, IVideoTrack, IVideoTrackPreference } from "../../../public_types";
18
+ import { ISharedReference } from "../../../utils/reference";
23
19
  /**
24
20
  * Manage audio and text tracks for all active periods.
25
21
  * Choose the audio and text tracks for each period and record this choice.
@@ -82,16 +78,15 @@ export default class TrackChoiceManager {
82
78
  */
83
79
  setPreferredVideoTracks(preferredVideoTracks: IVideoTrackPreference[], shouldApply: boolean): void;
84
80
  /**
85
- * Add Subject to choose Adaptation for new "audio" or "text" Period.
81
+ * Add shared reference to choose Adaptation for new "audio" or "text" Period.
86
82
  * @param {string} bufferType - The concerned buffer type
87
83
  * @param {Period} period - The concerned Period.
88
- * @param {Subject.<Object|null>} adaptation$ - A subject through which the
89
- * choice will be given
84
+ * @param {Object} adaptationRef
90
85
  */
91
- addPeriod(bufferType: "audio" | "text" | "video", period: Period, adaptation$: Subject<Adaptation | null>): void;
86
+ addPeriod(bufferType: "audio" | "text" | "video", period: Period, adaptationRef: ISharedReference<Adaptation | null | undefined>): void;
92
87
  /**
93
- * Remove Subject to choose an "audio", "video" or "text" Adaptation for a
94
- * Period.
88
+ * Remove shared reference to choose an "audio", "video" or "text" Adaptation
89
+ * for a Period.
95
90
  * @param {string} bufferType - The concerned buffer type
96
91
  * @param {Period} period - The concerned Period.
97
92
  */
@@ -104,21 +99,21 @@ export default class TrackChoiceManager {
104
99
  */
105
100
  update(): void;
106
101
  /**
107
- * Emit initial audio Adaptation through the given Subject based on:
102
+ * Emit initial audio Adaptation through the given shared reference based on:
108
103
  * - the preferred audio tracks
109
104
  * - the last choice for this period, if one
110
105
  * @param {Period} period - The concerned Period.
111
106
  */
112
107
  setInitialAudioTrack(period: Period): void;
113
108
  /**
114
- * Emit initial text Adaptation through the given Subject based on:
109
+ * Emit initial text Adaptation through the given shared reference based on:
115
110
  * - the preferred text tracks
116
111
  * - the last choice for this period, if one
117
112
  * @param {Period} period - The concerned Period.
118
113
  */
119
114
  setInitialTextTrack(period: Period): void;
120
115
  /**
121
- * Emit initial video Adaptation through the given Subject based on:
116
+ * Emit initial video Adaptation through the given shared reference based on:
122
117
  * - the preferred video tracks
123
118
  * - the last choice for this period, if one
124
119
  * @param {Period} period - The concerned Period.
@@ -13,6 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ /**
17
+ * This file is used to abstract the notion of text, audio and video tracks
18
+ * switching for an easier API management.
19
+ */
16
20
  import log from "../../../log";
17
21
  import arrayFind from "../../../utils/array_find";
18
22
  import arrayIncludes from "../../../utils/array_includes";
@@ -44,6 +48,7 @@ function normalizeTextTracks(tracks) {
44
48
  return tracks.map(function (t) { return t === null ?
45
49
  t :
46
50
  { normalized: normalizeLanguage(t.language),
51
+ forced: t.forced,
47
52
  closedCaption: t.closedCaption }; });
48
53
  }
49
54
  /**
@@ -102,13 +107,12 @@ var TrackChoiceManager = /** @class */ (function () {
102
107
  }
103
108
  };
104
109
  /**
105
- * Add Subject to choose Adaptation for new "audio" or "text" Period.
110
+ * Add shared reference to choose Adaptation for new "audio" or "text" Period.
106
111
  * @param {string} bufferType - The concerned buffer type
107
112
  * @param {Period} period - The concerned Period.
108
- * @param {Subject.<Object|null>} adaptation$ - A subject through which the
109
- * choice will be given
113
+ * @param {Object} adaptationRef
110
114
  */
111
- TrackChoiceManager.prototype.addPeriod = function (bufferType, period, adaptation$) {
115
+ TrackChoiceManager.prototype.addPeriod = function (bufferType, period, adaptationRef) {
112
116
  var _a;
113
117
  var periodItem = getPeriodItem(this._periods, period);
114
118
  var adaptations = period.getSupportedAdaptations(bufferType);
@@ -118,16 +122,16 @@ var TrackChoiceManager = /** @class */ (function () {
118
122
  return;
119
123
  }
120
124
  else {
121
- periodItem[bufferType] = { adaptations: adaptations, adaptation$: adaptation$ };
125
+ periodItem[bufferType] = { adaptations: adaptations, adaptationRef: adaptationRef };
122
126
  }
123
127
  }
124
128
  else {
125
- this._periods.add((_a = { period: period }, _a[bufferType] = { adaptations: adaptations, adaptation$: adaptation$ }, _a));
129
+ this._periods.add((_a = { period: period }, _a[bufferType] = { adaptations: adaptations, adaptationRef: adaptationRef }, _a));
126
130
  }
127
131
  };
128
132
  /**
129
- * Remove Subject to choose an "audio", "video" or "text" Adaptation for a
130
- * Period.
133
+ * Remove shared reference to choose an "audio", "video" or "text" Adaptation
134
+ * for a Period.
131
135
  * @param {string} bufferType - The concerned buffer type
132
136
  * @param {Period} period - The concerned Period.
133
137
  */
@@ -165,7 +169,7 @@ var TrackChoiceManager = /** @class */ (function () {
165
169
  this._resetChosenVideoTracks();
166
170
  };
167
171
  /**
168
- * Emit initial audio Adaptation through the given Subject based on:
172
+ * Emit initial audio Adaptation through the given shared reference based on:
169
173
  * - the preferred audio tracks
170
174
  * - the last choice for this period, if one
171
175
  * @param {Period} period - The concerned Period.
@@ -181,7 +185,7 @@ var TrackChoiceManager = /** @class */ (function () {
181
185
  var chosenAudioAdaptation = this._audioChoiceMemory.get(period);
182
186
  if (chosenAudioAdaptation === null) {
183
187
  // If the Period was previously without audio, keep it that way
184
- audioInfos.adaptation$.next(null);
188
+ audioInfos.adaptationRef.setValue(null);
185
189
  }
186
190
  else if (chosenAudioAdaptation === undefined ||
187
191
  !arrayIncludes(audioAdaptations, chosenAudioAdaptation)) {
@@ -190,14 +194,14 @@ var TrackChoiceManager = /** @class */ (function () {
190
194
  var normalizedPref = normalizeAudioTracks(preferredAudioTracks);
191
195
  var optimalAdaptation = findFirstOptimalAudioAdaptation(audioAdaptations, normalizedPref);
192
196
  this._audioChoiceMemory.set(period, optimalAdaptation);
193
- audioInfos.adaptation$.next(optimalAdaptation);
197
+ audioInfos.adaptationRef.setValue(optimalAdaptation);
194
198
  }
195
199
  else {
196
- audioInfos.adaptation$.next(chosenAudioAdaptation); // set last one
200
+ audioInfos.adaptationRef.setValue(chosenAudioAdaptation); // set last one
197
201
  }
198
202
  };
199
203
  /**
200
- * Emit initial text Adaptation through the given Subject based on:
204
+ * Emit initial text Adaptation through the given shared reference based on:
201
205
  * - the preferred text tracks
202
206
  * - the last choice for this period, if one
203
207
  * @param {Period} period - The concerned Period.
@@ -213,23 +217,23 @@ var TrackChoiceManager = /** @class */ (function () {
213
217
  var chosenTextAdaptation = this._textChoiceMemory.get(period);
214
218
  if (chosenTextAdaptation === null) {
215
219
  // If the Period was previously without text, keep it that way
216
- textInfos.adaptation$.next(null);
220
+ textInfos.adaptationRef.setValue(null);
217
221
  }
218
222
  else if (chosenTextAdaptation === undefined ||
219
223
  !arrayIncludes(textAdaptations, chosenTextAdaptation)) {
220
224
  // Find the optimal text Adaptation
221
225
  var preferredTextTracks = this._preferredTextTracks;
222
226
  var normalizedPref = normalizeTextTracks(preferredTextTracks);
223
- var optimalAdaptation = findFirstOptimalTextAdaptation(textAdaptations, normalizedPref);
227
+ var optimalAdaptation = findFirstOptimalTextAdaptation(textAdaptations, normalizedPref, this._audioChoiceMemory.get(period));
224
228
  this._textChoiceMemory.set(period, optimalAdaptation);
225
- textInfos.adaptation$.next(optimalAdaptation);
229
+ textInfos.adaptationRef.setValue(optimalAdaptation);
226
230
  }
227
231
  else {
228
- textInfos.adaptation$.next(chosenTextAdaptation); // set last one
232
+ textInfos.adaptationRef.setValue(chosenTextAdaptation); // set last one
229
233
  }
230
234
  };
231
235
  /**
232
- * Emit initial video Adaptation through the given Subject based on:
236
+ * Emit initial video Adaptation through the given shared reference based on:
233
237
  * - the preferred video tracks
234
238
  * - the last choice for this period, if one
235
239
  * @param {Period} period - The concerned Period.
@@ -260,13 +264,13 @@ var TrackChoiceManager = /** @class */ (function () {
260
264
  }
261
265
  if (newBaseAdaptation === null) {
262
266
  this._videoChoiceMemory.set(period, null);
263
- videoInfos.adaptation$.next(null);
267
+ videoInfos.adaptationRef.setValue(null);
264
268
  return;
265
269
  }
266
270
  var newVideoAdaptation = getRightVideoTrack(newBaseAdaptation, this.trickModeTrackEnabled);
267
271
  this._videoChoiceMemory.set(period, { baseAdaptation: newBaseAdaptation,
268
272
  adaptation: newVideoAdaptation });
269
- videoInfos.adaptation$.next(newVideoAdaptation);
273
+ videoInfos.adaptationRef.setValue(newVideoAdaptation);
270
274
  };
271
275
  /**
272
276
  * Set audio track based on the ID of its adaptation for a given added Period.
@@ -292,7 +296,7 @@ var TrackChoiceManager = /** @class */ (function () {
292
296
  return;
293
297
  }
294
298
  this._audioChoiceMemory.set(period, wantedAdaptation);
295
- audioInfos.adaptation$.next(wantedAdaptation);
299
+ audioInfos.adaptationRef.setValue(wantedAdaptation);
296
300
  };
297
301
  /**
298
302
  * Set text track based on the ID of its adaptation for a given added Period.
@@ -318,7 +322,7 @@ var TrackChoiceManager = /** @class */ (function () {
318
322
  return;
319
323
  }
320
324
  this._textChoiceMemory.set(period, wantedAdaptation);
321
- textInfos.adaptation$.next(wantedAdaptation);
325
+ textInfos.adaptationRef.setValue(wantedAdaptation);
322
326
  };
323
327
  /**
324
328
  * Set video track based on the ID of its adaptation for a given added Period.
@@ -346,7 +350,7 @@ var TrackChoiceManager = /** @class */ (function () {
346
350
  var newVideoAdaptation = getRightVideoTrack(wantedBaseAdaptation, this.trickModeTrackEnabled);
347
351
  this._videoChoiceMemory.set(period, { baseAdaptation: wantedBaseAdaptation,
348
352
  adaptation: newVideoAdaptation });
349
- videoInfos.adaptation$.next(newVideoAdaptation);
353
+ videoInfos.adaptationRef.setValue(newVideoAdaptation);
350
354
  };
351
355
  /**
352
356
  * Disable the current text track for a given period.
@@ -367,7 +371,7 @@ var TrackChoiceManager = /** @class */ (function () {
367
371
  return;
368
372
  }
369
373
  this._textChoiceMemory.set(period, null);
370
- textInfos.adaptation$.next(null);
374
+ textInfos.adaptationRef.setValue(null);
371
375
  };
372
376
  /**
373
377
  * Disable the current video track for a given period.
@@ -385,7 +389,7 @@ var TrackChoiceManager = /** @class */ (function () {
385
389
  return;
386
390
  }
387
391
  this._videoChoiceMemory.set(period, null);
388
- videoInfos.adaptation$.next(null);
392
+ videoInfos.adaptationRef.setValue(null);
389
393
  };
390
394
  TrackChoiceManager.prototype.disableVideoTrickModeTracks = function () {
391
395
  this.trickModeTrackEnabled = false;
@@ -456,13 +460,17 @@ var TrackChoiceManager = /** @class */ (function () {
456
460
  if (isNullOrUndefined(chosenTextAdaptation)) {
457
461
  return null;
458
462
  }
459
- return {
463
+ var formatted = {
460
464
  language: takeFirstSet(chosenTextAdaptation.language, ""),
461
465
  normalized: takeFirstSet(chosenTextAdaptation.normalizedLanguage, ""),
462
466
  closedCaption: chosenTextAdaptation.isClosedCaption === true,
463
467
  id: chosenTextAdaptation.id,
464
468
  label: chosenTextAdaptation.label,
465
469
  };
470
+ if (chosenTextAdaptation.isForcedSubtitles !== undefined) {
471
+ formatted.forced = chosenTextAdaptation.isForcedSubtitles;
472
+ }
473
+ return formatted;
466
474
  };
467
475
  /**
468
476
  * Returns an object describing the chosen video track for the given video
@@ -567,15 +575,21 @@ var TrackChoiceManager = /** @class */ (function () {
567
575
  chosenTextAdaptation.id :
568
576
  null;
569
577
  return textInfos.adaptations
570
- .map(function (adaptation) { return ({
571
- language: takeFirstSet(adaptation.language, ""),
572
- normalized: takeFirstSet(adaptation.normalizedLanguage, ""),
573
- closedCaption: adaptation.isClosedCaption === true,
574
- id: adaptation.id,
575
- active: currentId === null ? false :
576
- currentId === adaptation.id,
577
- label: adaptation.label,
578
- }); });
578
+ .map(function (adaptation) {
579
+ var formatted = {
580
+ language: takeFirstSet(adaptation.language, ""),
581
+ normalized: takeFirstSet(adaptation.normalizedLanguage, ""),
582
+ closedCaption: adaptation.isClosedCaption === true,
583
+ id: adaptation.id,
584
+ active: currentId === null ? false :
585
+ currentId === adaptation.id,
586
+ label: adaptation.label,
587
+ };
588
+ if (adaptation.isForcedSubtitles !== undefined) {
589
+ formatted.forced = adaptation.isForcedSubtitles;
590
+ }
591
+ return formatted;
592
+ });
579
593
  };
580
594
  /**
581
595
  * Returns all available video tracks for a given Period, as an array of
@@ -686,7 +700,7 @@ var TrackChoiceManager = /** @class */ (function () {
686
700
  }
687
701
  var optimalAdaptation = findFirstOptimalAudioAdaptation(audioAdaptations, normalizedPref);
688
702
  _this._audioChoiceMemory.set(period, optimalAdaptation);
689
- audioItem.adaptation$.next(optimalAdaptation);
703
+ audioItem.adaptationRef.setValue(optimalAdaptation);
690
704
  // previous "next" call could have changed everything, start over
691
705
  recursiveUpdateAudioTrack(0);
692
706
  };
@@ -725,9 +739,9 @@ var TrackChoiceManager = /** @class */ (function () {
725
739
  recursiveUpdateTextTrack(index + 1);
726
740
  return;
727
741
  }
728
- var optimalAdaptation = findFirstOptimalTextAdaptation(textAdaptations, normalizedPref);
742
+ var optimalAdaptation = findFirstOptimalTextAdaptation(textAdaptations, normalizedPref, _this._audioChoiceMemory.get(period));
729
743
  _this._textChoiceMemory.set(period, optimalAdaptation);
730
- textItem.adaptation$.next(optimalAdaptation);
744
+ textItem.adaptationRef.setValue(optimalAdaptation);
731
745
  // previous "next" call could have changed everything, start over
732
746
  recursiveUpdateTextTrack(0);
733
747
  };
@@ -779,7 +793,7 @@ var TrackChoiceManager = /** @class */ (function () {
779
793
  baseAdaptation: chosenVideoAdaptation.baseAdaptation,
780
794
  adaptation: wantedVideoAdaptation,
781
795
  });
782
- videoItem.adaptation$.next(wantedVideoAdaptation);
796
+ videoItem.adaptationRef.setValue(wantedVideoAdaptation);
783
797
  // previous "next" call could have changed everything, start over
784
798
  return recursiveUpdateVideoTrack(0);
785
799
  }
@@ -787,14 +801,14 @@ var TrackChoiceManager = /** @class */ (function () {
787
801
  var optimalAdaptation = findFirstOptimalVideoAdaptation(videoAdaptations, preferredVideoTracks);
788
802
  if (optimalAdaptation === null) {
789
803
  _this._videoChoiceMemory.set(period, null);
790
- videoItem.adaptation$.next(null);
804
+ videoItem.adaptationRef.setValue(null);
791
805
  // previous "next" call could have changed everything, start over
792
806
  return recursiveUpdateVideoTrack(0);
793
807
  }
794
808
  var newVideoAdaptation = getRightVideoTrack(optimalAdaptation, _this.trickModeTrackEnabled);
795
809
  _this._videoChoiceMemory.set(period, { baseAdaptation: optimalAdaptation,
796
810
  adaptation: newVideoAdaptation });
797
- videoItem.adaptation$.next(newVideoAdaptation);
811
+ videoItem.adaptationRef.setValue(newVideoAdaptation);
798
812
  // previous "next" call could have changed everything, start over
799
813
  return recursiveUpdateVideoTrack(0);
800
814
  };
@@ -902,7 +916,9 @@ function createTextPreferenceMatcher(preferredTextTrack) {
902
916
  return function matchTextPreference(textAdaptation) {
903
917
  return takeFirstSet(textAdaptation.normalizedLanguage, "") === preferredTextTrack.normalized &&
904
918
  (preferredTextTrack.closedCaption ? textAdaptation.isClosedCaption === true :
905
- textAdaptation.isClosedCaption !== true);
919
+ textAdaptation.isClosedCaption !== true) &&
920
+ (preferredTextTrack.forced === true ? textAdaptation.isForcedSubtitles === true :
921
+ textAdaptation.isForcedSubtitles !== true);
906
922
  };
907
923
  }
908
924
  /**
@@ -912,9 +928,11 @@ function createTextPreferenceMatcher(preferredTextTrack) {
912
928
  * `null` if the most optimal text adaptation is no text adaptation.
913
929
  * @param {Array.<Object>} textAdaptations
914
930
  * @param {Array.<Object|null>} preferredTextTracks
931
+ * @param {Object|null|undefined} chosenAudioAdaptation
915
932
  * @returns {Adaptation|null}
916
933
  */
917
- function findFirstOptimalTextAdaptation(textAdaptations, preferredTextTracks) {
934
+ function findFirstOptimalTextAdaptation(textAdaptations, preferredTextTracks, chosenAudioAdaptation) {
935
+ var _a;
918
936
  if (textAdaptations.length === 0) {
919
937
  return null;
920
938
  }
@@ -929,6 +947,18 @@ function findFirstOptimalTextAdaptation(textAdaptations, preferredTextTracks) {
929
947
  return foundAdaptation;
930
948
  }
931
949
  }
950
+ var forcedSubtitles = textAdaptations.filter(function (ad) { return ad.isForcedSubtitles === true; });
951
+ if (forcedSubtitles.length > 0) {
952
+ if (chosenAudioAdaptation !== null && chosenAudioAdaptation !== undefined) {
953
+ var sameLanguage = arrayFind(forcedSubtitles, function (f) {
954
+ return f.normalizedLanguage === chosenAudioAdaptation.normalizedLanguage;
955
+ });
956
+ if (sameLanguage !== undefined) {
957
+ return sameLanguage;
958
+ }
959
+ }
960
+ return (_a = arrayFind(forcedSubtitles, function (f) { return f.normalizedLanguage === undefined; })) !== null && _a !== void 0 ? _a : null;
961
+ }
932
962
  // no optimal adaptation
933
963
  return null;
934
964
  }
@@ -13,20 +13,23 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Observable } from "rxjs";
17
16
  import { IPlayerState } from "../../public_types";
18
- import { IStallingSituation } from "../init";
19
- import { IPlaybackObservation } from "./playback_observer";
17
+ import { IReadOnlySharedReference } from "../../utils/reference";
18
+ import { CancellationSignal } from "../../utils/task_canceller";
19
+ import { ContentInitializer, IStallingSituation } from "../init";
20
+ import { IPlaybackObservation, IReadOnlyPlaybackObserver } from "./playback_observer";
20
21
  /**
21
- * Returns Observable which will emit:
22
- * - `"seeking"` when we are seeking in the given mediaElement
23
- * - `"seeked"` when a seek is considered as finished by the given observation$
24
- * Observable.
25
22
  * @param {HTMLMediaElement} mediaElement
26
- * @param {Observable} observation$
27
- * @returns {Observable}
23
+ * @param {Object} playbackObserver - Observes playback conditions on
24
+ * `mediaElement`.
25
+ * @param {function} onSeeking - Callback called when a seeking operation starts
26
+ * on `mediaElement`.
27
+ * @param {function} onSeeked - Callback called when a seeking operation ends
28
+ * on `mediaElement`.
29
+ * @param {Object} cancelSignal - When triggered, stop calling callbacks and
30
+ * remove all listeners this function has registered.
28
31
  */
29
- export declare function emitSeekEvents(mediaElement: HTMLMediaElement | null, observation$: Observable<IPlaybackObservation>): Observable<"seeking" | "seeked">;
32
+ export declare function emitSeekEvents(mediaElement: HTMLMediaElement | null, playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>, onSeeking: () => void, onSeeked: () => void, cancelSignal: CancellationSignal): void;
30
33
  /** Player state dictionnary. */
31
34
  export declare const enum PLAYER_STATES {
32
35
  STOPPED = "STOPPED",
@@ -39,6 +42,7 @@ export declare const enum PLAYER_STATES {
39
42
  SEEKING = "SEEKING",
40
43
  RELOADING = "RELOADING"
41
44
  }
45
+ export declare function constructPlayerStateReference(initializer: ContentInitializer, mediaElement: HTMLMediaElement, playbackObserver: IReadOnlyPlaybackObserver<IPlaybackObservation>, cancelSignal: CancellationSignal): IReadOnlySharedReference<IPlayerState>;
42
46
  /**
43
47
  * Get state string for a _loaded_ content.
44
48
  * @param {HTMLMediaElement} mediaElement
@@ -48,3 +52,4 @@ export declare const enum PLAYER_STATES {
48
52
  * @returns {string}
49
53
  */
50
54
  export declare function getLoadedContentState(mediaElement: HTMLMediaElement, stalledStatus: IStallingSituation | null): IPlayerState;
55
+ export declare function isLoadedState(state: IPlayerState): boolean;
@@ -13,31 +13,91 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { defer as observableDefer, EMPTY, filter, map, merge as observableMerge, startWith, switchMap, take, } from "rxjs";
17
16
  import config from "../../config";
17
+ import arrayIncludes from "../../utils/array_includes";
18
+ import createSharedReference from "../../utils/reference";
18
19
  /**
19
- * Returns Observable which will emit:
20
- * - `"seeking"` when we are seeking in the given mediaElement
21
- * - `"seeked"` when a seek is considered as finished by the given observation$
22
- * Observable.
23
20
  * @param {HTMLMediaElement} mediaElement
24
- * @param {Observable} observation$
25
- * @returns {Observable}
21
+ * @param {Object} playbackObserver - Observes playback conditions on
22
+ * `mediaElement`.
23
+ * @param {function} onSeeking - Callback called when a seeking operation starts
24
+ * on `mediaElement`.
25
+ * @param {function} onSeeked - Callback called when a seeking operation ends
26
+ * on `mediaElement`.
27
+ * @param {Object} cancelSignal - When triggered, stop calling callbacks and
28
+ * remove all listeners this function has registered.
26
29
  */
27
- export function emitSeekEvents(mediaElement, observation$) {
28
- return observableDefer(function () {
29
- if (mediaElement === null) {
30
- return EMPTY;
30
+ export function emitSeekEvents(mediaElement, playbackObserver, onSeeking, onSeeked, cancelSignal) {
31
+ if (cancelSignal.isCancelled || mediaElement === null) {
32
+ return;
33
+ }
34
+ var wasSeeking = playbackObserver.getReference().getValue().seeking;
35
+ if (wasSeeking) {
36
+ onSeeking();
37
+ if (cancelSignal.isCancelled) {
38
+ return;
39
+ }
40
+ }
41
+ playbackObserver.listen(function (obs) {
42
+ if (obs.event === "seeking") {
43
+ wasSeeking = true;
44
+ onSeeking();
31
45
  }
32
- var isSeeking$ = observation$.pipe(filter(function (observation) { return observation.event === "seeking"; }), map(function () { return "seeking"; }));
33
- if (mediaElement.seeking) {
34
- isSeeking$ = isSeeking$.pipe(startWith("seeking"));
46
+ else if (wasSeeking && obs.event === "seeked") {
47
+ wasSeeking = false;
48
+ onSeeked();
35
49
  }
36
- var hasSeeked$ = isSeeking$.pipe(switchMap(function () {
37
- return observation$.pipe(filter(function (observation) { return observation.event === "seeked"; }), map(function () { return "seeked"; }), take(1));
38
- }));
39
- return observableMerge(isSeeking$, hasSeeked$);
40
- });
50
+ }, { includeLastObservation: true, clearSignal: cancelSignal });
51
+ }
52
+ export function constructPlayerStateReference(initializer, mediaElement, playbackObserver, cancelSignal) {
53
+ var playerStateRef = createSharedReference("LOADING" /* PLAYER_STATES.LOADING */, cancelSignal);
54
+ initializer.addEventListener("loaded", function () {
55
+ if (playerStateRef.getValue() === "LOADING" /* PLAYER_STATES.LOADING */) {
56
+ playerStateRef.setValue("LOADED" /* PLAYER_STATES.LOADED */);
57
+ if (!cancelSignal.isCancelled) {
58
+ var newState = getLoadedContentState(mediaElement, null);
59
+ if (newState !== "PAUSED" /* PLAYER_STATES.PAUSED */) {
60
+ playerStateRef.setValue(newState);
61
+ }
62
+ }
63
+ }
64
+ else {
65
+ playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, null));
66
+ }
67
+ }, cancelSignal);
68
+ initializer.addEventListener("reloadingMediaSource", function () {
69
+ if (isLoadedState(playerStateRef.getValue())) {
70
+ playerStateRef.setValueIfChanged("RELOADING" /* PLAYER_STATES.RELOADING */);
71
+ }
72
+ }, cancelSignal);
73
+ /**
74
+ * Keep track of the last known stalling situation.
75
+ * `null` if playback is not stalled.
76
+ */
77
+ var prevStallReason = null;
78
+ initializer.addEventListener("stalled", function (s) {
79
+ if (s !== prevStallReason) {
80
+ if (isLoadedState(playerStateRef.getValue())) {
81
+ playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, s));
82
+ }
83
+ prevStallReason = s;
84
+ }
85
+ }, cancelSignal);
86
+ initializer.addEventListener("unstalled", function () {
87
+ if (prevStallReason !== null) {
88
+ if (isLoadedState(playerStateRef.getValue())) {
89
+ playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, null));
90
+ }
91
+ prevStallReason = null;
92
+ }
93
+ }, cancelSignal);
94
+ playbackObserver.listen(function (observation) {
95
+ if (isLoadedState(playerStateRef.getValue()) &&
96
+ arrayIncludes(["seeking", "ended", "play", "pause"], observation.event)) {
97
+ playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, prevStallReason));
98
+ }
99
+ }, { clearSignal: cancelSignal });
100
+ return playerStateRef;
41
101
  }
42
102
  /**
43
103
  * Get state string for a _loaded_ content.
@@ -69,3 +129,8 @@ export function getLoadedContentState(mediaElement, stalledStatus) {
69
129
  return mediaElement.paused ? "PAUSED" /* PLAYER_STATES.PAUSED */ :
70
130
  "PLAYING" /* PLAYER_STATES.PLAYING */;
71
131
  }
132
+ export function isLoadedState(state) {
133
+ return state !== "LOADING" /* PLAYER_STATES.LOADING */ &&
134
+ state !== "RELOADING" /* PLAYER_STATES.RELOADING */ &&
135
+ state !== "STOPPED" /* PLAYER_STATES.STOPPED */;
136
+ }
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /// <reference types="jest" />
17
- import { Subject } from "rxjs";
18
17
  import { IEncryptedEventData } from "../../../../compat/eme";
19
18
  import EventEmitter from "../../../../utils/event_emitter";
20
19
  /** Default MediaKeySystemAccess configuration used by the RxPlayer. */
@@ -30,6 +29,24 @@ export declare const defaultKSConfig: {
30
29
  contentType: string;
31
30
  }[];
32
31
  }[];
32
+ /**
33
+ * Default "com.microsoft.playready.recommendation" MediaKeySystemAccess
34
+ * configuration used by the RxPlayer.
35
+ */
36
+ export declare const defaultPRRecommendationKSConfig: {
37
+ audioCapabilities: {
38
+ robustness: string;
39
+ contentType: string;
40
+ }[];
41
+ distinctiveIdentifier: "optional";
42
+ initDataTypes: readonly ["cenc"];
43
+ persistentState: "optional";
44
+ sessionTypes: readonly ["temporary"];
45
+ videoCapabilities: {
46
+ robustness: string;
47
+ contentType: string;
48
+ }[];
49
+ }[];
33
50
  /** Default Widevine MediaKeySystemAccess configuration used by the RxPlayer. */
34
51
  export declare const defaultWidevineConfig: {
35
52
  audioCapabilities: {
@@ -104,10 +121,10 @@ export declare function requestMediaKeySystemAccessImpl(keySystem: string, confi
104
121
  export declare function mockCompat(exportedFunctions?: {}): {
105
122
  mockEvents: Record<string, jest.Mock<any, any>>;
106
123
  eventTriggers: {
107
- triggerEncrypted: Subject<IEncryptedEventData>;
108
- triggerKeyMessage: Subject<unknown>;
109
- triggerKeyError: Subject<unknown>;
110
- triggerKeyStatusesChange: Subject<unknown>;
124
+ triggerEncrypted(elt: HTMLMediaElement, value: unknown): void;
125
+ triggerKeyMessage(session: MediaKeySessionImpl, value: unknown): void;
126
+ triggerKeyError(session: MediaKeySessionImpl, value: unknown): void;
127
+ triggerKeyStatusesChange(session: MediaKeySessionImpl, value: unknown): void;
111
128
  };
112
129
  mockRequestMediaKeySystemAccess: jest.Mock<Promise<MediaKeySystemAccessImpl>, [keySystem: string, config: MediaKeySystemConfiguration[]]>;
113
130
  mockGetInitData: jest.Mock<IEncryptedEventData, [encryptedEvent: IEncryptedEventData]>;