rx-player 4.5.0-dev.2026021900 → 4.5.0-dev.2026032600

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 (290) hide show
  1. package/CHANGELOG.md +15 -3
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  6. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  7. package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
  8. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  9. package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
  10. package/dist/commonjs/compat/browser_version.d.ts +2 -1
  11. package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
  12. package/dist/commonjs/compat/browser_version.js +13 -0
  13. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  14. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
  15. package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
  16. package/dist/commonjs/compat/is_codec_supported.js +4 -3
  17. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  18. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  19. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
  20. package/dist/commonjs/core/cmcd/cmcd_data_builder.js +2 -2
  21. package/dist/commonjs/core/entry/content_preparer.d.ts +1 -6
  22. package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -1
  23. package/dist/commonjs/core/entry/content_preparer.js +2 -125
  24. package/dist/commonjs/core/entry/core_entry.d.ts +1 -1
  25. package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -1
  26. package/dist/commonjs/core/entry/core_entry.js +2 -7
  27. package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  28. package/dist/commonjs/core/entry/core_text_displayer_interface.js +3 -1
  29. package/dist/commonjs/core/entry/index.d.ts +1 -1
  30. package/dist/commonjs/core/entry/index.d.ts.map +1 -1
  31. package/dist/commonjs/core/entry/utils.d.ts +64 -0
  32. package/dist/commonjs/core/entry/utils.d.ts.map +1 -1
  33. package/dist/commonjs/core/entry/utils.js +165 -0
  34. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  35. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
  36. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts +5 -6
  37. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  38. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  39. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +34 -30
  40. package/dist/commonjs/experimental/features/worker/index.d.ts +2 -1
  41. package/dist/commonjs/experimental/features/worker/index.d.ts.map +1 -1
  42. package/dist/commonjs/experimental/features/worker/index.js +4 -3
  43. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  44. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  45. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  46. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
  47. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  48. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
  49. package/dist/commonjs/initialize_worker.js +1 -1
  50. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  51. package/dist/commonjs/main_thread/api/public_api.js +3 -3
  52. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  53. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
  54. package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
  55. package/dist/commonjs/manifest/classes/adaptation.js +3 -1
  56. package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
  57. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  58. package/dist/commonjs/manifest/classes/representation.js +45 -23
  59. package/dist/commonjs/manifest/types.d.ts +14 -6
  60. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  61. package/dist/commonjs/manifest/utils.js +4 -4
  62. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  63. package/dist/commonjs/mse/main_media_source_interface.js +3 -2
  64. package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
  65. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
  66. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  67. package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
  68. package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
  69. package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
  70. package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
  71. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  72. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  73. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
  74. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  75. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  76. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  77. package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
  78. package/dist/commonjs/transports/dash/segment_parser.js +6 -0
  79. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  80. package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
  81. package/dist/commonjs/transports/smooth/pipelines.js +3 -3
  82. package/dist/commonjs/transports/types.d.ts +28 -2
  83. package/dist/commonjs/transports/types.d.ts.map +1 -1
  84. package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
  85. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  86. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  87. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  88. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  89. package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
  90. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  91. package/dist/es2017/compat/browser_compatibility_types.js +7 -1
  92. package/dist/es2017/compat/browser_version.d.ts +2 -1
  93. package/dist/es2017/compat/browser_version.d.ts.map +1 -1
  94. package/dist/es2017/compat/browser_version.js +13 -1
  95. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  96. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
  97. package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
  98. package/dist/es2017/compat/is_codec_supported.js +2 -1
  99. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  100. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  101. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
  102. package/dist/es2017/core/cmcd/cmcd_data_builder.js +2 -2
  103. package/dist/es2017/core/entry/content_preparer.d.ts +1 -6
  104. package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -1
  105. package/dist/es2017/core/entry/content_preparer.js +1 -76
  106. package/dist/es2017/core/entry/core_entry.d.ts +1 -1
  107. package/dist/es2017/core/entry/core_entry.d.ts.map +1 -1
  108. package/dist/es2017/core/entry/core_entry.js +2 -7
  109. package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  110. package/dist/es2017/core/entry/core_text_displayer_interface.js +3 -1
  111. package/dist/es2017/core/entry/index.d.ts +1 -1
  112. package/dist/es2017/core/entry/index.d.ts.map +1 -1
  113. package/dist/es2017/core/entry/utils.d.ts +64 -0
  114. package/dist/es2017/core/entry/utils.d.ts.map +1 -1
  115. package/dist/es2017/core/entry/utils.js +98 -0
  116. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  117. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
  118. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts +5 -6
  119. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  120. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  121. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +21 -16
  122. package/dist/es2017/experimental/features/worker/index.d.ts +2 -1
  123. package/dist/es2017/experimental/features/worker/index.d.ts.map +1 -1
  124. package/dist/es2017/experimental/features/worker/index.js +2 -3
  125. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  126. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  127. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  128. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
  129. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  130. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
  131. package/dist/es2017/initialize_worker.js +1 -1
  132. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  133. package/dist/es2017/main_thread/api/public_api.js +3 -3
  134. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  135. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
  136. package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
  137. package/dist/es2017/manifest/classes/adaptation.js +3 -1
  138. package/dist/es2017/manifest/classes/representation.d.ts +6 -2
  139. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  140. package/dist/es2017/manifest/classes/representation.js +45 -23
  141. package/dist/es2017/manifest/types.d.ts +14 -6
  142. package/dist/es2017/manifest/types.d.ts.map +1 -1
  143. package/dist/es2017/manifest/utils.js +4 -4
  144. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  145. package/dist/es2017/mse/main_media_source_interface.js +2 -1
  146. package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
  147. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
  148. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  149. package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
  150. package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
  151. package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
  152. package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
  153. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  154. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  155. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
  156. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  157. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  158. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  159. package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
  160. package/dist/es2017/transports/dash/segment_parser.js +7 -1
  161. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  162. package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
  163. package/dist/es2017/transports/smooth/pipelines.js +3 -3
  164. package/dist/es2017/transports/types.d.ts +28 -2
  165. package/dist/es2017/transports/types.d.ts.map +1 -1
  166. package/dist/es2017/transports/utils/parse_text_track.js +1 -1
  167. package/dist/mpd-parser.wasm +0 -0
  168. package/dist/worker.js +8 -8
  169. package/eslint.config.mjs +1 -14
  170. package/package.json +19 -22
  171. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  172. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  173. package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
  174. package/src/compat/__tests__/browser_version.test.ts +57 -18
  175. package/src/compat/__tests__/clear_element_src.test.ts +20 -40
  176. package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
  177. package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
  178. package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
  179. package/src/compat/__tests__/remove_cue.test.ts +8 -20
  180. package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
  181. package/src/compat/browser_compatibility_types.ts +8 -1
  182. package/src/compat/browser_version.ts +17 -1
  183. package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
  184. package/src/compat/is_codec_supported.ts +2 -1
  185. package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
  186. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +774 -0
  187. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
  188. package/src/core/adaptive/__tests__/guess_based_chooser.test.ts +5 -2
  189. package/src/core/adaptive/utils/__tests__/bandwidth_estimator.test.ts +117 -0
  190. package/src/core/adaptive/utils/__tests__/last_estimate_storage.test.ts +76 -0
  191. package/src/core/adaptive/utils/__tests__/pending_requests_store.test.ts +5 -2
  192. package/src/core/adaptive/utils/__tests__/representation_score_calculator.test.ts +4 -2
  193. package/src/core/cmcd/__tests__/cmcd_data_builder.test.ts +464 -0
  194. package/src/core/cmcd/cmcd_data_builder.ts +2 -2
  195. package/src/core/entry/__tests__/FreezeResolver.test.ts +1 -1
  196. package/src/core/entry/__tests__/content_time_boundaries_observer.test.ts +1 -2
  197. package/src/core/entry/__tests__/core_text_displayer_interface.test.ts +205 -0
  198. package/src/core/entry/__tests__/get_buffered_data_per_media_buffer.test.ts +95 -0
  199. package/src/core/entry/__tests__/track_choice_setter.test.ts +288 -0
  200. package/src/core/entry/__tests__/utils.test.ts +315 -0
  201. package/src/core/entry/content_preparer.ts +7 -118
  202. package/src/core/entry/core_entry.ts +7 -14
  203. package/src/core/entry/core_text_displayer_interface.ts +3 -1
  204. package/src/core/entry/index.ts +1 -1
  205. package/src/core/entry/utils.ts +151 -0
  206. package/src/core/fetchers/__tests__/cdn_prioritizer.test.ts +166 -0
  207. package/src/core/fetchers/manifest/__tests__/manifest_fetcher.test.ts +803 -0
  208. package/src/core/fetchers/segment/__tests__/segment_fetcher.test.ts +872 -0
  209. package/src/core/fetchers/segment/__tests__/segment_queue.test.ts +557 -0
  210. package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
  211. package/src/core/fetchers/segment/segment_queue.ts +5 -6
  212. package/src/core/fetchers/thumbnails/__tests__/thumbnail_fetcher.test.ts +435 -0
  213. package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +28 -20
  214. package/src/core/fetchers/utils/__tests__/schedule_request.test.ts +331 -0
  215. package/src/core/stream/adaptation/__tests__/get_representations_switch_strategy.test.ts +4 -3
  216. package/src/core/stream/representation/utils/__tests__/append_segment_to_buffer.test.ts +1 -1
  217. package/src/core/stream/representation/utils/__tests__/get_segment_priority.test.ts +1 -1
  218. package/src/core/stream/representation/utils/__tests__/push_init_segment.test.ts +1 -1
  219. package/src/core/stream/representation/utils/__tests__/push_media_segment.test.ts +1 -1
  220. package/src/errors/__tests__/format_error.test.ts +23 -24
  221. package/src/experimental/features/worker/index.ts +2 -4
  222. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
  223. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
  224. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
  225. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
  226. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
  227. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
  228. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
  229. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
  230. package/src/features/__tests__/add_features.test.ts +12 -27
  231. package/src/initialize_worker.ts +1 -1
  232. package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
  233. package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
  234. package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
  235. package/src/main_thread/api/public_api.ts +3 -3
  236. package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
  237. package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
  238. package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
  239. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
  240. package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
  241. package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
  242. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
  243. package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
  244. package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
  245. package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
  246. package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
  247. package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
  248. package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
  249. package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
  250. package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
  251. package/src/manifest/classes/__tests__/period.test.ts +167 -117
  252. package/src/manifest/classes/__tests__/representation.test.ts +84 -25
  253. package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
  254. package/src/manifest/classes/adaptation.ts +4 -1
  255. package/src/manifest/classes/representation.ts +59 -27
  256. package/src/manifest/types.ts +14 -6
  257. package/src/manifest/utils.ts +4 -4
  258. package/src/mse/__tests__/main_media_source_interface.test.ts +848 -0
  259. package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
  260. package/src/mse/main_media_source_interface.ts +2 -1
  261. package/src/mse/worker_media_source_interface.ts +2 -2
  262. package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
  263. package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
  264. package/src/parsers/containers/isobmff/get_box.ts +17 -0
  265. package/src/parsers/containers/isobmff/index.ts +8 -1
  266. package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
  267. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
  268. package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
  269. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
  270. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
  271. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
  272. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
  273. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
  274. package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
  275. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
  276. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +16 -1
  277. package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
  278. package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
  279. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
  280. package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
  281. package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
  282. package/src/transports/dash/segment_parser.ts +13 -0
  283. package/src/transports/metaplaylist/pipelines.ts +2 -1
  284. package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
  285. package/src/transports/smooth/pipelines.ts +3 -3
  286. package/src/transports/types.ts +28 -2
  287. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
  288. package/src/transports/utils/parse_text_track.ts +1 -1
  289. package/src/utils/__tests__/base64.test.ts +159 -191
  290. package/src/utils/__tests__/object_assign.test.ts +2 -2
