mattebox 0.14.0 → 0.16.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 (255) 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 +6 -6
  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.154.0}/helpers/esm/asyncToGenerator.js +1 -1
  42. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
  43. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
  44. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectWithoutProperties.js +1 -1
  45. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  46. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
  47. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
  48. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.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 +8 -4
  63. package/dist/es2015/kernel/append-queue.js +1 -1
  64. package/dist/es2015/kernel/characteristics.js +19 -1
  65. package/dist/es2015/kernel/context.js +7 -0
  66. package/dist/es2015/kernel/dry-run.js +1 -1
  67. package/dist/es2015/kernel/mse.js +1 -1
  68. package/dist/es2015/kernel/prepare.js +3 -3
  69. package/dist/es2015/kernel/presentation.js +10 -1
  70. package/dist/es2015/kernel/reducer.js +92 -33
  71. package/dist/es2015/kernel/refresh.js +2 -2
  72. package/dist/es2015/kernel/rendition-select.js +2 -2
  73. package/dist/es2015/kernel/scheduler.js +31 -6
  74. package/dist/es2015/kernel/timeline.js +1 -1
  75. package/dist/es2015/kernel/trace.js +1 -1
  76. package/dist/es2015/kernel/transport.js +154 -22
  77. package/dist/es2015/presets/dash-ll/index.js +15 -0
  78. package/dist/es2015/presets/define.js +2 -2
  79. package/dist/es2015/presets/dual-ll/index.js +16 -0
  80. package/dist/es2015/presets/full/index.js +6 -4
  81. package/dist/es2015/presets/hls-ll/index.js +14 -0
  82. package/dist/es2015/presets/tiers.js +28 -3
  83. package/dist/es2015/protocols/dash-cmaf/index.js +13 -8
  84. package/dist/es2015/protocols/dash-cmaf/parse.js +129 -41
  85. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +1 -1
  86. package/dist/es2015/protocols/dash-cmaf/periods.js +1 -1
  87. package/dist/es2015/protocols/dash-live/index.js +75 -21
  88. package/dist/es2015/protocols/dash-ll/index.js +42 -0
  89. package/dist/es2015/protocols/hls-cmaf/index.js +5 -5
  90. package/dist/es2015/protocols/hls-cmaf/lexer.js +7 -1
  91. package/dist/es2015/protocols/hls-cmaf/parse.js +90 -27
  92. package/dist/es2015/protocols/hls-cmaf/unavailable.js +4 -3
  93. package/dist/es2015/protocols/hls-live/index.js +92 -18
  94. package/dist/es2015/protocols/hls-ll/index.js +30 -0
  95. package/dist/es2015/protocols/hls-ll/parse.js +240 -0
  96. package/dist/es2015/stages/abr/index.js +9 -2
  97. package/dist/es2015/stages/aes-128/index.js +1 -1
  98. package/dist/es2015/stages/chapters/index.js +2 -2
  99. package/dist/es2015/stages/chapters/parse.js +2 -2
  100. package/dist/es2015/stages/cmcd/index.js +7 -1
  101. package/dist/es2015/stages/codec-probe/index.js +1 -1
  102. package/dist/es2015/stages/content-steering/index.js +1 -1
  103. package/dist/es2015/stages/eme-core/index.js +193 -42
  104. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  105. package/dist/es2015/stages/hdr/index.js +1 -1
  106. package/dist/es2015/stages/live-catchup/index.js +221 -0
  107. package/dist/es2015/stages/qoe/index.js +1 -1
  108. package/dist/es2015/stages/recovery/index.js +2 -2
  109. package/dist/es2015/stages/rendition-names/index.js +1 -1
  110. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  111. package/dist/es2015/stages/text-cea708/decode.js +2 -2
  112. package/dist/es2015/stages/text-cea708/index.js +1 -1
  113. package/dist/es2015/stages/text-ttml/images.js +60 -0
  114. package/dist/es2015/stages/text-ttml/index.js +22 -6
  115. package/dist/es2015/stages/text-ttml/parse.js +71 -5
  116. package/dist/es2015/stages/thumbnails/index.js +1 -1
  117. package/dist/es2015/stages/timed-metadata/index.js +1 -1
  118. package/dist/es2015/stages/trick-play/index.js +1 -1
  119. package/dist/index.d.ts +1 -1
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +2 -1
  122. package/dist/index.js.map +1 -1
  123. package/dist/kernel/characteristics.d.ts +8 -1
  124. package/dist/kernel/characteristics.d.ts.map +1 -1
  125. package/dist/kernel/characteristics.js +23 -0
  126. package/dist/kernel/characteristics.js.map +1 -1
  127. package/dist/kernel/context.d.ts +4 -6
  128. package/dist/kernel/context.d.ts.map +1 -1
  129. package/dist/kernel/context.js +10 -0
  130. package/dist/kernel/context.js.map +1 -1
  131. package/dist/kernel/lifecycle.d.ts +2 -6
  132. package/dist/kernel/lifecycle.d.ts.map +1 -1
  133. package/dist/kernel/lifecycle.js.map +1 -1
  134. package/dist/kernel/prepare.d.ts +3 -0
  135. package/dist/kernel/prepare.d.ts.map +1 -1
  136. package/dist/kernel/prepare.js +2 -1
  137. package/dist/kernel/prepare.js.map +1 -1
  138. package/dist/kernel/presentation.d.ts +5 -0
  139. package/dist/kernel/presentation.d.ts.map +1 -1
  140. package/dist/kernel/presentation.js +9 -0
  141. package/dist/kernel/presentation.js.map +1 -1
  142. package/dist/kernel/reducer.d.ts.map +1 -1
  143. package/dist/kernel/reducer.js +108 -49
  144. package/dist/kernel/reducer.js.map +1 -1
  145. package/dist/kernel/refresh.d.ts.map +1 -1
  146. package/dist/kernel/refresh.js +2 -0
  147. package/dist/kernel/refresh.js.map +1 -1
  148. package/dist/kernel/scheduler.d.ts.map +1 -1
  149. package/dist/kernel/scheduler.js +40 -3
  150. package/dist/kernel/scheduler.js.map +1 -1
  151. package/dist/kernel/transport.d.ts +34 -5
  152. package/dist/kernel/transport.d.ts.map +1 -1
  153. package/dist/kernel/transport.js +148 -11
  154. package/dist/kernel/transport.js.map +1 -1
  155. package/dist/presets/dash-ll/index.d.ts +4 -0
  156. package/dist/presets/dash-ll/index.d.ts.map +1 -0
  157. package/dist/presets/dash-ll/index.js +10 -0
  158. package/dist/presets/dash-ll/index.js.map +1 -0
  159. package/dist/presets/dual-ll/index.d.ts +4 -0
  160. package/dist/presets/dual-ll/index.d.ts.map +1 -0
  161. package/dist/presets/dual-ll/index.js +15 -0
  162. package/dist/presets/dual-ll/index.js.map +1 -0
  163. package/dist/presets/full/index.d.ts.map +1 -1
  164. package/dist/presets/full/index.js +6 -4
  165. package/dist/presets/full/index.js.map +1 -1
  166. package/dist/presets/hls-ll/index.d.ts +4 -0
  167. package/dist/presets/hls-ll/index.d.ts.map +1 -0
  168. package/dist/presets/hls-ll/index.js +9 -0
  169. package/dist/presets/hls-ll/index.js.map +1 -0
  170. package/dist/presets/tiers.d.ts +16 -0
  171. package/dist/presets/tiers.d.ts.map +1 -1
  172. package/dist/presets/tiers.js +25 -0
  173. package/dist/presets/tiers.js.map +1 -1
  174. package/dist/protocols/dash-cmaf/index.d.ts +29 -1
  175. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  176. package/dist/protocols/dash-cmaf/index.js +9 -4
  177. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  178. package/dist/protocols/dash-cmaf/parse.d.ts +8 -2
  179. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  180. package/dist/protocols/dash-cmaf/parse.js +121 -14
  181. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  182. package/dist/protocols/dash-live/index.d.ts +22 -0
  183. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  184. package/dist/protocols/dash-live/index.js +77 -18
  185. package/dist/protocols/dash-live/index.js.map +1 -1
  186. package/dist/protocols/dash-ll/index.d.ts +27 -0
  187. package/dist/protocols/dash-ll/index.d.ts.map +1 -0
  188. package/dist/protocols/dash-ll/index.js +35 -0
  189. package/dist/protocols/dash-ll/index.js.map +1 -0
  190. package/dist/protocols/hls-cmaf/index.d.ts +23 -0
  191. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  192. package/dist/protocols/hls-cmaf/index.js +4 -4
  193. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  194. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  195. package/dist/protocols/hls-cmaf/lexer.js +7 -0
  196. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  197. package/dist/protocols/hls-cmaf/parse.d.ts +28 -2
  198. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  199. package/dist/protocols/hls-cmaf/parse.js +106 -11
  200. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  201. package/dist/protocols/hls-cmaf/unavailable.d.ts +1 -1
  202. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
  203. package/dist/protocols/hls-cmaf/unavailable.js +8 -2
  204. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
  205. package/dist/protocols/hls-live/index.d.ts +65 -0
  206. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  207. package/dist/protocols/hls-live/index.js +115 -16
  208. package/dist/protocols/hls-live/index.js.map +1 -1
  209. package/dist/protocols/hls-ll/index.d.ts +22 -0
  210. package/dist/protocols/hls-ll/index.d.ts.map +1 -0
  211. package/dist/protocols/hls-ll/index.js +32 -0
  212. package/dist/protocols/hls-ll/index.js.map +1 -0
  213. package/dist/protocols/hls-ll/parse.d.ts +45 -0
  214. package/dist/protocols/hls-ll/parse.d.ts.map +1 -0
  215. package/dist/protocols/hls-ll/parse.js +300 -0
  216. package/dist/protocols/hls-ll/parse.js.map +1 -0
  217. package/dist/stages/abr/index.d.ts.map +1 -1
  218. package/dist/stages/abr/index.js +6 -6
  219. package/dist/stages/abr/index.js.map +1 -1
  220. package/dist/stages/cmcd/index.d.ts.map +1 -1
  221. package/dist/stages/cmcd/index.js +12 -3
  222. package/dist/stages/cmcd/index.js.map +1 -1
  223. package/dist/stages/eme-core/index.d.ts +67 -2
  224. package/dist/stages/eme-core/index.d.ts.map +1 -1
  225. package/dist/stages/eme-core/index.js +191 -40
  226. package/dist/stages/eme-core/index.js.map +1 -1
  227. package/dist/stages/live-catchup/index.d.ts +42 -0
  228. package/dist/stages/live-catchup/index.d.ts.map +1 -0
  229. package/dist/stages/live-catchup/index.js +217 -0
  230. package/dist/stages/live-catchup/index.js.map +1 -0
  231. package/dist/stages/recovery/index.d.ts.map +1 -1
  232. package/dist/stages/recovery/index.js +6 -2
  233. package/dist/stages/recovery/index.js.map +1 -1
  234. package/dist/stages/text-ttml/images.d.ts +10 -0
  235. package/dist/stages/text-ttml/images.d.ts.map +1 -0
  236. package/dist/stages/text-ttml/images.js +71 -0
  237. package/dist/stages/text-ttml/images.js.map +1 -0
  238. package/dist/stages/text-ttml/index.d.ts +13 -0
  239. package/dist/stages/text-ttml/index.d.ts.map +1 -1
  240. package/dist/stages/text-ttml/index.js +26 -6
  241. package/dist/stages/text-ttml/index.js.map +1 -1
  242. package/dist/stages/text-ttml/parse.d.ts +5 -2
  243. package/dist/stages/text-ttml/parse.d.ts.map +1 -1
  244. package/dist/stages/text-ttml/parse.js +74 -2
  245. package/dist/stages/text-ttml/parse.js.map +1 -1
  246. package/dist/types/ir.d.ts +43 -0
  247. package/dist/types/ir.d.ts.map +1 -1
  248. package/dist/types/kernel.d.ts +4 -0
  249. package/dist/types/kernel.d.ts.map +1 -1
  250. package/dist/types/kernel.js.map +1 -1
  251. package/dist/types/messages.d.ts +40 -0
  252. package/dist/types/messages.d.ts.map +1 -1
  253. package/dist/types/stage.d.ts +24 -5
  254. package/dist/types/stage.d.ts.map +1 -1
  255. package/package.json +4 -2
