mattebox 0.14.0 → 0.15.0

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 (240) hide show
  1. package/README.md +29 -21
  2. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  3. package/dist/cdn/mattebox.dash-ll.min.js +3 -0
  4. package/dist/cdn/mattebox.dash.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  6. package/dist/cdn/mattebox.dual-ll.min.js +3 -0
  7. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  9. package/dist/cdn/mattebox.dual.min.js +3 -3
  10. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  11. package/dist/cdn/mattebox.hls-ll.min.js +3 -0
  12. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  13. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  14. package/dist/cdn/mattebox.hls.min.js +3 -3
  15. package/dist/cdn/mattebox.kernel.min.js +1 -1
  16. package/dist/cdn/mattebox.min.js +5 -5
  17. package/dist/containers/fmp4/writer.d.ts +7 -1
  18. package/dist/containers/fmp4/writer.d.ts.map +1 -1
  19. package/dist/containers/fmp4/writer.js +2 -1
  20. package/dist/containers/fmp4/writer.js.map +1 -1
  21. package/dist/containers/mp4-box/index.d.ts +8 -0
  22. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  23. package/dist/containers/mp4-box/index.js +27 -0
  24. package/dist/containers/mp4-box/index.js.map +1 -1
  25. package/dist/containers/ts-transmux/demux.d.ts +2 -0
  26. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  27. package/dist/containers/ts-transmux/demux.js +3 -1
  28. package/dist/containers/ts-transmux/demux.js.map +1 -1
  29. package/dist/containers/ts-transmux/h265.d.ts +51 -0
  30. package/dist/containers/ts-transmux/h265.d.ts.map +1 -0
  31. package/dist/containers/ts-transmux/h265.js +182 -0
  32. package/dist/containers/ts-transmux/h265.js.map +1 -0
  33. package/dist/containers/ts-transmux/transmux.d.ts +3 -2
  34. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  35. package/dist/containers/ts-transmux/transmux.js +35 -11
  36. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  37. package/dist/eme/index.d.ts +1 -10
  38. package/dist/eme/index.d.ts.map +1 -1
  39. package/dist/eme/index.js +4 -2
  40. package/dist/eme/index.js.map +1 -1
  41. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/asyncToGenerator.js +1 -1
  42. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.js +1 -1
  43. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectSpread2.js +1 -1
  44. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectWithoutProperties.js +1 -1
  45. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  46. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.js +1 -1
  47. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.js +1 -1
  48. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/typeof.js +1 -1
  49. package/dist/es2015/containers/fmp4/writer.js +2 -1
  50. package/dist/es2015/containers/id3.js +1 -1
  51. package/dist/es2015/containers/mp4-box/index.js +24 -1
  52. package/dist/es2015/containers/scte35.js +1 -1
  53. package/dist/es2015/containers/ts-transmux/demux.js +3 -1
  54. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  55. package/dist/es2015/containers/ts-transmux/h265.js +175 -0
  56. package/dist/es2015/containers/ts-transmux/index.js +1 -1
  57. package/dist/es2015/containers/ts-transmux/runner.js +2 -2
  58. package/dist/es2015/containers/ts-transmux/transmux.js +39 -16
  59. package/dist/es2015/containers/webvtt.js +1 -1
  60. package/dist/es2015/containers/wvtt.js +1 -1
  61. package/dist/es2015/eme/index.js +7 -5
  62. package/dist/es2015/index.js +6 -2
  63. package/dist/es2015/kernel/append-queue.js +1 -1
  64. package/dist/es2015/kernel/context.js +7 -0
  65. package/dist/es2015/kernel/dry-run.js +1 -1
  66. package/dist/es2015/kernel/mse.js +1 -1
  67. package/dist/es2015/kernel/prepare.js +3 -3
  68. package/dist/es2015/kernel/reducer.js +90 -31
  69. package/dist/es2015/kernel/refresh.js +2 -2
  70. package/dist/es2015/kernel/rendition-select.js +2 -2
  71. package/dist/es2015/kernel/scheduler.js +31 -6
  72. package/dist/es2015/kernel/timeline.js +1 -1
  73. package/dist/es2015/kernel/trace.js +1 -1
  74. package/dist/es2015/kernel/transport.js +154 -22
  75. package/dist/es2015/presets/dash-ll/index.js +15 -0
  76. package/dist/es2015/presets/define.js +2 -2
  77. package/dist/es2015/presets/dual-ll/index.js +16 -0
  78. package/dist/es2015/presets/full/index.js +6 -4
  79. package/dist/es2015/presets/hls-ll/index.js +14 -0
  80. package/dist/es2015/presets/tiers.js +28 -3
  81. package/dist/es2015/protocols/dash-cmaf/index.js +13 -8
  82. package/dist/es2015/protocols/dash-cmaf/parse.js +129 -41
  83. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +1 -1
  84. package/dist/es2015/protocols/dash-cmaf/periods.js +1 -1
  85. package/dist/es2015/protocols/dash-live/index.js +75 -21
  86. package/dist/es2015/protocols/dash-ll/index.js +42 -0
  87. package/dist/es2015/protocols/hls-cmaf/index.js +5 -5
  88. package/dist/es2015/protocols/hls-cmaf/lexer.js +7 -1
  89. package/dist/es2015/protocols/hls-cmaf/parse.js +27 -12
  90. package/dist/es2015/protocols/hls-cmaf/unavailable.js +1 -1
  91. package/dist/es2015/protocols/hls-live/index.js +92 -18
  92. package/dist/es2015/protocols/hls-ll/index.js +30 -0
  93. package/dist/es2015/protocols/hls-ll/parse.js +240 -0
  94. package/dist/es2015/stages/abr/index.js +9 -2
  95. package/dist/es2015/stages/aes-128/index.js +1 -1
  96. package/dist/es2015/stages/chapters/index.js +2 -2
  97. package/dist/es2015/stages/chapters/parse.js +2 -2
  98. package/dist/es2015/stages/cmcd/index.js +7 -1
  99. package/dist/es2015/stages/codec-probe/index.js +1 -1
  100. package/dist/es2015/stages/content-steering/index.js +1 -1
  101. package/dist/es2015/stages/eme-core/index.js +193 -42
  102. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  103. package/dist/es2015/stages/hdr/index.js +1 -1
  104. package/dist/es2015/stages/live-catchup/index.js +221 -0
  105. package/dist/es2015/stages/qoe/index.js +1 -1
  106. package/dist/es2015/stages/recovery/index.js +2 -2
  107. package/dist/es2015/stages/rendition-names/index.js +1 -1
  108. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  109. package/dist/es2015/stages/text-cea708/decode.js +2 -2
  110. package/dist/es2015/stages/text-cea708/index.js +1 -1
  111. package/dist/es2015/stages/text-ttml/images.js +60 -0
  112. package/dist/es2015/stages/text-ttml/index.js +22 -6
  113. package/dist/es2015/stages/text-ttml/parse.js +71 -5
  114. package/dist/es2015/stages/thumbnails/index.js +1 -1
  115. package/dist/es2015/stages/timed-metadata/index.js +1 -1
  116. package/dist/es2015/stages/trick-play/index.js +1 -1
  117. package/dist/index.d.ts.map +1 -1
  118. package/dist/index.js +1 -0
  119. package/dist/index.js.map +1 -1
  120. package/dist/kernel/context.d.ts +4 -6
  121. package/dist/kernel/context.d.ts.map +1 -1
  122. package/dist/kernel/context.js +10 -0
  123. package/dist/kernel/context.js.map +1 -1
  124. package/dist/kernel/lifecycle.d.ts +2 -6
  125. package/dist/kernel/lifecycle.d.ts.map +1 -1
  126. package/dist/kernel/lifecycle.js.map +1 -1
  127. package/dist/kernel/prepare.d.ts +3 -0
  128. package/dist/kernel/prepare.d.ts.map +1 -1
  129. package/dist/kernel/prepare.js +2 -1
  130. package/dist/kernel/prepare.js.map +1 -1
  131. package/dist/kernel/reducer.d.ts.map +1 -1
  132. package/dist/kernel/reducer.js +95 -40
  133. package/dist/kernel/reducer.js.map +1 -1
  134. package/dist/kernel/refresh.d.ts.map +1 -1
  135. package/dist/kernel/refresh.js +2 -0
  136. package/dist/kernel/refresh.js.map +1 -1
  137. package/dist/kernel/scheduler.d.ts.map +1 -1
  138. package/dist/kernel/scheduler.js +40 -3
  139. package/dist/kernel/scheduler.js.map +1 -1
  140. package/dist/kernel/transport.d.ts +34 -5
  141. package/dist/kernel/transport.d.ts.map +1 -1
  142. package/dist/kernel/transport.js +148 -11
  143. package/dist/kernel/transport.js.map +1 -1
  144. package/dist/presets/dash-ll/index.d.ts +4 -0
  145. package/dist/presets/dash-ll/index.d.ts.map +1 -0
  146. package/dist/presets/dash-ll/index.js +10 -0
  147. package/dist/presets/dash-ll/index.js.map +1 -0
  148. package/dist/presets/dual-ll/index.d.ts +4 -0
  149. package/dist/presets/dual-ll/index.d.ts.map +1 -0
  150. package/dist/presets/dual-ll/index.js +15 -0
  151. package/dist/presets/dual-ll/index.js.map +1 -0
  152. package/dist/presets/full/index.d.ts.map +1 -1
  153. package/dist/presets/full/index.js +6 -4
  154. package/dist/presets/full/index.js.map +1 -1
  155. package/dist/presets/hls-ll/index.d.ts +4 -0
  156. package/dist/presets/hls-ll/index.d.ts.map +1 -0
  157. package/dist/presets/hls-ll/index.js +9 -0
  158. package/dist/presets/hls-ll/index.js.map +1 -0
  159. package/dist/presets/tiers.d.ts +16 -0
  160. package/dist/presets/tiers.d.ts.map +1 -1
  161. package/dist/presets/tiers.js +25 -0
  162. package/dist/presets/tiers.js.map +1 -1
  163. package/dist/protocols/dash-cmaf/index.d.ts +29 -1
  164. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  165. package/dist/protocols/dash-cmaf/index.js +9 -4
  166. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  167. package/dist/protocols/dash-cmaf/parse.d.ts +8 -2
  168. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  169. package/dist/protocols/dash-cmaf/parse.js +121 -14
  170. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  171. package/dist/protocols/dash-live/index.d.ts +22 -0
  172. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  173. package/dist/protocols/dash-live/index.js +77 -18
  174. package/dist/protocols/dash-live/index.js.map +1 -1
  175. package/dist/protocols/dash-ll/index.d.ts +27 -0
  176. package/dist/protocols/dash-ll/index.d.ts.map +1 -0
  177. package/dist/protocols/dash-ll/index.js +35 -0
  178. package/dist/protocols/dash-ll/index.js.map +1 -0
  179. package/dist/protocols/hls-cmaf/index.d.ts +23 -0
  180. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  181. package/dist/protocols/hls-cmaf/index.js +4 -4
  182. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  183. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  184. package/dist/protocols/hls-cmaf/lexer.js +7 -0
  185. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  186. package/dist/protocols/hls-cmaf/parse.d.ts +28 -2
  187. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  188. package/dist/protocols/hls-cmaf/parse.js +42 -6
  189. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  190. package/dist/protocols/hls-live/index.d.ts +65 -0
  191. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  192. package/dist/protocols/hls-live/index.js +115 -16
  193. package/dist/protocols/hls-live/index.js.map +1 -1
  194. package/dist/protocols/hls-ll/index.d.ts +22 -0
  195. package/dist/protocols/hls-ll/index.d.ts.map +1 -0
  196. package/dist/protocols/hls-ll/index.js +32 -0
  197. package/dist/protocols/hls-ll/index.js.map +1 -0
  198. package/dist/protocols/hls-ll/parse.d.ts +45 -0
  199. package/dist/protocols/hls-ll/parse.d.ts.map +1 -0
  200. package/dist/protocols/hls-ll/parse.js +300 -0
  201. package/dist/protocols/hls-ll/parse.js.map +1 -0
  202. package/dist/stages/abr/index.d.ts.map +1 -1
  203. package/dist/stages/abr/index.js +6 -6
  204. package/dist/stages/abr/index.js.map +1 -1
  205. package/dist/stages/cmcd/index.d.ts.map +1 -1
  206. package/dist/stages/cmcd/index.js +12 -3
  207. package/dist/stages/cmcd/index.js.map +1 -1
  208. package/dist/stages/eme-core/index.d.ts +67 -2
  209. package/dist/stages/eme-core/index.d.ts.map +1 -1
  210. package/dist/stages/eme-core/index.js +191 -40
  211. package/dist/stages/eme-core/index.js.map +1 -1
  212. package/dist/stages/live-catchup/index.d.ts +42 -0
  213. package/dist/stages/live-catchup/index.d.ts.map +1 -0
  214. package/dist/stages/live-catchup/index.js +217 -0
  215. package/dist/stages/live-catchup/index.js.map +1 -0
  216. package/dist/stages/recovery/index.d.ts.map +1 -1
  217. package/dist/stages/recovery/index.js +6 -2
  218. package/dist/stages/recovery/index.js.map +1 -1
  219. package/dist/stages/text-ttml/images.d.ts +10 -0
  220. package/dist/stages/text-ttml/images.d.ts.map +1 -0
  221. package/dist/stages/text-ttml/images.js +71 -0
  222. package/dist/stages/text-ttml/images.js.map +1 -0
  223. package/dist/stages/text-ttml/index.d.ts +13 -0
  224. package/dist/stages/text-ttml/index.d.ts.map +1 -1
  225. package/dist/stages/text-ttml/index.js +26 -6
  226. package/dist/stages/text-ttml/index.js.map +1 -1
  227. package/dist/stages/text-ttml/parse.d.ts +5 -2
  228. package/dist/stages/text-ttml/parse.d.ts.map +1 -1
  229. package/dist/stages/text-ttml/parse.js +74 -2
  230. package/dist/stages/text-ttml/parse.js.map +1 -1
  231. package/dist/types/ir.d.ts +36 -0
  232. package/dist/types/ir.d.ts.map +1 -1
  233. package/dist/types/kernel.d.ts +4 -0
  234. package/dist/types/kernel.d.ts.map +1 -1
  235. package/dist/types/kernel.js.map +1 -1
  236. package/dist/types/messages.d.ts +40 -0
  237. package/dist/types/messages.d.ts.map +1 -1
  238. package/dist/types/stage.d.ts +24 -5
  239. package/dist/types/stage.d.ts.map +1 -1
  240. package/package.json +4 -2
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/asyncToGenerator.js";
3
3
  //#region src/kernel/transport.ts
