mattebox 0.10.0 → 0.12.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 (372) 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 +63 -27
  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 +47 -6
  123. package/dist/es2015/kernel/prepare.js +2 -2
  124. package/dist/es2015/kernel/reducer.js +83 -26
  125. package/dist/es2015/kernel/refresh.js +2 -2
  126. package/dist/es2015/kernel/rendition-select.js +91 -16
  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 +6 -3
  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 +421 -121
  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 +161 -39
  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 +18 -7
  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 +7 -5
  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 +31 -7
  159. package/dist/es2015/stages/eme-fairplay/index.js +18 -9
  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 +57 -6
  166. package/dist/es2015/stages/text-cea608/index.js +26 -93
  167. package/dist/es2015/stages/text-cea708/decode.js +379 -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 +30 -65
  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 +62 -19
  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 +47 -3
  203. package/dist/kernel/mse.js.map +1 -1
  204. package/dist/kernel/reducer.d.ts.map +1 -1
  205. package/dist/kernel/reducer.js +88 -12
  206. package/dist/kernel/reducer.js.map +1 -1
  207. package/dist/kernel/refresh.d.ts.map +1 -1
  208. package/dist/kernel/refresh.js +1 -0
  209. package/dist/kernel/refresh.js.map +1 -1
  210. package/dist/kernel/rendition-select.d.ts +29 -1
  211. package/dist/kernel/rendition-select.d.ts.map +1 -1
  212. package/dist/kernel/rendition-select.js +99 -21
  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 +2 -2
  234. package/dist/kernel/track-registry.d.ts.map +1 -1
  235. package/dist/kernel/track-registry.js +5 -3
  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 +430 -94
  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 +208 -24
  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 +24 -8
  284. package/dist/stages/abr/index.js.map +1 -1
  285. package/dist/stages/alt-audio/index.d.ts +3 -1
  286. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  287. package/dist/stages/alt-audio/index.js +8 -5
  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 +14 -0
  300. package/dist/stages/eme-core/index.d.ts.map +1 -1
  301. package/dist/stages/eme-core/index.js +38 -5
  302. package/dist/stages/eme-core/index.js.map +1 -1
  303. package/dist/stages/eme-fairplay/index.d.ts +5 -0
  304. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  305. package/dist/stages/eme-fairplay/index.js +17 -6
  306. package/dist/stages/eme-fairplay/index.js.map +1 -1
  307. package/dist/stages/hdr/index.d.ts +22 -0
  308. package/dist/stages/hdr/index.d.ts.map +1 -0
  309. package/dist/stages/hdr/index.js +191 -0
  310. package/dist/stages/hdr/index.js.map +1 -0
  311. package/dist/stages/meta-id3/index.d.ts.map +1 -1
  312. package/dist/stages/meta-id3/index.js +6 -2
  313. package/dist/stages/meta-id3/index.js.map +1 -1
  314. package/dist/stages/qoe/index.d.ts +32 -0
  315. package/dist/stages/qoe/index.d.ts.map +1 -0
  316. package/dist/stages/qoe/index.js +116 -0
  317. package/dist/stages/qoe/index.js.map +1 -0
  318. package/dist/stages/rendition-names/index.d.ts +41 -0
  319. package/dist/stages/rendition-names/index.d.ts.map +1 -0
  320. package/dist/stages/rendition-names/index.js +101 -0
  321. package/dist/stages/rendition-names/index.js.map +1 -0
  322. package/dist/stages/text-cea608/decode.d.ts +23 -2
  323. package/dist/stages/text-cea608/decode.d.ts.map +1 -1
  324. package/dist/stages/text-cea608/decode.js +59 -6
  325. package/dist/stages/text-cea608/decode.js.map +1 -1
  326. package/dist/stages/text-cea608/index.d.ts +9 -9
  327. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  328. package/dist/stages/text-cea608/index.js +31 -105
  329. package/dist/stages/text-cea608/index.js.map +1 -1
  330. package/dist/stages/text-cea708/decode.d.ts +79 -0
  331. package/dist/stages/text-cea708/decode.d.ts.map +1 -0
  332. package/dist/stages/text-cea708/decode.js +410 -0
  333. package/dist/stages/text-cea708/decode.js.map +1 -0
  334. package/dist/stages/text-cea708/index.d.ts +3 -0
  335. package/dist/stages/text-cea708/index.d.ts.map +1 -0
  336. package/dist/stages/text-cea708/index.js +93 -0
  337. package/dist/stages/text-cea708/index.js.map +1 -0
  338. package/dist/stages/text-ttml/index.d.ts +3 -0
  339. package/dist/stages/text-ttml/index.d.ts.map +1 -0
  340. package/dist/stages/text-ttml/index.js +74 -0
  341. package/dist/stages/text-ttml/index.js.map +1 -0
  342. package/dist/stages/text-ttml/parse.d.ts +16 -0
  343. package/dist/stages/text-ttml/parse.d.ts.map +1 -0
  344. package/dist/stages/text-ttml/parse.js +277 -0
  345. package/dist/stages/text-ttml/parse.js.map +1 -0
  346. package/dist/stages/text-webvtt/index.d.ts +6 -13
  347. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  348. package/dist/stages/text-webvtt/index.js +21 -68
  349. package/dist/stages/text-webvtt/index.js.map +1 -1
  350. package/dist/stages/timed-metadata/index.d.ts +15 -0
  351. package/dist/stages/timed-metadata/index.d.ts.map +1 -0
  352. package/dist/stages/timed-metadata/index.js +370 -0
  353. package/dist/stages/timed-metadata/index.js.map +1 -0
  354. package/dist/types/error.d.ts +1 -1
  355. package/dist/types/error.d.ts.map +1 -1
  356. package/dist/types/facade.d.ts +8 -10
  357. package/dist/types/facade.d.ts.map +1 -1
  358. package/dist/types/ir.d.ts +90 -0
  359. package/dist/types/ir.d.ts.map +1 -1
  360. package/dist/types/kernel.d.ts +8 -0
  361. package/dist/types/kernel.d.ts.map +1 -1
  362. package/dist/types/messages.d.ts +10 -1
  363. package/dist/types/messages.d.ts.map +1 -1
  364. package/dist/types/metadata.d.ts +59 -0
  365. package/dist/types/metadata.d.ts.map +1 -0
  366. package/dist/types/metadata.js +7 -0
  367. package/dist/types/metadata.js.map +1 -0
  368. package/dist/types/quality.d.ts +10 -0
  369. package/dist/types/quality.d.ts.map +1 -1
  370. package/dist/types/stage.d.ts +17 -0
  371. package/dist/types/stage.d.ts.map +1 -1
  372. 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,28 +282,51 @@ function mediaContentType(type) {
211
282
  if (type === "SUBTITLES") return "text";
212
283
  return null;
213
284
  }