@@ -1,8 +1,10 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
1
2
  import { concat, sequenceNumberFor, writeInitSegment, writeMediaSegment } from "../fmp4/writer.js";
2
- import { demux, unrollTimestamps } from "./demux.js";
3
+ import { STREAM_TYPE, demux, unrollTimestamps } from "./demux.js";
3
4
  import { ccTriplesFromSei } from "../sei.js";
4
5
  import { adtsFragment, parseAdts } from "../adts.js";
5
6
  import { NAL_TYPE, accessUnitFromNals, nalType, splitNalUnits, spsDimensions, toAccessUnit } from "./h264.js";
7
+ import { HEVC_NAL_TYPE, hevcAccessUnitFromNals, hevcDecoderConfiguration, hevcNalType, hevcSpsInfo } from "./h265.js";
6
8
  //#region src/containers/ts-transmux/transmux.ts
7
9
  /**
8
10
  * The transmux core: MPEG-TS bytes to a self-contained fragmented MP4. Each
@@ -42,6 +44,18 @@ function timedTags(streams, presentationStart, anchor) {
42
44
  }
43
45
  return tags;
44
46
  }
47
+ const AVC = {
48
+ type: nalType,
49
+ delimiter: NAL_TYPE.accessUnitDelimiter,
50
+ unit: accessUnitFromNals,
51
+ seiHeader: 1
52
+ };
53
+ const HEVC = {
54
+ type: hevcNalType,
55
+ delimiter: HEVC_NAL_TYPE.accessUnitDelimiter,
56
+ unit: hevcAccessUnitFromNals,
57
+ seiHeader: 2
58
+ };
45
59
  /**
46
60
  * Reframes video access units. Access units do not align with PES packet
47
61
  * boundaries in the wild: a picture's tail spills into the next PES packet,
@@ -51,7 +65,7 @@ function timedTags(streams, presentationStart, anchor) {
51
65
  * no delimiters falls back to one unit per PES, which is correct when the muxer
52
66
  * did align them.
53
67
  */
