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
@@ -36,10 +36,12 @@ export function getCodecsWithUnknownSupport(
36
36
  }
37
37
  for (const representation of adaptation.representations) {
38
38
  if (representation.isSupported === undefined) {
39
- codecsWithUnknownSupport.push({
40
- mimeType: representation.mimeType ?? "",
41
- codec: representation.codecs?.[0] ?? "",
42
- });
39
+ for (const codec of representation.baseCodecs ?? []) {
40
+ codecsWithUnknownSupport.push({
41
+ mimeType: representation.mimeType ?? "",
42
+ codec,
43
+ });
44
+ }
43
45
  }
44
46
  }
45
47
  }
@@ -151,7 +153,7 @@ export function updateManifestCodecSupport(
151
153
 
152
154
  const isEncrypted = representation.contentProtections !== undefined;
153
155
  const mimeType = representation.mimeType ?? "";
154
- let codecs = representation.codecs ?? [];
156
+ let codecs = representation.baseCodecs ?? [];
155
157
  if (codecs.length === 0) {
156
158
  codecs = [""];
157
159
  }
@@ -169,7 +171,7 @@ export function updateManifestCodecSupport(
169
171
  hasCodecWithUndefinedSupport = true;
170
172
  } else if (representation.isSupported) {
171
173
  hasSupportedCodec = true;
172
- representation.codecs = [codec];
174
+ representation.chosenCodec = codec; // we found the first compatible codec
173
175
 
174
176
  // Don't test subsequent codecs for that Representation
175
177
  break;
@@ -1,13 +1,27 @@
1
- import { describe, beforeEach, afterEach, it, expect, vi } from "vitest";
1
+ import { describe, beforeEach, it, expect, vi } from "vitest";
2
2
  import type { IParsedAdaptation, IParsedRepresentation } from "../../../parsers/manifest";
3
3
  import type {
4
4
  IRepresentationContext,
5
5
  IRepresentationFilterRepresentation,
6
6
  } from "../../../public_types";
7
- import type IAdaptation from "../adaptation";
7
+ import Adaptation from "../adaptation";
8
8
  import CodecSupportCache from "../codec_support_cache";
9
9
  import type { IRepresentationIndex } from "../representation_index";
10
10
 
11
+ const mocks = vi.hoisted(() => {
12
+ return {
13
+ fakeRepresentation: vi.fn(),
14
+ normalize: vi.fn(),
15
+ };
16
+ });
17
+
18
+ vi.mock("../representation", () => ({
19
+ default: mocks.fakeRepresentation,
20
+ }));
21
+ vi.mock("../../../utils/languages", () => ({
22
+ default: mocks.normalize,
23
+ }));
24
+
11
25
  const minimalRepresentationIndex: IRepresentationIndex = {
12
26
  getInitSegment() {
13
27
  return null;
@@ -61,7 +75,7 @@ const minimalRepresentationIndex: IRepresentationIndex = {
61
75
  /* noop */
62
76
  },
63
77
  };
64
- const mockDefaultRepresentationImpl = vi.fn(function (arg: IParsedRepresentation) {
78
+ const mockDefaultRepresentationImpl = function (arg: IParsedRepresentation) {
65
79
  return {
66
80
  bitrate: arg.bitrate,
67
81
  id: arg.id,
@@ -71,23 +85,18 @@ const mockDefaultRepresentationImpl = vi.fn(function (arg: IParsedRepresentation
71
85
  },
72
86
  index: arg.index,
73
87
  };
74
- });
88
+ };
75
89
 
76
90
  describe("Manifest - Adaptation", () => {
77
91
  beforeEach(() => {
78
92
  vi.resetModules();
79
- });
80
- afterEach(() => {
81
- mockDefaultRepresentationImpl.mockClear();
93
+ mocks.fakeRepresentation.mockReset();
94
+ mocks.normalize.mockReset();
82
95
  });
83
96
 
84
- it("should be able to create a minimal Adaptation", async () => {
85
- vi.doMock("../representation", () => ({
86
- default: mockDefaultRepresentationImpl,
87
- }));
97
+ it("should be able to create a minimal Adaptation", () => {
98
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
88
99
 
89
- const Adaptation = (await vi.importActual("../adaptation"))
90
- .default as typeof IAdaptation;
91
100
  const args: IParsedAdaptation = { id: "12", representations: [], type: "video" };
92
101
  const codecSupportCache = new CodecSupportCache([]);
93
102
  const adaptation = new Adaptation(args, codecSupportCache);
@@ -101,20 +110,13 @@ describe("Manifest - Adaptation", () => {
101
110
  expect(adaptation.manuallyAdded).toBe(false);
102
111
  expect(adaptation.getRepresentation("")).toBe(undefined);
103
112
 
104
- expect(mockDefaultRepresentationImpl).not.toHaveBeenCalled();
113
+ expect(mocks.fakeRepresentation).not.toHaveBeenCalled();
105
114
  });
106
115
 
107
- it("should normalize a given language", async () => {
108
- vi.doMock("../representation", () => ({
109
- default: mockDefaultRepresentationImpl,
110
- }));
111
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
112
- vi.doMock("../../../utils/languages", () => ({
113
- default: mockNormalize,
114
- }));
115
-
116
- const Adaptation = (await vi.importActual("../adaptation"))
117
- .default as typeof IAdaptation;
116
+ it("should normalize a given language", () => {
117
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
118
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
119
+
118
120
  const args1: IParsedAdaptation = {
119
121
  id: "12",
120
122
  representations: [],
@@ -125,9 +127,9 @@ describe("Manifest - Adaptation", () => {
125
127
  const adaptation1 = new Adaptation(args1, codecSupportCache);
126
128
  expect(adaptation1.language).toBe("fr");
127
129
  expect(adaptation1.normalizedLanguage).toBe("frfoo");
128
- expect(mockNormalize).toHaveBeenCalledTimes(1);
129
- expect(mockNormalize).toHaveBeenCalledWith("fr");
130
- mockNormalize.mockClear();
130
+ expect(mocks.normalize).toHaveBeenCalledTimes(1);
131
+ expect(mocks.normalize).toHaveBeenCalledWith("fr");
132
+ mocks.normalize.mockClear();
131
133
 
132
134
  const args2: IParsedAdaptation = {
133
135
  id: "12",
@@ -138,36 +140,25 @@ describe("Manifest - Adaptation", () => {
138
140
  const adaptation2 = new Adaptation(args2, codecSupportCache);
139
141
  expect(adaptation2.language).toBe("toto");
140
142
  expect(adaptation2.normalizedLanguage).toBe("totofoo");
141
- expect(mockNormalize).toHaveBeenCalledTimes(1);
142
- expect(mockNormalize).toHaveBeenCalledWith("toto");
143
+ expect(mocks.normalize).toHaveBeenCalledTimes(1);
144
+ expect(mocks.normalize).toHaveBeenCalledWith("toto");
143
145
  });
144
146
 
145
- it("should not call normalize if no language is given", async () => {
146
- vi.doMock("../representation", () => ({
147
- default: mockDefaultRepresentationImpl,
148
- }));
149
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
150
- vi.doMock("../../../utils/languages", () => ({
151
- default: mockNormalize,
152
- }));
153
-
154
- const Adaptation = (await vi.importActual("../adaptation"))
155
- .default as typeof IAdaptation;
147
+ it("should not call normalize if no language is given", () => {
148
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
149
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
150
+
156
151
  const args1: IParsedAdaptation = { id: "12", representations: [], type: "video" };
157
152
  const codecSupportCache = new CodecSupportCache([]);
158
153
  const adaptation1 = new Adaptation(args1, codecSupportCache);
159
154
  expect(adaptation1.language).toBe(undefined);
160
155
  expect(adaptation1.normalizedLanguage).toBe(undefined);
161
- expect(mockNormalize).not.toHaveBeenCalled();
156
+ expect(mocks.normalize).not.toHaveBeenCalled();
162
157
  });
163
158
 
164
- it("should create and sort the corresponding Representations", async () => {
165
- vi.doMock("../representation", () => ({
166
- default: mockDefaultRepresentationImpl,
167
- }));
159
+ it("should create and sort the corresponding Representations", () => {
160
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
168
161
 
169
- const Adaptation = (await vi.importActual("../adaptation"))
170
- .default as typeof IAdaptation;
171
162
  const rep1 = {
172
163
  bitrate: 10,
173
164
  id: "rep1",
@@ -192,20 +183,20 @@ describe("Manifest - Adaptation", () => {
192
183
  const codecSupportCache = new CodecSupportCache([]);
193
184
  const adaptation = new Adaptation(args, codecSupportCache);
194
185
  const parsedRepresentations = adaptation.representations;
195
- expect(mockDefaultRepresentationImpl).toHaveBeenCalledTimes(3);
196
- expect(mockDefaultRepresentationImpl).toHaveBeenNthCalledWith(
186
+ expect(mocks.fakeRepresentation).toHaveBeenCalledTimes(3);
187
+ expect(mocks.fakeRepresentation).toHaveBeenNthCalledWith(
197
188
  1,
198
189
  rep1,
199
190
  "text",
200
191
  codecSupportCache,
201
192
  );
202
- expect(mockDefaultRepresentationImpl).toHaveBeenNthCalledWith(
193
+ expect(mocks.fakeRepresentation).toHaveBeenNthCalledWith(
203
194
  2,
204
195
  rep2,
205
196
  "text",
206
197
  codecSupportCache,
207
198
  );
208
- expect(mockDefaultRepresentationImpl).toHaveBeenNthCalledWith(
199
+ expect(mocks.fakeRepresentation).toHaveBeenNthCalledWith(
209
200
  3,
210
201
  rep3,
211
202
  "text",
@@ -220,8 +211,8 @@ describe("Manifest - Adaptation", () => {
220
211
  expect(adaptation.getRepresentation("rep2")?.bitrate).toEqual(30);
221
212
  });
222
213
 
223
- it("should execute the representationFilter if given", async () => {
224
- const mockRepresentation = vi.fn(function (arg: IParsedRepresentation) {
214
+ it("should execute the representationFilter if given", () => {
215
+ mocks.fakeRepresentation.mockImplementation(function (arg: IParsedRepresentation) {
225
216
  return {
226
217
  bitrate: arg.bitrate,
227
218
  id: arg.id,
@@ -233,12 +224,6 @@ describe("Manifest - Adaptation", () => {
233
224
  };
234
225
  });
235
226
 
236
- vi.doMock("../representation", () => ({
237
- default: mockRepresentation,
238
- }));
239
-
240
- const Adaptation = (await vi.importActual("../adaptation"))
241
- .default as typeof IAdaptation;
242
227
  const rep1 = {
243
228
  bitrate: 10,
244
229
  id: "rep1",
@@ -313,17 +298,9 @@ describe("Manifest - Adaptation", () => {
313
298
  expect(adaptation.getRepresentation("rep4")?.id).toEqual("rep4");
314
299
  });
315
300
 
316
- it("should set an isDub value if one", async () => {
317
- vi.doMock("../representation", () => ({
318
- default: mockDefaultRepresentationImpl,
319
- }));
320
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
321
- vi.doMock("../../../utils/languages", () => ({
322
- default: mockNormalize,
323
- }));
324
-
325
- const Adaptation = (await vi.importActual("../adaptation"))
326
- .default as typeof IAdaptation;
301
+ it("should set an isDub value if one", () => {
302
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
303
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
327
304
 
328
305
  const args1: IParsedAdaptation = {
329
306
  id: "12",
@@ -336,7 +313,7 @@ describe("Manifest - Adaptation", () => {
336
313
  expect(adaptation1.language).toBe(undefined);
337
314
  expect(adaptation1.normalizedLanguage).toBe(undefined);
338
315
  expect(adaptation1.isDub).toEqual(false);
339
- expect(mockNormalize).not.toHaveBeenCalled();
316
+ expect(mocks.normalize).not.toHaveBeenCalled();
340
317
 
341
318
  const args2: IParsedAdaptation = {
342
319
  id: "12",
@@ -348,20 +325,12 @@ describe("Manifest - Adaptation", () => {
348
325
  expect(adaptation2.language).toBe(undefined);
349
326
  expect(adaptation2.normalizedLanguage).toBe(undefined);
350
327
  expect(adaptation2.isDub).toEqual(true);
351
- expect(mockNormalize).not.toHaveBeenCalled();
328
+ expect(mocks.normalize).not.toHaveBeenCalled();
352
329
  });
353
330
 
354
- it("should set an isClosedCaption value if one", async () => {
355
- vi.doMock("../representation", () => ({
356
- default: mockDefaultRepresentationImpl,
357
- }));
358
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
359
- vi.doMock("../../../utils/languages", () => ({
360
- default: mockNormalize,
361
- }));
362
-
363
- const Adaptation = (await vi.importActual("../adaptation"))
364
- .default as typeof IAdaptation;
331
+ it("should set an isClosedCaption value if one", () => {
332
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
333
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
365
334
 
366
335
  const args1: IParsedAdaptation = {
367
336
  id: "12",
@@ -374,7 +343,7 @@ describe("Manifest - Adaptation", () => {
374
343
  expect(adaptation1.language).toBe(undefined);
375
344
  expect(adaptation1.normalizedLanguage).toBe(undefined);
376
345
  expect(adaptation1.isClosedCaption).toEqual(false);
377
- expect(mockNormalize).not.toHaveBeenCalled();
346
+ expect(mocks.normalize).not.toHaveBeenCalled();
378
347
 
379
348
  const args2: IParsedAdaptation = {
380
349
  id: "12",
@@ -386,21 +355,12 @@ describe("Manifest - Adaptation", () => {
386
355
  expect(adaptation2.language).toBe(undefined);
387
356
  expect(adaptation2.normalizedLanguage).toBe(undefined);
388
357
  expect(adaptation2.isClosedCaption).toEqual(true);
389
- expect(mockNormalize).not.toHaveBeenCalled();
358
+ expect(mocks.normalize).not.toHaveBeenCalled();
390
359
  });
391
360
 
392
- it("should set an isAudioDescription value if one", async () => {
393
- vi.doMock("../representation", () => ({
394
- default: mockDefaultRepresentationImpl,
395
- }));
396
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
397
-
398
- vi.doMock("../../../utils/languages", () => ({
399
- default: mockNormalize,
400
- }));
401
-
402
- const Adaptation = (await vi.importActual("../adaptation"))
403
- .default as typeof IAdaptation;
361
+ it("should set an isAudioDescription value if one", () => {
362
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
363
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
404
364
 
405
365
  const args1: IParsedAdaptation = {
406
366
  id: "12",
@@ -413,7 +373,7 @@ describe("Manifest - Adaptation", () => {
413
373
  expect(adaptation1.language).toBe(undefined);
414
374
  expect(adaptation1.normalizedLanguage).toBe(undefined);
415
375
  expect(adaptation1.isAudioDescription).toEqual(false);
416
- expect(mockNormalize).not.toHaveBeenCalled();
376
+ expect(mocks.normalize).not.toHaveBeenCalled();
417
377
 
418
378
  const args2: IParsedAdaptation = {
419
379
  id: "12",
@@ -425,20 +385,12 @@ describe("Manifest - Adaptation", () => {
425
385
  expect(adaptation2.language).toBe(undefined);
426
386
  expect(adaptation2.normalizedLanguage).toBe(undefined);
427
387
  expect(adaptation2.isAudioDescription).toEqual(true);
428
- expect(mockNormalize).not.toHaveBeenCalled();
388
+ expect(mocks.normalize).not.toHaveBeenCalled();
429
389
  });
430
390
 
431
- it("should set a manuallyAdded value if one", async () => {
432
- vi.doMock("../representation", () => ({
433
- default: mockDefaultRepresentationImpl,
434
- }));
435
- const mockNormalize = vi.fn((lang: string) => lang + "foo");
436
- vi.doMock("../../../utils/languages", () => ({
437
- default: mockNormalize,
438
- }));
439
-
440
- const Adaptation = (await vi.importActual("../adaptation"))
441
- .default as typeof IAdaptation;
391
+ it("should set a manuallyAdded value if one", () => {
392
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
393
+ mocks.normalize.mockImplementation((lang: string) => lang + "foo");
442
394
 
443
395
  const args1: IParsedAdaptation = { id: "12", representations: [], type: "video" };
444
396
  const codecSupportCache = new CodecSupportCache([]);
@@ -448,7 +400,7 @@ describe("Manifest - Adaptation", () => {
448
400
  expect(adaptation1.language).toBe(undefined);
449
401
  expect(adaptation1.normalizedLanguage).toBe(undefined);
450
402
  expect(adaptation1.manuallyAdded).toEqual(false);
451
- expect(mockNormalize).not.toHaveBeenCalled();
403
+ expect(mocks.normalize).not.toHaveBeenCalled();
452
404
 
453
405
  const args2: IParsedAdaptation = { id: "12", representations: [], type: "video" };
454
406
  const adaptation2 = new Adaptation(args2, codecSupportCache, {
@@ -457,16 +409,12 @@ describe("Manifest - Adaptation", () => {
457
409
  expect(adaptation2.language).toBe(undefined);
458
410
  expect(adaptation2.normalizedLanguage).toBe(undefined);
459
411
  expect(adaptation2.manuallyAdded).toEqual(true);
460
- expect(mockNormalize).not.toHaveBeenCalled();
412
+ expect(mocks.normalize).not.toHaveBeenCalled();
461
413
  });
462
414
 
463
- it("should return the first Representation with the given Id with `getRepresentation`", async () => {
464
- vi.doMock("../representation", () => ({
465
- default: mockDefaultRepresentationImpl,
466
- }));
415
+ it("should return the first Representation with the given Id with `getRepresentation`", () => {
416
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
467
417
 
468
- const Adaptation = (await vi.importActual("../adaptation"))
469
- .default as typeof IAdaptation;
470
418
  const rep1 = {
471
419
  bitrate: 10,
472
420
  id: "rep1",
@@ -494,13 +442,9 @@ describe("Manifest - Adaptation", () => {
494
442
  expect(adaptation.getRepresentation("rep2")?.bitrate).toEqual(20);
495
443
  });
496
444
 
497
- it("should return undefined in `getRepresentation` if no representation is found with this Id", async () => {
498
- vi.doMock("../representation", () => ({
499
- default: mockDefaultRepresentationImpl,
500
- }));
445
+ it("should return undefined in `getRepresentation` if no representation is found with this Id", () => {
446
+ mocks.fakeRepresentation.mockImplementation(mockDefaultRepresentationImpl);
501
447
 
502
- const Adaptation = (await vi.importActual("../adaptation"))
503
- .default as typeof IAdaptation;
504
448
  const rep1 = {
505
449
  bitrate: 10,
506
450
  id: "rep1",