285
+ /** The attributes as one string, in name order, leaving out the names `skip` matches. */
286
+ function attributeKey(attributes, skip) {
287
+ return Object.keys(attributes).filter((name) => (skip === null || skip === void 0 ? void 0 : skip.test(name)) !== true).sort().map((name) => `${name}=${attributes[name]}`).join(",");
288
+ }
289
+ /**
290
+ * RFC 8216bis §4.4.6.1.1: groups of one TYPE carry the same members, and
291
+ * corresponding members differ only in these attributes. A member that
292
+ * matches on everything else is the same rendition in another encoding.
293
+ */
294
+ const PER_GROUP = /^(URI|GROUP-ID|CHANNELS|BIT-DEPTH|SAMPLE-RATE|STABLE-RENDITION-ID)$/;
295
+ /**
296
+ * RFC 8216bis §4.4.6.1: CHANNELS="6", or "16/JOC" for object-based audio.
297
+ * The first parameter counts the channels; the second names the object
298
+ * coding, where "-" means none.
299
+ */
300
+ function channelsOf(entry) {
301
+ var _entry$attributes$CHA;
302
+ const [count, objects] = ((_entry$attributes$CHA = entry.attributes.CHANNELS) !== null && _entry$attributes$CHA !== void 0 ? _entry$attributes$CHA : "").split("/");
303
+ const channels = Number(count);
304
+ return _objectSpread2(_objectSpread2({}, channels > 0 ? { channels } : {}), objects !== void 0 && objects !== "" && objects !== "-" ? { audioObjects: objects } : {});
305
+ }
214
306
  /** The CHARACTERISTICS tags of a rendition, as written, in order. */