@@ -1,17 +1,24 @@
1
- import { describe, afterEach, it, expect, vi } from "vitest";
2
- import type IProbeHDCPPolicy from "../../probers/HDCPPolicy";
1
+ import { describe, afterEach, it, expect, vi, beforeEach } from "vitest";
2
+ import probeHDCPPolicy from "../../probers/HDCPPolicy";
3
+
4
+ const compatEmeMock = vi.hoisted(() => {
5
+ return {
6
+ default: {
7
+ requestMediaKeySystemAccess: undefined as unknown,
8
+ },
9
+ };
10
+ });
11
+ vi.mock("../../../../../compat/eme", () => ({ default: () => compatEmeMock.default }));
3
12
 
4
13
  describe("MediaCapabilitiesProber probers - HDCPPolicy", () => {
5
- afterEach(() => {
14
+ beforeEach(() => {
6
15
  vi.resetModules();
7
16
  });
17
+ afterEach(() => {
18
+ compatEmeMock.default.requestMediaKeySystemAccess = undefined;
19
+ });
8
20
 
9
21
  it("should throw if no requestMediaKeySystemAccess", async () => {
10
- vi.doMock("../../../../../compat/eme", () => ({
11
- default: () => null,
12
- }));
13
- const probeHDCPPolicy = (await vi.importActual("../../probers/HDCPPolicy"))
14
- .default as typeof IProbeHDCPPolicy;
15
22
  await probeHDCPPolicy("1.1").then(
16
23
  () => {
17
24
  throw new Error("Should not have succeeded");
@@ -31,15 +38,7 @@ describe("MediaCapabilitiesProber probers - HDCPPolicy", () => {
31
38
  createMediaKeys: mockCreateMediaKeys,
32
39
  });
33
40
  });
34
- vi.doMock("../../../../../compat/eme", () => ({
35
- default: {
36
- requestMediaKeySystemAccess: mockRequestMediaKeySystemAcces,
37
- },
38
- }));
39
-
40
- const probeHDCPPolicy = (await vi.importActual("../../probers/HDCPPolicy"))
41
- .default as typeof IProbeHDCPPolicy;
42
-
41
+ compatEmeMock.default.requestMediaKeySystemAccess = mockRequestMediaKeySystemAcces;
43
42
  await probeHDCPPolicy("1.1").then(
44
43
  () => {
45
44
  throw new Error("Should not have succeeded");
@@ -59,15 +58,7 @@ describe("MediaCapabilitiesProber probers - HDCPPolicy", () => {
59
58
  createMediaKeys: mockCreateMediaKeys,
60
59
  });
61
60
  });
62
- vi.doMock("../../../../../compat/eme", () => ({
63
- default: () => ({
64
- requestMediaKeySystemAccess: mockRequestMediaKeySystemAcces,
65
- }),
66
- }));
67
-
68
- const probeHDCPPolicy = (await vi.importActual("../../probers/HDCPPolicy"))
69
- .default as typeof IProbeHDCPPolicy;
70
-
61
+ compatEmeMock.default.requestMediaKeySystemAccess = mockRequestMediaKeySystemAcces;
71
62
  await probeHDCPPolicy("1.1").then(
72
63
  () => {
73
64
  throw new Error("Should not have succeeded");
@@ -91,15 +82,7 @@ describe("MediaCapabilitiesProber probers - HDCPPolicy", () => {
91
82
  createMediaKeys: mockCreateMediaKeys,
92
83
  });
93
84
  });
94
- vi.doMock("../../../../../compat/eme", () => ({
95
- default: () => ({
96
- requestMediaKeySystemAccess: mockRequestMediaKeySystemAcces,
97
- }),
98
- }));
99
-
100
- const probeHDCPPolicy = (await vi.importActual("../../probers/HDCPPolicy"))
101
- .default as typeof IProbeHDCPPolicy;
102
-
85
+ compatEmeMock.default.requestMediaKeySystemAccess = mockRequestMediaKeySystemAcces;
103
86
  await probeHDCPPolicy("1.1").then((res: string) => {
104
87
  expect(res).toEqual("Supported");
105
88
  expect(mockCreateMediaKeys).toHaveBeenCalledTimes(1);
@@ -118,14 +101,8 @@ describe("MediaCapabilitiesProber probers - HDCPPolicy", () => {
118
101
  createMediaKeys: mockCreateMediaKeys,
119
102
  });
120
103
  });
121
- vi.doMock("../../../../../compat/eme", () => ({
122
- default: () => ({
123
- requestMediaKeySystemAccess: mockRequestMediaKeySystemAcces,
124
- }),
125
- }));
104
+ compatEmeMock.default.requestMediaKeySystemAccess = mockRequestMediaKeySystemAcces;
126
105
 
127
- const probeHDCPPolicy = (await vi.importActual("../../probers/HDCPPolicy"))
128
- .default as typeof IProbeHDCPPolicy;
129
106
  await probeHDCPPolicy("1.1").then((res: string) => {
130
107
  expect(res).toEqual("NotSupported");
131
108
  expect(mockCreateMediaKeys).toHaveBeenCalledTimes(1);
@@ -1,9 +1,9 @@
1
1
  import { describe, beforeEach, afterEach, it, expect, vi } from "vitest";
2
- import isNullOrUndefined from "../../../../../utils/is_null_or_undefined";
2
+ import globalScope from "../../../../../utils/global_scope";
3
3
  import probeDecodingInfos from "../../probers/decodingInfo";
4
4
  import type { IMediaConfiguration } from "../../types";
5
5
 
6
- const origMediaCapabilities = navigator.mediaCapabilities;
6
+ const oldNavigator = globalScope.navigator;
7
7
 
8
8
  /**
9
9
  * Stub decodingInfo API to resolve.
@@ -23,22 +23,34 @@ function stubDecodingInfo(isSupported: boolean, mustReject?: boolean) {
23
23
 
24
24
  const mockMediaCapabilities = {
25
25
  decodingInfo: decodingInfoStub,
26
- };
26
+ } as unknown as MediaCapabilities;
27
27
 
28
- // @ts-expect-error: `navigator.mediaCapabilities` is read-only normally, for
29
- // now, we're going through JSDom through so that's OK.
30
- navigator.mediaCapabilities = mockMediaCapabilities;
28
+ Object.defineProperty(navigator, "mediaCapabilities", {
29
+ get() {
30
+ return mockMediaCapabilities;
31
+ },
32
+ });
31
33
  return decodingInfoStub;
32
34
  }
33
35
 
34
36
  describe("MediaCapabilitiesProber probers - decodingInfo", () => {
35
37
  beforeEach(() => {
36
38
  vi.resetModules();
39
+
40
+ // Ugly trick to authorize the resetting of the `navigator` property:
41
+ // 1. We redefine what window.navigator points to so it can be modified.
42
+ // We don't care about its value here.
43
+ // 2. We're now able to remove it from `window`.
44
+ // 3. We now redefine it as an empty object.
45
+ Object.defineProperty(globalScope, "navigator", {});
46
+ // @ts-expect-error: part of the aforementioned trick
47
+ delete globalScope.navigator;
48
+ // @ts-expect-error: part of the aforementioned trick
49
+ globalScope.navigator = {};
37
50
  });
51
+
38
52
  afterEach(() => {
39
- // @ts-expect-error: `navigator.mediaCapabilities` is read-only normally, for
40
- // now, we're going through JSDom through so that's OK.
41
- navigator.mediaCapabilities = origMediaCapabilities;
53
+ globalScope.navigator = oldNavigator;
42
54
  });
43
55
 
44
56
  it("should throw if no video and audio config", async () => {
@@ -99,6 +111,10 @@ describe("MediaCapabilitiesProber probers - decodingInfo", () => {
99
111
  expect(decodingInfoStub).not.toHaveBeenCalled();
100
112
  }
101
113
  expect(thrownException).toEqual(true);
114
+ return probeDecodingInfos(configuration).catch(({ message }: { message: string }) => {
115
+ expect(message).toEqual("Not enough arguments for calling mediaCapabilites.");
116
+ expect(decodingInfoStub).not.toHaveBeenCalled();
117
+ });
102
118
  });
103
119
 
104
120
  it("should throw if no type in config", async () => {
@@ -137,42 +153,19 @@ describe("MediaCapabilitiesProber probers - decodingInfo", () => {
137
153
  });
138
154
 
139
155
  it("should throw if API mediaCapabilities not available", async () => {
140
- // @ts-expect-error: `navigator.mediaCapabilities` is read-only normally, for
141
- // now, we're going through JSDom through so that's OK.
142
- delete navigator.mediaCapabilities;
143
- return probeDecodingInfos({}).then(
144
- () => {
145
- throw new Error("Should not succeed");
146
- },
147
- (err: Error) => {
148
- expect(err).toBeInstanceOf(Error);
149
- expect(err.message).toEqual(
150
- "navigator.mediaCapabilites.decodingInfo is not available",
151
- );
152
- },
156
+ await expect(probeDecodingInfos({})).rejects.toThrowError(
157
+ "navigator.mediaCapabilites.decodingInfo is not available",
153
158
  );
154
159
  });
155
160
 
156
161
  it("should throw if API decodingInfo not available", async () => {
157
- if (!isNullOrUndefined(navigator.mediaCapabilities)) {
158
- // @ts-expect-error: `navigator.mediaCapabilities` is read-only normally, for
159
- // now, we're going through JSDom through so that's OK.
160
- delete navigator.mediaCapabilities.decodingInfo;
161
- } else {
162
- // @ts-expect-error: `navigator.mediaCapabilities` is read-only normally, for
163
- // now, we're going through JSDom through so that's OK.
164
- navigator.mediaCapabilities = {};
165
- }
166
- return probeDecodingInfos({}).then(
167
- () => {
168
- throw new Error("Should not succeed");
169
- },
170
- (err: Error) => {
171
- expect(err).toBeInstanceOf(Error);
172
- expect(err.message).toEqual(
173
- "navigator.mediaCapabilites.decodingInfo is not available",
174
- );
162
+ Object.defineProperty(navigator, "mediaCapabilities", {
163
+ get() {
164
+ return {};
175
165
  },
166
+ });
167
+ await expect(probeDecodingInfos({})).rejects.toThrowError(
168
+ "navigator.mediaCapabilites.decodingInfo is not available",
176
169
  );
177
170
  });
178
171
 
@@ -1,15 +1,30 @@
1
- import { describe, beforeEach, it, expect, vi } from "vitest";
2
- import type {
3
- findDefaultVideoCodec as IFindDefaultVideoCodec,
4
- findDefaultAudioCodec as IFindDefaultAudioCodec,
1
+ import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
2
+ import {
3
+ findDefaultVideoCodec,
4
+ findDefaultAudioCodec,
5
5
  } from "../../probers/defaultCodecsFinder";
6
6
 
7
+ const mocks = vi.hoisted(() => {
8
+ return {
9
+ default: {
10
+ MediaSource_: {} as unknown,
11
+ },
12
+ };
13
+ });
14
+
15
+ vi.mock("../../../../../compat/browser_compatibility_types", () => {
16
+ return mocks;
17
+ });
18
+
7
19
  describe("MediaCapabilitiesProber probers - findDefaultVideoCodec", () => {
8
20
  beforeEach(() => {
9
21
  vi.resetModules();
10
22
  });
23
+ afterEach(() => {
24
+ mocks.default.MediaSource_ = {};
25
+ });
11
26
 
12
- it("should find default video codec", async () => {
27
+ it("should find default video codec", () => {
13
28
  const mockIsTypeSupported = vi.fn((codec: string) => {
14
29
  return (
15
30
  codec === 'video/mp4;codecs="avc1.4d401e"' ||
@@ -17,53 +32,34 @@ describe("MediaCapabilitiesProber probers - findDefaultVideoCodec", () => {
17
32
  codec === 'video/webm;codecs="vp8"'
18
33
  );
19
34
  });
20
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
21
- MediaSource_: {
22
- isTypeSupported: mockIsTypeSupported,
23
- },
24
- }));
25
- const findDefaultVideoCodec = (
26
- await vi.importActual("../../probers/defaultCodecsFinder")
27
- ).findDefaultVideoCodec as typeof IFindDefaultVideoCodec;
35
+
36
+ mocks.default.MediaSource_ = {
37
+ isTypeSupported: mockIsTypeSupported,
38
+ };
28
39
  expect(findDefaultVideoCodec()).toBe('video/mp4;codecs="avc1.4d401e"');
29
40
  expect(mockIsTypeSupported).toHaveBeenCalledTimes(1);
30
41
  });
31
42
 
32
- it("should not find default video codec", async () => {
43
+ it("should not find default video codec", () => {
33
44
  const mockIsTypeSupported = vi.fn(() => false);
34
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
35
- MediaSource_: {
36
- isTypeSupported: mockIsTypeSupported,
37
- },
38
- }));
39
- const findDefaultVideoCodec = (
40
- await vi.importActual("../../probers/defaultCodecsFinder")
41
- ).findDefaultVideoCodec as typeof IFindDefaultVideoCodec;
45
+ mocks.default.MediaSource_ = {
46
+ isTypeSupported: mockIsTypeSupported,
47
+ };
42
48
  expect(() => {
43
49
  findDefaultVideoCodec();
44
50
  }).toThrowError("No default video codec found.");
45
51
  expect(mockIsTypeSupported).toHaveBeenCalledTimes(4);
46
52
  });
47
53
 
48
- it("should throw because no MediaSource", async () => {
49
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
50
- MediaSource_: null,
51
- }));
52
- const findDefaultVideoCodec = (
53
- await vi.importActual("../../probers/defaultCodecsFinder")
54
- ).findDefaultVideoCodec as typeof IFindDefaultVideoCodec;
54
+ it("should throw because no MediaSource", () => {
55
+ mocks.default.MediaSource_ = null;
55
56
  expect(() => {
56
57
  findDefaultVideoCodec();
57
58
  }).toThrowError("Cannot check video codec support: No API available.");
58
59
  });
59
60
 
60
- it("should throw because no isTypeSupported", async () => {
61
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
62
- MediaSource_: {},
63
- }));
64
- const findDefaultVideoCodec = (
65
- await vi.importActual("../../probers/defaultCodecsFinder")
66
- ).findDefaultVideoCodec as typeof IFindDefaultVideoCodec;
61
+ it("should throw because no isTypeSupported", () => {
62
+ mocks.default.MediaSource_ = {};
67
63
  expect(() => {
68
64
  findDefaultVideoCodec();
69
65
  }).toThrowError("Cannot check video codec support: No API available.");
@@ -75,59 +71,39 @@ describe("MediaCapabilitiesProber probers - findDefaultAudioCodec", () => {
75
71
  vi.resetModules();
76
72
  });
77
73
 
78
- it("should find default audio codec", async () => {
74
+ it("should find default audio codec", () => {
79
75
  const mockIsTypeSupported = vi.fn((codec: string) => {
80
76
  return (
81
77
  codec === 'audio/mp4;codecs="mp4a.40.2"' || codec === 'audio/webm;codecs="opus"'
82
78
  );
83
79
  });
84
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
85
- MediaSource_: {
86
- isTypeSupported: mockIsTypeSupported,
87
- },
88
- }));
89
- const findDefaultAudioCodec = (
90
- await vi.importActual("../../probers/defaultCodecsFinder")
91
- ).findDefaultAudioCodec as typeof IFindDefaultAudioCodec;
80
+ mocks.default.MediaSource_ = {
81
+ isTypeSupported: mockIsTypeSupported,
82
+ };
92
83
  expect(findDefaultAudioCodec()).toBe('audio/mp4;codecs="mp4a.40.2"');
93
84
  expect(mockIsTypeSupported).toHaveBeenCalledTimes(1);
94
85
  });
95
86
 
96
- it("should not find default audio codec", async () => {
87
+ it("should not find default audio codec", () => {
97
88
  const mockIsTypeSupported = vi.fn(() => false);
98
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
99
- MediaSource_: {
100
- isTypeSupported: mockIsTypeSupported,
101
- },
102
- }));
103
- const findDefaultAudioCodec = (
104
- await vi.importActual("../../probers/defaultCodecsFinder")
105
- ).findDefaultAudioCodec as typeof IFindDefaultAudioCodec;
89
+ mocks.default.MediaSource_ = {
90
+ isTypeSupported: mockIsTypeSupported,
91
+ };
106
92
  expect(() => {
107
93
  findDefaultAudioCodec();
108
94
  }).toThrowError("No default audio codec found.");
109
95
  expect(mockIsTypeSupported).toHaveBeenCalledTimes(2);
110
96
  });
111
97
 
112
- it("should throw because no MediaSource", async () => {
113
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
114
- MediaSource_: null,
115
- }));
116
- const findDefaultAudioCodec = (
117
- await vi.importActual("../../probers/defaultCodecsFinder")
118
- ).findDefaultAudioCodec as typeof IFindDefaultAudioCodec;
98
+ it("should throw because no MediaSource", () => {
99
+ mocks.default.MediaSource_ = null;
119
100
  expect(() => {
120
101
  findDefaultAudioCodec();
121
102
  }).toThrowError("Cannot check audio codec support: No API available.");
122
103
  });
123
104
 
124
- it("should throw because no isTypeSupported", async () => {
125
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
126
- MediaSource_: {},
127
- }));
128
- const findDefaultAudioCodec = (
129
- await vi.importActual("../../probers/defaultCodecsFinder")
130
- ).findDefaultAudioCodec as typeof IFindDefaultAudioCodec;
105
+ it("should throw because no isTypeSupported", () => {
106
+ mocks.default.MediaSource_ = {};
131
107
  expect(() => {
132
108
  findDefaultAudioCodec();
133
109
  }).toThrow("Cannot check audio codec support: No API available.");
@@ -1,31 +1,36 @@
1
- import { describe, beforeEach, it, expect, vi } from "vitest";
2
- import type IProbeMediaContentType from "../../probers/mediaContentType";
1
+ import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
2
+ import probeMediaContentType from "../../probers/mediaContentType";
3
3
  import type { IMediaConfiguration } from "../../types";
4
4
 
5
+ const mocks = vi.hoisted(() => {
6
+ return {
7
+ default: {
8
+ MediaSource_: {} as unknown,
9
+ },
10
+ };
11
+ });
12
+
13
+ vi.mock("../../../../../compat/browser_compatibility_types", () => {
14
+ return mocks;
15
+ });
16
+
5
17
  describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
6
18
  beforeEach(() => {
7
19
  vi.resetModules();
8
20
  });
21
+ afterEach(() => {
22
+ mocks.default.MediaSource_ = {};
23
+ });
9
24
 
10
25
  it("should throw if no compatible MediaSource API", async () => {
11
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
12
- MediaSource_: null,
13
- }));
14
- const probeMediaContentType = (
15
- await vi.importActual("../../probers/mediaContentType")
16
- ).default as typeof IProbeMediaContentType;
26
+ mocks.default.MediaSource_ = null;
17
27
  expect(() => probeMediaContentType({})).toThrowError("MediaSource API not available");
18
28
  });
19
29
 
20
30
  it("should throw if no compatible isTypeSupported API", async () => {
21
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
22
- MediaSource_: {
23
- isTypeSupported: false,
24
- },
25
- }));
26
- const probeMediaContentType = (
27
- await vi.importActual("../../probers/mediaContentType")
28
- ).default as typeof IProbeMediaContentType;
31
+ mocks.default.MediaSource_ = {
32
+ isTypeSupported: false,
33
+ };
29
34
  expect(() => probeMediaContentType({})).toThrowError(
30
35
  "MediaSource.isTypeSupported API not available",
31
36
  );
@@ -33,17 +38,12 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
33
38
 
34
39
  it("should throw if no specified contentType in config", async () => {
35
40
  const mockIsTypeSupported = vi.fn(() => true);
36
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
37
- MediaSource_: {
38
- isTypeSupported: mockIsTypeSupported,
39
- },
40
- }));
41
+ mocks.default.MediaSource_ = {
42
+ isTypeSupported: mockIsTypeSupported,
43
+ };
41
44
  const config: IMediaConfiguration = {
42
45
  type: "media-source",
43
46
  };
44
- const probeMediaContentType = (
45
- await vi.importActual("../../probers/mediaContentType")
46
- ).default as typeof IProbeMediaContentType;
47
47
 
48
48
  expect.assertions(1);
49
49
  expect(() => probeMediaContentType(config)).toThrowError(
@@ -53,20 +53,15 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
53
53
 
54
54
  it("should return `Supported` when video contentType is supported", async () => {
55
55
  const mockIsTypeSupported = vi.fn(() => true);
56
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
57
- MediaSource_: {
58
- isTypeSupported: mockIsTypeSupported,
59
- },
60
- }));
56
+ mocks.default.MediaSource_ = {
57
+ isTypeSupported: mockIsTypeSupported,
58
+ };
61
59
  const config: IMediaConfiguration = {
62
60
  type: "media-source",
63
61
  video: {
64
62
  contentType: "video/mp5",
65
63
  },
66
64
  };
67
- const probeMediaContentType = (
68
- await vi.importActual("../../probers/mediaContentType")
69
- ).default as typeof IProbeMediaContentType;
70
65
 
71
66
  expect.assertions(2);
72
67
  expect(probeMediaContentType(config)).toEqual("Supported");
@@ -75,20 +70,15 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
75
70
 
76
71
  it("should return `Supported` when audio contentType is supported", async () => {
77
72
  const mockIsTypeSupported = vi.fn(() => true);
78
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
79
- MediaSource_: {
80
- isTypeSupported: mockIsTypeSupported,
81
- },
82
- }));
73
+ mocks.default.MediaSource_ = {
74
+ isTypeSupported: mockIsTypeSupported,
75
+ };
83
76
  const config: IMediaConfiguration = {
84
77
  type: "media-source",
85
78
  audio: {
86
79
  contentType: "audio/wma",
87
80
  },
88
81
  };
89
- const probeMediaContentType = (
90
- await vi.importActual("../../probers/mediaContentType")
91
- ).default as typeof IProbeMediaContentType;
92
82
 
93
83
  expect.assertions(2);
94
84
  expect(probeMediaContentType(config)).toEqual("Supported");
@@ -97,11 +87,9 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
97
87
 
98
88
  it("should return `Supported` when both contentTypes are supported", async () => {
99
89
  const mockIsTypeSupported = vi.fn(() => true);
100
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
101
- MediaSource_: {
102
- isTypeSupported: mockIsTypeSupported,
103
- },
104
- }));
90
+ mocks.default.MediaSource_ = {
91
+ isTypeSupported: mockIsTypeSupported,
92
+ };
105
93
  const config: IMediaConfiguration = {
106
94
  type: "media-source",
107
95
  audio: {
@@ -111,9 +99,6 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
111
99
  contentType: "video/mp5",
112
100
  },
113
101
  };
114
- const probeMediaContentType = (
115
- await vi.importActual("../../probers/mediaContentType")
116
- ).default as typeof IProbeMediaContentType;
117
102
 
118
103
  expect(probeMediaContentType(config)).toEqual("Supported");
119
104
  expect(mockIsTypeSupported).toHaveBeenCalledTimes(2);
@@ -121,20 +106,15 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
121
106
 
122
107
  it("should return `NotSupported` when audio contentType is not supported", async () => {
123
108
  const mockIsTypeSupported = vi.fn(() => false);
124
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
125
- MediaSource_: {
126
- isTypeSupported: mockIsTypeSupported,
127
- },
128
- }));
109
+ mocks.default.MediaSource_ = {
110
+ isTypeSupported: mockIsTypeSupported,
111
+ };
129
112
  const config: IMediaConfiguration = {
130
113
  type: "media-source",
131
114
  audio: {
132
115
  contentType: "audio/wma",
133
116
  },
134
117
  };
135
- const probeMediaContentType = (
136
- await vi.importActual("../../probers/mediaContentType")
137
- ).default as typeof IProbeMediaContentType;
138
118
 
139
119
  expect.assertions(2);
140
120
  expect(probeMediaContentType(config)).toEqual("NotSupported");
@@ -143,20 +123,15 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
143
123
 
144
124
  it("should return `NotSupported` when video contentType is not supported", async () => {
145
125
  const mockIsTypeSupported = vi.fn(() => false);
146
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
147
- MediaSource_: {
148
- isTypeSupported: mockIsTypeSupported,
149
- },
150
- }));
126
+ mocks.default.MediaSource_ = {
127
+ isTypeSupported: mockIsTypeSupported,
128
+ };
151
129
  const config: IMediaConfiguration = {
152
130
  type: "media-source",
153
131
  video: {
154
132
  contentType: "video/mp5",
155
133
  },
156
134
  };
157
- const probeMediaContentType = (
158
- await vi.importActual("../../probers/mediaContentType")
159
- ).default as typeof IProbeMediaContentType;
160
135
 
161
136
  expect.assertions(2);
162
137
  expect(probeMediaContentType(config)).toEqual("NotSupported");
@@ -165,11 +140,9 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
165
140
 
166
141
  it("should return `NotSupported` when contentTypes are not supported", async () => {
167
142
  const mockIsTypeSupported = vi.fn(() => false);
168
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
169
- MediaSource_: {
170
- isTypeSupported: mockIsTypeSupported,
171
- },
172
- }));
143
+ mocks.default.MediaSource_ = {
144
+ isTypeSupported: mockIsTypeSupported,
145
+ };
173
146
  const config: IMediaConfiguration = {
174
147
  type: "media-source",
175
148
  video: {
@@ -179,9 +152,6 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
179
152
  contentType: "audio/wma",
180
153
  },
181
154
  };
182
- const probeMediaContentType = (
183
- await vi.importActual("../../probers/mediaContentType")
184
- ).default as typeof IProbeMediaContentType;
185
155
 
186
156
  expect.assertions(2);
187
157
  expect(probeMediaContentType(config)).toEqual("NotSupported");
@@ -192,11 +162,9 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
192
162
  const mockIsTypeSupported = vi.fn((type: string) => {
193
163
  return type === "video/mp5";
194
164
  });
195
- vi.doMock("../../../../../compat/browser_compatibility_types", () => ({
196
- MediaSource_: {
197
- isTypeSupported: mockIsTypeSupported,
198
- },
199
- }));
165
+ mocks.default.MediaSource_ = {
166
+ isTypeSupported: mockIsTypeSupported,
167
+ };
200
168
  const config: IMediaConfiguration = {
201
169
  type: "media-source",
202
170
  video: {
@@ -206,9 +174,6 @@ describe("MediaCapabilitiesProber - probers probeMediaContentType", () => {
206
174
  contentType: "audio/wma",
207
175
  },
208
176
  };
209
- const probeMediaContentType = (
210
- await vi.importActual("../../probers/mediaContentType")
211
- ).default as typeof IProbeMediaContentType;
212
177
 
213
178
  expect.assertions(2);
214
179
  expect(probeMediaContentType(config)).toEqual("NotSupported");
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { MediaSource_ } from "../../../../compat/browser_compatibility_types";
17
+ import BROWSER_GLOBALS from "../../../../compat/browser_compatibility_types";
18
18
  import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
19
19
 
20
20
  /**
@@ -30,6 +30,7 @@ export function findDefaultVideoCodec(): string {
30
30
  'video/mp4;codecs="hvc1.1.6.L93.B0"',
31
31
  'video/webm;codecs="vp8"',
32
32
  ];
33
+ const { MediaSource_ } = BROWSER_GLOBALS;
33
34
  if (
34
35
  isNullOrUndefined(MediaSource_) ||
35
36
  typeof MediaSource_.isTypeSupported !== "function"
@@ -52,6 +53,7 @@ export function findDefaultVideoCodec(): string {
52
53
  */
53
54
  export function findDefaultAudioCodec(): string {
54
55
  const audioCodecs = ['audio/mp4;codecs="mp4a.40.2"', 'audio/webm;codecs="opus"'];
56
+ const { MediaSource_ } = BROWSER_GLOBALS;
55
57
  if (
56
58
  isNullOrUndefined(MediaSource_) ||
57
59
  typeof MediaSource_.isTypeSupported !== "function"
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { MediaSource_ } from "../../../../compat/browser_compatibility_types";
17
+ import BROWSER_GLOBALS from "../../../../compat/browser_compatibility_types";
18
18
  import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
19
19
  import type { IMediaConfiguration } from "../types";
20
20
 
@@ -25,6 +25,7 @@ import type { IMediaConfiguration } from "../types";
25
25
  export default function probeContentType(
26
26
  config: IMediaConfiguration,
27
27
  ): "NotSupported" | "Supported" {
28
+ const { MediaSource_ } = BROWSER_GLOBALS;
28
29
  if (isNullOrUndefined(MediaSource_)) {
29
30
  throw new Error("MediaSource API not available");
30
31
  }