mattebox 0.6.0 → 0.7.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 (335) hide show
  1. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  2. package/dist/cdn/mattebox.dash.min.js +3 -3
  3. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  6. package/dist/cdn/mattebox.dual.min.js +3 -3
  7. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  10. package/dist/cdn/mattebox.hls.min.js +3 -3
  11. package/dist/cdn/mattebox.kernel.min.js +1 -1
  12. package/dist/cdn/mattebox.min.js +3 -6
  13. package/dist/containers/adts.d.ts +10 -0
  14. package/dist/containers/adts.d.ts.map +1 -1
  15. package/dist/containers/adts.js +27 -7
  16. package/dist/containers/adts.js.map +1 -1
  17. package/dist/containers/codec-probe/index.d.ts +0 -6
  18. package/dist/containers/codec-probe/index.d.ts.map +1 -1
  19. package/dist/containers/codec-probe/index.js +14 -23
  20. package/dist/containers/codec-probe/index.js.map +1 -1
  21. package/dist/containers/fmp4/fit.d.ts +26 -0
  22. package/dist/containers/fmp4/fit.d.ts.map +1 -0
  23. package/dist/containers/fmp4/fit.js +49 -0
  24. package/dist/containers/fmp4/fit.js.map +1 -0
  25. package/dist/containers/fmp4/writer.d.ts +7 -0
  26. package/dist/containers/fmp4/writer.d.ts.map +1 -1
  27. package/dist/containers/fmp4/writer.js +9 -1
  28. package/dist/containers/fmp4/writer.js.map +1 -1
  29. package/dist/containers/id3.d.ts.map +1 -1
  30. package/dist/containers/id3.js +2 -1
  31. package/dist/containers/id3.js.map +1 -1
  32. package/dist/containers/mp4-box/index.d.ts +75 -7
  33. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  34. package/dist/containers/mp4-box/index.js +225 -49
  35. package/dist/containers/mp4-box/index.js.map +1 -1
  36. package/dist/containers/packed-audio/index.d.ts.map +1 -1
  37. package/dist/containers/packed-audio/index.js +9 -27
  38. package/dist/containers/packed-audio/index.js.map +1 -1
  39. package/dist/containers/sei.d.ts +5 -0
  40. package/dist/containers/sei.d.ts.map +1 -1
  41. package/dist/containers/sei.js +5 -2
  42. package/dist/containers/sei.js.map +1 -1
  43. package/dist/containers/ts-transmux/demux.d.ts +7 -1
  44. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  45. package/dist/containers/ts-transmux/demux.js +38 -17
  46. package/dist/containers/ts-transmux/demux.js.map +1 -1
  47. package/dist/containers/ts-transmux/h264.d.ts.map +1 -1
  48. package/dist/containers/ts-transmux/h264.js +1 -17
  49. package/dist/containers/ts-transmux/h264.js.map +1 -1
  50. package/dist/containers/ts-transmux/index.d.ts.map +1 -1
  51. package/dist/containers/ts-transmux/index.js +11 -2
  52. package/dist/containers/ts-transmux/index.js.map +1 -1
  53. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  54. package/dist/containers/ts-transmux/transmux.js +6 -36
  55. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  56. package/dist/{stages/text-webvtt/parse.d.ts → containers/webvtt.d.ts} +4 -3
  57. package/dist/containers/webvtt.d.ts.map +1 -0
  58. package/dist/{stages/text-webvtt/parse.js → containers/webvtt.js} +1 -1
  59. package/dist/containers/webvtt.js.map +1 -0
  60. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
  61. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
  62. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
  63. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
  64. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  65. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
  66. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
  67. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
  68. package/dist/es2015/containers/adts.js +28 -8
  69. package/dist/es2015/containers/codec-probe/index.js +17 -26
  70. package/dist/es2015/containers/fmp4/fit.js +46 -0
  71. package/dist/es2015/containers/fmp4/writer.js +9 -1
  72. package/dist/es2015/containers/id3.js +3 -3
  73. package/dist/es2015/containers/mp4-box/index.js +224 -39
  74. package/dist/es2015/containers/packed-audio/index.js +6 -33
  75. package/dist/es2015/containers/sei.js +6 -3
  76. package/dist/es2015/containers/ts-transmux/demux.js +41 -22
  77. package/dist/es2015/containers/ts-transmux/h264.js +2 -18
  78. package/dist/es2015/containers/ts-transmux/index.js +9 -9
  79. package/dist/es2015/containers/ts-transmux/transmux.js +8 -39
  80. package/dist/es2015/{stages/text-webvtt/parse.js → containers/webvtt.js} +2 -2
  81. package/dist/es2015/index.js +40 -42
  82. package/dist/es2015/kernel/append-queue.js +1 -1
  83. package/dist/es2015/kernel/base64.js +25 -0
  84. package/dist/es2015/kernel/context.js +7 -0
  85. package/dist/es2015/kernel/effects.js +21 -1
  86. package/dist/es2015/kernel/loader.js +5 -4
  87. package/dist/es2015/kernel/mime.js +5 -1
  88. package/dist/es2015/kernel/mse.js +27 -71
  89. package/dist/es2015/kernel/prepare.js +77 -0
  90. package/dist/es2015/kernel/presentation.js +24 -0
  91. package/dist/es2015/kernel/reducer.js +279 -124
  92. package/dist/es2015/kernel/refresh.js +35 -0
  93. package/dist/es2015/kernel/rendition-select.js +109 -4
  94. package/dist/es2015/kernel/scheduler.js +23 -5
  95. package/dist/es2015/kernel/sinks/text-track-sink.js +27 -26
  96. package/dist/es2015/kernel/timeline.js +22 -1
  97. package/dist/es2015/kernel/trace.js +1 -1
  98. package/dist/es2015/kernel/track-registry.js +10 -2
  99. package/dist/es2015/kernel/transport.js +4 -4
  100. package/dist/es2015/kernel/url.js +12 -0
  101. package/dist/es2015/presets/define.js +2 -2
  102. package/dist/es2015/presets/full/index.js +9 -3
  103. package/dist/es2015/presets/tiers.js +7 -6
  104. package/dist/es2015/protocols/adapter-shared.js +28 -0
  105. package/dist/es2015/protocols/dash-cmaf/index.js +132 -88
  106. package/dist/es2015/protocols/dash-cmaf/parse.js +62 -64
  107. package/dist/es2015/protocols/dash-live/index.js +62 -37
  108. package/dist/es2015/protocols/dimensions.js +15 -0
  109. package/dist/es2015/protocols/hls-cmaf/index.js +108 -95
  110. package/dist/es2015/protocols/hls-cmaf/lexer.js +3 -0
  111. package/dist/es2015/protocols/hls-cmaf/parse.js +167 -56
  112. package/dist/es2015/protocols/hls-cmaf/unavailable.js +43 -0
  113. package/dist/es2015/protocols/hls-live/index.js +187 -109
  114. package/dist/es2015/stages/abr/index.js +8 -11
  115. package/dist/es2015/stages/abr-persist/index.js +18 -11
  116. package/dist/es2015/stages/aes-128/index.js +15 -8
  117. package/dist/es2015/stages/alt-audio/index.js +25 -13
  118. package/dist/es2015/stages/chapters/index.js +151 -0
  119. package/dist/es2015/stages/chapters/parse.js +149 -0
  120. package/dist/es2015/stages/cmaf-timing/index.js +24 -39
  121. package/dist/es2015/stages/cmcd/index.js +29 -6
  122. package/dist/es2015/stages/codec-switch/index.js +2 -5
  123. package/dist/es2015/stages/content-steering/index.js +13 -16
  124. package/dist/es2015/stages/eme-cenc/index.js +10 -4
  125. package/dist/es2015/stages/eme-core/index.js +31 -13
  126. package/dist/es2015/stages/eme-fairplay/index.js +12 -8
  127. package/dist/es2015/stages/nal-scan/index.js +30 -140
  128. package/dist/es2015/stages/recovery/index.js +47 -54
  129. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  130. package/dist/es2015/stages/text-cea608/index.js +3 -17
  131. package/dist/es2015/stages/text-webvtt/index.js +1 -1
  132. package/dist/es2015/stages/text-webvtt-segmented/index.js +15 -8
  133. package/dist/es2015/stages/thumbnails/index.js +213 -43
  134. package/dist/es2015/stages/trick-play/index.js +463 -0
  135. package/dist/index.d.ts +6 -0
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +36 -53
  138. package/dist/index.js.map +1 -1
  139. package/dist/kernel/base64.d.ts +9 -0
  140. package/dist/kernel/base64.d.ts.map +1 -0
  141. package/dist/kernel/base64.js +26 -0
  142. package/dist/kernel/base64.js.map +1 -0
  143. package/dist/kernel/context.d.ts +5 -1
  144. package/dist/kernel/context.d.ts.map +1 -1
  145. package/dist/kernel/context.js +10 -0
  146. package/dist/kernel/context.js.map +1 -1
  147. package/dist/kernel/effects.d.ts +9 -1
  148. package/dist/kernel/effects.d.ts.map +1 -1
  149. package/dist/kernel/effects.js +12 -0
  150. package/dist/kernel/effects.js.map +1 -1
  151. package/dist/kernel/lifecycle.js +1 -1
  152. package/dist/kernel/lifecycle.js.map +1 -1
  153. package/dist/kernel/loader.d.ts.map +1 -1
  154. package/dist/kernel/loader.js +5 -7
  155. package/dist/kernel/loader.js.map +1 -1
  156. package/dist/kernel/mime.d.ts +2 -0
  157. package/dist/kernel/mime.d.ts.map +1 -1
  158. package/dist/kernel/mime.js +4 -0
  159. package/dist/kernel/mime.js.map +1 -1
  160. package/dist/kernel/mse.d.ts +6 -10
  161. package/dist/kernel/mse.d.ts.map +1 -1
  162. package/dist/kernel/mse.js +20 -73
  163. package/dist/kernel/mse.js.map +1 -1
  164. package/dist/kernel/prepare.d.ts +28 -0
  165. package/dist/kernel/prepare.d.ts.map +1 -0
  166. package/dist/kernel/prepare.js +89 -0
  167. package/dist/kernel/prepare.js.map +1 -0
  168. package/dist/kernel/presentation.d.ts +20 -0
  169. package/dist/kernel/presentation.d.ts.map +1 -0
  170. package/dist/kernel/presentation.js +25 -0
  171. package/dist/kernel/presentation.js.map +1 -0
  172. package/dist/kernel/reducer.d.ts +24 -0
  173. package/dist/kernel/reducer.d.ts.map +1 -1
  174. package/dist/kernel/reducer.js +375 -152
  175. package/dist/kernel/reducer.js.map +1 -1
  176. package/dist/kernel/refresh.d.ts +14 -0
  177. package/dist/kernel/refresh.d.ts.map +1 -0
  178. package/dist/kernel/refresh.js +51 -0
  179. package/dist/kernel/refresh.js.map +1 -0
  180. package/dist/kernel/rendition-select.d.ts +38 -5
  181. package/dist/kernel/rendition-select.d.ts.map +1 -1
  182. package/dist/kernel/rendition-select.js +134 -2
  183. package/dist/kernel/rendition-select.js.map +1 -1
  184. package/dist/kernel/scheduler.d.ts +18 -3
  185. package/dist/kernel/scheduler.d.ts.map +1 -1
  186. package/dist/kernel/scheduler.js +32 -7
  187. package/dist/kernel/scheduler.js.map +1 -1
  188. package/dist/kernel/sinks/text-track-sink.d.ts +9 -0
  189. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  190. package/dist/kernel/sinks/text-track-sink.js +29 -29
  191. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  192. package/dist/kernel/timeline.d.ts +26 -7
  193. package/dist/kernel/timeline.d.ts.map +1 -1
  194. package/dist/kernel/timeline.js +21 -7
  195. package/dist/kernel/timeline.js.map +1 -1
  196. package/dist/kernel/track-registry.d.ts.map +1 -1
  197. package/dist/kernel/track-registry.js +17 -1
  198. package/dist/kernel/track-registry.js.map +1 -1
  199. package/dist/kernel/transport.d.ts.map +1 -1
  200. package/dist/kernel/transport.js +1 -0
  201. package/dist/kernel/transport.js.map +1 -1
  202. package/dist/kernel/url.d.ts +4 -0
  203. package/dist/kernel/url.d.ts.map +1 -0
  204. package/dist/kernel/url.js +11 -0
  205. package/dist/kernel/url.js.map +1 -0
  206. package/dist/presets/full/index.d.ts.map +1 -1
  207. package/dist/presets/full/index.js +8 -2
  208. package/dist/presets/full/index.js.map +1 -1
  209. package/dist/presets/tiers.d.ts +7 -6
  210. package/dist/presets/tiers.d.ts.map +1 -1
  211. package/dist/presets/tiers.js +7 -6
  212. package/dist/presets/tiers.js.map +1 -1
  213. package/dist/protocols/adapter-shared.d.ts +23 -0
  214. package/dist/protocols/adapter-shared.d.ts.map +1 -0
  215. package/dist/protocols/adapter-shared.js +23 -0
  216. package/dist/protocols/adapter-shared.js.map +1 -0
  217. package/dist/protocols/dash-cmaf/index.d.ts +2 -2
  218. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  219. package/dist/protocols/dash-cmaf/index.js +150 -97
  220. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  221. package/dist/protocols/dash-cmaf/parse.d.ts +2 -5
  222. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  223. package/dist/protocols/dash-cmaf/parse.js +46 -39
  224. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  225. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  226. package/dist/protocols/dash-live/index.js +67 -25
  227. package/dist/protocols/dash-live/index.js.map +1 -1
  228. package/dist/protocols/dimensions.d.ts +8 -0
  229. package/dist/protocols/dimensions.d.ts.map +1 -0
  230. package/dist/protocols/dimensions.js +13 -0
  231. package/dist/protocols/dimensions.js.map +1 -0
  232. package/dist/protocols/hls-cmaf/index.d.ts +3 -2
  233. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  234. package/dist/protocols/hls-cmaf/index.js +127 -114
  235. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  236. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  237. package/dist/protocols/hls-cmaf/lexer.js +3 -0
  238. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  239. package/dist/protocols/hls-cmaf/parse.d.ts +22 -14
  240. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  241. package/dist/protocols/hls-cmaf/parse.js +196 -69
  242. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  243. package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
  244. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
  245. package/dist/protocols/hls-cmaf/unavailable.js +38 -0
  246. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
  247. package/dist/protocols/hls-live/index.d.ts +17 -0
  248. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  249. package/dist/protocols/hls-live/index.js +202 -106
  250. package/dist/protocols/hls-live/index.js.map +1 -1
  251. package/dist/stages/abr/index.d.ts.map +1 -1
  252. package/dist/stages/abr/index.js +8 -14
  253. package/dist/stages/abr/index.js.map +1 -1
  254. package/dist/stages/abr-cap-size/index.d.ts +1 -1
  255. package/dist/stages/abr-persist/index.d.ts.map +1 -1
  256. package/dist/stages/abr-persist/index.js +17 -7
  257. package/dist/stages/abr-persist/index.js.map +1 -1
  258. package/dist/stages/aes-128/index.d.ts +0 -9
  259. package/dist/stages/aes-128/index.d.ts.map +1 -1
  260. package/dist/stages/aes-128/index.js +15 -13
  261. package/dist/stages/aes-128/index.js.map +1 -1
  262. package/dist/stages/alt-audio/index.d.ts +16 -0
  263. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  264. package/dist/stages/alt-audio/index.js +28 -15
  265. package/dist/stages/alt-audio/index.js.map +1 -1
  266. package/dist/stages/chapters/index.d.ts +20 -0
  267. package/dist/stages/chapters/index.d.ts.map +1 -0
  268. package/dist/stages/chapters/index.js +141 -0
  269. package/dist/stages/chapters/index.js.map +1 -0
  270. package/dist/stages/chapters/parse.d.ts +47 -0
  271. package/dist/stages/chapters/parse.d.ts.map +1 -0
  272. package/dist/stages/chapters/parse.js +168 -0
  273. package/dist/stages/chapters/parse.js.map +1 -0
  274. package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
  275. package/dist/stages/cmaf-timing/index.js +33 -42
  276. package/dist/stages/cmaf-timing/index.js.map +1 -1
  277. package/dist/stages/cmcd/index.d.ts +0 -11
  278. package/dist/stages/cmcd/index.d.ts.map +1 -1
  279. package/dist/stages/cmcd/index.js +30 -12
  280. package/dist/stages/cmcd/index.js.map +1 -1
  281. package/dist/stages/codec-switch/index.d.ts.map +1 -1
  282. package/dist/stages/codec-switch/index.js +3 -8
  283. package/dist/stages/codec-switch/index.js.map +1 -1
  284. package/dist/stages/content-steering/index.d.ts.map +1 -1
  285. package/dist/stages/content-steering/index.js +12 -9
  286. package/dist/stages/content-steering/index.js.map +1 -1
  287. package/dist/stages/eme-cenc/index.d.ts +0 -7
  288. package/dist/stages/eme-cenc/index.d.ts.map +1 -1
  289. package/dist/stages/eme-cenc/index.js +9 -5
  290. package/dist/stages/eme-cenc/index.js.map +1 -1
  291. package/dist/stages/eme-core/index.d.ts.map +1 -1
  292. package/dist/stages/eme-core/index.js +31 -15
  293. package/dist/stages/eme-core/index.js.map +1 -1
  294. package/dist/stages/eme-fairplay/index.d.ts +0 -7
  295. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  296. package/dist/stages/eme-fairplay/index.js +11 -9
  297. package/dist/stages/eme-fairplay/index.js.map +1 -1
  298. package/dist/stages/nal-scan/index.d.ts.map +1 -1
  299. package/dist/stages/nal-scan/index.js +32 -145
  300. package/dist/stages/nal-scan/index.js.map +1 -1
  301. package/dist/stages/recovery/index.d.ts.map +1 -1
  302. package/dist/stages/recovery/index.js +42 -56
  303. package/dist/stages/recovery/index.js.map +1 -1
  304. package/dist/stages/text-cea608/index.d.ts +11 -0
  305. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  306. package/dist/stages/text-cea608/index.js +3 -23
  307. package/dist/stages/text-cea608/index.js.map +1 -1
  308. package/dist/stages/text-webvtt/index.d.ts +12 -0
  309. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  310. package/dist/stages/text-webvtt/index.js +1 -1
  311. package/dist/stages/text-webvtt/index.js.map +1 -1
  312. package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -1
  313. package/dist/stages/text-webvtt-segmented/index.js +11 -8
  314. package/dist/stages/text-webvtt-segmented/index.js.map +1 -1
  315. package/dist/stages/thumbnails/index.d.ts +39 -10
  316. package/dist/stages/thumbnails/index.d.ts.map +1 -1
  317. package/dist/stages/thumbnails/index.js +220 -30
  318. package/dist/stages/thumbnails/index.js.map +1 -1
  319. package/dist/stages/trick-play/index.d.ts +51 -0
  320. package/dist/stages/trick-play/index.d.ts.map +1 -0
  321. package/dist/stages/trick-play/index.js +480 -0
  322. package/dist/stages/trick-play/index.js.map +1 -0
  323. package/dist/types/ir.d.ts +40 -1
  324. package/dist/types/ir.d.ts.map +1 -1
  325. package/dist/types/kernel.d.ts +41 -13
  326. package/dist/types/kernel.d.ts.map +1 -1
  327. package/dist/types/kernel.js +2 -1
  328. package/dist/types/kernel.js.map +1 -1
  329. package/dist/types/messages.d.ts +61 -10
  330. package/dist/types/messages.d.ts.map +1 -1
  331. package/dist/types/stage.d.ts +18 -0
  332. package/dist/types/stage.d.ts.map +1 -1
  333. package/package.json +1 -1
  334. package/dist/stages/text-webvtt/parse.d.ts.map +0 -1
  335. package/dist/stages/text-webvtt/parse.js.map +0 -1
