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,11 @@
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 } from "../../kernel/effects.js";
2
3
  import { normalizeMimeType } from "../../kernel/mime.js";
3
- import { mergeSidx, parse, sidxToSegments } from "./parse.js";
4
+ import { findRendition } from "../../kernel/presentation.js";
5
+ import { isUnresolved } from "../../kernel/timeline.js";
6
+ import { activeRenditions } from "../../kernel/rendition-select.js";
7
+ import { manifestFact } from "../adapter-shared.js";
8
+ import { parse, sidxToSegments } from "./parse.js";
4
9
  //#region src/protocols/dash-cmaf/index.ts
5
10
  /**
6
11
  * The dash-cmaf protocol adapter as a stage. Inert module: exports a
@@ -12,23 +17,25 @@ import { mergeSidx, parse, sidxToSegments } from "./parse.js";
12
17
  * indexed by a `sidx` box, so the concrete segments are unknown until that box
13
18
  * is fetched. That second phase mirrors HLS's media-playlist fetch: the parse
14
19
  * emits `sidx` addressing, this slice fetches the index byte range under a
15
- * `dash:idx:` token the transport correlates back, parses it, and merges the
16
- * resolved segments into the presentation.
20
+ * `dash:idx:` token the transport correlates back, parses it, and feeds the
21
+ * resolved segments back as a PLAYLIST_REFRESHED the kernel merges.
17
22
  */
18
23
  const INDEX_TOKEN = "dash:idx:";
19
24
  /** The MPD MIME type, ISO 23009-1 §C.2. */
20
25
  const MANIFEST_TYPES = ["application/dash+xml"];
21
26
  /** Unresolved on-demand addressing, or null for an explicit list or template. */
22
27
  function asSidx(addressing) {
23
- if (addressing === void 0 || Array.isArray(addressing)) return null;
24
- const candidate = addressing;
25
- return candidate.kind === "sidx" ? candidate : null;
28
+ return addressing !== void 0 && isUnresolved(addressing) ? addressing : null;
26
29
  }
27
30
  const INITIAL = {
28
31
  manifestUrl: null,
29
32
  mimeType: null,
30
- pending: {}
33
+ pending: {},
34
+ failed: {},
35
+ seen: ""
31
36
  };
37
+ /** The constraint source that excludes renditions whose index failed. */
38
+ const UNAVAILABLE = "dash:unavailable";
32
39
  /**
33
40
  * Whether this adapter owns the manifest bytes. An explicit mimeType
34
41
  * decides alone; without one, an MPD is an XML document and starts with
@@ -38,111 +45,148 @@ function claims(state, text) {
38
45
  if (state.mimeType !== null) return MANIFEST_TYPES.includes(state.mimeType);
39
46
  return text.trimStart().startsWith("<");
40
47
  }
41
- function findRendition(presentation, renditionId) {
42
- for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return rendition;
43
- return null;
44
- }
45
48
  /**
46
- * The renditions whose sidx index still needs fetching: every rendition of
47
- * every active track. Resolving only the "chosen" one is not enough, because
48
- * the kernel selects the audio rendition independently (an audio adaptation
49
- * set often has several bitrates) and may pick a different one than this slice
50
- * would; its segments would then stay unresolved and the audio buffer would
51
- * never fill, stalling playback since the element's buffered range is the
52
- * intersection across all source buffers. Resolving them all also means an ABR
53
- * switch finds its target already indexed. The fetches are one small range
54
- * each, so the cost is negligible.
49
+ * The renditions whose sidx index the selection needs and this slice has
50
+ * not asked for: the playing video rendition and its ladder neighbours, and
51
+ * every rendition of the active audio and text tracks. The kernel selects
52
+ * the audio rendition on its own (an audio adaptation set often has several
53
+ * bitrates) and keeps no record of the pick, so all of them resolve; an
54
+ * unresolved one would never fill the audio buffer. The whole video ladder
55
+ * does not: ABR steps one rung at a time, and a longer jump resolves when
56
+ * it happens, while the buffer plays.
55
57
  */
