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,6 +1,6 @@
1
1
  import { concat } from "../fmp4/writer.js";
2
+ import { looksLikeTransportStream } from "./sniff.js";
2
3
  //#region src/containers/ts-transmux/demux.ts
3
- /** MPEG-TS stream_type values this transmuxer routes. */
4
4
  /**
5
5
  * MPEG-TS demux: 188-byte packets into PES payloads, grouped by elementary
6
6
  * stream. PAT names the PMT, the PMT names the elementary PIDs and their
@@ -9,8 +9,7 @@ import { concat } from "../fmp4/writer.js";
9
9
  * loop strictly advances, so a truncated or garbage segment returns what it
10
10
  * could parse rather than throwing or spinning.
11
11
  */
12
- const PACKET_SIZE = 188;
13
- const SYNC_BYTE = 71;
12
+ /** MPEG-TS stream_type values this transmuxer routes. */
14
13
  const STREAM_TYPE = {
15
14
  h264: 27,
16
15
  aacAdts: 15,
@@ -26,17 +25,6 @@ function kindOf(streamType) {
26
25
  if (streamType === STREAM_TYPE.metadata) return "id3";
27
26
  return null;
28
27
  }
29
- /** True when the buffer carries the TS sync byte at the packet cadence. */
30
- function looksLikeTransportStream(data) {
31
- if (data.byteLength < PACKET_SIZE) return false;
32
- let offset = 0;
33
- while (offset + PACKET_SIZE < data.byteLength) {
34
- if (data[offset] === SYNC_BYTE && data[offset + PACKET_SIZE] === SYNC_BYTE) return true;
35
- offset += 1;
36
- if (offset > PACKET_SIZE) return false;
37
- }
38
- return false;
39
- }
40
28
  /** Reads a 33-bit PTS/DTS field from a 5-byte PES timestamp region. */
41
29
  function readTimestamp(data, offset) {
42
30
  var _data$offset, _data, _data2, _data3, _data4;
@@ -96,11 +84,11 @@ function pmtPidOf(payload) {
96
84
  function programTables(data) {
97
85
  let pat = null;
98
86
  let pmtPid = null;
99
- for (let offset = 0; offset + PACKET_SIZE <= data.byteLength; offset += PACKET_SIZE) {
87
+ for (let offset = 0; offset + 188 <= data.byteLength; offset += 188) {
100
88
  var _data5, _data6;
101
- if (data[offset] !== SYNC_BYTE) return null;
89
+ if (data[offset] !== 71) return null;
102
90
  const pid = (((_data5 = data[offset + 1]) !== null && _data5 !== void 0 ? _data5 : 0) & 31) << 8 | ((_data6 = data[offset + 2]) !== null && _data6 !== void 0 ? _data6 : 0);
103
- const packet = data.subarray(offset, offset + PACKET_SIZE);
91
+ const packet = data.subarray(offset, offset + 188);
104
92
  if (pid === 0 && pat === null) {
105
93
  pat = packet;
106
94
  pmtPid = pmtPidOf(packet.subarray(4));
@@ -116,7 +104,7 @@ function demux(data) {
116
104
  notTransportStream: true
117
105
  };
118
106
  let base = 0;
119
- while (base < data.byteLength && data[base] !== SYNC_BYTE) base += 1;
107
+ while (base < data.byteLength && data[base] !== 71) base += 1;
120
108
  let pmtPid = -1;
121
109
  const streamTypes = /* @__PURE__ */ new Map();
122
110
  const accumulators = /* @__PURE__ */ new Map();
@@ -128,12 +116,12 @@ function demux(data) {
128
116
  if (packet !== null) completed.push(packet);
129
117
  accumulators.delete(pid);
130
118
  }
131
- for (let offset = base; offset + PACKET_SIZE <= data.byteLength; offset += PACKET_SIZE) {
119
+ for (let offset = base; offset + 188 <= data.byteLength; offset += 188) {
132
120
  var _data7, _data8, _data9;
133
- if (data[offset] !== SYNC_BYTE) {
121
+ if (data[offset] !== 71) {
134
122
  let resync = offset + 1;
135
- while (resync < data.byteLength && data[resync] !== SYNC_BYTE) resync += 1;
136
- offset = resync - PACKET_SIZE;
123
+ while (resync < data.byteLength && data[resync] !== 71) resync += 1;
124
+ offset = resync - 188;
137
125
  continue;
138
126
  }
139
127
  const b1 = (_data7 = data[offset + 1]) !== null && _data7 !== void 0 ? _data7 : 0;
@@ -149,8 +137,8 @@ function demux(data) {
149
137
  const adaptationLength = (_data$payloadOffset = data[payloadOffset]) !== null && _data$payloadOffset !== void 0 ? _data$payloadOffset : 0;
150
138
  payloadOffset += 1 + adaptationLength;
151
139
  }
152
- if (payloadOffset >= offset + PACKET_SIZE) continue;
153
- const payload = data.subarray(payloadOffset, offset + PACKET_SIZE);
140
+ if (payloadOffset >= offset + 188) continue;
141
+ const payload = data.subarray(payloadOffset, offset + 188);
154
142
  if (pid === 0) {
155
143
  var _pmtPidOf;
156
144
  pmtPid = (_pmtPidOf = pmtPidOf(payload)) !== null && _pmtPidOf !== void 0 ? _pmtPidOf : pmtPid;
@@ -1,4 +1,4 @@
1
- import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.js";
1
+ import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js";
2
2
  import { toRbsp } from "../sei.js";
3
3
  //#region src/containers/ts-transmux/h264.ts
4
4
  /**
@@ -1,7 +1,10 @@
1
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
2
- import { looksLikeTransportStream } from "./demux.js";
1
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
2
+ import { looksLikeTransportStream } from "./sniff.js";
3
+ import { id3Events } from "../id3.js";
4
+ import { deliverMetadata, metadataWanted } from "../metadata.js";
3
5
  import { captionsWanted, deliverCaptions } from "../captions.js";
4
6
  import { createTransmuxRunner } from "./runner.js";
7
+ import { transmuxSource } from "./source.js";
5
8
  //#region src/containers/ts-transmux/index.ts
6
9
  /** Runs after decrypt-class steps (lower order) and before caption extraction. */
7
10
  const TRANSMUX_ORDER = 100;
@@ -23,17 +26,22 @@ function tsTransmux(options = {}) {
23
26
  provides: ["ts-transmux", "media-transform"],
24
27
  requires: ["media-time-probe"],
25
28
  install(ctx) {
26
- const runner = createTransmuxRunner(options);
29
+ const runner = createTransmuxRunner(options, transmuxSource);
27
30
  let announcedDrop = false;
31
+ const parameterSets = /* @__PURE__ */ new Map();
28
32
  ctx.registerTransform({
29
33
  name: "ts-transmux",
30
34
  order: TRANSMUX_ORDER,
31
35
  transform(data, meta) {
32
36
  return _asyncToGenerator(function* () {
37
+ var _ctx$getState$present, _ctx$getState$present2, _parameterSets$get;
33
38
  if (meta.contentType !== "video" && meta.contentType !== "audio") return data;
34
39
  if (!looksLikeTransportStream(data)) return data;
35
- const result = yield runner.run(data, meta.start, captionsWanted(), tracksFor(ctx, meta));
40
+ const key = `${(_ctx$getState$present = (_ctx$getState$present2 = ctx.getState().presentation) === null || _ctx$getState$present2 === void 0 ? void 0 : _ctx$getState$present2.id) !== null && _ctx$getState$present !== void 0 ? _ctx$getState$present : ""}|${meta.renditionId}`;
41
+ const result = yield runner.run(data, meta.start, captionsWanted(), tracksFor(ctx, meta), (_parameterSets$get = parameterSets.get(key)) !== null && _parameterSets$get !== void 0 ? _parameterSets$get : null);
42
+ if (result.parameterSets !== null) parameterSets.set(key, result.parameterSets);
36
43
  if (result.captions.length > 0) deliverCaptions(result.captions);
44
+ if (result.metadata.length > 0 && metadataWanted()) deliverMetadata(id3Events(result.metadata));
37
45
  if (result.droppedAudio && !announcedDrop) {
38
46
  announcedDrop = true;
39
47
  ctx.emit("transmux:dropped-audio", {
@@ -1,27 +1,30 @@
1
- import { transmux } from "./transmux.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
2
3
  //#region src/containers/ts-transmux/runner.ts
3
- /**
4
- * The boundary between the transform step and where the demux actually runs.
5
- * A Worker keeps the hot path off the main thread; when the build cannot emit
6
- * a Worker chunk, or the environment has no Worker, or a custom-URL Worker
7
- * fails to start, the same pure transmux runs synchronously on the main
8
- * thread. Both paths call the identical function, so the bytes match whatever
9
- * route a given browser takes; only the timing differs.
10
- */
11
- function runOnMainThread(bytes, presentationStart, wantCaptions, tracks) {
12
- return transmux(bytes, presentationStart, wantCaptions, tracks);
13
- }
14
- function createTransmuxRunner(options = {}) {
4
+ function createTransmuxRunner(options, source) {
15
5
  let worker = null;
16
6
  let workerBroken = options.disableWorker === true;
17
7
  let lastPath = "main";
18
8
  let nextId = 1;
19
9
  const pending = /* @__PURE__ */ new Map();
10
+ let loaded = null;
11
+ /** The same pure function, on the main thread, loaded on first need. */
12
+ function runOnMainThread(_x) {
13
+ return _runOnMainThread.apply(this, arguments);
14
+ }
15
+ function _runOnMainThread() {
16
+ _runOnMainThread = _asyncToGenerator(function* (request) {
17
+ var _loaded;
18
+ (_loaded = loaded) !== null && _loaded !== void 0 || (loaded = source.load());
19
+ return (yield loaded)(request.bytes, request.presentationStart, request.wantCaptions, request.tracks, request.parameterSets);
20
+ });
21
+ return _runOnMainThread.apply(this, arguments);
22
+ }
20
23
  function ensureWorker() {
21
24
  if (workerBroken) return null;
22
25
  if (worker !== null) return worker;
23
26
  try {
24
- worker = options.workerUrl !== void 0 ? new Worker(options.workerUrl, { type: "module" }) : new Worker(new URL("./transmux.worker.js", import.meta.url), { type: "module" });
27
+ worker = options.workerUrl !== void 0 ? new Worker(options.workerUrl, { type: "module" }) : source.worker();
25
28
  worker.onmessage = (event) => {
26
29
  const entry = pending.get(event.data.id);
27
30
  if (entry === void 0) return;
@@ -31,7 +34,9 @@ function createTransmuxRunner(options = {}) {
31
34
  notTransportStream: event.data.notTransportStream,
32
35
  empty: event.data.bytes === null && !event.data.notTransportStream,
33
36
  captions: event.data.captions,
34
- droppedAudio: event.data.droppedAudio
37
+ metadata: event.data.metadata,
38
+ droppedAudio: event.data.droppedAudio,
39
+ parameterSets: event.data.parameterSets
35
40
  });
36
41
  };
37
42
  worker.onerror = () => {
@@ -39,7 +44,7 @@ function createTransmuxRunner(options = {}) {
39
44
  worker = null;
40
45
  for (const [id, entry] of pending) {
41
46
  pending.delete(id);
42
- entry.resolve(runOnMainThread(entry.bytes, entry.presentationStart, entry.wantCaptions, entry.tracks));
47
+ runOnMainThread(entry).then(entry.resolve);
43
48
  }
44
49
  };
45
50
  } catch (_unused) {
@@ -49,38 +54,40 @@ function createTransmuxRunner(options = {}) {
49
54
  return worker;
50
55
  }
51
56
  return {
52
- run(bytes, presentationStart, wantCaptions = false, tracks = "all") {
57
+ run(bytes, presentationStart, wantCaptions = false, tracks = "all", parameterSets = null) {
58
+ const request = {
59
+ bytes,
60
+ presentationStart,
61
+ wantCaptions,
62
+ tracks,
63
+ parameterSets
64
+ };
53
65
  const active = ensureWorker();
54
66
  if (active === null) {
55
67
  lastPath = "main";
56
- return Promise.resolve(runOnMainThread(bytes, presentationStart, wantCaptions, tracks));
68
+ return runOnMainThread(request);
57
69
  }
58
70
  lastPath = "worker";
59
71
  const id = nextId;
60
72
  nextId += 1;
61
73
  const copy = bytes.slice();
62
74
  return new Promise((resolve) => {
63
- pending.set(id, {
64
- resolve,
65
- bytes,
66
- presentationStart,
67
- wantCaptions,
68
- tracks
69
- });
75
+ pending.set(id, _objectSpread2({ resolve }, request));
70
76
  try {
71
77
  active.postMessage({
72
78
  id,
73
79
  bytes: copy.buffer,
74
80
  presentationStart,
75
81
  wantCaptions,
76
- tracks
82
+ tracks,
83
+ parameterSets
77
84
  }, [copy.buffer]);
78
85
  } catch (_unused2) {
79
86
  pending.delete(id);
80
87
  workerBroken = true;
81
88
  worker = null;
82
89
  lastPath = "main";
83
- resolve(runOnMainThread(bytes, presentationStart, wantCaptions, tracks));
90
+ runOnMainThread(request).then(resolve);
84
91
  }
85
92
  });
86
93
  },
@@ -0,0 +1,36 @@
1
+ import { transmux } from "./transmux.js";
2
+ //#region src/containers/ts-transmux/serve.ts
3
+ /** Answers transmux requests on a Worker's scope. */
4
+ function serveTransmux(scope) {
5
+ scope.onmessage = (event) => {
6
+ var _event$data$parameter;
7
+ const { id, bytes, presentationStart, wantCaptions, tracks = "all" } = event.data;
8
+ const result = transmux(new Uint8Array(bytes), presentationStart, wantCaptions, tracks, (_event$data$parameter = event.data.parameterSets) !== null && _event$data$parameter !== void 0 ? _event$data$parameter : null);
9
+ const out = result.bytes;
10
+ if (out === null) {
11
+ scope.postMessage({
12
+ id,
13
+ bytes: null,
14
+ notTransportStream: result.notTransportStream,
15
+ captions: [],
16
+ metadata: [],
17
+ droppedAudio: result.droppedAudio,
18
+ parameterSets: null
19
+ }, []);
20
+ return;
21
+ }
22
+ const buffer = new ArrayBuffer(out.byteLength);
23
+ new Uint8Array(buffer).set(out);
24
+ scope.postMessage({
25
+ id,
26
+ bytes: buffer,
27
+ notTransportStream: false,
28
+ captions: result.captions,
29
+ metadata: result.metadata,
30
+ droppedAudio: result.droppedAudio,
31
+ parameterSets: result.parameterSets
32
+ }, [buffer]);
33
+ };
34
+ }
35
+ //#endregion
36
+ export { serveTransmux };
@@ -0,0 +1,13 @@
1
+ /** True when the buffer carries the TS sync byte at the packet cadence. */
2
+ function looksLikeTransportStream(data) {
3
+ if (data.byteLength < 188) return false;
4
+ let offset = 0;
5
+ while (offset + 188 < data.byteLength) {
6
+ if (data[offset] === 71 && data[offset + 188] === 71) return true;
7
+ offset += 1;
8
+ if (offset > 188) return false;
9
+ }
10
+ return false;
11
+ }
12
+ //#endregion
13
+ export { looksLikeTransportStream };
@@ -0,0 +1,7 @@
1
+ //#region src/containers/ts-transmux/source.ts
2
+ const transmuxSource = {
3
+ load: () => import("./transmux.js").then((module) => module.transmux),
4
+ worker: () => new Worker(new URL("./transmux.worker.js", import.meta.url), { type: "module" })
5
+ };
6
+ //#endregion
7
+ export { transmuxSource };
@@ -21,6 +21,27 @@ const VIDEO_TRACK_ID = 1;
21
21
  const AUDIO_TRACK_ID = 2;
22
22
  /** Fallback duration for a lone trailing video sample: 30 fps in 90 kHz. */
23
23
  const DEFAULT_FRAME_DURATION = 3e3;
24
+ const PTS_WRAP = Math.pow(2, 33);
25
+ /**
26
+ * The metadata stream's tags on the presentation timeline. The first video
27
+ * DTS (or audio PTS) sits at `presentationStart`, so each tag keeps its
28
+ * distance from it, across a 33-bit PTS wrap. The bytes are copied so a Worker posts only the
29
+ * tag, not the segment it was cut from.
30
+ */
31
+ function timedTags(streams, presentationStart, anchor) {
32
+ const tags = [];
33
+ for (const packet of streams.id3) {
34
+ if (packet.pts === null || anchor === null) continue;
35
+ let delta = (packet.pts - anchor) % PTS_WRAP;
36
+ if (delta > PTS_WRAP / 2) delta -= PTS_WRAP;
37
+ else if (delta < -PTS_WRAP / 2) delta += PTS_WRAP;
38
+ tags.push({
39
+ time: presentationStart + delta / VIDEO_TIMESCALE,
40
+ bytes: packet.data.slice()
41
+ });
42
+ }
43
+ return tags;
44
+ }
24
45
  /**
25
46
  * Reframes video access units. Access units do not align with PES packet
26
47
  * boundaries in the wild: a picture's tail spills into the next PES packet,
@@ -74,7 +95,8 @@ function frameAccessUnits(packets) {
74
95
  flush();
75
96
  return framed;
76
97
  }
77
- function buildVideo(packets, presentationStart, wantCaptions) {
98
+ function buildVideo(packets, presentationStart, wantCaptions, carried) {
99
+ var _ref, _sps, _ref2, _pps;
78
100
  if (packets.length === 0) return null;
79
101
  const framed = frameAccessUnits(packets);
80
102
  const units = framed.map((f) => f.unit);
@@ -84,6 +106,8 @@ function buildVideo(packets, presentationStart, wantCaptions) {
84
106
  if (unit.sps !== null) sps = unit.sps;
85
107
  if (unit.pps !== null) pps = unit.pps;
86
108
  }
109
+ sps = (_ref = (_sps = sps) !== null && _sps !== void 0 ? _sps : carried === null || carried === void 0 ? void 0 : carried.sps) !== null && _ref !== void 0 ? _ref : null;
110
+ pps = (_ref2 = (_pps = pps) !== null && _pps !== void 0 ? _pps : carried === null || carried === void 0 ? void 0 : carried.pps) !== null && _ref2 !== void 0 ? _ref2 : null;
87
111
  if (sps === null || pps === null) return null;
88
112
  const dts = unrollTimestamps(framed.map((f) => f.dts));
89
113
  const pts = unrollTimestamps(framed.map((f) => f.pts));
@@ -130,7 +154,11 @@ function buildVideo(packets, presentationStart, wantCaptions) {
130
154
  baseMediaDecodeTime: base,
131
155
  samples
132
156
  },
133
- captions
157
+ captions,
158
+ parameterSets: {
159
+ sps,
160
+ pps
161
+ }
134
162
  };
135
163
  }
136
164
  function buildAudio(packets, presentationStart) {
@@ -139,17 +167,19 @@ function buildAudio(packets, presentationStart) {
139
167
  if (adts.frames.length === 0) return null;
140
168
  return adtsFragment(adts, AUDIO_TRACK_ID, presentationStart);
141
169
  }
142
- function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "all") {
143
- var _video$captions;
170
+ function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "all", parameterSets = null) {
171
+ var _video$captions, _ref3, _streams$video$, _streams$audio$, _video$parameterSets;
144
172
  const streams = demux(input);
145
173
  if (streams.notTransportStream) return {
146
174
  bytes: null,
147
175
  notTransportStream: true,
148
176
  empty: false,
149
177
  captions: [],
150
- droppedAudio: false
178
+ metadata: [],
179
+ droppedAudio: false,
180
+ parameterSets: null
151
181
  };
152
- const video = tracks === "audio" ? null : buildVideo(streams.video, presentationStart, wantCaptions);
182
+ const video = tracks === "audio" ? null : buildVideo(streams.video, presentationStart, wantCaptions, parameterSets);
153
183
  const audio = tracks === "video" ? null : buildAudio(streams.audio, presentationStart);
154
184
  const droppedAudio = tracks === "video" && streams.audio.length > 0;
155
185
  if (video === null && audio === null) return {
@@ -157,7 +187,9 @@ function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "
157
187
  notTransportStream: false,
158
188
  empty: true,
159
189
  captions: [],
160
- droppedAudio
190
+ metadata: [],
191
+ droppedAudio,
192
+ parameterSets: null
161
193
  };
162
194
  const configs = [];
163
195
  const fragments = [];
@@ -176,7 +208,9 @@ function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "
176
208
  notTransportStream: false,
177
209
  empty: false,
178
210
  captions: (_video$captions = video === null || video === void 0 ? void 0 : video.captions) !== null && _video$captions !== void 0 ? _video$captions : [],
179
- droppedAudio
211
+ metadata: timedTags(streams, presentationStart, (_ref3 = video !== null ? (_streams$video$ = streams.video[0]) === null || _streams$video$ === void 0 ? void 0 : _streams$video$.dts : (_streams$audio$ = streams.audio[0]) === null || _streams$audio$ === void 0 ? void 0 : _streams$audio$.pts) !== null && _ref3 !== void 0 ? _ref3 : null),
212
+ droppedAudio,
213
+ parameterSets: (_video$parameterSets = video === null || video === void 0 ? void 0 : video.parameterSets) !== null && _video$parameterSets !== void 0 ? _video$parameterSets : null
180
214
  };
181
215
  }
182
216
  //#endregion
@@ -1,28 +1,9 @@
1
- import { transmux } from "./transmux.js";
1
+ import { serveTransmux } from "./serve.js";
2
2
  //#region src/containers/ts-transmux/transmux.worker.ts
3
- const scope = self;
4
- scope.onmessage = (event) => {
5
- const { id, bytes, presentationStart, wantCaptions, tracks = "all" } = event.data;
6
- const result = transmux(new Uint8Array(bytes), presentationStart, wantCaptions, tracks);
7
- const out = result.bytes;
8
- if (out === null) {
9
- scope.postMessage({
10
- id,
11
- bytes: null,
12
- notTransportStream: result.notTransportStream,
13
- captions: [],
14
- droppedAudio: result.droppedAudio
15
- }, []);
16
- return;
17
- }
18
- const buffer = new ArrayBuffer(out.byteLength);
19
- new Uint8Array(buffer).set(out);
20
- scope.postMessage({
21
- id,
22
- bytes: buffer,
23
- notTransportStream: false,
24
- captions: result.captions,
25
- droppedAudio: result.droppedAudio
26
- }, [buffer]);
27
- };
3
+ /**
4
+ * The Worker entry of the npm build, loaded by URL. Everything it does is
5
+ * in serve.ts, which the script-tag bundle also starts from its one copy of
6
+ * the transmux.
7
+ */
8
+ serveTransmux(self);
28
9
  //#endregion
@@ -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/containers/webvtt.ts
3
3
  /** `HH:MM:SS.mmm` or `MM:SS.mmm` to seconds, or null. */
4
4
  function parseTimestamp(text) {
@@ -56,5 +56,9 @@ function parseVtt(text) {
56
56
  skipped
57
57
  };
58
58
  }
59
+ /** Text made safe as WebVTT cue text: `&`, `<`, and `>` escaped (WebVTT §4.2.2). */
60
+ function escapeCueText(text) {
61
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
62
+ }
59
63
  //#endregion
60
- export { parseTimestamp, parseVtt };
64
+ export { escapeCueText, parseTimestamp, parseVtt };
@@ -0,0 +1,40 @@
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import { fourcc, viewOf } from "./mp4-box/index.js";
3
+ //#region src/containers/wvtt.ts
4
+ /** The child boxes of `bytes`, as type and payload. */
5
+ function boxes(bytes) {
6
+ const out = [];
7
+ const view = viewOf(bytes);
8
+ for (let offset = 0; offset + 8 <= bytes.byteLength;) {
9
+ const size = view.getUint32(offset);
10
+ if (size < 8 || offset + size > bytes.byteLength) break;
11
+ out.push([fourcc(bytes, offset + 4), bytes.subarray(offset + 8, offset + size)]);
12
+ offset += size;
13
+ }
14
+ return out;
15
+ }
16
+ /** The cues of a wvtt segment's samples, joined across samples. */
17
+ function wvttCues(samples) {
18
+ const decoder = new TextDecoder();
19
+ const cues = [];
20
+ for (const sample of samples) for (const [type, payload] of boxes(sample.bytes)) {
21
+ var _parts$get;
22
+ if (type !== "vttc") continue;
23
+ const parts = new Map(boxes(payload).map(([name, body]) => [name, decoder.decode(body)]));
24
+ const text = (_parts$get = parts.get("payl")) !== null && _parts$get !== void 0 ? _parts$get : "";
25
+ const settings = parts.get("sttg");
26
+ const joined = cues.find((cue) => cue.end === sample.start && cue.text === text && cue.settings === settings);
27
+ if (joined !== void 0) {
28
+ cues[cues.indexOf(joined)] = _objectSpread2(_objectSpread2({}, joined), {}, { end: sample.end });
29
+ continue;
30
+ }
31
+ cues.push(_objectSpread2({
32
+ start: sample.start,
33
+ end: sample.end,
34
+ text
35
+ }, settings !== void 0 && settings !== "" ? { settings } : {}));
36
+ }
37
+ return cues.map((cue) => _objectSpread2(_objectSpread2({}, cue), {}, { id: `${cue.start.toFixed(3)}|${cue.end.toFixed(3)}|${cue.text}` }));
38
+ }
39
+ //#endregion
40
+ export { wvttCues };
@@ -0,0 +1,79 @@
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
3
+ import emeCore from "../stages/eme-core/index.js";
4
+ //#region src/eme/index.ts
5
+ /**
6
+ * The engine's DRM on an element the engine does not drive. On Safari a
7
+ * player can play HLS natively with `video.src`; the element still fires
8
+ * `encrypted` and needs a license. `attachEme` runs the same `eme-core` and
9
+ * key-system stages the engine runs, on a small context of its own: the
10
+ * element, `fetch` for licenses and certificates, and a local event bus.
11
+ * Only the media route applies: init data comes from the element's
12
+ * `encrypted` event, since there is no manifest the engine has parsed.
13
+ */
14
+ const _excluded = ["keySystems", "requestHook"];
15
+ const noop = () => {};
16
+ /** Starts DRM on the element. Call it before you set `src`, so no `encrypted` event is missed. */
17
+ function attachEme(element, options = {}) {
18
+ const { keySystems = [], requestHook } = options, emeOptions = _objectWithoutProperties(options, _excluded);
19
+ const listeners = /* @__PURE__ */ new Map();
20
+ let drm;
21
+ const ctx = {
22
+ element,
23
+ registerNamespace: (_name, api) => {
24
+ drm = api;
25
+ },
26
+ request(url, init) {
27
+ var _init$method;
28
+ const draft = {
29
+ url,
30
+ headers: _objectSpread2({}, init.headers)
31
+ };
32
+ requestHook === null || requestHook === void 0 || requestHook(draft);
33
+ return fetch(draft.url, _objectSpread2({
34
+ method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
35
+ headers: draft.headers
36
+ }, init.body !== void 0 ? { body: init.body } : {}));
37
+ },
38
+ emit(event, payload) {
39
+ var _listeners$get;
40
+ for (const fn of [...(_listeners$get = listeners.get(event)) !== null && _listeners$get !== void 0 ? _listeners$get : []]) fn(payload);
41
+ },
42
+ on(event, fn) {
43
+ var _listeners$get2;
44
+ const set = (_listeners$get2 = listeners.get(event)) !== null && _listeners$get2 !== void 0 ? _listeners$get2 : /* @__PURE__ */ new Set();
45
+ listeners.set(event, set.add(fn));
46
+ return () => set.delete(fn);
47
+ },
48
+ registerSink: noop,
49
+ registerParser: noop,
50
+ registerTransform: noop,
51
+ registerChooser: noop,
52
+ registerSwitchPolicy: noop,
53
+ registerTypeProbe: noop,
54
+ registerTimeProbe: noop,
55
+ reduce: noop,
56
+ dispatch: noop,
57
+ addRequestHook: () => noop,
58
+ addResponseHook: () => noop,
59
+ capabilities: () => [],
60
+ getState: () => {
61
+ throw new Error("attachEme runs without an engine");
62
+ }
63
+ };
64
+ const teardowns = [];
65
+ for (const stage of [...keySystems, emeCore(emeOptions)]) {
66
+ const teardown = stage.install(ctx);
67
+ if (typeof teardown === "function") teardowns.push(teardown);
68
+ }
69
+ return {
70
+ drm,
71
+ on: ctx.on,
72
+ detach() {
73
+ for (const teardown of teardowns.splice(0).reverse()) teardown();
74
+ listeners.clear();
75
+ }
76
+ };
77
+ }
78
+ //#endregion
79
+ export { attachEme };