215
307
  function characteristicsOf(entry) {
216
- var _entry$attributes$CHA;
217
- return ((_entry$attributes$CHA = entry.attributes.CHARACTERISTICS) !== null && _entry$attributes$CHA !== void 0 ? _entry$attributes$CHA : "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== "");
308
+ var _entry$attributes$CHA2;
309
+ return ((_entry$attributes$CHA2 = entry.attributes.CHARACTERISTICS) !== null && _entry$attributes$CHA2 !== void 0 ? _entry$attributes$CHA2 : "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== "");
218
310
  }
219
311
  /**
220
312
  * RFC 8216bis §4.4.6.1: a CLOSED-CAPTIONS rendition names an in-band
221
- * CEA-608 channel (INSTREAM-ID CC1 to CC4) inside the video. It becomes a
222
- * text track with no segments; the caption stage reads the cues from the
223
- * video. CEA-708 services (SERVICEn) are left out until a stage decodes them.
313
+ * caption channel inside the video: a CEA-608 channel (INSTREAM-ID CC1 to
314
+ * CC4) or a CEA-708 service (SERVICE1 to SERVICE63). It becomes a text
315
+ * track with no segments; a caption stage reads the cues from the video.
224
316
  */
225
317
  function captionTrack(entry) {
318
+ var _entry$attributes$INS;
226
319
  if (entry.type !== "CLOSED-CAPTIONS") return null;
227
- const instreamId = entry.attributes["INSTREAM-ID"];
228
- if (instreamId === void 0 || !/^CC[1-4]$/.test(instreamId)) return null;
320
+ const instreamId = (_entry$attributes$INS = entry.attributes["INSTREAM-ID"]) !== null && _entry$attributes$INS !== void 0 ? _entry$attributes$INS : "";
321
+ 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;
322
+ if (mimeType === null) return null;
229
323
  const characteristics = characteristicsOf(entry);
230
- return _objectSpread2(_objectSpread2(_objectSpread2({
324
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
231
325
  id: `${entry.groupId}:${entry.name}`,
232
326
  contentType: "text",
233
- mimeType: "application/cea-608",
234
- protection: null
235
- }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), {}, { role: "caption" }, characteristics.length > 0 ? { characteristics } : {}), {}, {
327
+ mimeType,
328
+ name: entry.name
329
+ }, entry.attributes.AUTOSELECT === "YES" ? { autoselect: true } : {}), {}, { protection: null }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), {}, { role: "caption" }, characteristics.length > 0 ? { characteristics } : {}), {}, {
236
330
  instreamId,
237
331
  renditions: []
238
332
  });
