mattebox 0.9.0 → 0.11.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 (369) hide show
  1. package/README.md +1 -1
  2. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  3. package/dist/cdn/mattebox.dash.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  6. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  7. package/dist/cdn/mattebox.dual.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  10. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  11. package/dist/cdn/mattebox.hls.min.js +3 -3
  12. package/dist/cdn/mattebox.kernel.min.js +1 -1
  13. package/dist/cdn/mattebox.min.js +6 -2
  14. package/dist/containers/captions.d.ts +6 -5
  15. package/dist/containers/captions.d.ts.map +1 -1
  16. package/dist/containers/captions.js +9 -9
  17. package/dist/containers/captions.js.map +1 -1
  18. package/dist/containers/codec-probe/index.d.ts +15 -0
  19. package/dist/containers/codec-probe/index.d.ts.map +1 -1
  20. package/dist/containers/codec-probe/index.js +72 -5
  21. package/dist/containers/codec-probe/index.js.map +1 -1
  22. package/dist/containers/emsg.d.ts +15 -0
  23. package/dist/containers/emsg.d.ts.map +1 -0
  24. package/dist/containers/emsg.js +91 -0
  25. package/dist/containers/emsg.js.map +1 -0
  26. package/dist/containers/id3.d.ts +12 -0
  27. package/dist/containers/id3.d.ts.map +1 -1
  28. package/dist/containers/id3.js +53 -4
  29. package/dist/containers/id3.js.map +1 -1
  30. package/dist/containers/metadata.d.ts +18 -0
  31. package/dist/containers/metadata.d.ts.map +1 -0
  32. package/dist/containers/metadata.js +20 -0
  33. package/dist/containers/metadata.js.map +1 -0
  34. package/dist/containers/mp4-box/index.d.ts +16 -0
  35. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  36. package/dist/containers/mp4-box/index.js +28 -0
  37. package/dist/containers/mp4-box/index.js.map +1 -1
  38. package/dist/containers/scte35.d.ts +12 -0
  39. package/dist/containers/scte35.d.ts.map +1 -0
  40. package/dist/containers/scte35.js +116 -0
  41. package/dist/containers/scte35.js.map +1 -0
  42. package/dist/containers/ts-transmux/demux.d.ts +2 -2
  43. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  44. package/dist/containers/ts-transmux/demux.js +2 -18
  45. package/dist/containers/ts-transmux/demux.js.map +1 -1
  46. package/dist/containers/ts-transmux/index.d.ts.map +1 -1
  47. package/dist/containers/ts-transmux/index.js +14 -3
  48. package/dist/containers/ts-transmux/index.js.map +1 -1
  49. package/dist/containers/ts-transmux/module.d.ts +8 -0
  50. package/dist/containers/ts-transmux/module.d.ts.map +1 -0
  51. package/dist/containers/ts-transmux/module.js +8 -0
  52. package/dist/containers/ts-transmux/module.js.map +1 -0
  53. package/dist/containers/ts-transmux/runner.d.ts +20 -8
  54. package/dist/containers/ts-transmux/runner.d.ts.map +1 -1
  55. package/dist/containers/ts-transmux/runner.js +19 -22
  56. package/dist/containers/ts-transmux/runner.js.map +1 -1
  57. package/dist/containers/ts-transmux/serve.d.ts +35 -0
  58. package/dist/containers/ts-transmux/serve.d.ts.map +1 -0
  59. package/dist/containers/ts-transmux/serve.js +33 -0
  60. package/dist/containers/ts-transmux/serve.js.map +1 -0
  61. package/dist/containers/ts-transmux/sniff.d.ts +11 -0
  62. package/dist/containers/ts-transmux/sniff.d.ts.map +1 -0
  63. package/dist/containers/ts-transmux/sniff.js +25 -0
  64. package/dist/containers/ts-transmux/sniff.js.map +1 -0
  65. package/dist/containers/ts-transmux/source.d.ts +10 -0
  66. package/dist/containers/ts-transmux/source.d.ts.map +1 -0
  67. package/dist/containers/ts-transmux/source.js +5 -0
  68. package/dist/containers/ts-transmux/source.js.map +1 -0
  69. package/dist/containers/ts-transmux/transmux.d.ts +19 -1
  70. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  71. package/dist/containers/ts-transmux/transmux.js +46 -7
  72. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  73. package/dist/containers/ts-transmux/transmux.worker.js +7 -28
  74. package/dist/containers/ts-transmux/transmux.worker.js.map +1 -1
  75. package/dist/containers/webvtt.d.ts +2 -0
  76. package/dist/containers/webvtt.d.ts.map +1 -1
  77. package/dist/containers/webvtt.js +4 -0
  78. package/dist/containers/webvtt.js.map +1 -1
  79. package/dist/containers/wvtt.d.ts +12 -0
  80. package/dist/containers/wvtt.d.ts.map +1 -0
  81. package/dist/containers/wvtt.js +46 -0
  82. package/dist/containers/wvtt.js.map +1 -0
  83. package/dist/eme/index.d.ts +34 -0
  84. package/dist/eme/index.d.ts.map +1 -0
  85. package/dist/eme/index.js +75 -0
  86. package/dist/eme/index.js.map +1 -0
  87. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  88. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  89. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  90. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutProperties.js +1 -1
  91. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  92. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  93. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  94. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  95. package/dist/es2015/containers/captions.js +8 -8
  96. package/dist/es2015/containers/codec-probe/index.js +105 -6
  97. package/dist/es2015/containers/emsg.js +81 -0
  98. package/dist/es2015/containers/id3.js +54 -4
  99. package/dist/es2015/containers/metadata.js +20 -0
  100. package/dist/es2015/containers/mp4-box/index.js +27 -1
  101. package/dist/es2015/containers/scte35.js +114 -0
  102. package/dist/es2015/containers/ts-transmux/demux.js +12 -24
  103. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  104. package/dist/es2015/containers/ts-transmux/index.js +12 -4
  105. package/dist/es2015/containers/ts-transmux/runner.js +34 -27
  106. package/dist/es2015/containers/ts-transmux/serve.js +36 -0
  107. package/dist/es2015/containers/ts-transmux/sniff.js +13 -0
  108. package/dist/es2015/containers/ts-transmux/source.js +7 -0
  109. package/dist/es2015/containers/ts-transmux/transmux.js +42 -8
  110. package/dist/es2015/containers/ts-transmux/transmux.worker.js +7 -26
  111. package/dist/es2015/containers/webvtt.js +6 -2
  112. package/dist/es2015/containers/wvtt.js +40 -0
  113. package/dist/es2015/eme/index.js +79 -0
  114. package/dist/es2015/index.js +40 -14
  115. package/dist/es2015/kernel/append-queue.js +1 -1
  116. package/dist/es2015/kernel/base64.js +14 -3
  117. package/dist/es2015/kernel/bus.js +11 -8
  118. package/dist/es2015/kernel/context.js +5 -0
  119. package/dist/es2015/kernel/lifecycle.js +1 -0
  120. package/dist/es2015/kernel/loader.js +2 -2
  121. package/dist/es2015/kernel/mime.js +12 -1
  122. package/dist/es2015/kernel/mse.js +39 -5
  123. package/dist/es2015/kernel/prepare.js +2 -2
  124. package/dist/es2015/kernel/reducer.js +118 -26
  125. package/dist/es2015/kernel/refresh.js +2 -2
  126. package/dist/es2015/kernel/rendition-select.js +2 -1
  127. package/dist/es2015/kernel/scheduler.js +1 -1
  128. package/dist/es2015/kernel/sinks/caption-tracks.js +82 -0
  129. package/dist/es2015/kernel/sinks/native-sync.js +46 -0
  130. package/dist/es2015/kernel/sinks/text-formats.js +64 -0
  131. package/dist/es2015/kernel/sinks/text-track-sink.js +15 -4
  132. package/dist/es2015/kernel/timeline.js +12 -8
  133. package/dist/es2015/kernel/trace.js +1 -1
  134. package/dist/es2015/kernel/track-registry.js +21 -1
  135. package/dist/es2015/kernel/transport.js +34 -7
  136. package/dist/es2015/presets/define.js +2 -2
  137. package/dist/es2015/presets/full/index.js +22 -2
  138. package/dist/es2015/protocols/dash-cmaf/index.js +61 -14
  139. package/dist/es2015/protocols/dash-cmaf/parse.js +389 -106
  140. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +134 -0
  141. package/dist/es2015/protocols/dash-cmaf/periods.js +178 -0
  142. package/dist/es2015/protocols/dash-live/index.js +1 -1
  143. package/dist/es2015/protocols/hls-cmaf/index.js +41 -17
  144. package/dist/es2015/protocols/hls-cmaf/lexer.js +2 -1
  145. package/dist/es2015/protocols/hls-cmaf/parse.js +132 -22
  146. package/dist/es2015/protocols/hls-cmaf/unavailable.js +37 -6
  147. package/dist/es2015/protocols/hls-live/index.js +36 -10
  148. package/dist/es2015/stages/abr/index.js +10 -5
  149. package/dist/es2015/stages/abr-persist/index.js +1 -1
  150. package/dist/es2015/stages/aes-128/index.js +1 -1
  151. package/dist/es2015/stages/alt-audio/index.js +31 -11
  152. package/dist/es2015/stages/chapters/index.js +2 -2
  153. package/dist/es2015/stages/chapters/parse.js +2 -2
  154. package/dist/es2015/stages/cmcd/index.js +30 -3
  155. package/dist/es2015/stages/cmsd/index.js +72 -0
  156. package/dist/es2015/stages/codec-probe/index.js +28 -3
  157. package/dist/es2015/stages/content-steering/index.js +1 -1
  158. package/dist/es2015/stages/eme-core/index.js +22 -2
  159. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  160. package/dist/es2015/stages/hdr/index.js +214 -0
  161. package/dist/es2015/stages/meta-id3/index.js +6 -1
  162. package/dist/es2015/stages/qoe/index.js +111 -0
  163. package/dist/es2015/stages/recovery/index.js +1 -1
  164. package/dist/es2015/stages/rendition-names/index.js +101 -0
  165. package/dist/es2015/stages/text-cea608/decode.js +56 -5
  166. package/dist/es2015/stages/text-cea608/index.js +29 -27
  167. package/dist/es2015/stages/text-cea708/decode.js +377 -0
  168. package/dist/es2015/stages/text-cea708/index.js +98 -0
  169. package/dist/es2015/stages/text-ttml/index.js +88 -0
  170. package/dist/es2015/stages/text-ttml/parse.js +255 -0
  171. package/dist/es2015/stages/text-webvtt/index.js +31 -62
  172. package/dist/es2015/stages/thumbnails/index.js +1 -1
  173. package/dist/es2015/stages/timed-metadata/index.js +331 -0
  174. package/dist/es2015/stages/trick-play/index.js +3 -2
  175. package/dist/index.d.ts +1 -1
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +41 -11
  178. package/dist/index.js.map +1 -1
  179. package/dist/kernel/base64.d.ts +7 -2
  180. package/dist/kernel/base64.d.ts.map +1 -1
  181. package/dist/kernel/base64.js +14 -2
  182. package/dist/kernel/base64.js.map +1 -1
  183. package/dist/kernel/bus.d.ts.map +1 -1
  184. package/dist/kernel/bus.js +12 -9
  185. package/dist/kernel/bus.js.map +1 -1
  186. package/dist/kernel/context.d.ts +3 -1
  187. package/dist/kernel/context.d.ts.map +1 -1
  188. package/dist/kernel/context.js +5 -0
  189. package/dist/kernel/context.js.map +1 -1
  190. package/dist/kernel/lifecycle.d.ts +3 -1
  191. package/dist/kernel/lifecycle.d.ts.map +1 -1
  192. package/dist/kernel/lifecycle.js +1 -0
  193. package/dist/kernel/lifecycle.js.map +1 -1
  194. package/dist/kernel/loader.d.ts.map +1 -1
  195. package/dist/kernel/loader.js +3 -2
  196. package/dist/kernel/loader.js.map +1 -1
  197. package/dist/kernel/mime.d.ts +7 -0
  198. package/dist/kernel/mime.d.ts.map +1 -1
  199. package/dist/kernel/mime.js +12 -0
  200. package/dist/kernel/mime.js.map +1 -1
  201. package/dist/kernel/mse.d.ts.map +1 -1
  202. package/dist/kernel/mse.js +37 -2
  203. package/dist/kernel/mse.js.map +1 -1
  204. package/dist/kernel/reducer.d.ts +3 -0
  205. package/dist/kernel/reducer.d.ts.map +1 -1
  206. package/dist/kernel/reducer.js +117 -12
  207. package/dist/kernel/reducer.js.map +1 -1
  208. package/dist/kernel/refresh.d.ts.map +1 -1
  209. package/dist/kernel/refresh.js +1 -0
  210. package/dist/kernel/refresh.js.map +1 -1
  211. package/dist/kernel/rendition-select.d.ts.map +1 -1
  212. package/dist/kernel/rendition-select.js +4 -2
  213. package/dist/kernel/rendition-select.js.map +1 -1
  214. package/dist/kernel/sinks/caption-tracks.d.ts +11 -0
  215. package/dist/kernel/sinks/caption-tracks.d.ts.map +1 -0
  216. package/dist/kernel/sinks/caption-tracks.js +87 -0
  217. package/dist/kernel/sinks/caption-tracks.js.map +1 -0
  218. package/dist/kernel/sinks/native-sync.d.ts +24 -0
  219. package/dist/kernel/sinks/native-sync.d.ts.map +1 -0
  220. package/dist/kernel/sinks/native-sync.js +42 -0
  221. package/dist/kernel/sinks/native-sync.js.map +1 -0
  222. package/dist/kernel/sinks/text-formats.d.ts +25 -0
  223. package/dist/kernel/sinks/text-formats.d.ts.map +1 -0
  224. package/dist/kernel/sinks/text-formats.js +69 -0
  225. package/dist/kernel/sinks/text-formats.js.map +1 -0
  226. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  227. package/dist/kernel/sinks/text-track-sink.js +22 -4
  228. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  229. package/dist/kernel/timeline.d.ts +10 -6
  230. package/dist/kernel/timeline.d.ts.map +1 -1
  231. package/dist/kernel/timeline.js +14 -6
  232. package/dist/kernel/timeline.js.map +1 -1
  233. package/dist/kernel/track-registry.d.ts +8 -8
  234. package/dist/kernel/track-registry.d.ts.map +1 -1
  235. package/dist/kernel/track-registry.js +29 -4
  236. package/dist/kernel/track-registry.js.map +1 -1
  237. package/dist/kernel/transport.d.ts +8 -0
  238. package/dist/kernel/transport.d.ts.map +1 -1
  239. package/dist/kernel/transport.js +28 -1
  240. package/dist/kernel/transport.js.map +1 -1
  241. package/dist/presets/full/index.d.ts.map +1 -1
  242. package/dist/presets/full/index.js +21 -1
  243. package/dist/presets/full/index.js.map +1 -1
  244. package/dist/protocols/adapter-shared.d.ts +8 -0
  245. package/dist/protocols/adapter-shared.d.ts.map +1 -1
  246. package/dist/protocols/adapter-shared.js +6 -0
  247. package/dist/protocols/adapter-shared.js.map +1 -1
  248. package/dist/protocols/dash-cmaf/index.d.ts +9 -1
  249. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  250. package/dist/protocols/dash-cmaf/index.js +78 -14
  251. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  252. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  253. package/dist/protocols/dash-cmaf/parse.js +419 -90
  254. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  255. package/dist/protocols/dash-cmaf/periods-runtime.d.ts +6 -0
  256. package/dist/protocols/dash-cmaf/periods-runtime.d.ts.map +1 -0
  257. package/dist/protocols/dash-cmaf/periods-runtime.js +121 -0
  258. package/dist/protocols/dash-cmaf/periods-runtime.js.map +1 -0
  259. package/dist/protocols/dash-cmaf/periods.d.ts +24 -0
  260. package/dist/protocols/dash-cmaf/periods.d.ts.map +1 -0
  261. package/dist/protocols/dash-cmaf/periods.js +210 -0
  262. package/dist/protocols/dash-cmaf/periods.js.map +1 -0
  263. package/dist/protocols/hls-cmaf/index.d.ts +9 -1
  264. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  265. package/dist/protocols/hls-cmaf/index.js +49 -20
  266. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  267. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  268. package/dist/protocols/hls-cmaf/lexer.js +1 -0
  269. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  270. package/dist/protocols/hls-cmaf/parse.d.ts +3 -1
  271. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  272. package/dist/protocols/hls-cmaf/parse.js +169 -10
  273. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  274. package/dist/protocols/hls-cmaf/unavailable.d.ts +9 -1
  275. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
  276. package/dist/protocols/hls-cmaf/unavailable.js +29 -3
  277. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
  278. package/dist/protocols/hls-live/index.d.ts +9 -1
  279. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  280. package/dist/protocols/hls-live/index.js +36 -7
  281. package/dist/protocols/hls-live/index.js.map +1 -1
  282. package/dist/stages/abr/index.d.ts.map +1 -1
  283. package/dist/stages/abr/index.js +10 -6
  284. package/dist/stages/abr/index.js.map +1 -1
  285. package/dist/stages/alt-audio/index.d.ts +5 -2
  286. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  287. package/dist/stages/alt-audio/index.js +31 -11
  288. package/dist/stages/alt-audio/index.js.map +1 -1
  289. package/dist/stages/cmcd/index.d.ts.map +1 -1
  290. package/dist/stages/cmcd/index.js +39 -3
  291. package/dist/stages/cmcd/index.js.map +1 -1
  292. package/dist/stages/cmsd/index.d.ts +22 -0
  293. package/dist/stages/cmsd/index.d.ts.map +1 -0
  294. package/dist/stages/cmsd/index.js +65 -0
  295. package/dist/stages/cmsd/index.js.map +1 -0
  296. package/dist/stages/codec-probe/index.d.ts.map +1 -1
  297. package/dist/stages/codec-probe/index.js +30 -3
  298. package/dist/stages/codec-probe/index.js.map +1 -1
  299. package/dist/stages/eme-core/index.d.ts +7 -0
  300. package/dist/stages/eme-core/index.d.ts.map +1 -1
  301. package/dist/stages/eme-core/index.js +26 -0
  302. package/dist/stages/eme-core/index.js.map +1 -1
  303. package/dist/stages/hdr/index.d.ts +22 -0
  304. package/dist/stages/hdr/index.d.ts.map +1 -0
  305. package/dist/stages/hdr/index.js +191 -0
  306. package/dist/stages/hdr/index.js.map +1 -0
  307. package/dist/stages/meta-id3/index.d.ts.map +1 -1
  308. package/dist/stages/meta-id3/index.js +6 -2
  309. package/dist/stages/meta-id3/index.js.map +1 -1
  310. package/dist/stages/qoe/index.d.ts +32 -0
  311. package/dist/stages/qoe/index.d.ts.map +1 -0
  312. package/dist/stages/qoe/index.js +116 -0
  313. package/dist/stages/qoe/index.js.map +1 -0
  314. package/dist/stages/rendition-names/index.d.ts +41 -0
  315. package/dist/stages/rendition-names/index.d.ts.map +1 -0
  316. package/dist/stages/rendition-names/index.js +101 -0
  317. package/dist/stages/rendition-names/index.js.map +1 -0
  318. package/dist/stages/text-cea608/decode.d.ts +23 -2
  319. package/dist/stages/text-cea608/decode.d.ts.map +1 -1
  320. package/dist/stages/text-cea608/decode.js +55 -5
  321. package/dist/stages/text-cea608/decode.js.map +1 -1
  322. package/dist/stages/text-cea608/index.d.ts +10 -3
  323. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  324. package/dist/stages/text-cea608/index.js +34 -34
  325. package/dist/stages/text-cea608/index.js.map +1 -1
  326. package/dist/stages/text-cea708/decode.d.ts +79 -0
  327. package/dist/stages/text-cea708/decode.d.ts.map +1 -0
  328. package/dist/stages/text-cea708/decode.js +404 -0
  329. package/dist/stages/text-cea708/decode.js.map +1 -0
  330. package/dist/stages/text-cea708/index.d.ts +3 -0
  331. package/dist/stages/text-cea708/index.d.ts.map +1 -0
  332. package/dist/stages/text-cea708/index.js +93 -0
  333. package/dist/stages/text-cea708/index.js.map +1 -0
  334. package/dist/stages/text-ttml/index.d.ts +3 -0
  335. package/dist/stages/text-ttml/index.d.ts.map +1 -0
  336. package/dist/stages/text-ttml/index.js +74 -0
  337. package/dist/stages/text-ttml/index.js.map +1 -0
  338. package/dist/stages/text-ttml/parse.d.ts +16 -0
  339. package/dist/stages/text-ttml/parse.d.ts.map +1 -0
  340. package/dist/stages/text-ttml/parse.js +277 -0
  341. package/dist/stages/text-ttml/parse.js.map +1 -0
  342. package/dist/stages/text-webvtt/index.d.ts +6 -10
  343. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  344. package/dist/stages/text-webvtt/index.js +22 -64
  345. package/dist/stages/text-webvtt/index.js.map +1 -1
  346. package/dist/stages/timed-metadata/index.d.ts +15 -0
  347. package/dist/stages/timed-metadata/index.d.ts.map +1 -0
  348. package/dist/stages/timed-metadata/index.js +370 -0
  349. package/dist/stages/timed-metadata/index.js.map +1 -0
  350. package/dist/types/error.d.ts +1 -1
  351. package/dist/types/error.d.ts.map +1 -1
  352. package/dist/types/facade.d.ts +14 -10
  353. package/dist/types/facade.d.ts.map +1 -1
  354. package/dist/types/ir.d.ts +71 -0
  355. package/dist/types/ir.d.ts.map +1 -1
  356. package/dist/types/kernel.d.ts +11 -1
  357. package/dist/types/kernel.d.ts.map +1 -1
  358. package/dist/types/kernel.js.map +1 -1
  359. package/dist/types/messages.d.ts +20 -1
  360. package/dist/types/messages.d.ts.map +1 -1
  361. package/dist/types/metadata.d.ts +59 -0
  362. package/dist/types/metadata.d.ts.map +1 -0
  363. package/dist/types/metadata.js +7 -0
  364. package/dist/types/metadata.js.map +1 -0
  365. package/dist/types/quality.d.ts +3 -0
  366. package/dist/types/quality.d.ts.map +1 -1
  367. package/dist/types/stage.d.ts +17 -0
  368. package/dist/types/stage.d.ts.map +1 -1
  369. package/package.json +10 -2
