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

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 (100) hide show
  1. package/CHANGELOG.md +13 -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/core/cmcd/cmcd_data_builder.js +2 -2
  8. package/dist/commonjs/core/entry/content_preparer.d.ts +1 -6
  9. package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -1
  10. package/dist/commonjs/core/entry/content_preparer.js +2 -125
  11. package/dist/commonjs/core/entry/core_entry.d.ts +1 -1
  12. package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -1
  13. package/dist/commonjs/core/entry/core_entry.js +2 -7
  14. package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  15. package/dist/commonjs/core/entry/core_text_displayer_interface.js +3 -1
  16. package/dist/commonjs/core/entry/index.d.ts +1 -1
  17. package/dist/commonjs/core/entry/index.d.ts.map +1 -1
  18. package/dist/commonjs/core/entry/utils.d.ts +64 -0
  19. package/dist/commonjs/core/entry/utils.d.ts.map +1 -1
  20. package/dist/commonjs/core/entry/utils.js +165 -0
  21. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts +5 -6
  22. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  23. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  24. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +34 -30
  25. package/dist/commonjs/experimental/features/worker/index.d.ts +2 -1
  26. package/dist/commonjs/experimental/features/worker/index.d.ts.map +1 -1
  27. package/dist/commonjs/experimental/features/worker/index.js +4 -3
  28. package/dist/commonjs/main_thread/api/public_api.js +3 -3
  29. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  30. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  31. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  32. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  33. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  34. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  35. package/dist/es2017/core/cmcd/cmcd_data_builder.js +2 -2
  36. package/dist/es2017/core/entry/content_preparer.d.ts +1 -6
  37. package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -1
  38. package/dist/es2017/core/entry/content_preparer.js +1 -76
  39. package/dist/es2017/core/entry/core_entry.d.ts +1 -1
  40. package/dist/es2017/core/entry/core_entry.d.ts.map +1 -1
  41. package/dist/es2017/core/entry/core_entry.js +2 -7
  42. package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  43. package/dist/es2017/core/entry/core_text_displayer_interface.js +3 -1
  44. package/dist/es2017/core/entry/index.d.ts +1 -1
  45. package/dist/es2017/core/entry/index.d.ts.map +1 -1
  46. package/dist/es2017/core/entry/utils.d.ts +64 -0
  47. package/dist/es2017/core/entry/utils.d.ts.map +1 -1
  48. package/dist/es2017/core/entry/utils.js +98 -0
  49. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts +5 -6
  50. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  51. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  52. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +21 -16
  53. package/dist/es2017/experimental/features/worker/index.d.ts +2 -1
  54. package/dist/es2017/experimental/features/worker/index.d.ts.map +1 -1
  55. package/dist/es2017/experimental/features/worker/index.js +2 -3
  56. package/dist/es2017/main_thread/api/public_api.js +3 -3
  57. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  58. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  59. package/dist/mpd-parser.wasm +0 -0
  60. package/dist/worker.js +8 -8
  61. package/package.json +19 -22
  62. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  63. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  64. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +734 -0
  65. package/src/core/adaptive/__tests__/guess_based_chooser.test.ts +5 -2
  66. package/src/core/adaptive/utils/__tests__/bandwidth_estimator.test.ts +117 -0
  67. package/src/core/adaptive/utils/__tests__/last_estimate_storage.test.ts +76 -0
  68. package/src/core/adaptive/utils/__tests__/pending_requests_store.test.ts +5 -2
  69. package/src/core/adaptive/utils/__tests__/representation_score_calculator.test.ts +4 -2
  70. package/src/core/cmcd/__tests__/cmcd_data_builder.test.ts +464 -0
  71. package/src/core/cmcd/cmcd_data_builder.ts +2 -2
  72. package/src/core/entry/__tests__/FreezeResolver.test.ts +1 -1
  73. package/src/core/entry/__tests__/content_time_boundaries_observer.test.ts +1 -2
  74. package/src/core/entry/__tests__/core_text_displayer_interface.test.ts +205 -0
  75. package/src/core/entry/__tests__/get_buffered_data_per_media_buffer.test.ts +95 -0
  76. package/src/core/entry/__tests__/track_choice_setter.test.ts +288 -0
  77. package/src/core/entry/__tests__/utils.test.ts +309 -0
  78. package/src/core/entry/content_preparer.ts +7 -118
  79. package/src/core/entry/core_entry.ts +7 -14
  80. package/src/core/entry/core_text_displayer_interface.ts +3 -1
  81. package/src/core/entry/index.ts +1 -1
  82. package/src/core/entry/utils.ts +151 -0
  83. package/src/core/fetchers/__tests__/cdn_prioritizer.test.ts +166 -0
  84. package/src/core/fetchers/manifest/__tests__/manifest_fetcher.test.ts +803 -0
  85. package/src/core/fetchers/segment/__tests__/segment_fetcher.test.ts +872 -0
  86. package/src/core/fetchers/segment/__tests__/segment_queue.test.ts +557 -0
  87. package/src/core/fetchers/segment/segment_queue.ts +5 -6
  88. package/src/core/fetchers/thumbnails/__tests__/thumbnail_fetcher.test.ts +435 -0
  89. package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +28 -20
  90. package/src/core/fetchers/utils/__tests__/schedule_request.test.ts +331 -0
  91. package/src/core/stream/adaptation/__tests__/get_representations_switch_strategy.test.ts +4 -3
  92. package/src/core/stream/representation/utils/__tests__/append_segment_to_buffer.test.ts +1 -1
  93. package/src/core/stream/representation/utils/__tests__/get_segment_priority.test.ts +1 -1
  94. package/src/core/stream/representation/utils/__tests__/push_init_segment.test.ts +1 -1
  95. package/src/core/stream/representation/utils/__tests__/push_media_segment.test.ts +1 -1
  96. package/src/experimental/features/worker/index.ts +2 -4
  97. package/src/main_thread/api/public_api.ts +3 -3
  98. package/src/mse/__tests__/main_media_source_interface.test.ts +846 -0
  99. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +16 -1
  100. package/src/utils/__tests__/base64.test.ts +159 -191
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
2
  import type { IRepresentation } from "../../../manifest";