56
- function neededIndexes(kernel) {
57
- const presentation = kernel.presentation;
58
- if (presentation === null) return [];
59
- const activeIds = new Set([
58
+ function neededIndexes(state, kernel) {
59
+ const asked = new Set(Object.values(state.pending));
60
+ const needed = [];
61
+ for (const { rendition } of activeRenditions(kernel, [
60
62
  "video",
61
63
  "audio",
62
64
  "text"
63
- ].map((contentType) => kernel.tracks.active.get(contentType)).filter((id) => id !== void 0));
64
- const needed = [];
65
- for (const period of presentation.periods) for (const track of period.tracks) {
66
- if (!activeIds.has(track.id)) continue;
67
- for (const rendition of track.renditions) if (asSidx(rendition.segments) !== null) needed.push(rendition);
65
+ ], kernel.quality.active)) {
66
+ if (asSidx(rendition.segments) === null) continue;
67
+ if (asked.has(rendition.id) || rendition.id in state.failed) continue;
68
+ needed.push(rendition);
68
69
  }
69
70
  return needed;
70
71
  }
71
72
  /** Loops a message back into the bus through a zero-delay schedule effect. */
72
73
  function feed(message) {
73
- return {
74
- kind: "schedule",
75
- token: "dash:loopback",
76
- delayMs: 0,
77
- then: message
78
- };
74
+ return scheduled("dash:loopback", message);
75
+ }
76
+ /**
77
+ * An index that failed to load or held no segment. The rendition is
78
+ * excluded, so arbitration moves off it and nothing asks for the index
79
+ * again. When that leaves a media track with no rendition at all, the load
80
+ * fails: the stream cannot play, and waiting would only stall.
81
+ */
82
+ function unavailable(state, kernel, renditionId, error) {
83
+ var _findRendition$track, _findRendition;
84
+ const failed = _objectSpread2(_objectSpread2({}, state.failed), {}, { [renditionId]: true });
85
+ const next = _objectSpread2(_objectSpread2({}, state), {}, { failed });
86
+ const presentation = kernel.presentation;
87
+ if (presentation === null) return [next, []];
88
+ const track = (_findRendition$track = (_findRendition = findRendition(presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.track) !== null && _findRendition$track !== void 0 ? _findRendition$track : null;
89
+ const media = (track === null || track === void 0 ? void 0 : track.contentType) === "video" || (track === null || track === void 0 ? void 0 : track.contentType) === "audio";
90
+ if (track !== null && media && track.renditions.every((r) => r.id in failed)) return [next, [feed({
91
+ type: "MANIFEST_FAILED",
92
+ error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
93
+ })]];
94
+ return [next, [feed({
95
+ type: "CONSTRAIN",
96
+ source: UNAVAILABLE,
97
+ constraint: { excludeIds: Object.keys(failed) }
98
+ })]];
79
99
  }
80
100
  const reduceDash = (slice, msg, kernel) => {
81
101
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
82
- if (msg.type === "LOAD") return [{
102
+ if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
83
103
  manifestUrl: msg.url,
84
- mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType),
85
- pending: {}
86
- }, []];
104
+ mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
105
+ }), []];
87
106
  if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
88
107
  if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
89
- const text = new TextDecoder().decode(msg.bytes);
90
- if (!claims(state, text)) return [state, []];
91
- const result = parse(text, state.manifestUrl);
92
- if (result.presentation === null) {
93
- var _result$error;
94
- return [state, [feed({
95
- type: "MANIFEST_FAILED",
96
- error: (_result$error = result.error) !== null && _result$error !== void 0 ? _result$error : {
97
- category: "manifest",
98
- code: "MANIFEST_PARSE_FAILED",
99
- fatal: true,
100
- recoverable: false
101
- }
102
- })]];
108
+ const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), parse);
109
+ return [state, fact === null ? [] : [feed(fact)]];
110
+ }
111
+ let next = state;
112
+ if (msg.type === "PLAYLIST_REFRESHED" && msg.renditionId !== void 0) {
113
+ const renditionId = msg.renditionId;
114
+ const token = `${INDEX_TOKEN}${renditionId}`;
115
+ if (token in next.pending) {
116
+ const pending = _objectSpread2({}, next.pending);
117
+ delete pending[token];
118
+ next = _objectSpread2(_objectSpread2({}, next), {}, { pending });
103
119
  }
104
- return [state, [feed({
105
- type: "MANIFEST_LOADED",
106
- presentation: result.presentation
107
- })]];
108
120
  }