@@ -1,6 +1,14 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { base64ToBytes, bytesToBase64 } from "../../kernel/base64.js";
2
3
  import { registerKeySystem } from "../drm-shared.js";
3
4
  //#region src/stages/eme-fairplay/index.ts
5
+ /**
6
+ * FairPlay Streaming: the non-standard SPC/CKC flow. Safari only, and it
7
+ * differs from CENC enough to warrant its own stage — the CDM message is
8
+ * an SPC to POST as form data, the response is a CKC, and the content id
9
+ * comes from the skd:// URI the hls parser stored in licenseUrl. Registers
10
+ * a handler; eme-core drives it, including the certificate fetch.
11
+ */
4
12
  const FAIRPLAY_SYSTEM_ID = "94ce86fb-07ff-4f43-adb8-93d2fa968ca2";
5
13
  /** The content id from a skd:// init data blob: the URI's opaque tail. */
6
14
  function contentIdFromSkd(initData) {
@@ -10,9 +18,7 @@ function contentIdFromSkd(initData) {
10
18
  }
11
19
  /** Wraps the SPC as the `spc=` form body Apple's key servers expect. */
12
20
  function buildSpcRequest(message) {
13
- let binary = "";
14
- for (const b of new Uint8Array(message)) binary += String.fromCharCode(b);
15
- const spc = btoa(binary);
21
+ const spc = bytesToBase64(new Uint8Array(message));
16
22
  return new TextEncoder().encode(`spc=${encodeURIComponent(spc)}`);
17
23
  }
18
24
  /** Decodes a CKC form/base64 response into the bytes session.update wants. */
@@ -22,10 +28,8 @@ function parseCkcResponse(response) {
22
28
  const b64 = (_exec$ = (_exec = /^ckc=(.+)$/.exec(text)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _exec$ !== void 0 ? _exec$ : /^[A-Za-z0-9+/=]+$/.test(text) ? text : null;
23
29
  if (b64 === null) return response;
24
30
  try {
25
- const binary = atob(decodeURIComponent(b64));
26
- const bytes = new Uint8Array(binary.length);
27
- for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
28
- return bytes;
31
+ var _base64ToBytes;
32
+ return (_base64ToBytes = base64ToBytes(decodeURIComponent(b64))) !== null && _base64ToBytes !== void 0 ? _base64ToBytes : response;
29
33
  } catch (_unused) {
30
34
  return response;
31
35
  }
@@ -1,5 +1,5 @@
1
+ import { findBox, findBoxes, fourcc, fragmentSamples, sampleEntries, trackInfo, trexDefaults } from "../../containers/mp4-box/index.js";
1
2
  import { captionsWanted, deliverCaptions } from "../../containers/captions.js";
2
- import { findBox, findBoxes, fullBox, parseTfdt } from "../../containers/mp4-box/index.js";
3
3
  import { ccTriplesFromSei } from "../../containers/sei.js";
4
4
  //#region src/stages/nal-scan/index.ts
5
5
  /**
@@ -8,67 +8,21 @@ import { ccTriplesFromSei } from "../../containers/sei.js";
8
8
  * its own captions.
9
9
  */
10
10
  const SCAN_ORDER = 50;
11
- /** SampleEntry (8 bytes) plus VisualSampleEntry (70 bytes). ISO/IEC 14496-12 §12.1.3. */
12
- const VISUAL_ENTRY_HEADER = 78;
13
11
  /** H.264 SEI. ITU-T H.264 Table 7-1. */
14
12
  const AVC_SEI = 6;
15
13
  /** HEVC prefix and suffix SEI. ITU-T H.265 Table 7-1. */
16
14
  const HEVC_PREFIX_SEI = 39;
17
15
  const HEVC_SUFFIX_SEI = 40;
18
- const TFHD_BASE_DATA_OFFSET = 1;
19
- const TFHD_SAMPLE_DESCRIPTION = 2;
20
- const TFHD_DEFAULT_DURATION = 8;
21
- const TFHD_DEFAULT_SIZE = 16;
22
- const TFHD_DEFAULT_BASE_IS_MOOF = 131072;
23
- const TRUN_DATA_OFFSET = 1;
24
- const TRUN_FIRST_SAMPLE_FLAGS = 4;
25
- const TRUN_DURATION = 256;
26
- const TRUN_SIZE = 512;
27
- const TRUN_FLAGS = 1024;
28
- const TRUN_CTS = 2048;
29
- function view(bytes) {
30
- return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
31
- }
32
- function fourcc(bytes, at) {
33
- var _bytes$at, _bytes, _bytes2, _bytes3;
34
- return String.fromCharCode((_bytes$at = bytes[at]) !== null && _bytes$at !== void 0 ? _bytes$at : 0, (_bytes = bytes[at + 1]) !== null && _bytes !== void 0 ? _bytes : 0, (_bytes2 = bytes[at + 2]) !== null && _bytes2 !== void 0 ? _bytes2 : 0, (_bytes3 = bytes[at + 3]) !== null && _bytes3 !== void 0 ? _bytes3 : 0);
35
- }
36
- /** The format and body of the first stsd sample entry. */
37
- function sampleEntry(stsd) {
38
- var _fullBox;
39
- const body = (_fullBox = fullBox(stsd)) === null || _fullBox === void 0 ? void 0 : _fullBox.body;
40
- if (body === void 0 || body.byteLength < 12) return null;
41
- const size = view(body).getUint32(4);
42
- if (size < 8 || 4 + size > body.byteLength) return null;
43
- return {
44
- format: fourcc(body, 8),
45
- body: body.subarray(12, 4 + size)
46
- };
47
- }
48
16
  /** The H.264 and HEVC tracks of an init segment, by track ID. Other codecs carry no SEI. */
49
17
  function videoTracks(init) {
50
- const defaults = /* @__PURE__ */ new Map();
51
- const mvex = findBox(init, "moov/mvex");
52
- for (const trex of mvex === null ? [] : findBoxes(mvex.payload, "trex")) {
53
- var _fullBox2;
54
- const body = (_fullBox2 = fullBox(trex.payload)) === null || _fullBox2 === void 0 ? void 0 : _fullBox2.body;
55
- if (body === void 0 || body.byteLength < 16) continue;
56
- const v = view(body);
57
- defaults.set(v.getUint32(0), {
58
- duration: v.getUint32(8),
59
- size: v.getUint32(12)
60
- });
61
- }
62
18
  const tracks = /* @__PURE__ */ new Map();
63
19
  for (const trak of findBoxes(init, "moov/trak")) {
64
- var _fallback$duration, _fallback$size;
65
- const tkhd = findBox(trak.payload, "tkhd");
66
- const mdhd = findBox(trak.payload, "mdia/mdhd");
20
+ const info = trackInfo(trak.payload);
67
21
  const stsd = findBox(trak.payload, "mdia/minf/stbl/stsd");
68
- const entry = stsd === null ? null : sampleEntry(stsd.payload);
69
- if (tkhd === null || mdhd === null || entry === null) continue;
70
- if (entry.body.byteLength < VISUAL_ENTRY_HEADER) continue;
71
- const children = entry.body.subarray(VISUAL_ENTRY_HEADER);
22
+ const entry = stsd === null ? void 0 : sampleEntries(stsd.payload)[0];
23
+ if (info === null || entry === void 0) continue;
24
+ if (entry.body.byteLength < 78) continue;
25
+ const children = entry.body.subarray(78);
72
26
  let format = entry.format;
73
27
  if (format === "encv") {
74
28
  const sinf = findBox(children, "sinf");
@@ -81,19 +35,12 @@ function videoTracks(init) {
81
35
  const config = findBox(children, hevc ? "hvcC" : "avcC");
82
36
  const lengthAt = hevc ? 21 : 4;
83
37
  const lengthSize = config !== null && config.payload.byteLength > lengthAt ? (config.payload[lengthAt] & 3) + 1 : 4;
84
- const trackAt = tkhd.payload[0] === 1 ? 20 : 12;
85
- const scaleAt = mdhd.payload[0] === 1 ? 20 : 12;
86
- if (tkhd.payload.byteLength < trackAt + 4 || mdhd.payload.byteLength < scaleAt + 4) continue;
87
- const trackId = view(tkhd.payload).getUint32(trackAt);
88
- const timescale = view(mdhd.payload).getUint32(scaleAt);
38
+ const { trackId, timescale } = info;
89
39
  if (timescale === 0) continue;
90
- const fallback = defaults.get(trackId);
91
40
  tracks.set(trackId, {
92
41
  timescale,
93
42
  hevc,
94
- lengthSize,
95
- defaultDuration: (_fallback$duration = fallback === null || fallback === void 0 ? void 0 : fallback.duration) !== null && _fallback$duration !== void 0 ? _fallback$duration : 0,
96
- defaultSize: (_fallback$size = fallback === null || fallback === void 0 ? void 0 : fallback.size) !== null && _fallback$size !== void 0 ? _fallback$size : 0
43
+ lengthSize
97
44
  });
98
45
  }
99
46
  return tracks;
@@ -118,91 +65,31 @@ function seiUnits(sample, track, out) {
118
65
  * of its track in the segment, the timeline cmaf-timing and the transmuxer
119
66
  * produce. The tfdt itself may carry a broadcast clock.
120
67
  */
121
- function captionPackets(data, tracks, start) {
68
+ function captionPackets(data, tracks, defaults, start) {
122
69
  const packets = [];
123
70
  const firstDecode = /* @__PURE__ */ new Map();
124
- const nextDecode = /* @__PURE__ */ new Map();
125
- for (const moof of findBoxes(data, "moof")) {
126
- let previousEnd = moof.start;
127
- for (const traf of findBoxes(moof.payload, "traf")) {
128
- var _track$defaultDuratio, _track$defaultSize, _parseTfdt, _ref, _firstDecode$get;
129
- const tfhdBox = findBox(traf.payload, "tfhd");
130
- const tfhd = tfhdBox === null ? null : fullBox(tfhdBox.payload);
131
- if (tfhd === null || tfhd.body.byteLength < 4) continue;
132
- const tfhdView = view(tfhd.body);
133
- const trackId = tfhdView.getUint32(0);
134
- const track = tracks.get(trackId);
135
- let at = 4;
136
- let base = tfhd.flags & TFHD_DEFAULT_BASE_IS_MOOF ? moof.start : previousEnd;
137
- if (tfhd.flags & TFHD_BASE_DATA_OFFSET) {
138
- base = Number(tfhdView.getBigUint64(at));
139
- at += 8;
140
- }
141
- if (tfhd.flags & TFHD_SAMPLE_DESCRIPTION) at += 4;
142
- let defaultDuration = (_track$defaultDuratio = track === null || track === void 0 ? void 0 : track.defaultDuration) !== null && _track$defaultDuratio !== void 0 ? _track$defaultDuratio : 0;
143
- let defaultSize = (_track$defaultSize = track === null || track === void 0 ? void 0 : track.defaultSize) !== null && _track$defaultSize !== void 0 ? _track$defaultSize : 0;
144
- if (tfhd.flags & TFHD_DEFAULT_DURATION) {
145
- defaultDuration = tfhdView.getUint32(at);
146
- at += 4;
147
- }
148
- if (tfhd.flags & TFHD_DEFAULT_SIZE) defaultSize = tfhdView.getUint32(at);
149
- const tfdt = findBox(traf.payload, "tfdt");
150
- const tfdtTime = tfdt === null ? void 0 : (_parseTfdt = parseTfdt(tfdt.payload)) === null || _parseTfdt === void 0 ? void 0 : _parseTfdt.baseMediaDecodeTime;
151
- let decode = (_ref = tfdtTime !== null && tfdtTime !== void 0 ? tfdtTime : nextDecode.get(trackId)) !== null && _ref !== void 0 ? _ref : 0;
152
- const first = (_firstDecode$get = firstDecode.get(trackId)) !== null && _firstDecode$get !== void 0 ? _firstDecode$get : decode;
153
- firstDecode.set(trackId, first);
154
- let cursor = base;
155
- for (const trunBox of findBoxes(traf.payload, "trun")) {
156
- const trun = fullBox(trunBox.payload);
157
- if (trun === null || trun.body.byteLength < 4) continue;
158
- const trunView = view(trun.body);
159
- const count = trunView.getUint32(0);
160
- let p = 4;
161
- if (trun.flags & TRUN_DATA_OFFSET) {
162
- cursor = base + trunView.getInt32(p);
163
- p += 4;
164
- }
165
- if (trun.flags & TRUN_FIRST_SAMPLE_FLAGS) p += 4;
166
- const samples = Math.min(count, data.byteLength);
167
- for (let i = 0; i < samples; i += 1) {
168
- let duration = defaultDuration;
169
- let size = defaultSize;
170
- let cts = 0;
171
- if (trun.flags & TRUN_DURATION) {
172
- duration = trunView.getUint32(p);
173
- p += 4;
174
- }
175
- if (trun.flags & TRUN_SIZE) {
176
- size = trunView.getUint32(p);
177
- p += 4;
178
- }
179
- if (trun.flags & TRUN_FLAGS) p += 4;
180
- if (trun.flags & TRUN_CTS) {
181
- cts = trun.version === 1 ? trunView.getInt32(p) : trunView.getUint32(p);
182
- p += 4;
183
- }
184
- if (track !== void 0) {
185
- const units = [];
186
- seiUnits(data.subarray(cursor, cursor + size), track, units);
187
- const triples = [];
188
- for (const unit of units) triples.push(...ccTriplesFromSei(unit, track.hevc ? 2 : 1));
189
- if (triples.length > 0) packets.push({
190
- time: start + (decode - first + cts) / track.timescale,
191
- triples
192
- });
193
- }
194
- cursor += size;
195
- decode += duration;
196
- }
197
- }
198
- previousEnd = cursor;
199
- nextDecode.set(trackId, decode);
71
+ for (const traf of fragmentSamples(data, defaults)) {
72
+ var _ref, _firstDecode$get, _traf$samples$;
73
+ const track = tracks.get(traf.trackId);
74
+ const first = (_ref = (_firstDecode$get = firstDecode.get(traf.trackId)) !== null && _firstDecode$get !== void 0 ? _firstDecode$get : (_traf$samples$ = traf.samples[0]) === null || _traf$samples$ === void 0 ? void 0 : _traf$samples$.decodeTime) !== null && _ref !== void 0 ? _ref : 0;
75
+ firstDecode.set(traf.trackId, first);
76
+ if (track === void 0) continue;
77
+ for (const sample of traf.samples) {
78
+ const units = [];
79
+ seiUnits(data.subarray(sample.offset, sample.offset + sample.size), track, units);
80
+ const triples = [];
81
+ for (const unit of units) triples.push(...ccTriplesFromSei(unit, track.hevc ? 2 : 1));
82
+ if (triples.length > 0) packets.push({
83
+ time: start + (sample.decodeTime - first + sample.cts) / track.timescale,
84
+ triples
85
+ });
200
86
  }
201
87
  }
202
88
  return packets;
203
89
  }
204
90
  function nalScan() {
205
91
  let tracks = /* @__PURE__ */ new Map();
92
+ let defaults = /* @__PURE__ */ new Map();
206
93
  return {
207
94
  name: "nal-scan",
208
95
  provides: ["nal-scan"],
@@ -213,8 +100,11 @@ function nalScan() {
213
100
  transform(data, meta) {
214
101
  if (!captionsWanted() || meta.contentType !== "video") return data;
215
102
  try {
216
- if (findBox(data, "moov") !== null) tracks = videoTracks(data);
217
- if (tracks.size > 0) deliverCaptions(captionPackets(data, tracks, meta.start));
103
+ if (findBox(data, "moov") !== null) {
104
+ tracks = videoTracks(data);
105
+ defaults = trexDefaults(data);
106
+ }
107
+ if (tracks.size > 0) deliverCaptions(captionPackets(data, tracks, defaults, meta.start));
218
108
  } catch (_unused) {}
219
109
  return data;
220
110
  }
@@ -1,5 +1,24 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled, tickAfter } from "../../kernel/effects.js";
3
+ import { findRendition, findTrackSite } from "../../kernel/presentation.js";
4
+ import { segmentAt as segmentAt$1, segmentAtTime } from "../../kernel/timeline.js";
2
5
  //#region src/stages/recovery/index.ts
6
+ /**
7
+ * Recovery as a stage: the kernel keeps its circuit breakers as the last
8
+ * line, and this stage acts earlier through ordinary messages and its own
9
+ * constraint source. Nothing here is a private hook: exclusions are
10
+ * CONSTRAIN commands, jumps are SEEK commands, flushes are remove effects,
11
+ * and every decision is a trace entry.
12
+ *
13
+ * The escalation ladder for a failing segment: the transport already
14
+ * retried; a second failure on the same rendition excludes it under the
15
+ * 'recovery' source (readmitted after a backoff); a segment failing across
16
+ * renditions is a hole in the content and gets seeked over.
17
+ *
18
+ * The ladder for a stall with data ahead, fed by the waiting event and the
19
+ * kernel's playback watchdog: wait once, nudge the playhead, flush the
20
+ * buffers from the playhead and refetch, then skip past the segment.
21
+ */
3
22
  const DEFAULTS = {
4
23
  excludeAfter: 2,
5
24
  readmitAfterSeconds: 15,
@@ -20,12 +39,7 @@ const INITIAL = {
20
39
  };
21
40
  /** Loops a message back into the bus through a zero-delay schedule effect. */
22
41
  function feed(message) {
23
- return {
24
- kind: "schedule",
25
- token: "recovery:loopback",
26
- delayMs: 0,
27
- then: message
28
- };
42
+ return scheduled("recovery:loopback", message);
29
43
  }
30
44
  function constrainExcluded(excluded) {
31
45
  return excluded.length === 0 ? feed({
@@ -38,39 +52,34 @@ function constrainExcluded(excluded) {
38
52
  });
39
53
  }
40
54
  function isCueTrack(kernel, trackId) {
41
- var _kernel$presentation$, _kernel$presentation;
42
- for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.id === trackId) return track.contentType === "text" || track.contentType === "metadata";
43
- return false;
55
+ var _findTrackSite;
56
+ const type = (_findTrackSite = findTrackSite(kernel.presentation, trackId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track.contentType;
57
+ return type === "text" || type === "metadata";
44
58
  }
45
- function segmentWindow(kernel, seq) {
46
- var _kernel$presentation$2, _kernel$presentation2;
47
- for (const period of (_kernel$presentation$2 = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.periods) !== null && _kernel$presentation$2 !== void 0 ? _kernel$presentation$2 : []) for (const track of period.tracks) for (const rendition of track.renditions) {
48
- if (!Array.isArray(rendition.segments)) continue;
49
- const segment = rendition.segments.find((s) => s.seq === seq);
50
- if (segment !== void 0) return {
51
- start: segment.start,
52
- end: segment.start + segment.duration
53
- };
54
- }
55
- return null;
59
+ /**
60
+ * The window of segment `seq` in the rendition that failed it. Read through
61
+ * the kernel's addressing, so a DASH template answers as a list does.
62
+ */
63
+ function segmentWindow(kernel, renditionId, seq) {
64
+ const site = findRendition(kernel.presentation, renditionId);
65
+ if (site === null) return null;
66
+ const segment = segmentAt$1(site.rendition.segments, seq, site.period.start);
67
+ return segment === null ? null : {
68
+ start: segment.start,
69
+ end: segment.start + segment.duration
70
+ };
56
71
  }
57
72
  /** The segment of the active video rendition that covers `time`. */
58
73
  function segmentAt(kernel, time) {
59
- var _kernel$presentation$3, _kernel$presentation3;
60
74
  const active = kernel.quality.active;
61
- for (const period of (_kernel$presentation$3 = (_kernel$presentation3 = kernel.presentation) === null || _kernel$presentation3 === void 0 ? void 0 : _kernel$presentation3.periods) !== null && _kernel$presentation$3 !== void 0 ? _kernel$presentation$3 : []) for (const track of period.tracks) {
62
- if (track.contentType !== "video") continue;
63
- for (const rendition of track.renditions) {
64
- if (active !== null && rendition.id !== active) continue;
65
- if (!Array.isArray(rendition.segments)) continue;
66
- const segment = rendition.segments.find((s) => s.start <= time && time < s.start + s.duration);
67
- if (segment !== void 0) return {
68
- start: segment.start,
69
- end: segment.start + segment.duration
70
- };
71
- }
72
- }
73
- return null;
75
+ const site = active === null ? null : findRendition(kernel.presentation, active);
76
+ if (site === null || site.track.contentType !== "video") return null;
77
+ const segment = segmentAtTime(site.rendition.segments, time, site.period.start);
78
+ if (segment === null || segment.start > time) return null;
79
+ return {
80
+ start: segment.start,
81
+ end: segment.start + segment.duration
82
+ };
74
83
  }
75
84
  function createRecoveryReducer(options) {
76
85
  return (slice, msg, kernel) => {
@@ -86,7 +95,7 @@ function createRecoveryReducer(options) {
86
95
  let excluded = state.excluded;
87
96
  let readmitPending = state.readmitPending;
88
97
  if (seqFails[seqKey] >= options.skipAfter && state.skips < options.maxConsecutiveSkips) {
89
- const window = segmentWindow(kernel, msg.seq);
98
+ const window = segmentWindow(kernel, msg.renditionId, msg.seq);
90
99
  if (window !== null && kernel.playback.currentTime < window.end) {
91
100
  effects.push({
92
101
  kind: "emit",
@@ -114,15 +123,7 @@ function createRecoveryReducer(options) {
114
123
  payload: { renditionId: msg.renditionId }
115
124
  }, constrainExcluded(excluded));
116
125
  if (!readmitPending) {
117
- effects.push({
118
- kind: "schedule",
119
- token: READMIT_TOKEN,
120
- delayMs: options.readmitAfterSeconds * 1e3,
121
- then: {
122
- type: "TICK",
123
- token: READMIT_TOKEN
124
- }
125
- });
126
+ effects.push(tickAfter(READMIT_TOKEN, options.readmitAfterSeconds * 1e3));
126
127
  readmitPending = true;
127
128
  }
128
129
  }
@@ -158,15 +159,7 @@ function createRecoveryReducer(options) {
158
159
  }, constrainExcluded(rest)];
159
160
  let readmitPending = false;
160
161
  if (rest.length > 0) {
161
- effects.push({
162
- kind: "schedule",
163
- token: READMIT_TOKEN,
164
- delayMs: options.readmitAfterSeconds * 1e3,
165
- then: {
166
- type: "TICK",
167
- token: READMIT_TOKEN
168
- }
169
- });
162
+ effects.push(tickAfter(READMIT_TOKEN, options.readmitAfterSeconds * 1e3));
170
163
  readmitPending = true;
171
164
  }
172
165
  return [_objectSpread2(_objectSpread2({}, state), {}, {
@@ -1,4 +1,4 @@
1
- import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/defineProperty.js";
1
+ import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/defineProperty.js";
2
2
  //#region src/stages/text-cea608/decode.ts
3
3
  const ROWS = 15;
4
4
  /** The basic CEA-608 character set: ASCII with a handful of substitutions. */
@@ -1,3 +1,4 @@
1
+ import { adoptTextTrack, emptyTextTrack } from "../../kernel/sinks/text-track-sink.js";
1
2
  import { registerCaptionConsumer } from "../../containers/captions.js";
2
3
  import { Cea608Decoder } from "./decode.js";
3
4
  //#region src/stages/text-cea608/index.ts
@@ -25,24 +26,9 @@ function textCea608() {
25
26
  const element = ctx.element;
26
27
  let track = null;
27
28
  /** Empties the track. `cues` reads null while disabled; hidden makes them removable. */
28
- function empty(target) {
29
- target.mode = "hidden";
30
- const { cues } = target;
31
- if (cues === null) return;
32
- for (let i = cues.length - 1; i >= 0; i -= 1) {
33
- const cue = cues[i];
34
- if (cue !== void 0) target.removeCue(cue);
35
- }
36
- }
37
29
  function ensureTrack() {
38
30
  if (track === null) {
39
- var _track;
40
- for (const existing of element.textTracks) if (existing.kind === "captions" && existing.label === "CC1") {
41
- track = existing;
42
- empty(track);
43
- break;
44
- }
45
- (_track = track) !== null && _track !== void 0 || (track = element.addTextTrack("captions", "CC1", "en"));
31
+ track = adoptTextTrack(element, "captions", "CC1", "en");
46
32
  track.mode = "hidden";
47
33
  }
48
34
  return track;
@@ -59,7 +45,7 @@ function textCea608() {
59
45
  return () => {
60
46
  unregister();
61
47
  if (track !== null) {
62
- empty(track);
48
+ emptyTextTrack(track);
63
49
  track.mode = "disabled";
64
50
  track = null;
65
51
  }
@@ -1,5 +1,5 @@
1
+ import { parseVtt } from "../../containers/webvtt.js";
1
2
  import { createTextTrackSink } from "../../kernel/sinks/text-track-sink.js";
2
- import { parseVtt } from "./parse.js";
3
3
  //#region src/stages/text-webvtt/index.ts
4
4
  /**
5
5
  * WebVTT as a stage: a parser for text/vtt and the text sink registration
@@ -1,11 +1,14 @@
1
+ import { parseTimestamp } from "../../containers/webvtt.js";
1
2
  //#region src/stages/text-webvtt-segmented/index.ts
3
+ /**
4
+ * Segmented HLS subtitles: the X-TIMESTAMP-MAP header maps each segment's
5
+ * local cue times into MPEG-TS presentation time. This stage is a byte
6
+ * transform, ordered ahead of parsing: it shifts every cue timing by the
7
+ * segment's offset and strips the header, so the plain-VTT parser in
8
+ * text-webvtt never learns HLS exists. The offset is per segment, not per
9
+ * playlist; that is the bug this design makes unrepresentable.
10
+ */
2
11
  const MPEGTS_TIMESCALE = 9e4;
3
- function timestampToSeconds(text) {
4
- const [rest, millis] = text.split(".");
5
- const parts = (rest !== null && rest !== void 0 ? rest : "").split(":").map(Number);
6
- const [h, m, s] = parts.length === 3 ? parts : [0, ...parts];
7
- return (h !== null && h !== void 0 ? h : 0) * 3600 + (m !== null && m !== void 0 ? m : 0) * 60 + (s !== null && s !== void 0 ? s : 0) + Number(millis !== null && millis !== void 0 ? millis : 0) / 1e3;
8
- }
9
12
  function secondsToTimestamp(seconds) {
10
13
  const clamped = Math.max(0, seconds);
11
14
  const h = Math.floor(clamped / 3600);
@@ -22,12 +25,16 @@ function shiftTimestampMap(text) {
22
25
  let local = 0;
23
26
  let mpegts = 0;
24
27
  for (const part of header[1].split(",")) {
28
+ var _parseTimestamp;
25
29
  const [key, value] = splitOnce(part.trim());
26
- if (key === "LOCAL") local = timestampToSeconds(value);
30
+ if (key === "LOCAL") local = (_parseTimestamp = parseTimestamp(value)) !== null && _parseTimestamp !== void 0 ? _parseTimestamp : 0;
27
31
  if (key === "MPEGTS") mpegts = Number(value);
28
32
  }
29
33
  const offset = mpegts / MPEGTS_TIMESCALE - local;
30
- return text.replace(/X-TIMESTAMP-MAP=[^\r\n]*\r?\n?/, "").replace(/((?:\d+:)?[0-5]\d:[0-5]\d\.\d{3})(\s+-->\s+)((?:\d+:)?[0-5]\d:[0-5]\d\.\d{3})/g, (_, start, arrow, end) => `${secondsToTimestamp(timestampToSeconds(start) + offset)}${arrow}${secondsToTimestamp(timestampToSeconds(end) + offset)}`);
34
+ return text.replace(/X-TIMESTAMP-MAP=[^\r\n]*\r?\n?/, "").replace(/((?:\d+:)?[0-5]\d:[0-5]\d\.\d{3})(\s+-->\s+)((?:\d+:)?[0-5]\d:[0-5]\d\.\d{3})/g, (_, start, arrow, end) => {
35
+ var _parseTimestamp2, _parseTimestamp3;
36
+ return `${secondsToTimestamp(((_parseTimestamp2 = parseTimestamp(start)) !== null && _parseTimestamp2 !== void 0 ? _parseTimestamp2 : 0) + offset)}${arrow}${secondsToTimestamp(((_parseTimestamp3 = parseTimestamp(end)) !== null && _parseTimestamp3 !== void 0 ? _parseTimestamp3 : 0) + offset)}`;
37
+ });
31
38
  }
32
39
  function splitOnce(part) {
33
40
  const index = part.indexOf(":");