mattebox 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/README.md +1 -1
  2. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  3. package/dist/cdn/mattebox.dash.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  6. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  7. package/dist/cdn/mattebox.dual.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  10. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  11. package/dist/cdn/mattebox.hls.min.js +3 -3
  12. package/dist/cdn/mattebox.kernel.min.js +1 -1
  13. package/dist/cdn/mattebox.min.js +6 -2
  14. package/dist/containers/captions.d.ts +6 -5
  15. package/dist/containers/captions.d.ts.map +1 -1
  16. package/dist/containers/captions.js +9 -9
  17. package/dist/containers/captions.js.map +1 -1
  18. package/dist/containers/codec-probe/index.d.ts +15 -0
  19. package/dist/containers/codec-probe/index.d.ts.map +1 -1
  20. package/dist/containers/codec-probe/index.js +72 -5
  21. package/dist/containers/codec-probe/index.js.map +1 -1
  22. package/dist/containers/emsg.d.ts +15 -0
  23. package/dist/containers/emsg.d.ts.map +1 -0
  24. package/dist/containers/emsg.js +91 -0
  25. package/dist/containers/emsg.js.map +1 -0
  26. package/dist/containers/id3.d.ts +12 -0
  27. package/dist/containers/id3.d.ts.map +1 -1
  28. package/dist/containers/id3.js +53 -4
  29. package/dist/containers/id3.js.map +1 -1
  30. package/dist/containers/metadata.d.ts +18 -0
  31. package/dist/containers/metadata.d.ts.map +1 -0
  32. package/dist/containers/metadata.js +20 -0
  33. package/dist/containers/metadata.js.map +1 -0
  34. package/dist/containers/mp4-box/index.d.ts +16 -0
  35. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  36. package/dist/containers/mp4-box/index.js +28 -0
  37. package/dist/containers/mp4-box/index.js.map +1 -1
  38. package/dist/containers/scte35.d.ts +12 -0
  39. package/dist/containers/scte35.d.ts.map +1 -0
  40. package/dist/containers/scte35.js +116 -0
  41. package/dist/containers/scte35.js.map +1 -0
  42. package/dist/containers/ts-transmux/demux.d.ts +2 -2
  43. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  44. package/dist/containers/ts-transmux/demux.js +2 -18
  45. package/dist/containers/ts-transmux/demux.js.map +1 -1
  46. package/dist/containers/ts-transmux/index.d.ts.map +1 -1
  47. package/dist/containers/ts-transmux/index.js +14 -3
  48. package/dist/containers/ts-transmux/index.js.map +1 -1
  49. package/dist/containers/ts-transmux/module.d.ts +8 -0
  50. package/dist/containers/ts-transmux/module.d.ts.map +1 -0
  51. package/dist/containers/ts-transmux/module.js +8 -0
  52. package/dist/containers/ts-transmux/module.js.map +1 -0
  53. package/dist/containers/ts-transmux/runner.d.ts +20 -8
  54. package/dist/containers/ts-transmux/runner.d.ts.map +1 -1
  55. package/dist/containers/ts-transmux/runner.js +19 -22
  56. package/dist/containers/ts-transmux/runner.js.map +1 -1
  57. package/dist/containers/ts-transmux/serve.d.ts +35 -0
  58. package/dist/containers/ts-transmux/serve.d.ts.map +1 -0
  59. package/dist/containers/ts-transmux/serve.js +33 -0
  60. package/dist/containers/ts-transmux/serve.js.map +1 -0
  61. package/dist/containers/ts-transmux/sniff.d.ts +11 -0
  62. package/dist/containers/ts-transmux/sniff.d.ts.map +1 -0
  63. package/dist/containers/ts-transmux/sniff.js +25 -0
  64. package/dist/containers/ts-transmux/sniff.js.map +1 -0
  65. package/dist/containers/ts-transmux/source.d.ts +10 -0
  66. package/dist/containers/ts-transmux/source.d.ts.map +1 -0
  67. package/dist/containers/ts-transmux/source.js +5 -0
  68. package/dist/containers/ts-transmux/source.js.map +1 -0
  69. package/dist/containers/ts-transmux/transmux.d.ts +19 -1
  70. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  71. package/dist/containers/ts-transmux/transmux.js +46 -7
  72. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  73. package/dist/containers/ts-transmux/transmux.worker.js +7 -28
  74. package/dist/containers/ts-transmux/transmux.worker.js.map +1 -1
  75. package/dist/containers/webvtt.d.ts +2 -0
  76. package/dist/containers/webvtt.d.ts.map +1 -1
  77. package/dist/containers/webvtt.js +4 -0
  78. package/dist/containers/webvtt.js.map +1 -1
  79. package/dist/containers/wvtt.d.ts +12 -0
  80. package/dist/containers/wvtt.d.ts.map +1 -0
  81. package/dist/containers/wvtt.js +46 -0
  82. package/dist/containers/wvtt.js.map +1 -0
  83. package/dist/eme/index.d.ts +34 -0
  84. package/dist/eme/index.d.ts.map +1 -0
  85. package/dist/eme/index.js +75 -0
  86. package/dist/eme/index.js.map +1 -0
  87. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  88. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  89. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  90. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutProperties.js +1 -1
  91. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  92. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  93. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  94. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  95. package/dist/es2015/containers/captions.js +8 -8
  96. package/dist/es2015/containers/codec-probe/index.js +105 -6
  97. package/dist/es2015/containers/emsg.js +81 -0
  98. package/dist/es2015/containers/id3.js +54 -4
  99. package/dist/es2015/containers/metadata.js +20 -0
  100. package/dist/es2015/containers/mp4-box/index.js +27 -1
  101. package/dist/es2015/containers/scte35.js +114 -0
  102. package/dist/es2015/containers/ts-transmux/demux.js +12 -24
  103. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  104. package/dist/es2015/containers/ts-transmux/index.js +12 -4
  105. package/dist/es2015/containers/ts-transmux/runner.js +34 -27
  106. package/dist/es2015/containers/ts-transmux/serve.js +36 -0
  107. package/dist/es2015/containers/ts-transmux/sniff.js +13 -0
  108. package/dist/es2015/containers/ts-transmux/source.js +7 -0
  109. package/dist/es2015/containers/ts-transmux/transmux.js +42 -8
  110. package/dist/es2015/containers/ts-transmux/transmux.worker.js +7 -26
  111. package/dist/es2015/containers/webvtt.js +6 -2
  112. package/dist/es2015/containers/wvtt.js +40 -0
  113. package/dist/es2015/eme/index.js +79 -0
  114. package/dist/es2015/index.js +63 -27
  115. package/dist/es2015/kernel/append-queue.js +1 -1
  116. package/dist/es2015/kernel/base64.js +14 -3
  117. package/dist/es2015/kernel/bus.js +11 -8
  118. package/dist/es2015/kernel/context.js +5 -0
  119. package/dist/es2015/kernel/lifecycle.js +1 -0
  120. package/dist/es2015/kernel/loader.js +2 -2
  121. package/dist/es2015/kernel/mime.js +12 -1
  122. package/dist/es2015/kernel/mse.js +47 -6
  123. package/dist/es2015/kernel/prepare.js +2 -2
  124. package/dist/es2015/kernel/reducer.js +83 -26
  125. package/dist/es2015/kernel/refresh.js +2 -2
  126. package/dist/es2015/kernel/rendition-select.js +91 -16
  127. package/dist/es2015/kernel/scheduler.js +1 -1
  128. package/dist/es2015/kernel/sinks/caption-tracks.js +82 -0
  129. package/dist/es2015/kernel/sinks/native-sync.js +46 -0
  130. package/dist/es2015/kernel/sinks/text-formats.js +64 -0
  131. package/dist/es2015/kernel/sinks/text-track-sink.js +15 -4
  132. package/dist/es2015/kernel/timeline.js +12 -8
  133. package/dist/es2015/kernel/trace.js +1 -1
  134. package/dist/es2015/kernel/track-registry.js +6 -3
  135. package/dist/es2015/kernel/transport.js +34 -7
  136. package/dist/es2015/presets/define.js +2 -2
  137. package/dist/es2015/presets/full/index.js +22 -2
  138. package/dist/es2015/protocols/dash-cmaf/index.js +61 -14
  139. package/dist/es2015/protocols/dash-cmaf/parse.js +421 -121
  140. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +134 -0
  141. package/dist/es2015/protocols/dash-cmaf/periods.js +178 -0
  142. package/dist/es2015/protocols/dash-live/index.js +1 -1
  143. package/dist/es2015/protocols/hls-cmaf/index.js +41 -17
  144. package/dist/es2015/protocols/hls-cmaf/lexer.js +2 -1
  145. package/dist/es2015/protocols/hls-cmaf/parse.js +161 -39
  146. package/dist/es2015/protocols/hls-cmaf/unavailable.js +37 -6
  147. package/dist/es2015/protocols/hls-live/index.js +36 -10
  148. package/dist/es2015/stages/abr/index.js +18 -7
  149. package/dist/es2015/stages/abr-persist/index.js +1 -1
  150. package/dist/es2015/stages/aes-128/index.js +1 -1
  151. package/dist/es2015/stages/alt-audio/index.js +7 -5
  152. package/dist/es2015/stages/chapters/index.js +2 -2
  153. package/dist/es2015/stages/chapters/parse.js +2 -2
  154. package/dist/es2015/stages/cmcd/index.js +30 -3
  155. package/dist/es2015/stages/cmsd/index.js +72 -0
  156. package/dist/es2015/stages/codec-probe/index.js +28 -3
  157. package/dist/es2015/stages/content-steering/index.js +1 -1
  158. package/dist/es2015/stages/eme-core/index.js +31 -7
  159. package/dist/es2015/stages/eme-fairplay/index.js +18 -9
  160. package/dist/es2015/stages/hdr/index.js +214 -0
  161. package/dist/es2015/stages/meta-id3/index.js +6 -1
  162. package/dist/es2015/stages/qoe/index.js +111 -0
  163. package/dist/es2015/stages/recovery/index.js +1 -1
  164. package/dist/es2015/stages/rendition-names/index.js +101 -0
  165. package/dist/es2015/stages/text-cea608/decode.js +57 -6
  166. package/dist/es2015/stages/text-cea608/index.js +26 -93
  167. package/dist/es2015/stages/text-cea708/decode.js +379 -0
  168. package/dist/es2015/stages/text-cea708/index.js +98 -0
  169. package/dist/es2015/stages/text-ttml/index.js +88 -0
  170. package/dist/es2015/stages/text-ttml/parse.js +255 -0
  171. package/dist/es2015/stages/text-webvtt/index.js +30 -65
  172. package/dist/es2015/stages/thumbnails/index.js +1 -1
  173. package/dist/es2015/stages/timed-metadata/index.js +331 -0
  174. package/dist/es2015/stages/trick-play/index.js +3 -2
  175. package/dist/index.d.ts +1 -1
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +62 -19
  178. package/dist/index.js.map +1 -1
  179. package/dist/kernel/base64.d.ts +7 -2
  180. package/dist/kernel/base64.d.ts.map +1 -1
  181. package/dist/kernel/base64.js +14 -2
  182. package/dist/kernel/base64.js.map +1 -1
  183. package/dist/kernel/bus.d.ts.map +1 -1
  184. package/dist/kernel/bus.js +12 -9
  185. package/dist/kernel/bus.js.map +1 -1
  186. package/dist/kernel/context.d.ts +3 -1
  187. package/dist/kernel/context.d.ts.map +1 -1
  188. package/dist/kernel/context.js +5 -0
  189. package/dist/kernel/context.js.map +1 -1
  190. package/dist/kernel/lifecycle.d.ts +3 -1
  191. package/dist/kernel/lifecycle.d.ts.map +1 -1
  192. package/dist/kernel/lifecycle.js +1 -0
  193. package/dist/kernel/lifecycle.js.map +1 -1
  194. package/dist/kernel/loader.d.ts.map +1 -1
  195. package/dist/kernel/loader.js +3 -2
  196. package/dist/kernel/loader.js.map +1 -1
  197. package/dist/kernel/mime.d.ts +7 -0
  198. package/dist/kernel/mime.d.ts.map +1 -1
  199. package/dist/kernel/mime.js +12 -0
  200. package/dist/kernel/mime.js.map +1 -1
  201. package/dist/kernel/mse.d.ts.map +1 -1
  202. package/dist/kernel/mse.js +47 -3
  203. package/dist/kernel/mse.js.map +1 -1
  204. package/dist/kernel/reducer.d.ts.map +1 -1
  205. package/dist/kernel/reducer.js +88 -12
  206. package/dist/kernel/reducer.js.map +1 -1
  207. package/dist/kernel/refresh.d.ts.map +1 -1
  208. package/dist/kernel/refresh.js +1 -0
  209. package/dist/kernel/refresh.js.map +1 -1
  210. package/dist/kernel/rendition-select.d.ts +29 -1
  211. package/dist/kernel/rendition-select.d.ts.map +1 -1
  212. package/dist/kernel/rendition-select.js +99 -21
  213. package/dist/kernel/rendition-select.js.map +1 -1
  214. package/dist/kernel/sinks/caption-tracks.d.ts +11 -0
  215. package/dist/kernel/sinks/caption-tracks.d.ts.map +1 -0
  216. package/dist/kernel/sinks/caption-tracks.js +87 -0
  217. package/dist/kernel/sinks/caption-tracks.js.map +1 -0
  218. package/dist/kernel/sinks/native-sync.d.ts +24 -0
  219. package/dist/kernel/sinks/native-sync.d.ts.map +1 -0
  220. package/dist/kernel/sinks/native-sync.js +42 -0
  221. package/dist/kernel/sinks/native-sync.js.map +1 -0
  222. package/dist/kernel/sinks/text-formats.d.ts +25 -0
  223. package/dist/kernel/sinks/text-formats.d.ts.map +1 -0
  224. package/dist/kernel/sinks/text-formats.js +69 -0
  225. package/dist/kernel/sinks/text-formats.js.map +1 -0
  226. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  227. package/dist/kernel/sinks/text-track-sink.js +22 -4
  228. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  229. package/dist/kernel/timeline.d.ts +10 -6
  230. package/dist/kernel/timeline.d.ts.map +1 -1
  231. package/dist/kernel/timeline.js +14 -6
  232. package/dist/kernel/timeline.js.map +1 -1
  233. package/dist/kernel/track-registry.d.ts +2 -2
  234. package/dist/kernel/track-registry.d.ts.map +1 -1
  235. package/dist/kernel/track-registry.js +5 -3
  236. package/dist/kernel/track-registry.js.map +1 -1
  237. package/dist/kernel/transport.d.ts +8 -0
  238. package/dist/kernel/transport.d.ts.map +1 -1
  239. package/dist/kernel/transport.js +28 -1
  240. package/dist/kernel/transport.js.map +1 -1
  241. package/dist/presets/full/index.d.ts.map +1 -1
  242. package/dist/presets/full/index.js +21 -1
  243. package/dist/presets/full/index.js.map +1 -1
  244. package/dist/protocols/adapter-shared.d.ts +8 -0
  245. package/dist/protocols/adapter-shared.d.ts.map +1 -1
  246. package/dist/protocols/adapter-shared.js +6 -0
  247. package/dist/protocols/adapter-shared.js.map +1 -1
  248. package/dist/protocols/dash-cmaf/index.d.ts +9 -1
  249. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  250. package/dist/protocols/dash-cmaf/index.js +78 -14
  251. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  252. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  253. package/dist/protocols/dash-cmaf/parse.js +430 -94
  254. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  255. package/dist/protocols/dash-cmaf/periods-runtime.d.ts +6 -0
  256. package/dist/protocols/dash-cmaf/periods-runtime.d.ts.map +1 -0
  257. package/dist/protocols/dash-cmaf/periods-runtime.js +121 -0
  258. package/dist/protocols/dash-cmaf/periods-runtime.js.map +1 -0
  259. package/dist/protocols/dash-cmaf/periods.d.ts +24 -0
  260. package/dist/protocols/dash-cmaf/periods.d.ts.map +1 -0
  261. package/dist/protocols/dash-cmaf/periods.js +210 -0
  262. package/dist/protocols/dash-cmaf/periods.js.map +1 -0
  263. package/dist/protocols/hls-cmaf/index.d.ts +9 -1
  264. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  265. package/dist/protocols/hls-cmaf/index.js +49 -20
  266. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  267. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  268. package/dist/protocols/hls-cmaf/lexer.js +1 -0
  269. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  270. package/dist/protocols/hls-cmaf/parse.d.ts +3 -1
  271. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  272. package/dist/protocols/hls-cmaf/parse.js +208 -24
  273. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  274. package/dist/protocols/hls-cmaf/unavailable.d.ts +9 -1
  275. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
  276. package/dist/protocols/hls-cmaf/unavailable.js +29 -3
  277. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
  278. package/dist/protocols/hls-live/index.d.ts +9 -1
  279. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  280. package/dist/protocols/hls-live/index.js +36 -7
  281. package/dist/protocols/hls-live/index.js.map +1 -1
  282. package/dist/stages/abr/index.d.ts.map +1 -1
  283. package/dist/stages/abr/index.js +24 -8
  284. package/dist/stages/abr/index.js.map +1 -1
  285. package/dist/stages/alt-audio/index.d.ts +3 -1
  286. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  287. package/dist/stages/alt-audio/index.js +8 -5
  288. package/dist/stages/alt-audio/index.js.map +1 -1
  289. package/dist/stages/cmcd/index.d.ts.map +1 -1
  290. package/dist/stages/cmcd/index.js +39 -3
  291. package/dist/stages/cmcd/index.js.map +1 -1
  292. package/dist/stages/cmsd/index.d.ts +22 -0
  293. package/dist/stages/cmsd/index.d.ts.map +1 -0
  294. package/dist/stages/cmsd/index.js +65 -0
  295. package/dist/stages/cmsd/index.js.map +1 -0
  296. package/dist/stages/codec-probe/index.d.ts.map +1 -1
  297. package/dist/stages/codec-probe/index.js +30 -3
  298. package/dist/stages/codec-probe/index.js.map +1 -1
  299. package/dist/stages/eme-core/index.d.ts +14 -0
  300. package/dist/stages/eme-core/index.d.ts.map +1 -1
  301. package/dist/stages/eme-core/index.js +38 -5
  302. package/dist/stages/eme-core/index.js.map +1 -1
  303. package/dist/stages/eme-fairplay/index.d.ts +5 -0
  304. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  305. package/dist/stages/eme-fairplay/index.js +17 -6
  306. package/dist/stages/eme-fairplay/index.js.map +1 -1
  307. package/dist/stages/hdr/index.d.ts +22 -0
  308. package/dist/stages/hdr/index.d.ts.map +1 -0
  309. package/dist/stages/hdr/index.js +191 -0
  310. package/dist/stages/hdr/index.js.map +1 -0
  311. package/dist/stages/meta-id3/index.d.ts.map +1 -1
  312. package/dist/stages/meta-id3/index.js +6 -2
  313. package/dist/stages/meta-id3/index.js.map +1 -1
  314. package/dist/stages/qoe/index.d.ts +32 -0
  315. package/dist/stages/qoe/index.d.ts.map +1 -0
  316. package/dist/stages/qoe/index.js +116 -0
  317. package/dist/stages/qoe/index.js.map +1 -0
  318. package/dist/stages/rendition-names/index.d.ts +41 -0
  319. package/dist/stages/rendition-names/index.d.ts.map +1 -0
  320. package/dist/stages/rendition-names/index.js +101 -0
  321. package/dist/stages/rendition-names/index.js.map +1 -0
  322. package/dist/stages/text-cea608/decode.d.ts +23 -2
  323. package/dist/stages/text-cea608/decode.d.ts.map +1 -1
  324. package/dist/stages/text-cea608/decode.js +59 -6
  325. package/dist/stages/text-cea608/decode.js.map +1 -1
  326. package/dist/stages/text-cea608/index.d.ts +9 -9
  327. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  328. package/dist/stages/text-cea608/index.js +31 -105
  329. package/dist/stages/text-cea608/index.js.map +1 -1
  330. package/dist/stages/text-cea708/decode.d.ts +79 -0
  331. package/dist/stages/text-cea708/decode.d.ts.map +1 -0
  332. package/dist/stages/text-cea708/decode.js +410 -0
  333. package/dist/stages/text-cea708/decode.js.map +1 -0
  334. package/dist/stages/text-cea708/index.d.ts +3 -0
  335. package/dist/stages/text-cea708/index.d.ts.map +1 -0
  336. package/dist/stages/text-cea708/index.js +93 -0
  337. package/dist/stages/text-cea708/index.js.map +1 -0
  338. package/dist/stages/text-ttml/index.d.ts +3 -0
  339. package/dist/stages/text-ttml/index.d.ts.map +1 -0
  340. package/dist/stages/text-ttml/index.js +74 -0
  341. package/dist/stages/text-ttml/index.js.map +1 -0
  342. package/dist/stages/text-ttml/parse.d.ts +16 -0
  343. package/dist/stages/text-ttml/parse.d.ts.map +1 -0
  344. package/dist/stages/text-ttml/parse.js +277 -0
  345. package/dist/stages/text-ttml/parse.js.map +1 -0
  346. package/dist/stages/text-webvtt/index.d.ts +6 -13
  347. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  348. package/dist/stages/text-webvtt/index.js +21 -68
  349. package/dist/stages/text-webvtt/index.js.map +1 -1
  350. package/dist/stages/timed-metadata/index.d.ts +15 -0
  351. package/dist/stages/timed-metadata/index.d.ts.map +1 -0
  352. package/dist/stages/timed-metadata/index.js +370 -0
  353. package/dist/stages/timed-metadata/index.js.map +1 -0
  354. package/dist/types/error.d.ts +1 -1
  355. package/dist/types/error.d.ts.map +1 -1
  356. package/dist/types/facade.d.ts +8 -10
  357. package/dist/types/facade.d.ts.map +1 -1
  358. package/dist/types/ir.d.ts +90 -0
  359. package/dist/types/ir.d.ts.map +1 -1
  360. package/dist/types/kernel.d.ts +8 -0
  361. package/dist/types/kernel.d.ts.map +1 -1
  362. package/dist/types/messages.d.ts +10 -1
  363. package/dist/types/messages.d.ts.map +1 -1
  364. package/dist/types/metadata.d.ts +59 -0
  365. package/dist/types/metadata.d.ts.map +1 -0
  366. package/dist/types/metadata.js +7 -0
  367. package/dist/types/metadata.js.map +1 -0
  368. package/dist/types/quality.d.ts +10 -0
  369. package/dist/types/quality.d.ts.map +1 -1
  370. package/dist/types/stage.d.ts +17 -0
  371. package/dist/types/stage.d.ts.map +1 -1
  372. package/package.json +10 -2
