rx-player 4.5.0-dev.2026012302 → 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 (180) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  6. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  7. package/dist/commonjs/compat/should_seek_at_zero.d.ts +12 -0
  8. package/dist/commonjs/compat/should_seek_at_zero.d.ts.map +1 -0
  9. package/dist/commonjs/compat/should_seek_at_zero.js +23 -0
  10. package/dist/commonjs/core/cmcd/cmcd_data_builder.js +2 -2
  11. package/dist/commonjs/core/entry/FreezeResolver.js +2 -2
  12. package/dist/commonjs/core/entry/content_preparer.d.ts +1 -6
  13. package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -1
  14. package/dist/commonjs/core/entry/content_preparer.js +2 -125
  15. package/dist/commonjs/core/entry/content_time_boundaries_observer.d.ts.map +1 -1
  16. package/dist/commonjs/core/entry/content_time_boundaries_observer.js +8 -0
  17. package/dist/commonjs/core/entry/core_entry.d.ts +1 -1
  18. package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -1
  19. package/dist/commonjs/core/entry/core_entry.js +2 -7
  20. package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  21. package/dist/commonjs/core/entry/core_text_displayer_interface.js +3 -1
  22. package/dist/commonjs/core/entry/index.d.ts +1 -1
  23. package/dist/commonjs/core/entry/index.d.ts.map +1 -1
  24. package/dist/commonjs/core/entry/utils.d.ts +64 -0
  25. package/dist/commonjs/core/entry/utils.d.ts.map +1 -1
  26. package/dist/commonjs/core/entry/utils.js +165 -0
  27. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts +5 -6
  28. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  29. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  30. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +34 -30
  31. package/dist/commonjs/core/stream/representation/encryption_data_notifier.d.ts +70 -0
  32. package/dist/commonjs/core/stream/representation/encryption_data_notifier.d.ts.map +1 -0
  33. package/dist/commonjs/core/stream/representation/encryption_data_notifier.js +107 -0
  34. package/dist/commonjs/core/stream/representation/representation_stream.d.ts.map +1 -1
  35. package/dist/commonjs/core/stream/representation/representation_stream.js +12 -60
  36. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  37. package/dist/commonjs/default_config.d.ts +5 -0
  38. package/dist/commonjs/default_config.d.ts.map +1 -1
  39. package/dist/commonjs/default_config.js +5 -0
  40. package/dist/commonjs/experimental/features/worker/index.d.ts +2 -1
  41. package/dist/commonjs/experimental/features/worker/index.d.ts.map +1 -1
  42. package/dist/commonjs/experimental/features/worker/index.js +4 -3
  43. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  44. package/dist/commonjs/main_thread/api/public_api.js +28 -4
  45. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  46. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +23 -1
  47. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  48. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +3 -1
  49. package/dist/commonjs/manifest/classes/index.d.ts +2 -1
  50. package/dist/commonjs/manifest/classes/index.d.ts.map +1 -1
  51. package/dist/commonjs/manifest/classes/representation.d.ts +1 -1
  52. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  53. package/dist/commonjs/manifest/classes/representation.js +2 -2
  54. package/dist/commonjs/manifest/classes/representation_index/types.d.ts +2 -2
  55. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  56. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  57. package/dist/commonjs/utils/base64.d.ts +15 -1
  58. package/dist/commonjs/utils/base64.d.ts.map +1 -1
  59. package/dist/commonjs/utils/base64.js +6 -0
  60. package/dist/commonjs/utils/ranges.d.ts +1 -1
  61. package/dist/commonjs/utils/ranges.js +1 -1
  62. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  63. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  64. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  65. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  66. package/dist/es2017/compat/should_seek_at_zero.d.ts +12 -0
  67. package/dist/es2017/compat/should_seek_at_zero.d.ts.map +1 -0
  68. package/dist/es2017/compat/should_seek_at_zero.js +20 -0
  69. package/dist/es2017/core/cmcd/cmcd_data_builder.js +2 -2
  70. package/dist/es2017/core/entry/FreezeResolver.js +1 -1
  71. package/dist/es2017/core/entry/content_preparer.d.ts +1 -6
  72. package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -1
  73. package/dist/es2017/core/entry/content_preparer.js +1 -76
  74. package/dist/es2017/core/entry/content_time_boundaries_observer.d.ts.map +1 -1
  75. package/dist/es2017/core/entry/content_time_boundaries_observer.js +8 -0
  76. package/dist/es2017/core/entry/core_entry.d.ts +1 -1
  77. package/dist/es2017/core/entry/core_entry.d.ts.map +1 -1
  78. package/dist/es2017/core/entry/core_entry.js +2 -7
  79. package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  80. package/dist/es2017/core/entry/core_text_displayer_interface.js +3 -1
  81. package/dist/es2017/core/entry/index.d.ts +1 -1
  82. package/dist/es2017/core/entry/index.d.ts.map +1 -1
  83. package/dist/es2017/core/entry/utils.d.ts +64 -0
  84. package/dist/es2017/core/entry/utils.d.ts.map +1 -1
  85. package/dist/es2017/core/entry/utils.js +98 -0
  86. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts +5 -6
  87. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  88. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  89. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +21 -16
  90. package/dist/es2017/core/stream/representation/encryption_data_notifier.d.ts +70 -0
  91. package/dist/es2017/core/stream/representation/encryption_data_notifier.d.ts.map +1 -0
  92. package/dist/es2017/core/stream/representation/encryption_data_notifier.js +80 -0
  93. package/dist/es2017/core/stream/representation/representation_stream.d.ts.map +1 -1
  94. package/dist/es2017/core/stream/representation/representation_stream.js +10 -38
  95. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  96. package/dist/es2017/default_config.d.ts +5 -0
  97. package/dist/es2017/default_config.d.ts.map +1 -1
  98. package/dist/es2017/default_config.js +5 -0
  99. package/dist/es2017/experimental/features/worker/index.d.ts +2 -1
  100. package/dist/es2017/experimental/features/worker/index.d.ts.map +1 -1
  101. package/dist/es2017/experimental/features/worker/index.js +2 -3
  102. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  103. package/dist/es2017/main_thread/api/public_api.js +28 -4
  104. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  105. package/dist/es2017/main_thread/init/directfile_content_initializer.js +23 -1
  106. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  107. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +3 -1
  108. package/dist/es2017/manifest/classes/index.d.ts +2 -1
  109. package/dist/es2017/manifest/classes/index.d.ts.map +1 -1
  110. package/dist/es2017/manifest/classes/representation.d.ts +1 -1
  111. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  112. package/dist/es2017/manifest/classes/representation.js +1 -1
  113. package/dist/es2017/manifest/classes/representation_index/types.d.ts +2 -2
  114. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  115. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  116. package/dist/es2017/utils/base64.d.ts +15 -1
  117. package/dist/es2017/utils/base64.d.ts.map +1 -1
  118. package/dist/es2017/utils/base64.js +6 -0
  119. package/dist/es2017/utils/ranges.d.ts +1 -1
  120. package/dist/es2017/utils/ranges.js +1 -1
  121. package/dist/mpd-parser.wasm +0 -0
  122. package/dist/worker.js +8 -8
  123. package/package.json +26 -23
  124. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  125. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  126. package/src/compat/should_seek_at_zero.ts +23 -0
  127. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +734 -0
  128. package/src/core/adaptive/__tests__/guess_based_chooser.test.ts +793 -0
  129. package/src/core/adaptive/__tests__/network_analyzer.test.ts +514 -0
  130. package/src/core/adaptive/utils/__tests__/bandwidth_estimator.test.ts +117 -0
  131. package/src/core/adaptive/utils/__tests__/last_estimate_storage.test.ts +76 -0
  132. package/src/core/adaptive/utils/__tests__/pending_requests_store.test.ts +288 -0
  133. package/src/core/adaptive/utils/__tests__/representation_score_calculator.test.ts +249 -0
  134. package/src/core/cmcd/__tests__/cmcd_data_builder.test.ts +464 -0
  135. package/src/core/cmcd/cmcd_data_builder.ts +2 -2
  136. package/src/core/entry/FreezeResolver.ts +1 -1
  137. package/src/core/entry/__tests__/FreezeResolver.test.ts +542 -0
  138. package/src/core/entry/__tests__/content_time_boundaries_observer.test.ts +867 -0
  139. package/src/core/entry/__tests__/core_text_displayer_interface.test.ts +205 -0
  140. package/src/core/entry/__tests__/get_buffered_data_per_media_buffer.test.ts +95 -0
  141. package/src/core/entry/__tests__/track_choice_setter.test.ts +288 -0
  142. package/src/core/entry/__tests__/utils.test.ts +309 -0
  143. package/src/core/entry/content_preparer.ts +7 -118
  144. package/src/core/entry/content_time_boundaries_observer.ts +10 -0
  145. package/src/core/entry/core_entry.ts +7 -14
  146. package/src/core/entry/core_text_displayer_interface.ts +3 -1
  147. package/src/core/entry/index.ts +1 -1
  148. package/src/core/entry/utils.ts +151 -0
  149. package/src/core/fetchers/__tests__/cdn_prioritizer.test.ts +166 -0
  150. package/src/core/fetchers/manifest/__tests__/manifest_fetcher.test.ts +803 -0
  151. package/src/core/fetchers/segment/__tests__/segment_fetcher.test.ts +872 -0
  152. package/src/core/fetchers/segment/__tests__/segment_queue.test.ts +557 -0
  153. package/src/core/fetchers/segment/segment_queue.ts +5 -6
  154. package/src/core/fetchers/thumbnails/__tests__/thumbnail_fetcher.test.ts +435 -0
  155. package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +28 -20
  156. package/src/core/fetchers/utils/__tests__/schedule_request.test.ts +331 -0
  157. package/src/core/stream/adaptation/__tests__/get_representations_switch_strategy.test.ts +593 -0
  158. package/src/core/stream/period/utils/__tests__/get_adaptation_switch_strategy.test.ts +646 -0
  159. package/src/core/stream/representation/__tests__/encryption_data_notifier.test.ts +531 -0
  160. package/src/core/stream/representation/encryption_data_notifier.ts +122 -0
  161. package/src/core/stream/representation/representation_stream.ts +11 -49
  162. package/src/core/stream/representation/utils/__tests__/append_segment_to_buffer.test.ts +321 -0
  163. package/src/core/stream/representation/utils/__tests__/check_for_discontinuity.test.ts +513 -0
  164. package/src/core/stream/representation/utils/__tests__/get_segment_priority.test.ts +132 -0
  165. package/src/core/stream/representation/utils/__tests__/push_init_segment.test.ts +209 -0
  166. package/src/core/stream/representation/utils/__tests__/push_media_segment.test.ts +343 -0
  167. package/src/core/stream/representation/utils/get_needed_segments.ts +1 -1
  168. package/src/default_config.ts +6 -0
  169. package/src/experimental/features/worker/index.ts +2 -4
  170. package/src/main_thread/api/public_api.ts +33 -4
  171. package/src/main_thread/init/directfile_content_initializer.ts +26 -1
  172. package/src/main_thread/init/utils/initial_seek_and_play.ts +5 -1
  173. package/src/manifest/classes/index.ts +2 -0
  174. package/src/manifest/classes/representation.ts +2 -1
  175. package/src/manifest/classes/representation_index/types.ts +2 -2
  176. package/src/mse/__tests__/main_media_source_interface.test.ts +846 -0
  177. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +16 -1
  178. package/src/utils/__tests__/base64.test.ts +159 -191
  179. package/src/utils/base64.ts +30 -1
  180. package/src/utils/ranges.ts +1 -1
