mattebox 0.6.0 → 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 (335) 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 +75 -7
  33. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  34. package/dist/containers/mp4-box/index.js +225 -49
  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 +9 -27
  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 +11 -2
  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/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
  61. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
  62. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
  63. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
  64. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  65. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
  66. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
  67. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
  68. package/dist/es2015/containers/adts.js +28 -8
  69. package/dist/es2015/containers/codec-probe/index.js +17 -26
  70. package/dist/es2015/containers/fmp4/fit.js +46 -0
  71. package/dist/es2015/containers/fmp4/writer.js +9 -1
  72. package/dist/es2015/containers/id3.js +3 -3
  73. package/dist/es2015/containers/mp4-box/index.js +224 -39
  74. package/dist/es2015/containers/packed-audio/index.js +6 -33
  75. package/dist/es2015/containers/sei.js +6 -3
  76. package/dist/es2015/containers/ts-transmux/demux.js +41 -22
  77. package/dist/es2015/containers/ts-transmux/h264.js +2 -18
  78. package/dist/es2015/containers/ts-transmux/index.js +9 -9
  79. package/dist/es2015/containers/ts-transmux/transmux.js +8 -39
  80. package/dist/es2015/{stages/text-webvtt/parse.js → containers/webvtt.js} +2 -2
  81. package/dist/es2015/index.js +40 -42
  82. package/dist/es2015/kernel/append-queue.js +1 -1
  83. package/dist/es2015/kernel/base64.js +25 -0
  84. package/dist/es2015/kernel/context.js +7 -0
  85. package/dist/es2015/kernel/effects.js +21 -1
  86. package/dist/es2015/kernel/loader.js +5 -4
  87. package/dist/es2015/kernel/mime.js +5 -1
  88. package/dist/es2015/kernel/mse.js +27 -71
  89. package/dist/es2015/kernel/prepare.js +77 -0
  90. package/dist/es2015/kernel/presentation.js +24 -0
  91. package/dist/es2015/kernel/reducer.js +279 -124
  92. package/dist/es2015/kernel/refresh.js +35 -0
  93. package/dist/es2015/kernel/rendition-select.js +109 -4
  94. package/dist/es2015/kernel/scheduler.js +23 -5
  95. package/dist/es2015/kernel/sinks/text-track-sink.js +27 -26
  96. package/dist/es2015/kernel/timeline.js +22 -1
  97. package/dist/es2015/kernel/trace.js +1 -1
  98. package/dist/es2015/kernel/track-registry.js +10 -2
  99. package/dist/es2015/kernel/transport.js +4 -4
  100. package/dist/es2015/kernel/url.js +12 -0
  101. package/dist/es2015/presets/define.js +2 -2
  102. package/dist/es2015/presets/full/index.js +9 -3
  103. package/dist/es2015/presets/tiers.js +7 -6
  104. package/dist/es2015/protocols/adapter-shared.js +28 -0
  105. package/dist/es2015/protocols/dash-cmaf/index.js +132 -88
  106. package/dist/es2015/protocols/dash-cmaf/parse.js +62 -64
  107. package/dist/es2015/protocols/dash-live/index.js +62 -37
  108. package/dist/es2015/protocols/dimensions.js +15 -0
  109. package/dist/es2015/protocols/hls-cmaf/index.js +108 -95
  110. package/dist/es2015/protocols/hls-cmaf/lexer.js +3 -0
  111. package/dist/es2015/protocols/hls-cmaf/parse.js +167 -56
  112. package/dist/es2015/protocols/hls-cmaf/unavailable.js +43 -0
  113. package/dist/es2015/protocols/hls-live/index.js +187 -109
  114. package/dist/es2015/stages/abr/index.js +8 -11
  115. package/dist/es2015/stages/abr-persist/index.js +18 -11
  116. package/dist/es2015/stages/aes-128/index.js +15 -8
  117. package/dist/es2015/stages/alt-audio/index.js +25 -13
  118. package/dist/es2015/stages/chapters/index.js +151 -0
  119. package/dist/es2015/stages/chapters/parse.js +149 -0
  120. package/dist/es2015/stages/cmaf-timing/index.js +24 -39
  121. package/dist/es2015/stages/cmcd/index.js +29 -6
  122. package/dist/es2015/stages/codec-switch/index.js +2 -5
  123. package/dist/es2015/stages/content-steering/index.js +13 -16
  124. package/dist/es2015/stages/eme-cenc/index.js +10 -4
  125. package/dist/es2015/stages/eme-core/index.js +31 -13
  126. package/dist/es2015/stages/eme-fairplay/index.js +12 -8
  127. package/dist/es2015/stages/nal-scan/index.js +30 -140
  128. package/dist/es2015/stages/recovery/index.js +47 -54
  129. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  130. package/dist/es2015/stages/text-cea608/index.js +3 -17
  131. package/dist/es2015/stages/text-webvtt/index.js +1 -1
  132. package/dist/es2015/stages/text-webvtt-segmented/index.js +15 -8
  133. package/dist/es2015/stages/thumbnails/index.js +213 -43
  134. package/dist/es2015/stages/trick-play/index.js +463 -0
  135. package/dist/index.d.ts +6 -0
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +36 -53
  138. package/dist/index.js.map +1 -1
  139. package/dist/kernel/base64.d.ts +9 -0
  140. package/dist/kernel/base64.d.ts.map +1 -0
  141. package/dist/kernel/base64.js +26 -0
  142. package/dist/kernel/base64.js.map +1 -0
  143. package/dist/kernel/context.d.ts +5 -1
  144. package/dist/kernel/context.d.ts.map +1 -1
  145. package/dist/kernel/context.js +10 -0
  146. package/dist/kernel/context.js.map +1 -1
  147. package/dist/kernel/effects.d.ts +9 -1
  148. package/dist/kernel/effects.d.ts.map +1 -1
  149. package/dist/kernel/effects.js +12 -0
  150. package/dist/kernel/effects.js.map +1 -1
  151. package/dist/kernel/lifecycle.js +1 -1
  152. package/dist/kernel/lifecycle.js.map +1 -1
  153. package/dist/kernel/loader.d.ts.map +1 -1
  154. package/dist/kernel/loader.js +5 -7
  155. package/dist/kernel/loader.js.map +1 -1
  156. package/dist/kernel/mime.d.ts +2 -0
  157. package/dist/kernel/mime.d.ts.map +1 -1
  158. package/dist/kernel/mime.js +4 -0
  159. package/dist/kernel/mime.js.map +1 -1
  160. package/dist/kernel/mse.d.ts +6 -10
  161. package/dist/kernel/mse.d.ts.map +1 -1
  162. package/dist/kernel/mse.js +20 -73
  163. package/dist/kernel/mse.js.map +1 -1
  164. package/dist/kernel/prepare.d.ts +28 -0
  165. package/dist/kernel/prepare.d.ts.map +1 -0
  166. package/dist/kernel/prepare.js +89 -0
  167. package/dist/kernel/prepare.js.map +1 -0
  168. package/dist/kernel/presentation.d.ts +20 -0
  169. package/dist/kernel/presentation.d.ts.map +1 -0
  170. package/dist/kernel/presentation.js +25 -0
  171. package/dist/kernel/presentation.js.map +1 -0
  172. package/dist/kernel/reducer.d.ts +24 -0
  173. package/dist/kernel/reducer.d.ts.map +1 -1
  174. package/dist/kernel/reducer.js +375 -152
  175. package/dist/kernel/reducer.js.map +1 -1
  176. package/dist/kernel/refresh.d.ts +14 -0
  177. package/dist/kernel/refresh.d.ts.map +1 -0
  178. package/dist/kernel/refresh.js +51 -0
  179. package/dist/kernel/refresh.js.map +1 -0
  180. package/dist/kernel/rendition-select.d.ts +38 -5
  181. package/dist/kernel/rendition-select.d.ts.map +1 -1
  182. package/dist/kernel/rendition-select.js +134 -2
  183. package/dist/kernel/rendition-select.js.map +1 -1
  184. package/dist/kernel/scheduler.d.ts +18 -3
  185. package/dist/kernel/scheduler.d.ts.map +1 -1
  186. package/dist/kernel/scheduler.js +32 -7
  187. package/dist/kernel/scheduler.js.map +1 -1
  188. package/dist/kernel/sinks/text-track-sink.d.ts +9 -0
  189. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  190. package/dist/kernel/sinks/text-track-sink.js +29 -29
  191. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  192. package/dist/kernel/timeline.d.ts +26 -7
  193. package/dist/kernel/timeline.d.ts.map +1 -1
  194. package/dist/kernel/timeline.js +21 -7
  195. package/dist/kernel/timeline.js.map +1 -1
  196. package/dist/kernel/track-registry.d.ts.map +1 -1
  197. package/dist/kernel/track-registry.js +17 -1
  198. package/dist/kernel/track-registry.js.map +1 -1
  199. package/dist/kernel/transport.d.ts.map +1 -1
  200. package/dist/kernel/transport.js +1 -0
  201. package/dist/kernel/transport.js.map +1 -1
  202. package/dist/kernel/url.d.ts +4 -0
  203. package/dist/kernel/url.d.ts.map +1 -0
  204. package/dist/kernel/url.js +11 -0
  205. package/dist/kernel/url.js.map +1 -0
  206. package/dist/presets/full/index.d.ts.map +1 -1
  207. package/dist/presets/full/index.js +8 -2
  208. package/dist/presets/full/index.js.map +1 -1
  209. package/dist/presets/tiers.d.ts +7 -6
  210. package/dist/presets/tiers.d.ts.map +1 -1
  211. package/dist/presets/tiers.js +7 -6
  212. package/dist/presets/tiers.js.map +1 -1
  213. package/dist/protocols/adapter-shared.d.ts +23 -0
  214. package/dist/protocols/adapter-shared.d.ts.map +1 -0
  215. package/dist/protocols/adapter-shared.js +23 -0
  216. package/dist/protocols/adapter-shared.js.map +1 -0
  217. package/dist/protocols/dash-cmaf/index.d.ts +2 -2
  218. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  219. package/dist/protocols/dash-cmaf/index.js +150 -97
  220. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  221. package/dist/protocols/dash-cmaf/parse.d.ts +2 -5
  222. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  223. package/dist/protocols/dash-cmaf/parse.js +46 -39
  224. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  225. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  226. package/dist/protocols/dash-live/index.js +67 -25
  227. package/dist/protocols/dash-live/index.js.map +1 -1
  228. package/dist/protocols/dimensions.d.ts +8 -0
  229. package/dist/protocols/dimensions.d.ts.map +1 -0
  230. package/dist/protocols/dimensions.js +13 -0
  231. package/dist/protocols/dimensions.js.map +1 -0
  232. package/dist/protocols/hls-cmaf/index.d.ts +3 -2
  233. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  234. package/dist/protocols/hls-cmaf/index.js +127 -114
  235. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  236. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  237. package/dist/protocols/hls-cmaf/lexer.js +3 -0
  238. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  239. package/dist/protocols/hls-cmaf/parse.d.ts +22 -14
  240. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  241. package/dist/protocols/hls-cmaf/parse.js +196 -69
  242. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  243. package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
  244. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
  245. package/dist/protocols/hls-cmaf/unavailable.js +38 -0
  246. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
  247. package/dist/protocols/hls-live/index.d.ts +17 -0
  248. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  249. package/dist/protocols/hls-live/index.js +202 -106
  250. package/dist/protocols/hls-live/index.js.map +1 -1
  251. package/dist/stages/abr/index.d.ts.map +1 -1
  252. package/dist/stages/abr/index.js +8 -14
  253. package/dist/stages/abr/index.js.map +1 -1
  254. package/dist/stages/abr-cap-size/index.d.ts +1 -1
  255. package/dist/stages/abr-persist/index.d.ts.map +1 -1
  256. package/dist/stages/abr-persist/index.js +17 -7
  257. package/dist/stages/abr-persist/index.js.map +1 -1
  258. package/dist/stages/aes-128/index.d.ts +0 -9
  259. package/dist/stages/aes-128/index.d.ts.map +1 -1
  260. package/dist/stages/aes-128/index.js +15 -13
  261. package/dist/stages/aes-128/index.js.map +1 -1
  262. package/dist/stages/alt-audio/index.d.ts +16 -0
  263. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  264. package/dist/stages/alt-audio/index.js +28 -15
  265. package/dist/stages/alt-audio/index.js.map +1 -1
  266. package/dist/stages/chapters/index.d.ts +20 -0
  267. package/dist/stages/chapters/index.d.ts.map +1 -0
  268. package/dist/stages/chapters/index.js +141 -0
  269. package/dist/stages/chapters/index.js.map +1 -0
  270. package/dist/stages/chapters/parse.d.ts +47 -0
  271. package/dist/stages/chapters/parse.d.ts.map +1 -0
  272. package/dist/stages/chapters/parse.js +168 -0
  273. package/dist/stages/chapters/parse.js.map +1 -0
  274. package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
  275. package/dist/stages/cmaf-timing/index.js +33 -42
  276. package/dist/stages/cmaf-timing/index.js.map +1 -1
  277. package/dist/stages/cmcd/index.d.ts +0 -11
  278. package/dist/stages/cmcd/index.d.ts.map +1 -1
  279. package/dist/stages/cmcd/index.js +30 -12
  280. package/dist/stages/cmcd/index.js.map +1 -1
  281. package/dist/stages/codec-switch/index.d.ts.map +1 -1
  282. package/dist/stages/codec-switch/index.js +3 -8
  283. package/dist/stages/codec-switch/index.js.map +1 -1
  284. package/dist/stages/content-steering/index.d.ts.map +1 -1
  285. package/dist/stages/content-steering/index.js +12 -9
  286. package/dist/stages/content-steering/index.js.map +1 -1
  287. package/dist/stages/eme-cenc/index.d.ts +0 -7
  288. package/dist/stages/eme-cenc/index.d.ts.map +1 -1
  289. package/dist/stages/eme-cenc/index.js +9 -5
  290. package/dist/stages/eme-cenc/index.js.map +1 -1
  291. package/dist/stages/eme-core/index.d.ts.map +1 -1
  292. package/dist/stages/eme-core/index.js +31 -15
  293. package/dist/stages/eme-core/index.js.map +1 -1
  294. package/dist/stages/eme-fairplay/index.d.ts +0 -7
  295. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  296. package/dist/stages/eme-fairplay/index.js +11 -9
  297. package/dist/stages/eme-fairplay/index.js.map +1 -1
  298. package/dist/stages/nal-scan/index.d.ts.map +1 -1
  299. package/dist/stages/nal-scan/index.js +32 -145
  300. package/dist/stages/nal-scan/index.js.map +1 -1
  301. package/dist/stages/recovery/index.d.ts.map +1 -1
  302. package/dist/stages/recovery/index.js +42 -56
  303. package/dist/stages/recovery/index.js.map +1 -1
  304. package/dist/stages/text-cea608/index.d.ts +11 -0
  305. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  306. package/dist/stages/text-cea608/index.js +3 -23
  307. package/dist/stages/text-cea608/index.js.map +1 -1
  308. package/dist/stages/text-webvtt/index.d.ts +12 -0
  309. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  310. package/dist/stages/text-webvtt/index.js +1 -1
  311. package/dist/stages/text-webvtt/index.js.map +1 -1
  312. package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -1
  313. package/dist/stages/text-webvtt-segmented/index.js +11 -8
  314. package/dist/stages/text-webvtt-segmented/index.js.map +1 -1
  315. package/dist/stages/thumbnails/index.d.ts +39 -10
  316. package/dist/stages/thumbnails/index.d.ts.map +1 -1
  317. package/dist/stages/thumbnails/index.js +220 -30
  318. package/dist/stages/thumbnails/index.js.map +1 -1
  319. package/dist/stages/trick-play/index.d.ts +51 -0
  320. package/dist/stages/trick-play/index.d.ts.map +1 -0
  321. package/dist/stages/trick-play/index.js +480 -0
  322. package/dist/stages/trick-play/index.js.map +1 -0
  323. package/dist/types/ir.d.ts +40 -1
  324. package/dist/types/ir.d.ts.map +1 -1
  325. package/dist/types/kernel.d.ts +41 -13
  326. package/dist/types/kernel.d.ts.map +1 -1
  327. package/dist/types/kernel.js +2 -1
  328. package/dist/types/kernel.js.map +1 -1
  329. package/dist/types/messages.d.ts +61 -10
  330. package/dist/types/messages.d.ts.map +1 -1
  331. package/dist/types/stage.d.ts +18 -0
  332. package/dist/types/stage.d.ts.map +1 -1
  333. package/package.json +1 -1
  334. package/dist/stages/text-webvtt/parse.d.ts.map +0 -1
  335. package/dist/stages/text-webvtt/parse.js.map +0 -1