109
- if (msg.type === "SEGMENT_LOADED" && msg.trackId.startsWith(INDEX_TOKEN)) {
121
+ if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
122
+ var _findRendition2;
110
123
  const renditionId = state.pending[msg.trackId];
111
- if (renditionId === void 0 || kernel.presentation === null) return [state, []];
112
- const rendition = findRendition(kernel.presentation, renditionId);
124
+ const sidx = kernel.presentation === null ? null : asSidx((_findRendition2 = findRendition(kernel.presentation, renditionId)) === null || _findRendition2 === void 0 ? void 0 : _findRendition2.rendition.segments);
125
+ const segments = sidx === null ? [] : sidxToSegments(new Uint8Array(msg.bytes), sidx);
126
+ if (sidx !== null && segments.length > 0) {
127
+ var _segments$0$seq, _segments$;
128
+ return [state, [feed({
129
+ type: "PLAYLIST_REFRESHED",
130
+ trackId: renditionId,
131
+ renditionId,
132
+ mediaSequence: (_segments$0$seq = (_segments$ = segments[0]) === null || _segments$ === void 0 ? void 0 : _segments$.seq) !== null && _segments$0$seq !== void 0 ? _segments$0$seq : 0,
133
+ segments
134
+ })]];
135
+ }
113
136
  const pending = _objectSpread2({}, state.pending);
114
137
  delete pending[msg.trackId];
115
- const sidx = asSidx(rendition === null || rendition === void 0 ? void 0 : rendition.segments);
116
138
  if (sidx === null) return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), []];
117
- const segments = sidxToSegments(new Uint8Array(msg.bytes), sidx);
118
- if (segments.length === 0) return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), []];
119
- const merged = mergeSidx(kernel.presentation, renditionId, segments);
120
- return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), [feed({
121
- type: "MANIFEST_LOADED",
122
- presentation: merged
123
- })]];
139
+ const error = {
140
+ category: "media",
141
+ code: "MEDIA_CONTAINER_INVALID",
142
+ fatal: false,
143
+ recoverable: false,
144
+ context: {
145
+ renditionId,
146
+ reason: "sidx holds no segment"
147
+ }
148
+ };
149
+ const [failed, failEffects] = unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, error);
150
+ return [failed, [{
151
+ kind: "emit",
152
+ event: "error",
153
+ payload: {
154
+ category: error.category,
155
+ code: error.code,
156
+ fatal: false,
157
+ recoverable: false,
158
+ renditionId
159
+ }
160
+ }, ...failEffects]];
124
161
  }
125
- if ((msg.type === "MANIFEST_LOADED" || msg.type === "TIME_UPDATE" || msg.type === "RESUME") && kernel.lifecycle.phase !== "suspended") {
126
- const needed = neededIndexes(kernel).filter((rendition) => !Object.values(state.pending).includes(rendition.id));
127
- if (needed.length === 0) return [state, []];
128
- const effects = [];
162
+ if (msg.type === "SEGMENT_FAILED" && msg.trackId in state.pending) {
163
+ const renditionId = state.pending[msg.trackId];
129
164
  const pending = _objectSpread2({}, state.pending);
130
- for (const rendition of needed) {
131
- const token = `${INDEX_TOKEN}${rendition.id}`;
132
- if (pending[token] !== void 0) continue;
133
- const sidx = asSidx(rendition.segments);
134
- if (sidx === null) continue;
135
- pending[token] = rendition.id;
136
- effects.push({
137
- kind: "fetch",
138
- token,
139
- url: sidx.url,
140
- range: sidx.indexRange
141
- });
142
- }
143
- return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), effects];
165
+ delete pending[msg.trackId];
166
+ return unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, msg.error);
167
+ }
168
+ if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [next, []];
169
+ const key = `${kernel.quality.version}:${kernel.quality.active}`;
170
+ if (key === next.seen && msg.type !== "RESUME") return [next, []];
171
+ const effects = [];
172
+ const pending = _objectSpread2({}, next.pending);
173
+ for (const rendition of neededIndexes(next, kernel)) {
174
+ const sidx = asSidx(rendition.segments);
175
+ if (sidx === null) continue;
176
+ const token = `${INDEX_TOKEN}${rendition.id}`;
177
+ pending[token] = rendition.id;
178
+ effects.push({
179
+ kind: "fetch",
180
+ token,
181
+ url: sidx.url,
182
+ range: sidx.indexRange,
183
+ renditionId: rendition.id
184
+ });
144
185
  }
