@blockcast/mmt-container 0.1.0-main.09c5546569f1

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 +17151 -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 +248 -0
  52. package/dist/codec-utils.d.ts.map +1 -0
  53. package/dist/codec-utils.js +1265 -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 +332 -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 +5447 -0
  110. package/dist/mmtp-container-parser.js.map +7 -0
  111. package/dist/mmtp-container-parser.no-modules.js +7922 -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 +5658 -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 +8453 -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 +11101 -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 +7888 -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 +5704 -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 +1598 -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 +444 -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 +1510 -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,1265 @@
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 === "mmpu") return false;
458
+ if (type === "ftyp") sawFtyp = true;
459
+ if (type === "moov") {
460
+ if (!sawFtyp) return false;
461
+ sawMoov = true;
462
+ }
463
+ offset += size;
464
+ }
465
+ return offset === data.byteLength && sawFtyp && sawMoov;
466
+ }
467
+ function normalizeMmtpInitSegment(data) {
468
+ if (isFmp4InitSegment(data)) return data;
469
+ const parts = [];
470
+ let offset = 0;
471
+ let removedMpu = false;
472
+ while (offset + 8 <= data.byteLength) {
473
+ const view = new DataView(data.buffer, data.byteOffset + offset, data.byteLength - offset);
474
+ let size = view.getUint32(0, false);
475
+ let headerSize = 8;
476
+ if (size === 1) {
477
+ if (offset + 16 > data.byteLength) return void 0;
478
+ const largeSize = view.getBigUint64(8, false);
479
+ if (largeSize > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
480
+ size = Number(largeSize);
481
+ headerSize = 16;
482
+ } else if (size === 0) {
483
+ size = data.byteLength - offset;
484
+ }
485
+ if (size < headerSize || offset + size > data.byteLength) return void 0;
486
+ const type = String.fromCharCode(
487
+ data[offset + 4],
488
+ data[offset + 5],
489
+ data[offset + 6],
490
+ data[offset + 7]
491
+ );
492
+ if (type === "mmpu") removedMpu = true;
493
+ else parts.push(data.subarray(offset, offset + size));
494
+ offset += size;
495
+ }
496
+ if (!removedMpu || offset !== data.byteLength) return void 0;
497
+ const normalized = new Uint8Array(parts.reduce((total, part) => total + part.byteLength, 0));
498
+ let writeOffset = 0;
499
+ for (const part of parts) {
500
+ normalized.set(part, writeOffset);
501
+ writeOffset += part.byteLength;
502
+ }
503
+ return isFmp4InitSegment(normalized) ? normalized : void 0;
504
+ }
505
+ function hasIsoBmffMagic(data) {
506
+ for (let i = 0; i + 8 <= data.length && i < 32; i += 4) {
507
+ const tag = String.fromCharCode(data[i + 4], data[i + 5], data[i + 6], data[i + 7]);
508
+ if (tag === "ftyp" || tag === "moov") return true;
509
+ }
510
+ return false;
511
+ }
512
+ function findTrackStsdBoxes(data) {
513
+ const moov = findBox(data, 0, data.length, "moov");
514
+ if (!moov) return [];
515
+ const out = [];
516
+ for (const trak of findBoxes(data, moov.o + 8, moov.o + moov.sz, "trak")) {
517
+ const stsd = findNestedBox(data, trak.o + 8, trak.o + trak.sz, ["mdia", "minf", "stbl", "stsd"]);
518
+ if (stsd) out.push(stsd);
519
+ }
520
+ return out;
521
+ }
522
+ function findNestedBox(buf, start, end, path) {
523
+ let s = start;
524
+ let e = end;
525
+ let current;
526
+ for (const type of path) {
527
+ current = findBox(buf, s, e, type);
528
+ if (!current) return void 0;
529
+ s = current.o + 8;
530
+ e = current.o + current.sz;
531
+ }
532
+ return current;
533
+ }
534
+ function findBox(buf, start, end, type) {
535
+ return findBoxes(buf, start, end, type)[0];
536
+ }
537
+ function findBoxes(buf, start, end, type) {
538
+ const boxes = [];
539
+ let o = start;
540
+ while (o + 8 <= end) {
541
+ let sz = buf[o] << 24 | buf[o + 1] << 16 | buf[o + 2] << 8 | buf[o + 3];
542
+ const t = String.fromCharCode(buf[o + 4], buf[o + 5], buf[o + 6], buf[o + 7]);
543
+ if (sz === 0) sz = end - o;
544
+ if (sz < 8 || o + sz > end) break;
545
+ if (t === type) boxes.push({ o, sz });
546
+ o += sz;
547
+ }
548
+ return boxes;
549
+ }
550
+ function writeNalLength(buf, offset, len) {
551
+ buf[offset] = len >> 24 & 255;
552
+ buf[offset + 1] = len >> 16 & 255;
553
+ buf[offset + 2] = len >> 8 & 255;
554
+ buf[offset + 3] = len & 255;
555
+ return offset + 4;
556
+ }
557
+ function h264NalUnitsForKeyframeDetection(data, options) {
558
+ return splitH264SampleNalUnits(data, options).nals;
559
+ }
560
+ function splitPartialAvccNalUnits(data, lengthSize = 4) {
561
+ const nals = [];
562
+ let i = 0;
563
+ while (i + lengthSize < data.length) {
564
+ let len = 0;
565
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
566
+ i += lengthSize;
567
+ if (len <= 0 || i >= data.length) break;
568
+ const end = Math.min(i + len, data.length);
569
+ nals.push(data.subarray(i, end));
570
+ if (end < i + len) break;
571
+ i = end;
572
+ }
573
+ return nals;
574
+ }
575
+ function isLikelyRawH264NalUnit(data) {
576
+ if (data.length === 0) return false;
577
+ const header = data[0];
578
+ if ((header & 128) !== 0) return false;
579
+ const nalType = header & 31;
580
+ return nalType > 0 && nalType < 24;
581
+ }
582
+ function rawH264NalToAvcc(data) {
583
+ const out = new Uint8Array(4 + data.length);
584
+ new DataView(out.buffer, out.byteOffset, out.byteLength).setUint32(0, data.length);
585
+ out.set(data, 4);
586
+ return out;
587
+ }
588
+ function isH264IntraSlice(nal) {
589
+ const sliceType = readH264SliceType(nal);
590
+ return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
591
+ }
592
+ function readH264SliceType(nal) {
593
+ if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
594
+ const rbsp = removeEmulationPrevention(nal.subarray(1));
595
+ const state = { bitOffset: 0 };
596
+ if (readUnsignedExpGolomb(rbsp, state) === null) return null;
597
+ return readUnsignedExpGolomb(rbsp, state);
598
+ }
599
+ function readUnsignedExpGolomb(data, state) {
600
+ let leadingZeroBits = 0;
601
+ while (true) {
602
+ const bit = readBit(data, state);
603
+ if (bit === null) return null;
604
+ if (bit === 1) break;
605
+ leadingZeroBits++;
606
+ if (leadingZeroBits > 30) return null;
607
+ }
608
+ let suffix = 0;
609
+ for (let i = 0; i < leadingZeroBits; i++) {
610
+ const bit = readBit(data, state);
611
+ if (bit === null) return null;
612
+ suffix = suffix << 1 | bit;
613
+ }
614
+ return (1 << leadingZeroBits) - 1 + suffix;
615
+ }
616
+ function readBit(data, state) {
617
+ if (state.bitOffset >= data.length * 8) return null;
618
+ const byte = data[state.bitOffset >> 3];
619
+ const bit = byte >> 7 - (state.bitOffset & 7) & 1;
620
+ state.bitOffset++;
621
+ return bit;
622
+ }
623
+ function hex2(n) {
624
+ return n.toString(16).padStart(2, "0");
625
+ }
626
+ function pad2(n) {
627
+ return String(n).padStart(2, "0");
628
+ }
629
+ function codecStringFromAv1C(av1C) {
630
+ if (av1C.length < 4) return "av01.0.01M.08";
631
+ const profile = av1C[1] >>> 5 & 7;
632
+ const level = av1C[1] & 31;
633
+ const tier = (av1C[2] & 128) !== 0 ? "H" : "M";
634
+ let bitDepth = 8;
635
+ if ((av1C[2] & 64) !== 0) {
636
+ bitDepth = (av1C[2] & 32) !== 0 ? 12 : 10;
637
+ }
638
+ return `av01.${profile}.${pad2(level)}${tier}.${pad2(bitDepth)}`;
639
+ }
640
+ function codecStringFromVpcC(vpcC) {
641
+ if (vpcC.length < 3) return "vp09.00.10.08";
642
+ const offset = vpcC.length >= 7 && vpcC[0] <= 1 ? 4 : 0;
643
+ if (offset + 2 >= vpcC.length) return "vp09.00.10.08";
644
+ const profile = vpcC[offset];
645
+ const level = vpcC[offset + 1];
646
+ const bitDepth = vpcC[offset + 2] >>> 4 || 8;
647
+ return `vp09.${pad2(profile)}.${pad2(level)}.${pad2(bitDepth)}`;
648
+ }
649
+ function hevcCodecStringFromHvcC(c) {
650
+ const profileSpace = c[1] >> 6 & 3;
651
+ const tierFlag = c[1] >> 5 & 1;
652
+ const profileIdc = c[1] & 31;
653
+ const compat = (c[2] << 24 | c[3] << 16 | c[4] << 8 | c[5]) >>> 0;
654
+ let rev = 0;
655
+ let v = compat;
656
+ for (let i = 0; i < 32; i++) {
657
+ rev = (rev << 1 | v & 1) >>> 0;
658
+ v >>>= 1;
659
+ }
660
+ const compatStr = rev.toString(16);
661
+ const constraint = c.subarray(6, 12);
662
+ let lastNonZero = -1;
663
+ for (let i = 0; i < constraint.length; i++) if (constraint[i] !== 0) lastNonZero = i;
664
+ const constraintParts = [];
665
+ for (let i = 0; i <= lastNonZero; i++) constraintParts.push(constraint[i].toString(16));
666
+ const space = profileSpace === 0 ? "" : String.fromCharCode(64 + profileSpace);
667
+ const tier = tierFlag === 0 ? "L" : "H";
668
+ let s = `hvc1.${space}${profileIdc}.${compatStr}.${tier}${c[12]}`;
669
+ if (constraintParts.length > 0) s += "." + constraintParts.join(".");
670
+ return s;
671
+ }
672
+ var BitWriter = class {
673
+ constructor() {
674
+ this.buf = [];
675
+ this.byte = 0;
676
+ this.bit = 7;
677
+ }
678
+ u(val, bits) {
679
+ for (let i = bits - 1; i >= 0; i--) {
680
+ this.byte |= (val >> i & 1) << this.bit;
681
+ if (--this.bit < 0) {
682
+ this.buf.push(this.byte);
683
+ this.byte = 0;
684
+ this.bit = 7;
685
+ }
686
+ }
687
+ }
688
+ ue(val) {
689
+ const v = val + 1;
690
+ const bits = Math.floor(Math.log2(v)) + 1;
691
+ this.u(0, bits - 1);
692
+ this.u(v, bits);
693
+ }
694
+ se(val) {
695
+ this.ue(val <= 0 ? -val * 2 : val * 2 - 1);
696
+ }
697
+ finish() {
698
+ if (this.bit < 7) {
699
+ this.byte |= 1 << this.bit;
700
+ this.buf.push(this.byte);
701
+ }
702
+ return new Uint8Array(this.buf);
703
+ }
704
+ };
705
+ function resolveResolution(explicitW, explicitH, level) {
706
+ if (explicitW && explicitH) return { width: explicitW, height: explicitH };
707
+ const levelResolutions = {
708
+ 10: [176, 144],
709
+ 11: [352, 288],
710
+ 12: [352, 288],
711
+ 13: [352, 288],
712
+ 20: [352, 288],
713
+ 21: [720, 576],
714
+ 22: [720, 576],
715
+ 30: [1280, 720],
716
+ 31: [1280, 720],
717
+ 32: [1280, 1024],
718
+ 40: [1920, 1088],
719
+ 41: [1920, 1088],
720
+ 42: [2048, 1088],
721
+ 50: [4096, 2160],
722
+ 51: [4096, 2160],
723
+ 52: [4096, 2160]
724
+ };
725
+ const [w, h] = levelResolutions[level] ?? [1920, 1088];
726
+ return { width: explicitW ?? w, height: explicitH ?? h };
727
+ }
728
+ function buildMinimalSps(profile, constraint, level, width, height) {
729
+ const widthInMbs = Math.ceil(width / 16);
730
+ const heightInMapUnits = Math.ceil(height / 16);
731
+ const w = new BitWriter();
732
+ w.u(0, 1);
733
+ w.u(3, 2);
734
+ w.u(7, 5);
735
+ w.u(profile, 8);
736
+ w.u(constraint, 8);
737
+ w.u(level, 8);
738
+ w.ue(0);
739
+ if (profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44) {
740
+ w.ue(1);
741
+ w.ue(0);
742
+ w.ue(0);
743
+ w.u(0, 1);
744
+ w.u(0, 1);
745
+ }
746
+ w.ue(0);
747
+ w.ue(2);
748
+ w.ue(1);
749
+ w.u(0, 1);
750
+ w.ue(widthInMbs - 1);
751
+ w.ue(heightInMapUnits - 1);
752
+ w.u(1, 1);
753
+ w.u(1, 1);
754
+ const cropRight = widthInMbs * 16 - width;
755
+ const cropBottom = heightInMapUnits * 16 - height;
756
+ if (cropRight > 0 || cropBottom > 0) {
757
+ w.u(1, 1);
758
+ w.ue(0);
759
+ w.ue(cropRight / 2);
760
+ w.ue(0);
761
+ w.ue(cropBottom / 2);
762
+ } else {
763
+ w.u(0, 1);
764
+ }
765
+ w.u(0, 1);
766
+ return w.finish();
767
+ }
768
+ function buildMinimalPps(profile) {
769
+ const isHighProfile = profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44;
770
+ const w = new BitWriter();
771
+ w.u(0, 1);
772
+ w.u(3, 2);
773
+ w.u(8, 5);
774
+ w.ue(0);
775
+ w.ue(0);
776
+ w.u(isHighProfile ? 1 : 0, 1);
777
+ w.u(0, 1);
778
+ w.ue(0);
779
+ w.ue(0);
780
+ w.ue(0);
781
+ w.u(0, 1);
782
+ w.u(0, 2);
783
+ w.se(0);
784
+ w.se(0);
785
+ w.se(0);
786
+ w.u(1, 1);
787
+ w.u(0, 1);
788
+ w.u(0, 1);
789
+ if (isHighProfile) {
790
+ w.u(1, 1);
791
+ w.u(0, 1);
792
+ w.se(0);
793
+ }
794
+ return w.finish();
795
+ }
796
+ var ADTS_SAMPLE_RATES = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350];
797
+ function wrapAdtsFrame(raw, sampleRate, channels) {
798
+ const sri = ADTS_SAMPLE_RATES.indexOf(sampleRate);
799
+ const idx = sri >= 0 ? sri : 3;
800
+ const len = 7 + raw.length;
801
+ const out = new Uint8Array(len);
802
+ out[0] = 255;
803
+ out[1] = 241;
804
+ out[2] = 1 << 6 | idx << 2 | channels >> 2;
805
+ out[3] = (channels & 3) << 6 | len >> 11 & 3;
806
+ out[4] = len >> 3 & 255;
807
+ out[5] = (len & 7) << 5 | 31;
808
+ out[6] = 252;
809
+ out.set(raw, 7);
810
+ return out;
811
+ }
812
+ function extractAacAscFromInitSegment(data) {
813
+ if (!hasIsoBmffMagic(data)) return void 0;
814
+ for (const stsd of findTrackStsdBoxes(data)) {
815
+ const info = extractAacAscFromStsd(data, stsd);
816
+ if (info) return info;
817
+ }
818
+ return void 0;
819
+ }
820
+ function extractAacAscFromStsd(data, stsd) {
821
+ const s = stsd.o + 16;
822
+ const e = stsd.o + stsd.sz;
823
+ const mp4a = findBox(data, s, e, "mp4a");
824
+ if (!mp4a || mp4a.sz < 36) return void 0;
825
+ const esds = findBox(data, mp4a.o + 36, mp4a.o + mp4a.sz, "esds");
826
+ if (!esds || esds.sz < 12) return void 0;
827
+ const esdsPayload = data.subarray(esds.o + 8, esds.o + esds.sz);
828
+ const asc = extractAudioSpecificConfig(esdsPayload);
829
+ if (!asc || asc.length < 2) return void 0;
830
+ const aot = asc[0] >> 3;
831
+ return { codec: `mp4a.40.${aot}`, description: asc };
832
+ }
833
+ function extractAudioSpecificConfig(esds) {
834
+ let offset = 4;
835
+ while (offset < esds.length) {
836
+ const tag = esds[offset++];
837
+ let size = 0;
838
+ for (let i = 0; i < 4 && offset < esds.length; i++) {
839
+ const b = esds[offset++];
840
+ size = size << 7 | b & 127;
841
+ if ((b & 128) === 0) break;
842
+ }
843
+ if (tag === 5) {
844
+ if (offset + size > esds.length) return void 0;
845
+ return esds.subarray(offset, offset + size);
846
+ }
847
+ if (tag === 3) {
848
+ offset += 3;
849
+ } else if (tag === 4) {
850
+ offset += 13;
851
+ } else {
852
+ offset += size;
853
+ }
854
+ }
855
+ return void 0;
856
+ }
857
+ if (void 0) {
858
+ const { describe, test, expect } = void 0;
859
+ describe("codec-utils", () => {
860
+ describe("isAnnexB", () => {
861
+ test("4-byte start code", () => {
862
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
863
+ });
864
+ test("3-byte start code", () => {
865
+ expect(isAnnexB(new Uint8Array([0, 0, 1, 101]))).toBe(true);
866
+ });
867
+ test("rejects AVCC", () => {
868
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 10, 101]))).toBe(false);
869
+ });
870
+ });
871
+ describe("findAnnexBStartCode", () => {
872
+ test("at offset 0", () => {
873
+ expect(findAnnexBStartCode(new Uint8Array([0, 0, 0, 1, 101]))).toBe(0);
874
+ });
875
+ test("at offset 5", () => {
876
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204, 221, 238, 0, 0, 1, 101]))).toBe(5);
877
+ });
878
+ test("returns -1 when none", () => {
879
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204]))).toBe(-1);
880
+ });
881
+ });
882
+ describe("splitAnnexBNalUnits", () => {
883
+ test("splits two NALs", () => {
884
+ const data = new Uint8Array([0, 0, 0, 1, 101, 170, 187, 0, 0, 0, 1, 65, 204]);
885
+ const nals = splitAnnexBNalUnits(data);
886
+ expect(nals.length).toBe(2);
887
+ expect(nals[0]).toEqual(new Uint8Array([101, 170, 187]));
888
+ expect(nals[1]).toEqual(new Uint8Array([65, 204]));
889
+ });
890
+ test("handles 3-byte start codes", () => {
891
+ const nals = splitAnnexBNalUnits(new Uint8Array([0, 0, 1, 103, 66, 0, 0, 1, 104, 1]));
892
+ expect(nals.length).toBe(2);
893
+ });
894
+ });
895
+ describe("annexBToAvcc", () => {
896
+ test("converts single NAL", () => {
897
+ const annexB = new Uint8Array([0, 0, 0, 1, 65, 170, 187]);
898
+ const avcc = annexBToAvcc(annexB);
899
+ expect(avcc[3]).toBe(3);
900
+ expect(avcc[4]).toBe(65);
901
+ });
902
+ test("prepends SPS/PPS", () => {
903
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 1]);
904
+ const avcc = annexBToAvcc(annexB, { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) });
905
+ expect(avcc[3]).toBe(2);
906
+ expect(avcc[4]).toBe(103);
907
+ });
908
+ });
909
+ describe("detectH264Keyframe", () => {
910
+ test("IDR in Annex-B", () => {
911
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
912
+ });
913
+ test("SPS in Annex-B", () => {
914
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 103]))).toBe(true);
915
+ });
916
+ test("IDR in AVCC", () => {
917
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 5, 101, 1, 2, 3, 4]))).toBe(true);
918
+ });
919
+ test("IDR after AVCC AUD", () => {
920
+ expect(detectH264Keyframe(new Uint8Array([
921
+ 0,
922
+ 0,
923
+ 0,
924
+ 1,
925
+ 9,
926
+ 0,
927
+ 0,
928
+ 0,
929
+ 2,
930
+ 101,
931
+ 170
932
+ ]))).toBe(true);
933
+ });
934
+ test("non-IDR AVC I-slice in AVCC", () => {
935
+ expect(detectH264Keyframe(new Uint8Array([
936
+ 0,
937
+ 0,
938
+ 0,
939
+ 2,
940
+ 65,
941
+ 136
942
+ ]))).toBe(true);
943
+ });
944
+ test("raw H.264 IDR NAL", () => {
945
+ expect(detectH264Keyframe(new Uint8Array([101, 136, 132]))).toBe(true);
946
+ });
947
+ test("raw H.264 non-IDR I-slice NAL", () => {
948
+ expect(detectH264Keyframe(new Uint8Array([65, 136]))).toBe(true);
949
+ });
950
+ test("classifies partial length-prefixed IDR only when requested", () => {
951
+ const partial = new Uint8Array([0, 0, 32, 0, 101]);
952
+ expect(classifyH264Keyframe(partial)).toBeUndefined();
953
+ expect(classifyH264Keyframe(partial, { allowPartialAvcc: true })).toBe(true);
954
+ });
955
+ test("rejects P-frame", () => {
956
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 65]))).toBe(false);
957
+ });
958
+ test("rejects AVCC sample with only non-IDR slices", () => {
959
+ expect(detectH264Keyframe(new Uint8Array([
960
+ 0,
961
+ 0,
962
+ 0,
963
+ 2,
964
+ 65,
965
+ 192,
966
+ 0,
967
+ 0,
968
+ 0,
969
+ 2,
970
+ 65,
971
+ 192
972
+ ]))).toBe(false);
973
+ });
974
+ });
975
+ describe("avccToAnnexB", () => {
976
+ test("converts with SPS/PPS on keyframe", () => {
977
+ const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
978
+ const spsPps = { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) };
979
+ const annexB = avccToAnnexB(avcc, true, spsPps);
980
+ expect(annexB[3]).toBe(1);
981
+ expect(annexB[4]).toBe(103);
982
+ });
983
+ });
984
+ describe("codecStringFromAvcC", () => {
985
+ test("derives avc1.64002a", () => {
986
+ expect(codecStringFromAvcC(new Uint8Array([1, 100, 0, 42]))).toBe("avc1.64002a");
987
+ });
988
+ });
989
+ describe("extractAacAscFromInitSegment", () => {
990
+ function buildMinimalAacInit(asc) {
991
+ const box = (type, payload) => {
992
+ const sz = 8 + payload.length;
993
+ const out = new Uint8Array(sz);
994
+ out[0] = sz >>> 24 & 255;
995
+ out[1] = sz >>> 16 & 255;
996
+ out[2] = sz >>> 8 & 255;
997
+ out[3] = sz & 255;
998
+ out[4] = type.charCodeAt(0);
999
+ out[5] = type.charCodeAt(1);
1000
+ out[6] = type.charCodeAt(2);
1001
+ out[7] = type.charCodeAt(3);
1002
+ out.set(payload, 8);
1003
+ return out;
1004
+ };
1005
+ const concat = (...arrs) => {
1006
+ const total = arrs.reduce((n, a) => n + a.length, 0);
1007
+ const out = new Uint8Array(total);
1008
+ let off = 0;
1009
+ for (const a of arrs) {
1010
+ out.set(a, off);
1011
+ off += a.length;
1012
+ }
1013
+ return out;
1014
+ };
1015
+ const ftyp = box("ftyp", new Uint8Array([
1016
+ 105,
1017
+ 115,
1018
+ 111,
1019
+ 53,
1020
+ // 'iso5'
1021
+ 0,
1022
+ 0,
1023
+ 2,
1024
+ 0,
1025
+ // minor 0x200
1026
+ 105,
1027
+ 115,
1028
+ 111,
1029
+ 53,
1030
+ // 'iso5'
1031
+ 105,
1032
+ 115,
1033
+ 111,
1034
+ 54
1035
+ // 'iso6'
1036
+ ]));
1037
+ const dsi = new Uint8Array(2 + asc.length);
1038
+ dsi[0] = 5;
1039
+ dsi[1] = asc.length;
1040
+ dsi.set(asc, 2);
1041
+ const dcd = new Uint8Array(2 + 13 + dsi.length);
1042
+ dcd[0] = 4;
1043
+ dcd[1] = 13 + dsi.length;
1044
+ dcd[2] = 64;
1045
+ dcd[3] = 5 << 2 | 1;
1046
+ dcd.set(dsi, 15);
1047
+ const esd = new Uint8Array(2 + 3 + dcd.length);
1048
+ esd[0] = 3;
1049
+ esd[1] = 3 + dcd.length;
1050
+ esd.set(dcd, 5);
1051
+ const esdsPayload = new Uint8Array(4 + esd.length);
1052
+ esdsPayload.set(esd, 4);
1053
+ const esds = box("esds", esdsPayload);
1054
+ const mp4aFixed = new Uint8Array(28);
1055
+ mp4aFixed[7] = 1;
1056
+ mp4aFixed[16] = 0;
1057
+ mp4aFixed[17] = 1;
1058
+ mp4aFixed[18] = 0;
1059
+ mp4aFixed[19] = 16;
1060
+ mp4aFixed[24] = 187;
1061
+ mp4aFixed[25] = 128;
1062
+ const mp4a = box("mp4a", concat(mp4aFixed, esds));
1063
+ const stsdPayload = new Uint8Array(8 + mp4a.length);
1064
+ stsdPayload[7] = 1;
1065
+ stsdPayload.set(mp4a, 8);
1066
+ const stsd = box("stsd", stsdPayload);
1067
+ const stbl = box("stbl", stsd);
1068
+ const minf = box("minf", stbl);
1069
+ const mdia = box("mdia", minf);
1070
+ const trak = box("trak", mdia);
1071
+ const moov = box("moov", trak);
1072
+ return concat(ftyp, moov);
1073
+ }
1074
+ test("extracts AAC-LC mono 48k ASC and derives codec", () => {
1075
+ const asc = new Uint8Array([17, 136]);
1076
+ const init = buildMinimalAacInit(asc);
1077
+ const result = extractAacAscFromInitSegment(init);
1078
+ expect(result).toBeDefined();
1079
+ expect(result.codec).toBe("mp4a.40.2");
1080
+ expect(Array.from(result.description)).toEqual([17, 136]);
1081
+ });
1082
+ test("derives AOT 5 (HE-AAC) from ASC[0] >> 3", () => {
1083
+ const asc = new Uint8Array([41, 136]);
1084
+ const init = buildMinimalAacInit(asc);
1085
+ expect(extractAacAscFromInitSegment(init)?.codec).toBe("mp4a.40.5");
1086
+ });
1087
+ test("rejects data without ftyp/moov magic", () => {
1088
+ expect(extractAacAscFromInitSegment(new Uint8Array(64))).toBeUndefined();
1089
+ });
1090
+ test("rejects ftyp+moov with no audio (no mp4a sample entry)", () => {
1091
+ const ftyp = new Uint8Array([
1092
+ 0,
1093
+ 0,
1094
+ 0,
1095
+ 24,
1096
+ 102,
1097
+ 116,
1098
+ 121,
1099
+ 112,
1100
+ 105,
1101
+ 115,
1102
+ 111,
1103
+ 53,
1104
+ 0,
1105
+ 0,
1106
+ 2,
1107
+ 0,
1108
+ 105,
1109
+ 115,
1110
+ 111,
1111
+ 53,
1112
+ 105,
1113
+ 115,
1114
+ 111,
1115
+ 54
1116
+ ]);
1117
+ const moov = new Uint8Array([0, 0, 0, 8, 109, 111, 111, 118]);
1118
+ const cat = new Uint8Array(ftyp.length + moov.length);
1119
+ cat.set(ftyp);
1120
+ cat.set(moov, ftyp.length);
1121
+ expect(extractAacAscFromInitSegment(cat)).toBeUndefined();
1122
+ });
1123
+ });
1124
+ describe("hevc", () => {
1125
+ const vps = new Uint8Array([64, 1, 12, 1, 255, 255]);
1126
+ const sps = new Uint8Array([66, 1, 1, 1, 96, 0, 0, 0, 144, 0, 0, 0, 0, 0, 60, 160, 5, 2]);
1127
+ const pps = new Uint8Array([68, 1, 193, 114, 180, 98]);
1128
+ const idr = new Uint8Array([38, 1, 175, 6]);
1129
+ const lp = (...nals) => {
1130
+ const parts = [];
1131
+ for (const n of nals) {
1132
+ parts.push(n.length >> 24 & 255, n.length >> 16 & 255, n.length >> 8 & 255, n.length & 255, ...n);
1133
+ }
1134
+ return Uint8Array.from(parts);
1135
+ };
1136
+ test("isHevcCodec", () => {
1137
+ expect(isHevcCodec("hev1.1.6.L93.B0")).toBe(true);
1138
+ expect(isHevcCodec("hvc1.1.6.L93.B0")).toBe(true);
1139
+ expect(isHevcCodec("avc1.640033")).toBe(false);
1140
+ });
1141
+ test("removeEmulationPrevention strips 0x03", () => {
1142
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([0, 0, 3, 1])))).toEqual([0, 0, 1]);
1143
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([170, 187])))).toEqual([170, 187]);
1144
+ });
1145
+ test("splitAvccNalUnits splits length-prefixed NALs", () => {
1146
+ const nals = splitAvccNalUnits(lp(vps, sps));
1147
+ expect(nals.length).toBe(2);
1148
+ expect(nals[0]).toEqual(vps);
1149
+ expect(nals[1]).toEqual(sps);
1150
+ });
1151
+ test("isCompleteAvccSample accepts complete length-prefixed NAL samples", () => {
1152
+ expect(isCompleteAvccSample(lp(new Uint8Array([9]), idr))).toBe(true);
1153
+ });
1154
+ test("isCompleteAvccSample rejects Annex-B start-code samples", () => {
1155
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 1, 101, 170]))).toBe(false);
1156
+ });
1157
+ test("isCompleteAvccSample rejects truncated length-prefixed samples", () => {
1158
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 4, 101, 170]))).toBe(false);
1159
+ });
1160
+ test("normalizeH264SampleToAvcc leaves complete AVCC samples unchanged", () => {
1161
+ const avcc = lp(new Uint8Array([9]), idr);
1162
+ const normalized = normalizeH264SampleToAvcc(avcc);
1163
+ expect(normalized.format).toBe("avcc");
1164
+ expect(normalized.data).toBe(avcc);
1165
+ });
1166
+ test("normalizeH264SampleToAvcc converts a single raw H.264 NAL to AVCC", () => {
1167
+ const raw = new Uint8Array([101, 136, 132]);
1168
+ const normalized = normalizeH264SampleToAvcc(raw);
1169
+ expect(normalized.format).toBe("raw-nal");
1170
+ expect(normalized.data).toEqual(new Uint8Array([0, 0, 0, 3, 101, 136, 132]));
1171
+ });
1172
+ test("splitH264SampleNalUnits exposes Annex-B NALs without AVCC conversion", () => {
1173
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 136, 132]);
1174
+ const sample = splitH264SampleNalUnits(annexB);
1175
+ expect(sample.format).toBe("annexb");
1176
+ expect(sample.nals).toHaveLength(1);
1177
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136, 132]));
1178
+ });
1179
+ test("splitH264SampleNalUnits exposes single raw H.264 NALs without wrapping", () => {
1180
+ const raw = new Uint8Array([101, 136, 132]);
1181
+ const sample = splitH264SampleNalUnits(raw);
1182
+ expect(sample.format).toBe("raw-nal");
1183
+ expect(sample.nals).toEqual([raw]);
1184
+ });
1185
+ test("splitH264SampleNalUnits can expose partial AVCC NAL headers", () => {
1186
+ const partial = new Uint8Array([0, 0, 0, 5, 101, 136]);
1187
+ const sample = splitH264SampleNalUnits(partial, { allowPartialAvcc: true });
1188
+ expect(sample.format).toBe("partial-avcc");
1189
+ expect(sample.nals).toHaveLength(1);
1190
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136]));
1191
+ });
1192
+ test("extractHevcParameterSets finds VPS/SPS/PPS (length-prefixed)", () => {
1193
+ const sets = extractHevcParameterSets(lp(vps, sps, pps, idr));
1194
+ expect(sets.vps).toEqual(vps);
1195
+ expect(sets.sps).toEqual(sps);
1196
+ expect(sets.pps).toEqual(pps);
1197
+ });
1198
+ test("extractHevcParameterSets finds VPS/SPS/PPS (Annex-B)", () => {
1199
+ const sc = new Uint8Array([0, 0, 0, 1]);
1200
+ const annexb = Uint8Array.from([...sc, ...vps, ...sc, ...sps, ...sc, ...pps, ...sc, ...idr]);
1201
+ const sets = extractHevcParameterSets(annexb);
1202
+ expect(sets.vps).toEqual(vps);
1203
+ expect(sets.sps).toEqual(sps);
1204
+ expect(sets.pps).toEqual(pps);
1205
+ });
1206
+ test("generateHvcCFromParameterSets builds a valid hvcC", () => {
1207
+ const hvcc = generateHvcCFromParameterSets({ vps, sps, pps });
1208
+ expect(hvcc).not.toBeNull();
1209
+ expect(hvcc[0]).toBe(1);
1210
+ expect(hvcc[1]).toBe(sps[3]);
1211
+ expect(hvcc[22]).toBe(3);
1212
+ expect(hvcc[23] & 63).toBe(32);
1213
+ expect(hvcc[24] << 8 | hvcc[25]).toBe(1);
1214
+ });
1215
+ test("generateHvcCFromParameterSets returns null without SPS/PPS", () => {
1216
+ expect(generateHvcCFromParameterSets({ vps })).toBeNull();
1217
+ });
1218
+ test("extractHevcCodecDescription end-to-end from keyframe", () => {
1219
+ const desc = extractHevcCodecDescription(lp(vps, sps, pps, idr));
1220
+ expect(desc).not.toBeNull();
1221
+ expect(desc[0]).toBe(1);
1222
+ });
1223
+ test("hevcVclOnly strips parameter-set NALs, keeps VCL", () => {
1224
+ const stripped = hevcVclOnly(lp(vps, sps, pps, idr));
1225
+ const nals = splitAvccNalUnits(stripped);
1226
+ expect(nals.length).toBe(1);
1227
+ expect(nals[0]).toEqual(idr);
1228
+ });
1229
+ test("hevcVclOnly is a no-op for VCL-only length-prefixed input", () => {
1230
+ const vclOnly = lp(idr);
1231
+ expect(hevcVclOnly(vclOnly)).toBe(vclOnly);
1232
+ });
1233
+ });
1234
+ });
1235
+ }
1236
+ export {
1237
+ annexBToAvcc,
1238
+ avccToAnnexB,
1239
+ classifyH264Keyframe,
1240
+ codecStringFromAvcC,
1241
+ detectH264Keyframe,
1242
+ extractAacAscFromInitSegment,
1243
+ extractAvcCFromInitSegment,
1244
+ extractCodecDescriptionFromAnnexB,
1245
+ extractHevcCodecDescription,
1246
+ extractHevcParameterSets,
1247
+ extractSpsPpsFromAvcC,
1248
+ findAnnexBStartCode,
1249
+ generateFallbackAvcC,
1250
+ generateHvcCFromParameterSets,
1251
+ hevcVclOnly,
1252
+ isAnnexB,
1253
+ isCompleteAvccSample,
1254
+ isFmp4InitSegment,
1255
+ isHevcCodec,
1256
+ mmtpTimestampToMicros,
1257
+ normalizeH264SampleToAvcc,
1258
+ normalizeMmtpInitSegment,
1259
+ removeEmulationPrevention,
1260
+ splitAnnexBNalUnits,
1261
+ splitAvccNalUnits,
1262
+ splitH264SampleNalUnits,
1263
+ wrapAdtsFrame
1264
+ };
1265
+ //# sourceMappingURL=codec-utils.js.map