mattebox 0.6.1 → 0.8.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 (277) hide show
  1. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  2. package/dist/cdn/mattebox.dash.min.js +3 -3
  3. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  6. package/dist/cdn/mattebox.dual.min.js +3 -3
  7. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  10. package/dist/cdn/mattebox.hls.min.js +3 -3
  11. package/dist/cdn/mattebox.kernel.min.js +1 -1
  12. package/dist/cdn/mattebox.min.js +3 -6
  13. package/dist/containers/adts.d.ts +10 -0
  14. package/dist/containers/adts.d.ts.map +1 -1
  15. package/dist/containers/adts.js +27 -7
  16. package/dist/containers/adts.js.map +1 -1
  17. package/dist/containers/codec-probe/index.d.ts +0 -6
  18. package/dist/containers/codec-probe/index.d.ts.map +1 -1
  19. package/dist/containers/codec-probe/index.js +14 -23
  20. package/dist/containers/codec-probe/index.js.map +1 -1
  21. package/dist/containers/fmp4/fit.d.ts +26 -0
  22. package/dist/containers/fmp4/fit.d.ts.map +1 -0
  23. package/dist/containers/fmp4/fit.js +49 -0
  24. package/dist/containers/fmp4/fit.js.map +1 -0
  25. package/dist/containers/fmp4/writer.d.ts +7 -0
  26. package/dist/containers/fmp4/writer.d.ts.map +1 -1
  27. package/dist/containers/fmp4/writer.js +9 -1
  28. package/dist/containers/fmp4/writer.js.map +1 -1
  29. package/dist/containers/id3.d.ts.map +1 -1
  30. package/dist/containers/id3.js +2 -1
  31. package/dist/containers/id3.js.map +1 -1
  32. package/dist/containers/mp4-box/index.d.ts +66 -0
  33. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  34. package/dist/containers/mp4-box/index.js +207 -23
  35. package/dist/containers/mp4-box/index.js.map +1 -1
  36. package/dist/containers/packed-audio/index.d.ts.map +1 -1
  37. package/dist/containers/packed-audio/index.js +4 -26
  38. package/dist/containers/packed-audio/index.js.map +1 -1
  39. package/dist/containers/sei.d.ts +5 -0
  40. package/dist/containers/sei.d.ts.map +1 -1
  41. package/dist/containers/sei.js +5 -2
  42. package/dist/containers/sei.js.map +1 -1
  43. package/dist/containers/ts-transmux/demux.d.ts +7 -1
  44. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  45. package/dist/containers/ts-transmux/demux.js +38 -17
  46. package/dist/containers/ts-transmux/demux.js.map +1 -1
  47. package/dist/containers/ts-transmux/h264.d.ts.map +1 -1
  48. package/dist/containers/ts-transmux/h264.js +1 -17
  49. package/dist/containers/ts-transmux/h264.js.map +1 -1
  50. package/dist/containers/ts-transmux/index.d.ts.map +1 -1
  51. package/dist/containers/ts-transmux/index.js +9 -1
  52. package/dist/containers/ts-transmux/index.js.map +1 -1
  53. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  54. package/dist/containers/ts-transmux/transmux.js +6 -36
  55. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  56. package/dist/{stages/text-webvtt/parse.d.ts → containers/webvtt.d.ts} +4 -3
  57. package/dist/containers/webvtt.d.ts.map +1 -0
  58. package/dist/{stages/text-webvtt/parse.js → containers/webvtt.js} +1 -1
  59. package/dist/containers/webvtt.js.map +1 -0
  60. package/dist/es2015/containers/adts.js +28 -8
  61. package/dist/es2015/containers/codec-probe/index.js +17 -26
  62. package/dist/es2015/containers/fmp4/fit.js +46 -0
  63. package/dist/es2015/containers/fmp4/writer.js +9 -1
  64. package/dist/es2015/containers/id3.js +2 -2
  65. package/dist/es2015/containers/mp4-box/index.js +207 -19
  66. package/dist/es2015/containers/packed-audio/index.js +4 -28
  67. package/dist/es2015/containers/sei.js +6 -3
  68. package/dist/es2015/containers/ts-transmux/demux.js +41 -22
  69. package/dist/es2015/containers/ts-transmux/h264.js +1 -17
  70. package/dist/es2015/containers/ts-transmux/index.js +6 -3
  71. package/dist/es2015/containers/ts-transmux/transmux.js +8 -39
  72. package/dist/es2015/{stages/text-webvtt/parse.js → containers/webvtt.js} +2 -2
  73. package/dist/es2015/index.js +6 -15
  74. package/dist/es2015/kernel/base64.js +25 -0
  75. package/dist/es2015/kernel/effects.js +21 -1
  76. package/dist/es2015/kernel/mime.js +5 -1
  77. package/dist/es2015/kernel/presentation.js +24 -0
  78. package/dist/es2015/kernel/reducer.js +61 -75
  79. package/dist/es2015/kernel/refresh.js +1 -1
  80. package/dist/es2015/kernel/rendition-select.js +50 -5
  81. package/dist/es2015/kernel/sinks/text-track-sink.js +27 -26
  82. package/dist/es2015/kernel/timeline.js +1 -1
  83. package/dist/es2015/kernel/track-registry.js +10 -2
  84. package/dist/es2015/kernel/url.js +12 -0
  85. package/dist/es2015/presets/full/index.js +9 -3
  86. package/dist/es2015/protocols/adapter-shared.js +28 -0
  87. package/dist/es2015/protocols/dash-cmaf/index.js +18 -55
  88. package/dist/es2015/protocols/dash-cmaf/parse.js +60 -54
  89. package/dist/es2015/protocols/dash-live/index.js +13 -28
  90. package/dist/es2015/protocols/dimensions.js +15 -0
  91. package/dist/es2015/protocols/hls-cmaf/index.js +17 -52
  92. package/dist/es2015/protocols/hls-cmaf/lexer.js +3 -0
  93. package/dist/es2015/protocols/hls-cmaf/parse.js +134 -33
  94. package/dist/es2015/protocols/hls-cmaf/unavailable.js +2 -1
  95. package/dist/es2015/protocols/hls-live/index.js +24 -52
  96. package/dist/es2015/stages/abr/index.js +7 -10
  97. package/dist/es2015/stages/abr-persist/index.js +17 -10
  98. package/dist/es2015/stages/aes-128/index.js +14 -7
  99. package/dist/es2015/stages/alt-audio/index.js +24 -12
  100. package/dist/es2015/stages/chapters/index.js +170 -0
  101. package/dist/es2015/stages/chapters/parse.js +176 -0
  102. package/dist/es2015/stages/cmcd/index.js +14 -4
  103. package/dist/es2015/stages/codec-switch/index.js +2 -5
  104. package/dist/es2015/stages/content-steering/index.js +12 -15
  105. package/dist/es2015/stages/eme-cenc/index.js +10 -4
  106. package/dist/es2015/stages/eme-core/index.js +29 -11
  107. package/dist/es2015/stages/eme-fairplay/index.js +11 -7
  108. package/dist/es2015/stages/nal-scan/index.js +30 -140
  109. package/dist/es2015/stages/recovery/index.js +46 -53
  110. package/dist/es2015/stages/text-cea608/index.js +3 -17
  111. package/dist/es2015/stages/text-webvtt/index.js +1 -1
  112. package/dist/es2015/stages/text-webvtt-segmented/index.js +15 -8
  113. package/dist/es2015/stages/thumbnails/index.js +212 -42
  114. package/dist/es2015/stages/trick-play/index.js +463 -0
  115. package/dist/index.d.ts +6 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +5 -21
  118. package/dist/index.js.map +1 -1
  119. package/dist/kernel/base64.d.ts +9 -0
  120. package/dist/kernel/base64.d.ts.map +1 -0
  121. package/dist/kernel/base64.js +26 -0
  122. package/dist/kernel/base64.js.map +1 -0
  123. package/dist/kernel/effects.d.ts +9 -1
  124. package/dist/kernel/effects.d.ts.map +1 -1
  125. package/dist/kernel/effects.js +12 -0
  126. package/dist/kernel/effects.js.map +1 -1
  127. package/dist/kernel/lifecycle.js +1 -1
  128. package/dist/kernel/lifecycle.js.map +1 -1
  129. package/dist/kernel/mime.d.ts +2 -0
  130. package/dist/kernel/mime.d.ts.map +1 -1
  131. package/dist/kernel/mime.js +4 -0
  132. package/dist/kernel/mime.js.map +1 -1
  133. package/dist/kernel/presentation.d.ts +20 -0
  134. package/dist/kernel/presentation.d.ts.map +1 -0
  135. package/dist/kernel/presentation.js +25 -0
  136. package/dist/kernel/presentation.js.map +1 -0
  137. package/dist/kernel/reducer.d.ts +9 -0
  138. package/dist/kernel/reducer.d.ts.map +1 -1
  139. package/dist/kernel/reducer.js +72 -84
  140. package/dist/kernel/reducer.js.map +1 -1
  141. package/dist/kernel/refresh.d.ts.map +1 -1
  142. package/dist/kernel/refresh.js +1 -0
  143. package/dist/kernel/refresh.js.map +1 -1
  144. package/dist/kernel/rendition-select.d.ts +19 -4
  145. package/dist/kernel/rendition-select.d.ts.map +1 -1
  146. package/dist/kernel/rendition-select.js +67 -4
  147. package/dist/kernel/rendition-select.js.map +1 -1
  148. package/dist/kernel/sinks/text-track-sink.d.ts +9 -0
  149. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  150. package/dist/kernel/sinks/text-track-sink.js +29 -29
  151. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  152. package/dist/kernel/timeline.d.ts +8 -1
  153. package/dist/kernel/timeline.d.ts.map +1 -1
  154. package/dist/kernel/timeline.js +2 -2
  155. package/dist/kernel/timeline.js.map +1 -1
  156. package/dist/kernel/track-registry.d.ts.map +1 -1
  157. package/dist/kernel/track-registry.js +17 -1
  158. package/dist/kernel/track-registry.js.map +1 -1
  159. package/dist/kernel/url.d.ts +4 -0
  160. package/dist/kernel/url.d.ts.map +1 -0
  161. package/dist/kernel/url.js +11 -0
  162. package/dist/kernel/url.js.map +1 -0
  163. package/dist/presets/full/index.d.ts.map +1 -1
  164. package/dist/presets/full/index.js +8 -2
  165. package/dist/presets/full/index.js.map +1 -1
  166. package/dist/protocols/adapter-shared.d.ts +23 -0
  167. package/dist/protocols/adapter-shared.d.ts.map +1 -0
  168. package/dist/protocols/adapter-shared.js +23 -0
  169. package/dist/protocols/adapter-shared.js.map +1 -0
  170. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  171. package/dist/protocols/dash-cmaf/index.js +17 -73
  172. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  173. package/dist/protocols/dash-cmaf/parse.d.ts +2 -5
  174. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  175. package/dist/protocols/dash-cmaf/parse.js +46 -39
  176. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  177. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  178. package/dist/protocols/dash-live/index.js +13 -17
  179. package/dist/protocols/dash-live/index.js.map +1 -1
  180. package/dist/protocols/dimensions.d.ts +8 -0
  181. package/dist/protocols/dimensions.d.ts.map +1 -0
  182. package/dist/protocols/dimensions.js +13 -0
  183. package/dist/protocols/dimensions.js.map +1 -0
  184. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  185. package/dist/protocols/hls-cmaf/index.js +17 -56
  186. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  187. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  188. package/dist/protocols/hls-cmaf/lexer.js +3 -0
  189. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  190. package/dist/protocols/hls-cmaf/parse.d.ts +13 -9
  191. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  192. package/dist/protocols/hls-cmaf/parse.js +146 -22
  193. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  194. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
  195. package/dist/protocols/hls-cmaf/unavailable.js +3 -1
  196. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
  197. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  198. package/dist/protocols/hls-live/index.js +17 -52
  199. package/dist/protocols/hls-live/index.js.map +1 -1
  200. package/dist/stages/abr/index.d.ts.map +1 -1
  201. package/dist/stages/abr/index.js +8 -14
  202. package/dist/stages/abr/index.js.map +1 -1
  203. package/dist/stages/abr-cap-size/index.d.ts +1 -1
  204. package/dist/stages/abr-persist/index.d.ts.map +1 -1
  205. package/dist/stages/abr-persist/index.js +17 -7
  206. package/dist/stages/abr-persist/index.js.map +1 -1
  207. package/dist/stages/aes-128/index.d.ts +0 -9
  208. package/dist/stages/aes-128/index.d.ts.map +1 -1
  209. package/dist/stages/aes-128/index.js +13 -11
  210. package/dist/stages/aes-128/index.js.map +1 -1
  211. package/dist/stages/alt-audio/index.d.ts +16 -0
  212. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  213. package/dist/stages/alt-audio/index.js +23 -12
  214. package/dist/stages/alt-audio/index.js.map +1 -1
  215. package/dist/stages/chapters/index.d.ts +26 -0
  216. package/dist/stages/chapters/index.d.ts.map +1 -0
  217. package/dist/stages/chapters/index.js +156 -0
  218. package/dist/stages/chapters/index.js.map +1 -0
  219. package/dist/stages/chapters/parse.d.ts +65 -0
  220. package/dist/stages/chapters/parse.d.ts.map +1 -0
  221. package/dist/stages/chapters/parse.js +201 -0
  222. package/dist/stages/chapters/parse.js.map +1 -0
  223. package/dist/stages/cmcd/index.d.ts +0 -11
  224. package/dist/stages/cmcd/index.d.ts.map +1 -1
  225. package/dist/stages/cmcd/index.js +15 -9
  226. package/dist/stages/cmcd/index.js.map +1 -1
  227. package/dist/stages/codec-switch/index.d.ts.map +1 -1
  228. package/dist/stages/codec-switch/index.js +3 -8
  229. package/dist/stages/codec-switch/index.js.map +1 -1
  230. package/dist/stages/content-steering/index.d.ts.map +1 -1
  231. package/dist/stages/content-steering/index.js +12 -9
  232. package/dist/stages/content-steering/index.js.map +1 -1
  233. package/dist/stages/eme-cenc/index.d.ts +0 -7
  234. package/dist/stages/eme-cenc/index.d.ts.map +1 -1
  235. package/dist/stages/eme-cenc/index.js +9 -5
  236. package/dist/stages/eme-cenc/index.js.map +1 -1
  237. package/dist/stages/eme-core/index.d.ts.map +1 -1
  238. package/dist/stages/eme-core/index.js +31 -15
  239. package/dist/stages/eme-core/index.js.map +1 -1
  240. package/dist/stages/eme-fairplay/index.d.ts +0 -7
  241. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  242. package/dist/stages/eme-fairplay/index.js +11 -9
  243. package/dist/stages/eme-fairplay/index.js.map +1 -1
  244. package/dist/stages/nal-scan/index.d.ts.map +1 -1
  245. package/dist/stages/nal-scan/index.js +32 -145
  246. package/dist/stages/nal-scan/index.js.map +1 -1
  247. package/dist/stages/recovery/index.d.ts.map +1 -1
  248. package/dist/stages/recovery/index.js +42 -56
  249. package/dist/stages/recovery/index.js.map +1 -1
  250. package/dist/stages/text-cea608/index.d.ts +11 -0
  251. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  252. package/dist/stages/text-cea608/index.js +3 -23
  253. package/dist/stages/text-cea608/index.js.map +1 -1
  254. package/dist/stages/text-webvtt/index.d.ts +12 -0
  255. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  256. package/dist/stages/text-webvtt/index.js +1 -1
  257. package/dist/stages/text-webvtt/index.js.map +1 -1
  258. package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -1
  259. package/dist/stages/text-webvtt-segmented/index.js +11 -8
  260. package/dist/stages/text-webvtt-segmented/index.js.map +1 -1
  261. package/dist/stages/thumbnails/index.d.ts +39 -10
  262. package/dist/stages/thumbnails/index.d.ts.map +1 -1
  263. package/dist/stages/thumbnails/index.js +220 -30
  264. package/dist/stages/thumbnails/index.js.map +1 -1
  265. package/dist/stages/trick-play/index.d.ts +51 -0
  266. package/dist/stages/trick-play/index.d.ts.map +1 -0
  267. package/dist/stages/trick-play/index.js +480 -0
  268. package/dist/stages/trick-play/index.js.map +1 -0
  269. package/dist/types/ir.d.ts +40 -1
  270. package/dist/types/ir.d.ts.map +1 -1
  271. package/dist/types/kernel.d.ts +2 -0
  272. package/dist/types/kernel.d.ts.map +1 -1
  273. package/dist/types/messages.d.ts +12 -1
  274. package/dist/types/messages.d.ts.map +1 -1
  275. package/package.json +1 -1
  276. package/dist/stages/text-webvtt/parse.d.ts.map +0 -1
  277. package/dist/stages/text-webvtt/parse.js.map +0 -1
