mattebox 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (362) 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 +39 -14
  115. package/dist/es2015/kernel/append-queue.js +1 -1
  116. package/dist/es2015/kernel/base64.js +14 -3
  117. package/dist/es2015/kernel/bus.js +11 -8
  118. package/dist/es2015/kernel/context.js +5 -0
  119. package/dist/es2015/kernel/lifecycle.js +1 -0
  120. package/dist/es2015/kernel/loader.js +2 -2
  121. package/dist/es2015/kernel/mime.js +12 -1
  122. package/dist/es2015/kernel/mse.js +39 -5
  123. package/dist/es2015/kernel/prepare.js +2 -2
  124. package/dist/es2015/kernel/reducer.js +74 -20
  125. package/dist/es2015/kernel/refresh.js +2 -2
  126. package/dist/es2015/kernel/rendition-select.js +2 -1
  127. package/dist/es2015/kernel/scheduler.js +1 -1
  128. package/dist/es2015/kernel/sinks/caption-tracks.js +82 -0
  129. package/dist/es2015/kernel/sinks/native-sync.js +46 -0
  130. package/dist/es2015/kernel/sinks/text-formats.js +64 -0
  131. package/dist/es2015/kernel/sinks/text-track-sink.js +15 -4
  132. package/dist/es2015/kernel/timeline.js +12 -8
  133. package/dist/es2015/kernel/trace.js +1 -1
  134. package/dist/es2015/kernel/track-registry.js +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 +356 -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 +109 -30
  146. package/dist/es2015/protocols/hls-cmaf/unavailable.js +37 -6
  147. package/dist/es2015/protocols/hls-live/index.js +36 -10
  148. package/dist/es2015/stages/abr/index.js +10 -5
  149. package/dist/es2015/stages/abr-persist/index.js +1 -1
  150. package/dist/es2015/stages/aes-128/index.js +1 -1
  151. package/dist/es2015/stages/chapters/index.js +2 -2
  152. package/dist/es2015/stages/chapters/parse.js +2 -2
  153. package/dist/es2015/stages/cmcd/index.js +30 -3
  154. package/dist/es2015/stages/cmsd/index.js +72 -0
  155. package/dist/es2015/stages/codec-probe/index.js +28 -3
  156. package/dist/es2015/stages/content-steering/index.js +1 -1
  157. package/dist/es2015/stages/eme-core/index.js +22 -2
  158. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  159. package/dist/es2015/stages/hdr/index.js +214 -0
  160. package/dist/es2015/stages/meta-id3/index.js +6 -1
  161. package/dist/es2015/stages/qoe/index.js +111 -0
  162. package/dist/es2015/stages/recovery/index.js +1 -1
  163. package/dist/es2015/stages/rendition-names/index.js +101 -0
  164. package/dist/es2015/stages/text-cea608/decode.js +56 -5
  165. package/dist/es2015/stages/text-cea608/index.js +26 -93
  166. package/dist/es2015/stages/text-cea708/decode.js +377 -0
  167. package/dist/es2015/stages/text-cea708/index.js +98 -0
  168. package/dist/es2015/stages/text-ttml/index.js +88 -0
  169. package/dist/es2015/stages/text-ttml/parse.js +255 -0
  170. package/dist/es2015/stages/text-webvtt/index.js +30 -65
  171. package/dist/es2015/stages/thumbnails/index.js +1 -1
  172. package/dist/es2015/stages/timed-metadata/index.js +331 -0
  173. package/dist/es2015/stages/trick-play/index.js +3 -2
  174. package/dist/index.d.ts +1 -1
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +40 -13
  177. package/dist/index.js.map +1 -1
  178. package/dist/kernel/base64.d.ts +7 -2
  179. package/dist/kernel/base64.d.ts.map +1 -1
  180. package/dist/kernel/base64.js +14 -2
  181. package/dist/kernel/base64.js.map +1 -1
  182. package/dist/kernel/bus.d.ts.map +1 -1
  183. package/dist/kernel/bus.js +12 -9
  184. package/dist/kernel/bus.js.map +1 -1
  185. package/dist/kernel/context.d.ts +3 -1
  186. package/dist/kernel/context.d.ts.map +1 -1
  187. package/dist/kernel/context.js +5 -0
  188. package/dist/kernel/context.js.map +1 -1
  189. package/dist/kernel/lifecycle.d.ts +3 -1
  190. package/dist/kernel/lifecycle.d.ts.map +1 -1
  191. package/dist/kernel/lifecycle.js +1 -0
  192. package/dist/kernel/lifecycle.js.map +1 -1
  193. package/dist/kernel/loader.d.ts.map +1 -1
  194. package/dist/kernel/loader.js +3 -2
  195. package/dist/kernel/loader.js.map +1 -1
  196. package/dist/kernel/mime.d.ts +7 -0
  197. package/dist/kernel/mime.d.ts.map +1 -1
  198. package/dist/kernel/mime.js +12 -0
  199. package/dist/kernel/mime.js.map +1 -1
  200. package/dist/kernel/mse.d.ts.map +1 -1
  201. package/dist/kernel/mse.js +37 -2
  202. package/dist/kernel/mse.js.map +1 -1
  203. package/dist/kernel/reducer.d.ts.map +1 -1
  204. package/dist/kernel/reducer.js +77 -8
  205. package/dist/kernel/reducer.js.map +1 -1
  206. package/dist/kernel/refresh.d.ts.map +1 -1
  207. package/dist/kernel/refresh.js +1 -0
  208. package/dist/kernel/refresh.js.map +1 -1
  209. package/dist/kernel/rendition-select.d.ts.map +1 -1
  210. package/dist/kernel/rendition-select.js +4 -2
  211. package/dist/kernel/rendition-select.js.map +1 -1
  212. package/dist/kernel/sinks/caption-tracks.d.ts +11 -0
  213. package/dist/kernel/sinks/caption-tracks.d.ts.map +1 -0
  214. package/dist/kernel/sinks/caption-tracks.js +87 -0
  215. package/dist/kernel/sinks/caption-tracks.js.map +1 -0
  216. package/dist/kernel/sinks/native-sync.d.ts +24 -0
  217. package/dist/kernel/sinks/native-sync.d.ts.map +1 -0
  218. package/dist/kernel/sinks/native-sync.js +42 -0
  219. package/dist/kernel/sinks/native-sync.js.map +1 -0
  220. package/dist/kernel/sinks/text-formats.d.ts +25 -0
  221. package/dist/kernel/sinks/text-formats.d.ts.map +1 -0
  222. package/dist/kernel/sinks/text-formats.js +69 -0
  223. package/dist/kernel/sinks/text-formats.js.map +1 -0
  224. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  225. package/dist/kernel/sinks/text-track-sink.js +22 -4
  226. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  227. package/dist/kernel/timeline.d.ts +10 -6
  228. package/dist/kernel/timeline.d.ts.map +1 -1
  229. package/dist/kernel/timeline.js +14 -6
  230. package/dist/kernel/timeline.js.map +1 -1
  231. package/dist/kernel/track-registry.d.ts +2 -2
  232. package/dist/kernel/track-registry.d.ts.map +1 -1
  233. package/dist/kernel/track-registry.js +5 -3
  234. package/dist/kernel/track-registry.js.map +1 -1
  235. package/dist/kernel/transport.d.ts +8 -0
  236. package/dist/kernel/transport.d.ts.map +1 -1
  237. package/dist/kernel/transport.js +28 -1
  238. package/dist/kernel/transport.js.map +1 -1
  239. package/dist/presets/full/index.d.ts.map +1 -1
  240. package/dist/presets/full/index.js +21 -1
  241. package/dist/presets/full/index.js.map +1 -1
  242. package/dist/protocols/adapter-shared.d.ts +8 -0
  243. package/dist/protocols/adapter-shared.d.ts.map +1 -1
  244. package/dist/protocols/adapter-shared.js +6 -0
  245. package/dist/protocols/adapter-shared.js.map +1 -1
  246. package/dist/protocols/dash-cmaf/index.d.ts +9 -1
  247. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  248. package/dist/protocols/dash-cmaf/index.js +78 -14
  249. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  250. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  251. package/dist/protocols/dash-cmaf/parse.js +368 -94
  252. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  253. package/dist/protocols/dash-cmaf/periods-runtime.d.ts +6 -0
  254. package/dist/protocols/dash-cmaf/periods-runtime.d.ts.map +1 -0
  255. package/dist/protocols/dash-cmaf/periods-runtime.js +121 -0
  256. package/dist/protocols/dash-cmaf/periods-runtime.js.map +1 -0
  257. package/dist/protocols/dash-cmaf/periods.d.ts +24 -0
  258. package/dist/protocols/dash-cmaf/periods.d.ts.map +1 -0
  259. package/dist/protocols/dash-cmaf/periods.js +210 -0
  260. package/dist/protocols/dash-cmaf/periods.js.map +1 -0
  261. package/dist/protocols/hls-cmaf/index.d.ts +9 -1
  262. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  263. package/dist/protocols/hls-cmaf/index.js +49 -20
  264. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  265. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  266. package/dist/protocols/hls-cmaf/lexer.js +1 -0
  267. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  268. package/dist/protocols/hls-cmaf/parse.d.ts +3 -1
  269. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  270. package/dist/protocols/hls-cmaf/parse.js +137 -12
  271. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  272. package/dist/protocols/hls-cmaf/unavailable.d.ts +9 -1
  273. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
  274. package/dist/protocols/hls-cmaf/unavailable.js +29 -3
  275. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
  276. package/dist/protocols/hls-live/index.d.ts +9 -1
  277. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  278. package/dist/protocols/hls-live/index.js +36 -7
  279. package/dist/protocols/hls-live/index.js.map +1 -1
  280. package/dist/stages/abr/index.d.ts.map +1 -1
  281. package/dist/stages/abr/index.js +10 -6
  282. package/dist/stages/abr/index.js.map +1 -1
  283. package/dist/stages/cmcd/index.d.ts.map +1 -1
  284. package/dist/stages/cmcd/index.js +39 -3
  285. package/dist/stages/cmcd/index.js.map +1 -1
  286. package/dist/stages/cmsd/index.d.ts +22 -0
  287. package/dist/stages/cmsd/index.d.ts.map +1 -0
  288. package/dist/stages/cmsd/index.js +65 -0
  289. package/dist/stages/cmsd/index.js.map +1 -0
  290. package/dist/stages/codec-probe/index.d.ts.map +1 -1
  291. package/dist/stages/codec-probe/index.js +30 -3
  292. package/dist/stages/codec-probe/index.js.map +1 -1
  293. package/dist/stages/eme-core/index.d.ts +7 -0
  294. package/dist/stages/eme-core/index.d.ts.map +1 -1
  295. package/dist/stages/eme-core/index.js +26 -0
  296. package/dist/stages/eme-core/index.js.map +1 -1
  297. package/dist/stages/hdr/index.d.ts +22 -0
  298. package/dist/stages/hdr/index.d.ts.map +1 -0
  299. package/dist/stages/hdr/index.js +191 -0
  300. package/dist/stages/hdr/index.js.map +1 -0
  301. package/dist/stages/meta-id3/index.d.ts.map +1 -1
  302. package/dist/stages/meta-id3/index.js +6 -2
  303. package/dist/stages/meta-id3/index.js.map +1 -1
  304. package/dist/stages/qoe/index.d.ts +32 -0
  305. package/dist/stages/qoe/index.d.ts.map +1 -0
  306. package/dist/stages/qoe/index.js +116 -0
  307. package/dist/stages/qoe/index.js.map +1 -0
  308. package/dist/stages/rendition-names/index.d.ts +41 -0
  309. package/dist/stages/rendition-names/index.d.ts.map +1 -0
  310. package/dist/stages/rendition-names/index.js +101 -0
  311. package/dist/stages/rendition-names/index.js.map +1 -0
  312. package/dist/stages/text-cea608/decode.d.ts +23 -2
  313. package/dist/stages/text-cea608/decode.d.ts.map +1 -1
  314. package/dist/stages/text-cea608/decode.js +55 -5
  315. package/dist/stages/text-cea608/decode.js.map +1 -1
  316. package/dist/stages/text-cea608/index.d.ts +9 -9
  317. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  318. package/dist/stages/text-cea608/index.js +31 -105
  319. package/dist/stages/text-cea608/index.js.map +1 -1
  320. package/dist/stages/text-cea708/decode.d.ts +79 -0
  321. package/dist/stages/text-cea708/decode.d.ts.map +1 -0
  322. package/dist/stages/text-cea708/decode.js +404 -0
  323. package/dist/stages/text-cea708/decode.js.map +1 -0
  324. package/dist/stages/text-cea708/index.d.ts +3 -0
  325. package/dist/stages/text-cea708/index.d.ts.map +1 -0
  326. package/dist/stages/text-cea708/index.js +93 -0
  327. package/dist/stages/text-cea708/index.js.map +1 -0
  328. package/dist/stages/text-ttml/index.d.ts +3 -0
  329. package/dist/stages/text-ttml/index.d.ts.map +1 -0
  330. package/dist/stages/text-ttml/index.js +74 -0
  331. package/dist/stages/text-ttml/index.js.map +1 -0
  332. package/dist/stages/text-ttml/parse.d.ts +16 -0
  333. package/dist/stages/text-ttml/parse.d.ts.map +1 -0
  334. package/dist/stages/text-ttml/parse.js +277 -0
  335. package/dist/stages/text-ttml/parse.js.map +1 -0
  336. package/dist/stages/text-webvtt/index.d.ts +6 -13
  337. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  338. package/dist/stages/text-webvtt/index.js +21 -68
  339. package/dist/stages/text-webvtt/index.js.map +1 -1
  340. package/dist/stages/timed-metadata/index.d.ts +15 -0
  341. package/dist/stages/timed-metadata/index.d.ts.map +1 -0
  342. package/dist/stages/timed-metadata/index.js +370 -0
  343. package/dist/stages/timed-metadata/index.js.map +1 -0
  344. package/dist/types/error.d.ts +1 -1
  345. package/dist/types/error.d.ts.map +1 -1
  346. package/dist/types/facade.d.ts +8 -10
  347. package/dist/types/facade.d.ts.map +1 -1
  348. package/dist/types/ir.d.ts +65 -0
  349. package/dist/types/ir.d.ts.map +1 -1
  350. package/dist/types/kernel.d.ts +8 -0
  351. package/dist/types/kernel.d.ts.map +1 -1
  352. package/dist/types/messages.d.ts +10 -1
  353. package/dist/types/messages.d.ts.map +1 -1
  354. package/dist/types/metadata.d.ts +59 -0
  355. package/dist/types/metadata.d.ts.map +1 -0
  356. package/dist/types/metadata.js +7 -0
  357. package/dist/types/metadata.js.map +1 -0
  358. package/dist/types/quality.d.ts +3 -0
  359. package/dist/types/quality.d.ts.map +1 -1
  360. package/dist/types/stage.d.ts +17 -0
  361. package/dist/types/stage.d.ts.map +1 -1
  362. package/package.json +10 -2