@@ -1,9 +1,63 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { byteToHex } from "../../kernel/base64.js";
2
3
  import { resolveUrl } from "../../kernel/url.js";
3
4
  import { manifestError } from "../adapter-shared.js";
4
5
  import { dimensions } from "../dimensions.js";
5
6
  import { lex } from "./lexer.js";
6
7
  //#region src/protocols/hls-cmaf/parse.ts
8
+ /**
9
+ * m3u8 into the IR. Pure: no fetching, no state, no side effects. URLs are
10
+ * resolved here, against the playlist's own URL, and stored absolute;
11
+ * downstream code never does URL arithmetic.
12
+ *
13
+ * The HLS variant problem: EXT-X-STREAM-INF describes a bundle of one
14
+ * video rendition plus an audio group plus a subtitle group. The adapter
15
+ * decomposes variants into a video track with renditions, hoists
16
+ * EXT-X-MEDIA entries into their own tracks, and records the bundle in the
17
+ * coupling table as data. Generic descriptors only; the kernel routes.
18
+ */
19
+ /** Epoch seconds from an ISO 8601 date, or null. */
20
+ function epochSeconds(value) {
21
+ if (value === void 0) return null;
22
+ const ms = Date.parse(value);
23
+ return Number.isFinite(ms) ? ms / 1e3 : null;
24
+ }
25
+ /**
26
+ * The date ranges of a playlist (RFC 8216bis §4.4.5.1), merged by ID: a
27
+ * later tag with the same ID adds attributes and never changes one. Each
28
+ * maps to the presentation timeline through the playlist's first
29
+ * EXT-X-PROGRAM-DATE-TIME, which a playlist with date ranges must carry; a
30
+ * playlist without one yields none.
31
+ */
32
+ function dateRangesFrom(tags, anchor) {
33
+ if (anchor === void 0) return [];
34
+ const merged = /* @__PURE__ */ new Map();
35
+ for (const attributes of tags) {
36
+ const id = attributes.ID;
37
+ if (id === void 0) continue;
38
+ const known = merged.get(id);
39
+ merged.set(id, known === void 0 ? _objectSpread2({}, attributes) : _objectSpread2(_objectSpread2({}, attributes), known));
40
+ }
41
+ const toPresentation = (epoch) => anchor.presentationTime + (epoch - anchor.wallClock);
42
+ const out = [];
43
+ for (const [id, attributes] of merged) {
44
+ const startDate = epochSeconds(attributes["START-DATE"]);
45
+ if (startDate === null) continue;
46
+ const start = toPresentation(startDate);
47
+ const endDate = epochSeconds(attributes["END-DATE"]);
48
+ const duration = Number(attributes.DURATION);
49
+ const planned = Number(attributes["PLANNED-DURATION"]);
50
+ const end = endDate !== null ? toPresentation(endDate) : Number.isFinite(duration) ? start + duration : void 0;
51
+ out.push(_objectSpread2(_objectSpread2(_objectSpread2({
52
+ id,
53
+ start
54
+ }, end !== void 0 ? { end } : {}), Number.isFinite(planned) ? { plannedEnd: start + planned } : {}), {}, {
55
+ startDate,
56
+ attributes
57
+ }));
58
+ }
59
+ return out.sort((a, b) => a.start - b.start);
60
+ }
7
61
  /** n@o or n (continuing after the previous range). RFC 8216 §4.3.2.2. */