145
- return [state, []];
186
+ return [_objectSpread2(_objectSpread2({}, next), {}, {
187
+ pending,
188
+ seen: key
189
+ }), effects];
146
190
  };
147
191
  /**
148
192
  * The stage factory. `mattebox({ stages: [dashCmaf()] })` is all a consumer
@@ -1,5 +1,9 @@
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
2
  import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
3
+ import { resolveUrl } from "../../kernel/url.js";
4
+ import { base64ToBytes } from "../../kernel/base64.js";
5
+ import { manifestError } from "../adapter-shared.js";
6
+ import { dimensions } from "../dimensions.js";
3
7
  //#region src/protocols/dash-cmaf/parse.ts
4
8
  /**
5
9
  * MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
@@ -17,22 +21,6 @@ import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
17
21
  * becomes IndexedSegments and the kernel materializes one segment at a
18
22
  * time, so a long window never becomes an array.
19
23
  */
20
- function manifestError(reason) {
21
- return {
22
- category: "manifest",
23
- code: "MANIFEST_PARSE_FAILED",
24
- fatal: true,
25
- recoverable: false,
26
- context: { reason }
27
- };
28
- }
29
- function resolve(uri, baseUrl) {
30
- try {
31
- return new URL(uri, baseUrl).href;
32
- } catch (_unused) {
33
- return uri;
34
- }
35
- }
36
24
  /** ISO 8601 duration to seconds. Date parts use nominal day lengths. */
