mattebox 0.6.1 → 0.7.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 +151 -0
  101. package/dist/es2015/stages/chapters/parse.js +149 -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 +20 -0
  216. package/dist/stages/chapters/index.d.ts.map +1 -0
  217. package/dist/stages/chapters/index.js +141 -0
  218. package/dist/stages/chapters/index.js.map +1 -0
  219. package/dist/stages/chapters/parse.d.ts +47 -0
  220. package/dist/stages/chapters/parse.d.ts.map +1 -0
  221. package/dist/stages/chapters/parse.js +168 -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,4 +1,24 @@
1
1
  //#region src/kernel/effects.ts
2
+ /**
3
+ * A schedule effect: `then` re-enters the bus after `delayMs`, or at once.
4
+ * The token names the timer, so an abort under it cancels the timer; each
5
+ * caller keeps its own token.
6
+ */
7
+ function scheduled(token, then, delayMs = 0) {
8
+ return {
9
+ kind: "schedule",
10
+ token,
11
+ delayMs,
12
+ then
13
+ };
14
+ }
15
+ /** A TICK under `token` after `delayMs`; the slice that owns the token matches it. */
16
+ function tickAfter(token, delayMs) {
17
+ return scheduled(token, {
18
+ type: "TICK",
19
+ token
20
+ }, delayMs);
21
+ }
2
22
  function createEffectRunner(options = {}) {
3
23
  var _options$onEvent;
4
24
  const onEvent = (_options$onEvent = options.onEvent) !== null && _options$onEvent !== void 0 ? _options$onEvent : (() => void 0);
@@ -59,4 +79,4 @@ function createEffectRunner(options = {}) {
59
79
  };
60
80
  }
61
81
  //#endregion
62
- export { createEffectRunner };
82
+ export { createEffectRunner, scheduled, tickAfter };
@@ -12,9 +12,13 @@ function normalizeMimeType(value) {
12
12
  const semicolon = value.indexOf(";");
13
13
  return (semicolon === -1 ? value : value.slice(0, semicolon)).trim().toLowerCase();
14
14
  }
15
+ /** The full MSE type for a MIME type and its codecs: `video/mp4; codecs="avc1.42c01e"`, or the bare MIME type. */
16
+ function typeString(mimeType, codecs) {
17
+ return codecs === null ? mimeType : `${mimeType}; codecs="${codecs}"`;
18
+ }
15
19
  /** True for a capability string that names a manifest format: a MIME type, the only capability strings containing '/'. */
16
20
  function isManifestType(capability) {
17
21
  return capability.includes("/");
18
22
  }
19
23
  //#endregion
20
- export { isManifestType, normalizeMimeType };
24
+ export { isManifestType, normalizeMimeType, typeString };
@@ -0,0 +1,24 @@
1
+ //#region src/kernel/presentation.ts
2
+ /** An I-frame-only video track, kept for trick play and never selected for normal playback. */
3
+ function isTrick(track) {
4
+ return track.role === "trick";
5
+ }
6
+ function findTrackSite(presentation, trackId) {
7
+ var _presentation$periods;
8
+ 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 {
9
+ track,
10
+ period
11
+ };
12
+ return null;
13
+ }
14
+ function findRendition(presentation, renditionId) {
15
+ var _presentation$periods2;
16
+ for (const period of (_presentation$periods2 = presentation === null || presentation === void 0 ? void 0 : presentation.periods) !== null && _presentation$periods2 !== void 0 ? _presentation$periods2 : []) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return {
17
+ rendition,
18
+ track,
19
+ period
20
+ };
21
+ return null;
22
+ }
23
+ //#endregion
24
+ export { findRendition, findTrackSite, isTrick };
@@ -1,9 +1,11 @@
1
1
  import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
- import { normalizeMimeType } from "./mime.js";
2
+ import { tickAfter } from "./effects.js";
3
+ import { normalizeMimeType, typeString } from "./mime.js";
4
+ import { findRendition, findTrackSite, isTrick } from "./presentation.js";
3
5
  import { applyRefresh } from "./refresh.js";
4
6
  import { reconciledOffset, segmentAtTime } from "./timeline.js";
5
7
  import { bufferedEndFrom, schedule } from "./scheduler.js";