@@ -1,7 +1,55 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.formatErrorForSender = formatErrorForSender;
40
+ exports.synchronizeSegmentSinksOnObservation = synchronizeSegmentSinksOnObservation;
41
+ exports.updateCodecSupportInWorkerMode = updateCodecSupportInWorkerMode;
42
+ exports.extractExternalPlugins = extractExternalPlugins;
43
+ var browser_compatibility_types_1 = require("../../compat/browser_compatibility_types");
4
44
  var errors_1 = require("../../errors");
45
+ var manifest_1 = require("../../manifest");
46
+ var is_null_or_undefined_1 = require("../../utils/is_null_or_undefined");
47
+ /**
48
+ * Format an error, which may be of any form, into an Object than can easily be
49
+ * serialized - e.g. to be communicated through a postMessage-like API.
50
+ * @param {*} error - The error to serialized
51
+ * @returns {Object} - A serialization-safe error format
52
+ */
5
53
  function formatErrorForSender(error) {
6
54
  var formattedError = (0, errors_1.formatError)(error, {
7
55
  defaultCode: "NONE",
@@ -9,3 +57,120 @@ function formatErrorForSender(error) {
9
57
  });
10
58
  return formattedError.serialize();
11
59
  }
60
+ /**
61
+ * Synchronize SegmentSinks with what has been buffered.
62
+ * @param {Object} observation - The just-received playback observation,
63
+ * including what has been buffered on lower-level buffers
64
+ * @param {Object} segmentSinksStore - Interface allowing to interact
65
+ * with `SegmentSink`s, so their inventory can be updated accordingly.
66
+ */
67
+ function synchronizeSegmentSinksOnObservation(observation, segmentSinksStore) {
68
+ // Synchronize SegmentSinks with what has been buffered.
69
+ ["video", "audio", "text"].forEach(function (tType) {
70
+ var _a;
71
+ var segmentSinkStatus = segmentSinksStore.getStatus(tType);
72
+ if (segmentSinkStatus.type === "initialized") {
73
+ segmentSinkStatus.value.synchronizeInventory((_a = observation.buffered[tType]) !== null && _a !== void 0 ? _a : []);
74
+ }
75
+ });
76
+ }
77
+ /**
78
+ * Set Representation.isCodecSupportedInWebWorker to true or false
79
+ * If the codec is supported in the current context.
80
+ * If MSE in worker is not available, the attribute is not set.
81
+ */
82
+ function updateCodecSupportInWorkerMode(manifestToUpdate) {
83
+ var e_1, _a, e_2, _b, e_3, _c;
84
+ var _d, _e;
85
+ if ((0, is_null_or_undefined_1.default)(browser_compatibility_types_1.MediaSource_)) {
86
+ return;
87
+ }
88
+ var codecsMap = new Map();
89
+ try {
90
+ for (var _f = __values(manifestToUpdate.periods), _g = _f.next(); !_g.done; _g = _f.next()) {
91
+ var period = _g.value;
92
+ var checkedAdaptations = __spreadArray(__spreadArray([], __read(((_d = period.adaptations.video) !== null && _d !== void 0 ? _d : [])), false), __read(((_e = period.adaptations.audio) !== null && _e !== void 0 ? _e : [])), false);
93
+ try {
94
+ for (var checkedAdaptations_1 = (e_2 = void 0, __values(checkedAdaptations)), checkedAdaptations_1_1 = checkedAdaptations_1.next(); !checkedAdaptations_1_1.done; checkedAdaptations_1_1 = checkedAdaptations_1.next()) {
95
+ var adaptation = checkedAdaptations_1_1.value;
96
+ try {
97
+ for (var _h = (e_3 = void 0, __values(adaptation.representations)), _j = _h.next(); !_j.done; _j = _h.next()) {
98
+ var representation = _j.value;
99
+ var codec = "".concat(representation.mimeType, ";codecs=\"").concat(representation.codecs[0], "\"");
100
+ if (codecsMap.has(codec)) {
101
+ representation.isCodecSupportedInWebWorker = codecsMap.get(codec);
102
+ }
103
+ else {
104
+ var supported = browser_compatibility_types_1.MediaSource_.isTypeSupported(codec);
105
+ representation.isCodecSupportedInWebWorker = supported;
106
+ codecsMap.set(codec, supported);
107
+ }
108
+ }
109
+ }
110
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
111
+ finally {
112
+ try {
113
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
114
+ }
115
+ finally { if (e_3) throw e_3.error; }
116
+ }
117
+ }
118
+ }
119
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
120
+ finally {
121
+ try {
122
+ if (checkedAdaptations_1_1 && !checkedAdaptations_1_1.done && (_b = checkedAdaptations_1.return)) _b.call(checkedAdaptations_1);
123
+ }
124
+ finally { if (e_2) throw e_2.error; }
125
+ }
126
+ }
127
+ }
128
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
129
+ finally {
130
+ try {
131
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
132
+ }
133
+ finally { if (e_1) throw e_1.error; }
134
+ }
135
+ }
136
+ /**
137
+ * Some functions may be defined by the API, we call those "plugins".
138
+ * This function parses and extract the actual function from the different
139
+ * ways an application can provide it to us.
140
+ * @param {Object} input - The API input
141
+ * @param {Object} corePlugins - Context on what identified functions are
142
+ * defined right now.
143
+ * @returns {Function}
144
+ */
145
+ function extractExternalPlugins(input, corePlugins) {
146
+ var _a, _b, _c, _d, _e, _f, _g;
147
+ var manifestLoader;
148
+ var segmentLoader;
149
+ var representationFilter;
150
+ if (typeof ((_a = input.representationFilter) === null || _a === void 0 ? void 0 : _a.fn) === "function") {
151
+ representationFilter = input.representationFilter.fn;
152
+ }
153
+ else if (typeof ((_b = input.representationFilter) === null || _b === void 0 ? void 0 : _b.eval) === "string") {
154
+ representationFilter = (0, manifest_1.createRepresentationFilterFromFnString)(input.representationFilter.eval);
155
+ }
156
+ else if (typeof ((_c = input.representationFilter) === null || _c === void 0 ? void 0 : _c.workerId) === "string") {
157
+ representationFilter = corePlugins.representationFilters.get(input.representationFilter.workerId);
158
+ }
159
+ if (typeof ((_d = input.manifestLoader) === null || _d === void 0 ? void 0 : _d.fn) === "function") {
160
+ manifestLoader = input.manifestLoader.fn;
161
+ }
162
+ else if (typeof ((_e = input.manifestLoader) === null || _e === void 0 ? void 0 : _e.workerId) === "string") {
163
+ manifestLoader = corePlugins.manifestLoaders.get(input.manifestLoader.workerId);
164
+ }
165
+ if (typeof ((_f = input.segmentLoader) === null || _f === void 0 ? void 0 : _f.fn) === "function") {
166
+ segmentLoader = input.segmentLoader.fn;
167
+ }
168
+ else if (typeof ((_g = input.segmentLoader) === null || _g === void 0 ? void 0 : _g.workerId) === "string") {
169
+ segmentLoader = corePlugins.segmentLoaders.get(input.segmentLoader.workerId);
170
+ }
171
+ return {
172
+ manifestLoader: manifestLoader,
173
+ segmentLoader: segmentLoader,
174
+ representationFilter: representationFilter,
175
+ };
176
+ }
@@ -141,8 +141,8 @@ export interface ISegmentQueueEvent<T> {
141
141
  * You can now push that segment to its corresponding buffer and use its parsed
142
142
  * metadata.
143
143
  *
144
- * Only sent if an initialization segment exists (when the `SegmentQueue`'s
145
- * `hasInitSegment` constructor option has been set to `true`).
144
+ * Only sent if an initialization segment exists (when the `hasInitSegment`
145
+ * option has been set to `true`).
146
146
  * In that case, an `IParsedInitSegmentEvent` will always be sent before any
147
147
  * `IParsedSegmentEvent` event is sent.
148
148
  */
@@ -151,10 +151,9 @@ export interface ISegmentQueueEvent<T> {
151
151
  * Notify that a media chunk (decodable sub-part of a media segment) has been
152
152
  * loaded and parsed.
153
153
  *
154
- * If an initialization segment exists (when the `SegmentQueue`'s
155
- * `hasInitSegment` constructor option has been set to `true`), an
156
- * `IParsedSegmentEvent` will always be sent AFTER the `IParsedInitSegmentEvent`
157
- * event.
154
+ * If an initialization segment exists (when the `hasInitSegment` option has
155
+ * been set to `true`), an `IParsedSegmentEvent` will always be sent AFTER
156
+ * the `IParsedInitSegmentEvent` event.
158
157
  *
159
158
  * It can now be pushed to its corresponding buffer. Note that there might be
160
159
  * multiple `IParsedSegmentEvent` for a single segment, if that segment is
@@ -1 +1 @@
1
- {"version":3,"file":"segment_queue.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,6BAA6B,EAC7B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAGxD,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC9E,uCAAuC;IACvC,OAAO,CAAC,eAAe,CAAgC;IAEvD;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAAkC;IAE7D;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,8BAA8B,CAA2B;IAEjE;;;;;;;OAOG;gBAED,cAAc,EAAE,0BAA0B,CAAC,CAAC,CAAC,EAC7C,8BAA8B,EAAE,eAAe,CAAC,OAAO,CAAC;IAQ1D;;;;OAIG;IACI,uBAAuB,IAAI,QAAQ,GAAG,IAAI;IAIjD;;;;OAIG;IACI,wBAAwB,IAAI,QAAQ,GAAG,IAAI;IAIlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACI,eAAe,CACpB,OAAO,EAAE,oBAAoB,EAC7B,cAAc,EAAE,OAAO,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,eAAe,CAAC,iBAAiB,CAAC;IA0IrC;;;;;;;OAOG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAKtC;;;;;OAKG;IACH,OAAO,CAAC,oCAAoC;IA4L5C;;;;;;;OAOG;IACH,OAAO,CAAC,mCAAmC;CAuF5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;;;;;;;;OAUG;IACH,iBAAiB,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAChD;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7C,2EAA2E;IAC3E,kBAAkB,EAAE,QAAQ,CAAC;IAC7B;;;OAGG;IACH,YAAY,EAAE,oBAAoB,CAAC;IACnC;;;OAGG;IACH,UAAU,EAAE,IAAI,CAAC;IACjB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,+CAA+C;AAC/C,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,6BAA6B,CAAC,CAAC,CAAC,GAAG;IAC5E,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AACF,gDAAgD;AAChD,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,8BAA8B,CAAC,CAAC,CAAC,GAAG;IACzE,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AACF,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;OAUG;IACH,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IAEnC;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAcD,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,UAAU,EAAE,WAAW,CAAC;IACxB,wDAAwD;IACxD,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,cAAc,EAAE,eAAe,CAAC;CACjC"}
1
+ {"version":3,"file":"segment_queue.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_queue.ts"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"thumbnail_fetcher.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/thumbnails/thumbnail_fetcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAGV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AAIrD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB;AAC5C,gEAAgE;AAChE,QAAQ,EAAE,kBAAkB;AAC5B;;;;;;;GAOG;AACH,cAAc,EAAE,cAAc,GAAG,IAAI,GAEpC,iBAAiB,CAsNnB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;AAC9B,gDAAgD;AAChD,gBAAgB,EAAE;IAChB,2BAA2B;IAC3B,OAAO,EAAE,QAAQ,CAAC;IAClB,+CAA+C;IAC/C,KAAK,EAAE,eAAe,CAAC;IACvB,kEAAkE;IAClE,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,yDAAyD;AACzD,kBAAkB,EAAE,kBAAkB,KACnC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,8EAA8E;AAC9E,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC"}
1
+ {"version":3,"file":"thumbnail_fetcher.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/thumbnails/thumbnail_fetcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAIV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AAIrD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB;AAC5C,gEAAgE;AAChE,QAAQ,EAAE,kBAAkB;AAC5B;;;;;;;GAOG;AACH,cAAc,EAAE,cAAc,GAAG,IAAI,GAEpC,iBAAiB,CA6NnB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;AAC9B,gDAAgD;AAChD,gBAAgB,EAAE;IAChB,2BAA2B;IAC3B,OAAO,EAAE,QAAQ,CAAC;IAClB,+CAA+C;IAC/C,KAAK,EAAE,eAAe,CAAC;IACvB,kEAAkE;IAClE,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,yDAAyD;AACzD,kBAAkB,EAAE,kBAAkB,KACnC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,8EAA8E;AAC9E,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC"}
@@ -82,9 +82,9 @@ cdnPrioritizer) {
82
82
  */
83
83
  return function fetchThumbnail(thumbnailContext, cancellationSignal) {
84
84
  return __awaiter(this, void 0, void 0, function () {
85
- function doFetch() {
85
+ function fetchThumbnailStep() {
86
86
  return __awaiter(this, void 0, void 0, function () {
87
- var res, err_3, parsed;
87
+ var res, err_3;
88
88
  return __generator(this, function (_a) {
89
89
  switch (_a.label) {
90
90
  case 0:
@@ -95,42 +95,37 @@ cdnPrioritizer) {
95
95
  return [4 /*yield*/, (0, schedule_request_1.scheduleRequestWithCdns)(thumbnailTrack.cdnMetadata, cdnPrioritizer, callLoaderWithUrl, (0, object_assign_1.default)({ onRetry: onRetry }, requestOptions), requestCanceller.signal)];
96
96
  case 2:
97
97
  res = _a.sent();
98
- if (cancellationSignal.isCancelled()) {
99
- return [2 /*return*/, Promise.reject(cancellationSignal.cancellationError)];
100
- }
101
98
  log_1.default.debug("Thumbnails", "Thumbnail request ended with success", {
102
99
  time: thumbnail.time,
103
100
  });
104
- cancellationSignal.deregister(onCancellation);
105
- return [3 /*break*/, 4];
101
+ return [2 /*return*/, res];
106
102
  case 3:
107
103
  err_3 = _a.sent();
108
- cancellationSignal.deregister(onCancellation);
109
104
  if (err_3 instanceof task_canceller_1.CancellationError) {
110
105
  log_1.default.debug("Thumbnails", "Thumbnail request aborted", { time: thumbnail.time });
111
106
  throw err_3;
112
107
  }
113
108
  log_1.default.debug("Thumbnails", "Thumbnail request failed", { time: thumbnail.time });
114
109
  throw (0, error_selector_1.default)(err_3);
115
- case 4:
116
- try {
117
- parsed = pipeline.parseThumbnail(res.responseData, {
118
- thumbnail: thumbnail,
119
- thumbnailTrack: thumbnailTrack,
120
- });
121
- return [2 /*return*/, parsed];
122
- }
123
- catch (error) {
124
- throw (0, errors_1.formatError)(error, {
125
- defaultCode: "PIPELINE_PARSE_ERROR",
126
- defaultReason: "Unknown parsing error",
127
- });
128
- }
129
- return [2 /*return*/];
110
+ case 4: return [2 /*return*/];
130
111
  }
131
112
  });
132
113
  });
133
114
  }
115
+ function parseThumbnailStep(rawResponse) {
116
+ try {
117
+ return pipeline.parseThumbnail(rawResponse.responseData, {
118
+ thumbnail: thumbnail,
119
+ thumbnailTrack: thumbnailTrack,
120
+ });
121
+ }
122
+ catch (error) {
123
+ throw (0, errors_1.formatError)(error, {
124
+ defaultCode: "PIPELINE_PARSE_ERROR",
125
+ defaultReason: "Unknown parsing error",
126
+ });
127
+ }
128
+ }
134
129
  function onCancellation() {
135
130
  log_1.default.debug("Thumbnails", "Thumbnail request cancelled", { time: thumbnail.time });
136
131
  var requestIdx = pendingRequestsInfo.indexOf(currRequestInfo);
@@ -161,11 +156,12 @@ cdnPrioritizer) {
161
156
  time: thumbnail.time,
162
157
  }, formattedErr);
163
158
  }
164
- var currRequestInfo, pendingInfo, response, err_1, thumbnail, thumbnailTrack, requestOptions, connectionTimeout, pipelineRequestOptions, requestCanceller, fetchPromise, clearRequestInfo, fetchResult, err_2;
159
+ var thumbnail, thumbnailTrack, currRequestInfo, pendingInfo, response, err_1, requestOptions, connectionTimeout, pipelineRequestOptions, requestCanceller, fetchPromise, clearRequestInfo, fetchResult, err_2;
165
160
  return __generator(this, function (_a) {
166
161
  switch (_a.label) {
167
162
  case 0:
168
163
  cancellationSignal.register(onCancellation);
164
+ thumbnail = thumbnailContext.segment, thumbnailTrack = thumbnailContext.track;
169
165
  pendingInfo = (0, array_find_1.default)(pendingRequestsInfo, function (_a) {
170
166
  var pCtxt = _a.thumbnailContext;
171
167
  return (pCtxt.period.id === thumbnailContext.period.id &&
@@ -192,9 +188,11 @@ cdnPrioritizer) {
192
188
  throw err_1;
193
189
  case 4:
194
190
  cancellationSignal.deregister(onCancellation);
195
- return [2 /*return*/, response];
191
+ if (cancellationSignal.isCancelled()) {
192
+ throw cancellationSignal.cancellationError;
193
+ }
194
+ return [2 /*return*/, parseThumbnailStep(response)];
196
195
  case 5:
197
- thumbnail = thumbnailContext.segment, thumbnailTrack = thumbnailContext.track;
198
196
  requestOptions = getThumbnailFetcherRequestOptions({});
199
197
  if (requestOptions.connectionTimeout === undefined ||
200
198
  requestOptions.connectionTimeout < 0) {
@@ -209,7 +207,7 @@ cdnPrioritizer) {
209
207
  cmcdPayload: undefined,
210
208
  };
211
209
  requestCanceller = new task_canceller_1.default("Thumbnail request");
212
- fetchPromise = doFetch();
210
+ fetchPromise = fetchThumbnailStep();
213
211
  currRequestInfo = {
214
212
  thumbnailContext: thumbnailContext,
215
213
  promise: fetchPromise,
@@ -228,13 +226,19 @@ cdnPrioritizer) {
228
226
  return [4 /*yield*/, fetchPromise];
229
227
  case 7:
230
228
  fetchResult = _a.sent();
231
- clearRequestInfo();
232
- return [2 /*return*/, fetchResult];
229
+ return [3 /*break*/, 9];
233
230
  case 8:
234
231
  err_2 = _a.sent();
235
232
  clearRequestInfo();
233
+ cancellationSignal.deregister(onCancellation);
236
234
  throw err_2;
237
- case 9: return [2 /*return*/];
235
+ case 9:
236
+ clearRequestInfo();
237
+ cancellationSignal.deregister(onCancellation);
238
+ if (cancellationSignal.isCancelled()) {
239
+ throw cancellationSignal.cancellationError;
240
+ }
241
+ return [2 /*return*/, parseThumbnailStep(fetchResult)];
238
242
  }
239
243
  });
240
244
  });
@@ -0,0 +1,70 @@
1
+ import type { Representation, IRepresentationProtectionData } from "../../../manifest/classes";
2
+ import type { IProtectionDataInfo } from "../../../transports";
3
+ /**
4
+ * Manages the one-time notification of encryption/DRM data for a Representation.
5
+ *
6
+ * This class collects encryption data from parsed segments and ensures that
7
+ * the encryption notification callback is triggered exactly once, as soon as
8
+ * sufficient data is available.
9
+ *
10
+ * The notification may occur in two ways:
11
+ * 1. **Early notification** (constructor): If the DRM system ID is known and
12
+ * complete encryption data (with all key IDs) is already available, the
13
+ * notification is sent immediately to enable faster license negotiation.
14
+ * 2. **Deferred notification** (onNewProtectionData): If early notification
15
+ * doesn't occur, encryption data is collected from parsed segments and
16
+ * the notification is sent once any encryption data becomes available.
17
+ *
18
+ * @example
19
+ * const notifier = new EncryptionDataNotifier({
20
+ * drmSystemId: "edef8ba979d64acea3c827dcd51d21ed",
21
+ * representation,
22
+ * notify: (data) => callbacks.encryptionDataEncountered(data),
23
+ * });
24
+ *
25
+ * // Later, when a segment is parsed:
26
+ * notifier.onNewProtectionData(parsedSegmentEvent.protectionData);
27
+ */
28
+ export default class EncryptionDataNotifier {
29
+ /**
30
+ * If `true` encryption data has already been sent through this
31
+ * `EncryptionDataNotifier`.
32
+ *
33
+ * For now we only send encryption data once per notifier at most as it was
34
+ * historically the only encountered case (encryption data in initialization
35
+ * segment).
36
+ * TODO: remove rule?
37
+ */
38
+ private _hasSentEncryptionData;
39
+ /**
40
+ * `Representation` linked to that `EncryptionDataNotifier`. Might be mutated
41
+ * to add encryption data information.
42
+ */
43
+ private _representation;
44
+ /** Callback to call when encryption information is first encountered. */
45
+ private _notify;
46
+ /**
47
+ * Create a new `EncryptionDataNotifier`.
48
+ * @param {Object} param0
49
+ * @param {string|undefined} param0.drmSystemId - If known the ID in hex
50
+ * format of the used DRM system (playready, widevine etc.).
51
+ * @param {Object} param0.representation - Object describing the
52
+ * Representation (including protection-related information). New encryption
53
+ * data might be added to it by this class.
54
+ * @param {Function} param0.notify - Function that will be called once new
55
+ * protection data has been detected.
56
+ */
57
+ constructor({ drmSystemId, representation, notify, }: {
58
+ drmSystemId: string | undefined;
59
+ representation: Representation;
60
+ notify: (contentProtections: IRepresentationProtectionData[]) => void;
61
+ });
62
+ /**
63
+ * Signal that new protection data information is available.
64
+ * If necessary, that data will be added to the Representation and sent
65
+ * through the `notifiy` callback passed in constructor.
66
+ * @param {Array.<Object>} data - The new protection data encountered.
67
+ */
68
+ onNewProtectionData(data: IProtectionDataInfo[]): void;
69
+ }
70
+ //# sourceMappingURL=encryption_data_notifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption_data_notifier.d.ts","sourceRoot":"","sources":["../../../../../src/core/stream/representation/encryption_data_notifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACzC;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB,CAAU;IACxC;;;OAGG;IACH,OAAO,CAAC,eAAe,CAAiB;IACxC,yEAAyE;IACzE,OAAO,CAAC,OAAO,CAAgE;IAE/E;;;;;;;;;;OAUG;gBACS,EACV,WAAW,EACX,cAAc,EACd,MAAM,GACP,EAAE;QACD,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,cAAc,EAAE,cAAc,CAAC;QAC/B,MAAM,EAAE,CAAC,kBAAkB,EAAE,6BAA6B,EAAE,KAAK,IAAI,CAAC;KACvE;IAuBD;;;;;OAKG;IACI,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,IAAI;CAuB9D"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ /**
15
+ * Manages the one-time notification of encryption/DRM data for a Representation.
16
+ *
17
+ * This class collects encryption data from parsed segments and ensures that
18
+ * the encryption notification callback is triggered exactly once, as soon as
19
+ * sufficient data is available.
20
+ *
21
+ * The notification may occur in two ways:
22
+ * 1. **Early notification** (constructor): If the DRM system ID is known and
23
+ * complete encryption data (with all key IDs) is already available, the
24
+ * notification is sent immediately to enable faster license negotiation.
25
+ * 2. **Deferred notification** (onNewProtectionData): If early notification
26
+ * doesn't occur, encryption data is collected from parsed segments and
27
+ * the notification is sent once any encryption data becomes available.
28
+ *
29
+ * @example
30
+ * const notifier = new EncryptionDataNotifier({
31
+ * drmSystemId: "edef8ba979d64acea3c827dcd51d21ed",
32
+ * representation,
33
+ * notify: (data) => callbacks.encryptionDataEncountered(data),
34
+ * });
35
+ *
36
+ * // Later, when a segment is parsed:
37
+ * notifier.onNewProtectionData(parsedSegmentEvent.protectionData);
38
+ */
39
+ var EncryptionDataNotifier = /** @class */ (function () {
40
+ /**
41
+ * Create a new `EncryptionDataNotifier`.
42
+ * @param {Object} param0
43
+ * @param {string|undefined} param0.drmSystemId - If known the ID in hex
44
+ * format of the used DRM system (playready, widevine etc.).
45
+ * @param {Object} param0.representation - Object describing the
46
+ * Representation (including protection-related information). New encryption
47
+ * data might be added to it by this class.
48
+ * @param {Function} param0.notify - Function that will be called once new
49
+ * protection data has been detected.
50
+ */
51
+ function EncryptionDataNotifier(_a) {
52
+ var drmSystemId = _a.drmSystemId, representation = _a.representation, notify = _a.notify;
53
+ this._hasSentEncryptionData = false;
54
+ this._representation = representation;
55
+ this._notify = notify;
56
+ // If the DRM system id is already known, and if we already have encryption data
57
+ // for it, we may not need to wait until the initialization segment is loaded to
58
+ // signal required protection data, thus performing License negotiations sooner
59
+ if (drmSystemId !== undefined) {
60
+ var encryptionData = representation.getEncryptionData(drmSystemId);
61
+ // If some key ids are not known yet, it may be safer to wait for this initialization
62
+ // segment to be loaded first
63
+ if (encryptionData.length > 0 &&
64
+ encryptionData.every(function (e) { return e.keyIds !== undefined; })) {
65
+ this._hasSentEncryptionData = true;
66
+ notify(encryptionData);
67
+ }
68
+ }
69
+ }
70
+ /**
71
+ * Signal that new protection data information is available.
72
+ * If necessary, that data will be added to the Representation and sent
73
+ * through the `notifiy` callback passed in constructor.
74
+ * @param {Array.<Object>} data - The new protection data encountered.
75
+ */
76
+ EncryptionDataNotifier.prototype.onNewProtectionData = function (data) {
77
+ var e_1, _a;
78
+ try {
79
+ // Supplementary encryption information might have been parsed.
80
+ for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
81
+ var protInfo = data_1_1.value;
82
+ // TODO better handle use cases like key rotation by not always grouping
83
+ // every protection data together? To check.
84
+ this._representation.addProtectionData(protInfo.initDataType, protInfo.keyId, protInfo.initData);
85
+ }
86
+ }
87
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
88
+ finally {
89
+ try {
90
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
91
+ }
92
+ finally { if (e_1) throw e_1.error; }
93
+ }
94
+ // Now that the initialization segment has been parsed - which may have
95
+ // included encryption information - take care of the encryption event
96
+ // if not already done.
97
+ if (!this._hasSentEncryptionData) {
98
+ var allEncryptionData = this._representation.getAllEncryptionData();
99
+ if (allEncryptionData.length > 0) {
100
+ this._notify(allEncryptionData);
101
+ this._hasSentEncryptionData = true;
102
+ }
103
+ }
104
+ };
105
+ return EncryptionDataNotifier;
106
+ }());
107
+ exports.default = EncryptionDataNotifier;
@@ -1 +1 @@
1
- {"version":3,"file":"representation_stream.d.ts","sourceRoot":"","sources":["../../../../../src/core/stream/representation/representation_stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAeH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAMxE,OAAO,KAAK,EAEV,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,gBAAgB,EAC3D,EACE,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,GACV,EAAE,8BAA8B,CAAC,gBAAgB,CAAC,EACnD,SAAS,EAAE,8BAA8B,EACzC,kBAAkB,EAAE,kBAAkB,GACrC,IAAI,CAoZN"}
1
+ {"version":3,"file":"representation_stream.d.ts","sourceRoot":"","sources":["../../../../../src/core/stream/representation/representation_stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAeH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAOxE,OAAO,KAAK,EAEV,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,gBAAgB,EAC3D,EACE,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,GACV,EAAE,8BAA8B,CAAC,gBAAgB,CAAC,EACnD,SAAS,EAAE,8BAA8B,EACzC,kBAAkB,EAAE,kBAAkB,GACrC,IAAI,CA6WN"}
@@ -14,17 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __values = (this && this.__values) || function(o) {
18
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19
- if (m) return m.call(o);
20
- if (o && typeof o.length === "number") return {
21
- next: function () {
22
- if (o && i >= o.length) o = void 0;
23
- return { value: o && o[i++], done: !o };
24
- }
25
- };
26
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27
- };
28
17
  Object.defineProperty(exports, "__esModule", { value: true });
29
18
  exports.default = RepresentationStream;
30
19
  /**
@@ -39,6 +28,7 @@ var config_1 = require("../../../config");
39
28
  var log_1 = require("../../../log");
40
29
  var object_assign_1 = require("../../../utils/object_assign");
41
30
  var task_canceller_1 = require("../../../utils/task_canceller");
31
+ var encryption_data_notifier_1 = require("./encryption_data_notifier");
42
32
  var get_buffer_status_1 = require("./utils/get_buffer_status");
43
33
  var get_segment_priority_1 = require("./utils/get_segment_priority");
44
34
  var push_init_segment_1 = require("./utils/push_init_segment");
@@ -110,27 +100,15 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
110
100
  if (!hasInitSegment) {
111
101
  initSegmentState.isLoaded = true;
112
102
  }
113
- /**
114
- * `true` if the event notifying about encryption data has already been
115
- * constructed.
116
- * Allows to avoid sending multiple times protection events.
117
- */
118
- var hasSentEncryptionData = false;
119
- // If the DRM system id is already known, and if we already have encryption data
120
- // for it, we may not need to wait until the initialization segment is loaded to
121
- // signal required protection data, thus performing License negotiations sooner
122
- if (drmSystemId !== undefined) {
123
- var encryptionData = representation.getEncryptionData(drmSystemId);
124
- // If some key ids are not known yet, it may be safer to wait for this initialization
125
- // segment to be loaded first
126
- if (encryptionData.length > 0 &&
127
- encryptionData.every(function (e) { return e.keyIds !== undefined; })) {
128
- hasSentEncryptionData = true;
129
- callbacks.encryptionDataEncountered(encryptionData.map(function (d) { return (0, object_assign_1.default)({ content: content }, d); }));
130
- if (canceller.isUsed()) {
131
- return; // previous callback has stopped everything by side-effect
132
- }
133
- }
103
+ var drmNotifier = new encryption_data_notifier_1.default({
104
+ drmSystemId: drmSystemId,
105
+ representation: representation,
106
+ notify: function (encryptionData) {
107
+ return callbacks.encryptionDataEncountered(encryptionData.map(function (d) { return (0, object_assign_1.default)({ content: content }, d); }));
108
+ },
109
+ });
110
+ if (canceller.isUsed()) {
111
+ return;
134
112
  }
135
113
  segmentQueue.addEventListener("error", function (err) {
136
114
  if (canceller.signal.isCancelled()) {
@@ -208,7 +186,7 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
208
186
  });
209
187
  }
210
188
  else if (initSegmentState.isLoaded) {
211
- log_1.default.warn("Stream", "Uninitialized index with an already loaded " + "initialization segment", {
189
+ log_1.default.warn("Stream", "Uninitialized index with an already loaded initialization segment", {
212
190
  bufferType: bufferType,
213
191
  representationBitrate: content.representation.bitrate,
214
192
  });
@@ -306,33 +284,7 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
306
284
  * @param {Object} evt
307
285
  */
308
286
  function onParsedChunk(evt) {
309
- var e_1, _a;
310
- try {
311
- // Supplementary encryption information might have been parsed.
312
- for (var _b = __values(evt.protectionData), _c = _b.next(); !_c.done; _c = _b.next()) {
313
- var protInfo = _c.value;
314
- // TODO better handle use cases like key rotation by not always grouping
315
- // every protection data together? To check.
316
- representation.addProtectionData(protInfo.initDataType, protInfo.keyId, protInfo.initData);
317
- }
318
- }
319
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
320
- finally {
321
- try {
322
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
323
- }
324
- finally { if (e_1) throw e_1.error; }
325
- }
326
- // Now that the initialization segment has been parsed - which may have
327
- // included encryption information - take care of the encryption event
328
- // if not already done.
329
- if (!hasSentEncryptionData) {
330
- var allEncryptionData = representation.getAllEncryptionData();
331
- if (allEncryptionData.length > 0) {
332
- callbacks.encryptionDataEncountered(allEncryptionData.map(function (p) { return (0, object_assign_1.default)({ content: content }, p); }));
333
- hasSentEncryptionData = true;
334
- }
335
- }
287
+ drmNotifier.onNewProtectionData(evt.protectionData);
336
288
  if (evt.segmentType === "init") {
337
289
  if (!representation.index.isInitialized() && evt.segmentList !== undefined) {
338
290
  representation.index.initialize(evt.segmentList);
@@ -217,7 +217,7 @@ function getAvailableBufferSize(bufferedSegments, segmentsBeingPushed, maxVideoB
217
217
  /**
218
218
  * From the given array of buffered chunks (`bufferedSegments`) returns the last
219
219
  * buffered chunk contiguous with the one at the `startIndex` index given.
220
- * @param {Array.<Object>}
220
+ * @param {Array.<Object>} bufferedSegments
221
221
  * @param {number} startIndex
222
222
  * @returns {Object}
223
223
  */