8
62
  function parseByteRange(value, previousEnd) {
9
63
  const [lengthText, offsetText] = value.split("@");
@@ -43,6 +97,8 @@ function protectionFrom(key, baseUrl) {
43
97
  }] };
44
98
  }
45
99
  const AUDIO_CODECS = /^(mp4a|ac-3|ec-3|opus|flac)/i;
100
+ /** Subtitles in fMP4: IMSC (Apple HLS authoring spec 5.10) and WebVTT. */
101
+ const TEXT_CODECS = /^(stpp|wvtt)/i;
46
102
  /**
47
103
  * A tile grid from LAYOUT="CxR" and a tile RESOLUTION, both from the Roku
48
104
  * image-playlist specification (EXT-X-IMAGE-STREAM-INF, EXT-X-TILES).
@@ -71,21 +127,25 @@ function tileGridFrom(attributes) {
71
127
  function normalizeAvcCodec(codec) {
72
128
  const match = /^(avc1|avc3)\.(\d+)\.(\d+)$/.exec(codec);
73
129
  if (match === null) return codec;
74
- const hex = (n) => (Number(n) & 255).toString(16).padStart(2, "0");
75
- return `${match[1]}.${hex(Number(match[2]))}00${hex(Number(match[3]))}`;
130
+ return `${match[1]}.${byteToHex(Number(match[2]))}00${byteToHex(Number(match[3]))}`;
76
131
  }
77
132
  function splitCodecs(value) {
78
133
  if (value === void 0) return {
79
134
  video: null,
80
- audio: null
135
+ audio: null,
136
+ text: null
81
137
  };
82
138
  let video = null;
83
139
  let audio = null;
140
+ let text = null;
84
141
  for (const codec of value.split(",").map((c) => c.trim())) {
85
142
  if (codec === "") continue;
86
143
  if (AUDIO_CODECS.test(codec)) {
87
144
  var _audio;
88
145
  audio = (_audio = audio) !== null && _audio !== void 0 ? _audio : codec;
146
+ } else if (TEXT_CODECS.test(codec)) {
147
+ var _text;
148
+ text = (_text = text) !== null && _text !== void 0 ? _text : codec;
89
149
  } else {
90
150
  var _video;
91
151
  video = (_video = video) !== null && _video !== void 0 ? _video : normalizeAvcCodec(codec);
@@ -93,7 +153,8 @@ function splitCodecs(value) {
93
153
  }
94
154
  return {
95
155
  video,
96
- audio
156
+ audio,
157
+ text
97
158
  };
98
159
  }
99
160
  /** parse a media playlist body into segments. */
