rx-player 4.0.0-beta.2 → 4.0.0-beta.3

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 (909) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +173 -63
  3. package/CONTRIBUTING.md +27 -13
  4. package/FILES.md +0 -4
  5. package/README.md +0 -25
  6. package/VERSION +1 -1
  7. package/dist/_esm5.processed/compat/add_class_name.js +6 -3
  8. package/dist/_esm5.processed/compat/add_text_track.js +11 -8
  9. package/dist/_esm5.processed/compat/browser_compatibility_types.d.ts +0 -1
  10. package/dist/_esm5.processed/compat/browser_compatibility_types.js +16 -11
  11. package/dist/_esm5.processed/compat/browser_detection.js +49 -33
  12. package/dist/_esm5.processed/compat/browser_version.js +11 -8
  13. package/dist/_esm5.processed/compat/can_patch_isobmff.js +6 -3
  14. package/dist/_esm5.processed/compat/can_rely_on_video_visibility_and_size.js +9 -6
  15. package/dist/_esm5.processed/compat/can_reuse_media_keys.js +6 -3
  16. package/dist/_esm5.processed/compat/change_source_buffer_type.js +6 -3
  17. package/dist/_esm5.processed/compat/clear_element_src.js +12 -9
  18. package/dist/_esm5.processed/compat/eme/close_session.js +45 -106
  19. package/dist/_esm5.processed/compat/eme/constants.js +6 -3
  20. package/dist/_esm5.processed/compat/eme/custom_key_system_access.js +18 -22
  21. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.d.ts +2 -2
  22. package/dist/_esm5.processed/compat/eme/custom_media_keys/ie11_media_keys.js +81 -101
  23. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.d.ts +6 -27
  24. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +16 -159
  25. package/dist/_esm5.processed/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +1 -1
  26. package/dist/_esm5.processed/compat/eme/custom_media_keys/moz_media_keys_constructor.js +31 -26
  27. package/dist/_esm5.processed/compat/eme/custom_media_keys/ms_media_keys_constructor.js +14 -14
  28. package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +2 -2
  29. package/dist/_esm5.processed/compat/eme/custom_media_keys/old_webkit_media_keys.js +75 -89
  30. package/dist/_esm5.processed/compat/eme/custom_media_keys/types.d.ts +1 -1
  31. package/dist/_esm5.processed/compat/eme/custom_media_keys/types.js +2 -1
  32. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.d.ts +2 -2
  33. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys.js +97 -119
  34. package/dist/_esm5.processed/compat/eme/custom_media_keys/webkit_media_keys_constructor.js +14 -16
  35. package/dist/_esm5.processed/compat/eme/eme-api-implementation.d.ts +78 -0
  36. package/dist/_esm5.processed/compat/eme/eme-api-implementation.js +198 -0
  37. package/dist/_esm5.processed/compat/eme/generate_key_request.js +36 -31
  38. package/dist/_esm5.processed/compat/eme/get_init_data.js +28 -25
  39. package/dist/_esm5.processed/compat/eme/get_uuid_kid_from_keystatus_kid.js +8 -5
  40. package/dist/_esm5.processed/compat/eme/get_webkit_fairplay_initdata.js +17 -14
  41. package/dist/_esm5.processed/compat/eme/index.d.ts +5 -3
  42. package/dist/_esm5.processed/compat/eme/index.js +13 -7
  43. package/dist/_esm5.processed/compat/eme/load_session.js +26 -69
  44. package/dist/_esm5.processed/compat/enable_audio_track.js +7 -4
  45. package/dist/_esm5.processed/compat/event_listeners.d.ts +13 -5
  46. package/dist/_esm5.processed/compat/event_listeners.js +132 -108
  47. package/dist/_esm5.processed/compat/get_start_date.js +7 -4
  48. package/dist/_esm5.processed/compat/global_scope.d.ts +9 -0
  49. package/dist/_esm5.processed/compat/global_scope.js +15 -0
  50. package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.js +6 -3
  51. package/dist/_esm5.processed/compat/index.d.ts +2 -3
  52. package/dist/_esm5.processed/compat/index.js +47 -25
  53. package/dist/_esm5.processed/compat/is_codec_supported.js +8 -5
  54. package/dist/_esm5.processed/compat/is_debug_mode_enabled.d.ts +7 -0
  55. package/dist/_esm5.processed/compat/is_debug_mode_enabled.js +12 -0
  56. package/dist/_esm5.processed/compat/is_node.d.ts +1 -0
  57. package/dist/_esm5.processed/compat/is_node.js +6 -2
  58. package/dist/_esm5.processed/compat/is_seeking_approximate.js +5 -3
  59. package/dist/_esm5.processed/compat/is_vtt_cue.js +6 -2
  60. package/dist/_esm5.processed/compat/is_worker.d.ts +5 -0
  61. package/dist/_esm5.processed/compat/is_worker.js +7 -0
  62. package/dist/_esm5.processed/compat/make_vtt_cue.js +10 -6
  63. package/dist/_esm5.processed/compat/on_height_width_change.js +25 -27
  64. package/dist/_esm5.processed/compat/patch_webkit_source_buffer.js +19 -16
  65. package/dist/_esm5.processed/compat/remove_cue.js +12 -9
  66. package/dist/_esm5.processed/compat/should_favour_custom_safari_EME.js +7 -4
  67. package/dist/_esm5.processed/compat/should_reload_media_source_on_decipherability_update.js +4 -1
  68. package/dist/_esm5.processed/compat/should_renew_media_key_system_access.js +6 -3
  69. package/dist/_esm5.processed/compat/should_unset_media_keys.js +6 -3
  70. package/dist/_esm5.processed/compat/should_validate_metadata.js +6 -3
  71. package/dist/_esm5.processed/compat/should_wait_for_data_before_loaded.js +6 -3
  72. package/dist/_esm5.processed/compat/should_wait_for_have_enough_data.d.ts +13 -0
  73. package/dist/_esm5.processed/compat/should_wait_for_have_enough_data.js +19 -0
  74. package/dist/_esm5.processed/config.js +15 -14
  75. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +136 -104
  76. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +19 -3
  77. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +66 -46
  78. package/dist/_esm5.processed/core/adaptive/guess_based_chooser.js +37 -43
  79. package/dist/_esm5.processed/core/adaptive/index.js +4 -2
  80. package/dist/_esm5.processed/core/adaptive/network_analyzer.js +75 -73
  81. package/dist/_esm5.processed/core/adaptive/utils/bandwidth_estimator.js +24 -23
  82. package/dist/_esm5.processed/core/adaptive/utils/ewma.js +13 -12
  83. package/dist/_esm5.processed/core/adaptive/utils/filter_by_bitrate.js +9 -6
  84. package/dist/_esm5.processed/core/adaptive/utils/filter_by_resolution.js +18 -19
  85. package/dist/_esm5.processed/core/adaptive/utils/get_buffer_levels.js +10 -7
  86. package/dist/_esm5.processed/core/adaptive/utils/last_estimate_storage.js +8 -7
  87. package/dist/_esm5.processed/core/adaptive/utils/pending_requests_store.d.ts +13 -3
  88. package/dist/_esm5.processed/core/adaptive/utils/pending_requests_store.js +26 -23
  89. package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.js +25 -23
  90. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.js +6 -3
  91. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +41 -40
  92. package/dist/_esm5.processed/core/api/debug/buffer_size_graph.js +31 -29
  93. package/dist/_esm5.processed/core/api/debug/constants.js +4 -1
  94. package/dist/_esm5.processed/core/api/debug/index.js +4 -2
  95. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +64 -72
  96. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +49 -46
  97. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +15 -12
  98. package/dist/_esm5.processed/core/api/debug/render.js +16 -13
  99. package/dist/_esm5.processed/core/api/debug/utils.js +18 -13
  100. package/dist/_esm5.processed/core/api/index.js +7 -4
  101. package/dist/_esm5.processed/core/api/option_utils.d.ts +1 -1
  102. package/dist/_esm5.processed/core/api/option_utils.js +86 -59
  103. package/dist/_esm5.processed/core/api/playback_observer.d.ts +8 -2
  104. package/dist/_esm5.processed/core/api/playback_observer.js +135 -123
  105. package/dist/_esm5.processed/core/api/public_api.d.ts +6 -0
  106. package/dist/_esm5.processed/core/api/public_api.js +614 -676
  107. package/dist/_esm5.processed/core/api/track_management/index.js +19 -3
  108. package/dist/_esm5.processed/core/api/track_management/media_element_tracks_store.js +233 -248
  109. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +2 -2
  110. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +47 -58
  111. package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +50 -29
  112. package/dist/_esm5.processed/core/api/track_management/tracks_store.js +325 -351
  113. package/dist/_esm5.processed/core/api/utils.js +32 -24
  114. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +3 -3
  115. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +167 -190
  116. package/dist/_esm5.processed/core/decrypt/attach_media_keys.d.ts +8 -2
  117. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +44 -72
  118. package/dist/_esm5.processed/core/decrypt/clear_on_stop.d.ts +1 -1
  119. package/dist/_esm5.processed/core/decrypt/clear_on_stop.js +15 -12
  120. package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +9 -67
  121. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +400 -542
  122. package/dist/_esm5.processed/core/decrypt/create_or_load_session.d.ts +1 -1
  123. package/dist/_esm5.processed/core/decrypt/create_or_load_session.js +44 -90
  124. package/dist/_esm5.processed/core/decrypt/create_session.d.ts +1 -1
  125. package/dist/_esm5.processed/core/decrypt/create_session.js +90 -149
  126. package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.d.ts +1 -1
  127. package/dist/_esm5.processed/core/decrypt/dispose_decryption_resources.js +24 -60
  128. package/dist/_esm5.processed/core/decrypt/find_key_system.d.ts +1 -1
  129. package/dist/_esm5.processed/core/decrypt/find_key_system.js +104 -162
  130. package/dist/_esm5.processed/core/decrypt/get_key_system_configuration.js +6 -3
  131. package/dist/_esm5.processed/core/decrypt/get_media_keys.d.ts +1 -1
  132. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +59 -109
  133. package/dist/_esm5.processed/core/decrypt/index.d.ts +2 -2
  134. package/dist/_esm5.processed/core/decrypt/index.js +26 -7
  135. package/dist/_esm5.processed/core/decrypt/init_media_keys.js +17 -59
  136. package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +1 -1
  137. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +84 -155
  138. package/dist/_esm5.processed/core/decrypt/set_server_certificate.d.ts +1 -1
  139. package/dist/_esm5.processed/core/decrypt/set_server_certificate.js +50 -103
  140. package/dist/_esm5.processed/core/decrypt/types.d.ts +61 -0
  141. package/dist/_esm5.processed/core/decrypt/types.js +43 -1
  142. package/dist/_esm5.processed/core/decrypt/utils/are_init_values_compatible.js +22 -19
  143. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.d.ts +1 -1
  144. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +40 -61
  145. package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +17 -61
  146. package/dist/_esm5.processed/core/decrypt/utils/clean_old_stored_persistent_info.js +8 -5
  147. package/dist/_esm5.processed/core/decrypt/utils/get_drm_system_id.js +8 -5
  148. package/dist/_esm5.processed/core/decrypt/utils/init_data_values_container.js +23 -23
  149. package/dist/_esm5.processed/core/decrypt/utils/is_session_usable.d.ts +1 -1
  150. package/dist/_esm5.processed/core/decrypt/utils/is_session_usable.js +15 -12
  151. package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.d.ts +0 -13
  152. package/dist/_esm5.processed/core/decrypt/utils/key_id_comparison.js +14 -38
  153. package/dist/_esm5.processed/core/decrypt/utils/key_session_record.js +26 -26
  154. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.d.ts +1 -1
  155. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +206 -310
  156. package/dist/_esm5.processed/core/decrypt/utils/media_keys_infos_store.d.ts +2 -1
  157. package/dist/_esm5.processed/core/decrypt/utils/media_keys_infos_store.js +8 -6
  158. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +1 -1
  159. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +103 -103
  160. package/dist/_esm5.processed/core/decrypt/utils/serializable_bytes.js +13 -12
  161. package/dist/_esm5.processed/core/decrypt/utils/server_certificate_store.d.ts +1 -1
  162. package/dist/_esm5.processed/core/decrypt/utils/server_certificate_store.js +18 -16
  163. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +37 -56
  164. package/dist/_esm5.processed/core/fetchers/index.js +7 -3
  165. package/dist/_esm5.processed/core/fetchers/manifest/index.js +4 -2
  166. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +233 -312
  167. package/dist/_esm5.processed/core/fetchers/segment/index.js +4 -2
  168. package/dist/_esm5.processed/core/fetchers/segment/prioritized_segment_fetcher.js +12 -9
  169. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +218 -233
  170. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +20 -19
  171. package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +73 -74
  172. package/dist/_esm5.processed/core/fetchers/utils/error_selector.js +8 -5
  173. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +210 -260
  174. package/dist/_esm5.processed/core/init/directfile_content_initializer.d.ts +60 -1
  175. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +122 -105
  176. package/dist/_esm5.processed/core/init/index.d.ts +1 -4
  177. package/dist/_esm5.processed/core/init/index.js +5 -3
  178. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +269 -307
  179. package/dist/_esm5.processed/core/init/types.d.ts +3 -17
  180. package/dist/_esm5.processed/core/init/types.js +7 -24
  181. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +109 -135
  182. package/dist/_esm5.processed/core/init/utils/create_media_source.js +35 -27
  183. package/dist/_esm5.processed/core/init/utils/create_stream_playback_observer.d.ts +9 -4
  184. package/dist/_esm5.processed/core/init/utils/create_stream_playback_observer.js +22 -14
  185. package/dist/_esm5.processed/core/init/utils/end_of_stream.js +30 -25
  186. package/dist/_esm5.processed/core/init/utils/get_initial_time.js +41 -37
  187. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +15 -10
  188. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +31 -28
  189. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.d.ts +3 -3
  190. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +48 -53
  191. package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.js +61 -58
  192. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +3 -3
  193. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +141 -160
  194. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/are_same_stream_events.js +3 -1
  195. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/index.js +4 -2
  196. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +28 -14
  197. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.d.ts +31 -9
  198. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +103 -79
  199. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/types.js +2 -1
  200. package/dist/_esm5.processed/core/init/utils/throw_on_media_error.js +16 -13
  201. package/dist/_esm5.processed/core/segment_buffers/garbage_collector.js +75 -126
  202. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +131 -140
  203. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/index.js +4 -2
  204. package/dist/_esm5.processed/core/segment_buffers/implementations/index.js +20 -3
  205. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +2 -2
  206. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +109 -128
  207. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/index.js +4 -2
  208. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/parsers.js +11 -8
  209. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +48 -47
  210. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/types.js +2 -1
  211. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/update_proportional_elements.js +18 -15
  212. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.js +22 -15
  213. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/index.js +4 -2
  214. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +65 -82
  215. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/parsers.js +11 -8
  216. package/dist/_esm5.processed/core/segment_buffers/implementations/types.js +19 -17
  217. package/dist/_esm5.processed/core/segment_buffers/implementations/utils/manual_time_ranges.js +23 -22
  218. package/dist/_esm5.processed/core/segment_buffers/index.js +13 -6
  219. package/dist/_esm5.processed/core/segment_buffers/inventory/buffered_history.d.ts +2 -2
  220. package/dist/_esm5.processed/core/segment_buffers/inventory/buffered_history.js +25 -22
  221. package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +8 -3
  222. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +152 -150
  223. package/dist/_esm5.processed/core/segment_buffers/inventory/types.js +2 -1
  224. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +9 -4
  225. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +82 -89
  226. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +1 -1
  227. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +130 -171
  228. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +31 -28
  229. package/dist/_esm5.processed/core/stream/adaptation/index.js +19 -3
  230. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +14 -8
  231. package/dist/_esm5.processed/core/stream/adaptation/types.js +2 -1
  232. package/dist/_esm5.processed/core/stream/index.d.ts +2 -2
  233. package/dist/_esm5.processed/core/stream/index.js +4 -2
  234. package/dist/_esm5.processed/core/stream/orchestrator/get_time_ranges_for_content.js +14 -21
  235. package/dist/_esm5.processed/core/stream/orchestrator/index.d.ts +2 -2
  236. package/dist/_esm5.processed/core/stream/orchestrator/index.js +4 -2
  237. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +15 -29
  238. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +193 -235
  239. package/dist/_esm5.processed/core/stream/period/index.js +19 -3
  240. package/dist/_esm5.processed/core/stream/period/period_stream.js +204 -228
  241. package/dist/_esm5.processed/core/stream/period/types.d.ts +3 -3
  242. package/dist/_esm5.processed/core/stream/period/types.js +2 -1
  243. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +18 -4
  244. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +34 -33
  245. package/dist/_esm5.processed/core/stream/representation/index.js +19 -3
  246. package/dist/_esm5.processed/core/stream/representation/representation_stream.d.ts +1 -1
  247. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +81 -68
  248. package/dist/_esm5.processed/core/stream/representation/types.d.ts +3 -4
  249. package/dist/_esm5.processed/core/stream/representation/types.js +2 -1
  250. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +33 -84
  251. package/dist/_esm5.processed/core/stream/representation/utils/check_for_discontinuity.js +32 -29
  252. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.d.ts +1 -1
  253. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +126 -145
  254. package/dist/_esm5.processed/core/stream/representation/utils/force_garbage_collection.js +32 -88
  255. package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +61 -47
  256. package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +71 -69
  257. package/dist/_esm5.processed/core/stream/representation/utils/get_segment_priority.js +8 -5
  258. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +2 -2
  259. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +22 -63
  260. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +1 -1
  261. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +49 -86
  262. package/dist/_esm5.processed/default_config.js +4 -2
  263. package/dist/_esm5.processed/errors/assertion_error.js +10 -26
  264. package/dist/_esm5.processed/errors/custom_loader_error.js +12 -28
  265. package/dist/_esm5.processed/errors/encrypted_media_error.js +16 -32
  266. package/dist/_esm5.processed/errors/error_codes.js +9 -4
  267. package/dist/_esm5.processed/errors/error_message.d.ts +1 -2
  268. package/dist/_esm5.processed/errors/error_message.js +5 -3
  269. package/dist/_esm5.processed/errors/format_error.js +9 -7
  270. package/dist/_esm5.processed/errors/index.js +25 -11
  271. package/dist/_esm5.processed/errors/is_known_error.js +14 -11
  272. package/dist/_esm5.processed/errors/media_error.d.ts +2 -2
  273. package/dist/_esm5.processed/errors/media_error.js +34 -47
  274. package/dist/_esm5.processed/errors/network_error.js +21 -37
  275. package/dist/_esm5.processed/errors/other_error.js +15 -31
  276. package/dist/_esm5.processed/errors/request_error.js +27 -29
  277. package/dist/_esm5.processed/experimental/features/dash_wasm.js +15 -9
  278. package/dist/_esm5.processed/experimental/features/debug_element.js +7 -4
  279. package/dist/_esm5.processed/experimental/features/index.d.ts +0 -1
  280. package/dist/_esm5.processed/experimental/features/index.js +9 -4
  281. package/dist/_esm5.processed/experimental/features/local.js +10 -4
  282. package/dist/_esm5.processed/experimental/features/metaplaylist.js +10 -4
  283. package/dist/_esm5.processed/experimental/index.js +5 -2
  284. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/features/dash.js +6 -3
  285. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/features/metaplaylist.js +6 -3
  286. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/index.js +7 -3
  287. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +22 -16
  288. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +22 -19
  289. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +6 -3
  290. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/types.js +2 -1
  291. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +125 -186
  292. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.js +11 -27
  293. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +76 -119
  294. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/index.js +24 -15
  295. package/dist/_esm5.processed/experimental/tools/index.js +11 -5
  296. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.d.ts +1 -1
  297. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/index.js +39 -44
  298. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +1 -1
  299. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +34 -36
  300. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/capabilities.js +21 -18
  301. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/index.js +4 -2
  302. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/log.js +5 -3
  303. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.d.ts +1 -1
  304. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +21 -17
  305. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +21 -17
  306. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +13 -10
  307. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +16 -13
  308. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/index.js +16 -14
  309. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +14 -11
  310. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.js +14 -11
  311. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +19 -15
  312. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +11 -7
  313. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/types.js +5 -2
  314. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/utils.js +25 -22
  315. package/dist/_esm5.processed/experimental/tools/parseBIFThumbnails.js +7 -4
  316. package/dist/_esm5.processed/features/add_features.js +11 -8
  317. package/dist/_esm5.processed/features/features_object.js +6 -3
  318. package/dist/_esm5.processed/features/index.js +7 -4
  319. package/dist/_esm5.processed/features/list/dash.js +12 -6
  320. package/dist/_esm5.processed/features/list/directfile.js +9 -5
  321. package/dist/_esm5.processed/features/list/eme.js +7 -4
  322. package/dist/_esm5.processed/features/list/html_sami_parser.js +9 -4
  323. package/dist/_esm5.processed/features/list/html_srt_parser.js +9 -4
  324. package/dist/_esm5.processed/features/list/html_text_buffer.js +7 -4
  325. package/dist/_esm5.processed/features/list/html_ttml_parser.js +9 -4
  326. package/dist/_esm5.processed/features/list/html_vtt_parser.js +9 -4
  327. package/dist/_esm5.processed/features/list/index.js +31 -14
  328. package/dist/_esm5.processed/features/list/native_sami_parser.js +10 -4
  329. package/dist/_esm5.processed/features/list/native_srt_parser.js +10 -4
  330. package/dist/_esm5.processed/features/list/native_text_buffer.js +8 -4
  331. package/dist/_esm5.processed/features/list/native_ttml_parser.js +10 -4
  332. package/dist/_esm5.processed/features/list/native_vtt_parser.js +10 -4
  333. package/dist/_esm5.processed/features/list/smooth.js +10 -4
  334. package/dist/_esm5.processed/features/types.d.ts +84 -7
  335. package/dist/_esm5.processed/features/types.js +2 -1
  336. package/dist/_esm5.processed/index.d.ts +0 -4
  337. package/dist/_esm5.processed/index.js +24 -8
  338. package/dist/_esm5.processed/log.js +5 -3
  339. package/dist/_esm5.processed/manifest/adaptation.js +52 -55
  340. package/dist/_esm5.processed/manifest/index.js +32 -13
  341. package/dist/_esm5.processed/manifest/manifest.d.ts +4 -7
  342. package/dist/_esm5.processed/manifest/manifest.js +117 -135
  343. package/dist/_esm5.processed/manifest/period.d.ts +2 -7
  344. package/dist/_esm5.processed/manifest/period.js +39 -46
  345. package/dist/_esm5.processed/manifest/representation.d.ts +12 -0
  346. package/dist/_esm5.processed/manifest/representation.js +81 -63
  347. package/dist/_esm5.processed/manifest/representation_index/index.js +5 -2
  348. package/dist/_esm5.processed/manifest/representation_index/static.js +43 -42
  349. package/dist/_esm5.processed/manifest/representation_index/types.js +2 -1
  350. package/dist/_esm5.processed/manifest/types.js +5 -2
  351. package/dist/_esm5.processed/manifest/update_period_in_place.js +38 -48
  352. package/dist/_esm5.processed/manifest/update_periods.js +59 -69
  353. package/dist/_esm5.processed/manifest/utils.js +14 -9
  354. package/dist/_esm5.processed/minimal.d.ts +1 -17
  355. package/dist/_esm5.processed/minimal.js +9 -39
  356. package/dist/_esm5.processed/parsers/containers/isobmff/constants.js +4 -1
  357. package/dist/_esm5.processed/parsers/containers/isobmff/create_box.js +14 -10
  358. package/dist/_esm5.processed/parsers/containers/isobmff/drm/index.js +5 -1
  359. package/dist/_esm5.processed/parsers/containers/isobmff/drm/playready.js +15 -11
  360. package/dist/_esm5.processed/parsers/containers/isobmff/get_box.js +48 -40
  361. package/dist/_esm5.processed/parsers/containers/isobmff/index.js +27 -6
  362. package/dist/_esm5.processed/parsers/containers/isobmff/read.js +20 -14
  363. package/dist/_esm5.processed/parsers/containers/isobmff/take_pssh_out.js +25 -20
  364. package/dist/_esm5.processed/parsers/containers/isobmff/utils.js +130 -112
  365. package/dist/_esm5.processed/parsers/containers/matroska/index.js +6 -1
  366. package/dist/_esm5.processed/parsers/containers/matroska/utils.js +67 -63
  367. package/dist/_esm5.processed/parsers/images/bif.js +40 -29
  368. package/dist/_esm5.processed/parsers/manifest/dash/common/attach_trickmode_track.js +10 -12
  369. package/dist/_esm5.processed/parsers/manifest/dash/common/flatten_overlapping_periods.js +10 -7
  370. package/dist/_esm5.processed/parsers/manifest/dash/common/get_clock_offset.d.ts +3 -3
  371. package/dist/_esm5.processed/parsers/manifest/dash/common/get_clock_offset.js +11 -7
  372. package/dist/_esm5.processed/parsers/manifest/dash/common/get_hdr_information.js +10 -6
  373. package/dist/_esm5.processed/parsers/manifest/dash/common/get_http_utc-timing_url.js +7 -6
  374. package/dist/_esm5.processed/parsers/manifest/dash/common/get_minimum_and_maximum_positions.js +10 -6
  375. package/dist/_esm5.processed/parsers/manifest/dash/common/get_periods_time_infos.js +14 -9
  376. package/dist/_esm5.processed/parsers/manifest/dash/common/index.js +10 -4
  377. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +73 -67
  378. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.js +9 -4
  379. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +32 -25
  380. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/index.js +11 -5
  381. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +81 -70
  382. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +130 -123
  383. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +15 -12
  384. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +35 -32
  385. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.js +14 -9
  386. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +30 -22
  387. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/index.js +4 -2
  388. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +14 -11
  389. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +5 -3
  390. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +131 -128
  391. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/tokens.js +16 -10
  392. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/utils.js +7 -3
  393. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +19 -18
  394. package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +8 -4
  395. package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.js +22 -19
  396. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +111 -108
  397. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_availability_start_time.js +4 -1
  398. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +6 -3
  399. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +86 -84
  400. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.d.ts +4 -0
  401. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +101 -84
  402. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +2 -2
  403. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +39 -37
  404. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +64 -65
  405. package/dist/_esm5.processed/parsers/manifest/dash/common/resolve_base_urls.js +12 -9
  406. package/dist/_esm5.processed/parsers/manifest/dash/index.js +8 -1
  407. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/index.js +4 -2
  408. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +66 -62
  409. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/BaseURL.js +7 -4
  410. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/ContentComponent.js +7 -4
  411. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/ContentProtection.js +22 -19
  412. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/EventStream.js +22 -19
  413. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Initialization.js +11 -8
  414. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/MPD.js +38 -34
  415. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Period.js +34 -30
  416. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +50 -38
  417. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.js +24 -21
  418. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentList.js +15 -12
  419. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.js +21 -18
  420. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentTimeline.js +6 -3
  421. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.js +12 -9
  422. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +60 -64
  423. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.js +33 -27
  424. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +1 -0
  425. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.js +2 -1
  426. package/dist/_esm5.processed/parsers/manifest/dash/parsers_types.d.ts +4 -4
  427. package/dist/_esm5.processed/parsers/manifest/dash/parsers_types.js +2 -1
  428. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/index.js +4 -2
  429. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +192 -237
  430. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +67 -62
  431. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.js +8 -4
  432. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.js +11 -7
  433. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.js +17 -13
  434. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.js +29 -24
  435. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/MPD.js +38 -33
  436. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Period.js +37 -32
  437. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +50 -35
  438. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.js +9 -5
  439. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.js +16 -12
  440. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentList.js +11 -7
  441. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.js +20 -16
  442. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.js +11 -7
  443. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/XLink.js +11 -7
  444. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/index.js +5 -1
  445. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/root.js +10 -6
  446. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/parsers_stack.js +22 -20
  447. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.js +2 -1
  448. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/utils.js +6 -2
  449. package/dist/_esm5.processed/parsers/manifest/index.js +17 -1
  450. package/dist/_esm5.processed/parsers/manifest/local/index.js +4 -2
  451. package/dist/_esm5.processed/parsers/manifest/local/parse_local_manifest.js +31 -26
  452. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +71 -84
  453. package/dist/_esm5.processed/parsers/manifest/local/types.d.ts +2 -0
  454. package/dist/_esm5.processed/parsers/manifest/local/types.js +2 -1
  455. package/dist/_esm5.processed/parsers/manifest/metaplaylist/index.js +4 -2
  456. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +76 -71
  457. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +52 -52
  458. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +200 -175
  459. package/dist/_esm5.processed/parsers/manifest/smooth/get_codecs.js +13 -8
  460. package/dist/_esm5.processed/parsers/manifest/smooth/index.js +7 -4
  461. package/dist/_esm5.processed/parsers/manifest/smooth/parse_C_nodes.js +17 -14
  462. package/dist/_esm5.processed/parsers/manifest/smooth/parse_protection_node.js +17 -15
  463. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +3 -3
  464. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +102 -97
  465. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +3 -3
  466. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +49 -47
  467. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +10 -7
  468. package/dist/_esm5.processed/parsers/manifest/smooth/utils/parseBoolean.js +4 -1
  469. package/dist/_esm5.processed/parsers/manifest/smooth/utils/reduceChildren.js +6 -3
  470. package/dist/_esm5.processed/parsers/manifest/smooth/utils/tokens.js +5 -1
  471. package/dist/_esm5.processed/parsers/manifest/types.d.ts +6 -4
  472. package/dist/_esm5.processed/parsers/manifest/types.js +2 -1
  473. package/dist/_esm5.processed/parsers/manifest/utils/check_manifest_ids.js +27 -24
  474. package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.js +10 -7
  475. package/dist/_esm5.processed/parsers/manifest/utils/get_first_time_from_adaptation.js +8 -5
  476. package/dist/_esm5.processed/parsers/manifest/utils/get_last_time_from_adaptation.js +8 -5
  477. package/dist/_esm5.processed/parsers/manifest/utils/get_maximum_positions.js +15 -12
  478. package/dist/_esm5.processed/parsers/manifest/utils/get_minimum_position.js +15 -12
  479. package/dist/_esm5.processed/parsers/manifest/utils/index_helpers.js +31 -22
  480. package/dist/_esm5.processed/parsers/manifest/utils/is_segment_still_available.js +9 -6
  481. package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.js +38 -45
  482. package/dist/_esm5.processed/parsers/texttracks/index.js +2 -1
  483. package/dist/_esm5.processed/parsers/texttracks/sami/html.js +45 -43
  484. package/dist/_esm5.processed/parsers/texttracks/sami/native.js +41 -39
  485. package/dist/_esm5.processed/parsers/texttracks/srt/find_end_of_cue_block.js +7 -4
  486. package/dist/_esm5.processed/parsers/texttracks/srt/get_cue_blocks.js +11 -8
  487. package/dist/_esm5.processed/parsers/texttracks/srt/html.js +32 -29
  488. package/dist/_esm5.processed/parsers/texttracks/srt/native.js +16 -13
  489. package/dist/_esm5.processed/parsers/texttracks/srt/parse_cue.js +21 -18
  490. package/dist/_esm5.processed/parsers/texttracks/srt/parse_timestamp.js +10 -7
  491. package/dist/_esm5.processed/parsers/texttracks/ttml/get_parameters.js +37 -30
  492. package/dist/_esm5.processed/parsers/texttracks/ttml/get_styling.js +48 -48
  493. package/dist/_esm5.processed/parsers/texttracks/ttml/get_time_delimiters.js +14 -11
  494. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.js +7 -2
  495. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +15 -12
  496. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_font_size.js +15 -12
  497. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +11 -8
  498. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +15 -12
  499. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_padding.js +25 -22
  500. package/dist/_esm5.processed/parsers/texttracks/ttml/html/create_element.js +117 -124
  501. package/dist/_esm5.processed/parsers/texttracks/ttml/html/generate_css_test_outline.js +11 -8
  502. package/dist/_esm5.processed/parsers/texttracks/ttml/html/index.js +4 -2
  503. package/dist/_esm5.processed/parsers/texttracks/ttml/html/parse_cue.js +12 -8
  504. package/dist/_esm5.processed/parsers/texttracks/ttml/html/parse_ttml_to_div.js +14 -11
  505. package/dist/_esm5.processed/parsers/texttracks/ttml/html/ttml_color_to_css_color.js +10 -7
  506. package/dist/_esm5.processed/parsers/texttracks/ttml/native/index.js +4 -2
  507. package/dist/_esm5.processed/parsers/texttracks/ttml/native/parse_cue.js +38 -35
  508. package/dist/_esm5.processed/parsers/texttracks/ttml/native/parse_ttml_to_vtt.js +11 -8
  509. package/dist/_esm5.processed/parsers/texttracks/ttml/parse_ttml.js +58 -58
  510. package/dist/_esm5.processed/parsers/texttracks/ttml/regexps.js +27 -13
  511. package/dist/_esm5.processed/parsers/texttracks/ttml/resolve_styles_inheritance.js +18 -18
  512. package/dist/_esm5.processed/parsers/texttracks/ttml/time_parsing.js +28 -26
  513. package/dist/_esm5.processed/parsers/texttracks/ttml/xml_utils.js +37 -25
  514. package/dist/_esm5.processed/parsers/texttracks/types.js +2 -1
  515. package/dist/_esm5.processed/parsers/texttracks/webvtt/get_cue_blocks.js +12 -9
  516. package/dist/_esm5.processed/parsers/texttracks/webvtt/get_style_blocks.js +14 -11
  517. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/convert_payload_to_html.js +11 -8
  518. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/create_default_style_elements.js +8 -5
  519. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/create_style_attribute.js +60 -60
  520. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/create_styled_element.js +30 -27
  521. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/index.js +4 -2
  522. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/parse_style_block.js +23 -26
  523. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/parse_webvtt_to_div.js +20 -17
  524. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/to_html.js +23 -18
  525. package/dist/_esm5.processed/parsers/texttracks/webvtt/native/index.js +4 -2
  526. package/dist/_esm5.processed/parsers/texttracks/webvtt/native/parse_vtt_to_cues.js +19 -16
  527. package/dist/_esm5.processed/parsers/texttracks/webvtt/native/set_settings_on_cue.js +20 -17
  528. package/dist/_esm5.processed/parsers/texttracks/webvtt/native/to_native_cue.js +8 -5
  529. package/dist/_esm5.processed/parsers/texttracks/webvtt/parse_cue_block.js +26 -18
  530. package/dist/_esm5.processed/parsers/texttracks/webvtt/parse_timestamp.js +10 -7
  531. package/dist/_esm5.processed/parsers/texttracks/webvtt/utils.js +15 -7
  532. package/dist/_esm5.processed/public_types.d.ts +6 -8
  533. package/dist/_esm5.processed/public_types.js +2 -1
  534. package/dist/_esm5.processed/tools/TextTrackRenderer/index.js +13 -6
  535. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +26 -24
  536. package/dist/_esm5.processed/tools/index.js +6 -4
  537. package/dist/_esm5.processed/tools/string_utils.js +10 -1
  538. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +16 -24
  539. package/dist/_esm5.processed/transports/dash/construct_segment_url.js +6 -3
  540. package/dist/_esm5.processed/transports/dash/extract_complete_chunks.js +17 -14
  541. package/dist/_esm5.processed/transports/dash/get_events_out_of_emsgs.js +19 -16
  542. package/dist/_esm5.processed/transports/dash/index.js +4 -2
  543. package/dist/_esm5.processed/transports/dash/init_segment_loader.js +47 -27
  544. package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +23 -16
  545. package/dist/_esm5.processed/transports/dash/manifest_parser.js +68 -59
  546. package/dist/_esm5.processed/transports/dash/pipelines.js +20 -17
  547. package/dist/_esm5.processed/transports/dash/segment_loader.js +49 -39
  548. package/dist/_esm5.processed/transports/dash/segment_parser.js +58 -39
  549. package/dist/_esm5.processed/transports/dash/text_loader.js +36 -30
  550. package/dist/_esm5.processed/transports/dash/text_parser.js +39 -29
  551. package/dist/_esm5.processed/transports/index.js +17 -1
  552. package/dist/_esm5.processed/transports/local/index.js +4 -2
  553. package/dist/_esm5.processed/transports/local/pipelines.js +26 -22
  554. package/dist/_esm5.processed/transports/local/segment_loader.js +26 -23
  555. package/dist/_esm5.processed/transports/local/segment_parser.js +36 -25
  556. package/dist/_esm5.processed/transports/local/text_parser.js +42 -27
  557. package/dist/_esm5.processed/transports/metaplaylist/index.js +4 -2
  558. package/dist/_esm5.processed/transports/metaplaylist/manifest_loader.js +11 -7
  559. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +92 -96
  560. package/dist/_esm5.processed/transports/smooth/extract_timings_infos.js +26 -20
  561. package/dist/_esm5.processed/transports/smooth/index.js +4 -2
  562. package/dist/_esm5.processed/transports/smooth/is_mp4_embedded_track.js +4 -1
  563. package/dist/_esm5.processed/transports/smooth/isobmff/create_audio_init_segment.js +22 -19
  564. package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.js +92 -67
  565. package/dist/_esm5.processed/transports/smooth/isobmff/create_init_segment.js +29 -26
  566. package/dist/_esm5.processed/transports/smooth/isobmff/create_traf_box.js +9 -6
  567. package/dist/_esm5.processed/transports/smooth/isobmff/create_video_init_segment.js +23 -20
  568. package/dist/_esm5.processed/transports/smooth/isobmff/get_aaces_header.js +10 -7
  569. package/dist/_esm5.processed/transports/smooth/isobmff/index.js +13 -6
  570. package/dist/_esm5.processed/transports/smooth/isobmff/parse_tfrf.js +19 -16
  571. package/dist/_esm5.processed/transports/smooth/isobmff/parse_tfxd.js +9 -6
  572. package/dist/_esm5.processed/transports/smooth/isobmff/patch_segment.js +41 -38
  573. package/dist/_esm5.processed/transports/smooth/pipelines.js +107 -96
  574. package/dist/_esm5.processed/transports/smooth/segment_loader.js +149 -153
  575. package/dist/_esm5.processed/transports/smooth/utils.js +7 -3
  576. package/dist/_esm5.processed/transports/types.d.ts +17 -8
  577. package/dist/_esm5.processed/transports/types.js +2 -1
  578. package/dist/_esm5.processed/transports/utils/byte_range.js +6 -4
  579. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +23 -17
  580. package/dist/_esm5.processed/transports/utils/check_isobmff_integrity.js +14 -11
  581. package/dist/_esm5.processed/transports/utils/find_complete_box.js +11 -8
  582. package/dist/_esm5.processed/transports/utils/generate_manifest_loader.js +22 -14
  583. package/dist/_esm5.processed/transports/utils/get_isobmff_timing_infos.d.ts +0 -3
  584. package/dist/_esm5.processed/transports/utils/get_isobmff_timing_infos.js +13 -13
  585. package/dist/_esm5.processed/transports/utils/infer_segment_container.js +4 -1
  586. package/dist/_esm5.processed/transports/utils/parse_text_track.js +40 -26
  587. package/dist/_esm5.processed/utils/are_arrays_of_numbers_equal.js +8 -2
  588. package/dist/_esm5.processed/utils/are_codecs_compatible.js +11 -9
  589. package/dist/_esm5.processed/utils/array_find.js +7 -4
  590. package/dist/_esm5.processed/utils/array_find_index.js +6 -3
  591. package/dist/_esm5.processed/utils/array_includes.js +12 -11
  592. package/dist/_esm5.processed/utils/assert.js +15 -10
  593. package/dist/_esm5.processed/utils/assert_unreachable.js +6 -3
  594. package/dist/_esm5.processed/utils/base64.js +23 -18
  595. package/dist/_esm5.processed/utils/byte_parsing.js +30 -17
  596. package/dist/_esm5.processed/utils/cancellable_sleep.js +8 -5
  597. package/dist/_esm5.processed/utils/create_cancellable_promise.js +7 -4
  598. package/dist/_esm5.processed/utils/deep_merge.d.ts +2 -5
  599. package/dist/_esm5.processed/utils/deep_merge.js +10 -21
  600. package/dist/_esm5.processed/utils/event_emitter.js +24 -24
  601. package/dist/_esm5.processed/utils/flat_map.js +7 -4
  602. package/dist/_esm5.processed/utils/get_fuzzed_delay.js +6 -3
  603. package/dist/_esm5.processed/utils/hash_buffer.js +7 -4
  604. package/dist/_esm5.processed/utils/id_generator.js +6 -3
  605. package/dist/_esm5.processed/utils/initialization_segment_cache.js +11 -12
  606. package/dist/_esm5.processed/utils/is_non_empty_string.js +4 -1
  607. package/dist/_esm5.processed/utils/is_null_or_undefined.js +4 -1
  608. package/dist/_esm5.processed/utils/languages/ISO_639-1_to_ISO_639-3.js +4 -2
  609. package/dist/_esm5.processed/utils/languages/ISO_639-2_to_ISO_639-3.js +4 -2
  610. package/dist/_esm5.processed/utils/languages/index.js +7 -3
  611. package/dist/_esm5.processed/utils/languages/normalize.js +26 -20
  612. package/dist/_esm5.processed/utils/logger.js +24 -23
  613. package/dist/_esm5.processed/utils/monotonic_timestamp.d.ts +9 -0
  614. package/dist/_esm5.processed/utils/monotonic_timestamp.js +15 -0
  615. package/dist/_esm5.processed/utils/noop.js +4 -1
  616. package/dist/_esm5.processed/utils/object_assign.js +8 -10
  617. package/dist/_esm5.processed/utils/object_values.js +6 -3
  618. package/dist/_esm5.processed/utils/ranges.d.ts +50 -8
  619. package/dist/_esm5.processed/utils/ranges.js +163 -64
  620. package/dist/_esm5.processed/utils/reference.d.ts +78 -37
  621. package/dist/_esm5.processed/utils/reference.js +235 -155
  622. package/dist/_esm5.processed/utils/request/fetch.d.ts +4 -4
  623. package/dist/_esm5.processed/utils/request/fetch.js +79 -107
  624. package/dist/_esm5.processed/utils/request/index.js +9 -4
  625. package/dist/_esm5.processed/utils/request/xhr.js +49 -36
  626. package/dist/_esm5.processed/utils/resolve_url.js +18 -18
  627. package/dist/_esm5.processed/utils/retry_promise_with_backoff.js +34 -81
  628. package/dist/_esm5.processed/utils/sleep.js +5 -2
  629. package/dist/_esm5.processed/utils/slice_uint8array.js +3 -1
  630. package/dist/_esm5.processed/utils/sorted_list.js +37 -40
  631. package/dist/_esm5.processed/utils/starts_with.js +5 -2
  632. package/dist/_esm5.processed/utils/string_parsing.js +84 -72
  633. package/dist/_esm5.processed/utils/take_first_set.js +9 -10
  634. package/dist/_esm5.processed/utils/task_canceller.js +51 -71
  635. package/dist/_esm5.processed/utils/warn_once.js +7 -4
  636. package/dist/_esm5.processed/utils/weak_map_memory.js +12 -11
  637. package/dist/_esm5.processed/utils/wrapInPromise.d.ts +7 -0
  638. package/dist/_esm5.processed/utils/wrapInPromise.js +25 -0
  639. package/dist/mpd-parser.wasm +0 -0
  640. package/dist/rx-player.js +42885 -44008
  641. package/dist/rx-player.min.js +1 -1
  642. package/jest.config.js +1 -22
  643. package/package.json +56 -57
  644. package/scripts/build/constants.d.ts +1 -23
  645. package/scripts/build/generate_build.js +1 -1
  646. package/scripts/check_nodejs_import_compatibility.js +1 -1
  647. package/scripts/list-npm-scripts.js +146 -38
  648. package/scripts/update-version +1 -4
  649. package/sonar-project.properties +1 -1
  650. package/src/compat/__tests__/browser_compatibility_types.test.ts +51 -72
  651. package/src/compat/__tests__/is_vtt_cue.test.ts +20 -16
  652. package/src/compat/__tests__/make_vtt_cue.test.ts +11 -9
  653. package/src/compat/__tests__/patch_webkit_source_buffer.test.ts +26 -25
  654. package/src/compat/__tests__/should_favour_custom_safari_EME.test.ts +11 -9
  655. package/src/compat/__tests__/should_wait_for_have_enough_data.test.ts +36 -0
  656. package/src/compat/browser_compatibility_types.ts +9 -16
  657. package/src/compat/browser_detection.ts +11 -8
  658. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +11 -8
  659. package/src/compat/eme/custom_media_keys/index.ts +8 -184
  660. package/src/compat/eme/custom_media_keys/moz_media_keys_constructor.ts +26 -22
  661. package/src/compat/eme/custom_media_keys/ms_media_keys_constructor.ts +13 -15
  662. package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +11 -8
  663. package/src/compat/eme/custom_media_keys/types.ts +1 -1
  664. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +15 -11
  665. package/src/compat/eme/custom_media_keys/webkit_media_keys_constructor.ts +14 -16
  666. package/src/compat/eme/eme-api-implementation.ts +319 -0
  667. package/src/compat/eme/index.ts +8 -6
  668. package/src/compat/event_listeners.ts +32 -39
  669. package/src/compat/global_scope.ts +18 -0
  670. package/src/compat/index.ts +2 -24
  671. package/src/compat/is_debug_mode_enabled.ts +12 -0
  672. package/src/compat/is_node.ts +4 -1
  673. package/src/compat/is_vtt_cue.ts +2 -1
  674. package/src/compat/is_worker.ts +9 -0
  675. package/src/compat/make_vtt_cue.ts +3 -2
  676. package/src/compat/on_height_width_change.ts +4 -9
  677. package/src/compat/patch_webkit_source_buffer.ts +4 -3
  678. package/src/compat/should_wait_for_have_enough_data.ts +17 -0
  679. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +245 -102
  680. package/src/core/adaptive/adaptive_representation_selector.ts +52 -35
  681. package/src/core/adaptive/buffer_based_chooser.ts +41 -13
  682. package/src/core/adaptive/guess_based_chooser.ts +4 -3
  683. package/src/core/adaptive/network_analyzer.ts +8 -6
  684. package/src/core/adaptive/utils/pending_requests_store.ts +15 -5
  685. package/src/core/api/debug/buffer_size_graph.ts +3 -1
  686. package/src/core/api/option_utils.ts +2 -2
  687. package/src/core/api/playback_observer.ts +16 -9
  688. package/src/core/api/public_api.ts +47 -31
  689. package/src/core/api/track_management/track_dispatcher.ts +9 -6
  690. package/src/core/api/track_management/tracks_store.ts +112 -90
  691. package/src/core/api/utils.ts +3 -3
  692. package/src/core/decrypt/__tests__/__global__/get_license.test.ts +3 -3
  693. package/src/core/decrypt/__tests__/__global__/init_data.test.ts +24 -14
  694. package/src/core/decrypt/__tests__/__global__/media_key_system_access.test.ts +74 -48
  695. package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +21 -15
  696. package/src/core/decrypt/__tests__/__global__/server_certificate.test.ts +16 -13
  697. package/src/core/decrypt/__tests__/__global__/utils.ts +39 -24
  698. package/src/core/decrypt/attach_media_keys.ts +33 -8
  699. package/src/core/decrypt/clear_on_stop.ts +1 -1
  700. package/src/core/decrypt/content_decryptor.ts +213 -262
  701. package/src/core/decrypt/create_or_load_session.ts +1 -1
  702. package/src/core/decrypt/create_session.ts +1 -1
  703. package/src/core/decrypt/dispose_decryption_resources.ts +19 -4
  704. package/src/core/decrypt/find_key_system.ts +24 -19
  705. package/src/core/decrypt/get_media_keys.ts +2 -2
  706. package/src/core/decrypt/index.ts +1 -6
  707. package/src/core/decrypt/session_events_listener.ts +3 -4
  708. package/src/core/decrypt/set_server_certificate.ts +1 -1
  709. package/src/core/decrypt/types.ts +69 -0
  710. package/src/core/decrypt/utils/check_key_statuses.ts +1 -1
  711. package/src/core/decrypt/utils/is_session_usable.ts +1 -1
  712. package/src/core/decrypt/utils/key_id_comparison.ts +2 -27
  713. package/src/core/decrypt/utils/key_session_record.ts +3 -5
  714. package/src/core/decrypt/utils/loaded_sessions_store.ts +2 -2
  715. package/src/core/decrypt/utils/media_keys_infos_store.ts +4 -1
  716. package/src/core/decrypt/utils/persistent_sessions_store.ts +2 -5
  717. package/src/core/decrypt/utils/server_certificate_store.ts +1 -1
  718. package/src/core/fetchers/cdn_prioritizer.ts +1 -1
  719. package/src/core/fetchers/manifest/manifest_fetcher.ts +22 -18
  720. package/src/core/fetchers/segment/segment_fetcher.ts +3 -2
  721. package/src/core/fetchers/utils/schedule_request.ts +6 -5
  722. package/src/core/init/directfile_content_initializer.ts +85 -21
  723. package/src/core/init/index.ts +6 -7
  724. package/src/core/init/media_source_content_initializer.ts +56 -26
  725. package/src/core/init/types.ts +2 -16
  726. package/src/core/init/utils/__tests__/refresh_scheduled_events_list.test.ts +22 -8
  727. package/src/core/init/utils/create_media_source.ts +4 -1
  728. package/src/core/init/utils/create_stream_playback_observer.ts +24 -14
  729. package/src/core/init/utils/end_of_stream.ts +1 -0
  730. package/src/core/init/utils/get_initial_time.ts +3 -1
  731. package/src/core/init/utils/get_loaded_reference.ts +6 -3
  732. package/src/core/init/utils/initial_seek_and_play.ts +7 -7
  733. package/src/core/init/utils/initialize_content_decryption.ts +32 -39
  734. package/src/core/init/utils/media_source_duration_updater.ts +13 -9
  735. package/src/core/init/utils/rebuffering_controller.ts +13 -10
  736. package/src/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.ts +7 -4
  737. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +113 -73
  738. package/src/core/segment_buffers/garbage_collector.ts +3 -3
  739. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +10 -2
  740. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +17 -17
  741. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +1 -1
  742. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +2 -2
  743. package/src/core/segment_buffers/implementations/utils/manual_time_ranges.ts +2 -2
  744. package/src/core/segment_buffers/inventory/buffered_history.ts +4 -3
  745. package/src/core/segment_buffers/inventory/segment_inventory.ts +1 -0
  746. package/src/core/stream/adaptation/adaptation_stream.ts +43 -28
  747. package/src/core/stream/adaptation/types.ts +15 -9
  748. package/src/core/stream/index.ts +2 -0
  749. package/src/core/stream/orchestrator/get_time_ranges_for_content.ts +1 -6
  750. package/src/core/stream/orchestrator/index.ts +2 -0
  751. package/src/core/stream/orchestrator/stream_orchestrator.ts +38 -42
  752. package/src/core/stream/period/period_stream.ts +62 -23
  753. package/src/core/stream/period/types.ts +5 -3
  754. package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +10 -0
  755. package/src/core/stream/representation/representation_stream.ts +6 -3
  756. package/src/core/stream/representation/types.ts +5 -5
  757. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +2 -2
  758. package/src/core/stream/representation/utils/downloading_queue.ts +4 -5
  759. package/src/core/stream/representation/utils/force_garbage_collection.ts +3 -3
  760. package/src/core/stream/representation/utils/get_buffer_status.ts +2 -1
  761. package/src/core/stream/representation/utils/push_init_segment.ts +2 -3
  762. package/src/core/stream/representation/utils/push_media_segment.ts +2 -2
  763. package/src/errors/__tests__/encrypted_media_error.test.ts +2 -2
  764. package/src/errors/__tests__/error_message.test.ts +1 -1
  765. package/src/errors/__tests__/format_error.test.ts +2 -2
  766. package/src/errors/__tests__/media_error.test.ts +3 -3
  767. package/src/errors/__tests__/network_error.test.ts +10 -9
  768. package/src/errors/__tests__/other_error.test.ts +3 -3
  769. package/src/errors/__tests__/request_error.test.ts +4 -4
  770. package/src/errors/custom_loader_error.ts +0 -1
  771. package/src/errors/encrypted_media_error.ts +4 -2
  772. package/src/errors/error_message.ts +2 -7
  773. package/src/errors/media_error.ts +26 -20
  774. package/src/errors/network_error.ts +1 -1
  775. package/src/errors/other_error.ts +1 -1
  776. package/src/errors/request_error.ts +16 -1
  777. package/src/experimental/features/__tests__/dash_wasm.test.ts +4 -12
  778. package/src/experimental/features/__tests__/debug_element.test.ts +7 -21
  779. package/src/experimental/features/__tests__/local.test.ts +14 -23
  780. package/src/experimental/features/__tests__/metaplaylist.test.ts +14 -21
  781. package/src/experimental/features/dash_wasm.ts +3 -0
  782. package/src/experimental/features/index.ts +0 -1
  783. package/src/experimental/features/local.ts +3 -0
  784. package/src/experimental/features/metaplaylist.ts +3 -0
  785. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +10 -9
  786. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +26 -18
  787. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +24 -23
  788. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +2 -4
  789. package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +7 -4
  790. package/src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts +5 -4
  791. package/src/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.ts +4 -3
  792. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.ts +4 -3
  793. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +3 -2
  794. package/src/features/features_object.ts +2 -1
  795. package/src/features/list/__tests__/dash.test.ts +15 -15
  796. package/src/features/list/__tests__/directfile.test.ts +4 -13
  797. package/src/features/list/__tests__/eme.test.ts +4 -12
  798. package/src/features/list/__tests__/html_sami_parser.test.ts +9 -14
  799. package/src/features/list/__tests__/html_srt_parser.test.ts +5 -10
  800. package/src/features/list/__tests__/html_text_buffer.test.ts +10 -19
  801. package/src/features/list/__tests__/html_ttml_parser.test.ts +5 -10
  802. package/src/features/list/__tests__/html_vtt_parser.test.ts +5 -10
  803. package/src/features/list/__tests__/native_sami_parser.test.ts +9 -14
  804. package/src/features/list/__tests__/native_srt_parser.test.ts +5 -10
  805. package/src/features/list/__tests__/native_text_buffer.test.ts +5 -13
  806. package/src/features/list/__tests__/native_ttml_parser.test.ts +5 -10
  807. package/src/features/list/__tests__/native_vtt_parser.test.ts +5 -10
  808. package/src/features/list/__tests__/smooth.test.ts +10 -10
  809. package/src/features/list/dash.ts +3 -0
  810. package/src/features/list/eme.ts +1 -1
  811. package/src/features/list/html_sami_parser.ts +2 -0
  812. package/src/features/list/html_srt_parser.ts +2 -0
  813. package/src/features/list/html_text_buffer.ts +2 -2
  814. package/src/features/list/html_ttml_parser.ts +2 -0
  815. package/src/features/list/html_vtt_parser.ts +2 -0
  816. package/src/features/list/native_sami_parser.ts +3 -0
  817. package/src/features/list/native_srt_parser.ts +3 -0
  818. package/src/features/list/native_text_buffer.ts +3 -2
  819. package/src/features/list/native_ttml_parser.ts +3 -0
  820. package/src/features/list/native_vtt_parser.ts +3 -0
  821. package/src/features/list/smooth.ts +3 -0
  822. package/src/features/types.ts +89 -18
  823. package/src/index.ts +31 -5
  824. package/src/manifest/__tests__/manifest.test.ts +134 -75
  825. package/src/manifest/__tests__/period.test.ts +82 -55
  826. package/src/manifest/__tests__/update_periods.test.ts +4 -4
  827. package/src/manifest/manifest.ts +30 -20
  828. package/src/manifest/period.ts +3 -14
  829. package/src/manifest/representation.ts +21 -3
  830. package/src/minimal.ts +4 -18
  831. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +2 -1
  832. package/src/parsers/manifest/dash/common/get_clock_offset.ts +5 -4
  833. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +7 -4
  834. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +11 -5
  835. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +1 -0
  836. package/src/parsers/manifest/dash/common/parse_mpd.ts +9 -5
  837. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -6
  838. package/src/parsers/manifest/dash/common/parse_representation_index.ts +2 -2
  839. package/src/parsers/manifest/dash/common/parse_representations.ts +10 -0
  840. package/src/parsers/manifest/dash/js-parser/node_parsers/Representation.ts +7 -0
  841. package/src/parsers/manifest/dash/node_parser_types.ts +1 -0
  842. package/src/parsers/manifest/dash/parsers_types.ts +4 -4
  843. package/src/parsers/manifest/dash/wasm-parser/Cargo.lock +2 -2
  844. package/src/parsers/manifest/dash/wasm-parser/Cargo.toml +1 -1
  845. package/src/parsers/manifest/dash/wasm-parser/rs/errors.rs +3 -3
  846. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +37 -67
  847. package/src/parsers/manifest/dash/wasm-parser/rs/lib.rs +7 -7
  848. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +94 -105
  849. package/src/parsers/manifest/dash/wasm-parser/rs/processor/mod.rs +119 -109
  850. package/src/parsers/manifest/dash/wasm-parser/rs/processor/s_element.rs +24 -26
  851. package/src/parsers/manifest/dash/wasm-parser/rs/reader.rs +2 -2
  852. package/src/parsers/manifest/dash/wasm-parser/rs/reportable.rs +42 -18
  853. package/src/parsers/manifest/dash/wasm-parser/rs/utils.rs +29 -29
  854. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +2 -1
  855. package/src/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.ts +1 -1
  856. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +12 -0
  857. package/src/parsers/manifest/local/parse_local_manifest.ts +3 -1
  858. package/src/parsers/manifest/local/types.ts +2 -0
  859. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +3 -1
  860. package/src/parsers/manifest/smooth/create_parser.ts +4 -3
  861. package/src/parsers/manifest/smooth/representation_index.ts +6 -5
  862. package/src/parsers/manifest/smooth/shared_smooth_segment_timeline.ts +6 -5
  863. package/src/parsers/manifest/types.ts +6 -4
  864. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +1 -2
  865. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.test.ts +2 -1
  866. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +9 -7
  867. package/src/public_types.ts +11 -9
  868. package/src/transports/dash/manifest_parser.ts +8 -5
  869. package/src/transports/local/pipelines.ts +4 -3
  870. package/src/transports/metaplaylist/pipelines.ts +5 -3
  871. package/src/transports/smooth/pipelines.ts +4 -2
  872. package/src/transports/smooth/segment_loader.ts +1 -1
  873. package/src/transports/types.ts +17 -7
  874. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +8 -8
  875. package/src/transports/utils/call_custom_manifest_loader.ts +2 -1
  876. package/src/transports/utils/get_isobmff_timing_infos.ts +0 -3
  877. package/src/typings/globals.d.ts +0 -44
  878. package/src/utils/__tests__/base64.test.ts +4 -2
  879. package/src/utils/__tests__/id_generator.test.ts +7 -4
  880. package/src/utils/__tests__/ranges.test.ts +354 -47
  881. package/src/utils/are_arrays_of_numbers_equal.ts +5 -1
  882. package/src/utils/assert.ts +4 -1
  883. package/src/utils/deep_merge.ts +2 -2
  884. package/src/utils/monotonic_timestamp.ts +12 -0
  885. package/src/utils/ranges.ts +110 -14
  886. package/src/utils/reference.ts +235 -237
  887. package/src/utils/request/fetch.ts +11 -9
  888. package/src/utils/request/xhr.ts +6 -5
  889. package/src/utils/string_parsing.ts +5 -4
  890. package/src/utils/wrapInPromise.ts +24 -0
  891. package/tsconfig.json +1 -1
  892. package/tsconfig.modules.json +3 -3
  893. package/appveyor.yml +0 -24
  894. package/dist/_esm5.processed/compat/has_eme_apis.d.ts +0 -21
  895. package/dist/_esm5.processed/compat/has_eme_apis.js +0 -24
  896. package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts +0 -47
  897. package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +0 -70
  898. package/dist/_esm5.processed/core/stream/utils/create_reload_request.d.ts +0 -32
  899. package/dist/_esm5.processed/core/stream/utils/create_reload_request.js +0 -54
  900. package/dist/_esm5.processed/features/initialize_features.d.ts +0 -19
  901. package/dist/_esm5.processed/features/initialize_features.js +0 -100
  902. package/dist/rx-player.d.ts +0 -3
  903. package/dist/rx-player.min.d.ts +0 -3
  904. package/src/compat/__tests__/has_eme_apis.test.ts +0 -56
  905. package/src/compat/has_eme_apis.ts +0 -26
  906. package/src/core/stream/adaptation/utils/create_representation_estimator.ts +0 -114
  907. package/src/core/stream/utils/create_reload_request.ts +0 -69
  908. package/src/features/__tests__/initialize_features.test.ts +0 -477
  909. package/src/features/initialize_features.ts +0 -120
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Copyright 2015 CANAL+ Group
3
4
  *