@@ -0,0 +1,98 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { registerCaptionConsumer } from "../../containers/captions.js";
3
+ import { inbandCaptions, vttCue } from "../../kernel/sinks/caption-tracks.js";
4
+ import { Dtvcc } from "./decode.js";
5
+ //#region src/stages/text-cea708/index.ts
6
+ /**
7
+ * CEA-708 in-band captions as a stage. It registers a caption consumer
8
+ * beside text-cea608's, and reads the DTVCC triples (cc_type 2 and 3) that
9
+ * stage leaves. Each service is a text track like any subtitle: HLS
10
+ * `INSTREAM-ID="SERVICEn"`, DASH `urn:scte:dash:cc:cea-708:2015`, or a track
11
+ * added on the service's first cue (`cea708:SERVICEn`).
12
+ *
13
+ * Each visible window becomes a VTTCue on the service's native caption
14
+ * track, labelled SERVICEn. The window's anchor maps to `line` and
15
+ * `position`, its anchor point to `lineAlign` and `positionAlign`, its
16
+ * column count to `size`, its justification to `align`, and the pen's
17
+ * italics and underline to `<i>` and `<u>`. Colors, opacities, edges, and
18
+ * fonts are not mapped: a VTTCue carries no color without page CSS. The cue
19
+ * keeps the window layout in a `cea708` property the browser ignores, for a
20
+ * player that draws captions itself.
21
+ */
22
+ const MIME = "application/cea-708";
23
+ const ALIGN = [
24
+ "left",
25
+ "right",
26
+ "center",
27
+ "left"
28
+ ];
29
+ const LINE_ALIGN = [
30
+ "start",
31
+ "center",
32
+ "end"
33
+ ];
34
+ const POSITION_ALIGN = [
35
+ "line-left",
36
+ "center",
37
+ "line-right"
38
+ ];
39
+ /**
40
+ * Places the cue where its window sits (§8.4). Relative anchors are percent;
41
+ * absolute ones are cells of a 75-row grid, 210 columns wide at 16:9 and 160
42
+ * at 4:3. A browser that rejects a value keeps its default for it.
43
+ */
44
+ function place(target, cue, wide) {
45
+ const placed = target;
46
+ const { layout } = cue;
47
+ const across = wide ? 210 : 160;
48
+ const line = layout.relative ? layout.anchorVertical : layout.anchorVertical / 75 * 100;
49
+ const position = layout.relative ? layout.anchorHorizontal : layout.anchorHorizontal / across * 100;
50
+ const settings = [
51
+ ["snapToLines", false],
52
+ ["line", Math.min(100, line)],
53
+ ["position", Math.min(100, position)],
54
+ ["size", Math.min(100, layout.columns / (wide ? 42 : 32) * 100)],
55
+ ["align", ALIGN[layout.justify]],
56
+ ["lineAlign", LINE_ALIGN[Math.floor(layout.anchorPoint / 3)]],
57
+ ["positionAlign", POSITION_ALIGN[layout.anchorPoint % 3]]
58
+ ];
59
+ for (const [key, value] of settings) try {
60
+ placed[key] = value;
61
+ } catch (_unused) {}
62
+ placed.cea708 = _objectSpread2({ window: cue.window }, layout);
63
+ }
64
+ function textCea708() {
65
+ return {
66
+ name: "text-cea708",
67
+ provides: ["text-cea708", {
68
+ contentType: "text",
69
+ mimeType: MIME
70
+ }],
71
+ requires: [["nal-scan", "ts-transmux"]],
72
+ install(ctx) {
73
+ const dtvcc = new Dtvcc();
74
+ const captions = inbandCaptions(ctx, MIME, "cea708");
75
+ const unregister = registerCaptionConsumer((packets) => {
76
+ for (const packet of packets) for (const triple of packet.triples) if (triple.type >= 2) dtvcc.push(triple.type, triple.a, triple.b, packet.time);
77
+ const video = ctx.element;
78
+ const wide = !(video.videoHeight > 0 && video.videoWidth / video.videoHeight < 1.5);
79
+ for (const [service, cues] of dtvcc.drain()) {
80
+ const native = [];
81
+ for (const cue of cues) {
82
+ const made = vttCue(cue.start, cue.end, cue.text);
83
+ if (made === null) continue;
84
+ place(made, cue, wide);
85
+ native.push(made);
86
+ }
87
+ captions.show(`SERVICE${service}`, native);
88
+ }
89
+ });
90
+ return () => {
91
+ unregister();
92
+ captions.dispose();
93
+ };
94
+ }
95
+ };
96
+ }
97
+ //#endregion
98
+ export { textCea708 as default };
@@ -0,0 +1,88 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { findRendition } from "../../kernel/presentation.js";
3
+ import { segmentAt } from "../../kernel/timeline.js";
4
+ import { timedSamples, trackTimescales } from "../../containers/mp4-box/index.js";
5
+ import { joinTextSink } from "../../kernel/sinks/text-formats.js";
6
+ import { parseTtml } from "./parse.js";
7
+ //#region src/stages/text-ttml/index.ts
8
+ /**
9
+ * TTML subtitles as a stage, for the IMSC1 Text Profile and EBU-TT-D. It
10
+ * joins the one text sink with two formats:
11
+ *
12
+ * - `application/ttml+xml`: a whole document per segment, a sidecar for the
13
+ * period or one file per segment, timed on the presentation timeline.
14
+ * - `application/mp4;stpp`: TTML in fMP4 (ISO/IEC 14496-30), one document
15
+ * per sample. The document's times are on the track's media timeline, so
16
+ * they map through the segment's decode time, which lands at the
17
+ * segment's start. Some packagers time each document from its sample's
18
+ * start instead; a document whose times fall before its sample is read
19
+ * that way.
20
+ *
21
+ * Italics, bold, and underline show; the region places the cue. Colors do
22
+ * not: a VTTCue carries them only through page CSS, which the engine does
23
+ * not write. Each cue's `payload` holds its resolved styles, for a player
24
+ * that draws captions itself.
25
+ */
26
+ const TTML = "application/ttml+xml";
27
+ /** The cues with open ends closed at `end`, and an id for each, so a refetched segment adds nothing twice. */
28
+ function finish(cues, shift, end) {
29
+ return cues.map((cue) => {
30
+ const start = cue.start + shift;
31
+ const stop = Math.min(cue.end + shift, end);
32
+ return _objectSpread2(_objectSpread2({}, cue), {}, {
33
+ id: `${start.toFixed(3)}|${stop.toFixed(3)}|${cue.text}`,
34
+ start,
35
+ end: stop
36
+ });
37
+ });
38
+ }
39
+ function textTtml() {
40
+ return {
41
+ name: "text-ttml",
42
+ provides: [
43
+ "text-ttml",
44
+ {
45
+ contentType: "text",
46
+ mimeType: TTML
47
+ },
48
+ {
49
+ contentType: "text",
50
+ mimeType: "application/mp4",
51
+ codecs: "stpp"
52
+ }
53
+ ],
54
+ requires: ["scheduler"],
55
+ install(ctx) {
56
+ const timescales = /* @__PURE__ */ new Map();
57
+ function parseStpp(data, meta) {
58
+ if (meta.isInit) {
59
+ timescales.set(meta.renditionId, trackTimescales(data));
60
+ return [];
61
+ }
62
+ const cues = [];
63
+ for (const sample of timedSamples(data, timescales.get(meta.renditionId), meta.start)) {
64
+ const parsed = parseTtml(new TextDecoder().decode(sample.bytes));
65
+ const relative = parsed.some((cue) => cue.start + sample.shift < sample.start - .5);
66
+ cues.push(...finish(parsed, relative ? sample.start : sample.shift, sample.end));
67
+ }
68
+ return cues;
69
+ }
70
+ /**
71
+ * A whole document, timed on the presentation timeline, or from its
72
+ * DASH period's start when the segment carries that offset.
73
+ */
74
+ function parseDocument(data, meta) {
75
+ var _segmentAt;
76
+ const site = findRendition(ctx.getState().presentation, meta.renditionId);
77
+ const offset = site === null ? void 0 : (_segmentAt = segmentAt(site.rendition.segments, meta.seq, site.period.start)) === null || _segmentAt === void 0 ? void 0 : _segmentAt.timeOffset;
78
+ return finish(parseTtml(new TextDecoder().decode(data)), offset !== null && offset !== void 0 ? offset : 0, meta.start + meta.duration);
79
+ }
80
+ return joinTextSink(ctx, {
81
+ [TTML]: parseDocument,
82
+ "application/mp4;stpp": parseStpp
83
+ });
84
+ }
85
+ };
86
+ }
87
+ //#endregion
88
+ export { textTtml as default };
@@ -0,0 +1,255 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { escapeCueText } from "../../containers/webvtt.js";
3
+ //#region src/stages/text-ttml/parse.ts
4
+ /**
5
+ * TTML to cues, for the IMSC1 Text Profile (W3C IMSC 1.0.1 to 1.2), which
6
+ * EBU-TT-D documents also conform to. It reads `tt`, `head` (styling and
7
+ * layout), `body`, `div`, `p`, `span`, and `br`, the timing attributes, the
8
+ * styles a cue can show, and the region a `p` is flowed into. Anything else
9
+ * is ignored, so a richer document still shows its text.
10
+ *
11
+ * Times come back in document time; `Infinity` marks an end the document
12
+ * leaves open, for the caller to close at its segment's end.
13
+ */
14
+ const TTP = "http://www.w3.org/ns/ttml#parameter";
15
+ const TTS = "http://www.w3.org/ns/ttml#styling";
16
+ const XML = "http://www.w3.org/XML/1998/namespace";
17
+ /** The styles kept: what a cue shows, and what the raw form carries for a page. */
18
+ const STYLES = [
19
+ "fontStyle",
20
+ "fontWeight",
21
+ "textDecoration",
22
+ "textAlign",
23
+ "color",
24
+ "backgroundColor",
25
+ "displayAlign",
26
+ "origin",
27
+ "extent"
28
+ ];
29
+ /** Region-only styles do not pass from a region or a parent to its content. */
30
+ const NOT_INHERITED = /* @__PURE__ */ new Set([
31
+ "backgroundColor",
32
+ "displayAlign",
33
+ "origin",
34
+ "extent"
35
+ ]);
36
+ function attrNS(element, ns, prefix, name) {
37
+ var _element$getAttribute;
38
+ return (_element$getAttribute = element.getAttributeNS(ns, name)) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : element.getAttribute(`${prefix}:${name}`);
39
+ }
40
+ function childElements(element, name) {
41
+ return [...element.children].filter((child) => name === void 0 || child.localName === name);
42
+ }
43
+ /**
44
+ * A TTML time expression in seconds (TTML2 §10.3.1): clock time
45
+ * `hh:mm:ss.fff` or `hh:mm:ss:ff.sub`, or an offset `12.5s`, `250ms`, `2m`,
46
+ * `1h`, `30f`, `100t`. Null for anything else.
47
+ */
48
+ function parseTime(value, rates) {
49
+ if (value === null) return null;
50
+ const text = value.trim();
51
+ const clock = /^(\d+):(\d\d):(\d\d)(?:(\.\d+)|:(\d+)(?:\.(\d+))?)?$/.exec(text);
52
+ if (clock !== null) {
53
+ const [, h, m, s, fraction, frames, sub] = clock;
54
+ return Number(h) * 3600 + Number(m) * 60 + Number(s) + (fraction !== void 0 ? Number(fraction) : 0) + (frames !== void 0 ? Number(frames) / rates.frame : 0) + (sub !== void 0 ? Number(sub) / (rates.frame * rates.subFrame) : 0);
55
+ }
56
+ const offset = /^(\d+(?:\.\d+)?)(h|ms|m|s|f|t)$/.exec(text);
57
+ if (offset === null) return null;
58
+ const units = {
59
+ h: 3600,
60
+ m: 60,
61
+ s: 1,
62
+ ms: .001,
63
+ f: 1 / rates.frame,
64
+ t: 1 / rates.tick
65
+ };
66
+ return Number(offset[1]) * units[offset[2]];
67
+ }
68
+ /** The frame, sub-frame, and tick rates the root declares (TTML2 §7.2). */
69
+ function ratesOf(tt) {
70
+ var _attrNS, _attrNS2, _attrNS3;
71
+ const declared = attrNS(tt, TTP, "ttp", "frameRate");
72
+ const [num, den] = ((_attrNS = attrNS(tt, TTP, "ttp", "frameRateMultiplier")) !== null && _attrNS !== void 0 ? _attrNS : "1 1").split(/\s+/);
73
+ const frame = Number(declared !== null && declared !== void 0 ? declared : 30) * (Number(num) / Number(den) || 1);
74
+ const subFrame = Number((_attrNS2 = attrNS(tt, TTP, "ttp", "subFrameRate")) !== null && _attrNS2 !== void 0 ? _attrNS2 : 1);
75
+ return {
76
+ frame,
77
+ subFrame,
78
+ tick: Number((_attrNS3 = attrNS(tt, TTP, "ttp", "tickRate")) !== null && _attrNS3 !== void 0 ? _attrNS3 : declared !== null ? frame * subFrame : 1)
79
+ };
80
+ }
81
+ function inlineStyle(element) {
82
+ const style = {};
83
+ for (const key of STYLES) {
84
+ const value = attrNS(element, TTS, "tts", key);
85
+ if (value !== null) style[key] = value.trim();
86
+ }
87
+ return style;
88
+ }
89
+ /** A length as a percent of the root container: `%`, `px` against the root extent, `c` against the cell grid. */
90
+ function percent(value, axis, root, cells) {
91
+ const match = value === void 0 ? null : /^(-?[\d.]+)(%|px|c)$/.exec(value);
92
+ if (match === null) return null;
93
+ const n = Number(match[1]);
94
+ if (match[2] === "%") return n;
95
+ const whole = match[2] === "px" ? root[axis] : cells[axis];
96
+ return whole !== void 0 && whole > 0 ? n / whole * 100 : null;
97
+ }
98
+ /** WebVTT settings that put the cue where its region sits (IMSC1 §8, WebVTT §4.3). */
99
+ function settingsFor(style, root, cells) {
100
+ var _style$origin, _style$extent;
101
+ const origin = ((_style$origin = style.origin) !== null && _style$origin !== void 0 ? _style$origin : "").split(/\s+/);
102
+ const extent = ((_style$extent = style.extent) !== null && _style$extent !== void 0 ? _style$extent : "").split(/\s+/);
103
+ const x = percent(origin[0], 0, root, cells);
104
+ const y = percent(origin[1], 1, root, cells);
105
+ const w = percent(extent[0], 0, root, cells);
106
+ const h = percent(extent[1], 1, root, cells);
107
+ const out = [];
108
+ if (x !== null && w !== null) out.push(`position:${x + w / 2}%,center`, `size:${w}%`);
109
+ if (y !== null && h !== null) {
110
+ var _style$displayAlign;
111
+ const display = (_style$displayAlign = style.displayAlign) !== null && _style$displayAlign !== void 0 ? _style$displayAlign : "before";
112
+ out.push(display === "after" ? `line:${y + h}%,end` : display === "center" ? `line:${y + h / 2}%,center` : `line:${y}%,start`);
113
+ }
114
+ const align = style.textAlign;
115
+ if (align !== void 0 && [
116
+ "left",
117
+ "center",
118
+ "right",
119
+ "start",
120
+ "end"
121
+ ].includes(align)) out.push(`align:${align}`);
122
+ return out.join(" ");
123
+ }
124
+ /** The cues of a TTML document. Throws a RangeError for bytes that are not XML. */
125
+ function parseTtml(xml) {
126
+ var _attrNS4, _attrNS5;
127
+ const doc = new DOMParser().parseFromString(xml, "application/xml");
128
+ const tt = doc.documentElement;
129
+ if (tt === null || tt.localName !== "tt" || doc.getElementsByTagName("parsererror").length > 0) throw new RangeError("not a TTML document");
130
+ const timeBase = attrNS(tt, TTP, "ttp", "timeBase");
131
+ if (timeBase !== null && timeBase !== "media") return [];
132
+ const rates = ratesOf(tt);
133
+ const root = ((_attrNS4 = attrNS(tt, TTS, "tts", "extent")) !== null && _attrNS4 !== void 0 ? _attrNS4 : "").split(/\s+/).map((v) => Number.parseFloat(v));
134
+ const cells = ((_attrNS5 = attrNS(tt, TTP, "ttp", "cellResolution")) !== null && _attrNS5 !== void 0 ? _attrNS5 : "32 15").split(/\s+/).map(Number);
135
+ const styles = /* @__PURE__ */ new Map();
136
+ const regions = /* @__PURE__ */ new Map();
137
+ const head = childElements(tt, "head")[0];
138
+ for (const styling of head === void 0 ? [] : childElements(head, "styling")) for (const style of childElements(styling, "style")) styles.set(idOf(style), style);
139
+ for (const layout of head === void 0 ? [] : childElements(head, "layout")) for (const region of childElements(layout, "region")) regions.set(idOf(region), region);
140
+ function idOf(element) {
141
+ var _ref, _element$getAttribute2;
142
+ return (_ref = (_element$getAttribute2 = element.getAttributeNS(XML, "id")) !== null && _element$getAttribute2 !== void 0 ? _element$getAttribute2 : element.getAttribute("xml:id")) !== null && _ref !== void 0 ? _ref : "";
143
+ }
144
+ /** The style an element specifies: referenced styles in order, then nested and inline ones. */
145
+ function specified(element, seen = /* @__PURE__ */ new Set()) {
146
+ var _element$getAttribute3;
147
+ let style = {};
148
+ for (const ref of ((_element$getAttribute3 = element.getAttribute("style")) !== null && _element$getAttribute3 !== void 0 ? _element$getAttribute3 : "").split(/\s+/)) {
149
+ const referenced = styles.get(ref);
150
+ if (referenced === void 0 || seen.has(referenced)) continue;
151
+ seen.add(referenced);
152
+ style = _objectSpread2(_objectSpread2({}, style), specified(referenced, seen));
153
+ }
154
+ for (const nested of childElements(element, "style")) style = _objectSpread2(_objectSpread2({}, style), inlineStyle(nested));
155
+ return _objectSpread2(_objectSpread2({}, style), inlineStyle(element));
156
+ }
157
+ function inherit(parent) {
158
+ const out = {};
159
+ for (const key of STYLES) if (!NOT_INHERITED.has(key) && parent[key] !== void 0) out[key] = parent[key];
160
+ return out;
161
+ }
162
+ function interval(element, parent) {
163
+ const begin = parseTime(element.getAttribute("begin"), rates);
164
+ const end = parseTime(element.getAttribute("end"), rates);
165
+ const dur = parseTime(element.getAttribute("dur"), rates);
166
+ const start = parent[0] + (begin !== null && begin !== void 0 ? begin : 0);
167
+ let stop = parent[1];
168
+ if (end !== null) stop = Math.min(stop, parent[0] + end);
169
+ if (dur !== null) stop = Math.min(stop, start + dur);
170
+ return [start, stop];
171
+ }
172
+ /** The text runs of a p's content, each with its own active interval and markup. */
173
+ function runs(node, style, span, out) {
174
+ for (const child of node.childNodes) if (child.nodeType === 3) {
175
+ var _child$nodeValue, _style$textDecoration;
176
+ const text = ((_child$nodeValue = child.nodeValue) !== null && _child$nodeValue !== void 0 ? _child$nodeValue : "").replace(/[ \t\r\n]+/g, " ");
177
+ if (text === "") continue;
178
+ let markup = escapeCueText(text);
179
+ if (((_style$textDecoration = style.textDecoration) === null || _style$textDecoration === void 0 ? void 0 : _style$textDecoration.includes("underline")) === true) markup = `<u>${markup}</u>`;
180
+ if (style.fontWeight === "bold") markup = `<b>${markup}</b>`;
181
+ if (style.fontStyle === "italic" || style.fontStyle === "oblique") markup = `<i>${markup}</i>`;
182
+ out.push({
183
+ text: markup,
184
+ start: span[0],
185
+ end: span[1]
186
+ });
187
+ } else if (child.nodeType === 1) {
188
+ const element = child;
189
+ if (element.localName === "br") out.push({
190
+ text: "\n",
191
+ start: span[0],
192
+ end: span[1]
193
+ });
194
+ else if (element.localName === "span") runs(element, _objectSpread2(_objectSpread2({}, inherit(style)), specified(element)), interval(element, span), out);
195
+ }
196
+ }
197
+ const cues = [];
198
+ function cuesOf(p, style, span) {
199
+ const content = [];
200
+ runs(p, style, span, content);
201
+ const edges = [.../* @__PURE__ */ new Set([
202
+ span[0],
203
+ span[1],
204
+ ...content.flatMap((r) => [r.start, r.end])
205
+ ])].filter((t) => t >= span[0] && t <= span[1]).sort((a, b) => a - b);
206
+ const settings = settingsFor(style, root, cells);
207
+ const payload = Object.fromEntries(Object.entries(style));
208
+ for (let i = 0; i + 1 < edges.length; i += 1) {
209
+ const from = edges[i];
210
+ const to = edges[i + 1];
211
+ const text = content.filter((r) => r.start <= from && r.end >= to).map((r) => r.text).join("").split("\n").map((line) => line.trim()).join("\n").trim();
212
+ if (text === "") continue;
213
+ const last = cues[cues.length - 1];
214
+ if (last !== void 0 && last.end === from && last.text === text && last.settings === settings) {
215
+ cues[cues.length - 1] = _objectSpread2(_objectSpread2({}, last), {}, { end: to });
216
+ continue;
217
+ }
218
+ cues.push(_objectSpread2(_objectSpread2({
219
+ start: from,
220
+ end: to,
221
+ text
222
+ }, settings !== "" ? { settings } : {}), {}, { payload }));
223
+ }
224
+ }
225
+ /** Walks body and its divs, carrying timing, style, and region down to each p. */
226
+ function walk(element, parentStyle, region, span) {
227
+ var _element$getAttribute4;
228
+ const own = (_element$getAttribute4 = element.getAttribute("region")) !== null && _element$getAttribute4 !== void 0 ? _element$getAttribute4 : region;
229
+ const regionElement = own === null ? void 0 : regions.get(own);
230
+ const fromRegion = regionElement === void 0 ? {} : specified(regionElement);
231
+ const style = _objectSpread2(_objectSpread2(_objectSpread2({}, fromRegion), inherit(parentStyle)), specified(element));
232
+ const placed = _objectSpread2(_objectSpread2({}, style), pick(fromRegion));
233
+ const interval_ = interval(element, span);
234
+ if (element.localName === "p") {
235
+ cuesOf(element, placed, interval_);
236
+ return;
237
+ }
238
+ for (const child of childElements(element)) if (child.localName === "div" || child.localName === "p") walk(child, style, own, interval_);
239
+ }
240
+ function pick(style) {
241
+ const out = {};
242
+ for (const key of [
243
+ "origin",
244
+ "extent",
245
+ "displayAlign",
246
+ "backgroundColor"
247
+ ]) if (style[key] !== void 0) out[key] = style[key];
248
+ return out;
249
+ }
250
+ const body = childElements(tt, "body")[0];
251
+ if (body !== void 0) walk(body, {}, null, [0, Number.POSITIVE_INFINITY]);
252
+ return cues.sort((a, b) => a.start - b.start);
253
+ }
254
+ //#endregion
255
+ export { parseTime, parseTtml };
@@ -1,20 +1,15 @@
1
+ import { timedSamples, trackTimescales } from "../../containers/mp4-box/index.js";
1
2
  import { parseVtt } from "../../containers/webvtt.js";