@@ -117,6 +178,8 @@ function parseMediaPlaylist(text, baseUrl) {
117
178
  let pendingDuration = null;
118
179
  let pendingRange = null;
119
180
  let pendingDiscontinuity = false;
181
+ let discontinuitySequence = 0;
182
+ const dateRangeTags = [];
120
183
  let previousRangeEnd = null;
121
184
  let start = 0;
122
185
  let seq = 0;
@@ -147,6 +210,12 @@ function parseMediaPlaylist(text, baseUrl) {
147
210
  case "EXT-X-DISCONTINUITY":
148
211
  pendingDiscontinuity = true;
149
212
  break;
213
+ case "EXT-X-DATERANGE":
214
+ dateRangeTags.push(line.attributes);
215
+ break;
216
+ case "EXT-X-DISCONTINUITY-SEQUENCE":
217
+ discontinuitySequence = Number(line.value) || 0;
218
+ break;
150
219
  case "EXT-X-MAP": {
151
220
  const uri = line.attributes.URI;
152
221
  if (uri !== void 0) {
@@ -180,12 +249,14 @@ function parseMediaPlaylist(text, baseUrl) {
180
249
  presentationTime: start
181
250
  };
182
251
  pendingDate = null;
183
- segments.push(_objectSpread2(_objectSpread2(_objectSpread2({
252
+ if (pendingDiscontinuity) discontinuitySequence += 1;
253
+ const opensEpoch = segments.length === 0 || pendingDiscontinuity;
254
+ segments.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
184
255
  seq,
185
256
  start,
186
257
  duration: pendingDuration,
187
258
  url: resolveUrl(line.uri, baseUrl)
188
- }, pendingRange !== null ? { byteRange: pendingRange } : {}), pendingDiscontinuity ? { discontinuity: true } : {}), pendingKey !== null ? { key: pendingKey } : {}));
259
+ }, pendingRange !== null ? { byteRange: pendingRange } : {}), pendingDiscontinuity ? { discontinuity: true } : {}), opensEpoch ? { discontinuitySequence } : {}), pendingKey !== null ? { key: pendingKey } : {}));
189
260
  previousRangeEnd = pendingRange !== null ? pendingRange.end : previousRangeEnd;
