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,18 +1,19 @@
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 { tickAfter } from "./effects.js";
3
- import { normalizeMimeType, typeString } from "./mime.js";
3
+ import { cueFormat, normalizeMimeType, typeString } from "./mime.js";
4
4
  import { findRendition, findTrackSite, isTrick } from "./presentation.js";
5
5
  import { applyRefresh } from "./refresh.js";
6
6
  import { reconciledOffset, segmentAtTime } from "./timeline.js";
7
7
  import { bufferedEndFrom, reachesEnd, schedule } from "./scheduler.js";
8
- import { availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
8
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
9
+ import { activeAudio, audioGroup, audioInGroup, availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
9
10
  import { sbIdFor } from "./sinks/mse-sink.js";
10
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectWithoutProperties.js";
11
11
  //#region src/kernel/reducer.ts
12
12
  const _excluded = ["pendingInit"];
13
13
  const _excluded2 = ["repeat"];
14
14
  const _excluded3 = ["appended"];
15
15
  const _excluded4 = ["initFor"];
16
+ const _excluded5 = ["serverThroughput"];
16
17
  /**
17
18
  * The default tuning. Every value is overridable through the `config`
18
19
  * parameters of `initialState` and `createReducer`; these are starting
@@ -46,6 +47,7 @@ function initialState(config) {
46
47
  buffers: /* @__PURE__ */ new Map(),
47
48
  bufferErrors: /* @__PURE__ */ new Map(),
48
49
  cues: /* @__PURE__ */ new Map(),
50
+ cueInits: /* @__PURE__ */ new Map(),
49
51
  live: null,
50
52
  scheduling: {
51
53
  inflight: /* @__PURE__ */ new Map(),
@@ -323,11 +325,21 @@ function reduceCommand(state, msg, cfg, hooks) {
323
325
  return [_objectSpread2(_objectSpread2({}, next), {}, {
324
326
  lifecycle: { phase: "suspended" },
325
327
  live: null
326
- }), aborts];
328
+ }), [...aborts, {
329
+ kind: "emit",
330
+ event: "lifecycle:suspended",
331
+ payload: {}
332
+ }]];
327
333
  }
328
- case "RESUME":
334
+ case "RESUME": {
329
335
  if (state.lifecycle.phase !== "suspended") return reject(state, msg.type, "not suspended");
330
- return driveScheduling(_objectSpread2(_objectSpread2({}, state), {}, { lifecycle: { phase: "ready" } }), hooks, cfg);
336
+ const [resumed, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, state), {}, { lifecycle: { phase: "ready" } }), hooks, cfg);
337
+ return [resumed, [{
338
+ kind: "emit",
339
+ event: "lifecycle:resumed",
340
+ payload: {}
341
+ }, ...effects]];
342
+ }
331
343
  case "SEEK": {
332
344
  if (state.presentation === null) return reject(state, msg.type, "no source");
333
345
  const [next, aborts] = abortInflight(state);
@@ -433,10 +445,13 @@ function reduceCommand(state, msg, cfg, hooks) {
433
445
  active.delete(msg.contentType);
434
446
  const cues = new Map(state.cues);
435
447
  cues.delete(trackId);
448
+ const cueInits = new Map(state.cueInits);
449
+ cueInits.delete(trackId);
436
450
  const [aborted, abortEffects] = abortInflight(state, trackId);
437
451
  return [_objectSpread2(_objectSpread2({}, aborted), {}, {
438
452
  tracks: _objectSpread2(_objectSpread2({}, state.tracks), {}, { active }),
439
453
  cues,
454
+ cueInits,
440
455
  quality: bumped(state.quality)
441
456
  }), [
442
457
  ...abortEffects,
@@ -506,6 +521,11 @@ function reduceCommand(state, msg, cfg, hooks) {
506
521
  scheduling: clearRepeat(state.scheduling)
507
522
  }), []];
508
523
  }
524
+ case "THROUGHPUT_HINT": {
525
+ if (msg.bps !== null && (!Number.isFinite(msg.bps) || msg.bps <= 0)) return reject(state, msg.type, "invalid throughput");
526
+ const _state$stats = state.stats, { serverThroughput: _old } = _state$stats, stats = _objectWithoutProperties(_state$stats, _excluded5);
527
+ return [_objectSpread2(_objectSpread2({}, state), {}, { stats: msg.bps === null ? stats : _objectSpread2(_objectSpread2({}, stats), {}, { serverThroughput: msg.bps }) }), []];
528
+ }
509
529
  case "SET_BUFFER_GOAL":
510
530
  if (!Number.isFinite(msg.seconds) || msg.seconds <= 0) return reject(state, msg.type, "invalid buffer goal");
511
531
  return [_objectSpread2(_objectSpread2({}, state), {}, { scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { bufferGoal: msg.seconds }) }), []];