2
- import { createTextTrackSink } from "../../kernel/sinks/text-track-sink.js";
3
+ import { wvttCues } from "../../containers/wvtt.js";
4
+ import { joinTextSink } from "../../kernel/sinks/text-formats.js";
3
5
  //#region src/stages/text-webvtt/index.ts
4
6
  /**
5
- * WebVTT as a stage: a parser for text/vtt and the text sink registration
6
- * that makes text tracks selectable. Cues become native VTTCues through the
7
- * kernel's TextTrackSink; the browser renders, styles, and exposes the
8
- * caption UI, which is why this stage stays small.
9
- *
10
- * The stage also keeps the element's TextTrackList and the engine's text
11
- * selection in step, both ways. Every text track exists natively from the
12
- * manifest on, so the browser's caption menu lists all of them; the active
13
- * one is `showing`, the rest `disabled`. A pick in that menu selects in the
14
- * engine, and switching captions off there deselects.
15
- *
16
- * It mirrors only its own format. In-band captions are text tracks too, and
17
- * text-cea608 mirrors those into the caption track it fills itself.
7
+ * WebVTT as a stage: the parsers for `text/vtt` files and for WebVTT in
8
+ * fMP4 (`wvtt`, ISO/IEC 14496-30), joined to the one text sink
9
+ * every subtitle format shares (`kernel/sinks/text-formats.ts`). Cues become
10
+ * native VTTCues; the browser renders, styles, and exposes the caption UI,
11
+ * which is why this stage stays small. It mirrors only its own format's
12
+ * tracks; the in-band caption stages fill caption tracks of their own.
18
13
  */
