rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100

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 (222) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
  6. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  7. package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
  8. package/dist/commonjs/compat/browser_version.d.ts +2 -1
  9. package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
  10. package/dist/commonjs/compat/browser_version.js +13 -0
  11. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  12. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
  13. package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
  14. package/dist/commonjs/compat/is_codec_supported.js +4 -3
  15. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  16. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  17. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
  18. package/dist/commonjs/core/entry/utils.js +3 -3
  19. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  20. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
  21. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  22. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  23. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  24. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
  25. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  26. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
  27. package/dist/commonjs/initialize_worker.js +1 -1
  28. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  29. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  30. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  31. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
  32. package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
  33. package/dist/commonjs/manifest/classes/adaptation.js +3 -1
  34. package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
  35. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  36. package/dist/commonjs/manifest/classes/representation.js +45 -23
  37. package/dist/commonjs/manifest/types.d.ts +14 -6
  38. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  39. package/dist/commonjs/manifest/utils.js +4 -4
  40. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  41. package/dist/commonjs/mse/main_media_source_interface.js +3 -2
  42. package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
  43. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
  44. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  45. package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
  46. package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
  47. package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
  48. package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
  49. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  50. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  51. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
  52. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  53. package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
  54. package/dist/commonjs/transports/dash/segment_parser.js +6 -0
  55. package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
  56. package/dist/commonjs/transports/dash/text_parser.js +5 -1
  57. package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
  58. package/dist/commonjs/transports/local/text_parser.js +5 -1
  59. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  60. package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
  61. package/dist/commonjs/transports/smooth/pipelines.js +3 -3
  62. package/dist/commonjs/transports/types.d.ts +28 -2
  63. package/dist/commonjs/transports/types.d.ts.map +1 -1
  64. package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
  65. package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
  66. package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
  67. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  68. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  69. package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
  70. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  71. package/dist/es2017/compat/browser_compatibility_types.js +7 -1
  72. package/dist/es2017/compat/browser_version.d.ts +2 -1
  73. package/dist/es2017/compat/browser_version.d.ts.map +1 -1
  74. package/dist/es2017/compat/browser_version.js +13 -1
  75. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  76. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
  77. package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
  78. package/dist/es2017/compat/is_codec_supported.js +2 -1
  79. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  80. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  81. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
  82. package/dist/es2017/core/entry/utils.js +4 -4
  83. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  84. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
  85. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  86. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  87. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  88. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
  89. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  90. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
  91. package/dist/es2017/initialize_worker.js +1 -1
  92. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  93. package/dist/es2017/main_thread/api/public_api.js +2 -2
  94. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  95. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
  96. package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
  97. package/dist/es2017/manifest/classes/adaptation.js +3 -1
  98. package/dist/es2017/manifest/classes/representation.d.ts +6 -2
  99. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  100. package/dist/es2017/manifest/classes/representation.js +45 -23
  101. package/dist/es2017/manifest/types.d.ts +14 -6
  102. package/dist/es2017/manifest/types.d.ts.map +1 -1
  103. package/dist/es2017/manifest/utils.js +4 -4
  104. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  105. package/dist/es2017/mse/main_media_source_interface.js +2 -1
  106. package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
  107. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
  108. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  109. package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
  110. package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
  111. package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
  112. package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
  113. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  114. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  115. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
  116. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  117. package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
  118. package/dist/es2017/transports/dash/segment_parser.js +7 -1
  119. package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
  120. package/dist/es2017/transports/dash/text_parser.js +5 -1
  121. package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
  122. package/dist/es2017/transports/local/text_parser.js +5 -1
  123. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  124. package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
  125. package/dist/es2017/transports/smooth/pipelines.js +3 -3
  126. package/dist/es2017/transports/types.d.ts +28 -2
  127. package/dist/es2017/transports/types.d.ts.map +1 -1
  128. package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
  129. package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
  130. package/dist/es2017/transports/utils/parse_text_track.js +1 -1
  131. package/dist/worker.js +6 -6
  132. package/eslint.config.mjs +1 -14
  133. package/package.json +1 -1
  134. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  135. package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
  136. package/src/compat/__tests__/browser_version.test.ts +57 -18
  137. package/src/compat/__tests__/clear_element_src.test.ts +20 -40
  138. package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
  139. package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
  140. package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
  141. package/src/compat/__tests__/remove_cue.test.ts +8 -20
  142. package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
  143. package/src/compat/browser_compatibility_types.ts +8 -1
  144. package/src/compat/browser_version.ts +17 -1
  145. package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
  146. package/src/compat/is_codec_supported.ts +2 -1
  147. package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
  148. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
  149. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
  150. package/src/core/entry/__tests__/utils.test.ts +7 -1
  151. package/src/core/entry/utils.ts +4 -4
  152. package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
  153. package/src/errors/__tests__/format_error.test.ts +23 -24
  154. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
  155. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
  156. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
  157. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
  158. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
  159. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
  160. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
  161. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
  162. package/src/features/__tests__/add_features.test.ts +12 -27
  163. package/src/initialize_worker.ts +1 -1
  164. package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
  165. package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
  166. package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
  167. package/src/main_thread/api/public_api.ts +2 -2
  168. package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
  169. package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
  170. package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
  171. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
  172. package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
  173. package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
  174. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
  175. package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
  176. package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
  177. package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
  178. package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
  179. package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
  180. package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
  181. package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
  182. package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
  183. package/src/manifest/classes/__tests__/period.test.ts +167 -117
  184. package/src/manifest/classes/__tests__/representation.test.ts +84 -25
  185. package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
  186. package/src/manifest/classes/adaptation.ts +4 -1
  187. package/src/manifest/classes/representation.ts +59 -27
  188. package/src/manifest/types.ts +14 -6
  189. package/src/manifest/utils.ts +4 -4
  190. package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
  191. package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
  192. package/src/mse/main_media_source_interface.ts +2 -1
  193. package/src/mse/worker_media_source_interface.ts +2 -2
  194. package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
  195. package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
  196. package/src/parsers/containers/isobmff/get_box.ts +17 -0
  197. package/src/parsers/containers/isobmff/index.ts +8 -1
  198. package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
  199. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
  200. package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
  201. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
  202. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
  203. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
  204. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
  205. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
  206. package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
  207. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
  208. package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
  209. package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
  210. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
  211. package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
  212. package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
  213. package/src/transports/dash/segment_parser.ts +13 -0
  214. package/src/transports/dash/text_parser.ts +5 -1
  215. package/src/transports/local/text_parser.ts +5 -1
  216. package/src/transports/metaplaylist/pipelines.ts +2 -1
  217. package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
  218. package/src/transports/smooth/pipelines.ts +3 -3
  219. package/src/transports/types.ts +28 -2
  220. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
  221. package/src/transports/utils/parse_text_track.ts +10 -3
  222. package/src/utils/__tests__/object_assign.test.ts +2 -2