190
261
  start += pendingDuration;
191
262
  seq += 1;
@@ -194,7 +265,7 @@ function parseMediaPlaylist(text, baseUrl) {
194
265
  pendingDiscontinuity = false;
195
266
  }
196
267
  return {
197
- playlist: _objectSpread2(_objectSpread2({
268
+ playlist: _objectSpread2(_objectSpread2(_objectSpread2({
198
269
  segments,
199
270
  init,
200
271
  targetDuration,
@@ -202,7 +273,7 @@ function parseMediaPlaylist(text, baseUrl) {
202
273
  endlist,
203
274
  playlistType,
204
275
  protection
205
- }, dateAnchor !== void 0 ? { dateAnchor } : {}), tiles !== null ? { tiles } : {}),
276
+ }, dateAnchor !== void 0 ? { dateAnchor } : {}), tiles !== null ? { tiles } : {}), dateRangeTags.length > 0 ? { dateRanges: dateRangesFrom(dateRangeTags, dateAnchor) } : {}),
206
277
  error: null
207
278
  };
208
279
  }
@@ -211,6 +282,34 @@ function mediaContentType(type) {
211
282
  if (type === "SUBTITLES") return "text";
212
283
  return null;
213
284
  }
285
+ /** The CHARACTERISTICS tags of a rendition, as written, in order. */
286
+ function characteristicsOf(entry) {
287
+ var _entry$attributes$CHA;
288
+ return ((_entry$attributes$CHA = entry.attributes.CHARACTERISTICS) !== null && _entry$attributes$CHA !== void 0 ? _entry$attributes$CHA : "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== "");
289
+ }
290
+ /**
291
+ * RFC 8216bis §4.4.6.1: a CLOSED-CAPTIONS rendition names an in-band
292
+ * caption channel inside the video: a CEA-608 channel (INSTREAM-ID CC1 to
293
+ * CC4) or a CEA-708 service (SERVICE1 to SERVICE63). It becomes a text
294
+ * track with no segments; a caption stage reads the cues from the video.
295
+ */
296
+ function captionTrack(entry) {
297
+ var _entry$attributes$INS;
298
+ if (entry.type !== "CLOSED-CAPTIONS") return null;
299
+ const instreamId = (_entry$attributes$INS = entry.attributes["INSTREAM-ID"]) !== null && _entry$attributes$INS !== void 0 ? _entry$attributes$INS : "";
300
+ const mimeType = /^CC[1-4]$/.test(instreamId) ? "application/cea-608" : /^SERVICE([1-9]|[1-5]\d|6[0-3])$/.test(instreamId) ? "application/cea-708" : null;
301
+ if (mimeType === null) return null;
302
+ const characteristics = characteristicsOf(entry);
303
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
304
+ id: `${entry.groupId}:${entry.name}`,
305
+ contentType: "text",
306
+ mimeType,
307
+ name: entry.name
308
+ }, entry.attributes.AUTOSELECT === "YES" ? { autoselect: true } : {}), {}, { protection: null }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), {}, { role: "caption" }, characteristics.length > 0 ? { characteristics } : {}), {}, {
309
+ instreamId,
310
+ renditions: []
311
+ });
312
+ }
214
313
  /**
215
314
  * The rendition fields a tag with a URI attribute declares: the Roku
216
315
  * EXT-X-IMAGE-STREAM-INF and the RFC 8216 §4.3.4.3 EXT-X-I-FRAME-STREAM-INF.
@@ -322,13 +421,13 @@ function parse(text, baseUrl) {
322
421
  const audioOnly = media.playlist.segments.every((s) => /\.(aac|mp3|ac3|ec3|m4a)(\?|$)/i.test(s.url));
323
422
  const contentType = audioOnly ? "audio" : "video";
324
423
  const mimeType = audioOnly ? "audio/mp4" : "video/mp4";
325
- const rendition = _objectSpread2({
424
+ const rendition = _objectSpread2(_objectSpread2({
326
425
  id: "r-0",
327
426
  bitrate: 0,
328
427
  codecs: null,
329
428
  mimeType,
330
429
  segments: media.playlist.segments
331
- }, media.playlist.init !== null ? { init: media.playlist.init } : {});
430
+ }, media.playlist.init !== null ? { init: media.playlist.init } : {}), media.playlist.dateRanges !== void 0 ? { dateRanges: media.playlist.dateRanges } : {});
332
431
  return {
333
432
  presentation: _objectSpread2(_objectSpread2(_objectSpread2({
334
433
  id: baseUrl,
@@ -411,17 +510,19 @@ function parse(text, baseUrl) {
411
510
  const hasAudioGroup = variant.attributes.AUDIO !== void 0;
412
511
  const codecs = video !== null && !hasAudioGroup && audio !== null ? `${video}, ${audio}` : video;
413
512
  const frameRate = Number(variant.attributes["FRAME-RATE"]);
513
+ const range = variant.attributes["VIDEO-RANGE"];
514
+ const videoRange = range === "SDR" || range === "PQ" || range === "HLG" ? range : video !== null && /^dv(h1|he|a1|av)/.test(video) ? "PQ" : void 0;
414
515
  const pathway = variant.attributes["PATHWAY-ID"];
415
516
  const id = pathway !== void 0 ? `v-${bandwidth}-${pathway}` : `v-${bandwidth}`;
416
517
  if (renditions.some((r) => r.id === id)) continue;
417
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
518
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
418
519
  id,
419
520
  bitrate: bandwidth,
420
521
  codecs,
421
522
  mimeType: "video/mp4",
422
523
  segments: [],
423
524
  playlistUrl: variant.uri
424
- }, pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}));
525
+ }, pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}), videoRange !== void 0 ? { videoRange } : {}));
425
526
  const requires = {};
426
527
  if (variant.attributes.AUDIO !== void 0) requires.audio = variant.attributes.AUDIO;
427
528
  if (variant.attributes.SUBTITLES !== void 0) requires.text = variant.attributes.SUBTITLES;
@@ -463,21 +564,27 @@ function parse(text, baseUrl) {
463
564
  });
464
565
  }
465
566
  for (const entry of mediaEntries) {
466
- var _variants$find, _entry$attributes$CHA;
567
+ var _variants$find, _variants$find2;
568
+ const caption = captionTrack(entry);
569
+ if (caption !== null) {
570
+ tracks.push(caption);
571
+ continue;
572
+ }
467
573
  const contentType = mediaContentType(entry.type);
468
574
  if (contentType === null || entry.uri === null) continue;
469
575
  const { audio } = splitCodecs((_variants$find = variants.find((v) => v.attributes.AUDIO === entry.groupId)) === null || _variants$find === void 0 ? void 0 : _variants$find.attributes.CODECS);
470
- const mimeType = contentType === "audio" ? "audio/mp4" : "text/vtt";
471
- const characteristics = ((_entry$attributes$CHA = entry.attributes.CHARACTERISTICS) !== null && _entry$attributes$CHA !== void 0 ? _entry$attributes$CHA : "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== "");
472
- tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
576
+ const { text } = splitCodecs((_variants$find2 = variants.find((v) => v.attributes.SUBTITLES === entry.groupId)) === null || _variants$find2 === void 0 ? void 0 : _variants$find2.attributes.CODECS);
577
+ const mimeType = contentType === "audio" ? "audio/mp4" : text !== null ? "application/mp4" : "text/vtt";
578
+ const characteristics = characteristicsOf(entry);
579
+ tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
473
580
  id: `${entry.groupId}:${entry.name}`,
474
581
  contentType,
475
582
  mimeType,
476
- protection: sessionProtection
477
- }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), entry.attributes.DEFAULT === "YES" ? { role: "main" } : { role: "alternate" }), characteristics.length > 0 ? { characteristics } : {}), contentType === "text" && entry.attributes.FORCED === "YES" ? { forced: true } : {}), {}, { renditions: [{
583
+ name: entry.name
584
+ }, entry.attributes.AUTOSELECT === "YES" ? { autoselect: true } : {}), {}, { protection: sessionProtection }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), entry.attributes.DEFAULT === "YES" ? { role: "main" } : { role: "alternate" }), characteristics.length > 0 ? { characteristics } : {}), contentType === "text" && entry.attributes.FORCED === "YES" ? { forced: true } : {}), {}, { renditions: [{
478
585
  id: `${entry.groupId}:${entry.name}`,
479
586
  bitrate: 0,
480
- codecs: contentType === "audio" ? audio : null,
587
+ codecs: contentType === "audio" ? audio : text,
481
588
  mimeType,
482
589
  segments: [],
483
590
  playlistUrl: entry.uri
@@ -551,7 +658,7 @@ function refreshFor(presentation, renditionId, playlist) {
551
658
  if (knownLast !== void 0 && incomingLast !== void 0 && !playlist.endlist && incomingLast.seq < knownLast.seq) return null;
552
659
  const shift = timelineShift(!playlist.endlist && knownLast === void 0 && sibling.length > 0 ? sibling : previous, playlist.segments);
553
660
  const segments = shift === 0 ? playlist.segments : playlist.segments.map((s) => _objectSpread2(_objectSpread2({}, s), {}, { start: s.start + shift }));
554
- return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
661
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
555
662
  type: "PLAYLIST_REFRESHED",
556
663
  trackId: renditionId,
557
664
  renditionId,
@@ -563,7 +670,10 @@ function refreshFor(presentation, renditionId, playlist) {
563
670
  }, playlist.endlist ? {} : { updatePeriod: playlist.targetDuration || 4 }), playlist.dateAnchor !== void 0 ? { dateAnchor: {
564
671
  wallClock: playlist.dateAnchor.wallClock,
565
672
  presentationTime: playlist.dateAnchor.presentationTime + shift
566
- } } : {});
673
+ } } : {}), playlist.dateRanges !== void 0 ? { dateRanges: shift === 0 ? playlist.dateRanges : playlist.dateRanges.map((range) => shiftRange(range, shift)) } : {});
674
+ }
675
+ function shiftRange(range, shift) {
676
+ return _objectSpread2(_objectSpread2(_objectSpread2({}, range), {}, { start: range.start + shift }, range.end !== void 0 ? { end: range.end + shift } : {}), range.plannedEnd !== void 0 ? { plannedEnd: range.plannedEnd + shift } : {});
567
677
  }
568
678
  //#endregion
569
679
  export { normalizeAvcCodec, parse, parseMediaPlaylist, refreshFor };
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { isTrick } from "../../kernel/presentation.js";
3
3
  import { withDeadGroups } from "../../kernel/rendition-select.js";
4
4
  //#region src/protocols/hls-cmaf/unavailable.ts
@@ -14,6 +14,24 @@ const LOAD_FAILED = "hls:unavailable";
14
14
  /** Renditions whose playlist kept failing to reload (hls-live). */
