@blockcast/mmt-container 0.1.0-main.149f78a4adae

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 (678) hide show
  1. package/README.md +432 -0
  2. package/dist/.build-stamp +0 -0
  3. package/dist/__tests__/test-utils.d.ts +71 -0
  4. package/dist/__tests__/test-utils.d.ts.map +1 -0
  5. package/dist/align.d.ts +148 -0
  6. package/dist/align.d.ts.map +1 -0
  7. package/dist/align.js +88 -0
  8. package/dist/align.js.map +7 -0
  9. package/dist/audio-init-parser.d.ts +66 -0
  10. package/dist/audio-init-parser.d.ts.map +1 -0
  11. package/dist/audio-init-parser.js +118 -0
  12. package/dist/audio-init-parser.js.map +7 -0
  13. package/dist/audio-ring-buffer.d.ts +50 -0
  14. package/dist/audio-ring-buffer.d.ts.map +1 -0
  15. package/dist/audio-ring-buffer.js +93 -0
  16. package/dist/audio-ring-buffer.js.map +7 -0
  17. package/dist/authored-timing.d.ts +32 -0
  18. package/dist/authored-timing.d.ts.map +1 -0
  19. package/dist/authored-timing.js +32 -0
  20. package/dist/authored-timing.js.map +7 -0
  21. package/dist/browser-runtime.js +17109 -0
  22. package/dist/browser-runtime.js.map +7 -0
  23. package/dist/carp-catalog.d.ts +318 -0
  24. package/dist/carp-catalog.d.ts.map +1 -0
  25. package/dist/carp-catalog.js +549 -0
  26. package/dist/carp-catalog.js.map +7 -0
  27. package/dist/catalog-fec-params.d.ts +82 -0
  28. package/dist/catalog-fec-params.d.ts.map +1 -0
  29. package/dist/catalog-fec-params.js +66 -0
  30. package/dist/catalog-fec-params.js.map +7 -0
  31. package/dist/catalog-network-source.d.ts +19 -0
  32. package/dist/catalog-network-source.d.ts.map +1 -0
  33. package/dist/catalog-network-source.js +22 -0
  34. package/dist/catalog-network-source.js.map +7 -0
  35. package/dist/catalog-validator.d.ts +18 -0
  36. package/dist/catalog-validator.d.ts.map +1 -0
  37. package/dist/catalog-validator.js +7747 -0
  38. package/dist/catalog-validator.js.map +7 -0
  39. package/dist/cmaf-block-assembler.d.ts +168 -0
  40. package/dist/cmaf-block-assembler.d.ts.map +1 -0
  41. package/dist/cmaf-block-assembler.js +1755 -0
  42. package/dist/cmaf-block-assembler.js.map +7 -0
  43. package/dist/cmaf-group-batcher.d.ts +38 -0
  44. package/dist/cmaf-group-batcher.d.ts.map +1 -0
  45. package/dist/cmaf-group-batcher.js +195 -0
  46. package/dist/cmaf-group-batcher.js.map +7 -0
  47. package/dist/cmcd-producer.d.ts +104 -0
  48. package/dist/cmcd-producer.d.ts.map +1 -0
  49. package/dist/cmcd-producer.js +207 -0
  50. package/dist/cmcd-producer.js.map +7 -0
  51. package/dist/codec-utils.d.ts +235 -0
  52. package/dist/codec-utils.d.ts.map +1 -0
  53. package/dist/codec-utils.js +1225 -0
  54. package/dist/codec-utils.js.map +7 -0
  55. package/dist/fec-codec.d.ts +32 -0
  56. package/dist/fec-codec.d.ts.map +1 -0
  57. package/dist/fec-codec.js +47 -0
  58. package/dist/fec-codec.js.map +7 -0
  59. package/dist/fec-manager.d.ts +266 -0
  60. package/dist/fec-manager.d.ts.map +1 -0
  61. package/dist/fec-manager.js +1447 -0
  62. package/dist/fec-manager.js.map +7 -0
  63. package/dist/fec-starvation-detector.d.ts +59 -0
  64. package/dist/fec-starvation-detector.d.ts.map +1 -0
  65. package/dist/fec-starvation-detector.js +75 -0
  66. package/dist/fec-starvation-detector.js.map +7 -0
  67. package/dist/fec-worker-setup.d.ts +76 -0
  68. package/dist/fec-worker-setup.d.ts.map +1 -0
  69. package/dist/fec-worker-setup.js +603 -0
  70. package/dist/fec-worker-setup.js.map +7 -0
  71. package/dist/fmp4-completion.d.ts +30 -0
  72. package/dist/fmp4-completion.d.ts.map +1 -0
  73. package/dist/fmp4-completion.js +21 -0
  74. package/dist/fmp4-completion.js.map +7 -0
  75. package/dist/fmp4-reader.d.ts +37 -0
  76. package/dist/fmp4-reader.d.ts.map +1 -0
  77. package/dist/fmp4-reader.js +100 -0
  78. package/dist/fmp4-reader.js.map +7 -0
  79. package/dist/index.d.ts +47 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +330 -0
  82. package/dist/index.js.map +7 -0
  83. package/dist/iso-bmff-timing.d.ts +47 -0
  84. package/dist/iso-bmff-timing.d.ts.map +1 -0
  85. package/dist/iso-bmff-timing.js +526 -0
  86. package/dist/iso-bmff-timing.js.map +7 -0
  87. package/dist/loc.d.ts +68 -0
  88. package/dist/loc.d.ts.map +1 -0
  89. package/dist/loc.js +143 -0
  90. package/dist/loc.js.map +7 -0
  91. package/dist/manifest-auth-plan.d.ts +30 -0
  92. package/dist/manifest-auth-plan.d.ts.map +1 -0
  93. package/dist/manifest-auth-plan.js +1267 -0
  94. package/dist/manifest-auth-plan.js.map +7 -0
  95. package/dist/media-router.d.ts +338 -0
  96. package/dist/media-router.d.ts.map +1 -0
  97. package/dist/media-router.js +802 -0
  98. package/dist/media-router.js.map +7 -0
  99. package/dist/mfu-reassembler.d.ts +264 -0
  100. package/dist/mfu-reassembler.d.ts.map +1 -0
  101. package/dist/mfu-reassembler.js +2668 -0
  102. package/dist/mfu-reassembler.js.map +7 -0
  103. package/dist/mfu-reassembly-policy.d.ts +24 -0
  104. package/dist/mfu-reassembly-policy.d.ts.map +1 -0
  105. package/dist/mfu-reassembly-policy.js +99 -0
  106. package/dist/mfu-reassembly-policy.js.map +7 -0
  107. package/dist/mmtp-container-parser.d.ts +304 -0
  108. package/dist/mmtp-container-parser.d.ts.map +1 -0
  109. package/dist/mmtp-container-parser.js +5378 -0
  110. package/dist/mmtp-container-parser.js.map +7 -0
  111. package/dist/mmtp-container-parser.no-modules.js +7853 -0
  112. package/dist/mmtp-container-parser.no-modules.js.map +7 -0
  113. package/dist/mmtp-decode-pipeline.d.ts +96 -0
  114. package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
  115. package/dist/mmtp-decode-pipeline.js +5589 -0
  116. package/dist/mmtp-decode-pipeline.js.map +7 -0
  117. package/dist/mmtp-router.d.ts +383 -0
  118. package/dist/mmtp-router.d.ts.map +1 -0
  119. package/dist/mmtp-router.js +8384 -0
  120. package/dist/mmtp-router.js.map +7 -0
  121. package/dist/mmtp-to-cmaf.d.ts +166 -0
  122. package/dist/mmtp-to-cmaf.d.ts.map +1 -0
  123. package/dist/mmtp-to-cmaf.js +781 -0
  124. package/dist/mmtp-to-cmaf.js.map +7 -0
  125. package/dist/multicast-auth-catalog.d.ts +115 -0
  126. package/dist/multicast-auth-catalog.d.ts.map +1 -0
  127. package/dist/multicast-auth-catalog.js +202 -0
  128. package/dist/multicast-auth-catalog.js.map +7 -0
  129. package/dist/multicast-input.d.ts +107 -0
  130. package/dist/multicast-input.d.ts.map +1 -0
  131. package/dist/multicast-input.js +256 -0
  132. package/dist/multicast-input.js.map +7 -0
  133. package/dist/multicast-manager.d.ts +330 -0
  134. package/dist/multicast-manager.d.ts.map +1 -0
  135. package/dist/multicast-manager.js +11032 -0
  136. package/dist/multicast-manager.js.map +7 -0
  137. package/dist/multicast-transport.d.ts +62 -0
  138. package/dist/multicast-transport.d.ts.map +1 -0
  139. package/dist/multicast-transport.js +338 -0
  140. package/dist/multicast-transport.js.map +7 -0
  141. package/dist/multicast-unwrap.d.ts +57 -0
  142. package/dist/multicast-unwrap.d.ts.map +1 -0
  143. package/dist/multicast-unwrap.js +384 -0
  144. package/dist/multicast-unwrap.js.map +7 -0
  145. package/dist/no-modules.d.ts +9 -0
  146. package/dist/no-modules.d.ts.map +1 -0
  147. package/dist/no-modules.js +7819 -0
  148. package/dist/no-modules.js.map +7 -0
  149. package/dist/phase14-catalog-override.d.ts +126 -0
  150. package/dist/phase14-catalog-override.d.ts.map +1 -0
  151. package/dist/phase14-catalog-override.js +155 -0
  152. package/dist/phase14-catalog-override.js.map +7 -0
  153. package/dist/repair-fetch.d.ts +58 -0
  154. package/dist/repair-fetch.d.ts.map +1 -0
  155. package/dist/repair-fetch.js +117 -0
  156. package/dist/repair-fetch.js.map +7 -0
  157. package/dist/sample-combiner.d.ts +182 -0
  158. package/dist/sample-combiner.d.ts.map +1 -0
  159. package/dist/sample-combiner.js +571 -0
  160. package/dist/sample-combiner.js.map +7 -0
  161. package/dist/signaling.d.ts +29 -0
  162. package/dist/signaling.d.ts.map +1 -0
  163. package/dist/signaling.js +232 -0
  164. package/dist/signaling.js.map +7 -0
  165. package/dist/source-auth.d.ts +2 -0
  166. package/dist/source-auth.d.ts.map +1 -0
  167. package/dist/source-auth.js +1220 -0
  168. package/dist/source-auth.js.map +7 -0
  169. package/dist/switching-set-alignment.d.ts +61 -0
  170. package/dist/switching-set-alignment.d.ts.map +1 -0
  171. package/dist/switching-set-alignment.js +85 -0
  172. package/dist/switching-set-alignment.js.map +7 -0
  173. package/dist/timestamp-codec.d.ts +34 -0
  174. package/dist/timestamp-codec.d.ts.map +1 -0
  175. package/dist/timestamp-codec.js +456 -0
  176. package/dist/timestamp-codec.js.map +7 -0
  177. package/dist/track-pipeline-setup.d.ts +72 -0
  178. package/dist/track-pipeline-setup.d.ts.map +1 -0
  179. package/dist/track-pipeline-setup.js +306 -0
  180. package/dist/track-pipeline-setup.js.map +7 -0
  181. package/dist/track-pipeline.d.ts +121 -0
  182. package/dist/track-pipeline.d.ts.map +1 -0
  183. package/dist/track-pipeline.js +229 -0
  184. package/dist/track-pipeline.js.map +7 -0
  185. package/dist/track-session.d.ts +269 -0
  186. package/dist/track-session.d.ts.map +1 -0
  187. package/dist/track-session.js +597 -0
  188. package/dist/track-session.js.map +7 -0
  189. package/dist/transport-pool.d.ts +69 -0
  190. package/dist/transport-pool.d.ts.map +1 -0
  191. package/dist/transport-pool.js +88 -0
  192. package/dist/transport-pool.js.map +7 -0
  193. package/dist/wasm-mfu-reassembler.d.ts +81 -0
  194. package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
  195. package/dist/wasm-mfu-reassembler.js +1915 -0
  196. package/dist/wasm-mfu-reassembler.js.map +7 -0
  197. package/dist/wasm-mmtp-container-parser.d.ts +10 -0
  198. package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
  199. package/dist/wasm-mmtp-container-parser.js +5635 -0
  200. package/dist/wasm-mmtp-container-parser.js.map +7 -0
  201. package/node_modules/@blockcast/fec-worker/README.md +213 -0
  202. package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
  203. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +80 -0
  204. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
  205. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +270 -0
  206. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
  207. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +252 -0
  208. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
  209. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
  210. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
  211. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
  212. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
  213. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +565 -0
  214. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
  215. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
  216. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
  217. package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
  218. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
  219. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
  220. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
  221. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +349 -0
  222. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
  223. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
  224. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
  225. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
  226. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
  227. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +179 -0
  228. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
  229. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +47 -0
  230. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
  231. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
  232. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
  233. package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
  234. package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
  235. package/node_modules/@blockcast/fec-worker/package.json +59 -0
  236. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +309 -0
  237. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +268 -0
  238. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1048 -0
  239. package/node_modules/@blockcast/fec-worker/src/index.ts +32 -0
  240. package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +558 -0
  241. package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
  242. package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +194 -0
  243. package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
  244. package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  245. package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  246. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  247. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  248. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  249. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  250. package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  251. package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  252. package/node_modules/@blockcast/mmt-base/README.md +120 -0
  253. package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  254. package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  255. package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  256. package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  257. package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  258. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
  259. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  260. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
  261. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  262. package/node_modules/@blockcast/mmt-base/package.json +49 -0
  263. package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  264. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
  265. package/node_modules/@blockcast/mmt-fec/README.md +270 -0
  266. package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
  267. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +80 -0
  268. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
  269. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +294 -0
  270. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
  271. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +72 -0
  272. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
  273. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +192 -0
  274. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
  275. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
  276. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
  277. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
  278. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
  279. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
  280. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
  281. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
  282. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
  283. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +185 -0
  284. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
  285. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +273 -0
  286. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
  287. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +22 -0
  288. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
  289. package/node_modules/@blockcast/mmt-fec/dist/index.js +22 -0
  290. package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
  291. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
  292. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
  293. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
  294. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
  295. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +174 -0
  296. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
  297. package/node_modules/@blockcast/mmt-fec/dist/oti.js +256 -0
  298. package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
  299. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
  300. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
  301. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
  302. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
  303. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  304. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  305. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  306. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  307. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  308. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  309. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  310. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  311. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +120 -0
  312. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  313. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  314. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  315. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  316. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  317. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
  318. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  319. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
  320. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  321. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
  322. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  323. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
  324. package/node_modules/@blockcast/mmt-fec/package.json +79 -0
  325. package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +369 -0
  326. package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +277 -0
  327. package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
  328. package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
  329. package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +332 -0
  330. package/node_modules/@blockcast/mmt-fec/src/index.ts +77 -0
  331. package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
  332. package/node_modules/@blockcast/mmt-fec/src/oti.ts +319 -0
  333. package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
  334. package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
  335. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
  336. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
  337. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
  338. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
  339. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
  340. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
  341. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
  342. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
  343. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
  344. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
  345. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
  346. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
  347. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +90 -0
  348. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
  349. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +462 -0
  350. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
  351. package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
  352. package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
  353. package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
  354. package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
  355. package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +636 -0
  356. package/node_modules/@noble/hashes/LICENSE +21 -0
  357. package/node_modules/@noble/hashes/README.md +521 -0
  358. package/node_modules/@noble/hashes/_assert.d.ts +17 -0
  359. package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
  360. package/node_modules/@noble/hashes/_assert.js +18 -0
  361. package/node_modules/@noble/hashes/_assert.js.map +1 -0
  362. package/node_modules/@noble/hashes/_blake.d.ts +14 -0
  363. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  364. package/node_modules/@noble/hashes/_blake.js +50 -0
  365. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  366. package/node_modules/@noble/hashes/_md.d.ts +51 -0
  367. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  368. package/node_modules/@noble/hashes/_md.js +162 -0
  369. package/node_modules/@noble/hashes/_md.js.map +1 -0
  370. package/node_modules/@noble/hashes/_u64.d.ts +55 -0
  371. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  372. package/node_modules/@noble/hashes/_u64.js +90 -0
  373. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  374. package/node_modules/@noble/hashes/argon2.d.ts +32 -0
  375. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  376. package/node_modules/@noble/hashes/argon2.js +401 -0
  377. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  378. package/node_modules/@noble/hashes/blake1.d.ts +106 -0
  379. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  380. package/node_modules/@noble/hashes/blake1.js +459 -0
  381. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  382. package/node_modules/@noble/hashes/blake2.d.ts +116 -0
  383. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  384. package/node_modules/@noble/hashes/blake2.js +420 -0
  385. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  386. package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
  387. package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
  388. package/node_modules/@noble/hashes/blake2b.js +14 -0
  389. package/node_modules/@noble/hashes/blake2b.js.map +1 -0
  390. package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
  391. package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
  392. package/node_modules/@noble/hashes/blake2s.js +24 -0
  393. package/node_modules/@noble/hashes/blake2s.js.map +1 -0
  394. package/node_modules/@noble/hashes/blake3.d.ts +54 -0
  395. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  396. package/node_modules/@noble/hashes/blake3.js +255 -0
  397. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  398. package/node_modules/@noble/hashes/crypto.d.ts +2 -0
  399. package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
  400. package/node_modules/@noble/hashes/crypto.js +5 -0
  401. package/node_modules/@noble/hashes/crypto.js.map +1 -0
  402. package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
  403. package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
  404. package/node_modules/@noble/hashes/cryptoNode.js +18 -0
  405. package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
  406. package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
  407. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  408. package/node_modules/@noble/hashes/eskdf.js +166 -0
  409. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  410. package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
  411. package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
  412. package/node_modules/@noble/hashes/esm/_assert.js +15 -0
  413. package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
  414. package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
  415. package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
  416. package/node_modules/@noble/hashes/esm/_blake.js +45 -0
  417. package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
  418. package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
  419. package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
  420. package/node_modules/@noble/hashes/esm/_md.js +155 -0
  421. package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  422. package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
  423. package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
  424. package/node_modules/@noble/hashes/esm/_u64.js +67 -0
  425. package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  426. package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
  427. package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
  428. package/node_modules/@noble/hashes/esm/argon2.js +392 -0
  429. package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
  430. package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
  431. package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
  432. package/node_modules/@noble/hashes/esm/blake1.js +452 -0
  433. package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
  434. package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
  435. package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
  436. package/node_modules/@noble/hashes/esm/blake2.js +413 -0
  437. package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
  438. package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
  439. package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
  440. package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
  441. package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
  442. package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
  443. package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
  444. package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
  445. package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
  446. package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
  447. package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
  448. package/node_modules/@noble/hashes/esm/blake3.js +251 -0
  449. package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
  450. package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
  451. package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
  452. package/node_modules/@noble/hashes/esm/crypto.js +2 -0
  453. package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
  454. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
  455. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
  456. package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
  457. package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
  458. package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
  459. package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
  460. package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
  461. package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
  462. package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
  463. package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
  464. package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
  465. package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
  466. package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
  467. package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
  468. package/node_modules/@noble/hashes/esm/hmac.js +86 -0
  469. package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
  470. package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
  471. package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
  472. package/node_modules/@noble/hashes/esm/index.js +33 -0
  473. package/node_modules/@noble/hashes/esm/index.js.map +1 -0
  474. package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
  475. package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
  476. package/node_modules/@noble/hashes/esm/legacy.js +281 -0
  477. package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  478. package/node_modules/@noble/hashes/esm/package.json +10 -0
  479. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
  480. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
  481. package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
  482. package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
  483. package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
  484. package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
  485. package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
  486. package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
  487. package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
  488. package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
  489. package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
  490. package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
  491. package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
  492. package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
  493. package/node_modules/@noble/hashes/esm/sha1.js +11 -0
  494. package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
  495. package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
  496. package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
  497. package/node_modules/@noble/hashes/esm/sha2.js +375 -0
  498. package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  499. package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
  500. package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
  501. package/node_modules/@noble/hashes/esm/sha256.js +20 -0
  502. package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
  503. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
  504. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
  505. package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
  506. package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
  507. package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
  508. package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
  509. package/node_modules/@noble/hashes/esm/sha3.js +234 -0
  510. package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
  511. package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
  512. package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
  513. package/node_modules/@noble/hashes/esm/sha512.js +26 -0
  514. package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
  515. package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
  516. package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
  517. package/node_modules/@noble/hashes/esm/utils.js +281 -0
  518. package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  519. package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
  520. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  521. package/node_modules/@noble/hashes/hkdf.js +88 -0
  522. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  523. package/node_modules/@noble/hashes/hmac.d.ts +35 -0
  524. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  525. package/node_modules/@noble/hashes/hmac.js +91 -0
  526. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  527. package/node_modules/@noble/hashes/index.d.ts +1 -0
  528. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  529. package/node_modules/@noble/hashes/index.js +33 -0
  530. package/node_modules/@noble/hashes/index.js.map +1 -0
  531. package/node_modules/@noble/hashes/legacy.d.ts +71 -0
  532. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  533. package/node_modules/@noble/hashes/legacy.js +287 -0
  534. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  535. package/node_modules/@noble/hashes/package.json +266 -0
  536. package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
  537. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  538. package/node_modules/@noble/hashes/pbkdf2.js +101 -0
  539. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  540. package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
  541. package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
  542. package/node_modules/@noble/hashes/ripemd160.js +16 -0
  543. package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
  544. package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
  545. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  546. package/node_modules/@noble/hashes/scrypt.js +232 -0
  547. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  548. package/node_modules/@noble/hashes/sha1.d.ts +11 -0
  549. package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
  550. package/node_modules/@noble/hashes/sha1.js +14 -0
  551. package/node_modules/@noble/hashes/sha1.js.map +1 -0
  552. package/node_modules/@noble/hashes/sha2.d.ts +159 -0
  553. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  554. package/node_modules/@noble/hashes/sha2.js +384 -0
  555. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  556. package/node_modules/@noble/hashes/sha256.d.ts +20 -0
  557. package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
  558. package/node_modules/@noble/hashes/sha256.js +23 -0
  559. package/node_modules/@noble/hashes/sha256.js.map +1 -0
  560. package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
  561. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  562. package/node_modules/@noble/hashes/sha3-addons.js +402 -0
  563. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  564. package/node_modules/@noble/hashes/sha3.d.ts +53 -0
  565. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  566. package/node_modules/@noble/hashes/sha3.js +239 -0
  567. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  568. package/node_modules/@noble/hashes/sha512.d.ts +26 -0
  569. package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
  570. package/node_modules/@noble/hashes/sha512.js +29 -0
  571. package/node_modules/@noble/hashes/sha512.js.map +1 -0
  572. package/node_modules/@noble/hashes/src/_assert.ts +22 -0
  573. package/node_modules/@noble/hashes/src/_blake.ts +50 -0
  574. package/node_modules/@noble/hashes/src/_md.ts +176 -0
  575. package/node_modules/@noble/hashes/src/_u64.ts +91 -0
  576. package/node_modules/@noble/hashes/src/argon2.ts +497 -0
  577. package/node_modules/@noble/hashes/src/blake1.ts +534 -0
  578. package/node_modules/@noble/hashes/src/blake2.ts +486 -0
  579. package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
  580. package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
  581. package/node_modules/@noble/hashes/src/blake3.ts +272 -0
  582. package/node_modules/@noble/hashes/src/crypto.ts +9 -0
  583. package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
  584. package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
  585. package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
  586. package/node_modules/@noble/hashes/src/hmac.ts +94 -0
  587. package/node_modules/@noble/hashes/src/index.ts +31 -0
  588. package/node_modules/@noble/hashes/src/legacy.ts +293 -0
  589. package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
  590. package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
  591. package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
  592. package/node_modules/@noble/hashes/src/sha1.ts +10 -0
  593. package/node_modules/@noble/hashes/src/sha2.ts +402 -0
  594. package/node_modules/@noble/hashes/src/sha256.ts +24 -0
  595. package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
  596. package/node_modules/@noble/hashes/src/sha3.ts +258 -0
  597. package/node_modules/@noble/hashes/src/sha512.ts +34 -0
  598. package/node_modules/@noble/hashes/src/utils.ts +395 -0
  599. package/node_modules/@noble/hashes/utils.d.ts +161 -0
  600. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  601. package/node_modules/@noble/hashes/utils.js +313 -0
  602. package/node_modules/@noble/hashes/utils.js.map +1 -0
  603. package/package.json +203 -0
  604. package/schemas/catalog.schema.json +283 -0
  605. package/src/align.ts +235 -0
  606. package/src/audio-init-parser.ts +189 -0
  607. package/src/audio-ring-buffer.ts +120 -0
  608. package/src/authored-timing.ts +63 -0
  609. package/src/carp-catalog.ts +776 -0
  610. package/src/catalog-fec-params.ts +167 -0
  611. package/src/catalog-network-source.ts +49 -0
  612. package/src/catalog-validator.ts +34 -0
  613. package/src/cmaf-block-assembler.ts +1058 -0
  614. package/src/cmaf-group-batcher.ts +104 -0
  615. package/src/cmcd-producer.ts +329 -0
  616. package/src/codec-utils.ts +1539 -0
  617. package/src/fec-codec.ts +61 -0
  618. package/src/fec-manager.ts +1939 -0
  619. package/src/fec-starvation-detector.ts +128 -0
  620. package/src/fec-worker-setup.ts +177 -0
  621. package/src/fmp4-completion.ts +47 -0
  622. package/src/fmp4-reader.ts +112 -0
  623. package/src/index.ts +443 -0
  624. package/src/iso-bmff-timing.ts +688 -0
  625. package/src/loc.ts +181 -0
  626. package/src/manifest-auth-plan.ts +107 -0
  627. package/src/media-router.ts +1185 -0
  628. package/src/mfu-reassembler.ts +2842 -0
  629. package/src/mfu-reassembly-policy.ts +134 -0
  630. package/src/mmtp-container-parser.ts +1498 -0
  631. package/src/mmtp-decode-pipeline.ts +315 -0
  632. package/src/mmtp-router.ts +3027 -0
  633. package/src/mmtp-to-cmaf.ts +956 -0
  634. package/src/multicast-auth-catalog.ts +340 -0
  635. package/src/multicast-input.ts +439 -0
  636. package/src/multicast-manager.ts +1503 -0
  637. package/src/multicast-transport.ts +320 -0
  638. package/src/multicast-unwrap.ts +132 -0
  639. package/src/no-modules.ts +20 -0
  640. package/src/phase14-catalog-override.ts +336 -0
  641. package/src/repair-fetch.ts +217 -0
  642. package/src/sample-combiner.ts +846 -0
  643. package/src/signaling.ts +78 -0
  644. package/src/source-auth.ts +1 -0
  645. package/src/switching-set-alignment.ts +109 -0
  646. package/src/timestamp-codec.ts +265 -0
  647. package/src/track-pipeline-setup.ts +189 -0
  648. package/src/track-pipeline.ts +332 -0
  649. package/src/track-session.ts +778 -0
  650. package/src/transport-pool.ts +128 -0
  651. package/src/wasm-mfu-reassembler.ts +372 -0
  652. package/src/wasm-mmtp-container-parser.ts +23 -0
  653. package/test-vectors/align.json +199 -0
  654. package/test-vectors/catalog/README.md +25 -0
  655. package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
  656. package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
  657. package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
  658. package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
  659. package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
  660. package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
  661. package/test-vectors/catalog/negative/network-source-object.json +25 -0
  662. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +26 -0
  663. package/test-vectors/catalog/negative/repair-track-legacy-shape.json +18 -0
  664. package/test-vectors/catalog/negative/track-role-empty.json +16 -0
  665. package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
  666. package/test-vectors/catalog/positive/fec-multicast.json +51 -0
  667. package/test-vectors/catalog/positive/flat-av.json +30 -0
  668. package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
  669. package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
  670. package/test-vectors/catalog/positive/track-role.json +49 -0
  671. package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
  672. package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
  673. package/test-vectors/catalog-multicast-auth-v1.json +26 -0
  674. package/test-vectors/catalog-validation.json +148 -0
  675. package/test-vectors/catalog-validator-public-api.mjs +25 -0
  676. package/test-vectors/generate-source-auth-fixture.mjs +114 -0
  677. package/test-vectors/source-auth-v1.json +61 -0
  678. package/test-vectors/subsample-placement-v1.json +230 -0