@@ -1,7 +1,28 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
- import { mergePlaylist, parseMediaPlaylist } from "../hls-cmaf/parse.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled, tickAfter } from "../../kernel/effects.js";
3
+ import { findRendition } from "../../kernel/presentation.js";
4
+ import { activeRenditions } from "../../kernel/rendition-select.js";
5
+ import { parseMediaPlaylist, refreshFor } from "../hls-cmaf/parse.js";
6
+ import { RELOAD_FAILED, unavailableMessages } from "../hls-cmaf/unavailable.js";
3
7
  import { registerLiveNamespace } from "../live-shared.js";
4
8
  //#region src/protocols/hls-live/index.ts
9
+ /**
10
+ * HLS live: the edge is read, never computed. A slice reducer reloads the
11
+ * active playlists on the TARGETDURATION cadence, reconciles the sliding
12
+ * window as absorb-a-fact-derive-the-diff (seqs stay stable across reloads
13
+ * because they come from MEDIA-SEQUENCE, so replacing the segment list IS
14
+ * the diff for scheduling), and reports the availability window through
15
+ * LIVE_WINDOW_CHANGED facts. EXT-X-ENDLIST converts the presentation to
16
+ * VOD and the reload loop dies with it.
17
+ *
18
+ * One playlist drives the window (the active video rendition, or audio for
19
+ * an audio-only presentation); every other active track's playlist (the
20
+ * audio group's rendition, a segmented subtitle playlist) reloads on the
21
+ * same tick as a companion, the way videojs-http-streaming runs a playlist
22
+ * loader per media type. A companion left stale drains once playback
23
+ * passes the edge it was fetched at, which looks like a live stream dying
24
+ * a minute in.
25
+ */
5
26
  const REFRESH_TOKEN = "hls:live:refresh";