15
15
  const RELOAD_FAILED = "hls-live:unavailable";
16
16
  /**
17
+ * What `source` excludes for the failed renditions in `ids`, together with
18
+ * the other source: `excluded` is everything out, `own` the part `source`
19
+ * writes. A source writes its own failures, and a variant a dead audio group
20
+ * drags along that the other source does not exclude already. Writing the
21
+ * other source's renditions too would keep them out after that source
22
+ * readmits them.
23
+ */
24
+ function exclusion(presentation, kernel, source, ids) {
25
+ var _kernel$quality$const, _kernel$quality$const2;
26
+ const other = source === "hls:unavailable" ? RELOAD_FAILED : LOAD_FAILED;
27
+ const otherIds = new Set((_kernel$quality$const = (_kernel$quality$const2 = kernel.quality.constraints.get(other)) === null || _kernel$quality$const2 === void 0 ? void 0 : _kernel$quality$const2.excludeIds) !== null && _kernel$quality$const !== void 0 ? _kernel$quality$const : []);
28
+ const excluded = withDeadGroups(presentation, /* @__PURE__ */ new Set([...ids, ...otherIds]));
29
+ return {
30
+ excluded,
31
+ own: [...excluded].filter((id) => ids.includes(id) || !otherIds.has(id))
32
+ };
33
+ }
34
+ /**
17
35
  * The messages that stop relying on the renditions in `ids`, the whole list
18
36
  * `source` excludes. A failed audio group takes the variants that require
19
37
  * it, so arbitration moves to a variant on a working group and alt-audio
@@ -22,11 +40,9 @@ const RELOAD_FAILED = "hls-live:unavailable";
22
40
  * has none and no variant names an audio group to move to.
23
41
  */