4
4
  const DEFAULT_RETRY_POLICY = {
5
5
  maxAttempts: 3,
@@ -26,6 +26,120 @@ const PRIMED_TTL_MS = 3e4;
26
26
  function primedKey(url, range) {
27
27
  return range === void 0 ? url : `${url} ${range.start}-${range.end}`;
28
28
  }
29
+ /** The two byte arrays as one. */
30
+ function join(head, tail) {
31
+ if (head.byteLength === 0) return tail;
32
+ const out = new Uint8Array(head.byteLength + tail.byteLength);
33
+ out.set(head);
34
+ out.set(tail, head.byteLength);
35
+ return out;
36
+ }
37
+ /**
38
+ * The throughput of chunked delivery, by moof timing, the default of the
39
+ * reference low-latency player: each chunk's bytes over the time from its
40
+ * first bytes to its end, so the encoder's pauses between chunks do not
41
+ * count. The last chunk is left out, chunks that took under a millisecond
42
+ * join the next ones, and at least two must remain. The sample is their
43
+ * mean, as bytes and milliseconds; null without enough chunks, and the
44
+ * segment then measures its whole time, as that player falls back to.
45
+ */
46
+ function chunkedTransfer(chunks) {
47
+ const rates = [];
48
+ let bytes = 0;
49
+ let pending = {
50
+ bytes: 0,
51
+ ms: 0
52
+ };
53
+ for (const chunk of chunks.slice(0, -1)) {
54
+ pending = {
55
+ bytes: pending.bytes + chunk.bytes,
56
+ ms: pending.ms + chunk.end - chunk.start
57
+ };
58
+ if (pending.ms <= 1) continue;
59
+ rates.push(pending.bytes / pending.ms);
60
+ bytes += pending.bytes;
61
+ pending = {
62
+ bytes: 0,
63
+ ms: 0
64
+ };
65
+ }
66
+ if (rates.length < 2) return null;
67
+ const mean = rates.reduce((sum, rate) => sum + rate, 0) / rates.length;
68
+ return {
69
+ bytes,
70
+ ms: bytes / mean
71
+ };
72
+ }
73
+ /**
74
+ * Reads a body as it arrives and hands on each run of complete chunks,
75
+ * timing each from the read that brought its first bytes to the read that
76
+ * completed it.
77
+ */
78
+ function readChunks(_x, _x2, _x3, _x4) {
79
+ return _readChunks.apply(this, arguments);
80
+ }
81
+ function _readChunks() {
82
+ _readChunks = _asyncToGenerator(function* (body, split, onChunk, now) {
83
+ const reader = body.getReader();
84
+ let held = /* @__PURE__ */ new Uint8Array(0);
85
+ let size = 0;
86
+ let began = 0;
87
+ const timed = [];
88
+ for (;;) {
89
+ const read = yield reader.read();
90
+ if (read.done) break;
91
+ const at = now();
92
+ if (held.byteLength === 0) began = at;
93
+ size += read.value.byteLength;
94
+ held = join(held, read.value);
95
+ const ready = split(held);
96
+ if (ready > 0) {
97
+ onChunk(held.slice(0, ready).buffer);
98
+ timed.push({
99
+ bytes: ready,
100
+ start: began,
101
+ end: at
102
+ });
103
+ held = held.slice(ready);
104
+ began = at;
105
+ }
106
+ }
107
+ return {
108
+ rest: held.slice().buffer,
109
+ size,
110
+ transfer: chunkedTransfer(timed)
111
+ };
112
+ });
113
+ return _readChunks.apply(this, arguments);
114
+ }
115
+ /**
116
+ * Fetches with a deadline for the response headers. Past `timeoutMs` the
117
+ * request aborts and the promise rejects with a TimeoutError; `signal`
118
+ * aborts it too, with an AbortError.
119
+ */
120
+ function fetchWithin(fetchImpl, url, init, timeoutMs, signal) {
121
+ if (timeoutMs === null && signal === void 0) return fetchImpl(url, init);
122
+ const controller = new AbortController();
123
+ const abort = () => controller.abort();
124
+ if ((signal === null || signal === void 0 ? void 0 : signal.aborted) === true) abort();
125
+ signal === null || signal === void 0 || signal.addEventListener("abort", abort);
126
+ let timedOut = false;
127
+ const timer = timeoutMs === null ? null : setTimeout(() => {
128
+ timedOut = true;
129
+ abort();
130
+ }, timeoutMs);
131
+ const done = () => {
132
+ if (timer !== null) clearTimeout(timer);
133
+ signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
134
+ };
135
+ return fetchImpl(url, _objectSpread2(_objectSpread2({}, init), {}, { signal: controller.signal })).then((response) => {
136
+ done();
137
+ return response;
138
+ }, (error) => {
139
+ done();
140
+ throw timedOut ? new DOMException(`${url}: no response in ${timeoutMs} ms`, "TimeoutError") : error;
141
+ });
142
+ }
29
143
  function createTransport(options) {
30
144
  var _options$fetchImpl, _options$now;
31
145
  const policy = _objectSpread2(_objectSpread2({}, DEFAULT_RETRY_POLICY), options.retry);
@@ -71,11 +185,11 @@ function createTransport(options) {
71
185
  var _sink$failed;
72
186
  live.delete(sink.id + token);
73
187
  (_sink$failed = sink.failed) === null || _sink$failed === void 0 || _sink$failed.call(sink, token);
74
- sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2({
188
+ sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
75
189
  type: "SEGMENT_FAILED",
76
190
  trackId: request.trackId,
77
191
  seq: request.seq
78
- }, request.renditionId !== void 0 ? { renditionId: request.renditionId } : {}), status !== void 0 ? { status } : {}), {}, { error: {
192
+ }, request.renditionId !== void 0 ? { renditionId: request.renditionId } : {}), request.preload === true ? { preload: true } : {}), status !== void 0 ? { status } : {}), {}, { error: {
79
193
  category: "network",
80
194
  code,
81
195
  fatal: false,
@@ -91,7 +205,7 @@ function createTransport(options) {
91
205
  hook(info);
92
206
  } catch (_unused) {}
93
207
  }
94
- function attempt(sink, token, request, effectUrl, range, timeoutFromEffect, attemptNo) {
208
+ function attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo) {
95
209
  const state = {
96
210
  controller: new AbortController(),
97
211
  timedOut: false,
@@ -126,20 +240,21 @@ function createTransport(options) {
126
240
  }
127
241
  state.retryId = setTimeout(() => {
128
242
  state.retryId = null;
129
- attempt(sink, token, request, effectUrl, range, timeoutFromEffect, attemptNo + 1);
243
+ attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo + 1);
130
244
  }, backoffDelayMs(policy, attemptNo));
131
245
  };
132
246
  const answer = takePrimed(effectUrl, range);
133
247
  (answer !== null ? Promise.resolve(new Response(answer.bytes, {
134
248
  status: 200,
135
249
  headers: answer.headers
136
- })) : fetchImpl(draft.url, {
250
+ })) : fetchImpl(draft.url, _objectSpread2(_objectSpread2({}, head ? { method: "HEAD" } : {}), {}, {
137
251
  headers: draft.headers,
138
252
  signal: state.controller.signal
139
- })).then(function() {
253
+ }))).then(function() {
140
254
  var _ref = _asyncToGenerator(function* (response) {
141
- var _options$acceptManife, _response$body;
255
+ var _options$acceptManife, _response$body, _options$split, _options$split2, _streamed$size, _streamed$transfer, _response$headers$get;
142
256
  if (state.timeoutId !== null) clearTimeout(state.timeoutId);
257
+ const wait = now() - startedAt;
143
258
  if (!response.ok) {
144
259
  notifyResponse({
145
260
  token,
@@ -157,7 +272,19 @@ function createTransport(options) {
157
272
  const contentType = response.headers.get("content-type");
158
273
  const refused = request.trackId === "manifest" && contentType !== null && ((_options$acceptManife = options.acceptManifestType) === null || _options$acceptManife === void 0 ? void 0 : _options$acceptManife.call(options, contentType)) === false;
159
274
  if (refused) yield (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.cancel();
160
- const bytes = refused ? /* @__PURE__ */ new ArrayBuffer(0) : yield response.arrayBuffer();
275
+ const split = request.chunked === true && sink === main && answer === null ? (_options$split = (_options$split2 = options.split) === null || _options$split2 === void 0 ? void 0 : _options$split2.call(options)) !== null && _options$split !== void 0 ? _options$split : null : null;
276
+ const streamed = split !== null && response.body != null ? yield readChunks(response.body, split, (chunk) => sink.absorb({
277
+ type: "SEGMENT_CHUNK",
278
+ trackId: request.trackId,
279
+ seq: request.seq,
280
+ token,
281
+ bytes: chunk
282
+ }), now) : null;
283
+ let bytes;
284
+ if (refused) bytes = /* @__PURE__ */ new ArrayBuffer(0);
285
+ else if (streamed !== null) bytes = streamed.rest;
286
+ else bytes = yield response.arrayBuffer();
287
+ const size = (_streamed$size = streamed === null || streamed === void 0 ? void 0 : streamed.size) !== null && _streamed$size !== void 0 ? _streamed$size : bytes.byteLength;
161
288
  if (state.userAborted) {
162
289
  live.delete(sink.id + token);
163
290
  return;
@@ -168,7 +295,7 @@ function createTransport(options) {
168
295
  url: draft.url,
169
296
  status: response.status,
170
297
  rtt,
171
- size: bytes.byteLength,
298
+ size,
172
299
  outcome: refused ? "failure" : "success",
173
300
  attempt: attemptNo,
174
301
  headers: response.headers
@@ -200,18 +327,23 @@ function createTransport(options) {
200
327
  keepMs: sink.keepMs,
201
328
  rtt
202
329
  }));
203
- sink.absorb({
330
+ let transfer = (_streamed$transfer = streamed === null || streamed === void 0 ? void 0 : streamed.transfer) !== null && _streamed$transfer !== void 0 ? _streamed$transfer : void 0;
331
+ if (transfer === void 0 && request.preload === true && answer === null) transfer = {
332
+ bytes: size,
333
+ ms: rtt - wait
334
+ };
335
+ const date = head || request.seq < 0 ? Date.parse((_response$headers$get = response.headers.get("date")) !== null && _response$headers$get !== void 0 ? _response$headers$get : "") : NaN;
336
+ sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2({
204
337
  type: "SEGMENT_LOADED",
205
338
  trackId: request.trackId,
206
339
  seq: request.seq,
207
340
  token,
208
341
  bytes,
209
342
  rtt,
210
- size: bytes.byteLength,
211
- wallClock: Date.now() / 1e3
212
- });
343
+ size
344
+ }, transfer !== void 0 ? { transfer } : {}), Number.isFinite(date) ? { serverDate: date / 1e3 } : {}), {}, { wallClock: Date.now() / 1e3 }));
213
345
  });
214
- return function(_x) {
346
+ return function(_x5) {
215
347
  return _ref.apply(this, arguments);
216
348
  };
217
349
  }()).catch(() => {
@@ -256,7 +388,7 @@ function createTransport(options) {
256
388
  seq: -1,
257
389
  url: effect.url
258
390
  }, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
259
- attempt(main, effect.token, request, effect.url, effect.range, effect.timeout, 1);
391
+ attempt(main, effect.token, request, effect.url, effect.range, effect.timeout, effect.method === "HEAD", 1);
260
392
  return () => cancel(effect.token);
261
393
  });
262
394
  },
@@ -278,7 +410,7 @@ function createTransport(options) {
278
410
  url: effect.url
279
411
  }, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
280
412
  tokens.add(effect.token);
281
- attempt(sink, effect.token, request, effect.url, effect.range, effect.timeout, 1);
413
+ attempt(sink, effect.token, request, effect.url, effect.range, effect.timeout, effect.method === "HEAD", 1);
282
414
  return () => cancel(sink.id + effect.token);
283
415
  },
284
416
  close() {
@@ -292,17 +424,17 @@ function createTransport(options) {
292
424
  const draft = {
293
425
  url,
294
426
  headers: _objectSpread2({}, (_init$headers = init.headers) !== null && _init$headers !== void 0 ? _init$headers : {}),
295
- timeoutMs: defaultTimeout,
427
+ timeoutMs: init.timeoutMs === void 0 ? defaultTimeout : init.timeoutMs,
296
428
  token: `req:${url}`,
297
429
  attempt: 1
298
430
  };
299
431
  for (const hook of [...requestHooks]) try {
300
432
  hook(draft);
301
433
  } catch (_unused3) {}
302
- return fetchImpl(draft.url, _objectSpread2({
434
+ return fetchWithin(fetchImpl, draft.url, _objectSpread2({
303
435
  method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
304
436
  headers: draft.headers
305
- }, init.body !== void 0 ? { body: init.body } : {}));
437
+ }, init.body !== void 0 ? { body: init.body } : {}), draft.timeoutMs, init.signal);
306
438
  })();
307
439
  },