@@ -348,13 +442,13 @@ function parse(text, baseUrl) {
348
442
  const audioOnly = media.playlist.segments.every((s) => /\.(aac|mp3|ac3|ec3|m4a)(\?|$)/i.test(s.url));
349
443
  const contentType = audioOnly ? "audio" : "video";
350
444
  const mimeType = audioOnly ? "audio/mp4" : "video/mp4";
351
- const rendition = _objectSpread2({
445
+ const rendition = _objectSpread2(_objectSpread2({
352
446
  id: "r-0",
353
447
  bitrate: 0,
354
448
  codecs: null,
355
449
  mimeType,
356
450
  segments: media.playlist.segments
357
- }, media.playlist.init !== null ? { init: media.playlist.init } : {});
451
+ }, media.playlist.init !== null ? { init: media.playlist.init } : {}), media.playlist.dateRanges !== void 0 ? { dateRanges: media.playlist.dateRanges } : {});
358
452
  return {
359
453
  presentation: _objectSpread2(_objectSpread2(_objectSpread2({
360
454
  id: baseUrl,
@@ -425,6 +519,7 @@ function parse(text, baseUrl) {
425
519
  const renditions = [];
426
520
  const audioOnlyVariants = [];
427
521
  const couplings = [];
522
+ const declared = /* @__PURE__ */ new Map();
428
523
  for (const variant of variants) {
429
524
  var _dimensions;
430
525
  const bandwidth = Number(variant.attributes.BANDWIDTH) || 0;
@@ -437,17 +532,26 @@ function parse(text, baseUrl) {
437
532
  const hasAudioGroup = variant.attributes.AUDIO !== void 0;
438
533
  const codecs = video !== null && !hasAudioGroup && audio !== null ? `${video}, ${audio}` : video;
439
534
  const frameRate = Number(variant.attributes["FRAME-RATE"]);
535
+ const range = variant.attributes["VIDEO-RANGE"];
536
+ const videoRange = range === "SDR" || range === "PQ" || range === "HLG" ? range : video !== null && /^dv(h1|he|a1|av)/.test(video) ? "PQ" : void 0;
440
537
  const pathway = variant.attributes["PATHWAY-ID"];
441
- const id = pathway !== void 0 ? `v-${bandwidth}-${pathway}` : `v-${bandwidth}`;
442
- if (renditions.some((r) => r.id === id)) continue;
443
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
538
+ let id = pathway !== void 0 ? `v-${bandwidth}-${pathway}` : `v-${bandwidth}`;
539
+ const taken = declared.get(id);
540
+ if (taken !== void 0) {
541
+ if (attributeKey(taken) === attributeKey(variant.attributes)) continue;
542
+ id = `${id}-${renditions.length}`;
543
+ }
544
+ declared.set(id, variant.attributes);
545
+ const average = Number(variant.attributes["AVERAGE-BANDWIDTH"]);
546
+ const supplemental = variant.attributes["SUPPLEMENTAL-CODECS"];
547
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
444
548
  id,
445
549
  bitrate: bandwidth,
446
550
  codecs,
447
551
  mimeType: "video/mp4",
448
552
  segments: [],
449
553
  playlistUrl: variant.uri
450
- }, pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}));
554
+ }, average > 0 ? { averageBitrate: average } : {}), supplemental !== void 0 ? { supplementalCodecs: supplemental } : {}), pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}), videoRange !== void 0 ? { videoRange } : {}));
451
555
  const requires = {};
452
556
  if (variant.attributes.AUDIO !== void 0) requires.audio = variant.attributes.AUDIO;
453
557
  if (variant.attributes.SUBTITLES !== void 0) requires.text = variant.attributes.SUBTITLES;
@@ -488,8 +592,9 @@ function parse(text, baseUrl) {
488
592
  renditions: audioRenditions
489
593
  });
490
594
  }