3
3
  import GuessBasedChooser from "../guess_based_chooser";
4
4
  import { ABRAlgorithmType } from "../utils/last_estimate_storage";
@@ -74,7 +74,6 @@ describe("GuessBasedChooser", () => {
74
74
  let representations: IRepresentation[];
75
75
 
76
76
  beforeEach(() => {
77
- vi.clearAllMocks();
78
77
  mocks.getMonotonicTimeStamp.mockReturnValue(10000);
79
78
 
80
79
  // Setup mock representations (sorted by bitrate ascending)
@@ -96,6 +95,10 @@ describe("GuessBasedChooser", () => {
96
95
  };
97
96
  });
98
97
 
98
+ afterEach(() => {
99
+ vi.resetAllMocks();
100
+ });
101
+
99
102
  describe("constructor", () => {
100
103
  it("should initialize with correct default values", () => {
101
104
  const chooser = new GuessBasedChooser(mockScoreCalculator, mockPrevEstimate);
@@ -0,0 +1,117 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import BandwidthEstimator from "../bandwidth_estimator";
3
+
4
+ describe("ABR - BandwidthEstimator", () => {
5
+ it("should return undefined if no sample has been added yet", () => {
6
+ const bwEstimator = new BandwidthEstimator();
7
+ expect(bwEstimator.getEstimate()).toBe(undefined);
8
+ });
9
+
10
+ it("should return undefined if not enough bytes has been received", () => {
11
+ const bwEstimator = new BandwidthEstimator();
12
+ bwEstimator.addSample(800, 10);
13
+ expect(bwEstimator.getEstimate()).toBe(undefined);
14
+ bwEstimator.addSample(800, 10);
15
+ expect(bwEstimator.getEstimate()).toBe(undefined);
16
+ bwEstimator.addSample(800, 10);
17
+ expect(bwEstimator.getEstimate()).toBe(undefined);
18
+ bwEstimator.addSample(80000000, 1000000);
19
+ expect(bwEstimator.getEstimate()).toBe(100);
20
+ });
21
+
22
+ it("should calculate bitrate in function of consecutive request' durations and size", () => {
23
+ const bwEstimator = new BandwidthEstimator();
24
+ bwEstimator.addSample(8000, 1000000);
25
+ expect(bwEstimator.getEstimate()).toBe(1000000);
26
+ bwEstimator.addSample(4000, 1000000);
27
+ expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
28
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1400000);
29
+ bwEstimator.addSample(1000, 1000000);
30
+ expect(bwEstimator.getEstimate()).toBeLessThan(3000000);
31
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(2000000);
32
+ });
33
+
34
+ it("should reset the estimation when reset is called", () => {
35
+ const bwEstimator = new BandwidthEstimator();
36
+ bwEstimator.addSample(8000, 1000000);
37
+ bwEstimator.addSample(4000, 1000000);
38
+ bwEstimator.addSample(1000, 1000000);
39
+
40
+ bwEstimator.reset();
41
+ expect(bwEstimator.getEstimate()).toBe(undefined);
42
+ bwEstimator.addSample(8000, 1000000);
43
+ expect(bwEstimator.getEstimate()).toBe(1000000);
44
+ });
45
+
46
+ it("should estimate a low bitrate quicker than a higher one", () => {
47
+ const bwEstimator = new BandwidthEstimator();
48
+
49
+ // 1st test:
50
+ // we raise the bitrate from 1 mega to 2 mega
51
+ // we should slowly go toward 2 megas as an estimate
52
+ bwEstimator.addSample(8000, 1000000); // 1 mega
53
+ bwEstimator.addSample(4000, 1000000); // 2 mega
54
+ expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
55
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1400000);
56
+ bwEstimator.addSample(4000, 1000000);
57
+ expect(bwEstimator.getEstimate()).toBeLessThan(1700000);
58
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1600000);
59
+ bwEstimator.addSample(4000, 1000000);
60
+ expect(bwEstimator.getEstimate()).toBeLessThan(1800000);
61
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1700000);
62
+ bwEstimator.addSample(4000, 1000000);
63
+ expect(bwEstimator.getEstimate()).toBeLessThan(1900000);
64
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1800000);
65
+ bwEstimator.addSample(4000, 1000000);
66
+ expect(bwEstimator.getEstimate()).toBeLessThan(1900000);
67
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1800000);
68
+ bwEstimator.addSample(4000, 1000000); // 6 iterations for 1900000+
69
+ expect(bwEstimator.getEstimate()).toBeLessThan(2000000);
70
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1900000);
71
+
72
+ bwEstimator.reset();
73
+ expect(bwEstimator.getEstimate()).toBe(undefined);
74
+
75
+ // 2st test:
76
+ // we decrease the bitrate from 2 mega to 1 mega
77
+ // we should quickly go to 1 mega
78
+ bwEstimator.addSample(4000, 1000000); // 2 mega
79
+ bwEstimator.addSample(8000, 1000000); // 1 mega - only 1 iteration for sub 1100000!
80
+ expect(bwEstimator.getEstimate()).toBeLessThan(1100000);
81
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1000000);
82
+
83
+ bwEstimator.reset();
84
+ expect(bwEstimator.getEstimate()).toBe(undefined);
85
+
86
+ // 3rd test:
87
+ // we both go up and down, from 5 mega to 10 then to 1 and come back to 10.
88
+ // the 1 mega estimate should have a very perceptible influence, even when
89
+ // going back to 10
90
+ bwEstimator.addSample(2000, 1250000); // 5 mega
91
+ expect(bwEstimator.getEstimate()).toBe(5000000);
92
+ bwEstimator.addSample(2000, 1250100); // 5 mega
93
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(5000000);
94
+ expect(bwEstimator.getEstimate()).toBeLessThan(5010000);
95
+ bwEstimator.addSample(1000, 1250700); // 10 mega
96
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(6000000);
97
+ expect(bwEstimator.getEstimate()).toBeLessThan(6500000);
98
+ bwEstimator.addSample(1000, 1251000); // 10 mega
99
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(6500000);
100
+ expect(bwEstimator.getEstimate()).toBeLessThan(7000000);
101
+ bwEstimator.addSample(10000, 1251000); // 1 mega
102
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(1000000);
103
+ expect(bwEstimator.getEstimate()).toBeLessThan(1500000);
104
+ bwEstimator.addSample(1000, 1250000); // 10 mega
105
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(3000000);
106
+ expect(bwEstimator.getEstimate()).toBeLessThan(3500000);
107
+ bwEstimator.addSample(1000, 1250100); // 10 mega
108
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(3500000);
109
+ expect(bwEstimator.getEstimate()).toBeLessThan(4000000);
110
+ bwEstimator.addSample(1000, 1250100); // 10 mega
111
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(4000000);
112
+ expect(bwEstimator.getEstimate()).toBeLessThan(4500000);
113
+ bwEstimator.addSample(1000, 1250100); // 10 mega
114
+ expect(bwEstimator.getEstimate()).toBeGreaterThan(4500000);
115
+ expect(bwEstimator.getEstimate()).toBeLessThan(5000000);
116
+ });
117
+ });
@@ -0,0 +1,76 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import LastEstimateStorage, { ABRAlgorithmType } from "../last_estimate_storage";
3
+
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
7
+
8
+ describe("LastEstimateStorage", () => {
9
+ let storage: LastEstimateStorage;
10
+
11
+ beforeEach(() => {
12
+ storage = new LastEstimateStorage();
13
+ });
14
+
15
+ describe("initial state", () => {
16
+ it("should initialize bandwidth as undefined", () => {
17
+ expect(storage.bandwidth).toBeUndefined();
18
+ });
19
+
20
+ it("should initialize representation as null", () => {
21
+ expect(storage.representation).toBeNull();
22
+ });
23
+
24
+ it("should initialize algorithmType as ABRAlgorithmType.None", () => {
25
+ expect(storage.algorithmType).toBe(ABRAlgorithmType.None);
26
+ });
27
+ });
28
+
29
+ describe("update()", () => {
30
+ it("should update representation with the provided value", () => {
31
+ const representation = { id: "rep1", bitrate: 1000 } as any;
32
+ storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
33
+ expect(storage.representation).toBe(representation);
34
+ });
35
+
36
+ it("should update bandwidth with the provided value", () => {
37
+ const representation = { id: "rep1", bitrate: 1000 } as any;
38
+ storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
39
+ expect(storage.bandwidth).toBe(500);
40
+ });
41
+
42
+ it("should update algorithmType with the provided value", () => {
43
+ const representation = { id: "rep1", bitrate: 1000 } as any;
44
+ storage.update(representation, 500, ABRAlgorithmType.BandwidthBased);
45
+ expect(storage.algorithmType).toBe(ABRAlgorithmType.BandwidthBased);
46
+ });
47
+
48
+ it("should allow bandwidth to be undefined", () => {
49
+ const representation = { id: "rep1", bitrate: 1000 } as any;
50
+ storage.update(representation, undefined, ABRAlgorithmType.BufferBased);
51
+ expect(storage.bandwidth).toBeUndefined();
52
+ });
53
+
54
+ it("should correctly reflect a BufferBased algorithm type", () => {
55
+ const representation = { id: "rep2" } as any;
56
+ storage.update(representation, 200, ABRAlgorithmType.BufferBased);
57
+ expect(storage.algorithmType).toBe(ABRAlgorithmType.BufferBased);
58
+ });
59
+
60
+ it("should correctly reflect a GuessBased algorithm type", () => {
61
+ const representation = { id: "rep3" } as any;
62
+ storage.update(representation, 300, ABRAlgorithmType.GuessBased);
63
+ expect(storage.algorithmType).toBe(ABRAlgorithmType.GuessBased);
64
+ });
65
+
66
+ it("should overwrite previous values on subsequent updates", () => {
67
+ const rep1 = { id: "rep1" } as any;
68
+ const rep2 = { id: "rep2" } as any;
69
+ storage.update(rep1, 100, ABRAlgorithmType.BandwidthBased);
70
+ storage.update(rep2, 999, ABRAlgorithmType.GuessBased);
71
+ expect(storage.representation).toBe(rep2);
72
+ expect(storage.bandwidth).toBe(999);
73
+ expect(storage.algorithmType).toBe(ABRAlgorithmType.GuessBased);
74
+ });
75
+ });
76
+ });
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, beforeEach, vi } from "vitest";
1
+ import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
2
2
  import PendingRequestsStore from "../pending_requests_store";