@@ -681,10 +701,31 @@ function reduceFact(state, msg, cfg, hooks) {
681
701
  let timeline = state.timeline;
682
702
  let quality = state.quality;
683
703
  let cues = state.cues;
704
+ let cueInits = state.cueInits;
684
705
  const effects = [];
685
706
  const cueTrack = matched.sbId === void 0 ? findTrack(state.presentation, matched.trackId) : null;
707
+ if (cueTrack !== null && (cueTrack.contentType === "text" || cueTrack.contentType === "metadata") && matched.seq < 0 && matched.renditionId !== void 0) {
708
+ var _cueTrack$renditions$;
709
+ cueInits = new Map(cueInits).set(matched.trackId, matched.renditionId);
710
+ effects.push({
711
+ kind: "deliver",
712
+ trackId: matched.trackId,
713
+ contentType: cueTrack.contentType,
714
+ data: msg.bytes,
715
+ meta: {
716
+ trackId: matched.trackId,
717
+ renditionId: matched.renditionId,
718
+ contentType: cueTrack.contentType,
719
+ seq: matched.seq,
720
+ start: 0,
721
+ duration: 0,
722
+ isInit: true,
723
+ format: cueFormat(cueTrack.mimeType, (_cueTrack$renditions$ = cueTrack.renditions.find((r) => r.id === matched.renditionId)) === null || _cueTrack$renditions$ === void 0 ? void 0 : _cueTrack$renditions$.codecs)
724
+ }
725
+ });
726
+ }
686
727
  if (cueTrack !== null && (cueTrack.contentType === "text" || cueTrack.contentType === "metadata") && matched.segmentStart !== void 0) {
687
- var _matched$segmentDurat, _cues$get, _matched$renditionId, _matched$segmentDurat2;
728
+ var _matched$segmentDurat, _cues$get, _matched$renditionId, _matched$segmentDurat2, _cueTrack$renditions$2;
688
729
  const span = {
689
730
  start: matched.segmentStart,
690
731
  end: matched.segmentStart + ((_matched$segmentDurat = matched.segmentDuration) !== null && _matched$segmentDurat !== void 0 ? _matched$segmentDurat : 0)
@@ -704,7 +745,8 @@ function reduceFact(state, msg, cfg, hooks) {
704
745
  seq: matched.seq,
705
746
  start: matched.segmentStart,
706
747
  duration: (_matched$segmentDurat2 = matched.segmentDuration) !== null && _matched$segmentDurat2 !== void 0 ? _matched$segmentDurat2 : 0,
707
- isInit: matched.seq < 0
748
+ isInit: matched.seq < 0,
749
+ format: cueFormat(cueTrack.mimeType, (_cueTrack$renditions$2 = cueTrack.renditions.find((r) => r.id === matched.renditionId)) === null || _cueTrack$renditions$2 === void 0 ? void 0 : _cueTrack$renditions$2.codecs)
708
750
  }
709
751
  });
710
752
  }
@@ -811,6 +853,7 @@ function reduceFact(state, msg, cfg, hooks) {
811
853
  timeline,
812
854
  quality,
813
855
  cues,
856
+ cueInits,
814
857
  scheduling: withPendingInit(_objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }), pendingInit),
815
858
  stats
816
859
  }), effects];