595
+ const soundtracks = /* @__PURE__ */ new Map();
491
596
  for (const entry of mediaEntries) {
492
- var _variants$find;
597
+ var _variants$find, _variants$find2;
493
598
  const caption = captionTrack(entry);
494
599
  if (caption !== null) {
495
600
  tracks.push(caption);
@@ -498,21 +603,35 @@ function parse(text, baseUrl) {
498
603
  const contentType = mediaContentType(entry.type);
499
604
  if (contentType === null || entry.uri === null) continue;
500
605
  const { audio } = splitCodecs((_variants$find = variants.find((v) => v.attributes.AUDIO === entry.groupId)) === null || _variants$find === void 0 ? void 0 : _variants$find.attributes.CODECS);
501
- const mimeType = contentType === "audio" ? "audio/mp4" : "text/vtt";
502
- const characteristics = characteristicsOf(entry);
503
- tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
504
- id: `${entry.groupId}:${entry.name}`,
505
- contentType,
506
- mimeType,
507
- protection: sessionProtection
508
- }, 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: [{
606
+ const { text } = splitCodecs((_variants$find2 = variants.find((v) => v.attributes.SUBTITLES === entry.groupId)) === null || _variants$find2 === void 0 ? void 0 : _variants$find2.attributes.CODECS);
607
+ const mimeType = contentType === "audio" ? "audio/mp4" : text !== null ? "application/mp4" : "text/vtt";
608
+ const rendition = _objectSpread2({
509
609
  id: `${entry.groupId}:${entry.name}`,
510
610
  bitrate: 0,
511
- codecs: contentType === "audio" ? audio : null,
611
+ codecs: contentType === "audio" ? audio : text,
512
612
  mimeType,
513
613
  segments: [],
514
614
  playlistUrl: entry.uri
515
- }] }));
615
+ }, channelsOf(entry));
616
+ const key = attributeKey(entry.attributes, PER_GROUP);
617
+ const twin = contentType === "audio" ? soundtracks.get(key) : void 0;
618
+ if (twin !== void 0 && !twin.groups.has(entry.groupId)) {
619
+ twin.groups.add(entry.groupId);
620
+ twin.renditions.push(rendition);
621
+ continue;
622
+ }
623
+ const renditions = [rendition];
624
+ if (contentType === "audio") soundtracks.set(key, {
625
+ groups: /* @__PURE__ */ new Set([entry.groupId]),
626
+ renditions
627
+ });
628
+ const characteristics = characteristicsOf(entry);
629
+ tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
630
+ id: `${entry.groupId}:${entry.name}`,
631
+ contentType,
632
+ mimeType,
633
+ name: entry.name
634
+ }, 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 }));
516
635
  }
517
636
  const trick = trickTrack(iframeStreams, baseUrl, sessionProtection);
518
637
  if (trick !== null) tracks.push(trick);
@@ -582,7 +701,7 @@ function refreshFor(presentation, renditionId, playlist) {
582
701
  if (knownLast !== void 0 && incomingLast !== void 0 && !playlist.endlist && incomingLast.seq < knownLast.seq) return null;
583
702
  const shift = timelineShift(!playlist.endlist && knownLast === void 0 && sibling.length > 0 ? sibling : previous, playlist.segments);
584
703
  const segments = shift === 0 ? playlist.segments : playlist.segments.map((s) => _objectSpread2(_objectSpread2({}, s), {}, { start: s.start + shift }));
585
- return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
704
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
586
705
  type: "PLAYLIST_REFRESHED",
587
706
  trackId: renditionId,
588
707
  renditionId,
@@ -594,7 +713,10 @@ function refreshFor(presentation, renditionId, playlist) {
594
713
  }, playlist.endlist ? {} : { updatePeriod: playlist.targetDuration || 4 }), playlist.dateAnchor !== void 0 ? { dateAnchor: {
595
714
  wallClock: playlist.dateAnchor.wallClock,
596
715
  presentationTime: playlist.dateAnchor.presentationTime + shift
597
- } } : {});
716
+ } } : {}), playlist.dateRanges !== void 0 ? { dateRanges: shift === 0 ? playlist.dateRanges : playlist.dateRanges.map((range) => shiftRange(range, shift)) } : {});
717
+ }
718
+ function shiftRange(range, shift) {
719
+ 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 } : {});
598
720
  }
599
721
  //#endregion
600
722
  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,20 +21,31 @@ 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);
37
+ }
38
+ /** The codec family and the range, as one key: avc1 and avc3 are one family, hvc1 and hev1 too. */
39
+ function kind(rendition) {
40
+ var _rendition$codecs, _rendition$videoRange;
41
+ return `${((_rendition$codecs = rendition.codecs) !== null && _rendition$codecs !== void 0 ? _rendition$codecs : "").slice(0, 4).replace("avc3", "avc1").replace("hev1", "hvc1")}:${(_rendition$videoRange = rendition.videoRange) !== null && _rendition$videoRange !== void 0 ? _rendition$videoRange : "SDR"}`;
32
42
  }