308
440
  addRequestHook(hook) {
@@ -320,4 +452,4 @@ function createTransport(options) {
320
452
  };
321
453
  }
322
454
  //#endregion
323
- export { DEFAULT_RETRY_POLICY, backoffDelayMs, createTransport };
455
+ export { DEFAULT_RETRY_POLICY, backoffDelayMs, chunkedTransfer, createTransport, fetchWithin };
@@ -0,0 +1,15 @@
1
+ import { definePreset } from "../define.js";
2
+ import { base, dashLlLine, lowLatencyTier } from "../tiers.js";
3
+ //#region src/presets/dash-ll/index.ts
4
+ /**
5
+ * The `dash-ll` preset: low-latency DASH on demand and live, CMAF segments,
6
+ * live catch-up, the base. An MPD without low-latency signalling plays as
7
+ * in `dash`.
8
+ */
9
+ const preset = definePreset("dash-ll", () => [
10
+ ...dashLlLine(),
11
+ ...lowLatencyTier(),
12
+ ...base()
13
+ ]);
14
+ //#endregion
15
+ export { preset as default };
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectWithoutProperties.js";
3
3
  import { mattebox } from "../index.js";
4
4
  //#region src/presets/define.ts
5
5
  const _excluded = ["stages", "without"];
@@ -0,0 +1,16 @@
1
+ import { definePreset } from "../define.js";
2
+ import { base, dashLlLine, hlsLlLine, lowLatencyTier } from "../tiers.js";
3
+ //#region src/presets/dual-ll/index.ts
4
+ /**
5
+ * The `dual-ll` preset: low-latency HLS and low-latency DASH, CMAF
6
+ * segments, live catch-up, the base. One engine for a catalogue that mixes
7
+ * HLS and DASH live channels.
8
+ */
9
+ const preset = definePreset("dual-ll", () => [
10
+ ...hlsLlLine(),
11
+ ...dashLlLine(),
12
+ ...lowLatencyTier(),
13
+ ...base()
14
+ ]);
15
+ //#endregion
16
+ export { preset as default };
@@ -9,10 +9,11 @@ import hdr from "../../stages/hdr/index.js";
9
9
  import cmsd from "../../stages/cmsd/index.js";