@@ -13,99 +14,29 @@
13
14
  * See the License for the specific language governing permissions and
14
15
  * limitations under the License.
15
16
  */
16
- var __extends = (this && this.__extends) || (function () {
17
- var extendStatics = function (d, b) {
18
- extendStatics = Object.setPrototypeOf ||
19
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
- return extendStatics(d, b);
22
- };
23
- return function (d, b) {
24
- if (typeof b !== "function" && b !== null)
25
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
- extendStatics(d, b);
27
- function __() { this.constructor = d; }
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- };
30
- })();
31
- var __assign = (this && this.__assign) || function () {
32
- __assign = Object.assign || function(t) {
33
- for (var s, i = 1, n = arguments.length; i < n; i++) {
34
- s = arguments[i];
35
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
36
- t[p] = s[p];
37
- }
38
- return t;
39
- };
40
- return __assign.apply(this, arguments);
41
- };
42
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
43
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
44
- return new (P || (P = Promise))(function (resolve, reject) {
45
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
46
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48
- step((generator = generator.apply(thisArg, _arguments || [])).next());
49
- });
50
- };
51
- var __generator = (this && this.__generator) || function (thisArg, body) {
52
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
53
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
54
- function verb(n) { return function (v) { return step([n, v]); }; }
55
- function step(op) {
56
- if (f) throw new TypeError("Generator is already executing.");
57
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
58
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
- if (y = 0, t) op = [op[0] & 2, t.value];
60
- switch (op[0]) {
61
- case 0: case 1: t = op; break;
62
- case 4: _.label++; return { value: op[1], done: false };
63
- case 5: _.label++; y = op[1]; op = [0]; continue;
64
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
65
- default:
66
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
67
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
68
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
69
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
70
- if (t[2]) _.ops.pop();
71
- _.trys.pop(); continue;
72
- }
73
- op = body.call(thisArg, _);
74
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
75
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
76
- }
77
- };
78
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
79
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
80
- if (ar || !(i in from)) {
81
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
82
- ar[i] = from[i];
83
- }
84
- }
85
- return to.concat(ar || Array.prototype.slice.call(from));
86
- };
87
- import { events, getInitData, } from "../../compat/";
88
- import config from "../../config";
89
- import { EncryptedMediaError, OtherError, } from "../../errors";
90
- import log from "../../log";
91
- import areArraysOfNumbersEqual from "../../utils/are_arrays_of_numbers_equal";
92
- import arrayFind from "../../utils/array_find";
93
- import arrayIncludes from "../../utils/array_includes";
94
- import EventEmitter from "../../utils/event_emitter";
95
- import isNullOrUndefined from "../../utils/is_null_or_undefined";
96
- import { bytesToHex } from "../../utils/string_parsing";
97
- import TaskCanceller from "../../utils/task_canceller";
98
- import attachMediaKeys from "./attach_media_keys";
99
- import createOrLoadSession from "./create_or_load_session";
100
- import initMediaKeys from "./init_media_keys";
101
- import SessionEventsListener, { BlacklistedSessionError, } from "./session_events_listener";
102
- import setServerCertificate from "./set_server_certificate";
103
- import { DecommissionedSessionError } from "./utils/check_key_statuses";
104
- import cleanOldStoredPersistentInfo from "./utils/clean_old_stored_persistent_info";
105
- import getDrmSystemId from "./utils/get_drm_system_id";
106
- import InitDataValuesContainer from "./utils/init_data_values_container";
107
- import { areAllKeyIdsContainedIn, areKeyIdsEqual, areSomeKeyIdsContainedIn, isKeyIdContainedIn, } from "./utils/key_id_comparison";
108
- var onEncrypted = events.onEncrypted;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const eme_1 = require("../../compat/eme");
19
+ const config_1 = require("../../config");
20
+ const errors_1 = require("../../errors");
21
+ const log_1 = require("../../log");
22
+ const are_arrays_of_numbers_equal_1 = require("../../utils/are_arrays_of_numbers_equal");
23
+ const array_find_1 = require("../../utils/array_find");
24
+ const array_includes_1 = require("../../utils/array_includes");
25
+ const event_emitter_1 = require("../../utils/event_emitter");
26
+ const is_null_or_undefined_1 = require("../../utils/is_null_or_undefined");
27
+ const string_parsing_1 = require("../../utils/string_parsing");
28
+ const task_canceller_1 = require("../../utils/task_canceller");
29
+ const attach_media_keys_1 = require("./attach_media_keys");
30
+ const create_or_load_session_1 = require("./create_or_load_session");
31
+ const init_media_keys_1 = require("./init_media_keys");
32
+ const session_events_listener_1 = require("./session_events_listener");
33
+ const set_server_certificate_1 = require("./set_server_certificate");
34
+ const types_1 = require("./types");
35
+ const check_key_statuses_1 = require("./utils/check_key_statuses");
36
+ const clean_old_stored_persistent_info_1 = require("./utils/clean_old_stored_persistent_info");
37
+ const get_drm_system_id_1 = require("./utils/get_drm_system_id");
38
+ const init_data_values_container_1 = require("./utils/init_data_values_container");
39
+ const key_id_comparison_1 = require("./utils/key_id_comparison");
109
40
  /**
110
41
  * Module communicating with the Content Decryption Module (or CDM) to be able
111
42
  * to decrypt contents.
@@ -118,8 +49,16 @@ var onEncrypted = events.onEncrypted;
118
49
  *
119
50
  * @class ContentDecryptor
120
51
  */