@@ -1,9 +1,10 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
2
2
  import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
3
- import { resolveUrl } from "../../kernel/url.js";
4
3
  import { base64ToBytes } from "../../kernel/base64.js";
4
+ import { resolveUrl } from "../../kernel/url.js";
5
5
  import { manifestError } from "../adapter-shared.js";
6
6
  import { dimensions } from "../dimensions.js";
7
+ import { flattenPeriods } from "./periods.js";
7
8
  //#region src/protocols/dash-cmaf/parse.ts
8
9
  /**
9
10
  * MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
@@ -136,6 +137,37 @@ function audioCharacteristics(adaptationSet) {
136
137
  }
137
138
  return tags;
138
139
  }
140
+ /**
141
+ * ISO/IEC 23009-1 §5.10.2: a Period's EventStreams. Each Event's
142
+ * presentationTime counts in the stream's timescale from its
143
+ * presentationTimeOffset, relative to the Period start. The body is the
144
+ * messageData attribute, or else the element's text. Events carry the
145
+ * scheme as written; nothing here decides what one means.
146
+ */
147
+ function eventsOf(periodElement, periodStart) {
148
+ const out = [];
149
+ for (const stream of children(periodElement, "EventStream")) {
150
+ var _numberAttr, _numberAttr2;
151
+ const scheme = attr(stream, "schemeIdUri");
152
+ if (scheme === null) continue;
153
+ const value = attr(stream, "value");
154
+ const timescale = (_numberAttr = numberAttr(stream, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : 1;
155
+ const offset = (_numberAttr2 = numberAttr(stream, "presentationTimeOffset")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : 0;
156
+ let index = 0;
157
+ for (const event of children(stream, "Event")) {
158
+ var _numberAttr3, _ref, _attr6, _event$textContent, _attr7;
159
+ const time = (_numberAttr3 = numberAttr(event, "presentationTime")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : 0;
160
+ const duration = numberAttr(event, "duration");
161
+ const data = (_ref = (_attr6 = attr(event, "messageData")) !== null && _attr6 !== void 0 ? _attr6 : (_event$textContent = event.textContent) === null || _event$textContent === void 0 ? void 0 : _event$textContent.trim()) !== null && _ref !== void 0 ? _ref : "";
162
+ out.push(_objectSpread2(_objectSpread2(_objectSpread2({ scheme }, value !== null ? { value } : {}), {}, {
163
+ id: (_attr7 = attr(event, "id")) !== null && _attr7 !== void 0 ? _attr7 : `${scheme}:${index}`,
164
+ start: periodStart + (time - offset) / timescale
165
+ }, duration !== null ? { duration: duration / timescale } : {}), data !== "" ? { data } : {}));
166
+ index += 1;
167
+ }
168
+ }
169
+ return out.sort((a, b) => a.start - b.start);
170
+ }
139
171
  const CEA608_SCHEME = "urn:scte:dash:cc:cea-608:2015";
140
172
  /**
141
173
  * SCTE 214-1: an Accessibility descriptor with the CEA-608 scheme names the
@@ -147,9 +179,9 @@ const CEA608_SCHEME = "urn:scte:dash:cc:cea-608:2015";
147
179
  function captionChannels(adaptationSet) {
148
180
  const out = [];
149
181
  for (const descriptor of children(adaptationSet, "Accessibility")) {
150
- var _attr6;
182
+ var _attr8;
151
183
  if (attr(descriptor, "schemeIdUri") !== CEA608_SCHEME) continue;
152
- const value = ((_attr6 = attr(descriptor, "value")) !== null && _attr6 !== void 0 ? _attr6 : "").trim();
184
+ const value = ((_attr8 = attr(descriptor, "value")) !== null && _attr8 !== void 0 ? _attr8 : "").trim();
153
185
  if (value === "") {
154
186
  out.push(["CC1", null]);
155
187
  continue;
@@ -169,6 +201,114 @@ function captionChannels(adaptationSet) {
169
201
  }
170
202
  return out;
171
203
  }
204
+ const CEA708_SCHEME = "urn:scte:dash:cc:cea-708:2015";
205
+ /**
206
+ * SCTE 214-1: an Accessibility descriptor with the CEA-708 scheme names the
207
+ * caption services of a video AdaptationSet, as "1=lang:eng;2=lang:spa"
208
+ * (other keys such as `war` and `er` beside `lang` are ignored), "1=eng", or
209
+ * bare languages in service order. An empty value means service 1.
210
+ */
211
+ function captionServices(adaptationSet) {
212
+ const out = [];
213
+ for (const descriptor of children(adaptationSet, "Accessibility")) {
214
+ var _attr9;
215
+ if (attr(descriptor, "schemeIdUri") !== CEA708_SCHEME) continue;
216
+ const value = ((_attr9 = attr(descriptor, "value")) !== null && _attr9 !== void 0 ? _attr9 : "").trim();
217
+ if (value === "") {
218
+ out.push(["SERVICE1", null]);
219
+ continue;
220
+ }
221
+ value.split(";").forEach((entry, index) => {
222
+ var _keys$find$split$, _keys$find, _keys$;
223
+ const [left, right] = entry.split("=");
224
+ const service = right === void 0 ? index + 1 : Number.parseInt(left, 10);
225
+ const keys = (right !== null && right !== void 0 ? right : left).split(",");
226
+ const lang = (_keys$find$split$ = (_keys$find = keys.find((key) => key.trim().startsWith("lang:"))) === null || _keys$find === void 0 ? void 0 : _keys$find.split(":")[1]) !== null && _keys$find$split$ !== void 0 ? _keys$find$split$ : keys.length === 1 && !((_keys$ = keys[0]) === null || _keys$ === void 0 ? void 0 : _keys$.includes(":")) ? keys[0] : void 0;
227
+ if (service >= 1 && service <= 63) out.push([`SERVICE${service}`, (lang === null || lang === void 0 ? void 0 : lang.trim()) || null]);
228
+ });
229
+ }
230
+ return out;
231
+ }
232
+ const TRANSFER_CHARACTERISTICS = "urn:mpeg:mpegB:cicp:TransferCharacteristics";
233
+ /**
234
+ * The video range a representation signals: the CICP transfer
235
+ * characteristics property (ISO/IEC 23001-8; DASH-IF IOP), 16 for PQ and 18
236
+ * for HLG, on the Representation or its AdaptationSet; else PQ for a Dolby
237
+ * Vision codec; else nothing.
238
+ */
239
+ /**
240
+ * `@scte214:supplementalCodecs` (ETSI TS 103 285 §5.2.3): a Dolby Vision
241
+ * layer over the base codec. Read by local name, since the prefix is the
242
+ * manifest's choice.
243
+ */
244
+ function supplementalOf(representation, adaptationSet) {
245
+ for (const element of [representation, adaptationSet]) for (const attribute of Array.from(element.attributes)) if (attribute.localName === "supplementalCodecs") return { supplementalCodecs: attribute.value };
246
+ return {};
247
+ }
248
+ function videoRangeOf(representation, adaptationSet, codecs) {
249
+ for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
250
+ if (attr(property, "schemeIdUri") !== TRANSFER_CHARACTERISTICS) continue;
251
+ const value = attr(property, "value");
252
+ return { videoRange: value === "16" ? "PQ" : value === "18" ? "HLG" : "SDR" };
253
+ }
254
+ return codecs !== null && /^dv(h1|he|a1|av)/.test(codecs) ? { videoRange: "PQ" } : {};
255
+ }
256
+ /**
257
+ * Channel counts by ISO/IEC 23091-3 ChannelConfiguration index, from 1 to
258
+ * 20 (index 8 is reserved, so 0, as an unknown count).
259
+ */
260
+ const CICP_CHANNELS = [
261
+ 1,
262
+ 2,
263
+ 3,
264
+ 4,
265
+ 5,
266
+ 6,
267
+ 8,
268
+ 0,
269
+ 3,
270
+ 4,
271
+ 7,
272
+ 8,
273
+ 24,
274
+ 8,
275
+ 12,
276
+ 10,
277
+ 12,
278
+ 14,
279
+ 12,
280
+ 14
281
+ ];
282
+ /**
283
+ * The channel count an AudioChannelConfiguration declares, on the
284
+ * Representation or its AdaptationSet. The MPEG scheme
285
+ * (ISO/IEC 23009-1 §5.8.5.4) writes the count; the CICP scheme an index;
286
+ * the Dolby scheme (ETSI TS 102 366 Annex I) a 16-bit hex mask with one bit
287
+ * per speaker or speaker pair. Another scheme says nothing here.
288
+ */
289
+ function channelsOf(representation, adaptationSet) {
290
+ for (const element of [representation, adaptationSet]) for (const config of children(element, "AudioChannelConfiguration")) {
291
+ var _attr10, _attr11;
292
+ const scheme = (_attr10 = attr(config, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "";
293
+ const value = (_attr11 = attr(config, "value")) !== null && _attr11 !== void 0 ? _attr11 : "";
294
+ let channels = 0;
295
+ if (scheme === "urn:mpeg:dash:23003:3:audio_channel_configuration:2011") channels = Number(value);
296
+ else if (scheme === "urn:mpeg:mpegB:cicp:ChannelConfiguration") {
297
+ var _CICP_CHANNELS;
298
+ channels = (_CICP_CHANNELS = CICP_CHANNELS[Number(value) - 1]) !== null && _CICP_CHANNELS !== void 0 ? _CICP_CHANNELS : 0;
299
+ } else if (/dolby.*audio_channel_configuration/.test(scheme)) {
300
+ const mask = Number.parseInt(value, 16);
301
+ channels = bitCount(mask) + bitCount(mask & 1652);
302
+ }
303
+ if (channels > 0) return { channels };
304
+ }
305
+ return {};
306
+ }
307
+ function bitCount(value) {
308
+ let count = 0;
309
+ for (let bits = value; bits > 0; bits >>= 1) count += bits & 1;
310
+ return count;
311
+ }
172
312
  /**
173
313
  * A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
174
314
  * representation declaring a playout rate other than 1. Both mark an
@@ -177,8 +317,8 @@ function captionChannels(adaptationSet) {
177
317
  */
178
318
  function isTrickMode(adaptationSet) {
179
319
  for (const property of children(adaptationSet, "EssentialProperty")) {
180
- var _attr7;
181
- if (((_attr7 = attr(property, "schemeIdUri")) !== null && _attr7 !== void 0 ? _attr7 : "").includes("trickmode")) return true;
320
+ var _attr12;
321
+ if (((_attr12 = attr(property, "schemeIdUri")) !== null && _attr12 !== void 0 ? _attr12 : "").includes("trickmode")) return true;
182
322
  }
183
323
  if (numberAttr(adaptationSet, "maxPlayoutRate") !== null) return true;
184
324
  for (const representation of children(adaptationSet, "Representation")) {
@@ -197,8 +337,8 @@ function tileGridOf(representation, adaptationSet, width, height) {
197
337
  if (width === null || height === null) return null;
198
338
  const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
199
339
  for (const property of properties) {
200
- var _attr8;
201
- if (!((_attr8 = attr(property, "schemeIdUri")) !== null && _attr8 !== void 0 ? _attr8 : "").includes("thumbnail_tile")) continue;
340
+ var _attr13;
341
+ if (!((_attr13 = attr(property, "schemeIdUri")) !== null && _attr13 !== void 0 ? _attr13 : "").includes("thumbnail_tile")) continue;
202
342
  const grid = dimensions(attr(property, "value"));
203
343
  if (grid === null) continue;
204
344
  const [columns, rows] = grid;
@@ -223,16 +363,16 @@ function mergeTemplates(levels) {
223
363
  let timelineElement = null;
224
364
  let found = false;
225
365
  for (const level of levels) {
226
- var _attr9, _attr10, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
366
+ var _attr14, _attr15, _numberAttr4, _numberAttr5, _numberAttr6, _numberAttr7, _children$2;
227
367
  const template = children(level, "SegmentTemplate")[0];
228
368
  if (template === void 0) continue;
229
369
  found = true;
230
- media = (_attr9 = attr(template, "media")) !== null && _attr9 !== void 0 ? _attr9 : media;
231
- initialization = (_attr10 = attr(template, "initialization")) !== null && _attr10 !== void 0 ? _attr10 : initialization;
232
- timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
233
- startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
234
- duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
235
- pto = (_numberAttr4 = numberAttr(template, "presentationTimeOffset")) !== null && _numberAttr4 !== void 0 ? _numberAttr4 : pto;
370
+ media = (_attr14 = attr(template, "media")) !== null && _attr14 !== void 0 ? _attr14 : media;
371
+ initialization = (_attr15 = attr(template, "initialization")) !== null && _attr15 !== void 0 ? _attr15 : initialization;
372
+ timescale = (_numberAttr4 = numberAttr(template, "timescale")) !== null && _numberAttr4 !== void 0 ? _numberAttr4 : timescale;
373
+ startNumber = (_numberAttr5 = numberAttr(template, "startNumber")) !== null && _numberAttr5 !== void 0 ? _numberAttr5 : startNumber;
374
+ duration = (_numberAttr6 = numberAttr(template, "duration")) !== null && _numberAttr6 !== void 0 ? _numberAttr6 : duration;
375
+ pto = (_numberAttr7 = numberAttr(template, "presentationTimeOffset")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : pto;
236
376
  timelineElement = (_children$2 = children(template, "SegmentTimeline")[0]) !== null && _children$2 !== void 0 ? _children$2 : timelineElement;
237
377
  }
238
378
  if (!found) return null;
@@ -250,17 +390,74 @@ function mergeTemplates(levels) {
250
390
  * SegmentTimeline into compressed runs. @r repeats; a negative @r repeats
251
391
  * until the next S@t, or the period end on the last S.
252
392
  */
393
+ /**
394
+ * ISO/IEC 23009-1 §5.3.9.3: a SegmentList names each segment by URL and
395
+ * optional byte range, timed by @duration or a SegmentTimeline. The
396
+ * attributes and the Initialization inherit from Period to Representation;
397
+ * the SegmentURLs come from the deepest level that has them. Null when no
398
+ * level has a SegmentList.
399
+ */
400
+ function segmentListOf(levels, base, periodStart, periodEndUnits) {
401
+ var _attr17;
402
+ let timescale = 1;
403
+ let duration = null;
404
+ let startNumber = 1;
405
+ let offset = 0;
406
+ let initialization = null;
407
+ let timelineElement = null;
408
+ let urls = [];
409
+ let found = false;
410
+ for (const level of levels) {
411
+ var _numberAttr8, _numberAttr9, _numberAttr10, _numberAttr11, _children$3, _children$4;
412
+ const list = children(level, "SegmentList")[0];
413
+ if (list === void 0) continue;
414
+ found = true;
415
+ timescale = (_numberAttr8 = numberAttr(list, "timescale")) !== null && _numberAttr8 !== void 0 ? _numberAttr8 : timescale;
416
+ duration = (_numberAttr9 = numberAttr(list, "duration")) !== null && _numberAttr9 !== void 0 ? _numberAttr9 : duration;
417
+ startNumber = (_numberAttr10 = numberAttr(list, "startNumber")) !== null && _numberAttr10 !== void 0 ? _numberAttr10 : startNumber;
418
+ offset = (_numberAttr11 = numberAttr(list, "presentationTimeOffset")) !== null && _numberAttr11 !== void 0 ? _numberAttr11 : offset;
419
+ initialization = (_children$3 = children(list, "Initialization")[0]) !== null && _children$3 !== void 0 ? _children$3 : initialization;
420
+ timelineElement = (_children$4 = children(list, "SegmentTimeline")[0]) !== null && _children$4 !== void 0 ? _children$4 : timelineElement;
421
+ const here = children(list, "SegmentURL");
422
+ if (here.length > 0) urls = here;
423
+ }
424
+ if (!found) return null;
425
+ const times = [];
426
+ if (timelineElement !== null) {
427
+ const runs = parseTimeline(timelineElement, periodEndUnits(timescale, offset));
428
+ if (runs === null) return "invalid";
429
+ for (const run of runs) for (let i = 0; i < run.count; i += 1) times.push([run.start + i * run.duration, run.duration]);
430
+ } else if (duration !== null) for (let i = 0; i < urls.length; i += 1) times.push([offset + i * duration, duration]);
431
+ else if (urls.length > 1) return "invalid";
432
+ const segments = [];
433
+ urls.forEach((url, i) => {
434
+ var _times$i, _attr16;
435
+ const [time, length] = (_times$i = times[i]) !== null && _times$i !== void 0 ? _times$i : [offset, 0];
436
+ const range = parseByteRange(attr(url, "mediaRange"));
437
+ segments.push(_objectSpread2({
438
+ seq: startNumber + i,
439
+ start: periodStart + (time - offset) / timescale,
440
+ duration: length / timescale,
441
+ url: resolveUrl((_attr16 = attr(url, "media")) !== null && _attr16 !== void 0 ? _attr16 : "", base)
442
+ }, range !== null ? { byteRange: range } : {}));
443
+ });
444
+ const initRange = initialization === null ? null : parseByteRange(attr(initialization, "range"));
445
+ return {
446
+ segments,
447
+ init: initialization === null ? null : _objectSpread2({ url: resolveUrl((_attr17 = attr(initialization, "sourceURL")) !== null && _attr17 !== void 0 ? _attr17 : "", base) }, initRange !== null ? { byteRange: initRange } : {})
448
+ };
449
+ }
253
450
  function parseTimeline(timelineElement, periodEndUnits) {
254
451
  const sElements = children(timelineElement, "S");
255
452
  const runs = [];
256
453
  let time = 0;
257
454
  for (let i = 0; i < sElements.length; i += 1) {
258
- var _numberAttr5, _numberAttr6;
455
+ var _numberAttr12, _numberAttr13;
259
456
  const s = sElements[i];
260
457
  const d = numberAttr(s, "d");
261
458
  if (d === null || d <= 0) return null;
262
- time = (_numberAttr5 = numberAttr(s, "t")) !== null && _numberAttr5 !== void 0 ? _numberAttr5 : time;
263
- const r = (_numberAttr6 = numberAttr(s, "r")) !== null && _numberAttr6 !== void 0 ? _numberAttr6 : 0;
459
+ time = (_numberAttr12 = numberAttr(s, "t")) !== null && _numberAttr12 !== void 0 ? _numberAttr12 : time;
460
+ const r = (_numberAttr13 = numberAttr(s, "r")) !== null && _numberAttr13 !== void 0 ? _numberAttr13 : 0;
264
461
  let count;
265
462
  if (r >= 0) count = r + 1;
266
463
  else {
@@ -286,80 +483,65 @@ function substituteIdentity(template, id, bandwidth) {
286
483
  });
287
484
  }
288
485
  function contentTypeOf(adaptationSet, mimeType) {
486
+ var _attr18, _children$5;
289
487
  const declared = attr(adaptationSet, "contentType");
290
488
  if (declared === "video" || declared === "audio" || declared === "text" || declared === "image" || declared === "metadata") return declared;
291
489
  if (mimeType.startsWith("audio/")) return "audio";
292
490
  if (mimeType.startsWith("image/")) return "image";
293
491
  if (mimeType.startsWith("text/") || mimeType === "application/ttml+xml") return "text";
492
+ const codecs = (_attr18 = attr(adaptationSet, "codecs")) !== null && _attr18 !== void 0 ? _attr18 : attr((_children$5 = children(adaptationSet, "Representation")[0]) !== null && _children$5 !== void 0 ? _children$5 : adaptationSet, "codecs");
493
+ if (mimeType === "application/mp4" && codecs !== null && /^(stpp|wvtt)/.test(codecs)) return "text";
294
494
  return "video";
295
495
  }
296
- /** parse an MPD document into a Presentation. Never throws. */
297
- function parse(text, baseUrl) {
298
- var _parseDuration, _parseDuration2, _attr18;
299
- let doc;
300
- try {
301
- doc = new DOMParser().parseFromString(text, "text/xml");
302
- } catch (cause) {
496
+ /**
497
+ * Each Period's start and duration (ISO/IEC 23009-1 §5.3.2.1): `@start`, or
498
+ * where the previous period ends; `@duration`, or up to the next period's
499
+ * start, or up to the presentation's end.
500
+ */
501
+ function periodSpans(elements, mpdDuration) {
502
+ const starts = [];
503
+ let previousEnd = 0;
504
+ for (const element of elements) {
505
+ var _parseDuration;
506
+ const start = (_parseDuration = parseDuration(attr(element, "start"))) !== null && _parseDuration !== void 0 ? _parseDuration : previousEnd;
507
+ const duration = parseDuration(attr(element, "duration"));
508
+ starts.push(start);
509
+ previousEnd = start !== null && duration !== null ? start + duration : null;
510
+ }
511
+ return elements.map((element, i) => {
512
+ var _starts$i, _parseDuration2;
513
+ const start = (_starts$i = starts[i]) !== null && _starts$i !== void 0 ? _starts$i : 0;
514
+ const next = starts[i + 1];
303
515
  return {
304
- presentation: null,
305
- error: _objectSpread2(_objectSpread2({}, manifestError("unparsable XML")), {}, { cause })
516
+ start,
517
+ duration: (_parseDuration2 = parseDuration(attr(element, "duration"))) !== null && _parseDuration2 !== void 0 ? _parseDuration2 : next !== null && next !== void 0 ? next - start : mpdDuration !== null ? mpdDuration - start : null
306
518
  };
307
- }
308
- const mpd = doc.documentElement;
309
- if (mpd === null || mpd.localName !== "MPD" || doc.getElementsByTagName("parsererror").length > 0) return {
310
- presentation: null,
311
- error: manifestError("not an MPD document")
312
- };
313
- const isLive = attr(mpd, "type") === "dynamic";
314
- const mpdDuration = parseDuration(attr(mpd, "mediaPresentationDuration"));
315
- const mpdBase = applyBaseUrl(mpd, baseUrl);
316
- let live;
317
- if (isLive) {
318
- var _attr11, _attr12, _attr13;
319
- const availabilityStart = Date.parse((_attr11 = attr(mpd, "availabilityStartTime")) !== null && _attr11 !== void 0 ? _attr11 : "");
320
- const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
321
- const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
322
- const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
323
- const timing = children(mpd, "UTCTiming")[0];
324
- live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
325
- scheme: (_attr12 = attr(timing, "schemeIdUri")) !== null && _attr12 !== void 0 ? _attr12 : "",
326
- value: (_attr13 = attr(timing, "value")) !== null && _attr13 !== void 0 ? _attr13 : ""
327
- } } : {});
328
- }
329
- let steering;
330
- const steeringElement = children(mpd, "ContentSteering")[0];
331
- if (steeringElement !== void 0) {
332
- var _steeringElement$text, _steeringElement$text2;
333
- const serverUri = (_steeringElement$text = (_steeringElement$text2 = steeringElement.textContent) === null || _steeringElement$text2 === void 0 ? void 0 : _steeringElement$text2.trim()) !== null && _steeringElement$text !== void 0 ? _steeringElement$text : "";
334
- if (serverUri !== "") {
335
- const bases = {};
336
- for (const base of children(mpd, "BaseURL")) {
337
- var _base$textContent;
338
- const location = attr(base, "serviceLocation");
339
- const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
340
- if (location !== null && text !== void 0 && text !== "") bases[location] = resolveUrl(text, baseUrl);
341
- }
342
- steering = _objectSpread2(_objectSpread2({ serverUri: resolveUrl(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
343
- }
344
- }
345
- const periodElement = children(mpd, "Period")[0];
346
- if (periodElement === void 0) return {
347
- presentation: null,
348
- error: {
349
- category: "manifest",
350
- code: "MANIFEST_EMPTY",
351
- fatal: true,
352
- recoverable: false,
353
- context: { reason: "MPD with no Period" }
354
- }
355
- };
356
- const periodStart = (_parseDuration = parseDuration(attr(periodElement, "start"))) !== null && _parseDuration !== void 0 ? _parseDuration : 0;
357
- const periodDuration = (_parseDuration2 = parseDuration(attr(periodElement, "duration"))) !== null && _parseDuration2 !== void 0 ? _parseDuration2 : mpdDuration !== null ? mpdDuration - periodStart : null;
519
+ });
520
+ }
521
+ /**
522
+ * The earlier periods an AdaptationSet continues: DASH-IF IOP period
523
+ * continuity and connectivity (ISO/IEC 23009-1 §5.3.2.4), whose value names
524
+ * the earlier Period's id.
525
+ */
526
+ function followsOf(adaptationSet) {
527
+ return children(adaptationSet, "SupplementalProperty").filter((property) => {
528
+ var _attr19;
529
+ return /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test((_attr19 = attr(property, "schemeIdUri")) !== null && _attr19 !== void 0 ? _attr19 : "");
530
+ }).flatMap((property) => {
531
+ var _attr20;
532
+ return ((_attr20 = attr(property, "value")) !== null && _attr20 !== void 0 ? _attr20 : "").split(/[\s,]+/).filter((v) => v !== "");
533
+ });
534
+ }
535
+ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
536
+ var _attr29;
537
+ const matching = /* @__PURE__ */ new Map();
538
+ const periodStart = span.start;
539
+ const periodDuration = span.duration;
358
540
  const periodBase = applyBaseUrl(periodElement, mpdBase);
359
541
  const tracks = [];
360
542
  const adaptationSets = children(periodElement, "AdaptationSet");
361
543
  for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
362
- var _roles$, _trackMime2;
544
+ var _roles$, _trackMime2, _children$6;
363
545
  const adaptationSet = adaptationSets[asIndex];
364
546
  const trick = isTrickMode(adaptationSet);
365
547
  const asPlayoutRate = numberAttr(adaptationSet, "maxPlayoutRate");
@@ -373,19 +555,19 @@ function parse(text, baseUrl) {
373
555
  const renditions = [];
374
556
  let trackMime = null;
375
557
  for (const representation of children(adaptationSet, "Representation")) {
376
- var _ref, _attr14, _trackMime, _parseFrameRate2, _numberAttr8, _attr17;
558
+ var _ref2, _attr21, _trackMime, _parseFrameRate2, _numberAttr15, _attr27, _attr28;
377
559
  const id = attr(representation, "id");
378
560
  const bandwidth = numberAttr(representation, "bandwidth");
379
561
  if (id === null || bandwidth === null) continue;
380
562
  const repBase = applyBaseUrl(representation, asBase);
381
- const mimeType = (_ref = (_attr14 = attr(representation, "mimeType")) !== null && _attr14 !== void 0 ? _attr14 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
563
+ const mimeType = (_ref2 = (_attr21 = attr(representation, "mimeType")) !== null && _attr21 !== void 0 ? _attr21 : asMime) !== null && _ref2 !== void 0 ? _ref2 : "video/mp4";
382
564
  trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
383
565
  const segmentBase = children(representation, "SegmentBase")[0];
384
566
  if (segmentBase !== void 0) {
385
- var _numberAttr7, _parseFrameRate, _attr15;
567
+ var _numberAttr14, _parseFrameRate, _attr22, _attr23;
386
568
  const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
387
569
  if (indexRange === null) continue;
388
- const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
570
+ const baseTimescale = (_numberAttr14 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr14 !== void 0 ? _numberAttr14 : 1;
389
571
  const pto = numberAttr(segmentBase, "presentationTimeOffset");
390
572
  const initElement = children(segmentBase, "Initialization")[0];
391
573
  const initRange = initElement !== void 0 ? parseByteRange(attr(initElement, "range")) : null;
@@ -402,13 +584,31 @@ function parse(text, baseUrl) {
402
584
  const w = numberAttr(representation, "width");
403
585
  const h = numberAttr(representation, "height");
404
586
  const fr = (_parseFrameRate = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate !== void 0 ? _parseFrameRate : parseFrameRate(attr(adaptationSet, "frameRate"));
405
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
587
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
406
588
  id,
407
589
  bitrate: bandwidth,
408
- codecs: (_attr15 = attr(representation, "codecs")) !== null && _attr15 !== void 0 ? _attr15 : asCodecs,
590
+ codecs: (_attr22 = attr(representation, "codecs")) !== null && _attr22 !== void 0 ? _attr22 : asCodecs,
409
591
  mimeType,
410
592
  segments: sidxSegments
411
- }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
593
+ }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr23 = attr(representation, "codecs")) !== null && _attr23 !== void 0 ? _attr23 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
594
+ continue;
595
+ }
596
+ const list = segmentListOf([
597
+ periodElement,
598
+ adaptationSet,
599
+ representation
600
+ ], repBase, periodStart, (timescale, offset) => periodDuration !== null ? Math.round(offset + periodDuration * timescale) : null);
601
+ if (list === "invalid") return { error: manifestError(`bad SegmentList in '${id}'`) };
602
+ if (list !== null) {
603
+ var _attr24, _attr25;
604
+ const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null ? _objectSpread2(_objectSpread2({}, segment), {}, { duration: periodDuration }) : segment);
605
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
606
+ id,
607
+ bitrate: bandwidth,
608
+ codecs: (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs,
609
+ mimeType,
610
+ segments
611
+ }, list.init !== null ? { init: list.init } : {}), numberAttr(representation, "width") !== null ? { width: numberAttr(representation, "width") } : {}), numberAttr(representation, "height") !== null ? { height: numberAttr(representation, "height") } : {}), videoRangeOf(representation, adaptationSet, (_attr25 = attr(representation, "codecs")) !== null && _attr25 !== void 0 ? _attr25 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
412
612
  continue;
413
613
  }
414
614
  const template = mergeTemplates([
@@ -418,11 +618,11 @@ function parse(text, baseUrl) {
418
618
  ]);
419
619
  if (template === null || template.media === null) {
420
620
  if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
421
- var _attr16;
621
+ var _attr26;
422
622
  renditions.push({
423
623
  id,
424
624
  bitrate: bandwidth,
425
- codecs: (_attr16 = attr(representation, "codecs")) !== null && _attr16 !== void 0 ? _attr16 : asCodecs,
625
+ codecs: (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs,
426
626
  mimeType,
427
627
  segments: [{
428
628
  seq: 0,
@@ -436,17 +636,11 @@ function parse(text, baseUrl) {
436
636
  }
437
637
  const periodEndUnits = periodDuration !== null ? Math.round(template.presentationTimeOffset + periodDuration * template.timescale) : null;
438
638
  const timeline = template.timelineElement !== null ? parseTimeline(template.timelineElement, periodEndUnits) : null;
439
- if (template.timelineElement !== null && timeline === null) return {
440
- presentation: null,
441
- error: manifestError(`bad SegmentTimeline in '${id}'`)
442
- };
639
+ if (template.timelineElement !== null && timeline === null) return { error: manifestError(`bad SegmentTimeline in '${id}'`) };
443
640
  let endSeq = null;
444
641
  if (timeline !== null) endSeq = template.startNumber - 1 + timeline.reduce((sum, run) => sum + run.count, 0);
445
642
  else if (template.duration !== null && periodDuration !== null) endSeq = template.startNumber - 1 + Math.ceil(periodDuration * template.timescale / template.duration);
446
- else if (template.duration === null) return {
447
- presentation: null,
448
- error: manifestError(`no addressing for '${id}'`)
449
- };
643
+ else if (template.duration === null) return { error: manifestError(`no addressing for '${id}'`) };
450
644
  const segments = _objectSpread2({
451
645
  kind: "indexed",
452
646
  urlTemplate: resolveUrl(substituteIdentity(template.media, id, bandwidth), repBase),
@@ -461,43 +655,149 @@ function parse(text, baseUrl) {
461
655
  const width = numberAttr(representation, "width");
462
656
  const height = numberAttr(representation, "height");
463
657
  const tiles = tileGridOf(representation, adaptationSet, width, height);
464
- const playoutRate = trick ? (_numberAttr8 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr8 !== void 0 ? _numberAttr8 : asPlayoutRate : null;
465
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
658
+ const playoutRate = trick ? (_numberAttr15 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr15 !== void 0 ? _numberAttr15 : asPlayoutRate : null;
659
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
466
660
  id,
467
661
  bitrate: bandwidth,
468
- codecs: (_attr17 = attr(representation, "codecs")) !== null && _attr17 !== void 0 ? _attr17 : asCodecs,
662
+ codecs: (_attr27 = attr(representation, "codecs")) !== null && _attr27 !== void 0 ? _attr27 : asCodecs,
469
663
  mimeType,
470
664
  segments
471
- }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}));
665
+ }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr28 = attr(representation, "codecs")) !== null && _attr28 !== void 0 ? _attr28 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
472
666
  }
473
667
  if (renditions.length === 0) continue;
474
668
  const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
475
669
  const contentType = contentTypeOf(adaptationSet, mimeType);
476
670
  const characteristics = contentType === "audio" ? audioCharacteristics(adaptationSet) : [];
477
671
  const forced = contentType === "text" && (roles.includes("forced-subtitle") || roles.includes("forced_subtitle"));
478
- tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
479
- id: attr(adaptationSet, "id") !== null ? `as-${attr(adaptationSet, "id")}` : `as-i${asIndex}`,
672
+ const label = (_children$6 = children(adaptationSet, "Label")[0]) === null || _children$6 === void 0 || (_children$6 = _children$6.textContent) === null || _children$6 === void 0 ? void 0 : _children$6.trim();
673
+ const trackId = attr(adaptationSet, "id") !== null ? `as-${attr(adaptationSet, "id")}` : `as-i${asIndex}`;
674
+ matching.set(trackId, {
675
+ asId: attr(adaptationSet, "id"),
676
+ follows: followsOf(adaptationSet)
677
+ });
678
+ tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
679
+ id: trackId,
480
680
  contentType,
481
- mimeType,
681
+ mimeType
682
+ }, label !== void 0 && label !== "" ? { name: label } : {}), {}, {
482
683
  protection: protectionSchemes.length > 0 ? { schemes: protectionSchemes } : null,
483
684
  renditions
484
685
  }, lang !== null ? { lang } : {}), role !== null ? { role } : {}), roles.length > 0 ? { roles } : {}), characteristics.length > 0 ? { characteristics } : {}), forced ? { forced: true } : {}));
485
686
  }
486
687
  const hasVideo = tracks.some((t) => t.contentType === "video");
487
- for (const adaptationSet of hasVideo ? adaptationSets : []) for (const [instreamId, lang] of captionChannels(adaptationSet)) {
488
- const id = `cea608:${instreamId}`;
489
- if (!/^CC[1-4]$/.test(instreamId) || tracks.some((t) => t.id === id)) continue;
490
- tracks.push(_objectSpread2(_objectSpread2({
491
- id,
492
- contentType: "text",
493
- mimeType: "application/cea-608",
494
- protection: null
495
- }, lang !== null ? { lang } : {}), {}, {
496
- role: "caption",
497
- instreamId,
498
- renditions: []
499
- }));
688
+ for (const adaptationSet of hasVideo ? adaptationSets : []) {
689
+ const channels = [...captionChannels(adaptationSet).map(([channel, lang]) => [
690
+ "608",
691
+ channel,
692
+ lang
693
+ ]), ...captionServices(adaptationSet).map(([service, lang]) => [
694
+ "708",
695
+ service,
696
+ lang
697
+ ])];
698
+ for (const [format, instreamId, lang] of channels) {
699
+ const id = `cea${format}:${instreamId}`;
700
+ if (format === "608" && !/^CC[1-4]$/.test(instreamId)) continue;
701
+ if (tracks.some((t) => t.id === id)) continue;
702
+ tracks.push(_objectSpread2(_objectSpread2({
703
+ id,
704
+ contentType: "text",
705
+ mimeType: `application/cea-${format}`,
706
+ protection: null
707
+ }, lang !== null ? { lang } : {}), {}, {
708
+ role: "caption",
709
+ instreamId,
710
+ renditions: []
711
+ }));
712
+ }
713
+ }
714
+ const events = eventsOf(periodElement, periodStart);
715
+ return {
716
+ id: (_attr29 = attr(periodElement, "id")) !== null && _attr29 !== void 0 ? _attr29 : `p${index}`,
717
+ start: periodStart,
718
+ duration: periodDuration,
719
+ tracks,
720
+ events,
721
+ matching
722
+ };
723
+ }
724
+ /** parse an MPD document into a Presentation. Never throws. */
725
+ function parse(text, baseUrl) {
726
+ var _flat$tracks, _flat$events;
727
+ let doc;
728
+ try {
729
+ doc = new DOMParser().parseFromString(text, "text/xml");
730
+ } catch (cause) {
731
+ return {
732
+ presentation: null,
733
+ error: _objectSpread2(_objectSpread2({}, manifestError("unparsable XML")), {}, { cause })
734
+ };
735
+ }
736
+ const mpd = doc.documentElement;
737
+ if (mpd === null || mpd.localName !== "MPD" || doc.getElementsByTagName("parsererror").length > 0) return {
738
+ presentation: null,
739
+ error: manifestError("not an MPD document")
740
+ };
741
+ const isLive = attr(mpd, "type") === "dynamic";
742
+ const mpdDuration = parseDuration(attr(mpd, "mediaPresentationDuration"));
743
+ const mpdBase = applyBaseUrl(mpd, baseUrl);
744
+ let live;
745
+ if (isLive) {
746
+ var _attr30, _attr31, _attr32;
747
+ const availabilityStart = Date.parse((_attr30 = attr(mpd, "availabilityStartTime")) !== null && _attr30 !== void 0 ? _attr30 : "");
748
+ const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
749
+ const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
750
+ const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
751
+ const timing = children(mpd, "UTCTiming")[0];
752
+ live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
753
+ scheme: (_attr31 = attr(timing, "schemeIdUri")) !== null && _attr31 !== void 0 ? _attr31 : "",
754
+ value: (_attr32 = attr(timing, "value")) !== null && _attr32 !== void 0 ? _attr32 : ""
755
+ } } : {});
756
+ }
757
+ let steering;
758
+ const steeringElement = children(mpd, "ContentSteering")[0];
759
+ if (steeringElement !== void 0) {
760
+ var _steeringElement$text, _steeringElement$text2;
761
+ const serverUri = (_steeringElement$text = (_steeringElement$text2 = steeringElement.textContent) === null || _steeringElement$text2 === void 0 ? void 0 : _steeringElement$text2.trim()) !== null && _steeringElement$text !== void 0 ? _steeringElement$text : "";
762
+ if (serverUri !== "") {
763
+ const bases = {};
764
+ for (const base of children(mpd, "BaseURL")) {
765
+ var _base$textContent;
766
+ const location = attr(base, "serviceLocation");
767
+ const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
768
+ if (location !== null && text !== void 0 && text !== "") bases[location] = resolveUrl(text, baseUrl);
769
+ }
770
+ steering = _objectSpread2(_objectSpread2({ serverUri: resolveUrl(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
771
+ }
500
772
  }
773
+ const periodElements = children(mpd, "Period");
774
+ if (periodElements.length === 0) return {
775
+ presentation: null,
776
+ error: {
777
+ category: "manifest",
778
+ code: "MANIFEST_EMPTY",
779
+ fatal: true,
780
+ recoverable: false,
781
+ context: { reason: "MPD with no Period" }
782
+ }
783
+ };
784
+ const spans = periodSpans(periodElements, mpdDuration);
785
+ const parsed = [];
786
+ for (let i = 0; i < periodElements.length; i += 1) {
787
+ if (i > 0 && isLive) break;
788
+ const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive);
789
+ if ("error" in result) return {
790
+ presentation: null,
791
+ error: result.error
792
+ };
793
+ parsed.push(result);
794
+ }
795
+ const flat = parsed.length > 1 ? flattenPeriods(parsed) : null;
796
+ const first = parsed[0];
797
+ const tracks = (_flat$tracks = flat === null || flat === void 0 ? void 0 : flat.tracks) !== null && _flat$tracks !== void 0 ? _flat$tracks : first.tracks;
798
+ const events = (_flat$events = flat === null || flat === void 0 ? void 0 : flat.events) !== null && _flat$events !== void 0 ? _flat$events : first.events;
799
+ const lastSpan = flat === null ? first : parsed[parsed.length - 1];
800
+ const total = flat === null ? first.duration : lastSpan.duration === null ? null : lastSpan.start + lastSpan.duration - first.start;
501
801
  if (tracks.length === 0) return {
502
802
  presentation: null,
503
803
  error: {
@@ -508,19 +808,19 @@ function parse(text, baseUrl) {
508
808
  context: { reason: "no playable adaptation set" }
509
809
  }
510
810
  };
511
- return {
811
+ return _objectSpread2({
512
812
  presentation: _objectSpread2(_objectSpread2(_objectSpread2({
513
813
  id: baseUrl,
514
814
  isLive
515
815
  }, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
516
816
  periods: [_objectSpread2(_objectSpread2({
517
- id: (_attr18 = attr(periodElement, "id")) !== null && _attr18 !== void 0 ? _attr18 : "p0",
518
- start: periodStart
519
- }, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
817
+ id: first.id,
818
+ start: first.start
819
+ }, total !== null ? { duration: total } : {}), {}, { tracks }, events.length > 0 ? { events } : {})],
520
820
  couplings: []
521
821
  }, live !== void 0 ? { live } : {}), steering !== void 0 ? { steering } : {}),
522
822
  error: null
523
- };
823
+ }, flat !== null && flat.warnings.length > 0 ? { warnings: flat.warnings } : {});
524
824
  }
525
825
  /**
526
826
  * Turns a fetched sidx box into explicit byte-range segments. The first media