6
27
  const TICK_TOKEN = "hls-live:reload";
7
28
  const INITIAL = {
@@ -13,9 +34,20 @@ const INITIAL = {
13
34
  inflight: null,
14
35
  lastEndSeq: -1,
15
36
  awaitingTarget: false,
16
- suspended: false
37
+ suspended: false,
38
+ failures: {},
39
+ abandoned: []
17
40
  };
18
41
  /**
42
+ * Failed reloads of one playlist in a row before the loop gives up on it.
43
+ * Each reload already carries the transport's own retries, so this is
44
+ * several rounds of a playlist that does not answer: an expired token, a
45
+ * stream that ended without ENDLIST. The playlist is then abandoned and
46
+ * playback moves off it. Retrying forever only keeps the network busy for
47
+ * a stream that cannot play.
48
+ */
49
+ const FAILURE_LIMIT = 4;
50
+ /**
19
51
  * A two-hour DVR playlist is tens of kilobytes; reloading four of them every
20
52
  * target duration saturates a slow link. The audio and text companions keep
21
53
  * the full cadence because playback consumes them; the other video rungs
@@ -34,61 +66,63 @@ const LADDER_EVERY = 3;
34
66
  function refreshToken(renditionId) {
35
67
  return `${REFRESH_TOKEN}:${renditionId}`;
36
68
  }
69
+ /** A reload of one playlist. The rendition rides along so a failure counts toward steering failover. */
70
+ function reload(target) {
71
+ return {
72
+ kind: "fetch",
73
+ token: refreshToken(target.renditionId),
74
+ url: target.url,
75
+ renditionId: target.renditionId
76
+ };
77
+ }
37
78
  function renditionOfToken(token) {
38
79
  return token.startsWith(`${REFRESH_TOKEN}:`) ? token.slice(17) : null;
39
80
  }
40
- function findRendition(presentation, renditionId) {
41
- for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return rendition;
42
- return null;
43
- }
44
81
  /**
45
- * The active tracks' playlists other than the window rendition's: every
46
- * other video rendition, the audio group rendition, a segmented subtitle
47
- * playlist. The whole video ladder reloads because a switch can only land
48
- * on a rendition whose playlist reaches the playhead; one left at its
49
- * startup window can never be scheduled from, so the switch never happens.
50
- * Renditions without a playlist of their own (muxed audio, a text track in
51
- * a single file) need no reload.
82
+ * The active tracks' playlists other than the window rendition's: the audio
83
+ * group rendition, a segmented subtitle playlist, and the video rungs next
84
+ * to the window rendition. A switch can only land on a rendition whose
85
+ * playlist reaches the playhead, and ABR steps one rung at a time, so the
86
+ * neighbours stay fresh; a longer jump reloads its target at once (the
87
+ * switch branch). Reloading the whole ladder saturates the link on a large
88
+ * multivariant playlist. Renditions without a playlist of their own (muxed
89
+ * audio, a text track in a single file) need no reload, and a playlist
90
+ * shared by several renditions reloads once.
52
91
  */
53
- function companionTargets(presentation, kernel, windowRenditionId) {
54
- const activeIds = new Set([
92
+ function companionTargets(kernel, window, abandoned) {
93
+ var _window$id;
94
+ const urls = /* @__PURE__ */ new Set();
95
+ if ((window === null || window === void 0 ? void 0 : window.playlistUrl) !== void 0) urls.add(window.playlistUrl);
96
+ const out = [];
97
+ const add = (rendition, ladder) => {
98
+ const url = rendition.playlistUrl;
99
+ if (url === void 0 || urls.has(url) || abandoned.includes(rendition.id)) return;
100
+ urls.add(url);
101
+ out.push({
102
+ url,
103
+ renditionId: rendition.id,
104
+ ladder
105
+ });
106
+ };
107
+ const types = window === null ? [
108
+ "audio",
109
+ "text",
110
+ "image"
111
+ ] : [
55
112
  "video",
56
113
  "audio",
57
- "text"
58
- ].map((contentType) => kernel.tracks.active.get(contentType)).filter((id) => id !== void 0));
59
- const out = [];
60
- for (const period of presentation.periods) for (const track of period.tracks) {
61
- if (!activeIds.has(track.id)) continue;
62
- for (const rendition of track.renditions) {
63
- if (rendition.id === windowRenditionId || rendition.playlistUrl === void 0) continue;
64
- out.push({
65
- url: rendition.playlistUrl,
66
- renditionId: rendition.id,
67
- ladder: track.contentType === "video"
68
- });
69
- }
70
- }
114
+ "text",
115
+ "image"
116
+ ];
117
+ for (const { contentType, rendition } of activeRenditions(kernel, types, (_window$id = window === null || window === void 0 ? void 0 : window.id) !== null && _window$id !== void 0 ? _window$id : null)) add(rendition, contentType === "video");
71
118
  return out;
72
119
  }
73
120
  /** Loops a message back into the bus through a zero-delay schedule effect. */
74
121
  function feed(message) {
75
- return {
76
- kind: "schedule",
77
- token: "hls-live:loopback",
78
- delayMs: 0,
79
- then: message
80
- };
122
+ return scheduled("hls-live:loopback", message);
81
123
  }
82
124
  function tick(delaySeconds) {
83
- return {
84
- kind: "schedule",
85
- token: TICK_TOKEN,
86
- delayMs: Math.max(500, delaySeconds * 1e3),
87
- then: {
88
- type: "TICK",
89
- token: TICK_TOKEN
90
- }
91
- };
125
+ return tickAfter(TICK_TOKEN, Math.max(500, delaySeconds * 1e3));
92
126
  }
93
127
  /**
94
128
  * The rendition whose playlist drives the live window: the active video
@@ -96,7 +130,7 @@ function tick(delaySeconds) {
96
130
  * presentation (a radio or packed-audio DVR stream) has no video track, so
97
131
  * audio drives the window there.
98
132
  */
99
- function windowRendition(presentation, kernel) {
133
+ function windowRendition(presentation, kernel, abandoned) {
100
134
  let fallback = null;
101
135
  for (const contentType of ["video", "audio"]) {
102
136
  for (const period of presentation.periods) for (const track of period.tracks) {
@@ -104,6 +138,7 @@ function windowRendition(presentation, kernel) {
104
138
  for (const rendition of track.renditions) {
105
139
  var _fallback;
106
140
  if (!Array.isArray(rendition.segments) || rendition.segments.length === 0) continue;
141
+ if (abandoned.includes(rendition.id)) continue;
107
142
  if (rendition.id === kernel.quality.active) return rendition;
108
143
  fallback = (_fallback = fallback) !== null && _fallback !== void 0 ? _fallback : rendition;
109
144
  }
@@ -115,7 +150,7 @@ function windowRendition(presentation, kernel) {
115
150
  /**
116
151
  * The window fact for the rendition's current segment list, or null when
117
152
  * the kernel already holds exactly that window: every companion reload
118
- * feeds a MANIFEST_LOADED, and a window that has not moved is not news.
153
+ * feeds a PLAYLIST_REFRESHED, and a window that has not moved is not news.
119
154
  */
120
155
  function windowFact(presentation, rendition, kernel) {
121
156
  var _presentation$live$ho, _presentation$live, _presentation$live$up, _presentation$live2;
@@ -139,10 +174,69 @@ function windowFact(presentation, rendition, kernel) {
139
174
  }
140
175
  /** The playlist URL a rendition's reload resolves against. */
141
176
  function playlistUrlFor(presentation, renditionId, target) {
142
- const rendition = findRendition(presentation, renditionId);
177
+ var _findRendition;
178
+ const rendition = (_findRendition = findRendition(presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.rendition;
143
179
  if ((rendition === null || rendition === void 0 ? void 0 : rendition.playlistUrl) !== void 0) return rendition.playlistUrl;
144
180
  return target !== null && target.renditionId === renditionId ? target.url : null;
145
181
  }
182
+ /** Every rendition whose playlist is `url`. */
183
+ function renditionIdsAt(presentation, url) {
184
+ const ids = [];
185
+ for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.playlistUrl === url) ids.push(rendition.id);
186
+ return ids;
187
+ }
188
+ /**
189
+ * A reload that failed, or answered with a playlist that does not parse.
190
+ * The target tries again soon rather than let the loop die, and every
191
+ * other playlist waits for the next tick, up to FAILURE_LIMIT times in a
192
+ * row. Then the playlist is abandoned: its renditions are excluded, so
193
+ * arbitration moves to another variant (or, for an audio group, to a
194
+ * variant on another group), and the next tick reloads whatever the window
195
+ * rendition is then. The load fails only when nothing is left to move to.
196
+ */
197
+ function reloadFailed(state, kernel, renditionId, error) {
198
+ var _state$failures$rendi, _findRendition2;
199
+ const count = ((_state$failures$rendi = state.failures[renditionId]) !== null && _state$failures$rendi !== void 0 ? _state$failures$rendi : 0) + 1;
200
+ const failures = _objectSpread2(_objectSpread2({}, state.failures), {}, { [renditionId]: count });
201
+ const isTarget = state.target !== null && renditionId === state.target.renditionId;
202
+ if (count < FAILURE_LIMIT) {
203
+ if (!isTarget) return [_objectSpread2(_objectSpread2({}, state), {}, { failures }), []];
204
+ if (state.tickPending) return [_objectSpread2(_objectSpread2({}, state), {}, {
205
+ failures,
206
+ inflight: null
207
+ }), []];
208
+ return [_objectSpread2(_objectSpread2({}, state), {}, {
209
+ failures,
210
+ inflight: null,
211
+ tickPending: true
212
+ }), [tick(2)]];
213
+ }
214
+ const presentation = kernel.presentation;
215
+ const url = presentation === null ? null : playlistUrlFor(presentation, renditionId, state.target);
216
+ const sharing = presentation !== null && url !== null && ((_findRendition2 = findRendition(presentation, renditionId)) === null || _findRendition2 === void 0 ? void 0 : _findRendition2.rendition.playlistUrl) !== void 0 ? renditionIdsAt(presentation, url) : [renditionId];
217
+ const abandoned = [.../* @__PURE__ */ new Set([...state.abandoned, ...sharing])];
218
+ const messages = unavailableMessages(kernel, RELOAD_FAILED, abandoned, {
219
+ category: "manifest",
220
+ code: "MANIFEST_REFRESH_FAILED",
221
+ fatal: true,
222
+ recoverable: false,
223
+ context: {
224
+ cause: error.code,
225
+ renditionId,
226
+ attempts: count
227
+ }
228
+ });
229
+ const next = _objectSpread2(_objectSpread2({}, state), {}, {
230
+ failures,
231
+ abandoned,
232
+ companions: state.companions.filter((c) => !abandoned.includes(c.renditionId)),
233
+ inflight: isTarget ? null : state.inflight
234
+ });
235
+ const effects = messages.map(feed);
236
+ const failed = messages.some((m) => m.type === "MANIFEST_FAILED");
237
+ if (isTarget && !failed && !state.tickPending) return [_objectSpread2(_objectSpread2({}, next), {}, { tickPending: true }), [...effects, tick(2)]];
238
+ return [next, effects];
239
+ }
146
240
  const reduceHlsLive = (slice, msg, kernel) => {
147
241
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
148
242
  if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, { manifestUrl: msg.url }), []];
@@ -168,29 +262,22 @@ const reduceHlsLive = (slice, msg, kernel) => {
168
262
  if (!state.suspended) return [state, []];
169
263
  const resumed = _objectSpread2(_objectSpread2({}, state), {}, { suspended: false });
170
264
  if (state.target === null || ((_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.isLive) !== true) return [resumed, []];
171
- const effects = [{
172
- kind: "fetch",
173
- token: refreshToken(state.target.renditionId),
174
- url: state.target.url
175
- }];
176
- for (const companion of state.companions) effects.push({
177
- kind: "fetch",
178
- token: refreshToken(companion.renditionId),
179
- url: companion.url
180
- });
265
+ const effects = [reload(state.target)];
266
+ for (const companion of state.companions) effects.push(reload(companion));
181
267
  return [_objectSpread2(_objectSpread2({}, resumed), {}, {
182
268
  inflight: state.target.renditionId,
183
269
  awaitingTarget: true
184
270
  }), effects];
185
271
  }
186
- if (msg.type === "MANIFEST_LOADED") {
187
- var _rendition$playlistUr, _rendition$id;
188
- if (!msg.presentation.isLive) return [_objectSpread2(_objectSpread2({}, state), {}, {
272
+ if ((msg.type === "MANIFEST_LOADED" || msg.type === "PLAYLIST_REFRESHED") && kernel.presentation !== null) {
273
+ var _rendition$playlistUr;
274
+ const presentation = kernel.presentation;
275
+ if (!presentation.isLive) return [_objectSpread2(_objectSpread2({}, state), {}, {
189
276
  target: null,
190
277
  companions: [],
191
278
  inflight: null
192
279
  }), []];
193
- const rendition = windowRendition(msg.presentation, kernel);
280
+ const rendition = windowRendition(presentation, kernel, state.abandoned);
194
281
  const effects = [];
195
282
  const url = (_rendition$playlistUr = rendition === null || rendition === void 0 ? void 0 : rendition.playlistUrl) !== null && _rendition$playlistUr !== void 0 ? _rendition$playlistUr : state.manifestUrl;
196
283
  const target = url !== null && rendition !== null ? {
@@ -198,28 +285,24 @@ const reduceHlsLive = (slice, msg, kernel) => {
198
285
  renditionId: rendition.id,
199
286
  ladder: false
200
287
  } : state.target;
201
- const companions = companionTargets(msg.presentation, kernel, (_rendition$id = rendition === null || rendition === void 0 ? void 0 : rendition.id) !== null && _rendition$id !== void 0 ? _rendition$id : null);
288
+ const companions = companionTargets(kernel, rendition, state.abandoned);
202
289
  const switched = state.target !== null && target !== null && target.renditionId !== state.target.renditionId;
203
290
  let awaitingTarget = state.awaitingTarget;
204
291
  let inflight = state.inflight;
205
292
  if (switched && target !== null) {
206
293
  if (inflight !== target.renditionId) {
207
- effects.push({
208
- kind: "fetch",
209
- token: refreshToken(target.renditionId),
210
- url: target.url
211
- });
294
+ effects.push(reload(target));
212
295
  inflight = target.renditionId;
213
296
  }
214
297
  awaitingTarget = true;
215
298
  } else if (!awaitingTarget && rendition !== null) {
216
- const window = windowFact(msg.presentation, rendition, kernel);
299
+ const window = windowFact(presentation, rendition, kernel);
217
300
  if (window !== null) effects.push(window);
218
301
  }
219
302
  let tickPending = state.tickPending;
220
303
  if (!tickPending && inflight === null && target !== null) {
221
- var _msg$presentation$liv, _msg$presentation$liv2;
222
- effects.push(tick((_msg$presentation$liv = (_msg$presentation$liv2 = msg.presentation.live) === null || _msg$presentation$liv2 === void 0 ? void 0 : _msg$presentation$liv2.updatePeriod) !== null && _msg$presentation$liv !== void 0 ? _msg$presentation$liv : 4));
304
+ var _presentation$live$up2, _presentation$live3;
305
+ effects.push(tick((_presentation$live$up2 = (_presentation$live3 = presentation.live) === null || _presentation$live3 === void 0 ? void 0 : _presentation$live3.updatePeriod) !== null && _presentation$live$up2 !== void 0 ? _presentation$live$up2 : 4));
223
306
  tickPending = true;
224
307
  }
225
308
  return [_objectSpread2(_objectSpread2({}, state), {}, {
@@ -236,25 +319,34 @@ const reduceHlsLive = (slice, msg, kernel) => {
236
319
  tickPending: false,
237
320
  inflight: null
238
321
  }), []];
322
+ let target = state.target;
323
+ let awaitingTarget = state.awaitingTarget;
324
+ if (state.abandoned.includes(target.renditionId)) {
325
+ const rendition = windowRendition(kernel.presentation, kernel, state.abandoned);
326
+ target = (rendition === null || rendition === void 0 ? void 0 : rendition.playlistUrl) !== void 0 ? {
327
+ url: rendition.playlistUrl,
328
+ renditionId: rendition.id,
329
+ ladder: false
330
+ } : null;
331
+ if (target === null) return [_objectSpread2(_objectSpread2({}, state), {}, {
332
+ tickPending: false,
333
+ inflight: null
334
+ }), []];
335
+ awaitingTarget = true;
336
+ }
239
337
  const effects = [];
240
338
  let inflight = state.inflight;
241
- if (inflight !== state.target.renditionId) {
242
- effects.push({
243
- kind: "fetch",
244
- token: refreshToken(state.target.renditionId),
245
- url: state.target.url
246
- });
247
- inflight = state.target.renditionId;
339
+ if (inflight !== target.renditionId) {
340
+ effects.push(reload(target));
341
+ inflight = target.renditionId;
248
342
  }
249
343
  for (const companion of state.companions) {
250
344
  if (companion.ladder && state.round % LADDER_EVERY !== 0) continue;
251
- effects.push({
252
- kind: "fetch",
253
- token: refreshToken(companion.renditionId),
254
- url: companion.url
255
- });
345
+ effects.push(reload(companion));
256
346
  }
257
347
  return [_objectSpread2(_objectSpread2({}, state), {}, {
348
+ target,
349
+ awaitingTarget,
258
350
  round: state.round + 1,
259
351
  tickPending: false,
260
352
  inflight
@@ -263,15 +355,10 @@ const reduceHlsLive = (slice, msg, kernel) => {
263
355
  if (msg.type === "SEGMENT_FAILED") {
264
356
  const renditionId = renditionOfToken(msg.trackId);
265
357
  if (renditionId === null) return [state, []];
266
- if (state.target === null || renditionId !== state.target.renditionId) return [state, []];
267
- if (state.tickPending) return [_objectSpread2(_objectSpread2({}, state), {}, { inflight: null }), []];
268
- return [_objectSpread2(_objectSpread2({}, state), {}, {
269
- inflight: null,
270
- tickPending: true
271
- }), [tick(2)]];
358
+ return reloadFailed(state, kernel, renditionId, msg.error);
272
359
  }
273
360
  if (msg.type === "SEGMENT_LOADED") {
274
- var _lastSegment$seq;
361
+ var _findRendition3, _lastSegment$seq;
275
362
  const renditionId = renditionOfToken(msg.trackId);
276
363
  if (renditionId === null || kernel.presentation === null) return [state, []];
277
364
  const isTarget = state.target !== null && renditionId === state.target.renditionId;
@@ -279,26 +366,16 @@ const reduceHlsLive = (slice, msg, kernel) => {
279
366
  if (url === null) return [state, []];
280
367
  const text = new TextDecoder().decode(msg.bytes);
281
368
  const media = parseMediaPlaylist(text, url);
282
- if (media.playlist === null) {
283
- if (!isTarget) return [state, []];
284
- if (state.tickPending) return [_objectSpread2(_objectSpread2({}, state), {}, { inflight: null }), []];
285
- return [_objectSpread2(_objectSpread2({}, state), {}, {
286
- inflight: null,
287
- tickPending: true
288
- }), [tick(2)]];
369
+ if (media.playlist === null) return reloadFailed(state, kernel, renditionId, media.error);
370
+ const failures = _objectSpread2({}, state.failures);
371
+ delete failures[renditionId];
372
+ const sharing = ((_findRendition3 = findRendition(kernel.presentation, renditionId)) === null || _findRendition3 === void 0 ? void 0 : _findRendition3.rendition.playlistUrl) === void 0 ? [renditionId] : renditionIdsAt(kernel.presentation, url);
373
+ const effects = [];
374
+ for (const id of sharing) {
375
+ const refresh = refreshFor(kernel.presentation, id, media.playlist);
376
+ if (refresh !== null) effects.push(feed(refresh));
289
377
  }
290
- const refreshed = mergePlaylist(kernel.presentation, renditionId, media.playlist);
291
- const effects = [feed({
292
- type: "PLAYLIST_REFRESHED",
293
- trackId: renditionId,
294
- renditionId,
295
- mediaSequence: media.playlist.mediaSequence,
296
- segments: media.playlist.segments
297
- }), feed({
298
- type: "MANIFEST_LOADED",
299
- presentation: refreshed
300
- })];
301
- if (!isTarget) return [state, effects];
378
+ if (!isTarget) return [_objectSpread2(_objectSpread2({}, state), {}, { failures }), effects];
302
379
  const lastSegment = media.playlist.segments[media.playlist.segments.length - 1];
303
380
  const endSeq = (_lastSegment$seq = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.seq) !== null && _lastSegment$seq !== void 0 ? _lastSegment$seq : -1;
304
381
  const changed = endSeq !== state.lastEndSeq;
@@ -309,6 +386,7 @@ const reduceHlsLive = (slice, msg, kernel) => {
309
386
  tickPending = true;
310
387
  }
311
388
  return [_objectSpread2(_objectSpread2({}, state), {}, {
389
+ failures,
312
390
  lastEndSeq: endSeq,
313
391
  tickPending,
314
392
  inflight: null,
@@ -1,4 +1,6 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled } from "../../kernel/effects.js";
3
+ import { findRendition, isTrick } from "../../kernel/presentation.js";
2
4
  import { canSwitchTo } from "../../kernel/rendition-select.js";
3
5
  //#region src/stages/abr/index.ts
4
6
  /**
@@ -55,17 +57,12 @@ function choose(allowed, telemetry, options) {
55
57
  const INITIAL = { emergencyCap: null };
56
58
  /** Loops a command back into the bus through a zero-delay schedule effect. */
57
59
  function feed(message) {
58
- return {
59
- kind: "schedule",
60
- token: "abr:emergency",
61
- delayMs: 0,
62
- then: message
63
- };
60
+ return scheduled("abr:emergency", message);
64
61
  }
65
62
  function activeBitrate(kernel) {
66
- if (kernel.presentation === null || kernel.quality.active === null) return null;
67
- for (const period of kernel.presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === kernel.quality.active) return rendition.bitrate;
68
- return null;
63
+ var _findRendition$rendit, _findRendition;
64
+ const active = kernel.quality.active;
65
+ return active === null ? null : (_findRendition$rendit = (_findRendition = findRendition(kernel.presentation, active)) === null || _findRendition === void 0 ? void 0 : _findRendition.rendition.bitrate) !== null && _findRendition$rendit !== void 0 ? _findRendition$rendit : null;
69
66
  }
70
67
  /** The track ABR steers: video where there is one, else audio. */
71
68
  function leadTrack(kernel) {
@@ -76,7 +73,7 @@ function lowestBitrate(kernel) {
76
73
  var _kernel$presentation$, _kernel$presentation;
77
74
  let lowest = Number.POSITIVE_INFINITY;
78
75
  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) {
79
- if (track.contentType !== "video") continue;
76
+ if (track.contentType !== "video" || isTrick(track)) continue;
80
77
  for (const rendition of track.renditions) lowest = Math.min(lowest, rendition.bitrate);
81
78
  }
82
79
  return Number.isFinite(lowest) ? lowest : 0;
@@ -1,5 +1,17 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled } from "../../kernel/effects.js";
2
3
  //#region src/stages/abr-persist/index.ts
4
+ /**
5
+ * Bandwidth memory across sessions, for the startup rendition choice.
6
+ * Storage is injected, never assumed: TV environments and privacy modes
7
+ * break localStorage, so the consumer supplies the get/set pair and this
8
+ * stage stays storage-agnostic.
9
+ *
10
+ * Seeding rides the message loop: a remembered figure loops back as a
11
+ * THROUGHPUT_SAMPLE fact on LOAD, priming both EWMAs before the first real
12
+ * byte. Persisting crosses the pure boundary the only allowed way: the
13
+ * slice emits an event effect and the install-time listener writes.
14
+ */
3
15
  const INITIAL = {
4
16
  seeded: false,
5
17
  lastSaved: 0
@@ -16,16 +28,11 @@ function abrPersist(storage) {
16
28
  const reduce = (slice, msg, kernel) => {
17
29
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
18
30
  if (msg.type === "LOAD" && !state.seeded && remembered !== null && remembered > 0) {
19
- const effects = [{
20
- kind: "schedule",
21
- token: "abr-persist:seed",
22
- delayMs: 0,
23
- then: {
24
- type: "THROUGHPUT_SAMPLE",
25
- bps: remembered,
26
- trackId: "abr-persist"
27
- }
28
- }];
31
+ const effects = [scheduled("abr-persist:seed", {
32
+ type: "THROUGHPUT_SAMPLE",
33
+ bps: remembered,
34
+ trackId: "abr-persist"
35
+ })];
29
36
  return [_objectSpread2(_objectSpread2({}, state), {}, {
30
37
  seeded: true,
31
38
  lastSaved: remembered
@@ -1,5 +1,15 @@
1
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
1
+ import { findRendition } from "../../kernel/presentation.js";
2
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
2
3
  //#region src/stages/aes-128/index.ts
4
+ /**
5
+ * aes-128 as a stage: full-segment AES-CBC decryption for HLS EXT-X-KEY
6
+ * METHOD=AES-128 (RFC 8216 §4.3.2.4). One transform step, ordered ahead of
7
+ * every container step, so the transmux and the probe only ever see clear
8
+ * bytes. Keys are fetched through the transport's request path and cached
9
+ * by URL; the IV is the playlist's or, absent one, the media sequence
10
+ * number. SAMPLE-AES is not this: it decrypts inside the elementary stream
11
+ * and stays deferred.
12
+ */
3
13
  /** Before the transmux (100) and the codec probe (5), which must read clear bytes. */
4
14
  const DECRYPT_ORDER = 1;
5
15
  /** The 16-byte IV: the explicit hex one, or the sequence number big-endian. */
@@ -16,13 +26,10 @@ function ivFor(key, seq) {
16
26
  return iv;
17
27
  }
18
28
  function findSegment(state, renditionId, seq) {
19
- if (state.presentation === null || renditionId === "") return null;
20
- for (const period of state.presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) {
21
- var _rendition$segments$f;
22
- if (rendition.id !== renditionId || !Array.isArray(rendition.segments)) continue;
23
- return (_rendition$segments$f = rendition.segments.find((segment) => segment.seq === seq)) !== null && _rendition$segments$f !== void 0 ? _rendition$segments$f : null;
24
- }
25
- return null;
29
+ var _findRendition, _find;
30
+ const segments = (_findRendition = findRendition(state.presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.rendition.segments;
31
+ if (!Array.isArray(segments)) return null;
32
+ return (_find = segments.find((segment) => segment.seq === seq)) !== null && _find !== void 0 ? _find : null;
26
33
  }
27
34
  function aes128() {
28
35
  return {
@@ -1,4 +1,22 @@
1
+ import { scheduled } from "../../kernel/effects.js";
2
+ import { groupOf } from "../../kernel/rendition-select.js";
1
3
  //#region src/stages/alt-audio/index.ts
4
+ /**
5
+ * Alternate audio: a second media pipeline on sb:audio. The kernel already
6
+ * schedules audio tracks generically, so this stage owns selection and
7
+ * sync, not scheduling. Its core job is entanglement #2's other half:
8
+ * switching the video rendition can change the required audio group, and
9
+ * the audio track must follow, as one arbitration outcome.
10
+ *
11
+ * The coupling table carries the group each video rendition requires. This
12
+ * slice watches the active video rendition; when its coupling names an
13
+ * audio group the current audio track is not in, it selects a track in
14
+ * that group — preferring the current language so a group switch does not
15
+ * silently change languages.
16
+ *
17
+ * A user language choice is remembered and re-applied on top of every
18
+ * group switch, so `alt-audio` never fights `engine.tracks.select`.
19
+ */
2
20
  const INITIAL = { preferredLang: null };
3
21
  /** Audio tracks with their group parsed from the `group:name` id convention. */
4
22
  function audioTracks(kernel) {
@@ -7,10 +25,9 @@ function audioTracks(kernel) {
7
25
  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) {
8
26
  var _track$lang;
9
27
  if (track.contentType !== "audio") continue;
10
- const colon = track.id.indexOf(":");
11
28
  out.push({
12
29
  id: track.id,
13
- group: colon === -1 ? track.id : track.id.slice(0, colon),
30
+ group: groupOf(track.id),
14
31
  lang: (_track$lang = track.lang) !== null && _track$lang !== void 0 ? _track$lang : null,
15
32
  isDefault: track.role === "main"
16
33
  });
@@ -34,16 +51,11 @@ function pickInGroup(tracks, group, preferredLang) {
34
51
  }
35
52
  /** Loops a command back into the bus through a zero-delay schedule effect. */
36
53
  function select(trackId) {
37
- return {
38
- kind: "schedule",
39
- token: "alt-audio:select",
40
- delayMs: 0,
41
- then: {
42
- type: "SELECT_TRACK",
43
- trackId,
44
- apply: "soon"
45
- }
46
- };
54
+ return scheduled("alt-audio:select", {
55
+ type: "SELECT_TRACK",
56
+ trackId,
57
+ apply: "soon"
58
+ });
47
59
  }
48
60
  const reduceAltAudio = (slice, msg, kernel) => {
49
61
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
@@ -53,7 +65,7 @@ const reduceAltAudio = (slice, msg, kernel) => {
53
65
  if ((chosen === null || chosen === void 0 ? void 0 : chosen.lang) != null) return [{ preferredLang: chosen.lang }, []];
54
66
  return [state, []];
55
67
  }
56
- if (msg.type === "MANIFEST_LOADED" || msg.type === "SEGMENT_LOADED") {
68
+ if (msg.type === "MANIFEST_LOADED" || msg.type === "PLAYLIST_REFRESHED" || msg.type === "SEGMENT_LOADED") {
57
69
  const group = requiredGroup(kernel);
58
70
  if (group === null) return [state, []];
59
71
  const active = kernel.tracks.active.get("audio");