54
- function frameAccessUnits(packets) {
68
+ function frameAccessUnits(packets, syntax) {
55
69
  let total = 0;
56
70
  for (const p of packets) total += p.data.byteLength;
57
71
  const es = new Uint8Array(total);
@@ -67,8 +81,8 @@ function frameAccessUnits(packets) {
67
81
  offset += p.data.byteLength;
68
82
  }
69
83
  const nals = splitNalUnits(es);
70
- if (!nals.some((n) => nalType(n) === NAL_TYPE.accessUnitDelimiter)) return packets.map((p) => ({
71
- unit: toAccessUnit(p.data),
84
+ if (!nals.some((n) => syntax.type(n) === syntax.delimiter)) return packets.map((p) => ({
85
+ unit: syntax === AVC ? toAccessUnit(p.data) : syntax.unit(splitNalUnits(p.data)),
72
86
  pts: p.pts,
73
87
  dts: p.dts
74
88
  }));
@@ -81,14 +95,14 @@ function frameAccessUnits(packets) {
81
95
  while (boundaryIndex + 1 < boundaries.length && boundaries[boundaryIndex + 1].offset <= groupOffset) boundaryIndex += 1;
82
96
  const b = boundaries[boundaryIndex];
83
97
  framed.push({
84
- unit: accessUnitFromNals(group),
98
+ unit: syntax.unit(group),
85
99
  pts: b.pts,
86
100
  dts: b.dts
87
101
  });
88
102
  group = [];
89
103
  };
90
104
  for (const nal of nals) {
91
- if (nalType(nal) === NAL_TYPE.accessUnitDelimiter && group.length > 0) flush();
105
+ if (syntax.type(nal) === syntax.delimiter && group.length > 0) flush();
92
106
  if (group.length === 0) groupOffset = nal.byteOffset - es.byteOffset;
93
107
  group.push(nal);
94
108
  }
@@ -96,19 +110,24 @@ function frameAccessUnits(packets) {
96
110
  return framed;
97
111
  }
98
112
  function buildVideo(packets, presentationStart, wantCaptions, carried) {
99
- var _ref, _sps, _ref2, _pps;
113
+ var _packets$, _ref, _sps, _ref2, _pps, _ref3, _vps;
100
114
  if (packets.length === 0) return null;
101
- const framed = frameAccessUnits(packets);
115
+ const hevc = ((_packets$ = packets[0]) === null || _packets$ === void 0 ? void 0 : _packets$.streamType) === STREAM_TYPE.h265;
116
+ const syntax = hevc ? HEVC : AVC;
117
+ const framed = frameAccessUnits(packets, syntax);
102
118
  const units = framed.map((f) => f.unit);
119
+ let vps = null;
103
120
  let sps = null;
104
121
  let pps = null;
105
122
  for (const unit of units) {
123
+ if (unit.vps != null) vps = unit.vps;
106
124
  if (unit.sps !== null) sps = unit.sps;
107
125
  if (unit.pps !== null) pps = unit.pps;
108
126
  }
109
127
  sps = (_ref = (_sps = sps) !== null && _sps !== void 0 ? _sps : carried === null || carried === void 0 ? void 0 : carried.sps) !== null && _ref !== void 0 ? _ref : null;
110
128
  pps = (_ref2 = (_pps = pps) !== null && _pps !== void 0 ? _pps : carried === null || carried === void 0 ? void 0 : carried.pps) !== null && _ref2 !== void 0 ? _ref2 : null;
111
- if (sps === null || pps === null) return null;
129
+ vps = (_ref3 = (_vps = vps) !== null && _vps !== void 0 ? _vps : carried === null || carried === void 0 ? void 0 : carried.vps) !== null && _ref3 !== void 0 ? _ref3 : null;
130
+ if (sps === null || pps === null || hevc && vps === null) return null;
112
131
  const dts = unrollTimestamps(framed.map((f) => f.dts));
113
132
  const pts = unrollTimestamps(framed.map((f) => f.pts));
114
133
  const base = Math.round(presentationStart * VIDEO_TIMESCALE);
@@ -119,7 +138,7 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
119
138
  for (let i = 0; i < units.length; i += 1) {
120
139
  const unit = units[i];
121
140
  if (unit.sei.length === 0) continue;
122
- const triples = unit.sei.flatMap((nal) => ccTriplesFromSei(nal));
141
+ const triples = unit.sei.flatMap((nal) => ccTriplesFromSei(nal, syntax.seiHeader));
123
142
  if (triples.length === 0) continue;
124
143
  const time = presentationStart + (pts[i] - firstPts) / VIDEO_TIMESCALE;
125
144
  captions.push({
@@ -138,9 +157,9 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
138
157
  isKeyframe: units[i].isKeyframe
139
158
  });
140
159
  }
141
- const { width, height } = spsDimensions(sps);
160
+ const { width, height } = hevc ? hevcSpsInfo(sps) : spsDimensions(sps);
142
161
  return {
143
- config: {
162
+ config: _objectSpread2({
144
163
  id: VIDEO_TRACK_ID,
145
164
  kind: "video",
146
165
  timescale: VIDEO_TIMESCALE,
@@ -148,14 +167,18 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
148
167
  pps,
149
168
  width,
150
169
  height
151
- },
170
+ }, vps !== null ? { hvcC: hevcDecoderConfiguration(vps, sps, pps) } : {}),
152
171
  fragment: {
153
172
  trackId: VIDEO_TRACK_ID,
154
173
  baseMediaDecodeTime: base,
155
174
  samples
156
175
  },
157
176
  captions,
158
- parameterSets: {
177
+ parameterSets: vps !== null ? {
178
+ sps,
179
+ pps,
180
+ vps
181
+ } : {
159
182
  sps,
160
183
  pps
161
184
  }
@@ -168,7 +191,7 @@ function buildAudio(packets, presentationStart) {
168
191
  return adtsFragment(adts, AUDIO_TRACK_ID, presentationStart);
169
192
  }
170
193
  function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "all", parameterSets = null) {
171
- var _video$captions, _ref3, _streams$video$, _streams$audio$, _video$parameterSets;
194
+ var _video$captions, _ref4, _streams$video$, _streams$audio$, _video$parameterSets;
172
195
  const streams = demux(input);
173
196
  if (streams.notTransportStream) return {
174
197
  bytes: null,
@@ -208,7 +231,7 @@ function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "
208
231
  notTransportStream: false,
209
232
  empty: false,
210
233
  captions: (_video$captions = video === null || video === void 0 ? void 0 : video.captions) !== null && _video$captions !== void 0 ? _video$captions : [],
211
- metadata: timedTags(streams, presentationStart, (_ref3 = video !== null ? (_streams$video$ = streams.video[0]) === null || _streams$video$ === void 0 ? void 0 : _streams$video$.dts : (_streams$audio$ = streams.audio[0]) === null || _streams$audio$ === void 0 ? void 0 : _streams$audio$.pts) !== null && _ref3 !== void 0 ? _ref3 : null),
234
+ metadata: timedTags(streams, presentationStart, (_ref4 = video !== null ? (_streams$video$ = streams.video[0]) === null || _streams$video$ === void 0 ? void 0 : _streams$video$.dts : (_streams$audio$ = streams.audio[0]) === null || _streams$audio$ === void 0 ? void 0 : _streams$audio$.pts) !== null && _ref4 !== void 0 ? _ref4 : null),
212
235
  droppedAudio,
213
236
  parameterSets: (_video$parameterSets = video === null || video === void 0 ? void 0 : video.parameterSets) !== null && _video$parameterSets !== void 0 ? _video$parameterSets : null
214
237
  };
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  //#region src/containers/webvtt.ts
3
3
  /** `HH:MM:SS.mmm` or `MM:SS.mmm` to seconds, or null. */
4
4
  function parseTimestamp(text) {
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  import { fourcc, viewOf } from "./mp4-box/index.js";
3
3
  //#region src/containers/wvtt.ts
4
4
  /** The child boxes of `bytes`, as type and payload. */
@@ -1,5 +1,6 @@
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.154.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectWithoutProperties.js";
3
+ import { fetchWithin } from "../kernel/transport.js";
3
4
  import emeCore from "../stages/eme-core/index.js";
4
5
  //#region src/eme/index.ts
5
6
  /**
@@ -24,16 +25,16 @@ function attachEme(element, options = {}) {
24
25
  drm = api;
25
26
  },
26
27
  request(url, init) {
27
- var _init$method;
28
+ var _init$method, _init$timeoutMs;
28
29
  const draft = {
29
30
  url,
30
31
  headers: _objectSpread2({}, init.headers)
31
32
  };
32
33
  requestHook === null || requestHook === void 0 || requestHook(draft);
33
- return fetch(draft.url, _objectSpread2({
34
+ return fetchWithin((url, request) => fetch(url, request), draft.url, _objectSpread2({
34
35
  method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
35
36
  headers: draft.headers
36
- }, init.body !== void 0 ? { body: init.body } : {}));
37
+ }, init.body !== void 0 ? { body: init.body } : {}), (_init$timeoutMs = init.timeoutMs) !== null && _init$timeoutMs !== void 0 ? _init$timeoutMs : null, init.signal);
37
38
  },
38
39
  emit(event, payload) {
39
40
  var _listeners$get;
@@ -52,6 +53,7 @@ function attachEme(element, options = {}) {
52
53
  registerSwitchPolicy: noop,
53
54
  registerTypeProbe: noop,
54
55
  registerTimeProbe: noop,
56
+ registerChunkSplitter: noop,
55
57
  reduce: noop,
56
58
  dispatch: noop,
57
59
  addRequestHook: () => noop,
@@ -1,10 +1,11 @@
1
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
2
2
  import { exportTrace, replay } from "./kernel/trace.js";
3
3
  import { createBus } from "./kernel/bus.js";
4
4
  import { createEffectRunner } from "./kernel/effects.js";
5
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
5
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
6
6
  import { createSegmentPreparer } from "./kernel/prepare.js";
7
7
  import { cueFormat, normalizeMimeType } from "./kernel/mime.js";
8
+ import { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh, videoKind } from "./kernel/characteristics.js";
8
9
  import { findTrackSite, isTrick } from "./kernel/presentation.js";
9
10
  import { activeAudio, availableGroups, canSwitchTo, createArbiter, exclusionsOf } from "./kernel/rendition-select.js";
10
11
  import { createMseSink } from "./kernel/sinks/mse-sink.js";
@@ -15,7 +16,6 @@ import { compose } from "./kernel/loader.js";
15
16
  import { createMseController, decodable } from "./kernel/mse.js";
16
17
  import { createTrackRegistry } from "./kernel/track-registry.js";
17
18
  import { createTransport } from "./kernel/transport.js";
18
- import { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh } from "./kernel/characteristics.js";
19
19
  //#region src/index.ts
20
20
  /**
21
21
  * Mattebox: a modular adaptive-streaming engine for HLS and DASH.
@@ -71,6 +71,10 @@ function mattebox(options) {
71
71
  const transport = createTransport(_objectSpread2(_objectSpread2({
72
72
  absorb: prepare,
73
73
  inflight: (token) => bus.getState().scheduling.inflight.get(token),
74
+ split: () => {
75
+ var _hooks$chunkSplitter;
76
+ return (_hooks$chunkSplitter = hooks.chunkSplitter) !== null && _hooks$chunkSplitter !== void 0 ? _hooks$chunkSplitter : null;
77
+ },
74
78
  acceptManifestType: (contentType) => {
75
79
  const type = normalizeMimeType(contentType);
76
80
  return !(type.startsWith("audio/") || type.startsWith("video/")) || accepts(type);
@@ -429,4 +433,4 @@ mattebox.from = (el) => {
429
433
  return (_registry$get = registry.get(el)) !== null && _registry$get !== void 0 ? _registry$get : null;
430
434
  };
431
435
  //#endregion
432
- export { canSwitchTo, createReducer, exportTrace, initialState, isAudioDescription, isEnhancedSpeech, isOriginal, isSdh, mattebox, replay, resolveConfig };
436
+ export { canSwitchTo, createReducer, exportTrace, initialState, isAudioDescription, isEnhancedSpeech, isOriginal, isSdh, mattebox, replay, resolveConfig, videoKind };
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  //#region src/kernel/append-queue.ts
3
3
  function isQuotaError(err) {
4
4
  return err instanceof DOMException && err.name === "QuotaExceededError";
@@ -23,5 +23,23 @@ function isSdh(track) {
23
23
  function isOriginal(track) {
24
24
  return has(track, "public.original-content");
25
25
  }
26
+ /**
27
+ * The kind of a video track from its standard roles, as HTML's rules for
28
+ * media containers map them to VideoTrack.kind: sign and commentary stand
29
+ * alone, caption and subtitle with main are a picture with the text in it,
30
+ * and alternate is another version.
31
+ */
32
+ function videoKind(track) {
33
+ var _track$roles2;
34
+ const roles = (_track$roles2 = track.roles) !== null && _track$roles2 !== void 0 ? _track$roles2 : track.role !== void 0 ? [track.role] : [];
35
+ const main = roles.includes("main");
36
+ if (roles.includes("sign")) return "sign";
37
+ if (roles.includes("commentary") && !main) return "commentary";
38
+ if (roles.includes("caption") && main) return "captions";
39
+ if (roles.includes("subtitle") && main) return "subtitles";
40
+ if (main) return "main";
41
+ if (roles.includes("alternate")) return "alternative";
42
+ return "";
43
+ }
26
44
  //#endregion
27
- export { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh };
45
+ export { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh, videoKind };
@@ -13,6 +13,7 @@ function createStageContext(deps) {
13
13
  let registeredPolicy = false;
14
14
  let registeredProbe = false;
15
15
  let registeredTimeProbe = false;
16
+ let registeredSplitter = false;
16
17
  return {
17
18
  ctx: {
18
19
  element: deps.element,
@@ -72,6 +73,11 @@ function createStageContext(deps) {
72
73
  deps.hooks.timeProbe = probe;
73
74
  registeredTimeProbe = true;
74
75
  },
76
+ registerChunkSplitter(split) {
77
+ if (deps.hooks.chunkSplitter != null) throw new Error("a chunk splitter is already registered");
78
+ deps.hooks.chunkSplitter = split;
79
+ registeredSplitter = true;
80
+ },
75
81
  reduce(slice, reducer) {
76
82
  deps.slices.push([slice, reducer]);
77
83
  },
@@ -100,6 +106,7 @@ function createStageContext(deps) {
100
106
  if (registeredPolicy) deps.hooks.switchPolicy = null;
101
107
  if (registeredProbe) deps.hooks.typeProbe = null;
102
108
  if (registeredTimeProbe) deps.hooks.timeProbe = null;
109
+ if (registeredSplitter) deps.hooks.chunkSplitter = null;
103
110
  }
104
111
  };
105
112
  }
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  import { createBus } from "./bus.js";
3
3
  import { createEffectRunner } from "./effects.js";
4
4
  import { createSegmentPreparer } from "./prepare.js";
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  import { createAppendQueue } from "./append-queue.js";
3
3
  import { createEvictor } from "./evictor.js";
4
4
  //#region src/kernel/mse.ts
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
3
3
  //#region src/kernel/prepare.ts
4
4
  /**
5
5
  * The boundary meta a transform and the probe receive. The content type
@@ -27,7 +27,7 @@ function createSegmentPreparer(deps) {
27
27
  const chains = /* @__PURE__ */ new Map();
28
28
  return (fact) => {
29
29
  var _chains$get;
30
- if (fact.type !== "SEGMENT_LOADED" || fact.token === void 0) {
30
+ if (fact.type !== "SEGMENT_LOADED" && fact.type !== "SEGMENT_CHUNK" || fact.token === void 0) {
31
31
  deps.absorb(fact);
32
32
  return;
33
33
  }
@@ -1,8 +1,17 @@
1
+ import { videoKind } from "./characteristics.js";
1
2
  //#region src/kernel/presentation.ts
2
3
  /** An I-frame-only video track, kept for trick play and never selected for normal playback. */
3
4
  function isTrick(track) {
4
5
  return track.role === "trick";
5
6
  }
7
+ /**
8
+ * A video track that shows the main picture: its kind is main, or the
9
+ * manifest gives none. Not a sign-language, alternate or commentary version.
10
+ */
11
+ function isMainPicture(track) {
12
+ const kind = videoKind(track);
13
+ return !isTrick(track) && (kind === "main" || kind === "");
14
+ }
6
15
  function findTrackSite(presentation, trackId) {
7
16
  var _presentation$periods;
8
17
  for (const period of (_presentation$periods = presentation === null || presentation === void 0 ? void 0 : presentation.periods) !== null && _presentation$periods !== void 0 ? _presentation$periods : []) for (const track of period.tracks) if (track.id === trackId) return {
@@ -21,4 +30,4 @@ function findRendition(presentation, renditionId) {
21
30
  return null;
22
31
  }
23
32
  //#endregion
24
- export { findRendition, findTrackSite, isTrick };
33
+ export { findRendition, findTrackSite, isMainPicture, isTrick };
@@ -1,11 +1,11 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
2
2
  import { tickAfter } from "./effects.js";
3
3
  import { cueFormat, normalizeMimeType, typeString } from "./mime.js";
4
- import { findRendition, findTrackSite, isTrick } from "./presentation.js";
4
+ import { findRendition, findTrackSite, isMainPicture, isTrick } from "./presentation.js";
5
5
  import { applyRefresh } from "./refresh.js";
6
6
  import { reconciledOffset, segmentAtTime } from "./timeline.js";
7
7
  import { bufferedEndFrom, reachesEnd, schedule } from "./scheduler.js";
8
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
8
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectWithoutProperties.js";
9
9
  import { activeAudio, audioGroup, audioInGroup, availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
10
10
  import { sbIdFor } from "./sinks/mse-sink.js";
11
11
  //#region src/kernel/reducer.ts
@@ -236,11 +236,66 @@ function segmentedAt(candidates, time, periodStart) {
236
236
  * beside video, a text cue, or a playlist is a small transfer whose time
237
237
  * is latency, not bandwidth.
238
238
  */
239
+ /**
240
+ * The offset an append of media bytes takes. The first media segment to
241
+ * land in an epoch settles it for every buffer: its presentation start
242
+ * minus the decode time the probe read from its bytes, or the manifest's
243
+ * prediction when nothing read one. Later segments of the epoch, on any
244
+ * buffer, apply the settled value, so audio and video keep the alignment
245
+ * their shared media clock gives them: one offset per timeline, as
246
+ * videojs-http-streaming takes it from its main loader. Playlist
247
+ * discontinuities and period boundaries both land here.
248
+ */
249
+ function placeAppend(timeline, matched, mediaStart) {
250
+ const effects = [];
251
+ let reconciled = timeline.reconciled;
252
+ let offset = matched.epoch === void 0 ? void 0 : reconciled.get(matched.epoch);
253
+ if (offset === void 0 && matched.epoch !== void 0 && matched.seq >= 0 && matched.segmentStart !== void 0) {
254
+ const settled = mediaStart !== void 0 ? reconciledOffset(matched.segmentStart, mediaStart) : matched.timestampOffset;
255
+ if (settled !== void 0) {
256
+ offset = settled;
257
+ reconciled = new Map(reconciled).set(matched.epoch, settled);
258
+ }
259
+ }
260
+ if (offset === void 0) offset = matched.timestampOffset;
261
+ let periodOffsets = timeline.periodOffsets;
262
+ if (offset !== void 0 && periodOffsets.get(matched.sbId) !== offset) {
263
+ effects.push({
264
+ kind: "setTimestampOffset",
265
+ sbId: matched.sbId,
266
+ offset
267
+ });
268
+ periodOffsets = new Map(periodOffsets).set(matched.sbId, offset);
269
+ }
270
+ if (periodOffsets === timeline.periodOffsets && reconciled === timeline.reconciled) return {
271
+ timeline,
272
+ effects
273
+ };
274
+ return {
275
+ timeline: _objectSpread2(_objectSpread2({}, timeline), {}, {
276
+ periodOffsets,
277
+ reconciled
278
+ }),
279
+ effects
280
+ };
281
+ }
239
282
  function samplesThroughput(state, request) {
240
283
  var _state$tracks$active$;
241
284
  const lead = (_state$tracks$active$ = state.tracks.active.get("video")) !== null && _state$tracks$active$ !== void 0 ? _state$tracks$active$ : state.tracks.active.get("audio");
242
285
  return lead === void 0 ? request.renditionId === void 0 : request.trackId === lead;
243
286
  }
287
+ /**
288
+ * Seconds before the live edge that a jump to it lands. The edge often sits
289
+ * exactly on a segment boundary, and the segment that starts there may not
290
+ * start with a key frame; the scheduler then fetches the one before. A seek
291
+ * to that one's exact end, with media arriving a piece at a time, makes
292
+ * WebKit's GStreamer backend fail to decode (WebKitGTK and WPE); a target
293
+ * inside it does not.
294
+ */
295
+ const EDGE_INSET = .05;
296
+ function edgeStart(spanStart, edge) {
297
+ return Math.max(spanStart, edge - EDGE_INSET);
298
+ }
244
299
  /** Abort effects for every matching in-flight request, plus the state with them removed. */
245
300
  function abortInflight(state, trackId) {
246
301
  const effects = [];
@@ -379,7 +434,7 @@ function reduceCommand(state, msg, cfg, hooks) {
379
434
  const [next, aborts] = abortInflight(state);
380
435
  return [_objectSpread2(_objectSpread2({}, next), {}, { scheduling: clearRepeat(next.scheduling) }), [...aborts, {
381
436
  kind: "seekElement",
382
- to: state.live.edge
437
+ to: edgeStart(state.live.span.start, state.live.edge)
383
438
  }]];
384
439
  }
385
440
  case "SELECT_TRACK": {
@@ -626,7 +681,7 @@ function loadPresentation(state, merged, undecodableIds = /* @__PURE__ */ new Se
626
681
  for (const [token, request] of inflight) if (request.trackId === "manifest") inflight.delete(token);
627
682
  const phase = state.lifecycle.phase === "loading" ? "ready" : state.lifecycle.phase;
628
683
  const active = new Map(state.tracks.active);
629
- for (const period of presentation.periods) for (const track of period.tracks) if ((track.contentType === "video" || track.contentType === "audio") && !isTrick(track) && !active.has(track.contentType) && track.renditions.some((r) => !undecodableIds.has(r.id))) active.set(track.contentType, track.id);
684
+ for (const mainOnly of [true, false]) for (const period of presentation.periods) for (const track of period.tracks) if ((track.contentType === "video" || track.contentType === "audio") && !isTrick(track) && !active.has(track.contentType) && !(mainOnly && track.contentType === "video" && !isMainPicture(track)) && track.renditions.some((r) => !undecodableIds.has(r.id))) active.set(track.contentType, track.id);
630
685
  const loaded = _objectSpread2(_objectSpread2({}, state), {}, {
631
686
  lifecycle: { phase },
632
687
  presentation,
@@ -697,7 +752,24 @@ function reduceFact(state, msg, cfg, hooks) {
697
752
  const [failed, report] = failManifest(stopped, _objectSpread2(_objectSpread2({}, msg.error), {}, { fatal: true }), { context: msg.error.context });
698
753
  return [failed, [...aborts, ...report]];
699
754
  }
755
+ case "SEGMENT_CHUNK": {
756
+ const matched = state.scheduling.inflight.get(msg.token);
757
+ if ((matched === null || matched === void 0 ? void 0 : matched.sbId) === void 0) return [state, []];
758
+ const buffer = state.buffers.get(matched.sbId);
759
+ if (buffer === void 0 || buffer.initFor !== matched.renditionId) return [state, []];
760
+ const placed = placeAppend(state.timeline, _objectSpread2(_objectSpread2({}, matched), {}, { sbId: matched.sbId }), msg.mediaStart);
761
+ const buffers = new Map(state.buffers).set(matched.sbId, _objectSpread2(_objectSpread2({}, buffer), {}, { pendingAppends: buffer.pendingAppends + 1 }));
762
+ return [_objectSpread2(_objectSpread2({}, state), {}, {
763
+ buffers,
764
+ timeline: placed.timeline
765
+ }), [...placed.effects, {
766
+ kind: "append",
767
+ sbId: matched.sbId,
768
+ data: msg.bytes
769
+ }]];
770
+ }
700
771
  case "SEGMENT_LOADED": {
772
+ var _msg$transfer;
701
773
  let matched = null;
702
774
  if (msg.token !== void 0) {
703
775
  var _state$scheduling$inf;
@@ -709,7 +781,11 @@ function reduceFact(state, msg, cfg, hooks) {
709
781
  if (matched === null) return [state, []];
710
782
  const inflight = new Map(state.scheduling.inflight);
711
783
  inflight.delete(matched.token);
712
- const sampleBps = msg.rtt > 0 && msg.size >= cfg.ewmaMinSampleBytes && samplesThroughput(state, matched) ? msg.size * 8e3 / msg.rtt : null;
784
+ const sample = (_msg$transfer = msg.transfer) !== null && _msg$transfer !== void 0 ? _msg$transfer : {
785
+ bytes: msg.size,
786
+ ms: msg.rtt
787
+ };
788
+ const sampleBps = sample.ms > 0 && sample.bytes >= cfg.ewmaMinSampleBytes && samplesThroughput(state, matched) ? sample.bytes * 8e3 / sample.ms : null;
713
789
  const stats = sampleBps === null ? state.stats : {
714
790
  throughputEwma: ewma(state.stats.throughputEwma, sampleBps, cfg.ewmaAlpha),
715
791
  throughputFastEwma: ewma(state.stats.throughputFastEwma, sampleBps, cfg.ewmaFastAlpha)
@@ -810,30 +886,11 @@ function reduceFact(state, msg, cfg, hooks) {
810
886
  initFor
811
887
  }
812
888
  }]];
813
- let reconciled = state.timeline.reconciled;
814
- let offset = matched.epoch === void 0 ? void 0 : reconciled.get(matched.epoch);
815
- if (offset === void 0 && matched.epoch !== void 0 && matched.seq >= 0 && matched.segmentStart !== void 0) {
816
- const settled = msg.mediaStart !== void 0 ? reconciledOffset(matched.segmentStart, msg.mediaStart) : matched.timestampOffset;
817
- if (settled !== void 0) {
818
- offset = settled;
819
- reconciled = new Map(reconciled).set(matched.epoch, settled);
820
- }
821
- }
822
- if (offset === void 0) offset = matched.timestampOffset;
823
- let periodOffsets = state.timeline.periodOffsets;
824
- if (offset !== void 0 && periodOffsets.get(matched.sbId) !== offset) {
825
- effects.push({
826
- kind: "setTimestampOffset",
827
- sbId: matched.sbId,
828
- offset
829
- });
830
- periodOffsets = new Map(periodOffsets).set(matched.sbId, offset);
831
- }
832
- if (periodOffsets !== state.timeline.periodOffsets || reconciled !== state.timeline.reconciled) timeline = _objectSpread2(_objectSpread2({}, state.timeline), {}, {
833
- periodOffsets,
834
- reconciled
835
- });
836
- effects.push({
889
+ const placed = placeAppend(state.timeline, _objectSpread2(_objectSpread2({}, matched), {}, { sbId: matched.sbId }), msg.mediaStart);
890
+ effects.push(...placed.effects);
891
+ timeline = placed.timeline;
892
+ const appends = msg.bytes.byteLength > 0 || matched.chunked !== true;
893
+ if (appends) effects.push({
837
894
  kind: "append",
838
895
  sbId: matched.sbId,
839
896
  data: msg.bytes
@@ -853,7 +910,7 @@ function reduceFact(state, msg, cfg, hooks) {
853
910
  };
854
911
  appended = [...((_appended2 = appended) !== null && _appended2 !== void 0 ? _appended2 : []).filter((seg) => seg.seq !== seq || seg.renditionId !== renditionId).slice(-31), entry];
855
912
  }
856
- nextBuffers.set(matched.sbId, _objectSpread2(_objectSpread2({}, buffer), {}, { pendingAppends: buffer.pendingAppends + 1 }, appended !== void 0 ? { appended } : {}));
913
+ nextBuffers.set(matched.sbId, _objectSpread2(_objectSpread2({}, buffer), {}, { pendingAppends: buffer.pendingAppends + (appends ? 1 : 0) }, appended !== void 0 ? { appended } : {}));
857
914
  buffers = nextBuffers;
858
915
  }
859
916
  if (matched.sbId === sbIdFor("video") && matched.renditionId !== void 0 && matched.segmentStart !== void 0) {
@@ -880,6 +937,7 @@ function reduceFact(state, msg, cfg, hooks) {
880
937
  var _msg$status2;
881
938
  const inflight = new Map(state.scheduling.inflight);
882
939
  for (const [token, request] of inflight) if (request.trackId === msg.trackId && request.seq === msg.seq) inflight.delete(token);
940
+ if (msg.preload === true) return [_objectSpread2(_objectSpread2({}, state), {}, { scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }) }), []];
883
941
  if (msg.trackId === "manifest") {
884
942
  var _msg$error$context, _msg$status;
885
943
  const contentType = (_msg$error$context = msg.error.context) === null || _msg$error$context === void 0 ? void 0 : _msg$error$context.contentType;
@@ -1073,12 +1131,13 @@ function reduceFact(state, msg, cfg, hooks) {
1073
1131
  end: msg.end
1074
1132
  });
1075
1133
  if (firstWindow && msg.edge > state.playback.currentTime + 1) {
1076
- const [scheduled, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, withLive), {}, { playback: _objectSpread2(_objectSpread2({}, withLive.playback), {}, { currentTime: msg.edge }) }), hooks, cfg);
1134
+ const to = edgeStart(msg.start, msg.edge);
1135
+ const [scheduled, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, withLive), {}, { playback: _objectSpread2(_objectSpread2({}, withLive.playback), {}, { currentTime: to }) }), hooks, cfg);
1077
1136
  return [scheduled, [
1078
1137
  ...spanEffects,
1079
1138
  {
1080
1139
  kind: "seekElement",
1081
- to: msg.edge
1140
+ to
1082
1141
  },
1083
1142
  ...effects
1084
1143
  ]];
@@ -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.154.0/helpers/esm/objectSpread2.js";
2
2
  //#region src/kernel/refresh.ts
3
3
  /** The presentation with the refresh merged, or null when it names no rendition the presentation holds. */
4
4
  function applyRefresh(presentation, refresh) {
@@ -27,7 +27,7 @@ function applyRefresh(presentation, refresh) {
27
27
  }
28
28
  return _objectSpread2(_objectSpread2({}, presentation), {}, {
29
29
  isLive: true,
30
- live: _objectSpread2(_objectSpread2(_objectSpread2({}, presentation.live), refresh.updatePeriod !== void 0 ? { updatePeriod: refresh.updatePeriod } : {}), refresh.dateAnchor !== void 0 ? { dateAnchor: refresh.dateAnchor } : {}),
30
+ live: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, presentation.live), refresh.updatePeriod !== void 0 ? { updatePeriod: refresh.updatePeriod } : {}), refresh.holdBack !== void 0 ? { holdBack: refresh.holdBack } : {}), refresh.lowLatency !== void 0 ? { lowLatency: refresh.lowLatency } : {}), refresh.dateAnchor !== void 0 ? { dateAnchor: refresh.dateAnchor } : {}),
31
31
  periods
32
32
  });
33
33
  }
@@ -1,8 +1,8 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
2
2
  import { findRendition, findTrackSite } from "./presentation.js";
3
3
  import { segmentAtTime } from "./timeline.js";
4
4
  import { bufferedEndFrom } from "./scheduler.js";
5
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
5
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectWithoutProperties.js";
6
6
  //#region src/kernel/rendition-select.ts
7
7
  const _excluded = [
8
8
  "maxHeight",