10
10
  import chapters from "../../stages/chapters/index.js";
11
11
  import { definePreset } from "../define.js";
12
- import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
12
+ import { base, dashLlLine, drmTier, hlsLlLine, lowLatencyTier, tsTier } from "../tiers.js";
13
13
  //#region src/presets/full/index.ts
14
14
  /**
15
- * The `full` preset: `dual-ts-drm` plus the accessories: thumbnails (fetches image playlists, so opt-in elsewhere), chapters
15
+ * The `full` preset: `dual-ts-drm` with low-latency HLS, low-latency DASH
16
+ * and live catch-up (`hls-ll` and `dash-ll` in place of the plain lines), plus the accessories: thumbnails (fetches image playlists, so opt-in elsewhere), chapters
16
17
  * (loads a file the app names), trick play (a UI control drives it),
17
18
  * timed metadata (a page reads it), CEA-708 captions (US broadcast
18
19
  * streams carry 608 beside them, which the base reads), TTML subtitles
@@ -27,8 +28,9 @@ import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
27
28
  * the main CDN bundle exposes it.
28
29
  */
29
30
  const preset = definePreset("full", () => [
30
- ...hlsLine(),
31
- ...dashLine(),
31
+ ...hlsLlLine(),
32
+ ...dashLlLine(),
33
+ ...lowLatencyTier(),
32
34
  ...base(),
33
35
  ...tsTier(),
34
36
  ...drmTier(),
@@ -0,0 +1,14 @@
1
+ import { definePreset } from "../define.js";
2
+ import { base, hlsLlLine, lowLatencyTier } from "../tiers.js";
3
+ //#region src/presets/hls-ll/index.ts
4
+ /**
5
+ * The `hls-ll` preset: low-latency HLS on demand and live, CMAF segments,
6
+ * live catch-up, the base. A stream without parts plays as in `hls`.
7
+ */
8
+ const preset = definePreset("hls-ll", () => [
9
+ ...hlsLlLine(),
10
+ ...lowLatencyTier(),
11
+ ...base()
12
+ ]);
13
+ //#endregion
14
+ export { preset as default };
@@ -6,6 +6,7 @@ import pdt from "../stages/pdt/index.js";
6
6
  import nalScan from "../stages/nal-scan/index.js";
7
7
  import mp4Box from "../stages/mp4-box/index.js";
8
8
  import metaId3 from "../stages/meta-id3/index.js";
9
+ import liveCatchup from "../stages/live-catchup/index.js";
9
10
  import forcedSubtitles from "../stages/forced-subtitles/index.js";
10
11
  import emeFairplay from "../stages/eme-fairplay/index.js";
11
12
  import emeCore from "../stages/eme-core/index.js";
@@ -18,10 +19,12 @@ import altAudio from "../stages/alt-audio/index.js";
18
19
  import aes128 from "../stages/aes-128/index.js";
19
20
  import abrCapSize from "../stages/abr-cap-size/index.js";
20
21
  import abr from "../stages/abr/index.js";
21
- import hlsLive from "../protocols/hls-live/index.js";
22
22
  import hlsCmaf from "../protocols/hls-cmaf/index.js";
23
- import dashLive from "../protocols/dash-live/index.js";
23
+ import hlsLive from "../protocols/hls-live/index.js";
24
+ import hlsLl from "../protocols/hls-ll/index.js";
24
25
  import dashCmaf from "../protocols/dash-cmaf/index.js";
26
+ import dashLive from "../protocols/dash-live/index.js";
27
+ import dashLl from "../protocols/dash-ll/index.js";
25
28
  import packedAudio from "../containers/packed-audio/index.js";
26
29
  import tsTransmux from "../containers/ts-transmux/index.js";
27
30
  //#region src/presets/tiers.ts
@@ -42,11 +45,33 @@ function hlsLine() {
42
45
  aes128()
43
46
  ];
44
47
  }
48
+ /**
49
+ * Low-latency HLS: hls-ll in place of hls-cmaf and hls-live, which it
50
+ * contains. A playlist without parts plays as the HLS line plays it.
51
+ */
52
+ function hlsLlLine() {
53
+ return [hlsLl(), aes128()];
54
+ }
45
55
  /** DASH on demand and live. */
46
56
  function dashLine() {
47
57
  return [dashCmaf(), dashLive()];
48
58
  }
49
59
  /**
60
+ * Low-latency DASH: dash-ll in place of dash-cmaf and dash-live, which it
61
+ * contains. An MPD without low-latency signalling plays as the DASH line
62
+ * plays it.
63
+ */
64
+ function dashLlLine() {
65
+ return [dashLl()];
66
+ }
67
+ /**
68
+ * What a low-latency line needs beside it: the catch-up that holds the
69
+ * latency. It holds any live stream at its hold-back.
70
+ */
71
+ function lowLatencyTier() {
72
+ return [liveCatchup()];
73
+ }
74
+ /**
50
75
  * What every preset carries: adaptive quality with a size cap, recovery, content steering (inert until a manifest asks for it),
51
76
  * alternate audio with codec switching, WebVTT subtitles, CMAF timing (reads
52
77
  * each segment's decode time so the kernel lands it at its playlist time,
@@ -96,4 +121,4 @@ function drmTier() {
96
121
  ];
97
122
  }
98
123
  //#endregion
99
- export { base, dashLine, drmTier, hlsLine, tsTier };
124
+ export { base, dashLine, dashLlLine, drmTier, hlsLine, hlsLlLine, lowLatencyTier, tsTier };
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
2
2
  import { scheduled, tickAfter } from "../../kernel/effects.js";
3
3
  import { normalizeMimeType } from "../../kernel/mime.js";
4
4
  import { findRendition } from "../../kernel/presentation.js";
@@ -119,7 +119,8 @@ function retry(state, renditionId) {
119
119
  constraint: { excludeIds: Object.keys(failed) }
120
120
  })]];
121
121
  }
122
- const createReduceDash = (retryMs) => (slice, msg, kernel) => {
122
+ /** The slice reducer. `lowLatency` reads the MPD as dash-ll does. */
123
+ const createReduceDash = (retryMs, lowLatency = false) => (slice, msg, kernel) => {
123
124
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
124
125
  if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
125
126
  manifestUrl: msg.url,
@@ -131,7 +132,7 @@ const createReduceDash = (retryMs) => (slice, msg, kernel) => {
131
132
  let warnings = [];
132
133
  const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), (text, url) => {
133
134
  var _result$warnings;
134
- const result = parse(text, url);
135
+ const result = parse(text, url, lowLatency);
135
136
  if (result.presentation !== null) warnings = (_result$warnings = result.warnings) !== null && _result$warnings !== void 0 ? _result$warnings : [];
136
137
  return result;
137
138
  });
@@ -233,6 +234,13 @@ const createReduceDash = (retryMs) => (slice, msg, kernel) => {
233
234
  * The stage factory. `mattebox({ stages: [dashCmaf()] })` is all a consumer
234
235
  * needs for DASH-CMAF VOD, templated or on-demand.
235
236
  */
237
+ /** Installs the period runtime, which reads the slice this stage or dash-ll keeps. */
238
+ function installDashPeriods(ctx) {
239
+ return installPeriods(ctx, () => {
240
+ var _skips, _ctx$getState$dash;
241
+ return (_skips = (_ctx$getState$dash = ctx.getState().dash) === null || _ctx$getState$dash === void 0 ? void 0 : _ctx$getState$dash.skips) !== null && _skips !== void 0 ? _skips : [];
242
+ });
243
+ }
236
244
  function dashCmaf(options = {}) {
237
245
  var _options$unavailableR;
238
246
  const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : 15) * 1e3;
@@ -241,12 +249,9 @@ function dashCmaf(options = {}) {
241
249
  provides: ["dash-cmaf", ...MANIFEST_TYPES],
242
250
  install(ctx) {
243
251
  ctx.reduce("dash", createReduceDash(retryMs));
244
- return installPeriods(ctx, () => {
245
- var _skips, _ctx$getState$dash;
246
- return (_skips = (_ctx$getState$dash = ctx.getState().dash) === null || _ctx$getState$dash === void 0 ? void 0 : _ctx$getState$dash.skips) !== null && _skips !== void 0 ? _skips : [];
247
- });
252
+ return installDashPeriods(ctx);
248
253
  }
249
254
  };
250
255
  }
251
256
  //#endregion
252
- export { dashCmaf as default };
257
+ export { MANIFEST_TYPES, createReduceDash, dashCmaf as default, installDashPeriods };