6
- import { canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
8
+ import { availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
7
9
  import { sbIdFor } from "./sinks/mse-sink.js";
8
10
  import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectWithoutProperties.js";
9
11
  //#region src/kernel/reducer.ts
@@ -144,18 +146,6 @@ function clearRepeat(scheduling) {
144
146
  function ewma(previous, sample, alpha) {
145
147
  return previous === 0 ? sample : alpha * sample + (1 - alpha) * previous;
146
148
  }
147
- /** Companion groups present, as `contentType:groupId`, for the coupling filter. */
148
- function availableGroups(state) {
149
- var _state$presentation$p, _state$presentation;
150
- const groups = /* @__PURE__ */ new Set();
151
- for (const period of (_state$presentation$p = (_state$presentation = state.presentation) === null || _state$presentation === void 0 ? void 0 : _state$presentation.periods) !== null && _state$presentation$p !== void 0 ? _state$presentation$p : []) for (const track of period.tracks) {
152
- if (track.contentType !== "audio" && track.contentType !== "text") continue;
153
- const colon = track.id.indexOf(":");
154
- const group = colon === -1 ? track.id : track.id.slice(0, colon);
155
- groups.add(`${track.contentType}:${group}`);
156
- }
157
- return groups;
158
- }
159
149
  /** Merges one span into a sorted coverage list, coalescing overlaps. */
160
150
  function mergeCoverage(coverage, added) {
161
151
  const merged = [];
@@ -224,16 +214,8 @@ function forgetFlushed(buffers, effects) {
224
214
  return next;
225
215
  }
226
216
  function findTrack(presentation, trackId) {
227
- if (presentation === null) return null;
228
- for (const period of presentation.periods) for (const track of period.tracks) if (track.id === trackId) return track;
229
- return null;
230
- }
231
- function findTrackSite(presentation, trackId) {
232
- for (const period of presentation.periods) for (const track of period.tracks) if (track.id === trackId) return {
233
- track,
234
- period
235
- };
236
- return null;
217
+ var _findTrackSite$track, _findTrackSite;
218
+ return (_findTrackSite$track = (_findTrackSite = findTrackSite(presentation, trackId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track) !== null && _findTrackSite$track !== void 0 ? _findTrackSite$track : null;
237
219
  }
238
220
  /**
239
221
  * The first candidate whose segment list places a boundary around `time`.
@@ -246,15 +228,6 @@ function findTrackSite(presentation, trackId) {
246
228
  function segmentedAt(candidates, time, periodStart) {
247
229
  return candidates.find((rendition) => rendition !== void 0 && segmentAtTime(rendition.segments, time, periodStart) !== null);
248
230
  }
249
- function findRendition(presentation, renditionId) {
250
- if (presentation === null) return null;
251
- for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return {
252
- rendition,
253
- track,
254
- period
255
- };
256
- return null;
257
- }
258
231
  /**
259
232
  * Whether a completed request feeds the throughput estimate: only media of
260
233
  * the lead track (video where there is one, else audio). An audio segment
@@ -359,7 +332,13 @@ function reduceCommand(state, msg, cfg, hooks) {
359
332
  if (state.presentation === null) return reject(state, msg.type, "no source");
360
333
  const [next, aborts] = abortInflight(state);
361
334
  const to = state.live === null ? msg.to : Math.min(Math.max(msg.to, state.live.span.start), state.live.edge);
362
- return [_objectSpread2(_objectSpread2({}, next), {}, { scheduling: clearRepeat(next.scheduling) }), [...aborts, {
335
+ return [_objectSpread2(_objectSpread2({}, next), {}, {
336
+ playback: _objectSpread2(_objectSpread2({}, next.playback), {}, {
337
+ currentTime: to,
338
+ seeking: true
339
+ }),
340
+ scheduling: clearRepeat(next.scheduling)
341
+ }), [...aborts, {
363
342
  kind: "seekElement",
364
343
  to
365
344
  }]];
@@ -385,26 +364,38 @@ function reduceCommand(state, msg, cfg, hooks) {
385
364
  const effects = [];
386
365
  let buffers = state.buffers;
387
366
  let inflight = state.scheduling.inflight;
388
- const site = state.presentation === null ? null : findTrackSite(state.presentation, track.id);
367
+ const site = findTrackSite(state.presentation, track.id);
389
368
  const previousTrack = previous === void 0 ? null : findTrack(state.presentation, previous);
390
369
  const flushRendition = site === null ? void 0 : (_segmentedAt = segmentedAt([...track.renditions, ...(_previousTrack$rendit = previousTrack === null || previousTrack === void 0 ? void 0 : previousTrack.renditions) !== null && _previousTrack$rendit !== void 0 ? _previousTrack$rendit : []], state.playback.currentTime, site.period.start)) !== null && _segmentedAt !== void 0 ? _segmentedAt : track.renditions[0];
391
370
  if (previous !== void 0 && previous !== track.id && (track.contentType === "audio" || track.contentType === "video") && site !== null && flushRendition !== void 0) {
392
371
  const sbId = sbIdFor(track.contentType);
393
372
  const buffer = state.buffers.get(sbId);
373
+ const trickSwitch = track.contentType === "video" && (isTrick(track) || previousTrack !== null && isTrick(previousTrack));
394
374
  if (buffer !== void 0) {
395
- var _msg$apply;
396
- const plan = planPinApply({
397
- strategy: (_msg$apply = msg.apply) !== null && _msg$apply !== void 0 ? _msg$apply : "now",
398
- currentTime: state.playback.currentTime,
399
- ranges: buffer.ranges,
375
+ if (trickSwitch) effects.push({
376
+ kind: "remove",
400
377
  sbId,
401
- trackId: track.id,
402
- inflightTokens: [],
403
- period: site.period,
404
- rendition: flushRendition,
405
- tokenSeq: state.scheduling.tokenSeq
378
+ start: 0,
379
+ end: Number.POSITIVE_INFINITY
380
+ }, {
381
+ kind: "seekElement",
382
+ to: state.playback.currentTime
406
383
  });
407
- for (const effect of plan.effects) if (effect.kind !== "seekElement" || track.contentType === "video") effects.push(effect);
384
+ else {
385
+ var _msg$apply;
386
+ const plan = planPinApply({
387
+ strategy: (_msg$apply = msg.apply) !== null && _msg$apply !== void 0 ? _msg$apply : "now",
388
+ currentTime: state.playback.currentTime,
389
+ ranges: buffer.ranges,
390
+ sbId,
391
+ trackId: track.id,
392
+ inflightTokens: [],
393
+ period: site.period,
394
+ rendition: flushRendition,
395
+ tokenSeq: state.scheduling.tokenSeq
396
+ });
397
+ for (const effect of plan.effects) if (effect.kind !== "seekElement" || track.contentType === "video") effects.push(effect);
398
+ }
408
399
  const next = new Map(state.buffers);
409
400
  const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer, _excluded4);
410
401
  next.set(sbId, rest);
@@ -519,6 +510,16 @@ function reduceCommand(state, msg, cfg, hooks) {
519
510
  case "SET_BUFFER_GOAL":
520
511
  if (!Number.isFinite(msg.seconds) || msg.seconds <= 0) return reject(state, msg.type, "invalid buffer goal");
521
512
  return [_objectSpread2(_objectSpread2({}, state), {}, { scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { bufferGoal: msg.seconds }) }), []];
513
+ case "RESOLVE_RENDITION": {
514
+ var _state$tracks$resolve, _state$tracks$resolve2;
515
+ if (findRendition(state.presentation, msg.renditionId) === null) return reject(state, msg.type, `unknown rendition: ${msg.renditionId}`);
516
+ if ((_state$tracks$resolve = state.tracks.resolve) === null || _state$tracks$resolve === void 0 ? void 0 : _state$tracks$resolve.has(msg.renditionId)) return [state, []];
517
+ const resolve = new Set((_state$tracks$resolve2 = state.tracks.resolve) !== null && _state$tracks$resolve2 !== void 0 ? _state$tracks$resolve2 : []).add(msg.renditionId);
518
+ return [_objectSpread2(_objectSpread2({}, state), {}, {
519
+ tracks: _objectSpread2(_objectSpread2({}, state.tracks), {}, { resolve }),
520
+ quality: bumped(state.quality)
521
+ }), []];
522
+ }
522
523
  case "ABORT_INFLIGHT": return abortInflight(state, msg.trackId);
523
524
  }
524
525
  }
@@ -535,7 +536,7 @@ function undecodable(presentation, decodable) {
535
536
  const out = /* @__PURE__ */ new Set();
536
537
  for (const period of presentation.periods) for (const track of period.tracks) {
537
538
  if (track.contentType !== "video" && track.contentType !== "audio") continue;
538
- for (const r of track.renditions) if (r.codecs !== null && !decodable(`${r.mimeType}; codecs="${r.codecs}"`)) out.add(r.id);
539
+ for (const r of track.renditions) if (r.codecs !== null && !decodable(typeString(r.mimeType, r.codecs))) out.add(r.id);
539
540
  }
540
541
  return withDeadGroups(presentation, out);
541
542
  }
@@ -550,15 +551,15 @@ function loadPresentation(state, presentation, undecodableIds = /* @__PURE__ */
550
551
  for (const [token, request] of inflight) if (request.trackId === "manifest") inflight.delete(token);
551
552
  const phase = state.lifecycle.phase === "loading" ? "ready" : state.lifecycle.phase;
552
553
  const active = new Map(state.tracks.active);
553
- for (const period of presentation.periods) for (const track of period.tracks) if ((track.contentType === "video" || track.contentType === "audio") && !active.has(track.contentType) && track.renditions.some((r) => !undecodableIds.has(r.id))) active.set(track.contentType, track.id);
554
+ 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);
554
555
  const loaded = _objectSpread2(_objectSpread2({}, state), {}, {
555
556
  lifecycle: { phase },
556
557
  presentation,
557
558
  scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
558
- tracks: {
559
+ tracks: _objectSpread2(_objectSpread2({}, state.tracks), {}, {
559
560
  active,
560
561
  available
561
- },
562
+ }),
562
563
  quality: bumped(state.quality)
563
564
  });
564
565
  const manifestEffects = available.length === state.tracks.available.length && available.every((id, index) => id === state.tracks.available[index]) ? [] : [{
@@ -589,7 +590,7 @@ function reduceFact(state, msg, cfg, hooks) {
589
590
  case "MANIFEST_LOADED": {
590
591
  if (hooks.decodable === void 0) return loadPresentation(state, msg.presentation);
591
592
  const excluded = undecodable(msg.presentation, hooks.decodable);
592
- const tracks = msg.presentation.periods.flatMap((period) => period.tracks);
593
+ const tracks = msg.presentation.periods.flatMap((period) => period.tracks).filter((track) => !isTrick(track));
593
594
  const lead = ["video", "audio"].find((c) => tracks.some((t) => t.contentType === c));
594
595
  if (lead !== void 0 && !tracks.some((t) => t.contentType === lead && t.renditions.some((r) => !excluded.has(r.id)))) {
595
596
  const codecs = new Set(tracks.flatMap((t) => t.renditions.map((r) => {
@@ -678,7 +679,7 @@ function reduceFact(state, msg, cfg, hooks) {
678
679
  var _targetSite$rendition;
679
680
  const targetSite = findRendition(state.presentation, matched.renditionId);
680
681
  const declared = (_targetSite$rendition = targetSite === null || targetSite === void 0 ? void 0 : targetSite.rendition.codecs) !== null && _targetSite$rendition !== void 0 ? _targetSite$rendition : null;
681
- const targetCodecs = targetSite === null || declared === null ? buffer.codecs : `${targetSite.rendition.mimeType}; codecs="${declared}"`;
682
+ const targetCodecs = targetSite === null || declared === null ? buffer.codecs : typeString(targetSite.rendition.mimeType, declared);
682
683
  const familyChanged = declared !== null && codecFamily(declared) !== codecFamily(bufferCodecString(buffer.codecs));
683
684
  const nextBuffers = new Map(state.buffers);
684
685
  if (targetCodecs !== buffer.codecs && familyChanged) effects.push({
@@ -817,15 +818,7 @@ function reduceFact(state, msg, cfg, hooks) {
817
818
  status: (_msg$status2 = msg.status) !== null && _msg$status2 !== void 0 ? _msg$status2 : null
818
819
  }
819
820
  }];
820
- if (!isCueTrack) failEffects.push({
821
- kind: "schedule",
822
- token: "kernel:retry",
823
- delayMs: cfg.baseRetryDelayMs,
824
- then: {
825
- type: "TICK",
826
- token: "kernel:retry"
827
- }
828
- });
821
+ if (!isCueTrack) failEffects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
829
822
  return [_objectSpread2(_objectSpread2({}, state), {}, {
830
823
  cues,
831
824
  scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight })
@@ -889,15 +882,7 @@ function reduceFact(state, msg, cfg, hooks) {
889
882
  sbId: msg.sbId
890
883
  }, fatal && !msg.error.fatal ? { consecutiveFailures: count } : {})
891
884
  }];
892
- if (neverAppended && !fatal) effects.push({
893
- kind: "schedule",
894
- token: "kernel:retry",
895
- delayMs: cfg.baseRetryDelayMs,
896
- then: {
897
- type: "TICK",
898
- token: "kernel:retry"
899
- }
900
- });
885
+ if (neverAppended && !fatal) effects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
901
886
  let inflight = state.scheduling.inflight;
902
887
  if (fatal) {
903
888
  const pruned = new Map(state.scheduling.inflight);
@@ -967,7 +952,7 @@ function reduceFact(state, msg, cfg, hooks) {
967
952
  }
968
953
  }]];
969
954
  case "LIVE_WINDOW_CHANGED": {
970
- var _state$presentation2;
955
+ var _state$presentation;
971
956
  const firstWindow = state.live === null;
972
957
  const withLive = _objectSpread2(_objectSpread2({}, state), {}, { live: {
973
958
  span: {
@@ -977,7 +962,7 @@ function reduceFact(state, msg, cfg, hooks) {
977
962
  edge: msg.edge
978
963
  } });
979
964
  const spanEffects = [];
980
- if (firstWindow && ((_state$presentation2 = state.presentation) === null || _state$presentation2 === void 0 ? void 0 : _state$presentation2.duration) === void 0) spanEffects.push({
965
+ if (firstWindow && ((_state$presentation = state.presentation) === null || _state$presentation === void 0 ? void 0 : _state$presentation.duration) === void 0) spanEffects.push({
981
966
  kind: "setDuration",
982
967
  seconds: Number.POSITIVE_INFINITY
983
968
  });
@@ -1064,7 +1049,7 @@ function driveScheduling(state, hooks, cfg) {
1064
1049
  const inflight = [];
1065
1050
  for (const request of state.scheduling.inflight.values()) if (request.trackId === trackId) inflight.push(request);
1066
1051
  if (!state.buffers.has(sbId) && inflight.length === 0) {
1067
- const codecs = rendition.codecs === null ? rendition.mimeType : `${rendition.mimeType}; codecs="${rendition.codecs}"`;
1052
+ const codecs = typeString(rendition.mimeType, rendition.codecs);
1068
1053
  effects.push({
1069
1054
  kind: "createSourceBuffer",
1070
1055
  sbId,
@@ -1179,8 +1164,8 @@ function driveScheduling(state, hooks, cfg) {
1179
1164
  for (const request of result.requests) inflight.set(request.token, request);
1180
1165
  const mediaTracks = tracks.filter((track) => track.sbId !== void 0);
1181
1166
  if (state.presentation.duration !== void 0 && initFetches.length === 0 && result.effects.length === 0 && mediaTracks.length > 0 && mediaTracks.every((track) => {
1182
- var _state$presentation$d, _state$presentation3;
1183
- return bufferedEndFrom(track.ranges, state.playback.currentTime, .25) >= ((_state$presentation$d = (_state$presentation3 = state.presentation) === null || _state$presentation3 === void 0 ? void 0 : _state$presentation3.duration) !== null && _state$presentation$d !== void 0 ? _state$presentation$d : 0) - .5;
1167
+ var _state$presentation$d, _state$presentation2;
1168
+ return bufferedEndFrom(track.ranges, state.playback.currentTime, .25) >= ((_state$presentation$d = (_state$presentation2 = state.presentation) === null || _state$presentation2 === void 0 ? void 0 : _state$presentation2.duration) !== null && _state$presentation$d !== void 0 ? _state$presentation$d : 0) - .5;
1184
1169
  })) effects.push({ kind: "endOfStream" });
1185
1170
  if (effects.length === 0 && quality === state.quality) return [state, []];
1186
1171
  return [_objectSpread2(_objectSpread2({}, state), {}, {
@@ -1219,6 +1204,7 @@ const COMMAND_TYPES = {
1219
1204
  CONSTRAIN: true,
1220
1205
  RELEASE_CONSTRAINT: true,
1221
1206
  SET_BUFFER_GOAL: true,
1207
+ RESOLVE_RENDITION: true,
1222
1208
  ABORT_INFLIGHT: true
1223
1209
  };
1224
1210
  function isCommand(msg) {
@@ -11,7 +11,7 @@ function applyRefresh(presentation, refresh) {
11
11
  found = true;
12
12
  return _objectSpread2(_objectSpread2({}, track), {}, {
13
13
  protection: (_ref = (_track$protection = track.protection) !== null && _track$protection !== void 0 ? _track$protection : refresh.protection) !== null && _ref !== void 0 ? _ref : null,
14
- renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments: refresh.segments }, refresh.init !== void 0 ? { init: refresh.init } : {}) : rendition)
14
+ renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2(_objectSpread2({}, rendition), {}, { segments: refresh.segments }, refresh.init !== void 0 ? { init: refresh.init } : {}), refresh.tiles !== void 0 ? { tiles: refresh.tiles } : {}) : rendition)
15
15
  });
16
16
  }) }));
17
17
  if (!found) return null;
@@ -1,4 +1,5 @@
1
1
  import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { findRendition } from "./presentation.js";
2
3
  import { segmentAtTime } from "./timeline.js";
3
4
  import { bufferedEndFrom } from "./scheduler.js";
4
5
  //#region src/kernel/rendition-select.ts
@@ -72,6 +73,51 @@ function ladderNeighbours(renditions, activeId, constraints) {
72
73
  ...at + 1 < ladder.length ? [ladder[at + 1]] : []
73
74
  ];
74
75
  }
76
+ /** The group of an audio or text track, from the adapters' `group:name` id convention. */
77
+ function groupOf(trackId) {
78
+ const colon = trackId.indexOf(":");
79
+ return colon === -1 ? trackId : trackId.slice(0, colon);
80
+ }
81
+ /** Companion groups present, as `contentType:groupId`, for the coupling filter. */
82
+ function availableGroups(kernel) {
83
+ var _kernel$presentation$, _kernel$presentation;
84
+ const groups = /* @__PURE__ */ new Set();
85
+ for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.contentType === "audio" || track.contentType === "text") groups.add(`${track.contentType}:${groupOf(track.id)}`);
86
+ return groups;
87
+ }
88
+ /**
89
+ * The renditions of the active tracks an adapter resolves ahead of need,
90
+ * content type by content type in `types` order: for video the ladder
91
+ * neighbours of `videoId`, for the others every rendition of the active
92
+ * track. A track id repeated across periods yields each period's copy.
93
+ * Renditions asked for with RESOLVE_RENDITION follow.
94
+ */
95
+ function activeRenditions(kernel, types, videoId) {
96
+ var _kernel$tracks$resolv;
97
+ const out = [];
98
+ for (const contentType of types) {
99
+ var _kernel$presentation$2, _kernel$presentation2;
100
+ const trackId = kernel.tracks.active.get(contentType);
101
+ if (trackId === void 0) continue;
102
+ for (const period of (_kernel$presentation$2 = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.periods) !== null && _kernel$presentation$2 !== void 0 ? _kernel$presentation$2 : []) for (const track of period.tracks) {
103
+ if (track.id !== trackId) continue;
104
+ const candidates = contentType === "video" ? ladderNeighbours(track.renditions, videoId, kernel.quality.constraints) : track.renditions;
105
+ for (const rendition of candidates) out.push({
106
+ contentType,
107
+ rendition
108
+ });
109
+ }
110
+ }
111
+ for (const id of (_kernel$tracks$resolv = kernel.tracks.resolve) !== null && _kernel$tracks$resolv !== void 0 ? _kernel$tracks$resolv : []) {
112
+ if (out.some((entry) => entry.rendition.id === id)) continue;
113
+ const site = findRendition(kernel.presentation, id);
114
+ if (site !== null) out.push({
115
+ contentType: site.track.contentType,
116
+ rendition: site.rendition
117
+ });
118
+ }
119
+ return out;
120
+ }
75
121
  /**
76
122
  * `dead` plus the video variants that require an audio group none of whose
77
123
  * renditions is left. A variant names its audio by group, and the group
@@ -85,15 +131,14 @@ function withDeadGroups(presentation, dead) {
85
131
  const alive = /* @__PURE__ */ new Set();
86
132
  for (const period of presentation.periods) for (const track of period.tracks) {
87
133
  if (track.contentType !== "audio") continue;
88
- const colon = track.id.indexOf(":");
89
- const group = colon === -1 ? track.id : track.id.slice(0, colon);
134
+ const group = groupOf(track.id);
90
135
  known.add(group);
91
136
  if (track.renditions.some((r) => !dead.has(r.id))) alive.add(group);
92
137
  }
93
138
  for (const { renditionId, requires } of presentation.couplings) if (requires.audio !== void 0 && known.has(requires.audio) && !alive.has(requires.audio)) out.add(renditionId);
94
139
  return out;
95
140
  }
96
- /** The strict arbitration order from docs/08. Never deviate; never return zero renditions. */
141
+ /** The strict arbitration order. Never deviate; never return zero renditions. */
97
142
  function arbitrate(ctx) {
98
143
  const events = [];
99
144
  if (ctx.renditions.length === 0) return {
@@ -262,7 +307,7 @@ function canSwitchTo(current, target) {
262
307
  return "reload";
263
308
  }
264
309
  /**
265
- * The apply strategies from docs/08. `next` costs nothing and waits out
310
+ * The apply strategies. `next` costs nothing and waits out
266
311
  * the buffer. `soon` flushes from the next segment boundary after
267
312
  * currentTime plus a lead, so the switch is usually invisible. `now` pays
268
313
  * a visible stall for immediacy.
@@ -321,4 +366,4 @@ function planPinApply(input) {
321
366
  };
322
367
  }
323
368
  //#endregion
324
- export { arbitrate, canSwitchTo, codecFamily, createArbiter, ladderNeighbours, planPinApply, withDeadGroups };
369
+ export { activeRenditions, arbitrate, availableGroups, canSwitchTo, codecFamily, createArbiter, groupOf, ladderNeighbours, planPinApply, withDeadGroups };
@@ -35,35 +35,36 @@ function mergeRange(coverage, added) {
35
35
  merged.push(pending);
36
36
  return merged.sort((a, b) => a.start - b.start);
37
37
  }
38
- function createCueSink(contentType, kind, deps) {
39
- const tracks = /* @__PURE__ */ new Map();
40
- /**
41
- * A native track for the id. The element has no removeTextTrack, so a
42
- * previous attach on the same element (a rebuild, an element swap back)
43
- * leaves its tracks behind; one with our kind and label is adopted and
44
- * emptied rather than duplicated in the browser's caption menu.
45
- */
46
- /** Empties a native track. `cues` reads null while disabled; hidden makes them removable. */
47
- function empty(textTrack) {
48
- textTrack.mode = "hidden";
49
- const { cues } = textTrack;
50
- if (cues !== null) for (let i = cues.length - 1; i >= 0; i -= 1) {
51
- const cue = cues[i];
52
- if (cue !== void 0) textTrack.removeCue(cue);
53
- }
38
+ /** Empties a native track. `cues` reads null while disabled; hidden makes them removable. */
39
+ function emptyTextTrack(textTrack) {
40
+ textTrack.mode = "hidden";
41
+ const { cues } = textTrack;
42
+ if (cues === null) return;
43
+ for (let i = cues.length - 1; i >= 0; i -= 1) {
44
+ const cue = cues[i];
45
+ if (cue !== void 0) textTrack.removeCue(cue);
54
46
  }
55
- function adopt(label) {
56
- for (const existing of deps.element.textTracks) {
57
- if (existing.kind !== kind || existing.label !== label) continue;
58
- empty(existing);
59
- return existing;
60
- }
61
- return deps.element.addTextTrack(kind, label);
47
+ }
48
+ /**
49
+ * A native track of this kind and label on the element, emptied, or a new
50
+ * one. The element has no removeTextTrack, so a previous attach on the same
51
+ * element (a rebuild, an element swap back) leaves its tracks behind;
52
+ * adopting one keeps the browser's caption menu free of duplicates.
53
+ */
54
+ function adoptTextTrack(element, kind, label, lang) {
55
+ for (const existing of element.textTracks) {
56
+ if (existing.kind !== kind || existing.label !== label) continue;
57
+ emptyTextTrack(existing);
58
+ return existing;
62
59
  }
60
+ return element.addTextTrack(kind, label, lang);
61
+ }
62
+ function createCueSink(contentType, kind, deps) {
63
+ const tracks = /* @__PURE__ */ new Map();
63
64
  function retire(trackId) {
64
65
  const entry = tracks.get(trackId);
65
66
  if (entry === void 0) return;
66
- empty(entry.textTrack);
67
+ emptyTextTrack(entry.textTrack);
67
68
  entry.textTrack.mode = "disabled";
68
69
  tracks.delete(trackId);
69
70
  }
@@ -71,7 +72,7 @@ function createCueSink(contentType, kind, deps) {
71
72
  let entry = tracks.get(trackId);
72
73
  if (entry === void 0) {
73
74
  var _deps$label;
74
- const textTrack = adopt(`${(_deps$label = deps.label) !== null && _deps$label !== void 0 ? _deps$label : "mattebox"}:${trackId}`);
75
+ const textTrack = adoptTextTrack(deps.element, kind, `${(_deps$label = deps.label) !== null && _deps$label !== void 0 ? _deps$label : "mattebox"}:${trackId}`);
75
76
  textTrack.mode = "hidden";
76
77
  entry = {
77
78
  textTrack,
@@ -164,4 +165,4 @@ function createTextTrackSink(deps) {
164
165
  return createCueSink("text", "subtitles", deps);
165
166
  }
166
167
  //#endregion
167
- export { createCueSink, createTextTrackSink };
168
+ export { adoptTextTrack, createCueSink, createTextTrackSink, emptyTextTrack };
@@ -145,4 +145,4 @@ function segmentAtTime(addressing, time, periodStart = 0) {
145
145
  return null;
146
146
  }
147
147
  //#endregion
148
- export { buildEpochs, epochForSeq, epochKey, reconciledOffset, segmentAt, segmentAtTime, timestampOffsetFor };
148
+ export { buildEpochs, epochForSeq, epochKey, isIndexed, isUnresolved, reconciledOffset, segmentAt, segmentAtTime, timestampOffsetFor };
@@ -1,3 +1,4 @@
1
+ import { findTrackSite, isTrick } from "./presentation.js";
1
2
  //#region src/kernel/track-registry.ts
2
3
  function allTracks(state) {
3
4
  if (state.presentation === null) return [];
@@ -5,8 +6,8 @@ function allTracks(state) {
5
6
  }
6
7
  function createTrackRegistry(deps) {
7
8
  function find(trackId) {
8
- var _allTracks$find;
9
- return (_allTracks$find = allTracks(deps.getState()).find((track) => track.id === trackId)) !== null && _allTracks$find !== void 0 ? _allTracks$find : null;
9
+ var _findTrackSite$track, _findTrackSite;
10
+ return (_findTrackSite$track = (_findTrackSite = findTrackSite(deps.getState().presentation, trackId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track) !== null && _findTrackSite$track !== void 0 ? _findTrackSite$track : null;
10
11
  }
11
12
  return {
12
13
  get available() {
@@ -23,6 +24,13 @@ function createTrackRegistry(deps) {
23
24
  },
24
25
  select(trackId) {
25
26
  const track = find(trackId);
27
+ if (track !== null && isTrick(track)) {
28
+ deps.emitEvent("command:rejected", {
29
+ command: "SELECT_TRACK",
30
+ reason: `trick track: ${trackId}`
31
+ });
32
+ return;
33
+ }
26
34
  if (track !== null && !deps.hasSink(track.contentType)) {
27
35
  deps.emitEvent("command:rejected", {
28
36
  command: "SELECT_TRACK",
@@ -0,0 +1,12 @@
1
+ //#region src/kernel/url.ts
2
+ /** URL resolution shared by the manifest parsers and the stages that read files. */
3
+ /** A URI made absolute against the document that carried it; an unparsable one stays as written. */
4
+ function resolveUrl(uri, baseUrl) {
5
+ try {
6
+ return new URL(uri, baseUrl).href;
7
+ } catch (_unused) {
8
+ return uri;
9
+ }
10
+ }
11
+ //#endregion
12
+ export { resolveUrl };
@@ -1,12 +1,16 @@
1
+ import trickPlay from "../../stages/trick-play/index.js";
1
2
  import thumbnails from "../../stages/thumbnails/index.js";
2
3
  import cmcd from "../../stages/cmcd/index.js";
4
+ import chapters from "../../stages/chapters/index.js";
3
5
  import { definePreset } from "../define.js";
4
6
  import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
5
7
  //#region src/presets/full/index.ts
6
8
  /**
7
9
  * The `full` preset: every stage the catalogue ships. `dual-ts-drm` plus
8
- * the accessories: CMCD (changes every request, so opt-in elsewhere) and
9
- * thumbnails (needs an app-supplied sprite track). Feature parity with
10
+ * the accessories: CMCD (changes every request, so opt-in elsewhere),
11
+ * thumbnails (fetches image playlists, so opt-in elsewhere), chapters
12
+ * (loads a file the app names), and trick play (a UI control drives it).
13
+ * Feature parity with
10
14
  * videojs-http-streaming; the modularity claim is measured against it, and
11
15
  * the main CDN bundle exposes it.
12
16
  */
@@ -17,7 +21,9 @@ const preset = definePreset("full", () => [
17
21
  ...tsTier(),
18
22
  ...drmTier(),
19
23
  cmcd(),
20
- thumbnails()
24
+ thumbnails(),
25
+ chapters(),
26
+ trickPlay()
21
27
  ]);
22
28
  //#endregion
23
29
  export { preset as default };
@@ -0,0 +1,28 @@
1
+ //#region src/protocols/adapter-shared.ts
2
+ function manifestError(reason) {
3
+ return {
4
+ category: "manifest",
5
+ code: "MANIFEST_PARSE_FAILED",
6
+ fatal: true,
7
+ recoverable: false,
8
+ context: { reason }
9
+ };
10
+ }
11
+ /**
12
+ * The fact for fetched manifest bytes, or null when this adapter does not
13
+ * claim them. Declining emits nothing; the kernel reports bytes nobody claims.
14
+ */
15
+ function manifestFact(bytes, url, claims, parse) {
16
+ const text = new TextDecoder().decode(bytes);
17
+ if (!claims(text)) return null;
18
+ const result = parse(text, url);
19
+ return result.presentation === null ? {
20
+ type: "MANIFEST_FAILED",
21
+ error: result.error
22
+ } : {
23
+ type: "MANIFEST_LOADED",
24
+ presentation: result.presentation
25
+ };
26
+ }
27
+ //#endregion
28
+ export { manifestError, manifestFact };