37
25
  function parseDuration(value) {
38
26
  if (value === null) return null;
@@ -80,17 +68,7 @@ function parseByteRange(value) {
80
68
  function applyBaseUrl(element, base) {
81
69
  var _baseElements$;
82
70
  const text = (_baseElements$ = children(element, "BaseURL")[0]) === null || _baseElements$ === void 0 || (_baseElements$ = _baseElements$.textContent) === null || _baseElements$ === void 0 ? void 0 : _baseElements$.trim();
83
- return text !== void 0 && text !== "" ? resolve(text, base) : base;
84
- }
85
- function base64ToArrayBuffer(text) {
86
- try {
87
- const binary = atob(text.replace(/\s+/g, ""));
88
- const bytes = new Uint8Array(binary.length);
89
- for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
90
- return bytes.buffer;
91
- } catch (_unused2) {
92
- return null;
93
- }
71
+ return text !== void 0 && text !== "" ? resolveUrl(text, base) : base;
94
72
  }
95
73
  const MP4_PROTECTION = "urn:mpeg:dash:mp4protection:2011";
96
74
  const UUID_URN = /^urn:uuid:([0-9a-f-]{36})$/i;
@@ -113,12 +91,12 @@ function parseProtection(elements) {
113
91
  }
114
92
  const schemes = [];
115
93
  for (const element of elements) {
116
- var _attr4, _children$;
94
+ var _attr4, _children$, _base64ToBytes$buffer, _base64ToBytes;
117
95
  const schemeIdUri = (_attr4 = attr(element, "schemeIdUri")) !== null && _attr4 !== void 0 ? _attr4 : "";
118
96
  const uuid = UUID_URN.exec(schemeIdUri);
119
97
  if (uuid === null) continue;
120
98
  const pssh = (_children$ = children(element, "pssh")[0]) === null || _children$ === void 0 || (_children$ = _children$.textContent) === null || _children$ === void 0 ? void 0 : _children$.trim();
121
- const initData = pssh !== void 0 && pssh !== "" ? base64ToArrayBuffer(pssh) : null;
99
+ const initData = pssh !== void 0 && pssh !== "" ? (_base64ToBytes$buffer = (_base64ToBytes = base64ToBytes(pssh)) === null || _base64ToBytes === void 0 ? void 0 : _base64ToBytes.buffer) !== null && _base64ToBytes$buffer !== void 0 ? _base64ToBytes$buffer : null : null;
122
100
  schemes.push({
123
101
  systemId: uuid[1].toLowerCase(),
124
102
  scheme: commonScheme,
@@ -141,7 +119,8 @@ function parseProtection(elements) {
141
119
  /**
142
120
  * A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
143
121
  * representation declaring a playout rate other than 1. Both mark an
144
- * I-frame-only set meant for scrubbing, never for normal playback.
122
+ * I-frame-only set meant for fast forward and previews, never for normal
123
+ * playback.
145
124
  */
146
125
  function isTrickMode(adaptationSet) {
147
126
  for (const property of children(adaptationSet, "EssentialProperty")) {
@@ -155,6 +134,30 @@ function isTrickMode(adaptationSet) {
155
134
  }
156
135
  return false;
157
136
  }
137
+ /**
138
+ * The DASH-IF IOP thumbnail grid: an EssentialProperty with the
139
+ * thumbnail_tile scheme and value `CxR`, on the Representation or its
140
+ * AdaptationSet. The Representation's width and height are the whole image,
141
+ * so one tile is that size divided by the grid.
142
+ */
143
+ function tileGridOf(representation, adaptationSet, width, height) {
144
+ if (width === null || height === null) return null;
145
+ const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
146
+ for (const property of properties) {
147
+ var _attr6;
148
+ if (!((_attr6 = attr(property, "schemeIdUri")) !== null && _attr6 !== void 0 ? _attr6 : "").includes("thumbnail_tile")) continue;
149
+ const grid = dimensions(attr(property, "value"));
150
+ if (grid === null) continue;
151
+ const [columns, rows] = grid;
152
+ return {
153
+ columns,
154
+ rows,
155
+ width: width / columns,
156
+ height: height / rows
157
+ };
158
+ }
159
+ return null;
160
+ }
158
161
  /** Merges SegmentTemplate attributes down Period, AdaptationSet, Representation. */
159
162
  function mergeTemplates(levels) {
160
163
  var _timescale, _startNumber, _pto;
@@ -167,12 +170,12 @@ function mergeTemplates(levels) {
167
170
  let timelineElement = null;
168
171
  let found = false;
169
172
  for (const level of levels) {
170
- var _attr6, _attr7, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
173
+ var _attr7, _attr8, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
171
174
  const template = children(level, "SegmentTemplate")[0];
172
175
  if (template === void 0) continue;
173
176
  found = true;
174
- media = (_attr6 = attr(template, "media")) !== null && _attr6 !== void 0 ? _attr6 : media;
175
- initialization = (_attr7 = attr(template, "initialization")) !== null && _attr7 !== void 0 ? _attr7 : initialization;
177
+ media = (_attr7 = attr(template, "media")) !== null && _attr7 !== void 0 ? _attr7 : media;
178
+ initialization = (_attr8 = attr(template, "initialization")) !== null && _attr8 !== void 0 ? _attr8 : initialization;
176
179
  timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
177
180
  startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
178
181
  duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
@@ -239,7 +242,7 @@ function contentTypeOf(adaptationSet, mimeType) {
239
242
  }
240
243
  /** parse an MPD document into a Presentation. Never throws. */
241
244
  function parse(text, baseUrl) {
242
- var _parseDuration, _parseDuration2, _attr15;
245
+ var _parseDuration, _parseDuration2, _attr16;
243
246
  let doc;
244
247
  try {
245
248
  doc = new DOMParser().parseFromString(text, "text/xml");
@@ -259,15 +262,15 @@ function parse(text, baseUrl) {
259
262
  const mpdBase = applyBaseUrl(mpd, baseUrl);
260
263
  let live;
261
264
  if (isLive) {
262
- var _attr8, _attr9, _attr10;
263
- const availabilityStart = Date.parse((_attr8 = attr(mpd, "availabilityStartTime")) !== null && _attr8 !== void 0 ? _attr8 : "");
265
+ var _attr9, _attr10, _attr11;
266
+ const availabilityStart = Date.parse((_attr9 = attr(mpd, "availabilityStartTime")) !== null && _attr9 !== void 0 ? _attr9 : "");
264
267
  const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
265
268
  const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
266
269
  const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
267
270
  const timing = children(mpd, "UTCTiming")[0];
268
271
  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: {
269
- scheme: (_attr9 = attr(timing, "schemeIdUri")) !== null && _attr9 !== void 0 ? _attr9 : "",
270
- value: (_attr10 = attr(timing, "value")) !== null && _attr10 !== void 0 ? _attr10 : ""
272
+ scheme: (_attr10 = attr(timing, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "",
273
+ value: (_attr11 = attr(timing, "value")) !== null && _attr11 !== void 0 ? _attr11 : ""
271
274
  } } : {});
272
275
  }
273
276
  let steering;
@@ -281,9 +284,9 @@ function parse(text, baseUrl) {
281
284
  var _base$textContent;
282
285
  const location = attr(base, "serviceLocation");
283
286
  const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
284
- if (location !== null && text !== void 0 && text !== "") bases[location] = resolve(text, baseUrl);
287
+ if (location !== null && text !== void 0 && text !== "") bases[location] = resolveUrl(text, baseUrl);
285
288
  }
286
- steering = _objectSpread2(_objectSpread2({ serverUri: resolve(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
289
+ steering = _objectSpread2(_objectSpread2({ serverUri: resolveUrl(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
287
290
  }
288
291
  }
289
292
  const periodElement = children(mpd, "Period")[0];
@@ -305,26 +308,27 @@ function parse(text, baseUrl) {
305
308
  for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
306
309
  var _children$0$getAttrib, _children$3, _trackMime2;
307
310
  const adaptationSet = adaptationSets[asIndex];
308
- if (isTrickMode(adaptationSet)) continue;
311
+ const trick = isTrickMode(adaptationSet);
312
+ const asPlayoutRate = numberAttr(adaptationSet, "maxPlayoutRate");
309
313
  const asBase = applyBaseUrl(adaptationSet, periodBase);
310
314
  const asMime = attr(adaptationSet, "mimeType");
311
315
  const asCodecs = attr(adaptationSet, "codecs");
312
316
  const lang = attr(adaptationSet, "lang");
313
- const role = (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
317
+ const role = trick ? "trick" : (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
314
318
  const protectionSchemes = parseProtection(children(adaptationSet, "ContentProtection"));
315
319
  const renditions = [];
316
320
  let trackMime = null;
317
321
  for (const representation of children(adaptationSet, "Representation")) {
318
- var _ref, _attr11, _trackMime, _parseFrameRate2, _attr14;
322
+ var _ref, _attr12, _trackMime, _parseFrameRate2, _numberAttr8, _attr15;
319
323
  const id = attr(representation, "id");
320
324
  const bandwidth = numberAttr(representation, "bandwidth");
321
325
  if (id === null || bandwidth === null) continue;
322
326
  const repBase = applyBaseUrl(representation, asBase);
323
- const mimeType = (_ref = (_attr11 = attr(representation, "mimeType")) !== null && _attr11 !== void 0 ? _attr11 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
327
+ const mimeType = (_ref = (_attr12 = attr(representation, "mimeType")) !== null && _attr12 !== void 0 ? _attr12 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
324
328
  trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
325
329
  const segmentBase = children(representation, "SegmentBase")[0];
326
330
  if (segmentBase !== void 0) {
327
- var _numberAttr7, _parseFrameRate, _attr12;
331
+ var _numberAttr7, _parseFrameRate, _attr13;
328
332
  const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
329
333
  if (indexRange === null) continue;
330
334
  const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
@@ -347,7 +351,7 @@ function parse(text, baseUrl) {
347
351
  renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
348
352
  id,
349
353
  bitrate: bandwidth,
350
- codecs: (_attr12 = attr(representation, "codecs")) !== null && _attr12 !== void 0 ? _attr12 : asCodecs,
354
+ codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
351
355
  mimeType,
352
356
  segments: sidxSegments
353
357
  }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
@@ -360,11 +364,11 @@ function parse(text, baseUrl) {
360
364
  ]);
361
365
  if (template === null || template.media === null) {
362
366
  if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
363
- var _attr13;
367
+ var _attr14;
364
368
  renditions.push({
365
369
  id,
366
370
  bitrate: bandwidth,
367
- codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
371
+ codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
368
372
  mimeType,
369
373
  segments: [{
370
374
  seq: 0,
@@ -391,24 +395,26 @@ function parse(text, baseUrl) {
391
395
  };
392
396
  const segments = _objectSpread2({
393
397
  kind: "indexed",
394
- urlTemplate: resolve(substituteIdentity(template.media, id, bandwidth), repBase),
398
+ urlTemplate: resolveUrl(substituteIdentity(template.media, id, bandwidth), repBase),
395
399
  startSeq: template.startNumber,
396
400
  endSeq: isLive ? null : endSeq,
397
401
  timescale: template.timescale,
398
402
  segmentDuration: timeline !== null ? null : template.duration,
399
403
  timeline
400
404
  }, template.presentationTimeOffset !== 0 ? { presentationTimeOffset: template.presentationTimeOffset } : {});
401
- const init = template.initialization !== null ? { url: resolve(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
405
+ const init = template.initialization !== null ? { url: resolveUrl(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
402
406
  const frameRate = (_parseFrameRate2 = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate2 !== void 0 ? _parseFrameRate2 : parseFrameRate(attr(adaptationSet, "frameRate"));
403
407
  const width = numberAttr(representation, "width");
404
408
  const height = numberAttr(representation, "height");
405
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
409
+ const tiles = tileGridOf(representation, adaptationSet, width, height);
410
+ const playoutRate = trick ? (_numberAttr8 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr8 !== void 0 ? _numberAttr8 : asPlayoutRate : null;
411
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
406
412
  id,
407
413
  bitrate: bandwidth,
408
- codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
414
+ codecs: (_attr15 = attr(representation, "codecs")) !== null && _attr15 !== void 0 ? _attr15 : asCodecs,
409
415
  mimeType,
410
416
  segments
411
- }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}));
417
+ }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}));
412
418
  }
413
419
  if (renditions.length === 0) continue;
414
420
  const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
@@ -436,7 +442,7 @@ function parse(text, baseUrl) {
436
442
  isLive
437
443
  }, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
438
444
  periods: [_objectSpread2(_objectSpread2({
439
- id: (_attr15 = attr(periodElement, "id")) !== null && _attr15 !== void 0 ? _attr15 : "p0",
445
+ id: (_attr16 = attr(periodElement, "id")) !== null && _attr16 !== void 0 ? _attr16 : "p0",
440
446
  start: periodStart
441
447
  }, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
442
448
  couplings: []
@@ -479,13 +485,5 @@ function sidxToSegments(sidxBytes, addressing) {
479
485
  }
480
486
  return segments;
481
487
  }
482
- /**
483
- * Immutably swaps a rendition's unresolved sidx addressing for the explicit
484
- * segment list parsed from its index box. Everything else about the
485
- * presentation is already known from the MPD.
486
- */
487
- function mergeSidx(presentation, renditionId, segments) {
488
- return _objectSpread2(_objectSpread2({}, presentation), {}, { periods: presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => track.renditions.some((r) => r.id === renditionId) ? _objectSpread2(_objectSpread2({}, track), {}, { renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments }) : rendition) }) : track) })) });
489
- }
490
488
  //#endregion
491
- export { mergeSidx, parse, parseDuration, sidxToSegments };
489
+ export { parse, parseDuration, sidxToSegments };