@@ -0,0 +1,1225 @@
1
+ // src/codec-utils.ts
2
+ function extractAvcCFromInitSegment(data) {
3
+ if (!hasIsoBmffMagic(data)) return void 0;
4
+ for (const stsd of findTrackStsdBoxes(data)) {
5
+ const info = extractVideoConfigFromStsd(data, stsd);
6
+ if (info) return info;
7
+ }
8
+ return void 0;
9
+ }
10
+ function extractVideoConfigFromStsd(data, stsd) {
11
+ let s = stsd.o + 16;
12
+ const e = stsd.o + stsd.sz;
13
+ const avc1 = findBox(data, s, e, "avc1");
14
+ if (avc1 && avc1.sz >= 86) {
15
+ const avcC = findBox(data, avc1.o + 86, avc1.o + avc1.sz, "avcC");
16
+ if (avcC && avcC.sz >= 12) {
17
+ const d = data.subarray(avcC.o + 8, avcC.o + avcC.sz);
18
+ const codec = `avc1.${hex2(d[1])}${hex2(d[2])}${hex2(d[3])}`;
19
+ return { codec, description: d };
20
+ }
21
+ }
22
+ const hvc1 = findBox(data, s, e, "hvc1") ?? findBox(data, s, e, "hev1");
23
+ if (hvc1 && hvc1.sz >= 86) {
24
+ const hvcC = findBox(data, hvc1.o + 86, hvc1.o + hvc1.sz, "hvcC");
25
+ if (hvcC && hvcC.sz >= 8 + 23) {
26
+ const d = data.subarray(hvcC.o + 8, hvcC.o + hvcC.sz);
27
+ return { codec: hevcCodecStringFromHvcC(d), description: d };
28
+ }
29
+ }
30
+ const av01 = findBox(data, s, e, "av01");
31
+ if (av01 && av01.sz >= 86) {
32
+ const av1C = findBox(data, av01.o + 86, av01.o + av01.sz, "av1C");
33
+ if (av1C && av1C.sz >= 8) {
34
+ const d = data.subarray(av1C.o + 8, av1C.o + av1C.sz);
35
+ return { codec: codecStringFromAv1C(d), description: d };
36
+ }
37
+ }
38
+ const vp09 = findBox(data, s, e, "vp09");
39
+ if (vp09 && vp09.sz >= 86) {
40
+ const vpcC = findBox(data, vp09.o + 86, vp09.o + vp09.sz, "vpcC");
41
+ if (vpcC && vpcC.sz >= 8) {
42
+ const d = data.subarray(vpcC.o + 8, vpcC.o + vpcC.sz);
43
+ return { codec: codecStringFromVpcC(d), description: d };
44
+ }
45
+ }
46
+ return void 0;
47
+ }
48
+ function generateFallbackAvcC(options) {
49
+ const opts = typeof options === "string" ? { codec: options } : options ?? {};
50
+ let profile = 100;
51
+ let constraint = 0;
52
+ let level = 42;
53
+ if (opts.codec) {
54
+ const match = opts.codec.match(/^avc[13]\.([0-9a-fA-F]{6})$/);
55
+ if (match) {
56
+ profile = Number.parseInt(match[1].substring(0, 2), 16);
57
+ constraint = Number.parseInt(match[1].substring(2, 4), 16);
58
+ level = Number.parseInt(match[1].substring(4, 6), 16);
59
+ }
60
+ }
61
+ const { width, height } = resolveResolution(opts.width, opts.height, level);
62
+ const sps = buildMinimalSps(profile, constraint, level, width, height);
63
+ const pps = buildMinimalPps(profile);
64
+ const avcC = new Uint8Array(5 + 1 + 2 + sps.length + 1 + 2 + pps.length);
65
+ let w = 0;
66
+ avcC[w++] = 1;
67
+ avcC[w++] = profile;
68
+ avcC[w++] = constraint;
69
+ avcC[w++] = level;
70
+ avcC[w++] = 255;
71
+ avcC[w++] = 225;
72
+ avcC[w++] = sps.length >> 8 & 255;
73
+ avcC[w++] = sps.length & 255;
74
+ avcC.set(sps, w);
75
+ w += sps.length;
76
+ avcC[w++] = 1;
77
+ avcC[w++] = pps.length >> 8 & 255;
78
+ avcC[w++] = pps.length & 255;
79
+ avcC.set(pps, w);
80
+ return avcC;
81
+ }
82
+ function extractSpsPpsFromAvcC(avcC) {
83
+ if (avcC.length < 8) return void 0;
84
+ const numSPS = avcC[5] & 31;
85
+ let offset = 6;
86
+ let sps;
87
+ for (let i = 0; i < numSPS && offset + 2 <= avcC.length; i++) {
88
+ const spsLen = avcC[offset] << 8 | avcC[offset + 1];
89
+ offset += 2;
90
+ if (offset + spsLen <= avcC.length) {
91
+ if (!sps) sps = avcC.subarray(offset, offset + spsLen);
92
+ offset += spsLen;
93
+ }
94
+ }
95
+ let pps;
96
+ if (offset < avcC.length) {
97
+ const numPPS = avcC[offset] & 31;
98
+ offset++;
99
+ for (let i = 0; i < numPPS && offset + 2 <= avcC.length; i++) {
100
+ const ppsLen = avcC[offset] << 8 | avcC[offset + 1];
101
+ offset += 2;
102
+ if (offset + ppsLen <= avcC.length) {
103
+ if (!pps) pps = avcC.subarray(offset, offset + ppsLen);
104
+ offset += ppsLen;
105
+ }
106
+ }
107
+ }
108
+ return sps && pps ? { sps, pps } : void 0;
109
+ }
110
+ function avccToAnnexB(avccData, isKeyframe, spsPps) {
111
+ let offset = 0;
112
+ let totalNalSize = 0;
113
+ let nalCount = 0;
114
+ while (offset + 4 <= avccData.length) {
115
+ const nalLen = avccData[offset] << 24 | avccData[offset + 1] << 16 | avccData[offset + 2] << 8 | avccData[offset + 3];
116
+ offset += 4;
117
+ if (nalLen <= 0 || offset + nalLen > avccData.length) break;
118
+ totalNalSize += nalLen;
119
+ nalCount++;
120
+ offset += nalLen;
121
+ }
122
+ if (nalCount === 0) return avccData;
123
+ let outSize = nalCount * 4 + totalNalSize;
124
+ if (isKeyframe) {
125
+ outSize += 4 + spsPps.sps.length + 4 + spsPps.pps.length;
126
+ }
127
+ const out = new Uint8Array(outSize);
128
+ let w = 0;
129
+ if (isKeyframe) {
130
+ out[w++] = 0;
131
+ out[w++] = 0;
132
+ out[w++] = 0;
133
+ out[w++] = 1;
134
+ out.set(spsPps.sps, w);
135
+ w += spsPps.sps.length;
136
+ out[w++] = 0;
137
+ out[w++] = 0;
138
+ out[w++] = 0;
139
+ out[w++] = 1;
140
+ out.set(spsPps.pps, w);
141
+ w += spsPps.pps.length;
142
+ }
143
+ offset = 0;
144
+ while (offset + 4 <= avccData.length) {
145
+ const nalLen = avccData[offset] << 24 | avccData[offset + 1] << 16 | avccData[offset + 2] << 8 | avccData[offset + 3];
146
+ offset += 4;
147
+ if (nalLen <= 0 || offset + nalLen > avccData.length) break;
148
+ out[w++] = 0;
149
+ out[w++] = 0;
150
+ out[w++] = 0;
151
+ out[w++] = 1;
152
+ out.set(avccData.subarray(offset, offset + nalLen), w);
153
+ w += nalLen;
154
+ offset += nalLen;
155
+ }
156
+ return out;
157
+ }
158
+ function extractCodecDescriptionFromAnnexB(data) {
159
+ const nalUnits = [];
160
+ let i = 0;
161
+ while (i < data.length - 4) {
162
+ if (data[i] === 0 && data[i + 1] === 0) {
163
+ let nalStart = 0;
164
+ if (data[i + 2] === 1) {
165
+ nalStart = i + 3;
166
+ } else if (data[i + 2] === 0 && data[i + 3] === 1) {
167
+ nalStart = i + 4;
168
+ }
169
+ if (nalStart > 0 && nalStart < data.length) {
170
+ let nalEnd = data.length;
171
+ for (let j = nalStart; j < data.length - 3; j++) {
172
+ if (data[j] === 0 && data[j + 1] === 0 && (data[j + 2] === 1 || data[j + 2] === 0 && data[j + 3] === 1)) {
173
+ nalEnd = j;
174
+ break;
175
+ }
176
+ }
177
+ const nalType = data[nalStart] & 31;
178
+ nalUnits.push({ type: nalType, data: data.slice(nalStart, nalEnd) });
179
+ i = nalEnd;
180
+ continue;
181
+ }
182
+ }
183
+ i++;
184
+ }
185
+ const sps = nalUnits.find((n) => n.type === 7);
186
+ const pps = nalUnits.find((n) => n.type === 8);
187
+ if (!sps || !pps) return null;
188
+ const avcCLength = 6 + 2 + sps.data.length + 1 + 2 + pps.data.length;
189
+ const avcC = new Uint8Array(avcCLength);
190
+ let offset = 0;
191
+ avcC[offset++] = 1;
192
+ avcC[offset++] = sps.data[1];
193
+ avcC[offset++] = sps.data[2];
194
+ avcC[offset++] = sps.data[3];
195
+ avcC[offset++] = 255;
196
+ avcC[offset++] = 225;
197
+ avcC[offset++] = sps.data.length >> 8 & 255;
198
+ avcC[offset++] = sps.data.length & 255;
199
+ avcC.set(sps.data, offset);
200
+ offset += sps.data.length;
201
+ avcC[offset++] = 1;
202
+ avcC[offset++] = pps.data.length >> 8 & 255;
203
+ avcC[offset++] = pps.data.length & 255;
204
+ avcC.set(pps.data, offset);
205
+ return avcC;
206
+ }
207
+ function codecStringFromAvcC(avcC) {
208
+ if (avcC.length < 4) return "avc1.640033";
209
+ return `avc1.${hex2(avcC[1])}${hex2(avcC[2])}${hex2(avcC[3])}`;
210
+ }
211
+ function isHevcCodec(codec) {
212
+ return codec.startsWith("hev1") || codec.startsWith("hvc1");
213
+ }
214
+ function hevcNalType(nal) {
215
+ return nal[0] >> 1 & 63;
216
+ }
217
+ function removeEmulationPrevention(rbsp) {
218
+ const out = [];
219
+ let zeros = 0;
220
+ for (let i = 0; i < rbsp.length; i++) {
221
+ const b = rbsp[i];
222
+ if (zeros >= 2 && b === 3 && i + 1 < rbsp.length && rbsp[i + 1] <= 3) {
223
+ zeros = 0;
224
+ continue;
225
+ }
226
+ out.push(b);
227
+ zeros = b === 0 ? zeros + 1 : 0;
228
+ }
229
+ return Uint8Array.from(out);
230
+ }
231
+ function splitAvccNalUnits(data, lengthSize = 4) {
232
+ const nals = [];
233
+ let i = 0;
234
+ while (i + lengthSize <= data.length) {
235
+ let len = 0;
236
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
237
+ i += lengthSize;
238
+ if (len <= 0 || i + len > data.length) break;
239
+ nals.push(data.subarray(i, i + len));
240
+ i += len;
241
+ }
242
+ return nals;
243
+ }
244
+ function isCompleteAvccSample(data, lengthSize = 4) {
245
+ let i = 0;
246
+ let count = 0;
247
+ while (i + lengthSize <= data.length) {
248
+ let len = 0;
249
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
250
+ i += lengthSize;
251
+ if (len <= 0 || i + len > data.length) return false;
252
+ i += len;
253
+ count++;
254
+ }
255
+ return count > 0 && i === data.length;
256
+ }
257
+ function normalizeH264SampleToAvcc(data) {
258
+ if (isCompleteAvccSample(data)) return { data, format: "avcc" };
259
+ if (isAnnexB(data)) return { data: annexBToAvcc(data), format: "annexb" };
260
+ if (isLikelyRawH264NalUnit(data)) return { data: rawH264NalToAvcc(data), format: "raw-nal" };
261
+ return { data, format: "unknown" };
262
+ }
263
+ function splitH264SampleNalUnits(data, options = {}) {
264
+ if (isCompleteAvccSample(data)) return { nals: splitAvccNalUnits(data), format: "avcc" };
265
+ if (isAnnexB(data)) return { nals: splitAnnexBNalUnits(data), format: "annexb" };
266
+ if (options.allowPartialAvcc === true) {
267
+ const partial = splitPartialAvccNalUnits(data);
268
+ if (partial.length > 0) return { nals: partial, format: "partial-avcc" };
269
+ }
270
+ if (isLikelyRawH264NalUnit(data)) return { nals: [data], format: "raw-nal" };
271
+ const nals = splitAvccNalUnits(data);
272
+ return { nals, format: nals.length > 0 ? "avcc" : "unknown" };
273
+ }
274
+ function extractHevcParameterSets(keyframe) {
275
+ const nals = isAnnexB(keyframe) ? splitAnnexBNalUnits(keyframe) : splitAvccNalUnits(keyframe);
276
+ const out = {};
277
+ for (const nal of nals) {
278
+ if (nal.length === 0) continue;
279
+ const t = hevcNalType(nal);
280
+ if (t === 32 && !out.vps) out.vps = nal;
281
+ else if (t === 33 && !out.sps) out.sps = nal;
282
+ else if (t === 34 && !out.pps) out.pps = nal;
283
+ }
284
+ return out;
285
+ }
286
+ function generateHvcCFromParameterSets(sets) {
287
+ const { vps, sps, pps } = sets;
288
+ if (!sps || !pps) return null;
289
+ const spsRbsp = removeEmulationPrevention(sps);
290
+ const ptl = spsRbsp.subarray(3, 15);
291
+ const arrays = [
292
+ { type: 32, nal: vps },
293
+ { type: 33, nal: sps },
294
+ { type: 34, nal: pps }
295
+ ].filter((a) => a.nal !== void 0);
296
+ let size = 23;
297
+ for (const a of arrays) size += 5 + a.nal.length;
298
+ const h = new Uint8Array(size);
299
+ let o = 0;
300
+ h[o++] = 1;
301
+ for (let i = 0; i < 12; i++) h[o++] = ptl[i] ?? 0;
302
+ h[o++] = 240;
303
+ h[o++] = 0;
304
+ h[o++] = 252;
305
+ h[o++] = 253;
306
+ h[o++] = 248;
307
+ h[o++] = 248;
308
+ h[o++] = 0;
309
+ h[o++] = 0;
310
+ h[o++] = 11;
311
+ h[o++] = arrays.length;
312
+ for (const a of arrays) {
313
+ h[o++] = a.type & 63;
314
+ h[o++] = 0;
315
+ h[o++] = 1;
316
+ h[o++] = a.nal.length >> 8 & 255;
317
+ h[o++] = a.nal.length & 255;
318
+ h.set(a.nal, o);
319
+ o += a.nal.length;
320
+ }
321
+ return h.subarray(0, o);
322
+ }
323
+ function extractHevcCodecDescription(keyframe) {
324
+ return generateHvcCFromParameterSets(extractHevcParameterSets(keyframe));
325
+ }
326
+ function hevcVclOnly(data) {
327
+ const nals = isAnnexB(data) ? splitAnnexBNalUnits(data) : splitAvccNalUnits(data);
328
+ const vcl = nals.filter((n) => n.length > 0 && hevcNalType(n) <= 31);
329
+ if (vcl.length === nals.length && !isAnnexB(data)) return data;
330
+ let size = 0;
331
+ for (const n of vcl) size += 4 + n.length;
332
+ const out = new Uint8Array(size);
333
+ let o = 0;
334
+ for (const n of vcl) {
335
+ out[o++] = n.length >> 24 & 255;
336
+ out[o++] = n.length >> 16 & 255;
337
+ out[o++] = n.length >> 8 & 255;
338
+ out[o++] = n.length & 255;
339
+ out.set(n, o);
340
+ o += n.length;
341
+ }
342
+ return out;
343
+ }
344
+ function isAnnexB(data) {
345
+ if (data.length >= 4 && data[0] === 0 && data[1] === 0 && (data[2] === 1 || data[2] === 0 && data[3] === 1)) {
346
+ return true;
347
+ }
348
+ return false;
349
+ }
350
+ function findAnnexBStartCode(data) {
351
+ for (let i = 0; i < data.length - 3; i++) {
352
+ if (data[i] === 0 && data[i + 1] === 0) {
353
+ if (data[i + 2] === 1) return i;
354
+ if (data[i + 2] === 0 && data[i + 3] === 1) return i;
355
+ }
356
+ }
357
+ return -1;
358
+ }
359
+ function splitAnnexBNalUnits(data) {
360
+ const nalUnits = [];
361
+ let i = 0;
362
+ while (i < data.length - 3) {
363
+ if (data[i] === 0 && data[i + 1] === 0) {
364
+ let scLen = 0;
365
+ if (data[i + 2] === 1) scLen = 3;
366
+ else if (data[i + 2] === 0 && i + 3 < data.length && data[i + 3] === 1) scLen = 4;
367
+ if (scLen > 0) {
368
+ const nalStart = i + scLen;
369
+ let nalEnd = data.length;
370
+ for (let j = nalStart + 1; j < data.length - 2; j++) {
371
+ if (data[j] === 0 && data[j + 1] === 0 && (data[j + 2] === 1 || data[j + 2] === 0 && j + 3 < data.length && data[j + 3] === 1)) {
372
+ nalEnd = j;
373
+ break;
374
+ }
375
+ }
376
+ if (nalEnd > nalStart) nalUnits.push(data.subarray(nalStart, nalEnd));
377
+ i = nalEnd;
378
+ continue;
379
+ }
380
+ }
381
+ i++;
382
+ }
383
+ return nalUnits;
384
+ }
385
+ function annexBToAvcc(data, spsPps) {
386
+ const nalUnits = splitAnnexBNalUnits(data);
387
+ if (nalUnits.length === 0) return data;
388
+ let extraSize = 0;
389
+ if (spsPps) {
390
+ extraSize = 4 + spsPps.sps.length + 4 + spsPps.pps.length;
391
+ }
392
+ const frameSize = nalUnits.reduce((sum, nal) => sum + 4 + nal.length, 0);
393
+ const output = new Uint8Array(extraSize + frameSize);
394
+ let w = 0;
395
+ if (spsPps) {
396
+ w = writeNalLength(output, w, spsPps.sps.length);
397
+ output.set(spsPps.sps, w);
398
+ w += spsPps.sps.length;
399
+ w = writeNalLength(output, w, spsPps.pps.length);
400
+ output.set(spsPps.pps, w);
401
+ w += spsPps.pps.length;
402
+ }
403
+ for (const nal of nalUnits) {
404
+ w = writeNalLength(output, w, nal.length);
405
+ output.set(nal, w);
406
+ w += nal.length;
407
+ }
408
+ return output;
409
+ }
410
+ function classifyH264Keyframe(data, options = {}) {
411
+ const nals = h264NalUnitsForKeyframeDetection(data, options);
412
+ if (nals.length === 0) return void 0;
413
+ let sawIntraSlice = false;
414
+ let sawNonIntraVcl = false;
415
+ let sawNal = false;
416
+ for (const nal of nals) {
417
+ sawNal = true;
418
+ const nalType = nal[0] !== void 0 ? nal[0] & 31 : -1;
419
+ if (nalType === 5 || nalType === 7) return true;
420
+ if (nalType === 1) {
421
+ if (isH264IntraSlice(nal)) sawIntraSlice = true;
422
+ else sawNonIntraVcl = true;
423
+ }
424
+ }
425
+ if (sawIntraSlice && !sawNonIntraVcl) return true;
426
+ return sawNal ? false : void 0;
427
+ }
428
+ function detectH264Keyframe(data, options = {}) {
429
+ return classifyH264Keyframe(data, options) === true;
430
+ }
431
+ function mmtpTimestampToMicros(rawTs) {
432
+ const ts = Number(rawTs) >>> 0;
433
+ if (ts === 0) return 0;
434
+ const seconds = ts >>> 16;
435
+ const frac = ts & 65535;
436
+ return seconds * 1e6 + Math.floor(frac * 1e6 / 65536);
437
+ }
438
+ function isFmp4InitSegment(data) {
439
+ let offset = 0;
440
+ let sawFtyp = false;
441
+ let sawMoov = false;
442
+ while (offset + 8 <= data.byteLength) {
443
+ const view = new DataView(data.buffer, data.byteOffset + offset, data.byteLength - offset);
444
+ let size = view.getUint32(0, false);
445
+ const type = String.fromCharCode(data[offset + 4], data[offset + 5], data[offset + 6], data[offset + 7]);
446
+ let headerSize = 8;
447
+ if (size === 1) {
448
+ if (offset + 16 > data.byteLength) return false;
449
+ const largeSize = view.getBigUint64(8, false);
450
+ if (largeSize > BigInt(Number.MAX_SAFE_INTEGER)) return false;
451
+ size = Number(largeSize);
452
+ headerSize = 16;
453
+ } else if (size === 0) {
454
+ size = data.byteLength - offset;
455
+ }
456
+ if (size < headerSize || offset + size > data.byteLength) return false;
457
+ if (type === "ftyp") sawFtyp = true;
458
+ if (type === "moov") {
459
+ if (!sawFtyp) return false;
460
+ sawMoov = true;
461
+ }
462
+ offset += size;
463
+ }
464
+ return offset === data.byteLength && sawFtyp && sawMoov;
465
+ }
466
+ function hasIsoBmffMagic(data) {
467
+ for (let i = 0; i + 8 <= data.length && i < 32; i += 4) {
468
+ const tag = String.fromCharCode(data[i + 4], data[i + 5], data[i + 6], data[i + 7]);
469
+ if (tag === "ftyp" || tag === "moov") return true;
470
+ }
471
+ return false;
472
+ }
473
+ function findTrackStsdBoxes(data) {
474
+ const moov = findBox(data, 0, data.length, "moov");
475
+ if (!moov) return [];
476
+ const out = [];
477
+ for (const trak of findBoxes(data, moov.o + 8, moov.o + moov.sz, "trak")) {
478
+ const stsd = findNestedBox(data, trak.o + 8, trak.o + trak.sz, ["mdia", "minf", "stbl", "stsd"]);
479
+ if (stsd) out.push(stsd);
480
+ }
481
+ return out;
482
+ }
483
+ function findNestedBox(buf, start, end, path) {
484
+ let s = start;
485
+ let e = end;
486
+ let current;
487
+ for (const type of path) {
488
+ current = findBox(buf, s, e, type);
489
+ if (!current) return void 0;
490
+ s = current.o + 8;
491
+ e = current.o + current.sz;
492
+ }
493
+ return current;
494
+ }
495
+ function findBox(buf, start, end, type) {
496
+ return findBoxes(buf, start, end, type)[0];
497
+ }
498
+ function findBoxes(buf, start, end, type) {
499
+ const boxes = [];
500
+ let o = start;
501
+ while (o + 8 <= end) {
502
+ let sz = buf[o] << 24 | buf[o + 1] << 16 | buf[o + 2] << 8 | buf[o + 3];
503
+ const t = String.fromCharCode(buf[o + 4], buf[o + 5], buf[o + 6], buf[o + 7]);
504
+ if (sz === 0) sz = end - o;
505
+ if (sz < 8 || o + sz > end) break;
506
+ if (t === type) boxes.push({ o, sz });
507
+ o += sz;
508
+ }
509
+ return boxes;
510
+ }
511
+ function writeNalLength(buf, offset, len) {
512
+ buf[offset] = len >> 24 & 255;
513
+ buf[offset + 1] = len >> 16 & 255;
514
+ buf[offset + 2] = len >> 8 & 255;
515
+ buf[offset + 3] = len & 255;
516
+ return offset + 4;
517
+ }
518
+ function h264NalUnitsForKeyframeDetection(data, options) {
519
+ return splitH264SampleNalUnits(data, options).nals;
520
+ }
521
+ function splitPartialAvccNalUnits(data, lengthSize = 4) {
522
+ const nals = [];
523
+ let i = 0;
524
+ while (i + lengthSize < data.length) {
525
+ let len = 0;
526
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
527
+ i += lengthSize;
528
+ if (len <= 0 || i >= data.length) break;
529
+ const end = Math.min(i + len, data.length);
530
+ nals.push(data.subarray(i, end));
531
+ if (end < i + len) break;
532
+ i = end;
533
+ }
534
+ return nals;
535
+ }
536
+ function isLikelyRawH264NalUnit(data) {
537
+ if (data.length === 0) return false;
538
+ const header = data[0];
539
+ if ((header & 128) !== 0) return false;
540
+ const nalType = header & 31;
541
+ return nalType > 0 && nalType < 24;
542
+ }
543
+ function rawH264NalToAvcc(data) {
544
+ const out = new Uint8Array(4 + data.length);
545
+ new DataView(out.buffer, out.byteOffset, out.byteLength).setUint32(0, data.length);
546
+ out.set(data, 4);
547
+ return out;
548
+ }
549
+ function isH264IntraSlice(nal) {
550
+ const sliceType = readH264SliceType(nal);
551
+ return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
552
+ }
553
+ function readH264SliceType(nal) {
554
+ if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
555
+ const rbsp = removeEmulationPrevention(nal.subarray(1));
556
+ const state = { bitOffset: 0 };
557
+ if (readUnsignedExpGolomb(rbsp, state) === null) return null;
558
+ return readUnsignedExpGolomb(rbsp, state);
559
+ }
560
+ function readUnsignedExpGolomb(data, state) {
561
+ let leadingZeroBits = 0;
562
+ while (true) {
563
+ const bit = readBit(data, state);
564
+ if (bit === null) return null;
565
+ if (bit === 1) break;
566
+ leadingZeroBits++;
567
+ if (leadingZeroBits > 30) return null;
568
+ }
569
+ let suffix = 0;
570
+ for (let i = 0; i < leadingZeroBits; i++) {
571
+ const bit = readBit(data, state);
572
+ if (bit === null) return null;
573
+ suffix = suffix << 1 | bit;
574
+ }
575
+ return (1 << leadingZeroBits) - 1 + suffix;
576
+ }
577
+ function readBit(data, state) {
578
+ if (state.bitOffset >= data.length * 8) return null;
579
+ const byte = data[state.bitOffset >> 3];
580
+ const bit = byte >> 7 - (state.bitOffset & 7) & 1;
581
+ state.bitOffset++;
582
+ return bit;
583
+ }
584
+ function hex2(n) {
585
+ return n.toString(16).padStart(2, "0");
586
+ }
587
+ function pad2(n) {
588
+ return String(n).padStart(2, "0");
589
+ }
590
+ function codecStringFromAv1C(av1C) {
591
+ if (av1C.length < 4) return "av01.0.01M.08";
592
+ const profile = av1C[1] >>> 5 & 7;
593
+ const level = av1C[1] & 31;
594
+ const tier = (av1C[2] & 128) !== 0 ? "H" : "M";
595
+ let bitDepth = 8;
596
+ if ((av1C[2] & 64) !== 0) {
597
+ bitDepth = (av1C[2] & 32) !== 0 ? 12 : 10;
598
+ }
599
+ return `av01.${profile}.${pad2(level)}${tier}.${pad2(bitDepth)}`;
600
+ }
601
+ function codecStringFromVpcC(vpcC) {
602
+ if (vpcC.length < 3) return "vp09.00.10.08";
603
+ const offset = vpcC.length >= 7 && vpcC[0] <= 1 ? 4 : 0;
604
+ if (offset + 2 >= vpcC.length) return "vp09.00.10.08";
605
+ const profile = vpcC[offset];
606
+ const level = vpcC[offset + 1];
607
+ const bitDepth = vpcC[offset + 2] >>> 4 || 8;
608
+ return `vp09.${pad2(profile)}.${pad2(level)}.${pad2(bitDepth)}`;
609
+ }
610
+ function hevcCodecStringFromHvcC(c) {
611
+ const profileSpace = c[1] >> 6 & 3;
612
+ const tierFlag = c[1] >> 5 & 1;
613
+ const profileIdc = c[1] & 31;
614
+ const compat = (c[2] << 24 | c[3] << 16 | c[4] << 8 | c[5]) >>> 0;
615
+ let rev = 0;
616
+ let v = compat;
617
+ for (let i = 0; i < 32; i++) {
618
+ rev = (rev << 1 | v & 1) >>> 0;
619
+ v >>>= 1;
620
+ }
621
+ const compatStr = rev.toString(16);
622
+ const constraint = c.subarray(6, 12);
623
+ let lastNonZero = -1;
624
+ for (let i = 0; i < constraint.length; i++) if (constraint[i] !== 0) lastNonZero = i;
625
+ const constraintParts = [];
626
+ for (let i = 0; i <= lastNonZero; i++) constraintParts.push(constraint[i].toString(16));
627
+ const space = profileSpace === 0 ? "" : String.fromCharCode(64 + profileSpace);
628
+ const tier = tierFlag === 0 ? "L" : "H";
629
+ let s = `hvc1.${space}${profileIdc}.${compatStr}.${tier}${c[12]}`;
630
+ if (constraintParts.length > 0) s += "." + constraintParts.join(".");
631
+ return s;
632
+ }
633
+ var BitWriter = class {
634
+ constructor() {
635
+ this.buf = [];
636
+ this.byte = 0;
637
+ this.bit = 7;
638
+ }
639
+ u(val, bits) {
640
+ for (let i = bits - 1; i >= 0; i--) {
641
+ this.byte |= (val >> i & 1) << this.bit;
642
+ if (--this.bit < 0) {
643
+ this.buf.push(this.byte);
644
+ this.byte = 0;
645
+ this.bit = 7;
646
+ }
647
+ }
648
+ }
649
+ ue(val) {
650
+ const v = val + 1;
651
+ const bits = Math.floor(Math.log2(v)) + 1;
652
+ this.u(0, bits - 1);
653
+ this.u(v, bits);
654
+ }
655
+ se(val) {
656
+ this.ue(val <= 0 ? -val * 2 : val * 2 - 1);
657
+ }
658
+ finish() {
659
+ if (this.bit < 7) {
660
+ this.byte |= 1 << this.bit;
661
+ this.buf.push(this.byte);
662
+ }
663
+ return new Uint8Array(this.buf);
664
+ }
665
+ };
666
+ function resolveResolution(explicitW, explicitH, level) {
667
+ if (explicitW && explicitH) return { width: explicitW, height: explicitH };
668
+ const levelResolutions = {
669
+ 10: [176, 144],
670
+ 11: [352, 288],
671
+ 12: [352, 288],
672
+ 13: [352, 288],
673
+ 20: [352, 288],
674
+ 21: [720, 576],
675
+ 22: [720, 576],
676
+ 30: [1280, 720],
677
+ 31: [1280, 720],
678
+ 32: [1280, 1024],
679
+ 40: [1920, 1088],
680
+ 41: [1920, 1088],
681
+ 42: [2048, 1088],
682
+ 50: [4096, 2160],
683
+ 51: [4096, 2160],
684
+ 52: [4096, 2160]
685
+ };
686
+ const [w, h] = levelResolutions[level] ?? [1920, 1088];
687
+ return { width: explicitW ?? w, height: explicitH ?? h };
688
+ }
689
+ function buildMinimalSps(profile, constraint, level, width, height) {
690
+ const widthInMbs = Math.ceil(width / 16);
691
+ const heightInMapUnits = Math.ceil(height / 16);
692
+ const w = new BitWriter();
693
+ w.u(0, 1);
694
+ w.u(3, 2);
695
+ w.u(7, 5);
696
+ w.u(profile, 8);
697
+ w.u(constraint, 8);
698
+ w.u(level, 8);
699
+ w.ue(0);
700
+ if (profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44) {
701
+ w.ue(1);
702
+ w.ue(0);
703
+ w.ue(0);
704
+ w.u(0, 1);
705
+ w.u(0, 1);
706
+ }
707
+ w.ue(0);
708
+ w.ue(2);
709
+ w.ue(1);
710
+ w.u(0, 1);
711
+ w.ue(widthInMbs - 1);
712
+ w.ue(heightInMapUnits - 1);
713
+ w.u(1, 1);
714
+ w.u(1, 1);
715
+ const cropRight = widthInMbs * 16 - width;
716
+ const cropBottom = heightInMapUnits * 16 - height;
717
+ if (cropRight > 0 || cropBottom > 0) {
718
+ w.u(1, 1);
719
+ w.ue(0);
720
+ w.ue(cropRight / 2);
721
+ w.ue(0);
722
+ w.ue(cropBottom / 2);
723
+ } else {
724
+ w.u(0, 1);
725
+ }
726
+ w.u(0, 1);
727
+ return w.finish();
728
+ }
729
+ function buildMinimalPps(profile) {
730
+ const isHighProfile = profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44;
731
+ const w = new BitWriter();
732
+ w.u(0, 1);
733
+ w.u(3, 2);
734
+ w.u(8, 5);
735
+ w.ue(0);
736
+ w.ue(0);
737
+ w.u(isHighProfile ? 1 : 0, 1);
738
+ w.u(0, 1);
739
+ w.ue(0);
740
+ w.ue(0);
741
+ w.ue(0);
742
+ w.u(0, 1);
743
+ w.u(0, 2);
744
+ w.se(0);
745
+ w.se(0);
746
+ w.se(0);
747
+ w.u(1, 1);
748
+ w.u(0, 1);
749
+ w.u(0, 1);
750
+ if (isHighProfile) {
751
+ w.u(1, 1);
752
+ w.u(0, 1);
753
+ w.se(0);
754
+ }
755
+ return w.finish();
756
+ }
757
+ var ADTS_SAMPLE_RATES = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350];
758
+ function wrapAdtsFrame(raw, sampleRate, channels) {
759
+ const sri = ADTS_SAMPLE_RATES.indexOf(sampleRate);
760
+ const idx = sri >= 0 ? sri : 3;
761
+ const len = 7 + raw.length;
762
+ const out = new Uint8Array(len);
763
+ out[0] = 255;
764
+ out[1] = 241;
765
+ out[2] = 1 << 6 | idx << 2 | channels >> 2;
766
+ out[3] = (channels & 3) << 6 | len >> 11 & 3;
767
+ out[4] = len >> 3 & 255;
768
+ out[5] = (len & 7) << 5 | 31;
769
+ out[6] = 252;
770
+ out.set(raw, 7);
771
+ return out;
772
+ }
773
+ function extractAacAscFromInitSegment(data) {
774
+ if (!hasIsoBmffMagic(data)) return void 0;
775
+ for (const stsd of findTrackStsdBoxes(data)) {
776
+ const info = extractAacAscFromStsd(data, stsd);
777
+ if (info) return info;
778
+ }
779
+ return void 0;
780
+ }
781
+ function extractAacAscFromStsd(data, stsd) {
782
+ const s = stsd.o + 16;
783
+ const e = stsd.o + stsd.sz;
784
+ const mp4a = findBox(data, s, e, "mp4a");
785
+ if (!mp4a || mp4a.sz < 36) return void 0;
786
+ const esds = findBox(data, mp4a.o + 36, mp4a.o + mp4a.sz, "esds");
787
+ if (!esds || esds.sz < 12) return void 0;
788
+ const esdsPayload = data.subarray(esds.o + 8, esds.o + esds.sz);
789
+ const asc = extractAudioSpecificConfig(esdsPayload);
790
+ if (!asc || asc.length < 2) return void 0;
791
+ const aot = asc[0] >> 3;
792
+ return { codec: `mp4a.40.${aot}`, description: asc };
793
+ }
794
+ function extractAudioSpecificConfig(esds) {
795
+ let offset = 4;
796
+ while (offset < esds.length) {
797
+ const tag = esds[offset++];
798
+ let size = 0;
799
+ for (let i = 0; i < 4 && offset < esds.length; i++) {
800
+ const b = esds[offset++];
801
+ size = size << 7 | b & 127;
802
+ if ((b & 128) === 0) break;
803
+ }
804
+ if (tag === 5) {
805
+ if (offset + size > esds.length) return void 0;
806
+ return esds.subarray(offset, offset + size);
807
+ }
808
+ if (tag === 3) {
809
+ offset += 3;
810
+ } else if (tag === 4) {
811
+ offset += 13;
812
+ } else {
813
+ offset += size;
814
+ }
815
+ }
816
+ return void 0;
817
+ }
818
+ if (void 0) {
819
+ const { describe, test, expect } = void 0;
820
+ describe("codec-utils", () => {
821
+ describe("isAnnexB", () => {
822
+ test("4-byte start code", () => {
823
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
824
+ });
825
+ test("3-byte start code", () => {
826
+ expect(isAnnexB(new Uint8Array([0, 0, 1, 101]))).toBe(true);
827
+ });
828
+ test("rejects AVCC", () => {
829
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 10, 101]))).toBe(false);
830
+ });
831
+ });
832
+ describe("findAnnexBStartCode", () => {
833
+ test("at offset 0", () => {
834
+ expect(findAnnexBStartCode(new Uint8Array([0, 0, 0, 1, 101]))).toBe(0);
835
+ });
836
+ test("at offset 5", () => {
837
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204, 221, 238, 0, 0, 1, 101]))).toBe(5);
838
+ });
839
+ test("returns -1 when none", () => {
840
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204]))).toBe(-1);
841
+ });
842
+ });
843
+ describe("splitAnnexBNalUnits", () => {
844
+ test("splits two NALs", () => {
845
+ const data = new Uint8Array([0, 0, 0, 1, 101, 170, 187, 0, 0, 0, 1, 65, 204]);
846
+ const nals = splitAnnexBNalUnits(data);
847
+ expect(nals.length).toBe(2);
848
+ expect(nals[0]).toEqual(new Uint8Array([101, 170, 187]));
849
+ expect(nals[1]).toEqual(new Uint8Array([65, 204]));
850
+ });
851
+ test("handles 3-byte start codes", () => {
852
+ const nals = splitAnnexBNalUnits(new Uint8Array([0, 0, 1, 103, 66, 0, 0, 1, 104, 1]));
853
+ expect(nals.length).toBe(2);
854
+ });
855
+ });
856
+ describe("annexBToAvcc", () => {
857
+ test("converts single NAL", () => {
858
+ const annexB = new Uint8Array([0, 0, 0, 1, 65, 170, 187]);
859
+ const avcc = annexBToAvcc(annexB);
860
+ expect(avcc[3]).toBe(3);
861
+ expect(avcc[4]).toBe(65);
862
+ });
863
+ test("prepends SPS/PPS", () => {
864
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 1]);
865
+ const avcc = annexBToAvcc(annexB, { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) });
866
+ expect(avcc[3]).toBe(2);
867
+ expect(avcc[4]).toBe(103);
868
+ });
869
+ });
870
+ describe("detectH264Keyframe", () => {
871
+ test("IDR in Annex-B", () => {
872
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
873
+ });
874
+ test("SPS in Annex-B", () => {
875
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 103]))).toBe(true);
876
+ });
877
+ test("IDR in AVCC", () => {
878
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 5, 101, 1, 2, 3, 4]))).toBe(true);
879
+ });
880
+ test("IDR after AVCC AUD", () => {
881
+ expect(detectH264Keyframe(new Uint8Array([
882
+ 0,
883
+ 0,
884
+ 0,
885
+ 1,
886
+ 9,
887
+ 0,
888
+ 0,
889
+ 0,
890
+ 2,
891
+ 101,
892
+ 170
893
+ ]))).toBe(true);
894
+ });
895
+ test("non-IDR AVC I-slice in AVCC", () => {
896
+ expect(detectH264Keyframe(new Uint8Array([
897
+ 0,
898
+ 0,
899
+ 0,
900
+ 2,
901
+ 65,
902
+ 136
903
+ ]))).toBe(true);
904
+ });
905
+ test("raw H.264 IDR NAL", () => {
906
+ expect(detectH264Keyframe(new Uint8Array([101, 136, 132]))).toBe(true);
907
+ });
908
+ test("raw H.264 non-IDR I-slice NAL", () => {
909
+ expect(detectH264Keyframe(new Uint8Array([65, 136]))).toBe(true);
910
+ });
911
+ test("classifies partial length-prefixed IDR only when requested", () => {
912
+ const partial = new Uint8Array([0, 0, 32, 0, 101]);
913
+ expect(classifyH264Keyframe(partial)).toBeUndefined();
914
+ expect(classifyH264Keyframe(partial, { allowPartialAvcc: true })).toBe(true);
915
+ });
916
+ test("rejects P-frame", () => {
917
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 65]))).toBe(false);
918
+ });
919
+ test("rejects AVCC sample with only non-IDR slices", () => {
920
+ expect(detectH264Keyframe(new Uint8Array([
921
+ 0,
922
+ 0,
923
+ 0,
924
+ 2,
925
+ 65,
926
+ 192,
927
+ 0,
928
+ 0,
929
+ 0,
930
+ 2,
931
+ 65,
932
+ 192
933
+ ]))).toBe(false);
934
+ });
935
+ });
936
+ describe("avccToAnnexB", () => {
937
+ test("converts with SPS/PPS on keyframe", () => {
938
+ const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
939
+ const spsPps = { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) };
940
+ const annexB = avccToAnnexB(avcc, true, spsPps);
941
+ expect(annexB[3]).toBe(1);
942
+ expect(annexB[4]).toBe(103);
943
+ });
944
+ });
945
+ describe("codecStringFromAvcC", () => {
946
+ test("derives avc1.64002a", () => {
947
+ expect(codecStringFromAvcC(new Uint8Array([1, 100, 0, 42]))).toBe("avc1.64002a");
948
+ });
949
+ });
950
+ describe("extractAacAscFromInitSegment", () => {
951
+ function buildMinimalAacInit(asc) {
952
+ const box = (type, payload) => {
953
+ const sz = 8 + payload.length;
954
+ const out = new Uint8Array(sz);
955
+ out[0] = sz >>> 24 & 255;
956
+ out[1] = sz >>> 16 & 255;
957
+ out[2] = sz >>> 8 & 255;
958
+ out[3] = sz & 255;
959
+ out[4] = type.charCodeAt(0);
960
+ out[5] = type.charCodeAt(1);
961
+ out[6] = type.charCodeAt(2);
962
+ out[7] = type.charCodeAt(3);
963
+ out.set(payload, 8);
964
+ return out;
965
+ };
966
+ const concat = (...arrs) => {
967
+ const total = arrs.reduce((n, a) => n + a.length, 0);
968
+ const out = new Uint8Array(total);
969
+ let off = 0;
970
+ for (const a of arrs) {
971
+ out.set(a, off);
972
+ off += a.length;
973
+ }
974
+ return out;
975
+ };
976
+ const ftyp = box("ftyp", new Uint8Array([
977
+ 105,
978
+ 115,
979
+ 111,
980
+ 53,
981
+ // 'iso5'
982
+ 0,
983
+ 0,
984
+ 2,
985
+ 0,
986
+ // minor 0x200
987
+ 105,
988
+ 115,
989
+ 111,
990
+ 53,
991
+ // 'iso5'
992
+ 105,
993
+ 115,
994
+ 111,
995
+ 54
996
+ // 'iso6'
997
+ ]));
998
+ const dsi = new Uint8Array(2 + asc.length);
999
+ dsi[0] = 5;
1000
+ dsi[1] = asc.length;
1001
+ dsi.set(asc, 2);
1002
+ const dcd = new Uint8Array(2 + 13 + dsi.length);
1003
+ dcd[0] = 4;
1004
+ dcd[1] = 13 + dsi.length;
1005
+ dcd[2] = 64;
1006
+ dcd[3] = 5 << 2 | 1;
1007
+ dcd.set(dsi, 15);
1008
+ const esd = new Uint8Array(2 + 3 + dcd.length);
1009
+ esd[0] = 3;
1010
+ esd[1] = 3 + dcd.length;
1011
+ esd.set(dcd, 5);
1012
+ const esdsPayload = new Uint8Array(4 + esd.length);
1013
+ esdsPayload.set(esd, 4);
1014
+ const esds = box("esds", esdsPayload);
1015
+ const mp4aFixed = new Uint8Array(28);
1016
+ mp4aFixed[7] = 1;
1017
+ mp4aFixed[16] = 0;
1018
+ mp4aFixed[17] = 1;
1019
+ mp4aFixed[18] = 0;
1020
+ mp4aFixed[19] = 16;
1021
+ mp4aFixed[24] = 187;
1022
+ mp4aFixed[25] = 128;
1023
+ const mp4a = box("mp4a", concat(mp4aFixed, esds));
1024
+ const stsdPayload = new Uint8Array(8 + mp4a.length);
1025
+ stsdPayload[7] = 1;
1026
+ stsdPayload.set(mp4a, 8);
1027
+ const stsd = box("stsd", stsdPayload);
1028
+ const stbl = box("stbl", stsd);
1029
+ const minf = box("minf", stbl);
1030
+ const mdia = box("mdia", minf);
1031
+ const trak = box("trak", mdia);
1032
+ const moov = box("moov", trak);
1033
+ return concat(ftyp, moov);
1034
+ }
1035
+ test("extracts AAC-LC mono 48k ASC and derives codec", () => {
1036
+ const asc = new Uint8Array([17, 136]);
1037
+ const init = buildMinimalAacInit(asc);
1038
+ const result = extractAacAscFromInitSegment(init);
1039
+ expect(result).toBeDefined();
1040
+ expect(result.codec).toBe("mp4a.40.2");
1041
+ expect(Array.from(result.description)).toEqual([17, 136]);
1042
+ });
1043
+ test("derives AOT 5 (HE-AAC) from ASC[0] >> 3", () => {
1044
+ const asc = new Uint8Array([41, 136]);
1045
+ const init = buildMinimalAacInit(asc);
1046
+ expect(extractAacAscFromInitSegment(init)?.codec).toBe("mp4a.40.5");
1047
+ });
1048
+ test("rejects data without ftyp/moov magic", () => {
1049
+ expect(extractAacAscFromInitSegment(new Uint8Array(64))).toBeUndefined();
1050
+ });
1051
+ test("rejects ftyp+moov with no audio (no mp4a sample entry)", () => {
1052
+ const ftyp = new Uint8Array([
1053
+ 0,
1054
+ 0,
1055
+ 0,
1056
+ 24,
1057
+ 102,
1058
+ 116,
1059
+ 121,
1060
+ 112,
1061
+ 105,
1062
+ 115,
1063
+ 111,
1064
+ 53,
1065
+ 0,
1066
+ 0,
1067
+ 2,
1068
+ 0,
1069
+ 105,
1070
+ 115,
1071
+ 111,
1072
+ 53,
1073
+ 105,
1074
+ 115,
1075
+ 111,
1076
+ 54
1077
+ ]);
1078
+ const moov = new Uint8Array([0, 0, 0, 8, 109, 111, 111, 118]);
1079
+ const cat = new Uint8Array(ftyp.length + moov.length);
1080
+ cat.set(ftyp);
1081
+ cat.set(moov, ftyp.length);
1082
+ expect(extractAacAscFromInitSegment(cat)).toBeUndefined();
1083
+ });
1084
+ });
1085
+ describe("hevc", () => {
1086
+ const vps = new Uint8Array([64, 1, 12, 1, 255, 255]);
1087
+ const sps = new Uint8Array([66, 1, 1, 1, 96, 0, 0, 0, 144, 0, 0, 0, 0, 0, 60, 160, 5, 2]);
1088
+ const pps = new Uint8Array([68, 1, 193, 114, 180, 98]);
1089
+ const idr = new Uint8Array([38, 1, 175, 6]);
1090
+ const lp = (...nals) => {
1091
+ const parts = [];
1092
+ for (const n of nals) {
1093
+ parts.push(n.length >> 24 & 255, n.length >> 16 & 255, n.length >> 8 & 255, n.length & 255, ...n);
1094
+ }
1095
+ return Uint8Array.from(parts);
1096
+ };
1097
+ test("isHevcCodec", () => {
1098
+ expect(isHevcCodec("hev1.1.6.L93.B0")).toBe(true);
1099
+ expect(isHevcCodec("hvc1.1.6.L93.B0")).toBe(true);
1100
+ expect(isHevcCodec("avc1.640033")).toBe(false);
1101
+ });
1102
+ test("removeEmulationPrevention strips 0x03", () => {
1103
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([0, 0, 3, 1])))).toEqual([0, 0, 1]);
1104
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([170, 187])))).toEqual([170, 187]);
1105
+ });
1106
+ test("splitAvccNalUnits splits length-prefixed NALs", () => {
1107
+ const nals = splitAvccNalUnits(lp(vps, sps));
1108
+ expect(nals.length).toBe(2);
1109
+ expect(nals[0]).toEqual(vps);
1110
+ expect(nals[1]).toEqual(sps);
1111
+ });
1112
+ test("isCompleteAvccSample accepts complete length-prefixed NAL samples", () => {
1113
+ expect(isCompleteAvccSample(lp(new Uint8Array([9]), idr))).toBe(true);
1114
+ });
1115
+ test("isCompleteAvccSample rejects Annex-B start-code samples", () => {
1116
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 1, 101, 170]))).toBe(false);
1117
+ });
1118
+ test("isCompleteAvccSample rejects truncated length-prefixed samples", () => {
1119
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 4, 101, 170]))).toBe(false);
1120
+ });
1121
+ test("normalizeH264SampleToAvcc leaves complete AVCC samples unchanged", () => {
1122
+ const avcc = lp(new Uint8Array([9]), idr);
1123
+ const normalized = normalizeH264SampleToAvcc(avcc);
1124
+ expect(normalized.format).toBe("avcc");
1125
+ expect(normalized.data).toBe(avcc);
1126
+ });
1127
+ test("normalizeH264SampleToAvcc converts a single raw H.264 NAL to AVCC", () => {
1128
+ const raw = new Uint8Array([101, 136, 132]);
1129
+ const normalized = normalizeH264SampleToAvcc(raw);
1130
+ expect(normalized.format).toBe("raw-nal");
1131
+ expect(normalized.data).toEqual(new Uint8Array([0, 0, 0, 3, 101, 136, 132]));
1132
+ });
1133
+ test("splitH264SampleNalUnits exposes Annex-B NALs without AVCC conversion", () => {
1134
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 136, 132]);
1135
+ const sample = splitH264SampleNalUnits(annexB);
1136
+ expect(sample.format).toBe("annexb");
1137
+ expect(sample.nals).toHaveLength(1);
1138
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136, 132]));
1139
+ });
1140
+ test("splitH264SampleNalUnits exposes single raw H.264 NALs without wrapping", () => {
1141
+ const raw = new Uint8Array([101, 136, 132]);
1142
+ const sample = splitH264SampleNalUnits(raw);
1143
+ expect(sample.format).toBe("raw-nal");
1144
+ expect(sample.nals).toEqual([raw]);
1145
+ });
1146
+ test("splitH264SampleNalUnits can expose partial AVCC NAL headers", () => {
1147
+ const partial = new Uint8Array([0, 0, 0, 5, 101, 136]);
1148
+ const sample = splitH264SampleNalUnits(partial, { allowPartialAvcc: true });
1149
+ expect(sample.format).toBe("partial-avcc");
1150
+ expect(sample.nals).toHaveLength(1);
1151
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136]));
1152
+ });
1153
+ test("extractHevcParameterSets finds VPS/SPS/PPS (length-prefixed)", () => {
1154
+ const sets = extractHevcParameterSets(lp(vps, sps, pps, idr));
1155
+ expect(sets.vps).toEqual(vps);
1156
+ expect(sets.sps).toEqual(sps);
1157
+ expect(sets.pps).toEqual(pps);
1158
+ });
1159
+ test("extractHevcParameterSets finds VPS/SPS/PPS (Annex-B)", () => {
1160
+ const sc = new Uint8Array([0, 0, 0, 1]);
1161
+ const annexb = Uint8Array.from([...sc, ...vps, ...sc, ...sps, ...sc, ...pps, ...sc, ...idr]);
1162
+ const sets = extractHevcParameterSets(annexb);
1163
+ expect(sets.vps).toEqual(vps);
1164
+ expect(sets.sps).toEqual(sps);
1165
+ expect(sets.pps).toEqual(pps);
1166
+ });
1167
+ test("generateHvcCFromParameterSets builds a valid hvcC", () => {
1168
+ const hvcc = generateHvcCFromParameterSets({ vps, sps, pps });
1169
+ expect(hvcc).not.toBeNull();
1170
+ expect(hvcc[0]).toBe(1);
1171
+ expect(hvcc[1]).toBe(sps[3]);
1172
+ expect(hvcc[22]).toBe(3);
1173
+ expect(hvcc[23] & 63).toBe(32);
1174
+ expect(hvcc[24] << 8 | hvcc[25]).toBe(1);
1175
+ });
1176
+ test("generateHvcCFromParameterSets returns null without SPS/PPS", () => {
1177
+ expect(generateHvcCFromParameterSets({ vps })).toBeNull();
1178
+ });
1179
+ test("extractHevcCodecDescription end-to-end from keyframe", () => {
1180
+ const desc = extractHevcCodecDescription(lp(vps, sps, pps, idr));
1181
+ expect(desc).not.toBeNull();
1182
+ expect(desc[0]).toBe(1);
1183
+ });
1184
+ test("hevcVclOnly strips parameter-set NALs, keeps VCL", () => {
1185
+ const stripped = hevcVclOnly(lp(vps, sps, pps, idr));
1186
+ const nals = splitAvccNalUnits(stripped);
1187
+ expect(nals.length).toBe(1);
1188
+ expect(nals[0]).toEqual(idr);
1189
+ });
1190
+ test("hevcVclOnly is a no-op for VCL-only length-prefixed input", () => {
1191
+ const vclOnly = lp(idr);
1192
+ expect(hevcVclOnly(vclOnly)).toBe(vclOnly);
1193
+ });
1194
+ });
1195
+ });
1196
+ }
1197
+ export {
1198
+ annexBToAvcc,
1199
+ avccToAnnexB,
1200
+ classifyH264Keyframe,
1201
+ codecStringFromAvcC,
1202
+ detectH264Keyframe,
1203
+ extractAacAscFromInitSegment,
1204
+ extractAvcCFromInitSegment,
1205
+ extractCodecDescriptionFromAnnexB,
1206
+ extractHevcCodecDescription,
1207
+ extractHevcParameterSets,
1208
+ extractSpsPpsFromAvcC,
1209
+ findAnnexBStartCode,
1210
+ generateFallbackAvcC,
1211
+ generateHvcCFromParameterSets,
1212
+ hevcVclOnly,
1213
+ isAnnexB,
1214
+ isCompleteAvccSample,
1215
+ isFmp4InitSegment,
1216
+ isHevcCodec,
1217
+ mmtpTimestampToMicros,
1218
+ normalizeH264SampleToAvcc,
1219
+ removeEmulationPrevention,
1220
+ splitAnnexBNalUnits,
1221
+ splitAvccNalUnits,
1222
+ splitH264SampleNalUnits,
1223
+ wrapAdtsFrame
1224
+ };
1225
+ //# sourceMappingURL=codec-utils.js.map