24
42
  function unavailableMessages(kernel, source, ids, error) {
25
- var _kernel$quality$const, _kernel$quality$const2;
26
43
  const presentation = kernel.presentation;
27
44
  if (presentation === null) return [];
28
- const other = source === "hls:unavailable" ? RELOAD_FAILED : LOAD_FAILED;
29
- const excluded = withDeadGroups(presentation, /* @__PURE__ */ new Set([...ids, ...(_kernel$quality$const = (_kernel$quality$const2 = kernel.quality.constraints.get(other)) === null || _kernel$quality$const2 === void 0 ? void 0 : _kernel$quality$const2.excludeIds) !== null && _kernel$quality$const !== void 0 ? _kernel$quality$const : []]));
45
+ const { excluded, own } = exclusion(presentation, kernel, source, ids);
30
46
  const grouped = presentation.couplings.some((c) => c.requires.audio !== void 0);
31
47
  const activeAudio = kernel.tracks.active.get("audio");
32
48
  if (presentation.periods.some((period) => period.tracks.some((track) => track.renditions.length > 0 && track.renditions.every((r) => excluded.has(r.id)) && (track.contentType === "video" && !isTrick(track) || track.id === activeAudio && !grouped)))) return [{
@@ -36,8 +52,23 @@ function unavailableMessages(kernel, source, ids, error) {
36
52
  return [{
37
53
  type: "CONSTRAIN",
38
54
  source,
39
- constraint: { excludeIds: [...excluded] }
55
+ constraint: { excludeIds: [...own] }
40
56
  }];
41
57
  }
58
+ /**
59
+ * The CONSTRAIN for what `source` still excludes once some of its failures
60
+ * are readmitted: `ids` is the shorter list. Fewer exclusions never stop
61
+ * playback, so there is no failure to report.
62
+ */
63
+ function readmitMessage(kernel, source, ids) {
64
+ const presentation = kernel.presentation;
65
+ if (presentation === null) return null;
66
+ const { own } = exclusion(presentation, kernel, source, ids);
67
+ return {
68
+ type: "CONSTRAIN",
69
+ source,
70
+ constraint: { excludeIds: [...own] }
71
+ };
72
+ }
42
73
  //#endregion
43
- export { LOAD_FAILED, RELOAD_FAILED, unavailableMessages };
74
+ export { LOAD_FAILED, RELOAD_FAILED, readmitMessage, unavailableMessages };
@@ -1,9 +1,9 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { scheduled, tickAfter } from "../../kernel/effects.js";
3
3
  import { findRendition } from "../../kernel/presentation.js";
4
4
  import { activeRenditions } from "../../kernel/rendition-select.js";
5
5
  import { parseMediaPlaylist, refreshFor } from "../hls-cmaf/parse.js";
6
- import { RELOAD_FAILED, unavailableMessages } from "../hls-cmaf/unavailable.js";
6
+ import { RELOAD_FAILED, readmitMessage, unavailableMessages } from "../hls-cmaf/unavailable.js";
7
7
  import { registerLiveNamespace } from "../live-shared.js";
8
8
  //#region src/protocols/hls-live/index.ts
9
9
  /**
@@ -25,6 +25,8 @@ import { registerLiveNamespace } from "../live-shared.js";
25
25
  */
26
26
  const REFRESH_TOKEN = "hls:live:refresh";
27
27
  const TICK_TOKEN = "hls-live:reload";
28
+ /** An abandoned playlist's retry, by one of its renditions: `hls-live:retry:<renditionId>`. */
29
+ const RETRY_TOKEN = "hls-live:retry:";
28
30
  const INITIAL = {
29
31
  manifestUrl: null,
30
32
  target: null,
@@ -194,7 +196,7 @@ function renditionIdsAt(presentation, url) {
194
196
  * variant on another group), and the next tick reloads whatever the window
195
197
  * rendition is then. The load fails only when nothing is left to move to.
196
198
  */
197
- function reloadFailed(state, kernel, renditionId, error) {
199
+ function reloadFailed(state, kernel, renditionId, error, retryMs) {
198
200
  var _state$failures$rendi, _findRendition2;
199
201
  const count = ((_state$failures$rendi = state.failures[renditionId]) !== null && _state$failures$rendi !== void 0 ? _state$failures$rendi : 0) + 1;
200
202
  const failures = _objectSpread2(_objectSpread2({}, state.failures), {}, { [renditionId]: count });
@@ -234,10 +236,31 @@ function reloadFailed(state, kernel, renditionId, error) {
234
236
  });
235
237
  const effects = messages.map(feed);
236
238
  const failed = messages.some((m) => m.type === "MANIFEST_FAILED");
239
+ if (!failed && Number.isFinite(retryMs)) effects.push(tickAfter(`${RETRY_TOKEN}${renditionId}`, retryMs));
237
240
  if (isTarget && !failed && !state.tickPending) return [_objectSpread2(_objectSpread2({}, next), {}, { tickPending: true }), [...effects, tick(2)]];
238
241
  return [next, effects];
239
242
  }
240
- const reduceHlsLive = (slice, msg, kernel) => {
243
+ /**
244
+ * The retry of an abandoned playlist: every rendition that reads it returns
245
+ * to arbitration with a clean failure count, and the reload loop picks it up
246
+ * when it is the window rendition or a companion again.
247
+ */
248
+ function retry(state, kernel, renditionId) {
249
+ var _findRendition3;
250
+ const presentation = kernel.presentation;
251
+ if (presentation === null || !state.abandoned.includes(renditionId)) return [state, []];
252
+ const url = (_findRendition3 = findRendition(presentation, renditionId)) === null || _findRendition3 === void 0 ? void 0 : _findRendition3.rendition.playlistUrl;
253
+ const sharing = url === void 0 ? [renditionId] : renditionIdsAt(presentation, url);
254
+ const abandoned = state.abandoned.filter((id) => !sharing.includes(id));
255
+ const failures = _objectSpread2({}, state.failures);
256
+ for (const id of sharing) delete failures[id];
257
+ const message = readmitMessage(kernel, RELOAD_FAILED, abandoned);
258
+ return [_objectSpread2(_objectSpread2({}, state), {}, {
259
+ abandoned,
260
+ failures
261
+ }), message === null ? [] : [feed(message)]];
262
+ }
263
+ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
241
264
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
242
265
  if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, { manifestUrl: msg.url }), []];
243
266
  if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
@@ -313,6 +336,7 @@ const reduceHlsLive = (slice, msg, kernel) => {
313
336
  awaitingTarget
314
337
  }), effects];
315
338
  }