@@ -830,8 +873,10 @@ function reduceFact(state, msg, cfg, hooks) {
830
873
  const failedTrack = findTrack(state.presentation, msg.trackId);
831
874
  const isCueTrack = failedTrack !== null && (failedTrack.contentType === "text" || failedTrack.contentType === "metadata");
832
875
  let cues = state.cues;
876
+ let cueInits = state.cueInits;
833
877
  if (isCueTrack) {
834
878
  const request = [...state.scheduling.inflight.values()].find((r) => r.trackId === msg.trackId && r.seq === msg.seq);
879
+ if (msg.seq < 0 && (request === null || request === void 0 ? void 0 : request.renditionId) !== void 0) cueInits = new Map(cueInits).set(msg.trackId, request.renditionId);
835
880
  if ((request === null || request === void 0 ? void 0 : request.segmentStart) !== void 0) {
836
881
  var _cues$get2, _request$segmentDurat;
837
882
  const next = new Map(cues);
@@ -858,6 +903,7 @@ function reduceFact(state, msg, cfg, hooks) {
858
903
  if (!isCueTrack) failEffects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
859
904
  return [_objectSpread2(_objectSpread2({}, state), {}, {
860
905
  cues,
906
+ cueInits,
861
907
  scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight })
862
908
  }), failEffects];
863
909
  }
@@ -911,13 +957,13 @@ function reduceFact(state, msg, cfg, hooks) {
911
957
  const effects = [{
912
958
  kind: "emit",
913
959
  event: "error",
914
- payload: _objectSpread2({
960
+ payload: _objectSpread2(_objectSpread2({
915
961
  category: msg.error.category,
916
962
  code: msg.error.code,
917
963
  fatal,
918
964
  recoverable: msg.error.recoverable,
919
965
  sbId: msg.sbId
920
- }, fatal && !msg.error.fatal ? { consecutiveFailures: count } : {})
966
+ }, fatal && !msg.error.fatal ? { consecutiveFailures: count } : {}), msg.error.context !== void 0 ? { context: msg.error.context } : {})
921
967
  }];
922
968
  if (neverAppended && !fatal) effects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
923
969
  let inflight = state.scheduling.inflight;
@@ -1052,7 +1098,7 @@ function driveScheduling(state, hooks, cfg) {
1052
1098
  const initFetches = [];
1053
1099
  let quality = state.quality;
1054
1100
  for (const contentType of ["video", "audio"]) {
1055
- var _state$buffers$get$pe, _state$buffers$get2, _state$buffers$get$ra2, _state$buffers$get3, _hooks$abr, _hooks$switchPolicy, _state$buffers$get4, _state$buffers$get5, _state$buffers$get$ra3, _state$buffers$get6;
1101
+ var _state$buffers$get$pe, _state$buffers$get2, _state$buffers$get$ra2, _state$buffers$get3, _state$stats$serverTh, _hooks$abr, _hooks$switchPolicy, _state$buffers$get4, _state$buffers$get5, _state$buffers$get$ra3, _state$buffers$get6;
1056
1102
  const trackId = state.tracks.active.get(contentType);
1057
1103
  if (trackId === void 0) continue;
1058
1104
  const found = findTrackSite(state.presentation, trackId);
@@ -1060,25 +1106,29 @@ function driveScheduling(state, hooks, cfg) {
1060
1106
  const sbId = sbIdFor(contentType);
1061
1107
  if (((_state$buffers$get$pe = (_state$buffers$get2 = state.buffers.get(sbId)) === null || _state$buffers$get2 === void 0 ? void 0 : _state$buffers$get2.pendingAppends) !== null && _state$buffers$get$pe !== void 0 ? _state$buffers$get$pe : 0) > 0) continue;
1062
1108
  const bufferAhead = bufferedEndFrom((_state$buffers$get$ra2 = (_state$buffers$get3 = state.buffers.get(sbId)) === null || _state$buffers$get3 === void 0 ? void 0 : _state$buffers$get3.ranges) !== null && _state$buffers$get$ra2 !== void 0 ? _state$buffers$get$ra2 : [], state.playback.currentTime, GAP_TOLERANCE) - state.playback.currentTime;
1063
- const memoKey = hooks.abr == null ? state.quality.version : `${state.quality.version}:${Math.round(state.stats.throughputEwma / 25e3)}:${Math.round(state.stats.throughputFastEwma / 25e3)}:${Math.round(bufferAhead)}:${state.quality.active}`;
1064
- const outcome = arbiterFor(hooks, contentType).run({
1065
- renditions: found.track.renditions,
1109
+ const memoKey = hooks.abr == null ? state.quality.version : `${state.quality.version}:${Math.round(state.stats.throughputEwma / 25e3)}:${Math.round(state.stats.throughputFastEwma / 25e3)}:${Math.round(((_state$stats$serverTh = state.stats.serverThroughput) !== null && _state$stats$serverTh !== void 0 ? _state$stats$serverTh : 0) / 25e3)}:${Math.round(bufferAhead)}:${state.quality.active}`;
1110
+ const couplings = state.presentation.couplings;
1111
+ const audio = activeAudio(state);
1112
+ const outcome = arbiterFor(hooks, contentType).run(_objectSpread2(_objectSpread2({
1113
+ renditions: contentType === "audio" ? audioInGroup(found.track.renditions, audioGroup(found.track.renditions, couplings, state.quality.constraints, quality.active)) : found.track.renditions,
1066
1114
  constraints: state.quality.constraints,
1067
1115
  pinned: state.quality.pinned,
1068
1116
  current: state.quality.active,
1069
- couplings: state.presentation.couplings,
1117
+ couplings,
1070
1118
  activeTracks: state.tracks.active,
1071
- availableGroups: availableGroups(state),
1119
+ availableGroups: availableGroups(state)
1120
+ }, audio !== void 0 ? { audio } : {}), {}, {
1072
1121
  abr: (_hooks$abr = hooks.abr) !== null && _hooks$abr !== void 0 ? _hooks$abr : null,
1073
- telemetry: {
1122
+ telemetry: _objectSpread2(_objectSpread2({
1074
1123
  throughputEwma: state.stats.throughputEwma,
1075
- throughputFastEwma: state.stats.throughputFastEwma,
1124
+ throughputFastEwma: state.stats.throughputFastEwma
1125
+ }, state.stats.serverThroughput !== void 0 ? { serverThroughput: state.stats.serverThroughput } : {}), {}, {
1076
1126
  bufferAhead,
1077
1127
  current: state.quality.active,
1078
1128
  currentTime: state.playback.currentTime,
1079
1129
  canSwitchTo: (_hooks$switchPolicy = hooks.switchPolicy) !== null && _hooks$switchPolicy !== void 0 ? _hooks$switchPolicy : canSwitchTo
1080
- }
1081
- }, memoKey);
1130
+ })
1131
+ }), contentType === "audio" ? `${memoKey}:${quality.active}` : memoKey);
1082
1132
  for (const event of outcome.events) effects.push(event);
1083
1133
  const rendition = found.track.renditions.find((r) => r.id === outcome.result.selected);
1084
1134
  if (rendition === void 0) continue;
@@ -1122,6 +1172,14 @@ function driveScheduling(state, hooks, cfg) {
1122
1172
  if (found === null || rendition === void 0) continue;
1123
1173
  const inflight = [];
1124
1174
  for (const request of state.scheduling.inflight.values()) if (request.trackId === trackId) inflight.push(request);
1175
+ if (rendition.init !== void 0 && state.cueInits.get(trackId) !== rendition.id) {
1176
+ if (inflight.length === 0) initFetches.push({
1177
+ trackId,
1178
+ rendition: rendition.id,
1179
+ init: rendition.init
1180
+ });
1181
+ continue;
1182
+ }
1125
1183
  tracks.push({
1126
1184
  trackId,
1127
1185
  period: found.period,
@@ -1188,14 +1246,12 @@ function driveScheduling(state, hooks, cfg) {
1188
1246
  token,
1189
1247
  url: pending.init.url
1190
1248
  }, pending.init.byteRange !== void 0 ? { range: pending.init.byteRange } : {}));
1191
- inflight.set(token, {
1249
+ inflight.set(token, _objectSpread2(_objectSpread2({
1192
1250
  token,
1193
1251
  trackId: pending.trackId,
1194
1252
  seq: -1,
1195
- url: pending.init.url,
1196
- sbId: pending.sbId,
1197
- renditionId: pending.rendition
1198
- });
1253
+ url: pending.init.url
1254
+ }, pending.sbId !== void 0 ? { sbId: pending.sbId } : {}), {}, { renditionId: pending.rendition }));
1199
1255
  }
1200
1256
  for (const effect of result.effects) effects.push(effect);
1201
1257
  for (const request of result.requests) inflight.set(request.token, request);
@@ -1241,6 +1297,7 @@ const COMMAND_TYPES = {
1241
1297
  CONSTRAIN: true,
1242
1298
  RELEASE_CONSTRAINT: true,
1243
1299
  SET_BUFFER_GOAL: true,
1300
+ THROUGHPUT_HINT: true,
1244
1301
  RESOLVE_RENDITION: true,
1245
1302
  ABORT_INFLIGHT: true,
1246
1303
  ADD_TRACK: true
@@ -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
  //#region src/kernel/refresh.ts
3
3
  /** The presentation with the refresh merged, or null when it names no rendition the presentation holds. */
4
4
  function applyRefresh(presentation, refresh) {
@@ -11,7 +11,7 @@ function applyRefresh(presentation, refresh) {
11
11
  found = true;
12
12
  return _objectSpread2(_objectSpread2({}, track), {}, {
13
13
  protection: (_ref = (_track$protection = track.protection) !== null && _track$protection !== void 0 ? _track$protection : refresh.protection) !== null && _ref !== void 0 ? _ref : null,
14
- renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2(_objectSpread2({}, rendition), {}, { segments: refresh.segments }, refresh.init !== void 0 ? { init: refresh.init } : {}), refresh.tiles !== void 0 ? { tiles: refresh.tiles } : {}) : rendition)
14
+ renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, rendition), {}, { segments: refresh.segments }, refresh.init !== void 0 ? { init: refresh.init } : {}), refresh.tiles !== void 0 ? { tiles: refresh.tiles } : {}), refresh.dateRanges !== void 0 ? { dateRanges: refresh.dateRanges } : {}) : rendition)
15
15
  });
16
16
  }) }));