3
3
  import type {
4
4
  IPendingRequestStoreBegin,
@@ -57,7 +57,10 @@ describe("PendingRequestsStore", () => {
57
57
 
58
58
  beforeEach(() => {
59
59
  store = new PendingRequestsStore();
60
- vi.clearAllMocks();
60
+ });
61
+
62
+ afterEach(() => {
63
+ vi.resetAllMocks();
61
64
  });
62
65
 
63
66
  describe("add", () => {
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
2
  import type { IRepresentation } from "../../../../manifest";
3
3
  import RepresentationScoreCalculator, {
4
4
  ScoreConfidenceLevel,
@@ -38,7 +38,6 @@ describe("RepresentationScoreCalculator", () => {
38
38
  let mockRepresentation2: IRepresentation;
39
39
 
40
40
  beforeEach(() => {
41
- vi.clearAllMocks();
42
41
  calculator = new RepresentationScoreCalculator();
43
42
 
44
43
  mockRepresentation1 = {
@@ -51,6 +50,9 @@ describe("RepresentationScoreCalculator", () => {
51
50
  bitrate: 2000000,
52
51
  } as IRepresentation;
53
52
  });
53
+ afterEach(() => {
54
+ vi.resetAllMocks();
55
+ });
54
56
 
55
57
  describe("addSample", () => {
56
58
  it("should add a sample for a new representation", () => {