33
43
  function choose(allowed, telemetry, options) {
34
44
  var _allowed$find, _telemetry$bufferAhea, _telemetry$canSwitchT;
35
- const sorted = [...allowed].sort((a, b) => a.bitrate - b.bitrate);
36
- const lowestRendition = sorted[0];
37
45
  const current = (_allowed$find = allowed.find((r) => r.id === telemetry.current)) !== null && _allowed$find !== void 0 ? _allowed$find : null;
46
+ const same = current === null ? [] : allowed.filter((r) => kind(r) === kind(current));
47
+ const sorted = [...same.length > 0 ? same : allowed].sort((a, b) => a.bitrate - b.bitrate);
48
+ const lowestRendition = sorted[0];
38
49
  const estimate = estimateBps(telemetry);
39
50
  if (estimate === 0) return (current !== null && current !== void 0 ? current : lowestRendition).id;
40
51
  let best = lowestRendition;
@@ -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
@@ -12,7 +12,9 @@ import { groupOf } from "../../kernel/rendition-select.js";
12
12
  * slice watches the active video rendition; when its coupling names an
13
13
  * audio group the current audio track is not in, it selects a track in
14
14
  * that group — preferring the current language so a group switch does not
15
- * silently change languages.
15
+ * silently change languages. A track offered in several groups needs no
16
+ * switch when it is in the required one: the kernel plays its rendition
17
+ * there.
16
18
  *
17
19
  * A user choice is remembered as its language and its characteristics, and
18
20
  * re-applied on top of every group switch, so `alt-audio` never fights
@@ -24,7 +26,7 @@ const INITIAL = {
24
26
  preferredLang: null,
25
27
  preferredCharacteristics: []
26
28
  };
27
- /** Audio tracks with their group parsed from the `group:name` id convention. */
29
+ /** Audio tracks with their groups parsed from the `group:name` rendition id convention. */
28
30
  function audioTracks(kernel) {
29
31
  var _kernel$presentation$, _kernel$presentation;
30
32
  const out = [];
@@ -33,7 +35,7 @@ function audioTracks(kernel) {
33
35
  if (track.contentType !== "audio") continue;
34
36
  out.push({
35
37
  id: track.id,
36
- group: groupOf(track.id),
38
+ groups: track.renditions.map((r) => groupOf(r.id)),
37
39
  lang: (_track$lang = track.lang) !== null && _track$lang !== void 0 ? _track$lang : null,
38
40
  characteristics: (_track$characteristic = track.characteristics) !== null && _track$characteristic !== void 0 ? _track$characteristic : [],
39
41
  isDefault: track.role === "main"
@@ -59,7 +61,7 @@ function sameTags(a, b) {
59
61
  */
60
62
  function pickInGroup(tracks, group, preference) {
61
63
  var _ref, _ref2, _sameLang$find;
62
- const inGroup = tracks.filter((t) => t.group === group);
64
+ const inGroup = tracks.filter((t) => t.groups.includes(group));
63
65
  if (inGroup.length === 0) return null;
64
66
  const { preferredLang, preferredCharacteristics } = preference;
65
67
  const sameLang = preferredLang !== null ? inGroup.filter((t) => t.lang === preferredLang) : [];
@@ -91,7 +93,7 @@ const reduceAltAudio = (slice, msg, kernel) => {
91
93
  const active = kernel.tracks.active.get("audio");
92
94
  const tracks = audioTracks(kernel);
93
95
  const activeInfo = tracks.find((t) => t.id === active);
94
- if (activeInfo !== void 0 && activeInfo.group === group) return [state, []];
96
+ if ((activeInfo === null || activeInfo === void 0 ? void 0 : activeInfo.groups.includes(group)) === true) return [state, []];
95
97
  const target = pickInGroup(tracks, group, state);
96
98
  if (target === void 0 || target === null || target.id === active) return [state, []];
97
99
  return [state, [select(target.id)]];