17
17
  if (!found) return null;
@@ -1,8 +1,16 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
2
- import { findRendition } from "./presentation.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { findRendition, findTrackSite } from "./presentation.js";
3
3
  import { segmentAtTime } from "./timeline.js";
4
4
  import { bufferedEndFrom } from "./scheduler.js";
5
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
5
6
  //#region src/kernel/rendition-select.ts
7
+ const _excluded = [
8
+ "maxHeight",
9
+ "maxWidth",
10
+ "maxBitrate",
11
+ "minBitrate",
12
+ "maxFrameRate"
13
+ ];
6
14
  /** The lead time before which a `soon` switch never disturbs the buffer. */
7
15
  const SOON_LEAD_SECONDS = 1.5;
8
16
  const GAP_TOLERANCE = .25;
@@ -18,6 +26,7 @@ function matches(rendition, constraint) {
18
26
  const codec = rendition.codecs;
19
27
  if (codec === null || !constraint.codecs.some((allowed) => codec.startsWith(allowed))) return false;
20
28
  }
29
+ if (constraint.hdr === false && (rendition.videoRange === "PQ" || rendition.videoRange === "HLG")) return false;
21
30
  if (constraint.filter !== void 0 && !constraint.filter(rendition)) return false;
22
31
  return true;
23
32
  }