121
- var ContentDecryptor = /** @class */ (function (_super) {
122
- __extends(ContentDecryptor, _super);
52
+ class ContentDecryptor extends event_emitter_1.default {
53
+ /**
54
+ * `true` if the EME API are available on the current platform according to
55
+ * the default EME implementation used.
56
+ * `false` otherwise.
57
+ * @returns {boolean}
58
+ */
59
+ static hasEmeApis() {
60
+ return !(0, is_null_or_undefined_1.default)(eme_1.default.requestMediaKeySystemAccess);
61
+ }
123
62
  /**
124
63
  * Create a new `ContentDecryptor`, and initialize its decryption capabilities
125
64
  * right away.
@@ -134,29 +73,28 @@ var ContentDecryptor = /** @class */ (function (_super) {
134
73
  * configurations. It will choose the appropriate one depending on user
135
74
  * settings and browser support.
136
75
  */
137
- function ContentDecryptor(mediaElement, ksOptions) {
138
- var _this = _super.call(this) || this;
139
- log.debug("DRM: Starting ContentDecryptor logic.");
140
- var canceller = new TaskCanceller();
141
- _this._currentSessions = [];
142
- _this._canceller = canceller;
143
- _this._wasAttachCalled = false;
144
- _this._initDataQueue = [];
145
- _this._stateData = { state: ContentDecryptorState.Initializing,
146
- isMediaKeysAttached: false,
76
+ constructor(mediaElement, ksOptions) {
77
+ super();
78
+ log_1.default.debug("DRM: Starting ContentDecryptor logic.");
79
+ const canceller = new task_canceller_1.default();
80
+ this._currentSessions = [];
81
+ this._canceller = canceller;
82
+ this._initDataQueue = [];
83
+ this._stateData = { state: types_1.ContentDecryptorState.Initializing,
84
+ isMediaKeysAttached: 0 /* MediaKeyAttachmentStatus.NotAttached */,
147
85
  isInitDataQueueLocked: true,
148
86
  data: null };
149
- _this.error = null;
150
- onEncrypted(mediaElement, function (evt) {
151
- log.debug("DRM: Encrypted event received from media element.");
152
- var initData = getInitData(evt);
87
+ this.error = null;
88
+ eme_1.default.onEncrypted(mediaElement, evt => {
89
+ log_1.default.debug("DRM: Encrypted event received from media element.");
90
+ const initData = (0, eme_1.getInitData)(evt);
153
91
  if (initData !== null) {
154
- _this.onInitializationData(initData);
92
+ this.onInitializationData(initData);
155
93
  }
156
94
  }, canceller.signal);
157
- initMediaKeys(mediaElement, ksOptions, canceller.signal)
158
- .then(function (mediaKeysInfo) {
159
- var options = mediaKeysInfo.options, mediaKeySystemAccess = mediaKeysInfo.mediaKeySystemAccess;
95
+ (0, init_media_keys_1.default)(mediaElement, ksOptions, canceller.signal)
96
+ .then((mediaKeysInfo) => {
97
+ const { options, mediaKeySystemAccess } = mediaKeysInfo;
160
98
  /**
161
99
  * String identifying the key system, allowing the rest of the code to
162
100
  * only advertise the required initialization data for license requests.
@@ -166,33 +104,33 @@ var ContentDecryptor = /** @class */ (function (_super) {
166
104
  * optimizations this property unlocks can break the loading of
167
105
  * MediaKeySessions persisted in older RxPlayer's versions.
168
106
  */
169
- var systemId;
170
- if (isNullOrUndefined(options.persistentLicenseConfig) ||
107
+ let systemId;
108
+ if ((0, is_null_or_undefined_1.default)(options.persistentLicenseConfig) ||
171
109
  options.persistentLicenseConfig.disableRetroCompatibility === true) {
172
- systemId = getDrmSystemId(mediaKeySystemAccess.keySystem);
110
+ systemId = (0, get_drm_system_id_1.default)(mediaKeySystemAccess.keySystem);
173
111
  }
174
- _this.systemId = systemId;
175
- if (_this._stateData.state === ContentDecryptorState.Initializing) {
176
- _this._stateData = { state: ContentDecryptorState.WaitingForAttachment,
112
+ this.systemId = systemId;
113
+ if (this._stateData.state === types_1.ContentDecryptorState.Initializing) {
114
+ this._stateData = { state: types_1.ContentDecryptorState.WaitingForAttachment,
177
115
  isInitDataQueueLocked: true,
178
- isMediaKeysAttached: false,
179
- data: { mediaKeysInfo: mediaKeysInfo, mediaElement: mediaElement } };
180
- _this.trigger("stateChange", _this._stateData.state);
116
+ isMediaKeysAttached: 0 /* MediaKeyAttachmentStatus.NotAttached */,
117
+ data: { mediaKeysInfo,
118
+ mediaElement } };
119
+ this.trigger("stateChange", this._stateData.state);
181
120
  }
182
121
  })
183
- .catch(function (err) {
184
- _this._onFatalError(err);
122
+ .catch((err) => {
123
+ this._onFatalError(err);
185
124
  });
186
- return _this;
187
125
  }
188
126
  /**
189
127
  * Returns the current state of the ContentDecryptor.
190
128
  * @see ContentDecryptorState
191
129
  * @returns {Object}
192
130
  */
193
- ContentDecryptor.prototype.getState = function () {
131
+ getState() {
194
132
  return this._stateData.state;
195
- };
133
+ }
196
134
  /**
197
135
  * Attach the current decryption capabilities to the HTMLMediaElement.
198
136
  * This method should only be called once the `ContentDecryptor` is in the
@@ -202,70 +140,65 @@ var ContentDecryptor = /** @class */ (function (_super) {
202
140
  * calling this method, and only push data to it once the `ReadyForContent`
203
141
  * state is reached, for compatibility reasons.
204
142
  */
205
- ContentDecryptor.prototype.attach = function () {
206
- var _this = this;
207
- if (this._stateData.state !== ContentDecryptorState.WaitingForAttachment) {
143
+ attach() {
144
+ if (this._stateData.state !== types_1.ContentDecryptorState.WaitingForAttachment) {
208
145
  throw new Error("`attach` should only be called when " +
209
146
  "in the WaitingForAttachment state");
210
147
  }
211
- else if (this._wasAttachCalled) {
212
- log.warn("DRM: ContentDecryptor's `attach` method called more than once.");
148
+ else if (this._stateData.isMediaKeysAttached !== 0 /* MediaKeyAttachmentStatus.NotAttached */) {
149
+ log_1.default.warn("DRM: ContentDecryptor's `attach` method called more than once.");
213
150
  return;
214
151
  }
215
- this._wasAttachCalled = true;
216
- var _a = this._stateData.data, mediaElement = _a.mediaElement, mediaKeysInfo = _a.mediaKeysInfo;
217
- var options = mediaKeysInfo.options, mediaKeys = mediaKeysInfo.mediaKeys, mediaKeySystemAccess = mediaKeysInfo.mediaKeySystemAccess, stores = mediaKeysInfo.stores;
218
- var stateToAttatch = { loadedSessionsStore: stores.loadedSessionsStore, mediaKeySystemAccess: mediaKeySystemAccess, mediaKeys: mediaKeys, keySystemOptions: options };
219
- var shouldDisableLock = options.disableMediaKeysAttachmentLock === true;
152
+ const { mediaElement, mediaKeysInfo } = this._stateData.data;
153
+ const { options, mediaKeys, mediaKeySystemAccess, stores } = mediaKeysInfo;
154
+ const shouldDisableLock = options.disableMediaKeysAttachmentLock === true;
220
155
  if (shouldDisableLock) {
221
- this._stateData = { state: ContentDecryptorState.ReadyForContent,
156
+ this._stateData = { state: types_1.ContentDecryptorState.ReadyForContent,
222
157
  isInitDataQueueLocked: true,
223
- isMediaKeysAttached: false,
224
- data: null };
158
+ isMediaKeysAttached: 1 /* MediaKeyAttachmentStatus.Pending */,
159
+ data: { mediaKeysInfo, mediaElement } };
225
160
  this.trigger("stateChange", this._stateData.state);
226
- if (this._isStopped()) { // previous trigger might have lead to disposal
161
+ // previous trigger might have lead to disposal
162
+ if (this._isStopped()) {
227
163
  return;
228
164
  }
229
165
  }
230
- log.debug("DRM: Attaching current MediaKeys");
231
- attachMediaKeys(mediaElement, stateToAttatch, this._canceller.signal)
232
- .then(function () { return __awaiter(_this, void 0, void 0, function () {
233
- var serverCertificate, resSsc, prevState;
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0:
237
- serverCertificate = options.serverCertificate;
238
- if (!!isNullOrUndefined(serverCertificate)) return [3 /*break*/, 2];
239
- return [4 /*yield*/, setServerCertificate(mediaKeys, serverCertificate)];
240
- case 1:
241
- resSsc = _a.sent();
242
- if (resSsc.type === "error") {
243
- this.trigger("warning", resSsc.value);
244
- }
245
- _a.label = 2;
246
- case 2:
247
- if (this._isStopped()) { // We might be stopped since then
248
- return [2 /*return*/];
249
- }
250
- prevState = this._stateData.state;
251
- this._stateData = { state: ContentDecryptorState.ReadyForContent,
252
- isMediaKeysAttached: true,
253
- isInitDataQueueLocked: false,
254
- data: { mediaKeysData: mediaKeysInfo } };
255
- if (prevState !== ContentDecryptorState.ReadyForContent) {
256
- this.trigger("stateChange", ContentDecryptorState.ReadyForContent);
257
- }
258
- if (!this._isStopped()) {
259
- this._processCurrentInitDataQueue();
260
- }
261
- return [2 /*return*/];
166
+ this._stateData.isMediaKeysAttached = 1 /* MediaKeyAttachmentStatus.Pending */;
167
+ const stateToAttach = { emeImplementation: eme_1.default,
168
+ loadedSessionsStore: stores.loadedSessionsStore,
169
+ mediaKeySystemAccess,
170
+ mediaKeys,
171
+ keySystemOptions: options };
172
+ log_1.default.debug("DRM: Attaching current MediaKeys");
173
+ (0, attach_media_keys_1.default)(mediaElement, stateToAttach, this._canceller.signal)
174
+ .then(async () => {
175
+ this._stateData.isMediaKeysAttached = 2 /* MediaKeyAttachmentStatus.Attached */;
176
+ const { serverCertificate } = options;
177
+ if (!(0, is_null_or_undefined_1.default)(serverCertificate)) {
178
+ const resSsc = await (0, set_server_certificate_1.default)(mediaKeys, serverCertificate);
179
+ if (resSsc.type === "error") {
180
+ this.trigger("warning", resSsc.value);
262
181
  }
263
- });
264
- }); })
265
- .catch(function (err) {
266
- _this._onFatalError(err);
182
+ }
183
+ if (this._isStopped()) { // We might be stopped since then
184
+ return;
185
+ }
186
+ const prevState = this._stateData.state;
187
+ this._stateData = { state: types_1.ContentDecryptorState.ReadyForContent,
188
+ isMediaKeysAttached: 2 /* MediaKeyAttachmentStatus.Attached */,
189
+ isInitDataQueueLocked: false,
190
+ data: { mediaKeysData: mediaKeysInfo } };
191
+ if (prevState !== types_1.ContentDecryptorState.ReadyForContent) {
192
+ this.trigger("stateChange", types_1.ContentDecryptorState.ReadyForContent);
193
+ }
194
+ if (!this._isStopped()) {
195
+ this._processCurrentInitDataQueue();
196
+ }
197
+ })
198
+ .catch((err) => {
199
+ this._onFatalError(err);
267
200
  });
268
- };
201
+ }
269
202
  /**
270
203
  * Stop this `ContentDecryptor` instance:
271
204
  * - stop listening and reacting to the various event listeners
@@ -273,15 +206,15 @@ var ContentDecryptor = /** @class */ (function (_super) {
273
206
  *
274
207
  * Once disposed, a `ContentDecryptor` cannot be used anymore.
275
208
  */
276
- ContentDecryptor.prototype.dispose = function () {
209
+ dispose() {
277
210
  this.removeEventListener();
278
- this._stateData = { state: ContentDecryptorState.Disposed,
211
+ this._stateData = { state: types_1.ContentDecryptorState.Disposed,
279
212
  isMediaKeysAttached: undefined,
280
213
  isInitDataQueueLocked: undefined,
281
214
  data: null };
282
215
  this._canceller.cancel();
283
216
  this.trigger("stateChange", this._stateData.state);
284
- };
217
+ }
285
218
  /**
286
219
  * Method to call when new protection initialization data is encounted on the
287
220
  * content.
@@ -291,8 +224,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
291
224
  *
292
225
  * @param {Object} initializationData
293
226
  */
294
- ContentDecryptor.prototype.onInitializationData = function (initializationData) {
295
- var _this = this;
227
+ onInitializationData(initializationData) {
296
228
  if (this._stateData.isInitDataQueueLocked !== false) {
297
229
  if (this._isStopped()) {
298
230
  throw new Error("ContentDecryptor either disposed or stopped.");
@@ -300,11 +232,11 @@ var ContentDecryptor = /** @class */ (function (_super) {
300
232
  this._initDataQueue.push(initializationData);
301
233
  return;
302
234
  }
303
- var mediaKeysData = this._stateData.data.mediaKeysData;
304
- var processedInitializationData = __assign(__assign({}, initializationData), { values: new InitDataValuesContainer(initializationData.values) });
235
+ const { mediaKeysData } = this._stateData.data;
236
+ const processedInitializationData = Object.assign(Object.assign({}, initializationData), { values: new init_data_values_container_1.default(initializationData.values) });
305
237
  this._processInitializationData(processedInitializationData, mediaKeysData)
306
- .catch(function (err) { _this._onFatalError(err); });
307
- };
238
+ .catch(err => { this._onFatalError(err); });
239
+ }
308
240
  /**
309
241
  * Async logic run each time new initialization data has to be processed.
310
242
  * The promise return may reject, in which case a fatal error should be linked
@@ -314,228 +246,223 @@ var ContentDecryptor = /** @class */ (function (_super) {
314
246
  * @param {Object} initializationData
315
247
  * @returns {Promise.<void>}
316
248
  */
317
- ContentDecryptor.prototype._processInitializationData = function (initializationData, mediaKeysData) {
318
- return __awaiter(this, void 0, void 0, function () {
319
- var mediaKeySystemAccess, stores, options, firstCreatedSession, keyIds, hexKids, period, createdSessions, periodKeys, _i, createdSessions_1, createdSess, periodKeysArr, _a, periodKeysArr_1, kid, _b, periodKeysArr_2, innerKid, wantedSessionType, _c, EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION, maxSessionCacheSize, sessionRes, sessionInfo, _d, mediaKeySession, sessionType, isSessionPersisted, requestData, error_1, entry, indexInCurrent;
320
- var _this = this;
321
- return __generator(this, function (_e) {
322
- switch (_e.label) {
323
- case 0:
324
- mediaKeySystemAccess = mediaKeysData.mediaKeySystemAccess, stores = mediaKeysData.stores, options = mediaKeysData.options;
325
- if (this._tryToUseAlreadyCreatedSession(initializationData, mediaKeysData) ||
326
- this._isStopped()) // _isStopped is voluntarly checked after here
327
- {
328
- return [2 /*return*/];
329
- }
330
- if (options.singleLicensePer === "content") {
331
- firstCreatedSession = arrayFind(this._currentSessions, function (x) {
332
- return x.source === "created-session" /* MediaKeySessionLoadingType.Created */;
333
- });
334
- if (firstCreatedSession !== undefined) {
335
- keyIds = initializationData.keyIds;
336
- if (keyIds === undefined) {
337
- if (initializationData.content === undefined) {
338
- log.warn("DRM: Unable to fallback from a non-decipherable quality.");
339
- }
340
- else {
341
- blackListProtectionData(initializationData.content.manifest, initializationData);
342
- }
343
- return [2 /*return*/];
344
- }
345
- firstCreatedSession.record.associateKeyIds(keyIds);
346
- if (initializationData.content !== undefined) {
347
- if (log.hasLevel("DEBUG")) {
348
- hexKids = keyIds
349
- .reduce(function (acc, kid) { return "".concat(acc, ", ").concat(bytesToHex(kid)); }, "");
350
- log.debug("DRM: Blacklisting new key ids", hexKids);
351
- }
352
- updateDecipherability(initializationData.content.manifest, [], keyIds, []);
353
- }
354
- return [2 /*return*/];
355
- }
356
- }
357
- else if (options.singleLicensePer === "periods" &&
358
- initializationData.content !== undefined) {
359
- period = initializationData.content.period;
360
- createdSessions = this._currentSessions
361
- .filter(function (x) { return x.source === "created-session" /* MediaKeySessionLoadingType.Created */; });
362
- periodKeys = new Set();
363
- addKeyIdsFromPeriod(periodKeys, period);
364
- for (_i = 0, createdSessions_1 = createdSessions; _i < createdSessions_1.length; _i++) {
365
- createdSess = createdSessions_1[_i];
366
- periodKeysArr = Array.from(periodKeys);
367
- for (_a = 0, periodKeysArr_1 = periodKeysArr; _a < periodKeysArr_1.length; _a++) {
368
- kid = periodKeysArr_1[_a];
369
- if (createdSess.record.isAssociatedWithKeyId(kid)) {
370
- createdSess.record.associateKeyIds(periodKeys.values());
371
- // Re-loop through the Period's key ids to blacklist ones that are missing
372
- // from `createdSess`'s `keyStatuses` and to update the content's
373
- // decipherability.
374
- for (_b = 0, periodKeysArr_2 = periodKeysArr; _b < periodKeysArr_2.length; _b++) {
375
- innerKid = periodKeysArr_2[_b];
376
- if (!isKeyIdContainedIn(innerKid, createdSess.keyStatuses.whitelisted) &&
377
- !isKeyIdContainedIn(innerKid, createdSess.keyStatuses.blacklisted)) {
378
- createdSess.keyStatuses.blacklisted.push(innerKid);
379
- }
380
- }
381
- updateDecipherability(initializationData.content.manifest, createdSess.keyStatuses.whitelisted, createdSess.keyStatuses.blacklisted, []);
382
- return [2 /*return*/];
383
- }
384
- }
385
- }
386
- }
387
- // /!\ Do not forget to unlock when done
388
- // TODO this is error-prone and can lead to performance issue when loading
389
- // persistent sessions.
390
- // Can we find a better strategy?
391
- this._lockInitDataQueue();
392
- if (isNullOrUndefined(options.persistentLicenseConfig)) {
393
- wantedSessionType = "temporary";
394
- }
395
- else if (!canCreatePersistentSession(mediaKeySystemAccess)) {
396
- log.warn("DRM: Cannot create \"persistent-license\" session: not supported");
397
- wantedSessionType = "temporary";
398
- }
399
- else {
400
- wantedSessionType = "persistent-license";
401
- }
402
- _c = config.getCurrent(), EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS = _c.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION = _c.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION;
403
- maxSessionCacheSize = typeof options.maxSessionCacheSize === "number" ?
404
- options.maxSessionCacheSize :
405
- EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS;
406
- return [4 /*yield*/, createOrLoadSession(initializationData, stores, wantedSessionType, maxSessionCacheSize, this._canceller.signal)];
407
- case 1:
408
- sessionRes = _e.sent();
409
- if (this._isStopped()) {
410
- return [2 /*return*/];
411
- }
412
- sessionInfo = {
413
- record: sessionRes.value.keySessionRecord,
414
- source: sessionRes.type,
415
- keyStatuses: { whitelisted: [], blacklisted: [] },
416
- blacklistedSessionError: null,
417
- };
418
- this._currentSessions.push(sessionInfo);
419
- _d = sessionRes.value, mediaKeySession = _d.mediaKeySession, sessionType = _d.sessionType;
420
- isSessionPersisted = false;
421
- SessionEventsListener(mediaKeySession, options, mediaKeySystemAccess.keySystem, {
422
- onKeyUpdate: function (value) {
423
- var linkedKeys = getKeyIdsLinkedToSession(initializationData, sessionInfo.record, options.singleLicensePer, sessionInfo.source === "created-session" /* MediaKeySessionLoadingType.Created */, value.whitelistedKeyIds, value.blacklistedKeyIds);
424
- sessionInfo.record.associateKeyIds(linkedKeys.whitelisted);
425
- sessionInfo.record.associateKeyIds(linkedKeys.blacklisted);
426
- sessionInfo.keyStatuses = { whitelisted: linkedKeys.whitelisted,
427
- blacklisted: linkedKeys.blacklisted };
428
- if (sessionInfo.record.getAssociatedKeyIds().length !== 0 &&
429
- sessionType === "persistent-license" &&
430
- stores.persistentSessionsStore !== null &&
431
- !isSessionPersisted) {
432
- var persistentSessionsStore = stores.persistentSessionsStore;
433
- cleanOldStoredPersistentInfo(persistentSessionsStore, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION - 1);
434
- persistentSessionsStore.add(initializationData, sessionInfo.record.getAssociatedKeyIds(), mediaKeySession);
435
- isSessionPersisted = true;
436
- }
437
- if (initializationData.content !== undefined) {
438
- updateDecipherability(initializationData.content.manifest, linkedKeys.whitelisted, linkedKeys.blacklisted, []);
439
- }
440
- _this._unlockInitDataQueue();
441
- },
442
- onWarning: function (value) {
443
- _this.trigger("warning", value);
444
- },
445
- onError: function (err) {
446
- var _a;
447
- if (err instanceof DecommissionedSessionError) {
448
- log.warn("DRM: A session's closing condition has been triggered");
449
- _this._lockInitDataQueue();
450
- var indexOf = _this._currentSessions.indexOf(sessionInfo);
451
- if (indexOf >= 0) {
452
- _this._currentSessions.splice(indexOf);
453
- }
454
- if (initializationData.content !== undefined) {
455
- updateDecipherability(initializationData.content.manifest, [], [], sessionInfo.record.getAssociatedKeyIds());
456
- }
457
- (_a = stores.persistentSessionsStore) === null || _a === void 0 ? void 0 : _a.delete(mediaKeySession.sessionId);
458
- stores.loadedSessionsStore.closeSession(mediaKeySession)
459
- .catch(function (e) {
460
- var closeError = e instanceof Error ? e :
461
- "unknown error";
462
- log.warn("DRM: failed to close expired session", closeError);
463
- })
464
- .then(function () { return _this._unlockInitDataQueue(); })
465
- .catch(function (retryError) { return _this._onFatalError(retryError); });
466
- if (!_this._isStopped()) {
467
- _this.trigger("warning", err.reason);
468
- }
469
- return;
470
- }
471
- if (!(err instanceof BlacklistedSessionError)) {
472
- _this._onFatalError(err);
473
- return;
474
- }
475
- sessionInfo.blacklistedSessionError = err;
476
- if (initializationData.content !== undefined) {
477
- var manifest = initializationData.content.manifest;
478
- log.info("DRM: blacklisting Representations based on " +
479
- "protection data.");
480
- blackListProtectionData(manifest, initializationData);
481
- }
482
- _this._unlockInitDataQueue();
483
- // TODO warning for blacklisted session?
484
- },
485
- }, this._canceller.signal);
486
- if (options.singleLicensePer === undefined ||
487
- options.singleLicensePer === "init-data") {
488
- this._unlockInitDataQueue();
489
- }
490
- if (!(sessionRes.type === "created-session" /* MediaKeySessionLoadingType.Created */)) return [3 /*break*/, 5];
491
- requestData = initializationData.values.constructRequestData();
492
- _e.label = 2;
493
- case 2:
494
- _e.trys.push([2, 4, , 5]);
495
- return [4 /*yield*/, stores.loadedSessionsStore.generateLicenseRequest(mediaKeySession, initializationData.type, requestData)];
496
- case 3:
497
- _e.sent();
498
- return [3 /*break*/, 5];
499
- case 4:
500
- error_1 = _e.sent();
501
- entry = stores.loadedSessionsStore.getEntryForSession(mediaKeySession);
502
- if (entry === null || entry.closingStatus.type !== "none") {
503
- indexInCurrent = this._currentSessions.indexOf(sessionInfo);
504
- if (indexInCurrent >= 0) {
505
- this._currentSessions.splice(indexInCurrent, 1);
249
+ async _processInitializationData(initializationData, mediaKeysData) {
250
+ const { mediaKeySystemAccess, stores, options } = mediaKeysData;
251
+ if (this._tryToUseAlreadyCreatedSession(initializationData, mediaKeysData) ||
252
+ this._isStopped()) // _isStopped is voluntarly checked after here
253
+ {
254
+ return;
255
+ }
256
+ if (options.singleLicensePer === "content") {
257
+ const firstCreatedSession = (0, array_find_1.default)(this._currentSessions, (x) => x.source === "created-session" /* MediaKeySessionLoadingType.Created */);
258
+ if (firstCreatedSession !== undefined) {
259
+ // We already fetched a `singleLicensePer: "content"` license, yet we
260
+ // could not use the already-created MediaKeySession with it.
261
+ // It means that we'll never handle it and we should thus blacklist it.
262
+ const keyIds = initializationData.keyIds;
263
+ if (keyIds === undefined) {
264
+ if (initializationData.content === undefined) {
265
+ log_1.default.warn("DRM: Unable to fallback from a non-decipherable quality.");
266
+ }
267
+ else {
268
+ blackListProtectionData(initializationData.content.manifest, initializationData);
269
+ }
270
+ return;
271
+ }
272
+ firstCreatedSession.record.associateKeyIds(keyIds);
273
+ if (initializationData.content !== undefined) {
274
+ if (log_1.default.hasLevel("DEBUG")) {
275
+ const hexKids = keyIds
276
+ .reduce((acc, kid) => `${acc}, ${(0, string_parsing_1.bytesToHex)(kid)}`, "");
277
+ log_1.default.debug("DRM: Blacklisting new key ids", hexKids);
278
+ }
279
+ updateDecipherability(initializationData.content.manifest, [], keyIds, []);
280
+ }
281
+ return;
282
+ }
283
+ }
284
+ else if (options.singleLicensePer === "periods" &&
285
+ initializationData.content !== undefined) {
286
+ const { period } = initializationData.content;
287
+ const createdSessions = this._currentSessions
288
+ .filter(x => x.source === "created-session" /* MediaKeySessionLoadingType.Created */);
289
+ const periodKeys = new Set();
290
+ addKeyIdsFromPeriod(periodKeys, period);
291
+ for (const createdSess of createdSessions) {
292
+ const periodKeysArr = Array.from(periodKeys);
293
+ for (const kid of periodKeysArr) {
294
+ if (createdSess.record.isAssociatedWithKeyId(kid)) {
295
+ createdSess.record.associateKeyIds(periodKeys.values());
296
+ // Re-loop through the Period's key ids to blacklist ones that are missing
297
+ // from `createdSess`'s `keyStatuses` and to update the content's
298
+ // decipherability.
299
+ for (const innerKid of periodKeysArr) {
300
+ if (!createdSess.keyStatuses.whitelisted
301
+ .some(k => (0, are_arrays_of_numbers_equal_1.default)(k, innerKid)) &&
302
+ !createdSess.keyStatuses.blacklisted
303
+ .some(k => (0, are_arrays_of_numbers_equal_1.default)(k, innerKid))) {
304
+ createdSess.keyStatuses.blacklisted.push(innerKid);
506
305
  }
507
- return [2 /*return*/, Promise.resolve()];
508
306
  }
509
- throw new EncryptedMediaError("KEY_GENERATE_REQUEST_ERROR", error_1 instanceof Error ? error_1.toString() :
510
- "Unknown error");
511
- case 5: return [2 /*return*/, Promise.resolve()];
307
+ updateDecipherability(initializationData.content.manifest, createdSess.keyStatuses.whitelisted, createdSess.keyStatuses.blacklisted, []);
308
+ return;
309
+ }
512
310
  }
513
- });
514
- });
515
- };
516
- ContentDecryptor.prototype._tryToUseAlreadyCreatedSession = function (initializationData, mediaKeysData) {
517
- var stores = mediaKeysData.stores, options = mediaKeysData.options;
311
+ }
312
+ }
313
+ // /!\ Do not forget to unlock when done
314
+ // TODO this is error-prone and can lead to performance issue when loading
315
+ // persistent sessions.
316
+ // Can we find a better strategy?
317
+ this._lockInitDataQueue();
318
+ let wantedSessionType;
319
+ if ((0, is_null_or_undefined_1.default)(options.persistentLicenseConfig)) {
320
+ wantedSessionType = "temporary";
321
+ }
322
+ else if (!canCreatePersistentSession(mediaKeySystemAccess)) {
323
+ log_1.default.warn("DRM: Cannot create \"persistent-license\" session: not supported");
324
+ wantedSessionType = "temporary";
325
+ }
326
+ else {
327
+ wantedSessionType = "persistent-license";
328
+ }
329
+ const { EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION } = config_1.default.getCurrent();
330
+ const maxSessionCacheSize = typeof options.maxSessionCacheSize === "number" ?
331
+ options.maxSessionCacheSize :
332
+ EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS;
333
+ const sessionRes = await (0, create_or_load_session_1.default)(initializationData, stores, wantedSessionType, maxSessionCacheSize, this._canceller.signal);
334
+ if (this._isStopped()) {
335
+ return;
336
+ }
337
+ const sessionInfo = {
338
+ record: sessionRes.value.keySessionRecord,
339
+ source: sessionRes.type,
340
+ keyStatuses: { whitelisted: [], blacklisted: [] },
341
+ blacklistedSessionError: null,
342
+ };
343
+ this._currentSessions.push(sessionInfo);
344
+ const { mediaKeySession, sessionType } = sessionRes.value;
345
+ /**
346
+ * We only store persistent sessions once its keys are known.
347
+ * This boolean allows to know if this session has already been
348
+ * persisted or not.
349
+ */
350
+ let isSessionPersisted = false;
351
+ (0, session_events_listener_1.default)(mediaKeySession, options, mediaKeySystemAccess.keySystem, {
352
+ onKeyUpdate: (value) => {
353
+ const linkedKeys = getKeyIdsLinkedToSession(initializationData, sessionInfo.record, options.singleLicensePer, sessionInfo.source === "created-session" /* MediaKeySessionLoadingType.Created */, value.whitelistedKeyIds, value.blacklistedKeyIds);
354
+ sessionInfo.record.associateKeyIds(linkedKeys.whitelisted);
355
+ sessionInfo.record.associateKeyIds(linkedKeys.blacklisted);
356
+ sessionInfo.keyStatuses = { whitelisted: linkedKeys.whitelisted,
357
+ blacklisted: linkedKeys.blacklisted };
358
+ if (sessionInfo.record.getAssociatedKeyIds().length !== 0 &&
359
+ sessionType === "persistent-license" &&
360
+ stores.persistentSessionsStore !== null &&
361
+ !isSessionPersisted) {
362
+ const { persistentSessionsStore } = stores;
363
+ (0, clean_old_stored_persistent_info_1.default)(persistentSessionsStore, EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION - 1);
364
+ persistentSessionsStore.add(initializationData, sessionInfo.record.getAssociatedKeyIds(), mediaKeySession);
365
+ isSessionPersisted = true;
366
+ }
367
+ if (initializationData.content !== undefined) {
368
+ updateDecipherability(initializationData.content.manifest, linkedKeys.whitelisted, linkedKeys.blacklisted, []);
369
+ }
370
+ this._unlockInitDataQueue();
371
+ },
372
+ onWarning: (value) => {
373
+ this.trigger("warning", value);
374
+ },
375
+ onError: (err) => {
376
+ var _a;
377
+ if (err instanceof check_key_statuses_1.DecommissionedSessionError) {
378
+ log_1.default.warn("DRM: A session's closing condition has been triggered");
379
+ this._lockInitDataQueue();
380
+ const indexOf = this._currentSessions.indexOf(sessionInfo);
381
+ if (indexOf >= 0) {
382
+ this._currentSessions.splice(indexOf);
383
+ }
384
+ if (initializationData.content !== undefined) {
385
+ updateDecipherability(initializationData.content.manifest, [], [], sessionInfo.record.getAssociatedKeyIds());
386
+ }
387
+ (_a = stores.persistentSessionsStore) === null || _a === void 0 ? void 0 : _a.delete(mediaKeySession.sessionId);
388
+ stores.loadedSessionsStore.closeSession(mediaKeySession)
389
+ .catch(e => {
390
+ const closeError = e instanceof Error ? e :
391
+ "unknown error";
392
+ log_1.default.warn("DRM: failed to close expired session", closeError);
393
+ })
394
+ .then(() => this._unlockInitDataQueue())
395
+ .catch((retryError) => this._onFatalError(retryError));
396
+ if (!this._isStopped()) {
397
+ this.trigger("warning", err.reason);
398
+ }
399
+ return;
400
+ }
401
+ if (!(err instanceof session_events_listener_1.BlacklistedSessionError)) {
402
+ this._onFatalError(err);
403
+ return;
404
+ }
405
+ sessionInfo.blacklistedSessionError = err;
406
+ if (initializationData.content !== undefined) {
407
+ const { manifest } = initializationData.content;
408
+ log_1.default.info("DRM: blacklisting Representations based on " +
409
+ "protection data.");
410
+ blackListProtectionData(manifest, initializationData);
411
+ }
412
+ this._unlockInitDataQueue();
413
+ // TODO warning for blacklisted session?
414
+ },
415
+ }, this._canceller.signal);
416
+ if (options.singleLicensePer === undefined ||
417
+ options.singleLicensePer === "init-data") {
418
+ this._unlockInitDataQueue();
419
+ }
420
+ if (sessionRes.type === "created-session" /* MediaKeySessionLoadingType.Created */) {
421
+ const requestData = initializationData.values.constructRequestData();
422
+ try {
423
+ await stores.loadedSessionsStore.generateLicenseRequest(mediaKeySession, initializationData.type, requestData);
424
+ }
425
+ catch (error) {
426
+ // First check that the error was not due to the MediaKeySession closing
427
+ // or being closed
428
+ const entry = stores.loadedSessionsStore.getEntryForSession(mediaKeySession);
429
+ if (entry === null || entry.closingStatus.type !== "none") {
430
+ // MediaKeySession closing/closed: Just remove from handled list and abort.
431
+ const indexInCurrent = this._currentSessions.indexOf(sessionInfo);
432
+ if (indexInCurrent >= 0) {
433
+ this._currentSessions.splice(indexInCurrent, 1);
434
+ }
435
+ return Promise.resolve();
436
+ }
437
+ throw new errors_1.EncryptedMediaError("KEY_GENERATE_REQUEST_ERROR", error instanceof Error ? error.toString() :
438
+ "Unknown error");
439
+ }
440
+ }
441
+ return Promise.resolve();
442
+ }
443
+ _tryToUseAlreadyCreatedSession(initializationData, mediaKeysData) {
444
+ const { stores, options } = mediaKeysData;
518
445
  /**
519
446
  * If set, a currently-used key session is already compatible to this
520
447
  * initialization data.
521
448
  */
522
- var compatibleSessionInfo = arrayFind(this._currentSessions, function (x) { return x.record.isCompatibleWith(initializationData); });
449
+ const compatibleSessionInfo = (0, array_find_1.default)(this._currentSessions, (x) => x.record.isCompatibleWith(initializationData));
523
450
  if (compatibleSessionInfo === undefined) {
524
451
  return false;
525
452
  }
526
453
  // Check if the compatible session is blacklisted
527
- var blacklistedSessionError = compatibleSessionInfo.blacklistedSessionError;
528
- if (!isNullOrUndefined(blacklistedSessionError)) {
454
+ const blacklistedSessionError = compatibleSessionInfo.blacklistedSessionError;
455
+ if (!(0, is_null_or_undefined_1.default)(blacklistedSessionError)) {
529
456
  if (initializationData.type === undefined ||
530
457
  initializationData.content === undefined) {
531
- log.error("DRM: This initialization data has already been blacklisted " +
458
+ log_1.default.error("DRM: This initialization data has already been blacklisted " +
532
459
  "but the current content is not known.");
533
460
  return true;
534
461
  }
535
462
  else {
536
- log.info("DRM: This initialization data has already been blacklisted. " +
463
+ log_1.default.info("DRM: This initialization data has already been blacklisted. " +
537
464
  "Blacklisting the related content.");
538
- var manifest = initializationData.content.manifest;
465
+ const { manifest } = initializationData.content;
539
466
  blackListProtectionData(manifest, initializationData);
540
467
  return true;
541
468
  }
@@ -546,7 +473,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
546
473
  * If set to `true`, the Representation(s) linked to this
547
474
  * initialization data's key id should be marked as "not decipherable".
548
475
  */
549
- var isUndecipherable = void 0;
476
+ let isUndecipherable;
550
477
  if (options.singleLicensePer === undefined ||
551
478
  options.singleLicensePer === "init-data") {
552
479
  // Note: In the default "init-data" mode, we only avoid a
@@ -557,8 +484,8 @@ var ContentDecryptor = /** @class */ (function (_super) {
557
484
  // This is to enforce v3.x.x retro-compatibility: we cannot
558
485
  // fallback from a Representation unless some RxPlayer option
559
486
  // documentating this behavior has been set.
560
- var blacklisted = compatibleSessionInfo.keyStatuses.blacklisted;
561
- isUndecipherable = areSomeKeyIdsContainedIn(initializationData.keyIds, blacklisted);
487
+ const { blacklisted } = compatibleSessionInfo.keyStatuses;
488
+ isUndecipherable = (0, key_id_comparison_1.areSomeKeyIdsContainedIn)(initializationData.keyIds, blacklisted);
562
489
  }
563
490
  else {
564
491
  // In any other mode, as soon as not all of this initialization
@@ -566,15 +493,15 @@ var ContentDecryptor = /** @class */ (function (_super) {
566
493
  // the corresponding Representation as "not decipherable".
567
494
  // This is because we've no such retro-compatibility guarantee to
568
495
  // make there.
569
- var whitelisted = compatibleSessionInfo.keyStatuses.whitelisted;
570
- isUndecipherable = !areAllKeyIdsContainedIn(initializationData.keyIds, whitelisted);
496
+ const { whitelisted } = compatibleSessionInfo.keyStatuses;
497
+ isUndecipherable = !(0, key_id_comparison_1.areAllKeyIdsContainedIn)(initializationData.keyIds, whitelisted);
571
498
  }
572
499
  if (isUndecipherable) {
573
500
  if (initializationData.content === undefined) {
574
- log.error("DRM: Cannot forbid key id, the content is unknown.");
501
+ log_1.default.error("DRM: Cannot forbid key id, the content is unknown.");
575
502
  return true;
576
503
  }
577
- log.info("DRM: Current initialization data is linked to blacklisted keys. " +
504
+ log_1.default.info("DRM: Current initialization data is linked to blacklisted keys. " +
578
505
  "Marking Representations as not decipherable");
579
506
  updateDecipherability(initializationData.content.manifest, [], initializationData.keyIds, []);
580
507
  return true;
@@ -583,26 +510,26 @@ var ContentDecryptor = /** @class */ (function (_super) {
583
510
  // If we reached here, it means that this initialization data is not
584
511
  // blacklisted in any way.
585
512
  // Search loaded session and put it on top of the cache if it exists.
586
- var entry = stores.loadedSessionsStore.reuse(initializationData);
513
+ const entry = stores.loadedSessionsStore.reuse(initializationData);
587
514
  if (entry !== null) {
588
515
  // TODO update decipherability to `true` if not?
589
- log.debug("DRM: Init data already processed. Skipping it.");
516
+ log_1.default.debug("DRM: Init data already processed. Skipping it.");
590
517
  return true;
591
518
  }
592
519
  // Session not found in `loadedSessionsStore`, it might have been closed
593
520
  // since.
594
521
  // Remove from `this._currentSessions` and start again.
595
- var indexOf = this._currentSessions.indexOf(compatibleSessionInfo);
522
+ const indexOf = this._currentSessions.indexOf(compatibleSessionInfo);
596
523
  if (indexOf === -1) {
597
- log.error("DRM: Unable to remove processed init data: not found.");
524
+ log_1.default.error("DRM: Unable to remove processed init data: not found.");
598
525
  }
599
526
  else {
600
- log.debug("DRM: A session from a processed init data is not available " +
527
+ log_1.default.debug("DRM: A session from a processed init data is not available " +
601
528
  "anymore. Re-processing it.");
602
529
  this._currentSessions.splice(indexOf, 1);
603
530
  }
604
531
  return false;
605
- };
532
+ }
606
533
  /**
607
534
  * Callback that should be called if an error that made the current
608
535
  * `ContentDecryptor` instance unusable arised.
@@ -613,48 +540,48 @@ var ContentDecryptor = /** @class */ (function (_super) {
613
540
  * @param {*} err - The error object which describes the issue. Will be
614
541
  * formatted and sent in an "error" event.
615
542
  */
616
- ContentDecryptor.prototype._onFatalError = function (err) {
543
+ _onFatalError(err) {
617
544
  if (this._canceller.isUsed()) {
618
545
  return;
619
546
  }
620
- var formattedErr = err instanceof Error ?
547
+ const formattedErr = err instanceof Error ?
621
548
  err :
622
- new OtherError("NONE", "Unknown decryption error");
549
+ new errors_1.OtherError("NONE", "Unknown decryption error");
623
550
  this.error = formattedErr;
624
551
  this._initDataQueue.length = 0;
625
- this._stateData = { state: ContentDecryptorState.Error,
552
+ this._stateData = { state: types_1.ContentDecryptorState.Error,
626
553
  isMediaKeysAttached: undefined,
627
554
  isInitDataQueueLocked: undefined,
628
555
  data: null };
629
556
  this._canceller.cancel();
630
557
  this.trigger("error", formattedErr);
631
558
  // The previous trigger might have lead to a disposal of the `ContentDecryptor`.
632
- if (this._stateData.state === ContentDecryptorState.Error) {
559
+ if (this._stateData.state === types_1.ContentDecryptorState.Error) {
633
560
  this.trigger("stateChange", this._stateData.state);
634
561
  }
635
- };
562
+ }
636
563
  /**
637
564
  * Return `true` if the `ContentDecryptor` has either been disposed or
638
565
  * encountered a fatal error which made it stop.
639
566
  * @returns {boolean}
640
567
  */
641
- ContentDecryptor.prototype._isStopped = function () {
642
- return this._stateData.state === ContentDecryptorState.Disposed ||
643
- this._stateData.state === ContentDecryptorState.Error;
644
- };
568
+ _isStopped() {
569
+ return this._stateData.state === types_1.ContentDecryptorState.Disposed ||
570
+ this._stateData.state === types_1.ContentDecryptorState.Error;
571
+ }
645
572
  /**
646
573
  * Start processing the next initialization data of the `_initDataQueue` if it
647
574
  * isn't lock.
648
575
  */
649
- ContentDecryptor.prototype._processCurrentInitDataQueue = function () {
576
+ _processCurrentInitDataQueue() {
650
577
  while (this._stateData.isInitDataQueueLocked === false) {
651
- var initData = this._initDataQueue.shift();
578
+ const initData = this._initDataQueue.shift();
652
579
  if (initData === undefined) {
653
580
  return;
654
581
  }
655
582
  this.onInitializationData(initData);
656
583
  }
657
- };
584
+ }
658
585
  /**
659
586
  * Lock new initialization data (from the `_initDataQueue`) from being
660
587
  * processed until `_unlockInitDataQueue` is called.
@@ -662,27 +589,26 @@ var ContentDecryptor = /** @class */ (function (_super) {
662
589
  * You may want to call this method when performing operations which may have
663
590
  * an impact on the handling of other initialization data.
664
591
  */
665
- ContentDecryptor.prototype._lockInitDataQueue = function () {
592
+ _lockInitDataQueue() {
666
593
  if (this._stateData.isInitDataQueueLocked === false) {
667
594
  this._stateData.isInitDataQueueLocked = true;
668
595
  }
669
- };
596
+ }
670
597
  /**
671
598
  * Unlock `_initDataQueue` and start processing the first element.
672
599
  *
673
600
  * Should have no effect if the `_initDataQueue` was not locked.
674
601
  */
675
- ContentDecryptor.prototype._unlockInitDataQueue = function () {
676
- if (this._stateData.isMediaKeysAttached !== true) {
677
- log.error("DRM: Trying to unlock in the wrong state");
602
+ _unlockInitDataQueue() {
603
+ if (this._stateData.isMediaKeysAttached !== 2 /* MediaKeyAttachmentStatus.Attached */) {
604
+ log_1.default.error("DRM: Trying to unlock in the wrong state");
678
605
  return;
679
606
  }
680
607
  this._stateData.isInitDataQueueLocked = false;
681
608
  this._processCurrentInitDataQueue();
682
- };
683
- return ContentDecryptor;
684
- }(EventEmitter));
685
- export default ContentDecryptor;
609
+ }
610
+ }
611
+ exports.default = ContentDecryptor;
686
612
  /**
687
613
  * Returns `true` if the given MediaKeySystemAccess can create
688
614
  * "persistent-license" MediaKeySessions.
@@ -690,9 +616,9 @@ export default ContentDecryptor;
690
616
  * @returns {Boolean}
691
617
  */
692
618
  function canCreatePersistentSession(mediaKeySystemAccess) {
693
- var sessionTypes = mediaKeySystemAccess.getConfiguration().sessionTypes;
619
+ const { sessionTypes } = mediaKeySystemAccess.getConfiguration();
694
620
  return sessionTypes !== undefined &&
695
- arrayIncludes(sessionTypes, "persistent-license");
621
+ (0, array_includes_1.default)(sessionTypes, "persistent-license");
696
622
  }
697
623
  /**
698
624
  * Change the decipherability of Representations which have their key id in one
@@ -713,29 +639,25 @@ function canCreatePersistentSession(mediaKeySystemAccess) {
713
639
  * @param {Array.<Uint8Array>} delistedKeyIds
714
640
  */
715
641
  function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIds, delistedKeyIds) {
716
- manifest.updateRepresentationsDeciperability(function (representation) {
642
+ manifest.updateRepresentationsDeciperability((representation) => {
717
643
  if (representation.contentProtections === undefined) {
718
644
  return representation.decipherable;
719
645
  }
720
- var contentKIDs = representation.contentProtections.keyIds;
646
+ const contentKIDs = representation.contentProtections.keyIds;
721
647
  if (contentKIDs !== undefined) {
722
- for (var _i = 0, contentKIDs_1 = contentKIDs; _i < contentKIDs_1.length; _i++) {
723
- var elt = contentKIDs_1[_i];
724
- for (var _a = 0, blacklistedKeyIds_1 = blacklistedKeyIds; _a < blacklistedKeyIds_1.length; _a++) {
725
- var blacklistedKeyId = blacklistedKeyIds_1[_a];
726
- if (areKeyIdsEqual(blacklistedKeyId, elt.keyId)) {
648
+ for (const elt of contentKIDs) {
649
+ for (const blacklistedKeyId of blacklistedKeyIds) {
650
+ if ((0, are_arrays_of_numbers_equal_1.default)(blacklistedKeyId, elt.keyId)) {
727
651
  return false;
728
652
  }
729
653
  }
730
- for (var _b = 0, whitelistedKeyIds_1 = whitelistedKeyIds; _b < whitelistedKeyIds_1.length; _b++) {
731
- var whitelistedKeyId = whitelistedKeyIds_1[_b];
732
- if (areKeyIdsEqual(whitelistedKeyId, elt.keyId)) {
654
+ for (const whitelistedKeyId of whitelistedKeyIds) {
655
+ if ((0, are_arrays_of_numbers_equal_1.default)(whitelistedKeyId, elt.keyId)) {
733
656
  return true;
734
657
  }
735
658
  }
736
- for (var _c = 0, delistedKeyIds_1 = delistedKeyIds; _c < delistedKeyIds_1.length; _c++) {
737
- var delistedKeyId = delistedKeyIds_1[_c];
738
- if (areKeyIdsEqual(delistedKeyId, elt.keyId)) {
659
+ for (const delistedKeyId of delistedKeyIds) {
660
+ if ((0, are_arrays_of_numbers_equal_1.default)(delistedKeyId, elt.keyId)) {
739
661
  return undefined;
740
662
  }
741
663
  }
@@ -751,77 +673,31 @@ function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIds, d
751
673
  * @param {Object} initData
752
674
  */
753
675
  function blackListProtectionData(manifest, initData) {
754
- manifest.updateRepresentationsDeciperability(function (representation) {
676
+ manifest.updateRepresentationsDeciperability((representation) => {
755
677
  var _a, _b;
756
678
  if (representation.decipherable === false) {
757
679
  return false;
758
680
  }
759
- var segmentProtections = (_b = (_a = representation.contentProtections) === null || _a === void 0 ? void 0 : _a.initData) !== null && _b !== void 0 ? _b : [];
760
- var _loop_1 = function (protection) {
681
+ const segmentProtections = (_b = (_a = representation.contentProtections) === null || _a === void 0 ? void 0 : _a.initData) !== null && _b !== void 0 ? _b : [];
682
+ for (const protection of segmentProtections) {
761
683
  if (initData.type === undefined ||
762
684
  protection.type === initData.type) {
763
- var containedInitData = initData.values.getFormattedValues()
764
- .every(function (undecipherableVal) {
765
- return protection.values.some(function (currVal) {
685
+ const containedInitData = initData.values.getFormattedValues()
686
+ .every(undecipherableVal => {
687
+ return protection.values.some(currVal => {
766
688
  return (undecipherableVal.systemId === undefined ||
767
689
  currVal.systemId === undecipherableVal.systemId) &&
768
- areArraysOfNumbersEqual(currVal.data, undecipherableVal.data);
690
+ (0, are_arrays_of_numbers_equal_1.default)(currVal.data, undecipherableVal.data);
769
691
  });
770
692
  });
771
693
  if (containedInitData) {
772
- return { value: false };
694
+ return false;
773
695
  }
774
696
  }
775
- };
776
- for (var _i = 0, segmentProtections_1 = segmentProtections; _i < segmentProtections_1.length; _i++) {
777
- var protection = segmentProtections_1[_i];
778
- var state_1 = _loop_1(protection);
779
- if (typeof state_1 === "object")
780
- return state_1.value;
781
697
  }
782
698
  return representation.decipherable;
783
699
  });
784
700
  }
785
- /** Enumeration of the various "state" the `ContentDecryptor` can be in. */
786
- export var ContentDecryptorState;
787
- (function (ContentDecryptorState) {
788
- /**
789
- * The `ContentDecryptor` is not yet ready to create key sessions and request
790
- * licenses.
791
- * This is is the initial state of the ContentDecryptor.
792
- */
793
- ContentDecryptorState[ContentDecryptorState["Initializing"] = 0] = "Initializing";
794
- /**
795
- * The `ContentDecryptor` has been initialized.
796
- * You should now called the `attach` method when you want to add decryption
797
- * capabilities to the HTMLMediaElement. The ContentDecryptor won't go to the
798
- * `ReadyForContent` state until `attach` is called.
799
- *
800
- * For compatibility reasons, this should be done after the HTMLMediaElement's
801
- * src attribute is set.
802
- *
803
- * It is also from when this state is reached that the `ContentDecryptor`'s
804
- * `systemId` property may be known.
805
- *
806
- * This state is always coming after the `Initializing` state.
807
- */
808
- ContentDecryptorState[ContentDecryptorState["WaitingForAttachment"] = 1] = "WaitingForAttachment";
809
- /**
810
- * Content (encrypted or not) can begin to be pushed on the HTMLMediaElement
811
- * (this state was needed because some browser quirks sometimes forces us to
812
- * call EME API before this can be done).
813
- *
814
- * This state is always coming after the `WaitingForAttachment` state.
815
- */
816
- ContentDecryptorState[ContentDecryptorState["ReadyForContent"] = 2] = "ReadyForContent";
817
- /**
818
- * The `ContentDecryptor` has encountered a fatal error and has been stopped.
819
- * It is now unusable.
820
- */
821
- ContentDecryptorState[ContentDecryptorState["Error"] = 3] = "Error";
822
- /** The `ContentDecryptor` has been disposed of and is now unusable. */
823
- ContentDecryptorState[ContentDecryptorState["Disposed"] = 4] = "Disposed";
824
- })(ContentDecryptorState || (ContentDecryptorState = {}));
825
701
  /**
826
702
  * Returns set of all usable and unusable keys - explicit or implicit - that are
827
703
  * linked to a `MediaKeySession`.
@@ -864,21 +740,18 @@ function getKeyIdsLinkedToSession(initializationData, keySessionRecord, singleLi
864
740
  * Every key id associated with the MediaKeySession, starting with
865
741
  * whitelisted ones.
866
742
  */
867
- var associatedKeyIds = __spreadArray(__spreadArray([], usableKeyIds, true), unusableKeyIds, true);
743
+ const associatedKeyIds = [...usableKeyIds,
744
+ ...unusableKeyIds];
868
745
  // Add all key ids associated to the `KeySessionRecord` yet not in
869
746
  // `usableKeyIds` nor in `unusableKeyIds`
870
- var allKnownKeyIds = keySessionRecord.getAssociatedKeyIds();
871
- var _loop_2 = function (kid) {
872
- if (!associatedKeyIds.some(function (ak) { return areKeyIdsEqual(ak, kid); })) {
873
- if (log.hasLevel("DEBUG")) {
874
- log.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it", bytesToHex(kid));
747
+ const allKnownKeyIds = keySessionRecord.getAssociatedKeyIds();
748
+ for (const kid of allKnownKeyIds) {
749
+ if (!associatedKeyIds.some(ak => (0, are_arrays_of_numbers_equal_1.default)(ak, kid))) {
750
+ if (log_1.default.hasLevel("DEBUG")) {
751
+ log_1.default.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it", (0, string_parsing_1.bytesToHex)(kid));
875
752
  }
876
753
  associatedKeyIds.push(kid);
877
754
  }
878
- };
879
- for (var _i = 0, allKnownKeyIds_1 = allKnownKeyIds; _i < allKnownKeyIds_1.length; _i++) {
880
- var kid = allKnownKeyIds_1[_i];
881
- _loop_2(kid);
882
755
  }
883
756
  if (singleLicensePer !== undefined && singleLicensePer !== "init-data") {
884
757
  // We want to add the current key ids in the blacklist if it is
@@ -894,52 +767,44 @@ function getKeyIdsLinkedToSession(initializationData, keySessionRecord, singleLi
894
767
  // sure yet. Because in any other `singleLicensePer`, we
895
768
  // need a good implementation anyway, it doesn't matter
896
769
  // there.
897
- var expectedKeyIds = initializationData.keyIds, content = initializationData.content;
770
+ const { keyIds: expectedKeyIds, content } = initializationData;
898
771
  if (expectedKeyIds !== undefined) {
899
- var missingKeyIds = expectedKeyIds.filter(function (expected) {
900
- return !associatedKeyIds.some(function (k) { return areKeyIdsEqual(k, expected); });
772
+ const missingKeyIds = expectedKeyIds.filter(expected => {
773
+ return !associatedKeyIds.some(k => (0, are_arrays_of_numbers_equal_1.default)(k, expected));
901
774
  });
902
775
  if (missingKeyIds.length > 0) {
903
- if (log.hasLevel("DEBUG")) {
904
- log.debug("DRM: init data keys missing in the license, blacklisting them", missingKeyIds.map(function (m) { return bytesToHex(m); }).join(", "));
776
+ if (log_1.default.hasLevel("DEBUG")) {
777
+ log_1.default.debug("DRM: init data keys missing in the license, blacklisting them", missingKeyIds.map(m => (0, string_parsing_1.bytesToHex)(m)).join(", "));
905
778
  }
906
- associatedKeyIds.push.apply(associatedKeyIds, missingKeyIds);
779
+ associatedKeyIds.push(...missingKeyIds);
907
780
  }
908
781
  }
909
782
  if (isCurrentLicense && content !== undefined) {
910
783
  if (singleLicensePer === "content") {
911
784
  // Put it in a Set to automatically filter out duplicates (by ref)
912
- var contentKeys = new Set();
913
- var manifest = content.manifest;
914
- for (var _b = 0, _c = manifest.periods; _b < _c.length; _b++) {
915
- var period = _c[_b];
785
+ const contentKeys = new Set();
786
+ const { manifest } = content;
787
+ for (const period of manifest.periods) {
916
788
  addKeyIdsFromPeriod(contentKeys, period);
917
789
  }
918
790
  mergeKeyIdSetIntoArray(contentKeys, associatedKeyIds);
919
791
  }
920
792
  else if (singleLicensePer === "periods") {
921
- var manifest = content.manifest;
922
- for (var _d = 0, _e = manifest.periods; _d < _e.length; _d++) {
923
- var period = _e[_d];
924
- var periodKeys = new Set();
793
+ const { manifest } = content;
794
+ for (const period of manifest.periods) {
795
+ const periodKeys = new Set();
925
796
  addKeyIdsFromPeriod(periodKeys, period);
926
797
  if (((_a = initializationData.content) === null || _a === void 0 ? void 0 : _a.period.id) === period.id) {
927
798
  mergeKeyIdSetIntoArray(periodKeys, associatedKeyIds);
928
799
  }
929
800
  else {
930
- var periodKeysArr = Array.from(periodKeys);
931
- var _loop_3 = function (kid) {
932
- var isFound = associatedKeyIds.some(function (k) { return areKeyIdsEqual(k, kid); });
801
+ const periodKeysArr = Array.from(periodKeys);
802
+ for (const kid of periodKeysArr) {
803
+ const isFound = associatedKeyIds.some(k => (0, are_arrays_of_numbers_equal_1.default)(k, kid));
933
804
  if (isFound) {
934
805
  mergeKeyIdSetIntoArray(periodKeys, associatedKeyIds);
935
- return "break";
936
- }
937
- };
938
- for (var _f = 0, periodKeysArr_3 = periodKeysArr; _f < periodKeysArr_3.length; _f++) {
939
- var kid = periodKeysArr_3[_f];
940
- var state_2 = _loop_3(kid);
941
- if (state_2 === "break")
942
806
  break;
807
+ }
943
808
  }
944
809
  }
945
810
  }
@@ -957,16 +822,12 @@ function getKeyIdsLinkedToSession(initializationData, keySessionRecord, singleLi
957
822
  * @param {Array.<Uint8Array>} arr
958
823
  */
959
824
  function mergeKeyIdSetIntoArray(set, arr) {
960
- var setArr = Array.from(set.values());
961
- var _loop_4 = function (kid) {
962
- var isFound = arr.some(function (k) { return areKeyIdsEqual(k, kid); });
825
+ const setArr = Array.from(set.values());
826
+ for (const kid of setArr) {
827
+ const isFound = arr.some(k => (0, are_arrays_of_numbers_equal_1.default)(k, kid));
963
828
  if (!isFound) {
964
829
  arr.push(kid);
965
830
  }
966
- };
967
- for (var _i = 0, setArr_1 = setArr; _i < setArr_1.length; _i++) {
968
- var kid = setArr_1[_i];
969
- _loop_4(kid);
970
831
  }
971
832
  }
972
833
  /**
@@ -975,14 +836,11 @@ function mergeKeyIdSetIntoArray(set, arr) {
975
836
  * @param {Object} period
976
837
  */
977
838
  function addKeyIdsFromPeriod(set, period) {
978
- for (var _i = 0, _a = period.getAdaptations(); _i < _a.length; _i++) {
979
- var adaptation = _a[_i];
980
- for (var _b = 0, _c = adaptation.representations; _b < _c.length; _b++) {
981
- var representation = _c[_b];
839
+ for (const adaptation of period.getAdaptations()) {
840
+ for (const representation of adaptation.representations) {
982
841
  if (representation.contentProtections !== undefined &&
983
842
  representation.contentProtections.keyIds !== undefined) {
984
- for (var _d = 0, _e = representation.contentProtections.keyIds; _d < _e.length; _d++) {
985
- var kidInf = _e[_d];
843
+ for (const kidInf of representation.contentProtections.keyIds) {
986
844
  set.add(kidInf.keyId);
987
845
  }
988
846
  }