@@ -1,14 +1,21 @@
1
- import { describe, beforeEach, it, expect, vi } from "vitest";
1
+ import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
2
2
  import type { ITNode } from "../../../../../../utils/xml-parser";
3
3
  import { parseXml } from "../../../../../../utils/xml-parser";
4
- import type IContentProtection from "../ContentProtection";
4
+ import parseContentProtection from "../ContentProtection";
5
+
6
+ const mocks = vi.hoisted(() => {
7
+ return {
8
+ hexToBytes: vi.fn(),
9
+ };
10
+ });
11
+ vi.mock("../../../../../../utils/string_parsing", () => ({
12
+ hexToBytes: mocks.hexToBytes,
13
+ }));
5
14
 
6
15
  function testStringAttribute(attributeName: string, variableName?: string): void {
7
16
  const _variableName = variableName ?? attributeName;
8
17
 
9
- it(`should correctly parse a ContentProtection element with a correct ${attributeName} attribute`, async () => {
10
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
11
- .default as typeof IContentProtection;
18
+ it(`should correctly parse a ContentProtection element with a correct ${attributeName} attribute`, () => {
12
19
  const element1 = parseXml(
13
20
  `<ContentProtection ${attributeName}="foobar" />`,
14
21
  )[0] as ITNode;
@@ -29,10 +36,11 @@ describe("DASH Node Parsers - ContentProtection", () => {
29
36
  beforeEach(() => {
30
37
  vi.resetModules();
31
38
  });
39
+ afterEach(() => {
40
+ mocks.hexToBytes.mockReset();
41
+ });
32
42
 
33
- it("should correctly parse a ContentProtection element without attributes", async () => {
34
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
35
- .default as typeof IContentProtection;
43
+ it("should correctly parse a ContentProtection element without attributes", () => {
36
44
  const element = parseXml("<ContentProtection />")[0] as ITNode;
37
45
  expect(parseContentProtection(element)).toEqual([
38
46
  { attributes: {}, children: { cencPssh: [] } },
@@ -43,16 +51,11 @@ describe("DASH Node Parsers - ContentProtection", () => {
43
51
  testStringAttribute("schemeIdUri");
44
52
  testStringAttribute("value");
45
53
 
46
- it("should correctly parse a ContentProtection element with a correct cenc:default_KID attribute", async () => {
54
+ it("should correctly parse a ContentProtection element with a correct cenc:default_KID attribute", () => {
47
55
  const keyId = new Uint8Array([0, 1, 2, 3]);
48
- const mockHexToBytes = vi.fn().mockImplementation(() => {
56
+ mocks.hexToBytes.mockImplementation(() => {
49
57
  return keyId;
50
58
  });
51
- vi.doMock("../../../../../../utils/string_parsing", () => ({
52
- hexToBytes: mockHexToBytes,
53
- }));
54
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
55
- .default as typeof IContentProtection;
56
59
  const element1 = parseXml(
57
60
  '<ContentProtection cenc:default_KID="dead-beef" />',
58
61
  )[0] as ITNode;
@@ -61,20 +64,15 @@ describe("DASH Node Parsers - ContentProtection", () => {
61
64
  { attributes: { keyId }, children: { cencPssh: [] } },
62
65
  [],
63
66
  ]);
64
- expect(mockHexToBytes).toHaveBeenCalledTimes(1);
65
- expect(mockHexToBytes).toHaveBeenCalledWith("deadbeef");
67
+ expect(mocks.hexToBytes).toHaveBeenCalledTimes(1);
68
+ expect(mocks.hexToBytes).toHaveBeenCalledWith("deadbeef");
66
69
  });
67
70
 
68
- it("should correctly parse a ContentProtection with every attributes", async () => {
71
+ it("should correctly parse a ContentProtection with every attributes", () => {
69
72
  const keyId = new Uint8Array([0, 1, 2, 3]);
70
- const mockHexToBytes = vi.fn().mockImplementation(() => {
73
+ mocks.hexToBytes.mockImplementation(() => {
71
74
  return keyId;
72
75
  });
73
- vi.doMock("../../../../../../utils/string_parsing", () => ({
74
- hexToBytes: mockHexToBytes,
75
- }));
76
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
77
- .default as typeof IContentProtection;
78
76
  const element = parseXml(
79
77
  `<ContentProtection
80
78
  schemeIdUri="foo"
@@ -91,9 +89,7 @@ describe("DASH Node Parsers - ContentProtection", () => {
91
89
  ]);
92
90
  });
93
91
 
94
- it("should correctly parse a ContentProtection with cenc:pssh children", async () => {
95
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
96
- .default as typeof IContentProtection;
92
+ it("should correctly parse a ContentProtection with cenc:pssh children", () => {
97
93
  const element = parseXml(
98
94
  `<ContentProtection>
99
95
  <cenc:pssh>AABBCC</cenc:pssh>
@@ -113,16 +109,11 @@ describe("DASH Node Parsers - ContentProtection", () => {
113
109
  ]);
114
110
  });
115
111
 
116
- it("should correctly parse a ContentProtection with both cenc:pssh children and every attributes", async () => {
112
+ it("should correctly parse a ContentProtection with both cenc:pssh children and every attributes", () => {
117
113
  const keyId = new Uint8Array([0, 1, 2, 3]);
118
- const mockHexToBytes = vi.fn().mockImplementation(() => {
114
+ mocks.hexToBytes.mockImplementation(() => {
119
115
  return keyId;
120
116
  });
121
- vi.doMock("../../../../../../utils/string_parsing", () => ({
122
- hexToBytes: mockHexToBytes,
123
- }));
124
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
125
- .default as typeof IContentProtection;
126
117
  const element = parseXml(
127
118
  `<ContentProtection
128
119
  schemeIdUri="foo"
@@ -144,9 +135,7 @@ describe("DASH Node Parsers - ContentProtection", () => {
144
135
  ]);
145
136
  });
146
137
 
147
- it("should return a warning if one of the cenc:pssh is invalid base64", async () => {
148
- const parseContentProtection = (await vi.importActual("../ContentProtection"))
149
- .default as typeof IContentProtection;
138
+ it("should return a warning if one of the cenc:pssh is invalid base64", () => {
150
139
  const element = parseXml(
151
140
  `<ContentProtection>
152
141
  <cenc:pssh>AA!BCC</cenc:pssh>
@@ -1,62 +1,49 @@
1
- import { describe, beforeEach, it, expect, vi } from "vitest";
1
+ import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
2
+ import log from "../../../../../../log";
2
3
  import type { ITNode } from "../../../../../../utils/xml-parser";
3
4
  import { parseXml } from "../../../../../../utils/xml-parser";
4
- import type IParseInitialization from "../Initialization";
5
- import type { MPDError as IMPDError } from "../utils";
5
+ import parseInitialization from "../Initialization";
6
+ import { MPDError } from "../utils";
7
+
8
+ const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
9
+ /* noop */
10
+ });
6
11
 
7
12
  describe("DASH Node Parsers - Initialization", () => {
8
13
  beforeEach(() => {
9
14
  vi.resetModules();
10
15
  });
16
+ afterEach(() => {
17
+ logWarn.mockClear();
18
+ });
11
19
 
12
- it("should correctly parse an element with no known attribute", async () => {
13
- const log = { default: { warn: () => null } };
14
- vi.doMock("../../../../../../log", () => log);
15
- const mockLog = vi.spyOn(log.default, "warn");
16
-
17
- const parseInitialization = (await vi.importActual("../Initialization"))
18
- .default as typeof IParseInitialization;
20
+ it("should correctly parse an element with no known attribute", () => {
19
21
  const element1 = parseXml("<Foo />")[0] as ITNode;
20
22
  expect(parseInitialization(element1)).toEqual([{}, []]);
21
23
 
22
24
  const element2 = parseXml('<Foo test="" />')[0] as ITNode;
23
25
  expect(parseInitialization(element2)).toEqual([{}, []]);
24
26
 
25
- expect(mockLog).not.toHaveBeenCalled();
26
- mockLog.mockRestore();
27
+ expect(logWarn).not.toHaveBeenCalled();
27
28
  });
28
29
 
29
- it("should correctly parse an element with a well-formed `range` attribute", async () => {
30
- const log = { default: { warn: () => null } };
31
- vi.doMock("../../../../../../log", () => log);
32
- const mockLog = vi.spyOn(log.default, "warn");
33
-
34
- const parseInitialization = (await vi.importActual("../Initialization"))
35
- .default as typeof IParseInitialization;
30
+ it("should correctly parse an element with a well-formed `range` attribute", () => {
36
31
  const element1 = parseXml('<Foo range="0-1" />')[0] as ITNode;
37
32
  expect(parseInitialization(element1)).toEqual([{ range: [0, 1] }, []]);
38
33
 
39
34
  const element2 = parseXml('<Foo range="100-1000" />')[0] as ITNode;
40
35
  expect(parseInitialization(element2)).toEqual([{ range: [100, 1000] }, []]);
41
36
 
42
- expect(mockLog).not.toHaveBeenCalled();
43
- mockLog.mockRestore();
37
+ expect(logWarn).not.toHaveBeenCalled();
44
38
  });
45
39
 
46
- it("should correctly parse an element with an incorrect `range` attribute", async () => {
47
- const log = { default: { warn: () => null } };
48
- vi.doMock("../../../../../../log", () => log);
49
- const mockLog = vi.spyOn(log.default, "warn").mockImplementation(vi.fn());
50
-
51
- const parseInitialization = (await vi.importActual("../Initialization"))
52
- .default as typeof IParseInitialization;
53
- const MPDError = (await vi.importActual("../utils")).MPDError as typeof IMPDError;
40
+ it("should correctly parse an element with an incorrect `range` attribute", () => {
54
41
  const element1 = parseXml('<Foo range="a" />')[0] as ITNode;
55
42
  const error1 = new MPDError('`range` property has an unrecognized format "a"');
56
43
  expect(parseInitialization(element1)).toEqual([{}, [error1]]);
57
44
 
58
- expect(mockLog).toHaveBeenCalledTimes(1);
59
- expect(mockLog).toHaveBeenCalledWith(
45
+ expect(logWarn).toHaveBeenCalledTimes(1);
46
+ expect(logWarn).toHaveBeenCalledWith(
60
47
  "dash",
61
48
  "failed to parse DASH value:",
62
49
  error1.message,
@@ -67,45 +54,29 @@ describe("DASH Node Parsers - Initialization", () => {
67
54
  const error2 = new MPDError('`range` property has an unrecognized format ""');
68
55
  expect(parseInitialization(element2)).toEqual([{}, [error2]]);
69
56
 
70
- expect(mockLog).toHaveBeenCalledTimes(2);
71
- expect(mockLog).toHaveBeenCalledWith(
57
+ expect(logWarn).toHaveBeenCalledTimes(2);
58
+ expect(logWarn).toHaveBeenCalledWith(
72
59
  "dash",
73
60
  "failed to parse DASH value:",
74
61
  error2.message,
75
62
  { dashName: "range" },
76
63
  );
77
-
78
- mockLog.mockRestore();
79
64
  });
80
65
 
81
- it("should correctly parse an element with a sourceURL attribute", async () => {
82
- const log = { default: { warn: () => null } };
83
- vi.doMock("../../../../../../log", () => log);
84
- const mockLog = vi.spyOn(log.default, "warn");
85
-
86
- const parseInitialization = (await vi.importActual("../Initialization"))
87
- .default as typeof IParseInitialization;
66
+ it("should correctly parse an element with a sourceURL attribute", () => {
88
67
  const element1 = parseXml('<Foo sourceURL="a" />')[0] as ITNode;
89
68
  expect(parseInitialization(element1)).toEqual([{ media: "a" }, []]);
90
69
 
91
70
  const element2 = parseXml('<Foo sourceURL="" />')[0] as ITNode;
92
71
  expect(parseInitialization(element2)).toEqual([{ media: "" }, []]);
93
72
 
94
- expect(mockLog).not.toHaveBeenCalled();
95
- mockLog.mockRestore();
73
+ expect(logWarn).not.toHaveBeenCalled();
96
74
  });
97
75
 
98
- it("should correctly parse an element with both a sourceURL and range attributes", async () => {
99
- const log = { default: { warn: () => null } };
100
- vi.doMock("../../../../../../log", () => log);
101
- const mockLog = vi.spyOn(log.default, "warn");
102
-
103
- const parseInitialization = (await vi.importActual("../Initialization"))
104
- .default as typeof IParseInitialization;
76
+ it("should correctly parse an element with both a sourceURL and range attributes", () => {
105
77
  const element1 = parseXml('<Foo sourceURL="a" range="4-10" />')[0] as ITNode;
106
78
  expect(parseInitialization(element1)).toEqual([{ media: "a", range: [4, 10] }, []]);
107
79
 
108
- expect(mockLog).not.toHaveBeenCalled();
109
- mockLog.mockRestore();
80
+ expect(logWarn).not.toHaveBeenCalled();
110
81
  });
111
82
  });
@@ -1,62 +1,49 @@
1
- import { describe, beforeEach, it, expect, vi } from "vitest";
1
+ import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
2
+ import log from "../../../../../../log";
2
3
  import type { ITNode } from "../../../../../../utils/xml-parser";
3
4
  import { parseXml } from "../../../../../../utils/xml-parser";
4
- import type IParseSegmentURL from "../SegmentURL";
5
- import type { MPDError as IMPDError } from "../utils";
5
+ import parseSegmentURL from "../SegmentURL";
6
+ import { MPDError } from "../utils";
7
+
8
+ const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
9
+ /* noop */
10
+ });
6
11
 
7
12
  describe("DASH Node Parsers - SegmentURL", () => {
8
13
  beforeEach(() => {
9
14
  vi.resetModules();
10
15
  });
16
+ afterEach(() => {
17
+ logWarn.mockClear();
18
+ });
11
19
 
12
- it("should correctly parse an element with no known attribute", async () => {
13
- const log = { default: { warn: () => null } };
14
- vi.doMock("../../../../../../log", () => log);
15
- const mockLog = vi.spyOn(log.default, "warn");
16
-
17
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
18
- .default as typeof IParseSegmentURL;
20
+ it("should correctly parse an element with no known attribute", () => {
19
21
  const element1 = parseXml("<Foo />")[0] as ITNode;
20
22
  expect(parseSegmentURL(element1)).toEqual([{}, []]);
21
23
 
22
24
  const element2 = parseXml('<Foo test="" />')[0] as ITNode;
23
25
  expect(parseSegmentURL(element2)).toEqual([{}, []]);
24
26
 
25
- expect(mockLog).not.toHaveBeenCalled();
26
- mockLog.mockRestore();
27
+ expect(logWarn).not.toHaveBeenCalled();
27
28
  });
28
29
 
29
- it("should correctly parse an element with a well-formed `mediaRange` attribute", async () => {
30
- const log = { default: { warn: () => null } };
31
- vi.doMock("../../../../../../log", () => log);
32
- const mockLog = vi.spyOn(log.default, "warn");
33
-
34
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
35
- .default as typeof IParseSegmentURL;
30
+ it("should correctly parse an element with a well-formed `mediaRange` attribute", () => {
36
31
  const element1 = parseXml('<Foo mediaRange="10-100" />')[0] as ITNode;
37
32
  expect(parseSegmentURL(element1)).toEqual([{ mediaRange: [10, 100] }, []]);
38
33
 
39
34
  const element2 = parseXml('<Foo mediaRange="0-1" />')[0] as ITNode;
40
35
  expect(parseSegmentURL(element2)).toEqual([{ mediaRange: [0, 1] }, []]);
41
36
 
42
- expect(mockLog).not.toHaveBeenCalled();
43
- mockLog.mockRestore();
37
+ expect(logWarn).not.toHaveBeenCalled();
44
38
  });
45
39
 
46
- it("should correctly parse an element with an incorrect `mediaRange` attribute", async () => {
47
- const log = { default: { warn: () => null } };
48
- vi.doMock("../../../../../../log", () => log);
49
- const mockLog = vi.spyOn(log.default, "warn").mockImplementation(vi.fn());
50
-
51
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
52
- .default as typeof IParseSegmentURL;
53
- const MPDError = (await vi.importActual("../utils")).MPDError as typeof IMPDError;
40
+ it("should correctly parse an element with an incorrect `mediaRange` attribute", () => {
54
41
  const element1 = parseXml('<Foo mediaRange="a" />')[0] as ITNode;
55
42
  const error1 = new MPDError('`mediaRange` property has an unrecognized format "a"');
56
43
  expect(parseSegmentURL(element1)).toEqual([{}, [error1]]);
57
44
 
58
- expect(mockLog).toHaveBeenCalledTimes(1);
59
- expect(mockLog).toHaveBeenCalledWith(
45
+ expect(logWarn).toHaveBeenCalledTimes(1);
46
+ expect(logWarn).toHaveBeenCalledWith(
60
47
  "dash",
61
48
  "failed to parse DASH value:",
62
49
  error1.message,
@@ -67,50 +54,32 @@ describe("DASH Node Parsers - SegmentURL", () => {
67
54
  const error2 = new MPDError('`mediaRange` property has an unrecognized format ""');
68
55
  expect(parseSegmentURL(element2)).toEqual([{}, [error2]]);
69
56
 
70
- expect(mockLog).toHaveBeenCalledTimes(2);
71
- expect(mockLog).toHaveBeenCalledWith(
57
+ expect(logWarn).toHaveBeenCalledTimes(2);
58
+ expect(logWarn).toHaveBeenCalledWith(
72
59
  "dash",
73
60
  "failed to parse DASH value:",
74
61
  error2.message,
75
62
  { dashName: "mediaRange" },
76
63
  );
77
-
78
- mockLog.mockRestore();
79
64
  });
80
65
 
81
- it("should correctly parse an element with a well-formed `indexRange` attribute", async () => {
82
- const log = {
83
- default: { warn: () => null },
84
- };
85
- vi.doMock("../../../../../../log", () => log);
86
- const mockLog = vi.spyOn(log.default, "warn");
87
-
88
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
89
- .default as typeof IParseSegmentURL;
66
+ it("should correctly parse an element with a well-formed `indexRange` attribute", () => {
90
67
  const element1 = parseXml('<Foo indexRange="0-100" />')[0] as ITNode;
91
68
  expect(parseSegmentURL(element1)).toEqual([{ indexRange: [0, 100] }, []]);
92
69
 
93
70
  const element2 = parseXml('<Foo indexRange="72-47" />')[0] as ITNode;
94
71
  expect(parseSegmentURL(element2)).toEqual([{ indexRange: [72, 47] }, []]);
95
72
 
96
- expect(mockLog).not.toHaveBeenCalled();
97
- mockLog.mockRestore();
73
+ expect(logWarn).not.toHaveBeenCalled();
98
74
  });
99
75
 
100
- it("should correctly parse an element with an incorrect `indexRange` attribute", async () => {
101
- const log = { default: { warn: () => null } };
102
- vi.doMock("../../../../../../log", () => log);
103
- const mockLog = vi.spyOn(log.default, "warn").mockImplementation(vi.fn());
104
-
105
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
106
- .default as typeof IParseSegmentURL;
107
- const MPDError = (await vi.importActual("../utils")).MPDError as typeof IMPDError;
76
+ it("should correctly parse an element with an incorrect `indexRange` attribute", () => {
108
77
  const element1 = parseXml('<Foo indexRange="a" />')[0] as ITNode;
109
78
  const error1 = new MPDError('`indexRange` property has an unrecognized format "a"');
110
79
  expect(parseSegmentURL(element1)).toEqual([{}, [error1]]);
111
80
 
112
- expect(mockLog).toHaveBeenCalledTimes(1);
113
- expect(mockLog).toHaveBeenCalledWith(
81
+ expect(logWarn).toHaveBeenCalledTimes(1);
82
+ expect(logWarn).toHaveBeenCalledWith(
114
83
  "dash",
115
84
  "failed to parse DASH value:",
116
85
  error1.message,
@@ -121,48 +90,32 @@ describe("DASH Node Parsers - SegmentURL", () => {
121
90
  const error2 = new MPDError('`indexRange` property has an unrecognized format ""');
122
91
  expect(parseSegmentURL(element2)).toEqual([{}, [error2]]);
123
92
 
124
- expect(mockLog).toHaveBeenCalledTimes(2);
125
- expect(mockLog).toHaveBeenCalledWith(
93
+ expect(logWarn).toHaveBeenCalledTimes(2);
94
+ expect(logWarn).toHaveBeenCalledWith(
126
95
  "dash",
127
96
  "failed to parse DASH value:",
128
97
  error2.message,
129
98
  { dashName: "indexRange" },
130
99
  );
131
-
132
- mockLog.mockRestore();
133
100
  });
134
101
 
135
- it("should correctly parse an element with a media attribute", async () => {
136
- const log = { default: { warn: () => null } };
137
- vi.doMock("../../../../../../log", () => log);
138
- const mockLog = vi.spyOn(log.default, "warn");
139
-
140
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
141
- .default as typeof IParseSegmentURL;
102
+ it("should correctly parse an element with a media attribute", () => {
142
103
  const element1 = parseXml('<Foo media="a" />')[0] as ITNode;
143
104
  expect(parseSegmentURL(element1)).toEqual([{ media: "a" }, []]);
144
105
 
145
106
  const element2 = parseXml('<Foo media="" />')[0] as ITNode;
146
107
  expect(parseSegmentURL(element2)).toEqual([{ media: "" }, []]);
147
108
 
148
- expect(mockLog).not.toHaveBeenCalled();
149
- mockLog.mockRestore();
109
+ expect(logWarn).not.toHaveBeenCalled();
150
110
  });
151
111
 
152
- it("should correctly parse an element with a index attribute", async () => {
153
- const log = { default: { warn: () => null } };
154
- vi.doMock("../../../../../../log", () => log);
155
- const mockLog = vi.spyOn(log.default, "warn");
156
-
157
- const parseSegmentURL = (await vi.importActual("../SegmentURL"))
158
- .default as typeof IParseSegmentURL;
112
+ it("should correctly parse an element with a index attribute", () => {
159
113
  const element1 = parseXml('<Foo index="a" />')[0] as ITNode;
160
114
  expect(parseSegmentURL(element1)).toEqual([{ index: "a" }, []]);
161
115
 
162
116
  const element2 = parseXml('<Foo index="" />')[0] as ITNode;
163
117
  expect(parseSegmentURL(element2)).toEqual([{ index: "" }, []]);
164
118
 
165
- expect(mockLog).not.toHaveBeenCalled();
166
- mockLog.mockRestore();
119
+ expect(logWarn).not.toHaveBeenCalled();
167
120
  });
168
121
  });
@@ -224,18 +224,20 @@ function createManifest(
224
224
  baseContentMetadata,
225
225
  );
226
226
  let supplementalCodecs: string | undefined;
227
- if (currentRepresentation.codecs.length > 1) {
228
- if (currentRepresentation.codecs.length > 2) {
227
+ if (currentRepresentation.baseCodecs.length > 1) {
228
+ if (currentRepresentation.baseCodecs.length > 2) {
229
229
  log.warn(
230
230
  "metaplaylist",
231
231
  "MetaPlaylist relying on more than 2 groups of " +
232
232
  "codecs with retro-compatibility",
233
233
  );
234
234
  }
235
- supplementalCodecs = currentRepresentation.codecs[0];
235
+ supplementalCodecs = currentRepresentation.baseCodecs[0];
236
236
  }
237
237
  const codecs =
238
- currentRepresentation.codecs[currentRepresentation.codecs.length - 1];
238
+ currentRepresentation.baseCodecs[
239
+ currentRepresentation.baseCodecs.length - 1
240
+ ];
239
241
  representations.push({
240
242
  bitrate: currentRepresentation.bitrate,
241
243
  index: newIndex,