@@ -34,6 +43,50 @@ function lowest(allowed) {
34
43
  for (const candidate of allowed) if (candidate.bitrate < best.bitrate) best = candidate;
35
44
  return best;
36
45
  }
46
+ /** Every rendition id a constraint excludes by id: undecodable, failed, on a lost pathway. */
47
+ function excludedIds(constraints) {
48
+ const excluded = /* @__PURE__ */ new Set();
49
+ for (const constraint of constraints.values()) {
50
+ var _constraint$excludeId2;
51
+ for (const id of (_constraint$excludeId2 = constraint.excludeIds) !== null && _constraint$excludeId2 !== void 0 ? _constraint$excludeId2 : []) excluded.add(id);
52
+ }
53
+ return excluded;
54
+ }
55
+ /**
56
+ * The video stream a rendition shows: renditions that read one playlist on
57
+ * one pathway carry the same video and differ only by audio group.
58
+ */
59
+ function streamOf(rendition) {
60
+ var _rendition$playlistUr;
61
+ return `${rendition.pathway}|${(_rendition$playlistUr = rendition.playlistUrl) !== null && _rendition$playlistUr !== void 0 ? _rendition$playlistUr : rendition.id}`;
62
+ }
63
+ /**
64
+ * The audio group the engine plays from the active audio track, whose
65
+ * renditions are `audio`: the group the video rendition `videoId` requires
66
+ * when the track has a usable rendition in it, else the group of the
67
+ * track's first usable rendition, in manifest order. Null when no coupling
68
+ * names an audio group (audio muxed into the video, or audio-only, or a
69
+ * manifest format without groups), or when no rendition is usable.
70
+ */
71
+ function audioGroup(audio, couplings, constraints, videoId) {
72
+ var _couplings$find, _groups$;
73
+ if (!couplings.some((c) => c.requires.audio !== void 0)) return null;
74
+ const excluded = excludedIds(constraints);
75
+ const groups = audio.filter((r) => !excluded.has(r.id)).map((r) => groupOf(r.id));
76
+ const required = (_couplings$find = couplings.find((c) => c.renditionId === videoId)) === null || _couplings$find === void 0 ? void 0 : _couplings$find.requires.audio;
77
+ return required !== void 0 && groups.includes(required) ? required : (_groups$ = groups[0]) !== null && _groups$ !== void 0 ? _groups$ : null;
78
+ }
79
+ /** The renditions of `audio` in `group`; all of them when none is. */
80
+ function audioInGroup(audio, group) {
81
+ const inGroup = audio.filter((r) => groupOf(r.id) === group);
82
+ return inGroup.length > 0 ? inGroup : audio;
83
+ }
84
+ /** The renditions of the active audio track, or undefined without one. */
85
+ function activeAudio(kernel) {
86
+ var _findTrackSite;
87
+ const trackId = kernel.tracks.active.get("audio");
88
+ return trackId === void 0 ? void 0 : (_findTrackSite = findTrackSite(kernel.presentation, trackId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track.renditions;
89
+ }
37
90
  /**
38
91
  * The video renditions an adapter resolves ahead of need: the active one
39
92
  * and the nearest rung below and above on its pathway. ABR moves one rung
@@ -45,11 +98,7 @@ function lowest(allowed) {
45
98
  */
46
99
  function ladderNeighbours(renditions, activeId, constraints) {
47
100
  var _pool$find;
48
- const excluded = /* @__PURE__ */ new Set();
49
- for (const constraint of constraints.values()) {
50
- var _constraint$excludeId2;
51
- for (const id of (_constraint$excludeId2 = constraint.excludeIds) !== null && _constraint$excludeId2 !== void 0 ? _constraint$excludeId2 : []) excluded.add(id);
52
- }
101
+ const excluded = excludedIds(constraints);
53
102
  const usable = renditions.filter((r) => !excluded.has(r.id));
54
103
  const pool = [...usable.length > 0 ? usable : renditions].sort((a, b) => a.bitrate - b.bitrate);
55
104
  const active = (_pool$find = pool.find((r) => r.id === activeId)) !== null && _pool$find !== void 0 ? _pool$find : pool[0];
@@ -78,11 +127,14 @@ function groupOf(trackId) {
78
127
  const colon = trackId.indexOf(":");
79
128
  return colon === -1 ? trackId : trackId.slice(0, colon);
80
129
  }
81
- /** Companion groups present, as `contentType:groupId`, for the coupling filter. */
130
+ /**
131
+ * Companion groups present, as `contentType:groupId`, for the coupling
132
+ * filter. A track offered in several audio groups counts in each.
133
+ */
82
134
  function availableGroups(kernel) {
83
135
  var _kernel$presentation$, _kernel$presentation;
84
136
  const groups = /* @__PURE__ */ new Set();
85
- for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.contentType === "audio" || track.contentType === "text") groups.add(`${track.contentType}:${groupOf(track.id)}`);
137
+ for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.contentType === "audio" || track.contentType === "text") for (const r of track.renditions) groups.add(`${track.contentType}:${groupOf(r.id)}`);
86
138
  return groups;
87
139
  }
88
140
  /**
@@ -100,8 +152,9 @@ function activeRenditions(kernel, types, videoId) {
100
152
  const trackId = kernel.tracks.active.get(contentType);
101
153
  if (trackId === void 0) continue;
102
154
  for (const period of (_kernel$presentation$2 = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.periods) !== null && _kernel$presentation$2 !== void 0 ? _kernel$presentation$2 : []) for (const track of period.tracks) {
155
+ var _kernel$presentation$3, _kernel$presentation3;
103
156
  if (track.id !== trackId) continue;
104
- const candidates = contentType === "video" ? ladderNeighbours(track.renditions, videoId, kernel.quality.constraints) : track.renditions;
157
+ const candidates = contentType === "video" ? ladderNeighbours(track.renditions, videoId, kernel.quality.constraints) : contentType === "audio" ? audioInGroup(track.renditions, audioGroup(track.renditions, (_kernel$presentation$3 = (_kernel$presentation3 = kernel.presentation) === null || _kernel$presentation3 === void 0 ? void 0 : _kernel$presentation3.couplings) !== null && _kernel$presentation$3 !== void 0 ? _kernel$presentation$3 : [], kernel.quality.constraints, videoId)) : track.renditions;
105
158
  for (const rendition of candidates) out.push({
106
159
  contentType,
107
160
  rendition
@@ -131,9 +184,10 @@ function withDeadGroups(presentation, dead) {
131
184
  const alive = /* @__PURE__ */ new Set();
132
185
  for (const period of presentation.periods) for (const track of period.tracks) {
133
186
  if (track.contentType !== "audio") continue;
134
- const group = groupOf(track.id);
135
- known.add(group);
136
- if (track.renditions.some((r) => !dead.has(r.id))) alive.add(group);
187
+ for (const r of track.renditions) {
188
+ known.add(groupOf(r.id));
189
+ if (!dead.has(r.id)) alive.add(groupOf(r.id));
190
+ }
137
191
  }
138
192
  for (const { renditionId, requires } of presentation.couplings) if (requires.audio !== void 0 && known.has(requires.audio) && !alive.has(requires.audio)) out.add(renditionId);
139
193
  return out;
@@ -182,6 +236,15 @@ function arbitrate(ctx) {
182
236
  event: "quality:coupling-unsatisfiable",
183
237
  payload: { active: Object.fromEntries(ctx.activeTracks) }
184
238
  });