@@ -1,6 +1,10 @@
1
1
  import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled } from "../../kernel/effects.js";
2
3
  import { normalizeMimeType } from "../../kernel/mime.js";
3
- import { ladderNeighbours } from "../../kernel/rendition-select.js";
4
+ import { findRendition } from "../../kernel/presentation.js";
5
+ import { isUnresolved } from "../../kernel/timeline.js";
6
+ import { activeRenditions } from "../../kernel/rendition-select.js";
7
+ import { manifestFact } from "../adapter-shared.js";
4
8
  import { parse, sidxToSegments } from "./parse.js";
5
9
  //#region src/protocols/dash-cmaf/index.ts
6
10
  /**
@@ -21,9 +25,7 @@ const INDEX_TOKEN = "dash:idx:";
21
25
  const MANIFEST_TYPES = ["application/dash+xml"];
22
26
  /** Unresolved on-demand addressing, or null for an explicit list or template. */
23
27
  function asSidx(addressing) {
24
- if (addressing === void 0 || Array.isArray(addressing)) return null;
25
- const candidate = addressing;
26
- return candidate.kind === "sidx" ? candidate : null;
28
+ return addressing !== void 0 && isUnresolved(addressing) ? addressing : null;
27
29
  }
28
30
  const INITIAL = {
29
31
  manifestUrl: null,
@@ -43,14 +45,6 @@ function claims(state, text) {
43
45
  if (state.mimeType !== null) return MANIFEST_TYPES.includes(state.mimeType);
44
46
  return text.trimStart().startsWith("<");
45
47
  }
46
- function findRendition(presentation, renditionId) {
47
- for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return rendition;
48
- return null;
49
- }
50
- function findTrackOf(presentation, renditionId) {
51
- for (const period of presentation.periods) for (const track of period.tracks) if (track.renditions.some((r) => r.id === renditionId)) return track;
52
- return null;
53
- }
54
48
  /**
55
49
  * The renditions whose sidx index the selection needs and this slice has
56
50
  * not asked for: the playing video rendition and its ladder neighbours, and
@@ -62,37 +56,22 @@ function findTrackOf(presentation, renditionId) {
62
56
  * it happens, while the buffer plays.
63
57
  */
64
58
  function neededIndexes(state, kernel) {
65
- const presentation = kernel.presentation;
66
- if (presentation === null) return [];
67
59
  const asked = new Set(Object.values(state.pending));
68
60
  const needed = [];
69
- for (const contentType of [
61
+ for (const { rendition } of activeRenditions(kernel, [
70
62
  "video",
71
63
  "audio",
72
64
  "text"
73
- ]) {
74
- const trackId = kernel.tracks.active.get(contentType);
75
- if (trackId === void 0) continue;
76
- for (const period of presentation.periods) for (const track of period.tracks) {
77
- if (track.id !== trackId) continue;
78
- const candidates = contentType === "video" ? ladderNeighbours(track.renditions, kernel.quality.active, kernel.quality.constraints) : track.renditions;
79
- for (const rendition of candidates) {
80
- if (asSidx(rendition.segments) === null) continue;
81
- if (asked.has(rendition.id) || rendition.id in state.failed) continue;
82
- needed.push(rendition);
83
- }
84
- }
65
+ ], kernel.quality.active)) {
66
+ if (asSidx(rendition.segments) === null) continue;
67
+ if (asked.has(rendition.id) || rendition.id in state.failed) continue;
68
+ needed.push(rendition);
85
69
  }
86
70
  return needed;
87
71
  }
88
72
  /** Loops a message back into the bus through a zero-delay schedule effect. */
89
73
  function feed(message) {
90
- return {
91
- kind: "schedule",
92
- token: "dash:loopback",
93
- delayMs: 0,
94
- then: message
95
- };
74
+ return scheduled("dash:loopback", message);
96
75
  }
97
76
  /**
98
77
  * An index that failed to load or held no segment. The rendition is
@@ -101,11 +80,12 @@ function feed(message) {
101
80
  * fails: the stream cannot play, and waiting would only stall.
102
81
  */
103
82
  function unavailable(state, kernel, renditionId, error) {
83
+ var _findRendition$track, _findRendition;
104
84
  const failed = _objectSpread2(_objectSpread2({}, state.failed), {}, { [renditionId]: true });
105
85
  const next = _objectSpread2(_objectSpread2({}, state), {}, { failed });
106
86
  const presentation = kernel.presentation;
107
87
  if (presentation === null) return [next, []];
108
- const track = findTrackOf(presentation, renditionId);
88
+ const track = (_findRendition$track = (_findRendition = findRendition(presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.track) !== null && _findRendition$track !== void 0 ? _findRendition$track : null;
109
89
  const media = (track === null || track === void 0 ? void 0 : track.contentType) === "video" || (track === null || track === void 0 ? void 0 : track.contentType) === "audio";
110
90
  if (track !== null && media && track.renditions.every((r) => r.id in failed)) return [next, [feed({
111
91
  type: "MANIFEST_FAILED",
@@ -125,25 +105,8 @@ const reduceDash = (slice, msg, kernel) => {
125
105
  }), []];
126
106
  if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
127
107
  if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
128
- const text = new TextDecoder().decode(msg.bytes);
129
- if (!claims(state, text)) return [state, []];
130
- const result = parse(text, state.manifestUrl);
131
- if (result.presentation === null) {
132
- var _result$error;
133
- return [state, [feed({
134
- type: "MANIFEST_FAILED",
135
- error: (_result$error = result.error) !== null && _result$error !== void 0 ? _result$error : {
136
- category: "manifest",
137
- code: "MANIFEST_PARSE_FAILED",
138
- fatal: true,
139
- recoverable: false
140
- }
141
- })]];
142
- }
143
- return [state, [feed({
144
- type: "MANIFEST_LOADED",
145
- presentation: result.presentation
146
- })]];
108
+ const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), parse);
109
+ return [state, fact === null ? [] : [feed(fact)]];
147
110
  }
148
111
  let next = state;
149
112
  if (msg.type === "PLAYLIST_REFRESHED" && msg.renditionId !== void 0) {
@@ -156,9 +119,9 @@ const reduceDash = (slice, msg, kernel) => {
156
119
  }
157
120
  }
158
121
  if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
159
- var _findRendition;
122
+ var _findRendition2;
160
123
  const renditionId = state.pending[msg.trackId];
161
- const sidx = kernel.presentation === null ? null : asSidx((_findRendition = findRendition(kernel.presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.segments);
124
+ const sidx = kernel.presentation === null ? null : asSidx((_findRendition2 = findRendition(kernel.presentation, renditionId)) === null || _findRendition2 === void 0 ? void 0 : _findRendition2.rendition.segments);
162
125
  const segments = sidx === null ? [] : sidxToSegments(new Uint8Array(msg.bytes), sidx);
163
126
  if (sidx !== null && segments.length > 0) {
164
127
  var _segments$0$seq, _segments$;
@@ -1,5 +1,9 @@
1
1
  import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
2
  import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
3
+ import { resolveUrl } from "../../kernel/url.js";
4
+ import { base64ToBytes } from "../../kernel/base64.js";
5
+ import { manifestError } from "../adapter-shared.js";
6
+ import { dimensions } from "../dimensions.js";
3
7
  //#region src/protocols/dash-cmaf/parse.ts
4
8
  /**
5
9
  * MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
@@ -17,22 +21,6 @@ import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
17
21
  * becomes IndexedSegments and the kernel materializes one segment at a
18
22
  * time, so a long window never becomes an array.
19
23
  */
20
- function manifestError(reason) {
21
- return {
22
- category: "manifest",
23
- code: "MANIFEST_PARSE_FAILED",
24
- fatal: true,
25
- recoverable: false,
26
- context: { reason }
27
- };
28
- }
29
- function resolve(uri, baseUrl) {
30
- try {
31
- return new URL(uri, baseUrl).href;
32
- } catch (_unused) {
33
- return uri;
34
- }
35
- }
36
24
  /** ISO 8601 duration to seconds. Date parts use nominal day lengths. */
37
25
  function parseDuration(value) {
38
26
  if (value === null) return null;
@@ -80,17 +68,7 @@ function parseByteRange(value) {
80
68
  function applyBaseUrl(element, base) {
81
69
  var _baseElements$;
82
70
  const text = (_baseElements$ = children(element, "BaseURL")[0]) === null || _baseElements$ === void 0 || (_baseElements$ = _baseElements$.textContent) === null || _baseElements$ === void 0 ? void 0 : _baseElements$.trim();
83
- return text !== void 0 && text !== "" ? resolve(text, base) : base;
84
- }
85
- function base64ToArrayBuffer(text) {
86
- try {
87
- const binary = atob(text.replace(/\s+/g, ""));
88
- const bytes = new Uint8Array(binary.length);
89
- for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
90
- return bytes.buffer;
91
- } catch (_unused2) {
92
- return null;
93
- }
71
+ return text !== void 0 && text !== "" ? resolveUrl(text, base) : base;
94
72
  }
95
73
  const MP4_PROTECTION = "urn:mpeg:dash:mp4protection:2011";
96
74
  const UUID_URN = /^urn:uuid:([0-9a-f-]{36})$/i;
@@ -113,12 +91,12 @@ function parseProtection(elements) {
113
91
  }
114
92
  const schemes = [];
115
93
  for (const element of elements) {
116
- var _attr4, _children$;
94
+ var _attr4, _children$, _base64ToBytes$buffer, _base64ToBytes;
117
95
  const schemeIdUri = (_attr4 = attr(element, "schemeIdUri")) !== null && _attr4 !== void 0 ? _attr4 : "";
118
96
  const uuid = UUID_URN.exec(schemeIdUri);
119
97
  if (uuid === null) continue;
120
98
  const pssh = (_children$ = children(element, "pssh")[0]) === null || _children$ === void 0 || (_children$ = _children$.textContent) === null || _children$ === void 0 ? void 0 : _children$.trim();
121
- const initData = pssh !== void 0 && pssh !== "" ? base64ToArrayBuffer(pssh) : null;
99
+ const initData = pssh !== void 0 && pssh !== "" ? (_base64ToBytes$buffer = (_base64ToBytes = base64ToBytes(pssh)) === null || _base64ToBytes === void 0 ? void 0 : _base64ToBytes.buffer) !== null && _base64ToBytes$buffer !== void 0 ? _base64ToBytes$buffer : null : null;
122
100
  schemes.push({
123
101
  systemId: uuid[1].toLowerCase(),
124
102
  scheme: commonScheme,
@@ -141,7 +119,8 @@ function parseProtection(elements) {
141
119
  /**
142
120
  * A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
143
121
  * representation declaring a playout rate other than 1. Both mark an
144
- * I-frame-only set meant for scrubbing, never for normal playback.
122
+ * I-frame-only set meant for fast forward and previews, never for normal
123
+ * playback.
145
124
  */
146
125
  function isTrickMode(adaptationSet) {
147
126
  for (const property of children(adaptationSet, "EssentialProperty")) {
@@ -155,6 +134,30 @@ function isTrickMode(adaptationSet) {
155
134
  }
156
135
  return false;
157
136
  }
137
+ /**
138
+ * The DASH-IF IOP thumbnail grid: an EssentialProperty with the
139
+ * thumbnail_tile scheme and value `CxR`, on the Representation or its
140
+ * AdaptationSet. The Representation's width and height are the whole image,
141
+ * so one tile is that size divided by the grid.
142
+ */
143
+ function tileGridOf(representation, adaptationSet, width, height) {
144
+ if (width === null || height === null) return null;
145
+ const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
146
+ for (const property of properties) {
147
+ var _attr6;
148
+ if (!((_attr6 = attr(property, "schemeIdUri")) !== null && _attr6 !== void 0 ? _attr6 : "").includes("thumbnail_tile")) continue;
149
+ const grid = dimensions(attr(property, "value"));
150
+ if (grid === null) continue;
151
+ const [columns, rows] = grid;
152
+ return {
153
+ columns,
154
+ rows,
155
+ width: width / columns,
156
+ height: height / rows
157
+ };
158
+ }
159
+ return null;
160
+ }
158
161
  /** Merges SegmentTemplate attributes down Period, AdaptationSet, Representation. */
159
162
  function mergeTemplates(levels) {
160
163
  var _timescale, _startNumber, _pto;
@@ -167,12 +170,12 @@ function mergeTemplates(levels) {
167
170
  let timelineElement = null;
168
171
  let found = false;
169
172
  for (const level of levels) {
170
- var _attr6, _attr7, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
173
+ var _attr7, _attr8, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
171
174
  const template = children(level, "SegmentTemplate")[0];
172
175
  if (template === void 0) continue;
173
176
  found = true;
174
- media = (_attr6 = attr(template, "media")) !== null && _attr6 !== void 0 ? _attr6 : media;
175
- initialization = (_attr7 = attr(template, "initialization")) !== null && _attr7 !== void 0 ? _attr7 : initialization;
177
+ media = (_attr7 = attr(template, "media")) !== null && _attr7 !== void 0 ? _attr7 : media;
178
+ initialization = (_attr8 = attr(template, "initialization")) !== null && _attr8 !== void 0 ? _attr8 : initialization;
176
179
  timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
177
180
  startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
178
181
  duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
@@ -239,7 +242,7 @@ function contentTypeOf(adaptationSet, mimeType) {
239
242
  }
240
243
  /** parse an MPD document into a Presentation. Never throws. */
241
244
  function parse(text, baseUrl) {
242
- var _parseDuration, _parseDuration2, _attr15;
245
+ var _parseDuration, _parseDuration2, _attr16;
243
246
  let doc;
244
247
  try {
245
248
  doc = new DOMParser().parseFromString(text, "text/xml");
@@ -259,15 +262,15 @@ function parse(text, baseUrl) {
259
262
  const mpdBase = applyBaseUrl(mpd, baseUrl);
260
263
  let live;
261
264
  if (isLive) {
262
- var _attr8, _attr9, _attr10;
263
- const availabilityStart = Date.parse((_attr8 = attr(mpd, "availabilityStartTime")) !== null && _attr8 !== void 0 ? _attr8 : "");
265
+ var _attr9, _attr10, _attr11;
266
+ const availabilityStart = Date.parse((_attr9 = attr(mpd, "availabilityStartTime")) !== null && _attr9 !== void 0 ? _attr9 : "");
264
267
  const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
265
268
  const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
266
269
  const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
267
270
  const timing = children(mpd, "UTCTiming")[0];
268
271
  live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
269
- scheme: (_attr9 = attr(timing, "schemeIdUri")) !== null && _attr9 !== void 0 ? _attr9 : "",
270
- value: (_attr10 = attr(timing, "value")) !== null && _attr10 !== void 0 ? _attr10 : ""
272
+ scheme: (_attr10 = attr(timing, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "",
273
+ value: (_attr11 = attr(timing, "value")) !== null && _attr11 !== void 0 ? _attr11 : ""
271
274
  } } : {});
272
275
  }
273
276
  let steering;
@@ -281,9 +284,9 @@ function parse(text, baseUrl) {
281
284
  var _base$textContent;
282
285
  const location = attr(base, "serviceLocation");
283
286
  const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
284
- if (location !== null && text !== void 0 && text !== "") bases[location] = resolve(text, baseUrl);
287
+ if (location !== null && text !== void 0 && text !== "") bases[location] = resolveUrl(text, baseUrl);
285
288
  }
286
- steering = _objectSpread2(_objectSpread2({ serverUri: resolve(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
289
+ steering = _objectSpread2(_objectSpread2({ serverUri: resolveUrl(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
287
290
  }
288
291
  }
289
292
  const periodElement = children(mpd, "Period")[0];
@@ -305,26 +308,27 @@ function parse(text, baseUrl) {
305
308
  for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
306
309
  var _children$0$getAttrib, _children$3, _trackMime2;
307
310
  const adaptationSet = adaptationSets[asIndex];
308
- if (isTrickMode(adaptationSet)) continue;
311
+ const trick = isTrickMode(adaptationSet);
312
+ const asPlayoutRate = numberAttr(adaptationSet, "maxPlayoutRate");
309
313
  const asBase = applyBaseUrl(adaptationSet, periodBase);
310
314
  const asMime = attr(adaptationSet, "mimeType");
311
315
  const asCodecs = attr(adaptationSet, "codecs");
312
316
  const lang = attr(adaptationSet, "lang");
313
- const role = (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
317
+ const role = trick ? "trick" : (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
314
318
  const protectionSchemes = parseProtection(children(adaptationSet, "ContentProtection"));
315
319
  const renditions = [];
316
320
  let trackMime = null;
317
321
  for (const representation of children(adaptationSet, "Representation")) {
318
- var _ref, _attr11, _trackMime, _parseFrameRate2, _attr14;
322
+ var _ref, _attr12, _trackMime, _parseFrameRate2, _numberAttr8, _attr15;
319
323
  const id = attr(representation, "id");
320
324
  const bandwidth = numberAttr(representation, "bandwidth");
321
325
  if (id === null || bandwidth === null) continue;
322
326
  const repBase = applyBaseUrl(representation, asBase);
323
- const mimeType = (_ref = (_attr11 = attr(representation, "mimeType")) !== null && _attr11 !== void 0 ? _attr11 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
327
+ const mimeType = (_ref = (_attr12 = attr(representation, "mimeType")) !== null && _attr12 !== void 0 ? _attr12 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
324
328
  trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
325
329
  const segmentBase = children(representation, "SegmentBase")[0];
326
330
  if (segmentBase !== void 0) {
327
- var _numberAttr7, _parseFrameRate, _attr12;
331
+ var _numberAttr7, _parseFrameRate, _attr13;
328
332
  const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
329
333
  if (indexRange === null) continue;
330
334
  const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
@@ -347,7 +351,7 @@ function parse(text, baseUrl) {
347
351
  renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
348
352
  id,
349
353
  bitrate: bandwidth,
350
- codecs: (_attr12 = attr(representation, "codecs")) !== null && _attr12 !== void 0 ? _attr12 : asCodecs,
354
+ codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
351
355
  mimeType,
352
356
  segments: sidxSegments
353
357
  }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
@@ -360,11 +364,11 @@ function parse(text, baseUrl) {
360
364
  ]);
361
365
  if (template === null || template.media === null) {
362
366
  if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
363
- var _attr13;
367
+ var _attr14;
364
368
  renditions.push({
365
369
  id,
366
370
  bitrate: bandwidth,
367
- codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
371
+ codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
368
372
  mimeType,
369
373
  segments: [{
370
374
  seq: 0,
@@ -391,24 +395,26 @@ function parse(text, baseUrl) {
391
395
  };
392
396
  const segments = _objectSpread2({
393
397
  kind: "indexed",
394
- urlTemplate: resolve(substituteIdentity(template.media, id, bandwidth), repBase),
398
+ urlTemplate: resolveUrl(substituteIdentity(template.media, id, bandwidth), repBase),
395
399
  startSeq: template.startNumber,
396
400
  endSeq: isLive ? null : endSeq,
397
401
  timescale: template.timescale,
398
402
  segmentDuration: timeline !== null ? null : template.duration,
399
403
  timeline
400
404
  }, template.presentationTimeOffset !== 0 ? { presentationTimeOffset: template.presentationTimeOffset } : {});
401
- const init = template.initialization !== null ? { url: resolve(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
405
+ const init = template.initialization !== null ? { url: resolveUrl(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
402
406
  const frameRate = (_parseFrameRate2 = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate2 !== void 0 ? _parseFrameRate2 : parseFrameRate(attr(adaptationSet, "frameRate"));
403
407
  const width = numberAttr(representation, "width");
404
408
  const height = numberAttr(representation, "height");
405
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
409
+ const tiles = tileGridOf(representation, adaptationSet, width, height);
410
+ const playoutRate = trick ? (_numberAttr8 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr8 !== void 0 ? _numberAttr8 : asPlayoutRate : null;
411
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
406
412
  id,
407
413
  bitrate: bandwidth,
408
- codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
414
+ codecs: (_attr15 = attr(representation, "codecs")) !== null && _attr15 !== void 0 ? _attr15 : asCodecs,
409
415
  mimeType,
410
416
  segments
411
- }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}));
417
+ }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}));
412
418
  }
413
419
  if (renditions.length === 0) continue;
414
420
  const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
@@ -436,7 +442,7 @@ function parse(text, baseUrl) {
436
442
  isLive
437
443
  }, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
438
444
  periods: [_objectSpread2(_objectSpread2({
439
- id: (_attr15 = attr(periodElement, "id")) !== null && _attr15 !== void 0 ? _attr15 : "p0",
445
+ id: (_attr16 = attr(periodElement, "id")) !== null && _attr16 !== void 0 ? _attr16 : "p0",
440
446
  start: periodStart
441
447
  }, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
442
448
  couplings: []
@@ -1,7 +1,16 @@
1
1
  import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled, tickAfter } from "../../kernel/effects.js";
2
3
  import { registerLiveNamespace } from "../live-shared.js";
3
4
  import { parse } from "../dash-cmaf/parse.js";
4
5
  //#region src/protocols/dash-live/index.ts
6
+ /**
7
+ * DASH live: the edge is computed, never read. Wall clock enters only as
8
+ * fields on facts, stamped at the transport and element boundaries; the
9
+ * slice turns availabilityStartTime plus clock skew into
10
+ * LIVE_WINDOW_CHANGED facts and reloads the MPD on minimumUpdatePeriod.
11
+ * UTCTiming corrects the client clock: a few seconds of drift silently
12
+ * breaks live playback, which is why the fetch is worth its round trip.
13
+ */
5
14
  const MPD_TOKEN = "dash:live:mpd";
6
15
  const UTC_TOKEN = "dash:live:utc";
7
16
  const TICK_TOKEN = "dash-live:reload";
@@ -62,35 +71,14 @@ function drivesWindow(presentation) {
62
71
  }
63
72
  /** Loops a message back into the bus through a zero-delay schedule effect. */
64
73
  function feed(message) {
65
- return {
66
- kind: "schedule",
67
- token: "dash-live:loopback",
68
- delayMs: 0,
69
- then: message
70
- };
74
+ return scheduled("dash-live:loopback", message);
71
75
  }
72
76
  function tick(delaySeconds) {
73
- return {
74
- kind: "schedule",
75
- token: TICK_TOKEN,
76
- delayMs: Math.max(500, delaySeconds * 1e3),
77
- then: {
78
- type: "TICK",
79
- token: TICK_TOKEN
80
- }
81
- };
77
+ return tickAfter(TICK_TOKEN, Math.max(500, delaySeconds * 1e3));
82
78
  }
83
79
  /** The one-second clock loop that slides the window while playback stalls. */
84
80
  function clockTick() {
85
- return {
86
- kind: "schedule",
87
- token: CLOCK_TOKEN,
88
- delayMs: 1e3,
89
- then: {
90
- type: "TICK",
91
- token: CLOCK_TOKEN
92
- }
93
- };
81
+ return tickAfter(CLOCK_TOKEN, 1e3);
94
82
  }
95
83
  /**
96
84
  * An MPD reload that failed or did not parse. The next reload waits one
@@ -223,10 +211,7 @@ const reduceDashLive = (slice, msg, kernel) => {
223
211
  if (msg.type === "SEGMENT_LOADED" && msg.trackId === MPD_TOKEN) {
224
212
  if (state.manifestUrl === null) return [state, []];
225
213
  const result = parse(new TextDecoder().decode(msg.bytes), state.manifestUrl);
226
- if (result.presentation === null) {
227
- var _result$error$code, _result$error;
228
- return reloadFailed(state, kernel.presentation, (_result$error$code = (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.code) !== null && _result$error$code !== void 0 ? _result$error$code : "MANIFEST_PARSE_FAILED");
229
- }
214
+ if (result.presentation === null) return reloadFailed(state, kernel.presentation, result.error.code);
230
215
  const effects = [];
231
216
  let next = _objectSpread2(_objectSpread2({}, state), {}, { failures: 0 });
232
217
  effects.push(feed({
@@ -0,0 +1,15 @@
1
+ //#region src/protocols/dimensions.ts
2
+ /**
3
+ * The `AxB` pair both manifest families write for sizes and grids: HLS
4
+ * RESOLUTION and LAYOUT (RFC 8216 §4.3.4.2, the Roku image-playlist tags),
5
+ * and the DASH-IF thumbnail_tile value. One copy serves both adapters.
6
+ */
7
+ /** `1280x720` or `10x1` into two positive integers, or null. */
8
+ function dimensions(value) {
9
+ const match = /^(\d+)x(\d+)$/.exec(value !== null && value !== void 0 ? value : "");
10
+ const a = Number(match === null || match === void 0 ? void 0 : match[1]);
11
+ const b = Number(match === null || match === void 0 ? void 0 : match[2]);
12
+ return a > 0 && b > 0 ? [a, b] : null;
13
+ }
14
+ //#endregion
15
+ export { dimensions };
@@ -1,6 +1,8 @@
1
1
  import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled } from "../../kernel/effects.js";
2
3
  import { normalizeMimeType } from "../../kernel/mime.js";
3
- import { ladderNeighbours } from "../../kernel/rendition-select.js";
4
+ import { activeRenditions } from "../../kernel/rendition-select.js";
5
+ import { manifestFact } from "../adapter-shared.js";
4
6
  import { parse, parseMediaPlaylist, refreshFor } from "./parse.js";
5
7
  import { LOAD_FAILED, unavailableMessages } from "./unavailable.js";
6
8
  //#region src/protocols/hls-cmaf/index.ts
@@ -44,32 +46,23 @@ function claims(state, text) {
44
46
  /**
45
47
  * The playlist URLs the selection needs and this slice has not asked for:
46
48
  * the playing video rendition and its ladder neighbours, and every
47
- * rendition of the active audio and text tracks (one each in practice; an
48
- * audio-only ladder is short). Fetching the whole ladder up front costs one
49
+ * rendition of the active audio, text, and image tracks (one each in
50
+ * practice; an audio-only ladder is short). Fetching the whole ladder up front costs one
49
51
  * request per variant, hundreds on a large multivariant playlist.
50
52
  */
51
53
  function neededPlaylists(state, kernel) {
52
- const presentation = kernel.presentation;
53
- if (presentation === null) return [];
54
54
  const asked = new Set(Object.values(state.pending));
55
55
  const needed = [];
56
- for (const contentType of [
56
+ for (const { rendition } of activeRenditions(kernel, [
57
57
  "video",
58
58
  "audio",
59
- "text"
60
- ]) {
61
- const trackId = kernel.tracks.active.get(contentType);
62
- if (trackId === void 0) continue;
63
- for (const period of presentation.periods) for (const track of period.tracks) {
64
- if (track.id !== trackId) continue;
65
- const candidates = contentType === "video" ? ladderNeighbours(track.renditions, kernel.quality.active, kernel.quality.constraints) : track.renditions;
66
- for (const rendition of candidates) {
67
- const url = rendition.playlistUrl;
68
- if (url === void 0 || url in state.answered || asked.has(url)) continue;
69
- if (needed.some((r) => r.playlistUrl === url)) continue;
70
- needed.push(rendition);
71
- }
72
- }
59
+ "text",
60
+ "image"
61
+ ], kernel.quality.active)) {
62
+ const url = rendition.playlistUrl;
63
+ if (url === void 0 || url in state.answered || asked.has(url)) continue;
64
+ if (needed.some((r) => r.playlistUrl === url)) continue;
65
+ needed.push(rendition);
73
66
  }
74
67
  return needed;
75
68
  }
@@ -81,12 +74,7 @@ function renditionsAt(presentation, url) {
81
74
  }
82
75
  /** Loops a message back into the bus through a zero-delay schedule effect. */
83
76
  function feed(message) {
84
- return {
85
- kind: "schedule",
86
- token: "hls:loopback",
87
- delayMs: 0,
88
- then: message
89
- };
77
+ return scheduled("hls:loopback", message);
90
78
  }
91
79
  /**
92
80
  * A playlist that failed to load or parse. Its renditions are excluded,
@@ -111,42 +99,19 @@ const reduceHls = (slice, msg, kernel) => {
111
99
  }), []];
112
100
  if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
113
101
  if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
114
- const text = new TextDecoder().decode(msg.bytes);
115
- if (!claims(state, text)) return [state, []];
116
- const result = parse(text, state.manifestUrl);
117
- if (result.presentation === null) {
118
- var _result$error;
119
- return [state, [feed({
120
- type: "MANIFEST_FAILED",
121
- error: (_result$error = result.error) !== null && _result$error !== void 0 ? _result$error : {
122
- category: "manifest",
123
- code: "MANIFEST_PARSE_FAILED",
124
- fatal: true,
125
- recoverable: false
126
- }
127
- })]];
128
- }
129
- return [state, [feed({
130
- type: "MANIFEST_LOADED",
131
- presentation: result.presentation
132
- })]];
102
+ const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), parse);
103
+ return [state, fact === null ? [] : [feed(fact)]];
133
104
  }
134
105
  let next = state;
135
106
  const effects = [];
136
107
  if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
137
- var _media$error;
138
108
  const url = state.pending[msg.trackId];
139
109
  const pending = _objectSpread2({}, state.pending);
140
110
  delete pending[msg.trackId];
141
111
  next = _objectSpread2(_objectSpread2({}, next), {}, { pending });
142
112
  const media = parseMediaPlaylist(new TextDecoder().decode(msg.bytes), url);
143
113
  const playlist = media.playlist;
144
- const error = playlist === null ? (_media$error = media.error) !== null && _media$error !== void 0 ? _media$error : {
145
- category: "manifest",
146
- code: "MANIFEST_PARSE_FAILED",
147
- fatal: false,
148
- recoverable: false
149
- } : playlist.endlist && playlist.segments.length === 0 ? {
114
+ const error = playlist === null ? media.error : playlist.endlist && playlist.segments.length === 0 ? {
150
115
  category: "manifest",
151
116
  code: "MANIFEST_EMPTY",
152
117
  fatal: false,
@@ -6,7 +6,10 @@ const ATTRIBUTE_TAGS = /* @__PURE__ */ new Set([
6
6
  "EXT-X-MAP",
7
7
  "EXT-X-KEY",
8
8
  "EXT-X-SESSION-KEY",
9
+ "EXT-X-SESSION-DATA",
9
10
  "EXT-X-I-FRAME-STREAM-INF",
11
+ "EXT-X-IMAGE-STREAM-INF",
12
+ "EXT-X-TILES",
10
13
  "EXT-X-CONTENT-STEERING"
11
14
  ]);
12
15
  /**