19
14
  const MIME = "text/vtt";
20
15
  function parseSegment(data, _meta) {
@@ -23,62 +18,32 @@ function parseSegment(data, _meta) {
23
18
  function textWebvtt() {
24
19
  return {
25
20
  name: "text-webvtt",
26
- provides: ["text-webvtt", {
27
- contentType: "text",
28
- mimeType: MIME
29
- }],
21
+ provides: [
22
+ "text-webvtt",
23
+ {
24
+ contentType: "text",
25
+ mimeType: MIME
26
+ },
27
+ {
28
+ contentType: "text",
29
+ mimeType: "application/mp4",
30
+ codecs: "wvtt"
31
+ }
32
+ ],
30
33
  requires: ["scheduler"],
31
34
  install(ctx) {
32
- const { element } = ctx;
33
- const sink = createTextTrackSink({
34
- element,
35
- parse: parseSegment
36
- });
37
- ctx.registerParser(MIME, parseSegment);
38
- ctx.registerSink("text", () => sink);
39
- function textTracks() {
40
- const presentation = ctx.getState().presentation;
41
- if (presentation === null) return [];
42
- return presentation.periods.flatMap((period) => period.tracks.filter((track) => track.contentType === "text" && track.mimeType === MIME));
43
- }
44
- function activeId() {
45
- return ctx.getState().tracks.active.get("text");
46
- }
47
- function mirror() {
48
- const active = activeId();
49
- const current = new Set(textTracks().map((track) => track.id));
50
- for (const id of sink.trackIds()) if (!current.has(id)) sink.retire(id);
51
- for (const track of textTracks()) {
52
- const native = sink.declare(track.id);
53
- const mode = track.id === active ? "showing" : "disabled";
54
- if (native.mode !== mode) native.mode = mode;
35
+ const timescales = /* @__PURE__ */ new Map();
36
+ function parseWvtt(data, meta) {
37
+ if (meta.isInit) {
38
+ timescales.set(meta.renditionId, trackTimescales(data));
39
+ return [];
55
40
  }
41
+ return wvttCues(timedSamples(data, timescales.get(meta.renditionId), meta.start));
56
42
  }
57
- function onNativeChange() {
58
- const active = activeId();
59
- const showing = textTracks().find((track) => {
60
- var _sink$nativeTrack;
61
- return ((_sink$nativeTrack = sink.nativeTrack(track.id)) === null || _sink$nativeTrack === void 0 ? void 0 : _sink$nativeTrack.mode) === "showing";
62
- });
63
- if (showing !== void 0) {
64
- if (showing.id !== active) ctx.dispatch({
65
- type: "SELECT_TRACK",
66
- trackId: showing.id
67
- });
68
- } else if (textTracks().some((track) => track.id === active)) ctx.dispatch({
69
- type: "DESELECT_TRACK",
70
- contentType: "text"
71
- });
72
- }
73
- ctx.on("tracks:changed", mirror);
74
- ctx.on("tracks:selected", (payload) => {
75
- if (payload.contentType === "text") mirror();
43
+ return joinTextSink(ctx, {
44
+ [MIME]: parseSegment,
45
+ "application/mp4;wvtt": parseWvtt
76
46
  });
77
- element.textTracks.addEventListener("change", onNativeChange);
78
- return () => {
79
- element.textTracks.removeEventListener("change", onNativeChange);
80
- sink.dispose();
81
- };
82
47
  }
83
48
  };
84
49
  }
@@ -1,6 +1,6 @@
1
1
  import { scheduled } from "../../kernel/effects.js";
2
2
  import { isIndexed, segmentAt, segmentAtTime } from "../../kernel/timeline.js";
3
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
3
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
4
4
  import { parseVtt } from "../../containers/webvtt.js";
5
5
  import { resolveUrl } from "../../kernel/url.js";
6
6
  //#region src/stages/thumbnails/index.ts