239
+ if (ctx.audio !== void 0) {
240
+ const group = audioGroup(ctx.audio, ctx.couplings, ctx.constraints, ctx.current);
241
+ const needs = (r) => {
242
+ var _ctx$couplings$find;
243
+ return (_ctx$couplings$find = ctx.couplings.find((c) => c.renditionId === r.id)) === null || _ctx$couplings$find === void 0 ? void 0 : _ctx$couplings$find.requires.audio;
244
+ };
245
+ const covered = new Set(allowed.filter((r) => needs(r) === group).map(streamOf));
246
+ allowed = allowed.filter((r) => needs(r) === group || !covered.has(streamOf(r)));
247
+ }
185
248
  const allowedIds = allowed.map((r) => r.id);
186
249
  if (ctx.pinned !== null) {
187
250
  if (allowedIds.includes(ctx.pinned)) return {
@@ -195,8 +258,9 @@ function arbitrate(ctx) {
195
258
  };
196
259
  const target = ctx.renditions.find((r) => r.id === ctx.pinned);
197
260
  if (target !== void 0) {
198
- const clamped = closestByBitrate(allowed, target);
199
- events.push({
261
+ const sibling = allowed.find((r) => target.playlistUrl !== void 0 && streamOf(r) === streamOf(target));
262
+ const clamped = sibling !== null && sibling !== void 0 ? sibling : closestByBitrate(allowed, target);
263
+ if (sibling === void 0) events.push({
200
264
  kind: "emit",
201
265
  event: "quality:pin-unsatisfiable",
202
266
  payload: {
@@ -254,6 +318,17 @@ function arbitrate(ctx) {
254
318
  events
255
319
  };
256
320
  }
321
+ /**
322
+ * The constraints without their numeric caps: what cannot play (codecs,
323
+ * excluded ids, HDR, a filter), not what is preferred. Arbitrated, they
324
+ * give the renditions a viewer may pick, since a pin may go past a cap.
325
+ */
326
+ function exclusionsOf(constraints) {
327
+ return new Map([...constraints].map(([source, _ref]) => {
328
+ let { maxHeight, maxWidth, maxBitrate, minBitrate, maxFrameRate } = _ref;
329
+ return [source, _objectWithoutProperties(_ref, _excluded)];
330
+ }));
331
+ }
257
332
  function createArbiter() {
258
333
  let lastVersion = NaN;
259
334
  let lastOutcome = null;
@@ -366,4 +441,4 @@ function planPinApply(input) {
366
441
  };
367
442
  }
368
443
  //#endregion
369
- export { activeRenditions, arbitrate, availableGroups, canSwitchTo, codecFamily, createArbiter, groupOf, ladderNeighbours, planPinApply, withDeadGroups };
444
+ export { activeAudio, activeRenditions, arbitrate, audioGroup, audioInGroup, availableGroups, canSwitchTo, codecFamily, createArbiter, exclusionsOf, groupOf, ladderNeighbours, planPinApply, withDeadGroups };
@@ -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 { buildEpochs, epochForSeq, epochKey, segmentAtTime, timestampOffsetFor } from "./timeline.js";
3
3
  //#region src/kernel/scheduler.ts
4
4
  const DEFAULT_GAP_TOLERANCE = .25;
@@ -0,0 +1,82 @@
1
+ import { adoptTextTrack, emptyTextTrack } from "./text-track-sink.js";
2
+ import { syncNativeTracks } from "./native-sync.js";
3
+ //#region src/kernel/sinks/caption-tracks.ts
4
+ /** A VTTCue, or null where the browser has none. */
5
+ function vttCue(start, end, text) {
6
+ const Ctor = globalThis.VTTCue;
7
+ return Ctor === void 0 ? null : new Ctor(start, end, text);
8
+ }
9
+ /** Wires a caption format's channels to tracks. `prefix` names added tracks, as `cea608:CC1`. */
10
+ function inbandCaptions(ctx, mime, prefix) {
11
+ const element = ctx.element;
12
+ const natives = /* @__PURE__ */ new Map();
13
+ const adding = /* @__PURE__ */ new Set();
14
+ function declared() {
15
+ var _ctx$getState$present, _ctx$getState$present2;
16
+ const out = [];
17
+ for (const period of (_ctx$getState$present = (_ctx$getState$present2 = ctx.getState().presentation) === null || _ctx$getState$present2 === void 0 ? void 0 : _ctx$getState$present2.periods) !== null && _ctx$getState$present !== void 0 ? _ctx$getState$present : []) for (const track of period.tracks) if (track.mimeType === mime) out.push(track);
18
+ return out;
19
+ }
20
+ /** The channel's caption track in the presentation, declared or added. */
21
+ function captionTrack(channel) {
22
+ var _declared$find;
23
+ return (_declared$find = declared().find((track) => track.instreamId === channel)) !== null && _declared$find !== void 0 ? _declared$find : null;
24
+ }
25
+ /** The channel's native track, created on first need. Hidden keeps cues arriving and removable. */
26
+ function ensureNative(channel) {
27
+ let native = natives.get(channel);
28
+ if (native === void 0) {
29
+ var _captionTrack;
30
+ native = adoptTextTrack(element, "captions", channel, (_captionTrack = captionTrack(channel)) === null || _captionTrack === void 0 ? void 0 : _captionTrack.lang);
31
+ native.mode = "hidden";
32
+ natives.set(channel, native);
33
+ }
34
+ return native;
35
+ }
36
+ const stopSync = syncNativeTracks(ctx, {
37
+ tracks: () => declared().filter((track) => track.instreamId !== void 0),
38
+ native: (track, create) => {
39
+ var _natives$get;
40
+ const channel = track.instreamId;
41
+ return (_natives$get = natives.get(channel)) !== null && _natives$get !== void 0 ? _natives$get : create ? ensureNative(channel) : null;
42
+ },
43
+ idle: "hidden",
44
+ before() {
45
+ for (const channel of [...adding]) if (captionTrack(channel) === null) adding.delete(channel);
46
+ }
47
+ });
48
+ return {
49
+ show(channel, cues) {
50
+ if (cues.length === 0) return;
51
+ if (captionTrack(channel) === null && !adding.has(channel)) {
52
+ if (ctx.getState().presentation !== null) {
53
+ adding.add(channel);
54
+ ctx.dispatch({
55
+ type: "ADD_TRACK",
56
+ track: {
57
+ id: `${prefix}:${channel}`,
58
+ contentType: "text",
59
+ mimeType: mime,
60
+ protection: null,
61
+ role: "caption",
62
+ instreamId: channel,
63
+ renditions: []
64
+ }
65
+ });
66
+ }
67
+ }
68
+ const target = ensureNative(channel);
69
+ for (const cue of cues) target.addCue(cue);
70
+ },
71
+ dispose() {
72
+ stopSync();
73
+ for (const native of natives.values()) {
74
+ emptyTextTrack(native);
75
+ native.mode = "disabled";
76
+ }
77
+ natives.clear();
78
+ }
79
+ };
80
+ }
81
+ //#endregion
82
+ export { inbandCaptions, vttCue };
@@ -0,0 +1,46 @@
1
+ //#region src/kernel/sinks/native-sync.ts
2
+ /** Starts the sync; returns its teardown. */
3
+ function syncNativeTracks(ctx, sync) {
4
+ const activeId = () => ctx.getState().tracks.active.get("text");
5
+ function mirror() {
6
+ var _sync$before;
7
+ (_sync$before = sync.before) === null || _sync$before === void 0 || _sync$before.call(sync);
8
+ const active = activeId();
9
+ for (const track of sync.tracks()) {
10
+ const showing = track.id === active;
11
+ const native = sync.native(track, showing);
12
+ if (native === null) continue;
13
+ const mode = showing ? "showing" : sync.idle;
14
+ if (native.mode !== mode) native.mode = mode;
15
+ }
16
+ }
17
+ function onNativeChange() {
18
+ const active = activeId();
19
+ const tracks = sync.tracks();
20
+ const showing = tracks.find((track) => {
21
+ var _sync$native;
22
+ return ((_sync$native = sync.native(track, false)) === null || _sync$native === void 0 ? void 0 : _sync$native.mode) === "showing";
23
+ });
24
+ if (showing !== void 0) {
25
+ if (showing.id !== active) ctx.dispatch({
26
+ type: "SELECT_TRACK",
27
+ trackId: showing.id
28
+ });
29
+ } else if (tracks.some((track) => track.id === active)) ctx.dispatch({
30
+ type: "DESELECT_TRACK",
31
+ contentType: "text"
32
+ });
33
+ }
34
+ const offChanged = ctx.on("tracks:changed", mirror);
35
+ const offSelected = ctx.on("tracks:selected", (payload) => {
36
+ if (payload.contentType === "text") mirror();
37
+ });
38
+ ctx.element.textTracks.addEventListener("change", onNativeChange);
39
+ return () => {
40
+ offChanged();
41
+ offSelected();
42
+ ctx.element.textTracks.removeEventListener("change", onNativeChange);
43
+ };
44
+ }
45
+ //#endregion
46
+ export { syncNativeTracks };
@@ -0,0 +1,64 @@
1
+ import { cueFormat } from "../mime.js";
2
+ import { createTextTrackSink } from "./text-track-sink.js";
3
+ import { syncNativeTracks } from "./native-sync.js";
4
+ //#region src/kernel/sinks/text-formats.ts
5
+ const shared = /* @__PURE__ */ new WeakMap();
6
+ /** The cue format of a text track: its MIME type, with the codec family in fMP4. */
7
+ function trackFormat(track) {
8
+ var _track$renditions$;
9
+ return cueFormat(track.mimeType, (_track$renditions$ = track.renditions[0]) === null || _track$renditions$ === void 0 ? void 0 : _track$renditions$.codecs);
10
+ }
11
+ /** Joins the stage to the element's text sink with its parsers. Returns the stage's teardown. */
12
+ function joinTextSink(ctx, parsers) {
13
+ const { element } = ctx;
14
+ let entry = shared.get(element);
15
+ const owner = entry === void 0;
16
+ if (entry === void 0) {
17
+ const map = /* @__PURE__ */ new Map();
18
+ const sink = createTextTrackSink({
19
+ element,
20
+ parse(data, meta) {
21
+ var _meta$format;
22
+ const parse = map.get((_meta$format = meta.format) !== null && _meta$format !== void 0 ? _meta$format : "text/vtt");
23
+ if (parse === void 0) throw new RangeError(`no parser for '${meta.format}'`);
24
+ return parse(data, meta);
25
+ }
26
+ });
27
+ entry = {
28
+ sink,
29
+ parsers: map
30
+ };
31
+ shared.set(element, entry);
32
+ ctx.registerSink("text", () => sink);
33
+ }
34
+ const { sink } = entry;
35
+ const formats = new Set(Object.keys(parsers));
36
+ for (const [format, parse] of Object.entries(parsers)) {
37
+ entry.parsers.set(format, parse);
38
+ ctx.registerParser(format, parse);
39
+ }
40
+ function texts() {
41
+ const presentation = ctx.getState().presentation;
42
+ if (presentation === null) return [];
43
+ return presentation.periods.flatMap((period) => period.tracks.filter((track) => track.contentType === "text"));
44
+ }
45
+ const stopSync = syncNativeTracks(ctx, {
46
+ tracks: () => texts().filter((track) => formats.has(trackFormat(track))),
47
+ native: (track) => sink.declare(track.id),
48
+ idle: "disabled",
49
+ before() {
50
+ const current = new Set(texts().map((track) => track.id));
51
+ for (const id of sink.trackIds()) if (!current.has(id)) sink.retire(id);
52
+ }
53
+ });
54
+ return () => {
55
+ stopSync();
56
+ for (const format of formats) entry.parsers.delete(format);
57
+ if (owner) {
58
+ sink.dispose();
59
+ shared.delete(element);
60
+ }
61
+ };
62
+ }
63
+ //#endregion
64
+ export { joinTextSink, trackFormat };