339
+ if (msg.type === "TICK" && msg.token.startsWith(RETRY_TOKEN)) return retry(state, kernel, msg.token.slice(15));
316
340
  if (msg.type === "TICK" && msg.token === TICK_TOKEN) {
317
341
  var _kernel$presentation2;
318
342
  if (state.suspended || state.target === null || ((_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.isLive) !== true) return [_objectSpread2(_objectSpread2({}, state), {}, {
@@ -355,10 +379,10 @@ const reduceHlsLive = (slice, msg, kernel) => {
355
379
  if (msg.type === "SEGMENT_FAILED") {
356
380
  const renditionId = renditionOfToken(msg.trackId);
357
381
  if (renditionId === null) return [state, []];
358
- return reloadFailed(state, kernel, renditionId, msg.error);
382
+ return reloadFailed(state, kernel, renditionId, msg.error, retryMs);
359
383
  }
360
384
  if (msg.type === "SEGMENT_LOADED") {
361
- var _findRendition3, _lastSegment$seq;
385
+ var _findRendition4, _lastSegment$seq;
362
386
  const renditionId = renditionOfToken(msg.trackId);
363
387
  if (renditionId === null || kernel.presentation === null) return [state, []];
364
388
  const isTarget = state.target !== null && renditionId === state.target.renditionId;
@@ -366,10 +390,10 @@ const reduceHlsLive = (slice, msg, kernel) => {
366
390
  if (url === null) return [state, []];
367
391
  const text = new TextDecoder().decode(msg.bytes);
368
392
  const media = parseMediaPlaylist(text, url);
369
- if (media.playlist === null) return reloadFailed(state, kernel, renditionId, media.error);
393
+ if (media.playlist === null) return reloadFailed(state, kernel, renditionId, media.error, retryMs);
370
394
  const failures = _objectSpread2({}, state.failures);
371
395
  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);
396
+ const sharing = ((_findRendition4 = findRendition(kernel.presentation, renditionId)) === null || _findRendition4 === void 0 ? void 0 : _findRendition4.rendition.playlistUrl) === void 0 ? [renditionId] : renditionIdsAt(kernel.presentation, url);
373
397
  const effects = [];
374
398
  for (const id of sharing) {
375
399
  const refresh = refreshFor(kernel.presentation, id, media.playlist);
@@ -396,13 +420,15 @@ const reduceHlsLive = (slice, msg, kernel) => {
396
420
  return [state, []];
397
421
  };
398
422
  /** The stage factory. Requires hls-cmaf; the loader enforces it. */
399
- function hlsLive() {
423
+ function hlsLive(options = {}) {
424
+ var _options$unavailableR;
425
+ const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : 15) * 1e3;
400
426
  return {
401
427
  name: "hls-live",
402
428
  provides: ["hls-live"],
403
429
  requires: ["hls-cmaf"],
404
430
  install(ctx) {
405
- ctx.reduce("hls-live", reduceHlsLive);
431
+ ctx.reduce("hls-live", createReduceHlsLive(retryMs));
406
432
  registerLiveNamespace(ctx);
407
433
  }
408
434
  };
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { scheduled } from "../../kernel/effects.js";
3
3
  import { findRendition, isTrick } from "../../kernel/presentation.js";
4
4
  import { canSwitchTo } from "../../kernel/rendition-select.js";
@@ -21,14 +21,19 @@ const DEFAULTS = {
21
21
  emergencyFactor: .5,
22
22
  recoveryFactor: 2
23
23
  };
24
- /** The conservative estimate: the minimum of the slow and fast EWMAs. */
24
+ /**
25
+ * The conservative estimate: the minimum of the slow and fast EWMAs, and of
26
+ * the server's estimate (CMSD `etp`) when one is known. Before the engine
27
+ * has measured anything, the server's estimate stands alone.
28
+ */
25
29
  function estimateBps(telemetry) {
26
30
  var _telemetry$throughput;
27
31
  const slow = telemetry.throughputEwma;
28
32
  const fast = (_telemetry$throughput = telemetry.throughputFastEwma) !== null && _telemetry$throughput !== void 0 ? _telemetry$throughput : slow;
29
- if (slow === 0) return fast;
30
- if (fast === 0) return slow;
31
- return Math.min(slow, fast);
33
+ const measured = slow === 0 ? fast : fast === 0 ? slow : Math.min(slow, fast);
34
+ const server = telemetry.serverThroughput;
35
+ if (server === void 0) return measured;
36
+ return measured === 0 ? server : Math.min(measured, server);
32
37
  }
33
38
  function choose(allowed, telemetry, options) {
34
39
  var _allowed$find, _telemetry$bufferAhea, _telemetry$canSwitchT;
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { scheduled } from "../../kernel/effects.js";
3
3
  //#region src/stages/abr-persist/index.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { findRendition } from "../../kernel/presentation.js";
2
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
2
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
3
3
  //#region src/stages/aes-128/index.ts
4
4
  /**
5
5
  * aes-128 as a stage: full-segment AES-CBC decryption for HLS EXT-X-KEY
@@ -14,21 +14,28 @@ import { groupOf } from "../../kernel/rendition-select.js";
14
14
  * that group — preferring the current language so a group switch does not
15
15
  * silently change languages.
16
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`.
17
+ * A user choice is remembered as its language and its characteristics, and
18
+ * re-applied on top of every group switch, so `alt-audio` never fights
19
+ * `engine.tracks.select`: an audio description track chosen in one group
20
+ * stays an audio description track in the next, not the regular track in
21
+ * the same language.
19
22
  */
20
- const INITIAL = { preferredLang: null };
23
+ const INITIAL = {
24
+ preferredLang: null,
25
+ preferredCharacteristics: []
26
+ };
21
27
  /** Audio tracks with their group parsed from the `group:name` id convention. */
22
28
  function audioTracks(kernel) {
23
29
  var _kernel$presentation$, _kernel$presentation;
24
30
  const out = [];
25
31
  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) {
26
- var _track$lang;
32
+ var _track$lang, _track$characteristic;
27
33
  if (track.contentType !== "audio") continue;
28
34
  out.push({
29
35
  id: track.id,
30
36
  group: groupOf(track.id),
31
37
  lang: (_track$lang = track.lang) !== null && _track$lang !== void 0 ? _track$lang : null,
38
+ characteristics: (_track$characteristic = track.characteristics) !== null && _track$characteristic !== void 0 ? _track$characteristic : [],
32
39
  isDefault: track.role === "main"
33
40
  });
34
41
  }
@@ -42,12 +49,21 @@ function requiredGroup(kernel) {
42
49
  const coupling = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.couplings.find((c) => c.renditionId === activeVideo);
43
50
  return (_coupling$requires$au = coupling === null || coupling === void 0 ? void 0 : coupling.requires.audio) !== null && _coupling$requires$au !== void 0 ? _coupling$requires$au : null;
44
51
  }
45
- /** Picks the audio track in `group`, preferring a language, then default, then first. */
46
- function pickInGroup(tracks, group, preferredLang) {
47
- var _ref, _ref2;
52
+ function sameTags(a, b) {
53
+ return a.length === b.length && a.every((tag) => b.includes(tag));
54
+ }
55
+ /**
56
+ * Picks the audio track in `group`: the preferred language with the
57
+ * preferred characteristics, then the language alone, then default, then
58
+ * first.
59
+ */
60
+ function pickInGroup(tracks, group, preference) {
61
+ var _ref, _ref2, _sameLang$find;
48
62
  const inGroup = tracks.filter((t) => t.group === group);
49
63
  if (inGroup.length === 0) return null;
50
- return (_ref = (_ref2 = preferredLang !== null ? inGroup.find((t) => t.lang === preferredLang) : void 0) !== null && _ref2 !== void 0 ? _ref2 : inGroup.find((t) => t.isDefault)) !== null && _ref !== void 0 ? _ref : inGroup[0];
64
+ const { preferredLang, preferredCharacteristics } = preference;
65
+ const sameLang = preferredLang !== null ? inGroup.filter((t) => t.lang === preferredLang) : [];
66
+ return (_ref = (_ref2 = (_sameLang$find = sameLang.find((t) => sameTags(t.characteristics, preferredCharacteristics))) !== null && _sameLang$find !== void 0 ? _sameLang$find : sameLang[0]) !== null && _ref2 !== void 0 ? _ref2 : inGroup.find((t) => t.isDefault)) !== null && _ref !== void 0 ? _ref : inGroup[0];
51
67
  }
52
68
  /** Loops a command back into the bus through a zero-delay schedule effect. */
53
69
  function select(trackId) {
@@ -61,9 +77,13 @@ const reduceAltAudio = (slice, msg, kernel) => {
61
77
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
62
78
  if (msg.type === "LOAD" || msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
63
79
  if (msg.type === "SELECT_TRACK") {
80
+ var _chosen$lang;
64
81
  const chosen = audioTracks(kernel).find((t) => t.id === msg.trackId);
65
- if ((chosen === null || chosen === void 0 ? void 0 : chosen.lang) != null) return [{ preferredLang: chosen.lang }, []];
66
- return [state, []];
82
+ if (chosen === void 0) return [state, []];
83
+ return [{
84
+ preferredLang: (_chosen$lang = chosen.lang) !== null && _chosen$lang !== void 0 ? _chosen$lang : state.preferredLang,
85
+ preferredCharacteristics: chosen.characteristics
86
+ }, []];
67
87
  }
68
88
  if (msg.type === "MANIFEST_LOADED" || msg.type === "PLAYLIST_REFRESHED" || msg.type === "SEGMENT_LOADED") {
69
89
  const group = requiredGroup(kernel);
@@ -72,7 +92,7 @@ const reduceAltAudio = (slice, msg, kernel) => {
72
92
  const tracks = audioTracks(kernel);
73
93
  const activeInfo = tracks.find((t) => t.id === active);
74
94
  if (activeInfo !== void 0 && activeInfo.group === group) return [state, []];
75
- const target = pickInGroup(tracks, group, state.preferredLang);
95
+ const target = pickInGroup(tracks, group, state);
76
96
  if (target === void 0 || target === null || target.id === active) return [state, []];
77
97
  return [state, [select(target.id)]];
78
98
  }
@@ -1,6 +1,6 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { findTrackSite } from "../../kernel/presentation.js";
3
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
3
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
4
4
  import { chaptersFromInput, parseAppleChapters, parseChapterTrack } from "./parse.js";
5
5
  //#region src/stages/chapters/index.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
2
- import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectWithoutProperties.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
3
3
  import { parseVtt } from "../../containers/webvtt.js";
4
4
  import { resolveUrl } from "../../kernel/url.js";
5
5
  //#region src/stages/chapters/parse.ts