@blockcast/mmt-container 0.1.0 → 0.3.0-main.ef68de90edb3

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 (799) hide show
  1. package/README.md +524 -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 +152 -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 +80 -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/block-policy.d.ts +314 -0
  22. package/dist/block-policy.d.ts.map +1 -0
  23. package/dist/block-policy.js +466 -0
  24. package/dist/block-policy.js.map +7 -0
  25. package/dist/browser-runtime.js +26549 -0
  26. package/dist/browser-runtime.js.map +7 -0
  27. package/dist/carp-catalog.d.ts +429 -0
  28. package/dist/carp-catalog.d.ts.map +1 -0
  29. package/dist/carp-catalog.js +985 -0
  30. package/dist/carp-catalog.js.map +7 -0
  31. package/dist/catalog-fec-params.d.ts +275 -0
  32. package/dist/catalog-fec-params.d.ts.map +1 -0
  33. package/dist/catalog-fec-params.js +702 -0
  34. package/dist/catalog-fec-params.js.map +7 -0
  35. package/dist/catalog-network-source.d.ts +42 -0
  36. package/dist/catalog-network-source.d.ts.map +1 -0
  37. package/dist/catalog-network-source.js +47 -0
  38. package/dist/catalog-network-source.js.map +7 -0
  39. package/dist/catalog-validator.d.ts +18 -0
  40. package/dist/catalog-validator.d.ts.map +1 -0
  41. package/dist/catalog-validator.js +7747 -0
  42. package/dist/catalog-validator.js.map +7 -0
  43. package/dist/cmaf-block-assembler.d.ts +285 -0
  44. package/dist/cmaf-block-assembler.d.ts.map +1 -0
  45. package/dist/cmaf-block-assembler.js +1966 -0
  46. package/dist/cmaf-block-assembler.js.map +7 -0
  47. package/dist/cmaf-group-batcher.d.ts +38 -0
  48. package/dist/cmaf-group-batcher.d.ts.map +1 -0
  49. package/dist/cmaf-group-batcher.js +176 -0
  50. package/dist/cmaf-group-batcher.js.map +7 -0
  51. package/dist/cmcd-producer.d.ts +104 -0
  52. package/dist/cmcd-producer.d.ts.map +1 -0
  53. package/dist/cmcd-producer.js +183 -0
  54. package/dist/cmcd-producer.js.map +7 -0
  55. package/dist/codec-utils.d.ts +384 -0
  56. package/dist/codec-utils.d.ts.map +1 -0
  57. package/dist/codec-utils.js +1546 -0
  58. package/dist/codec-utils.js.map +7 -0
  59. package/dist/conceal-timeline.d.ts +146 -0
  60. package/dist/conceal-timeline.d.ts.map +1 -0
  61. package/dist/conceal-timeline.js +137 -0
  62. package/dist/conceal-timeline.js.map +7 -0
  63. package/dist/delivery-gap.d.ts +75 -0
  64. package/dist/delivery-gap.d.ts.map +1 -0
  65. package/dist/delivery-gap.js +88 -0
  66. package/dist/delivery-gap.js.map +7 -0
  67. package/dist/duplicate-ledger.d.ts +197 -0
  68. package/dist/duplicate-ledger.d.ts.map +1 -0
  69. package/dist/duplicate-ledger.js +226 -0
  70. package/dist/duplicate-ledger.js.map +7 -0
  71. package/dist/fec-codec.d.ts +32 -0
  72. package/dist/fec-codec.d.ts.map +1 -0
  73. package/dist/fec-codec.js +47 -0
  74. package/dist/fec-codec.js.map +7 -0
  75. package/dist/fec-manager.d.ts +583 -0
  76. package/dist/fec-manager.d.ts.map +1 -0
  77. package/dist/fec-manager.js +3899 -0
  78. package/dist/fec-manager.js.map +7 -0
  79. package/dist/fec-starvation-detector.d.ts +59 -0
  80. package/dist/fec-starvation-detector.d.ts.map +1 -0
  81. package/dist/fec-starvation-detector.js +60 -0
  82. package/dist/fec-starvation-detector.js.map +7 -0
  83. package/dist/fec-state.d.ts +131 -0
  84. package/dist/fec-state.d.ts.map +1 -0
  85. package/dist/fec-state.js +87 -0
  86. package/dist/fec-state.js.map +7 -0
  87. package/dist/fec-worker-setup.d.ts +94 -0
  88. package/dist/fec-worker-setup.d.ts.map +1 -0
  89. package/dist/fec-worker-setup.js +673 -0
  90. package/dist/fec-worker-setup.js.map +7 -0
  91. package/dist/fmp4-completion.d.ts +30 -0
  92. package/dist/fmp4-completion.d.ts.map +1 -0
  93. package/dist/fmp4-completion.js +21 -0
  94. package/dist/fmp4-completion.js.map +7 -0
  95. package/dist/fmp4-reader.d.ts +37 -0
  96. package/dist/fmp4-reader.d.ts.map +1 -0
  97. package/dist/fmp4-reader.js +100 -0
  98. package/dist/fmp4-reader.js.map +7 -0
  99. package/dist/index.d.ts +44 -3
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +460 -14
  102. package/dist/index.js.map +7 -1
  103. package/dist/iso-block-locator.d.ts +118 -0
  104. package/dist/iso-block-locator.d.ts.map +1 -0
  105. package/dist/iso-block-locator.js +289 -0
  106. package/dist/iso-block-locator.js.map +7 -0
  107. package/dist/iso-bmff-timing.d.ts +78 -0
  108. package/dist/iso-bmff-timing.d.ts.map +1 -0
  109. package/dist/iso-bmff-timing.js +593 -0
  110. package/dist/iso-bmff-timing.js.map +7 -0
  111. package/dist/loc.d.ts +70 -75
  112. package/dist/loc.d.ts.map +1 -1
  113. package/dist/loc.js +106 -192
  114. package/dist/loc.js.map +7 -1
  115. package/dist/manifest-auth-plan.d.ts +30 -0
  116. package/dist/manifest-auth-plan.d.ts.map +1 -0
  117. package/dist/manifest-auth-plan.js +1266 -0
  118. package/dist/manifest-auth-plan.js.map +7 -0
  119. package/dist/media-router.d.ts +262 -0
  120. package/dist/media-router.d.ts.map +1 -0
  121. package/dist/media-router.js +584 -0
  122. package/dist/media-router.js.map +7 -0
  123. package/dist/mfu-reassembler.d.ts +313 -9
  124. package/dist/mfu-reassembler.d.ts.map +1 -1
  125. package/dist/mfu-reassembler.js +3051 -285
  126. package/dist/mfu-reassembler.js.map +7 -1
  127. package/dist/mfu-reassembly-policy.d.ts +24 -0
  128. package/dist/mfu-reassembly-policy.d.ts.map +1 -0
  129. package/dist/mfu-reassembly-policy.js +99 -0
  130. package/dist/mfu-reassembly-policy.js.map +7 -0
  131. package/dist/mmtp-container-parser.d.ts +568 -0
  132. package/dist/mmtp-container-parser.d.ts.map +1 -0
  133. package/dist/mmtp-container-parser.js +6580 -0
  134. package/dist/mmtp-container-parser.js.map +7 -0
  135. package/dist/mmtp-container-parser.no-modules.js +9616 -0
  136. package/dist/mmtp-container-parser.no-modules.js.map +7 -0
  137. package/dist/mmtp-decode-pipeline.d.ts +138 -0
  138. package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
  139. package/dist/mmtp-decode-pipeline.js +6814 -0
  140. package/dist/mmtp-decode-pipeline.js.map +7 -0
  141. package/dist/mmtp-router.d.ts +679 -0
  142. package/dist/mmtp-router.d.ts.map +1 -0
  143. package/dist/mmtp-router.js +11278 -0
  144. package/dist/mmtp-router.js.map +7 -0
  145. package/dist/mmtp-to-cmaf.d.ts +187 -0
  146. package/dist/mmtp-to-cmaf.d.ts.map +1 -0
  147. package/dist/mmtp-to-cmaf.js +716 -0
  148. package/dist/mmtp-to-cmaf.js.map +7 -0
  149. package/dist/multicast-auth-catalog.d.ts +115 -0
  150. package/dist/multicast-auth-catalog.d.ts.map +1 -0
  151. package/dist/multicast-auth-catalog.js +202 -0
  152. package/dist/multicast-auth-catalog.js.map +7 -0
  153. package/dist/multicast-input.d.ts +141 -0
  154. package/dist/multicast-input.d.ts.map +1 -0
  155. package/dist/multicast-input.js +390 -0
  156. package/dist/multicast-input.js.map +7 -0
  157. package/dist/multicast-manager.d.ts +669 -0
  158. package/dist/multicast-manager.d.ts.map +1 -0
  159. package/dist/multicast-manager.js +19101 -0
  160. package/dist/multicast-manager.js.map +7 -0
  161. package/dist/multicast-transport.d.ts +271 -0
  162. package/dist/multicast-transport.d.ts.map +1 -0
  163. package/dist/multicast-transport.js +2264 -0
  164. package/dist/multicast-transport.js.map +7 -0
  165. package/dist/multicast-unwrap.d.ts +57 -0
  166. package/dist/multicast-unwrap.d.ts.map +1 -0
  167. package/dist/multicast-unwrap.js +418 -0
  168. package/dist/multicast-unwrap.js.map +7 -0
  169. package/dist/no-modules.d.ts +10 -0
  170. package/dist/no-modules.d.ts.map +1 -0
  171. package/dist/no-modules.js +9491 -0
  172. package/dist/no-modules.js.map +7 -0
  173. package/dist/phase14-catalog-override.d.ts +126 -0
  174. package/dist/phase14-catalog-override.d.ts.map +1 -0
  175. package/dist/phase14-catalog-override.js +155 -0
  176. package/dist/phase14-catalog-override.js.map +7 -0
  177. package/dist/repair-fetch.d.ts +270 -0
  178. package/dist/repair-fetch.d.ts.map +1 -0
  179. package/dist/repair-fetch.js +381 -0
  180. package/dist/repair-fetch.js.map +7 -0
  181. package/dist/repair-layers.d.ts +158 -0
  182. package/dist/repair-layers.d.ts.map +1 -0
  183. package/dist/repair-layers.js +344 -0
  184. package/dist/repair-layers.js.map +7 -0
  185. package/dist/sample-combiner.d.ts +212 -0
  186. package/dist/sample-combiner.d.ts.map +1 -0
  187. package/dist/sample-combiner.js +595 -0
  188. package/dist/sample-combiner.js.map +7 -0
  189. package/dist/signaling.d.ts +29 -0
  190. package/dist/signaling.d.ts.map +1 -0
  191. package/dist/signaling.js +572 -0
  192. package/dist/signaling.js.map +7 -0
  193. package/dist/source-auth.d.ts +2 -0
  194. package/dist/source-auth.d.ts.map +1 -0
  195. package/dist/source-auth.js +1209 -0
  196. package/dist/source-auth.js.map +7 -0
  197. package/dist/switching-set-alignment.d.ts +61 -0
  198. package/dist/switching-set-alignment.d.ts.map +1 -0
  199. package/dist/switching-set-alignment.js +70 -0
  200. package/dist/switching-set-alignment.js.map +7 -0
  201. package/dist/timestamp-codec.d.ts +34 -0
  202. package/dist/timestamp-codec.d.ts.map +1 -0
  203. package/dist/timestamp-codec.js +473 -0
  204. package/dist/timestamp-codec.js.map +7 -0
  205. package/dist/track-pipeline-setup.d.ts +83 -0
  206. package/dist/track-pipeline-setup.d.ts.map +1 -0
  207. package/dist/track-pipeline-setup.js +291 -0
  208. package/dist/track-pipeline-setup.js.map +7 -0
  209. package/dist/track-pipeline.d.ts +121 -0
  210. package/dist/track-pipeline.d.ts.map +1 -0
  211. package/dist/track-pipeline.js +209 -0
  212. package/dist/track-pipeline.js.map +7 -0
  213. package/dist/track-session.d.ts +414 -0
  214. package/dist/track-session.d.ts.map +1 -0
  215. package/dist/track-session.js +754 -0
  216. package/dist/track-session.js.map +7 -0
  217. package/dist/transport-pool.d.ts +69 -0
  218. package/dist/transport-pool.d.ts.map +1 -0
  219. package/dist/transport-pool.js +74 -0
  220. package/dist/transport-pool.js.map +7 -0
  221. package/dist/wasm-mfu-reassembler.d.ts +97 -0
  222. package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
  223. package/dist/wasm-mfu-reassembler.js +2133 -0
  224. package/dist/wasm-mfu-reassembler.js.map +7 -0
  225. package/dist/wasm-mmtp-container-parser.d.ts +10 -0
  226. package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
  227. package/dist/wasm-mmtp-container-parser.js +6834 -0
  228. package/dist/wasm-mmtp-container-parser.js.map +7 -0
  229. package/node_modules/@blockcast/fec-worker/README.md +223 -0
  230. package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
  231. package/node_modules/@blockcast/fec-worker/dist/block-order.d.ts +38 -0
  232. package/node_modules/@blockcast/fec-worker/dist/block-order.d.ts.map +1 -0
  233. package/node_modules/@blockcast/fec-worker/dist/block-order.js +78 -0
  234. package/node_modules/@blockcast/fec-worker/dist/block-order.js.map +1 -0
  235. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +93 -0
  236. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
  237. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +346 -0
  238. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
  239. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +380 -0
  240. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
  241. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
  242. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
  243. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
  244. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
  245. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +859 -0
  246. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
  247. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
  248. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
  249. package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
  250. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
  251. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
  252. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
  253. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +370 -0
  254. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
  255. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
  256. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
  257. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
  258. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
  259. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +194 -0
  260. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
  261. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +62 -0
  262. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
  263. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
  264. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
  265. package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
  266. package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
  267. package/node_modules/@blockcast/fec-worker/package.json +59 -0
  268. package/node_modules/@blockcast/fec-worker/src/block-order.ts +93 -0
  269. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +392 -0
  270. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +399 -0
  271. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1502 -0
  272. package/node_modules/@blockcast/fec-worker/src/index.ts +35 -0
  273. package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +589 -0
  274. package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
  275. package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +209 -0
  276. package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
  277. package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  278. package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  279. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  280. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  281. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  282. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  283. package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  284. package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  285. package/node_modules/@blockcast/mmt-base/README.md +134 -0
  286. package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  287. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts +55 -0
  288. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts.map +1 -0
  289. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js +128 -0
  290. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js.map +1 -0
  291. package/node_modules/@blockcast/mmt-base/dist/index.d.ts +7 -0
  292. package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  293. package/node_modules/@blockcast/mmt-base/dist/index.js +7 -0
  294. package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  295. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +292 -0
  296. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  297. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +612 -0
  298. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  299. package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts +18 -0
  300. package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts.map +1 -0
  301. package/node_modules/@blockcast/mmt-base/dist/net-constants.js +18 -0
  302. package/node_modules/@blockcast/mmt-base/dist/net-constants.js.map +1 -0
  303. package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts +47 -0
  304. package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts.map +1 -0
  305. package/node_modules/@blockcast/mmt-base/dist/ntp-short.js +54 -0
  306. package/node_modules/@blockcast/mmt-base/dist/ntp-short.js.map +1 -0
  307. package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts +57 -0
  308. package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts.map +1 -0
  309. package/node_modules/@blockcast/mmt-base/dist/serial-number.js +98 -0
  310. package/node_modules/@blockcast/mmt-base/dist/serial-number.js.map +1 -0
  311. package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts +312 -0
  312. package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts.map +1 -0
  313. package/node_modules/@blockcast/mmt-base/dist/signalling.js +637 -0
  314. package/node_modules/@blockcast/mmt-base/dist/signalling.js.map +1 -0
  315. package/node_modules/@blockcast/mmt-base/package.json +49 -0
  316. package/node_modules/@blockcast/mmt-base/src/fec-block-profile.ts +145 -0
  317. package/node_modules/@blockcast/mmt-base/src/index.ts +6 -0
  318. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +892 -0
  319. package/node_modules/@blockcast/mmt-base/src/net-constants.ts +17 -0
  320. package/node_modules/@blockcast/mmt-base/src/ntp-short.ts +67 -0
  321. package/node_modules/@blockcast/mmt-base/src/serial-number.ts +107 -0
  322. package/node_modules/@blockcast/mmt-base/src/signalling.ts +862 -0
  323. package/node_modules/@blockcast/mmt-fec/README.md +271 -0
  324. package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
  325. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +82 -0
  326. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
  327. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +296 -0
  328. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
  329. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +106 -0
  330. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
  331. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +288 -0
  332. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
  333. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
  334. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
  335. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
  336. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
  337. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
  338. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
  339. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
  340. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
  341. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +205 -0
  342. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
  343. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +240 -0
  344. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
  345. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +28 -0
  346. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
  347. package/node_modules/@blockcast/mmt-fec/dist/index.js +28 -0
  348. package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
  349. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
  350. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
  351. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
  352. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
  353. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +258 -0
  354. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
  355. package/node_modules/@blockcast/mmt-fec/dist/oti.js +382 -0
  356. package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
  357. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
  358. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
  359. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
  360. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
  361. package/node_modules/@blockcast/mmt-fec/dist/repair-group.d.ts +82 -0
  362. package/node_modules/@blockcast/mmt-fec/dist/repair-group.d.ts.map +1 -0
  363. package/node_modules/@blockcast/mmt-fec/dist/repair-group.js +170 -0
  364. package/node_modules/@blockcast/mmt-fec/dist/repair-group.js.map +1 -0
  365. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  366. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  367. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  368. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  369. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  370. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  371. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  372. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  373. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +134 -0
  374. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  375. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts +55 -0
  376. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts.map +1 -0
  377. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js +128 -0
  378. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js.map +1 -0
  379. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +7 -0
  380. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  381. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +7 -0
  382. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  383. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +292 -0
  384. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  385. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +612 -0
  386. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  387. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts +18 -0
  388. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts.map +1 -0
  389. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.js +18 -0
  390. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.js.map +1 -0
  391. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts +47 -0
  392. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts.map +1 -0
  393. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.js +54 -0
  394. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.js.map +1 -0
  395. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts +57 -0
  396. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts.map +1 -0
  397. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.js +98 -0
  398. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.js.map +1 -0
  399. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.d.ts +312 -0
  400. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.d.ts.map +1 -0
  401. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.js +637 -0
  402. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.js.map +1 -0
  403. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
  404. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/fec-block-profile.ts +145 -0
  405. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +6 -0
  406. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +892 -0
  407. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/net-constants.ts +17 -0
  408. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/ntp-short.ts +67 -0
  409. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/serial-number.ts +107 -0
  410. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/signalling.ts +862 -0
  411. package/node_modules/@blockcast/mmt-fec/package.json +79 -0
  412. package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +371 -0
  413. package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +439 -0
  414. package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
  415. package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
  416. package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +310 -0
  417. package/node_modules/@blockcast/mmt-fec/src/index.ts +94 -0
  418. package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
  419. package/node_modules/@blockcast/mmt-fec/src/oti.ts +463 -0
  420. package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
  421. package/node_modules/@blockcast/mmt-fec/src/repair-group.ts +195 -0
  422. package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
  423. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
  424. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
  425. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
  426. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
  427. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
  428. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
  429. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
  430. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
  431. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
  432. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
  433. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
  434. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
  435. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +99 -0
  436. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
  437. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +492 -0
  438. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
  439. package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
  440. package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
  441. package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
  442. package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
  443. package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +669 -0
  444. package/node_modules/@noble/hashes/LICENSE +21 -0
  445. package/node_modules/@noble/hashes/README.md +521 -0
  446. package/node_modules/@noble/hashes/_assert.d.ts +17 -0
  447. package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
  448. package/node_modules/@noble/hashes/_assert.js +18 -0
  449. package/node_modules/@noble/hashes/_assert.js.map +1 -0
  450. package/node_modules/@noble/hashes/_blake.d.ts +14 -0
  451. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  452. package/node_modules/@noble/hashes/_blake.js +50 -0
  453. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  454. package/node_modules/@noble/hashes/_md.d.ts +51 -0
  455. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  456. package/node_modules/@noble/hashes/_md.js +162 -0
  457. package/node_modules/@noble/hashes/_md.js.map +1 -0
  458. package/node_modules/@noble/hashes/_u64.d.ts +55 -0
  459. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  460. package/node_modules/@noble/hashes/_u64.js +90 -0
  461. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  462. package/node_modules/@noble/hashes/argon2.d.ts +32 -0
  463. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  464. package/node_modules/@noble/hashes/argon2.js +401 -0
  465. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  466. package/node_modules/@noble/hashes/blake1.d.ts +106 -0
  467. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  468. package/node_modules/@noble/hashes/blake1.js +459 -0
  469. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  470. package/node_modules/@noble/hashes/blake2.d.ts +116 -0
  471. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  472. package/node_modules/@noble/hashes/blake2.js +420 -0
  473. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  474. package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
  475. package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
  476. package/node_modules/@noble/hashes/blake2b.js +14 -0
  477. package/node_modules/@noble/hashes/blake2b.js.map +1 -0
  478. package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
  479. package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
  480. package/node_modules/@noble/hashes/blake2s.js +24 -0
  481. package/node_modules/@noble/hashes/blake2s.js.map +1 -0
  482. package/node_modules/@noble/hashes/blake3.d.ts +54 -0
  483. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  484. package/node_modules/@noble/hashes/blake3.js +255 -0
  485. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  486. package/node_modules/@noble/hashes/crypto.d.ts +2 -0
  487. package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
  488. package/node_modules/@noble/hashes/crypto.js +5 -0
  489. package/node_modules/@noble/hashes/crypto.js.map +1 -0
  490. package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
  491. package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
  492. package/node_modules/@noble/hashes/cryptoNode.js +18 -0
  493. package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
  494. package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
  495. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  496. package/node_modules/@noble/hashes/eskdf.js +166 -0
  497. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  498. package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
  499. package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
  500. package/node_modules/@noble/hashes/esm/_assert.js +15 -0
  501. package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
  502. package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
  503. package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
  504. package/node_modules/@noble/hashes/esm/_blake.js +45 -0
  505. package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
  506. package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
  507. package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
  508. package/node_modules/@noble/hashes/esm/_md.js +155 -0
  509. package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  510. package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
  511. package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
  512. package/node_modules/@noble/hashes/esm/_u64.js +67 -0
  513. package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  514. package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
  515. package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
  516. package/node_modules/@noble/hashes/esm/argon2.js +392 -0
  517. package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
  518. package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
  519. package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
  520. package/node_modules/@noble/hashes/esm/blake1.js +452 -0
  521. package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
  522. package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
  523. package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
  524. package/node_modules/@noble/hashes/esm/blake2.js +413 -0
  525. package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
  526. package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
  527. package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
  528. package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
  529. package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
  530. package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
  531. package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
  532. package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
  533. package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
  534. package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
  535. package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
  536. package/node_modules/@noble/hashes/esm/blake3.js +251 -0
  537. package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
  538. package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
  539. package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
  540. package/node_modules/@noble/hashes/esm/crypto.js +2 -0
  541. package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
  542. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
  543. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
  544. package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
  545. package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
  546. package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
  547. package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
  548. package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
  549. package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
  550. package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
  551. package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
  552. package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
  553. package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
  554. package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
  555. package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
  556. package/node_modules/@noble/hashes/esm/hmac.js +86 -0
  557. package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
  558. package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
  559. package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
  560. package/node_modules/@noble/hashes/esm/index.js +33 -0
  561. package/node_modules/@noble/hashes/esm/index.js.map +1 -0
  562. package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
  563. package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
  564. package/node_modules/@noble/hashes/esm/legacy.js +281 -0
  565. package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  566. package/node_modules/@noble/hashes/esm/package.json +10 -0
  567. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
  568. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
  569. package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
  570. package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
  571. package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
  572. package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
  573. package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
  574. package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
  575. package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
  576. package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
  577. package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
  578. package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
  579. package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
  580. package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
  581. package/node_modules/@noble/hashes/esm/sha1.js +11 -0
  582. package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
  583. package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
  584. package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
  585. package/node_modules/@noble/hashes/esm/sha2.js +375 -0
  586. package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  587. package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
  588. package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
  589. package/node_modules/@noble/hashes/esm/sha256.js +20 -0
  590. package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
  591. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
  592. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
  593. package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
  594. package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
  595. package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
  596. package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
  597. package/node_modules/@noble/hashes/esm/sha3.js +234 -0
  598. package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
  599. package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
  600. package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
  601. package/node_modules/@noble/hashes/esm/sha512.js +26 -0
  602. package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
  603. package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
  604. package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
  605. package/node_modules/@noble/hashes/esm/utils.js +281 -0
  606. package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  607. package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
  608. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  609. package/node_modules/@noble/hashes/hkdf.js +88 -0
  610. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  611. package/node_modules/@noble/hashes/hmac.d.ts +35 -0
  612. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  613. package/node_modules/@noble/hashes/hmac.js +91 -0
  614. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  615. package/node_modules/@noble/hashes/index.d.ts +1 -0
  616. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  617. package/node_modules/@noble/hashes/index.js +33 -0
  618. package/node_modules/@noble/hashes/index.js.map +1 -0
  619. package/node_modules/@noble/hashes/legacy.d.ts +71 -0
  620. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  621. package/node_modules/@noble/hashes/legacy.js +287 -0
  622. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  623. package/node_modules/@noble/hashes/package.json +266 -0
  624. package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
  625. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  626. package/node_modules/@noble/hashes/pbkdf2.js +101 -0
  627. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  628. package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
  629. package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
  630. package/node_modules/@noble/hashes/ripemd160.js +16 -0
  631. package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
  632. package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
  633. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  634. package/node_modules/@noble/hashes/scrypt.js +232 -0
  635. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  636. package/node_modules/@noble/hashes/sha1.d.ts +11 -0
  637. package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
  638. package/node_modules/@noble/hashes/sha1.js +14 -0
  639. package/node_modules/@noble/hashes/sha1.js.map +1 -0
  640. package/node_modules/@noble/hashes/sha2.d.ts +159 -0
  641. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  642. package/node_modules/@noble/hashes/sha2.js +384 -0
  643. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  644. package/node_modules/@noble/hashes/sha256.d.ts +20 -0
  645. package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
  646. package/node_modules/@noble/hashes/sha256.js +23 -0
  647. package/node_modules/@noble/hashes/sha256.js.map +1 -0
  648. package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
  649. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  650. package/node_modules/@noble/hashes/sha3-addons.js +402 -0
  651. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  652. package/node_modules/@noble/hashes/sha3.d.ts +53 -0
  653. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  654. package/node_modules/@noble/hashes/sha3.js +239 -0
  655. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  656. package/node_modules/@noble/hashes/sha512.d.ts +26 -0
  657. package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
  658. package/node_modules/@noble/hashes/sha512.js +29 -0
  659. package/node_modules/@noble/hashes/sha512.js.map +1 -0
  660. package/node_modules/@noble/hashes/src/_assert.ts +22 -0
  661. package/node_modules/@noble/hashes/src/_blake.ts +50 -0
  662. package/node_modules/@noble/hashes/src/_md.ts +176 -0
  663. package/node_modules/@noble/hashes/src/_u64.ts +91 -0
  664. package/node_modules/@noble/hashes/src/argon2.ts +497 -0
  665. package/node_modules/@noble/hashes/src/blake1.ts +534 -0
  666. package/node_modules/@noble/hashes/src/blake2.ts +486 -0
  667. package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
  668. package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
  669. package/node_modules/@noble/hashes/src/blake3.ts +272 -0
  670. package/node_modules/@noble/hashes/src/crypto.ts +9 -0
  671. package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
  672. package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
  673. package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
  674. package/node_modules/@noble/hashes/src/hmac.ts +94 -0
  675. package/node_modules/@noble/hashes/src/index.ts +31 -0
  676. package/node_modules/@noble/hashes/src/legacy.ts +293 -0
  677. package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
  678. package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
  679. package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
  680. package/node_modules/@noble/hashes/src/sha1.ts +10 -0
  681. package/node_modules/@noble/hashes/src/sha2.ts +402 -0
  682. package/node_modules/@noble/hashes/src/sha256.ts +24 -0
  683. package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
  684. package/node_modules/@noble/hashes/src/sha3.ts +258 -0
  685. package/node_modules/@noble/hashes/src/sha512.ts +34 -0
  686. package/node_modules/@noble/hashes/src/utils.ts +395 -0
  687. package/node_modules/@noble/hashes/utils.d.ts +161 -0
  688. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  689. package/node_modules/@noble/hashes/utils.js +313 -0
  690. package/node_modules/@noble/hashes/utils.js.map +1 -0
  691. package/package.json +179 -8
  692. package/schemas/catalog.schema.json +357 -0
  693. package/src/align.ts +239 -0
  694. package/src/audio-init-parser.ts +189 -0
  695. package/src/audio-ring-buffer.ts +120 -0
  696. package/src/authored-timing.ts +63 -0
  697. package/src/block-policy.ts +903 -0
  698. package/src/carp-catalog.ts +1065 -0
  699. package/src/catalog-fec-params.ts +729 -0
  700. package/src/catalog-network-source.ts +74 -0
  701. package/src/catalog-validator.ts +34 -0
  702. package/src/cmaf-block-assembler.ts +1255 -0
  703. package/src/cmaf-group-batcher.ts +104 -0
  704. package/src/cmcd-producer.ts +329 -0
  705. package/src/codec-utils.ts +1984 -0
  706. package/src/conceal-timeline.ts +293 -0
  707. package/src/delivery-gap.ts +147 -0
  708. package/src/duplicate-ledger.ts +372 -0
  709. package/src/fec-codec.ts +61 -0
  710. package/src/fec-manager.ts +4298 -0
  711. package/src/fec-starvation-detector.ts +128 -0
  712. package/src/fec-state.ts +219 -0
  713. package/src/fec-worker-setup.ts +283 -0
  714. package/src/fmp4-completion.ts +47 -0
  715. package/src/fmp4-reader.ts +112 -0
  716. package/src/index.ts +590 -21
  717. package/src/iso-block-locator.ts +329 -0
  718. package/src/iso-bmff-timing.ts +813 -0
  719. package/src/loc.ts +128 -154
  720. package/src/manifest-auth-plan.ts +107 -0
  721. package/src/media-router.ts +841 -0
  722. package/src/mfu-reassembler.ts +3480 -155
  723. package/src/mfu-reassembly-policy.ts +134 -0
  724. package/src/mmtp-container-parser.ts +2380 -0
  725. package/src/mmtp-decode-pipeline.ts +406 -0
  726. package/src/mmtp-router.ts +4860 -0
  727. package/src/mmtp-to-cmaf.ts +977 -0
  728. package/src/multicast-auth-catalog.ts +340 -0
  729. package/src/multicast-input.ts +793 -0
  730. package/src/multicast-manager.ts +2783 -0
  731. package/src/multicast-transport.ts +1058 -0
  732. package/src/multicast-unwrap.ts +132 -0
  733. package/src/no-modules.ts +21 -0
  734. package/src/phase14-catalog-override.ts +336 -0
  735. package/src/repair-fetch.ts +772 -0
  736. package/src/repair-layers.ts +533 -0
  737. package/src/sample-combiner.ts +938 -0
  738. package/src/signaling.ts +78 -0
  739. package/src/source-auth.ts +1 -0
  740. package/src/switching-set-alignment.ts +109 -0
  741. package/src/timestamp-codec.ts +265 -0
  742. package/src/track-pipeline-setup.ts +205 -0
  743. package/src/track-pipeline.ts +332 -0
  744. package/src/track-session.ts +1010 -0
  745. package/src/transport-pool.ts +128 -0
  746. package/src/wasm-mfu-reassembler.ts +405 -0
  747. package/src/wasm-mmtp-container-parser.ts +23 -0
  748. package/test-vectors/align.json +199 -0
  749. package/test-vectors/catalog/README.md +106 -0
  750. package/test-vectors/catalog/negative/archive-origin-with-path.json +33 -0
  751. package/test-vectors/catalog/negative/archive-unknown-field.json +34 -0
  752. package/test-vectors/catalog/negative/fec-block-profile-missing.json +51 -0
  753. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +52 -0
  754. package/test-vectors/catalog/negative/fec-enhancement-repair-removed.json +28 -0
  755. package/test-vectors/catalog/negative/fec-repair-layer-geometry.json +33 -0
  756. package/test-vectors/catalog/negative/fec-repair-layer-missing-symbols.json +31 -0
  757. package/test-vectors/catalog/negative/fec-repair-multiple-depends.json +32 -0
  758. package/test-vectors/catalog/negative/fec-repair-overlay-with-layer.json +34 -0
  759. package/test-vectors/catalog/negative/fec-repair-priority-out-of-band.json +24 -0
  760. package/test-vectors/catalog/negative/fec-repair-source-symbols-without-scope.json +33 -0
  761. package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
  762. package/test-vectors/catalog/negative/media-track-repair-layer.json +16 -0
  763. package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
  764. package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
  765. package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
  766. package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
  767. package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
  768. package/test-vectors/catalog/negative/multicast-network-source-empty.json +44 -0
  769. package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
  770. package/test-vectors/catalog/negative/network-source-object.json +25 -0
  771. package/test-vectors/catalog/negative/raptorq-source-symbols-over-max.json +24 -0
  772. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +27 -0
  773. package/test-vectors/catalog/negative/repair-track-legacy-shape.json +19 -0
  774. package/test-vectors/catalog/negative/track-role-empty.json +16 -0
  775. package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
  776. package/test-vectors/catalog/positive/archive-origin.json +34 -0
  777. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +52 -0
  778. package/test-vectors/catalog/positive/fec-layered-repair.json +106 -0
  779. package/test-vectors/catalog/positive/fec-multicast.json +52 -0
  780. package/test-vectors/catalog/positive/flat-av.json +30 -0
  781. package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
  782. package/test-vectors/catalog/positive/multicast-native-ssm-no-network-source.json +43 -0
  783. package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
  784. package/test-vectors/catalog/positive/track-role.json +49 -0
  785. package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
  786. package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
  787. package/test-vectors/catalog-multicast-auth-v1.json +26 -0
  788. package/test-vectors/catalog-validation.json +732 -0
  789. package/test-vectors/catalog-validator-public-api.mjs +25 -0
  790. package/test-vectors/generate-source-auth-fixture.mjs +114 -0
  791. package/test-vectors/hevc-x265-repeat-headers-v1.json +40 -0
  792. package/test-vectors/source-auth-v1.json +61 -0
  793. package/test-vectors/source-contiguity-v1.json +131 -0
  794. package/test-vectors/subsample-placement-v1.json +230 -0
  795. package/dist/mmtp.d.ts +0 -73
  796. package/dist/mmtp.d.ts.map +0 -1
  797. package/dist/mmtp.js +0 -210
  798. package/dist/mmtp.js.map +0 -1
  799. package/src/mmtp.ts +0 -277
@@ -0,0 +1,1546 @@
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
+ for (const sampleEntry of ["hvc1", "hev1"]) {
23
+ const hvc = findBox(data, s, e, sampleEntry);
24
+ if (!hvc || hvc.sz < 86) continue;
25
+ const hvcC = findBox(data, hvc.o + 86, hvc.o + hvc.sz, "hvcC");
26
+ if (hvcC && hvcC.sz >= 8 + 23) {
27
+ const d = data.subarray(hvcC.o + 8, hvcC.o + hvcC.sz);
28
+ return { codec: hevcCodecStringFromHvcC(d, sampleEntry), description: d };
29
+ }
30
+ }
31
+ const av01 = findBox(data, s, e, "av01");
32
+ if (av01 && av01.sz >= 86) {
33
+ const av1C = findBox(data, av01.o + 86, av01.o + av01.sz, "av1C");
34
+ if (av1C && av1C.sz >= 8) {
35
+ const d = data.subarray(av1C.o + 8, av1C.o + av1C.sz);
36
+ return { codec: codecStringFromAv1C(d), description: d };
37
+ }
38
+ }
39
+ const vp09 = findBox(data, s, e, "vp09");
40
+ if (vp09 && vp09.sz >= 86) {
41
+ const vpcC = findBox(data, vp09.o + 86, vp09.o + vp09.sz, "vpcC");
42
+ if (vpcC && vpcC.sz >= 8) {
43
+ const d = data.subarray(vpcC.o + 8, vpcC.o + vpcC.sz);
44
+ return { codec: codecStringFromVpcC(d), description: d };
45
+ }
46
+ }
47
+ return void 0;
48
+ }
49
+ function generateFallbackAvcC(options) {
50
+ const opts = typeof options === "string" ? { codec: options } : options ?? {};
51
+ let profile = 100;
52
+ let constraint = 0;
53
+ let level = 42;
54
+ if (opts.codec) {
55
+ const match = opts.codec.match(/^avc[13]\.([0-9a-fA-F]{6})$/);
56
+ if (match) {
57
+ profile = Number.parseInt(match[1].substring(0, 2), 16);
58
+ constraint = Number.parseInt(match[1].substring(2, 4), 16);
59
+ level = Number.parseInt(match[1].substring(4, 6), 16);
60
+ }
61
+ }
62
+ const { width, height } = resolveResolution(opts.width, opts.height, level);
63
+ const sps = buildMinimalSps(profile, constraint, level, width, height);
64
+ const pps = buildMinimalPps(profile);
65
+ const avcC = new Uint8Array(5 + 1 + 2 + sps.length + 1 + 2 + pps.length);
66
+ let w = 0;
67
+ avcC[w++] = 1;
68
+ avcC[w++] = profile;
69
+ avcC[w++] = constraint;
70
+ avcC[w++] = level;
71
+ avcC[w++] = 255;
72
+ avcC[w++] = 225;
73
+ avcC[w++] = sps.length >> 8 & 255;
74
+ avcC[w++] = sps.length & 255;
75
+ avcC.set(sps, w);
76
+ w += sps.length;
77
+ avcC[w++] = 1;
78
+ avcC[w++] = pps.length >> 8 & 255;
79
+ avcC[w++] = pps.length & 255;
80
+ avcC.set(pps, w);
81
+ return avcC;
82
+ }
83
+ function extractSpsPpsFromAvcC(avcC) {
84
+ if (avcC.length < 8) return void 0;
85
+ const numSPS = avcC[5] & 31;
86
+ let offset = 6;
87
+ let sps;
88
+ for (let i = 0; i < numSPS && offset + 2 <= avcC.length; i++) {
89
+ const spsLen = avcC[offset] << 8 | avcC[offset + 1];
90
+ offset += 2;
91
+ if (offset + spsLen <= avcC.length) {
92
+ if (!sps) sps = avcC.subarray(offset, offset + spsLen);
93
+ offset += spsLen;
94
+ }
95
+ }
96
+ let pps;
97
+ if (offset < avcC.length) {
98
+ const numPPS = avcC[offset] & 31;
99
+ offset++;
100
+ for (let i = 0; i < numPPS && offset + 2 <= avcC.length; i++) {
101
+ const ppsLen = avcC[offset] << 8 | avcC[offset + 1];
102
+ offset += 2;
103
+ if (offset + ppsLen <= avcC.length) {
104
+ if (!pps) pps = avcC.subarray(offset, offset + ppsLen);
105
+ offset += ppsLen;
106
+ }
107
+ }
108
+ }
109
+ return sps && pps ? { sps, pps } : void 0;
110
+ }
111
+ function avccToAnnexB(avccData, isKeyframe, spsPps) {
112
+ let offset = 0;
113
+ let totalNalSize = 0;
114
+ let nalCount = 0;
115
+ while (offset + 4 <= avccData.length) {
116
+ const nalLen = avccData[offset] << 24 | avccData[offset + 1] << 16 | avccData[offset + 2] << 8 | avccData[offset + 3];
117
+ offset += 4;
118
+ if (nalLen <= 0 || offset + nalLen > avccData.length) break;
119
+ totalNalSize += nalLen;
120
+ nalCount++;
121
+ offset += nalLen;
122
+ }
123
+ if (nalCount === 0) return avccData;
124
+ let outSize = nalCount * 4 + totalNalSize;
125
+ if (isKeyframe) {
126
+ outSize += 4 + spsPps.sps.length + 4 + spsPps.pps.length;
127
+ }
128
+ const out = new Uint8Array(outSize);
129
+ let w = 0;
130
+ if (isKeyframe) {
131
+ out[w++] = 0;
132
+ out[w++] = 0;
133
+ out[w++] = 0;
134
+ out[w++] = 1;
135
+ out.set(spsPps.sps, w);
136
+ w += spsPps.sps.length;
137
+ out[w++] = 0;
138
+ out[w++] = 0;
139
+ out[w++] = 0;
140
+ out[w++] = 1;
141
+ out.set(spsPps.pps, w);
142
+ w += spsPps.pps.length;
143
+ }
144
+ offset = 0;
145
+ while (offset + 4 <= avccData.length) {
146
+ const nalLen = avccData[offset] << 24 | avccData[offset + 1] << 16 | avccData[offset + 2] << 8 | avccData[offset + 3];
147
+ offset += 4;
148
+ if (nalLen <= 0 || offset + nalLen > avccData.length) break;
149
+ out[w++] = 0;
150
+ out[w++] = 0;
151
+ out[w++] = 0;
152
+ out[w++] = 1;
153
+ out.set(avccData.subarray(offset, offset + nalLen), w);
154
+ w += nalLen;
155
+ offset += nalLen;
156
+ }
157
+ return out;
158
+ }
159
+ function extractCodecDescriptionFromAnnexB(data) {
160
+ const nalUnits = [];
161
+ let i = 0;
162
+ while (i < data.length - 4) {
163
+ if (data[i] === 0 && data[i + 1] === 0) {
164
+ let nalStart = 0;
165
+ if (data[i + 2] === 1) {
166
+ nalStart = i + 3;
167
+ } else if (data[i + 2] === 0 && data[i + 3] === 1) {
168
+ nalStart = i + 4;
169
+ }
170
+ if (nalStart > 0 && nalStart < data.length) {
171
+ let nalEnd = data.length;
172
+ for (let j = nalStart; j < data.length - 3; j++) {
173
+ if (data[j] === 0 && data[j + 1] === 0 && (data[j + 2] === 1 || data[j + 2] === 0 && data[j + 3] === 1)) {
174
+ nalEnd = j;
175
+ break;
176
+ }
177
+ }
178
+ const nalType = data[nalStart] & 31;
179
+ nalUnits.push({ type: nalType, data: data.slice(nalStart, nalEnd) });
180
+ i = nalEnd;
181
+ continue;
182
+ }
183
+ }
184
+ i++;
185
+ }
186
+ const sps = nalUnits.find((n) => n.type === 7);
187
+ const pps = nalUnits.find((n) => n.type === 8);
188
+ if (!sps || !pps) return null;
189
+ const avcCLength = 6 + 2 + sps.data.length + 1 + 2 + pps.data.length;
190
+ const avcC = new Uint8Array(avcCLength);
191
+ let offset = 0;
192
+ avcC[offset++] = 1;
193
+ avcC[offset++] = sps.data[1];
194
+ avcC[offset++] = sps.data[2];
195
+ avcC[offset++] = sps.data[3];
196
+ avcC[offset++] = 255;
197
+ avcC[offset++] = 225;
198
+ avcC[offset++] = sps.data.length >> 8 & 255;
199
+ avcC[offset++] = sps.data.length & 255;
200
+ avcC.set(sps.data, offset);
201
+ offset += sps.data.length;
202
+ avcC[offset++] = 1;
203
+ avcC[offset++] = pps.data.length >> 8 & 255;
204
+ avcC[offset++] = pps.data.length & 255;
205
+ avcC.set(pps.data, offset);
206
+ return avcC;
207
+ }
208
+ function codecStringFromAvcC(avcC) {
209
+ if (avcC.length < 4) return "avc1.640033";
210
+ return `avc1.${hex2(avcC[1])}${hex2(avcC[2])}${hex2(avcC[3])}`;
211
+ }
212
+ function isHevcCodec(codec) {
213
+ return codec.startsWith("hev1") || codec.startsWith("hvc1");
214
+ }
215
+ function videoSampleEntryFromCodecString(codec) {
216
+ const fourCc = codec.split(".")[0];
217
+ if (fourCc === "avc1" || fourCc === "avc3" || fourCc === "hev1" || fourCc === "hvc1") return fourCc;
218
+ throw new Error(`Unsupported video codec family in codec string ${JSON.stringify(codec)}`);
219
+ }
220
+ function videoCodecFamily(sampleEntry) {
221
+ return sampleEntry === "avc1" || sampleEntry === "avc3" ? "avc" : "hevc";
222
+ }
223
+ var HEVC_NAL_UNIT_TYPE = {
224
+ TRAIL_R: 1,
225
+ /** First IRAP type. */
226
+ BLA_W_LP: 16,
227
+ IDR_W_RADL: 19,
228
+ IDR_N_LP: 20,
229
+ CRA_NUT: 21,
230
+ /** Last IRAP type (reserved IRAP VCL). */
231
+ RSV_IRAP_VCL23: 23,
232
+ /** Last VCL type; 32..=63 are non-VCL. */
233
+ LAST_VCL: 31,
234
+ VPS_NUT: 32,
235
+ SPS_NUT: 33,
236
+ PPS_NUT: 34,
237
+ AUD_NUT: 35,
238
+ PREFIX_SEI_NUT: 39,
239
+ SUFFIX_SEI_NUT: 40
240
+ };
241
+ var HEVC_NAL_HEADER_LENGTH = 2;
242
+ var HVCC_MAX_BIT_DEPTH_MINUS8 = 7;
243
+ function hevcNalUnitType(nal) {
244
+ return nal[0] >> 1 & 63;
245
+ }
246
+ function isHevcIrapNalUnitType(nalUnitType) {
247
+ return nalUnitType >= HEVC_NAL_UNIT_TYPE.BLA_W_LP && nalUnitType <= HEVC_NAL_UNIT_TYPE.RSV_IRAP_VCL23;
248
+ }
249
+ function hevcNalType(nal) {
250
+ return hevcNalUnitType(nal);
251
+ }
252
+ function removeEmulationPrevention(rbsp) {
253
+ const out = [];
254
+ let zeros = 0;
255
+ for (let i = 0; i < rbsp.length; i++) {
256
+ const b = rbsp[i];
257
+ if (zeros >= 2 && b === 3) {
258
+ zeros = 0;
259
+ continue;
260
+ }
261
+ out.push(b);
262
+ zeros = b === 0 ? zeros + 1 : 0;
263
+ }
264
+ return Uint8Array.from(out);
265
+ }
266
+ var RbspReader = class {
267
+ constructor(data) {
268
+ this.data = data;
269
+ }
270
+ #bit = 0;
271
+ bits(count) {
272
+ if (this.#bit + count > this.data.length * 8) throw new Error("HEVC SPS: RBSP truncated");
273
+ let value = 0;
274
+ for (let i = 0; i < count; i++, this.#bit++) {
275
+ value = value * 2 + (this.data[this.#bit >> 3] >> 7 - (this.#bit & 7) & 1);
276
+ }
277
+ return value;
278
+ }
279
+ skip(count) {
280
+ if (this.#bit + count > this.data.length * 8) throw new Error("HEVC SPS: RBSP truncated");
281
+ this.#bit += count;
282
+ }
283
+ ue() {
284
+ let leadingZeros = 0;
285
+ while (this.bits(1) === 0) {
286
+ if (++leadingZeros > 31) throw new Error("HEVC SPS: ue(v) exceeds 32 bits");
287
+ }
288
+ return leadingZeros === 0 ? 0 : 2 ** leadingZeros - 1 + this.bits(leadingZeros);
289
+ }
290
+ };
291
+ function parseHevcSps(sps) {
292
+ if (sps.length < HEVC_NAL_HEADER_LENGTH || (sps[0] & 128) !== 0 || (sps[1] & 7) === 0) {
293
+ throw new Error("HEVC SPS: invalid NAL unit header");
294
+ }
295
+ if (hevcNalUnitType(sps) !== HEVC_NAL_UNIT_TYPE.SPS_NUT) throw new Error("HEVC SPS: NAL unit is not an SPS");
296
+ if (((sps[0] & 1) << 5 | sps[1] >> 3) !== 0) {
297
+ throw new Error("HEVC SPS: not in the base layer (nuh_layer_id != 0)");
298
+ }
299
+ const r = new RbspReader(removeEmulationPrevention(sps).subarray(HEVC_NAL_HEADER_LENGTH));
300
+ r.bits(4);
301
+ const maxSubLayersMinus1 = r.bits(3);
302
+ if (maxSubLayersMinus1 > 6) throw new Error("HEVC SPS: sps_max_sub_layers_minus1 is greater than 6");
303
+ const temporalIdNestingFlag = r.bits(1) === 1;
304
+ const profileSpace = r.bits(2);
305
+ const tierFlag = r.bits(1) === 1;
306
+ const profileIdc = r.bits(5);
307
+ const profileCompatibilityFlags = r.bits(32) >>> 0;
308
+ const constraintIndicatorFlags = new Uint8Array(6);
309
+ for (let i = 0; i < 6; i++) constraintIndicatorFlags[i] = r.bits(8);
310
+ const levelIdc = r.bits(8);
311
+ const subLayerProfilePresent = [];
312
+ const subLayerLevelPresent = [];
313
+ for (let i = 0; i < maxSubLayersMinus1; i++) {
314
+ subLayerProfilePresent.push(r.bits(1) === 1);
315
+ subLayerLevelPresent.push(r.bits(1) === 1);
316
+ }
317
+ if (maxSubLayersMinus1 > 0) {
318
+ for (let i = maxSubLayersMinus1; i < 8; i++) r.skip(2);
319
+ }
320
+ for (let i = 0; i < maxSubLayersMinus1; i++) {
321
+ if (subLayerProfilePresent[i]) r.skip(88);
322
+ if (subLayerLevelPresent[i]) r.skip(8);
323
+ }
324
+ const seqParameterSetId = r.ue();
325
+ if (seqParameterSetId > 15) throw new Error("HEVC SPS: sps_seq_parameter_set_id is greater than 15");
326
+ const chromaFormatIdc = r.ue();
327
+ if (chromaFormatIdc > 3) throw new Error("HEVC SPS: chroma_format_idc is greater than 3");
328
+ if (chromaFormatIdc === 3) r.skip(1);
329
+ const picWidthInLumaSamples = r.ue();
330
+ const picHeightInLumaSamples = r.ue();
331
+ if (picWidthInLumaSamples === 0 || picHeightInLumaSamples === 0) {
332
+ throw new Error("HEVC SPS: picture dimension is zero");
333
+ }
334
+ if (r.bits(1) === 1) for (let i = 0; i < 4; i++) r.ue();
335
+ const bitDepthLumaMinus8 = r.ue();
336
+ const bitDepthChromaMinus8 = r.ue();
337
+ if (bitDepthLumaMinus8 > 8 || bitDepthChromaMinus8 > 8) throw new Error("HEVC SPS: bit depth is greater than 16");
338
+ return {
339
+ profileSpace,
340
+ tierFlag,
341
+ profileIdc,
342
+ profileCompatibilityFlags,
343
+ constraintIndicatorFlags,
344
+ levelIdc,
345
+ maxSubLayersMinus1,
346
+ temporalIdNestingFlag,
347
+ seqParameterSetId,
348
+ chromaFormatIdc,
349
+ picWidthInLumaSamples,
350
+ picHeightInLumaSamples,
351
+ bitDepthLumaMinus8,
352
+ bitDepthChromaMinus8
353
+ };
354
+ }
355
+ function hevcCodecStringFromSps(sps, sampleEntry) {
356
+ const info = parseHevcSps(sps);
357
+ return formatHevcCodecString(
358
+ sampleEntry,
359
+ info.profileSpace,
360
+ info.tierFlag,
361
+ info.profileIdc,
362
+ info.profileCompatibilityFlags,
363
+ info.constraintIndicatorFlags,
364
+ info.levelIdc
365
+ );
366
+ }
367
+ function formatHevcCodecString(sampleEntry, profileSpace, tierFlag, profileIdc, profileCompatibilityFlags, constraintIndicatorFlags, levelIdc) {
368
+ let reversed = 0;
369
+ let v = profileCompatibilityFlags >>> 0;
370
+ for (let i = 0; i < 32; i++) {
371
+ reversed = (reversed << 1 | v & 1) >>> 0;
372
+ v >>>= 1;
373
+ }
374
+ let lastNonZero = -1;
375
+ for (let i = 0; i < constraintIndicatorFlags.length; i++) if (constraintIndicatorFlags[i] !== 0) lastNonZero = i;
376
+ const space = profileSpace === 0 ? "" : String.fromCharCode(64 + profileSpace);
377
+ let codec = `${sampleEntry}.${space}${profileIdc}.${reversed.toString(16).toUpperCase()}.${tierFlag ? "H" : "L"}${levelIdc}`;
378
+ for (let i = 0; i <= lastNonZero; i++) codec += `.${constraintIndicatorFlags[i].toString(16).toUpperCase()}`;
379
+ return codec;
380
+ }
381
+ function splitHevcSample(data) {
382
+ if (isCompleteAvccSample(data)) return { nals: splitAvccNalUnits(data), lengthPrefixed: true };
383
+ if (isAnnexB(data)) return { nals: splitAnnexBNalUnits(data), lengthPrefixed: false };
384
+ return null;
385
+ }
386
+ function hevcNalUnitsContainIrap(nals) {
387
+ let sawNal = false;
388
+ for (const nal of nals) {
389
+ if (nal.length < HEVC_NAL_HEADER_LENGTH) continue;
390
+ sawNal = true;
391
+ if (isHevcIrapNalUnitType(hevcNalUnitType(nal))) return true;
392
+ }
393
+ return sawNal ? false : void 0;
394
+ }
395
+ function classifyHevcKeyframe(data) {
396
+ const split = splitHevcSample(data);
397
+ return split === null ? void 0 : hevcNalUnitsContainIrap(split.nals);
398
+ }
399
+ function detectHevcKeyframe(data) {
400
+ return classifyHevcKeyframe(data) === true;
401
+ }
402
+ function prepareHevcCmafSample(data, sampleEntry) {
403
+ const split = splitHevcSample(data);
404
+ if (split === null) return null;
405
+ const keyframe = hevcNalUnitsContainIrap(split.nals);
406
+ if (keyframe === void 0) return null;
407
+ const normalized = hevcNalUnitsToLengthPrefixed(data, split.nals, split.lengthPrefixed, sampleEntry);
408
+ return normalized === null ? null : { keyframe, data: normalized };
409
+ }
410
+ function normalizeHevcSampleToLengthPrefixed(data, sampleEntry) {
411
+ const prepared = prepareHevcCmafSample(data, sampleEntry);
412
+ if (prepared === null) {
413
+ throw new Error("HEVC sample is neither 4-byte length-prefixed nor Annex B, or holds no NAL unit to write");
414
+ }
415
+ return prepared.data;
416
+ }
417
+ function hevcNalUnitsToLengthPrefixed(data, nals, lengthPrefixed, sampleEntry) {
418
+ const kept = sampleEntry === "hvc1" ? nals.filter((nal) => {
419
+ const t = hevcNalUnitType(nal);
420
+ return t !== HEVC_NAL_UNIT_TYPE.VPS_NUT && t !== HEVC_NAL_UNIT_TYPE.SPS_NUT && t !== HEVC_NAL_UNIT_TYPE.PPS_NUT;
421
+ }) : nals;
422
+ if (kept.length === 0) return null;
423
+ if (lengthPrefixed && kept.length === nals.length) return data;
424
+ const out = new Uint8Array(kept.reduce((sum, nal) => sum + 4 + nal.length, 0));
425
+ let w = 0;
426
+ for (const nal of kept) {
427
+ w = writeNalLength(out, w, nal.length);
428
+ out.set(nal, w);
429
+ w += nal.length;
430
+ }
431
+ return out;
432
+ }
433
+ function splitAvccNalUnits(data, lengthSize = 4) {
434
+ const nals = [];
435
+ let i = 0;
436
+ while (i + lengthSize <= data.length) {
437
+ let len = 0;
438
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
439
+ i += lengthSize;
440
+ if (len <= 0 || i + len > data.length) break;
441
+ nals.push(data.subarray(i, i + len));
442
+ i += len;
443
+ }
444
+ return nals;
445
+ }
446
+ function isCompleteAvccSample(data, lengthSize = 4) {
447
+ let i = 0;
448
+ let count = 0;
449
+ while (i + lengthSize <= data.length) {
450
+ let len = 0;
451
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
452
+ i += lengthSize;
453
+ if (len <= 0 || i + len > data.length) return false;
454
+ i += len;
455
+ count++;
456
+ }
457
+ return count > 0 && i === data.length;
458
+ }
459
+ function normalizeH264SampleToAvcc(data) {
460
+ if (isCompleteAvccSample(data)) return { data, format: "avcc" };
461
+ if (isAnnexB(data)) return { data: annexBToAvcc(data), format: "annexb" };
462
+ if (isLikelyRawH264NalUnit(data)) return { data: rawH264NalToAvcc(data), format: "raw-nal" };
463
+ return { data, format: "unknown" };
464
+ }
465
+ function splitH264SampleNalUnits(data, options = {}) {
466
+ if (isCompleteAvccSample(data)) return { nals: splitAvccNalUnits(data), format: "avcc" };
467
+ if (isAnnexB(data)) return { nals: splitAnnexBNalUnits(data), format: "annexb" };
468
+ if (options.allowPartialAvcc === true) {
469
+ const partial = splitPartialAvccNalUnits(data);
470
+ if (partial.length > 0) return { nals: partial, format: "partial-avcc" };
471
+ }
472
+ if (isLikelyRawH264NalUnit(data)) return { nals: [data], format: "raw-nal" };
473
+ const nals = splitAvccNalUnits(data);
474
+ return { nals, format: nals.length > 0 ? "avcc" : "unknown" };
475
+ }
476
+ function extractHevcParameterSets(keyframe) {
477
+ const nals = isAnnexB(keyframe) ? splitAnnexBNalUnits(keyframe) : splitAvccNalUnits(keyframe);
478
+ const out = {};
479
+ for (const nal of nals) {
480
+ if (nal.length === 0) continue;
481
+ const t = hevcNalType(nal);
482
+ if (t === 32 && !out.vps) out.vps = nal;
483
+ else if (t === 33 && !out.sps) out.sps = nal;
484
+ else if (t === 34 && !out.pps) out.pps = nal;
485
+ }
486
+ return out;
487
+ }
488
+ function generateHvcCFromParameterSets(sets) {
489
+ const { vps, sps, pps } = sets;
490
+ if (!sps || !pps) return null;
491
+ const info = parseHevcSps(sps);
492
+ if (info.bitDepthLumaMinus8 > HVCC_MAX_BIT_DEPTH_MINUS8 || info.bitDepthChromaMinus8 > HVCC_MAX_BIT_DEPTH_MINUS8) {
493
+ throw new Error("HEVC SPS: bit depth of 16 is not representable in an hvcC record");
494
+ }
495
+ const arrays = [
496
+ { type: 32, nal: vps },
497
+ { type: 33, nal: sps },
498
+ { type: 34, nal: pps }
499
+ ].filter((a) => a.nal !== void 0);
500
+ let size = 23;
501
+ for (const a of arrays) size += 5 + a.nal.length;
502
+ const h = new Uint8Array(size);
503
+ let o = 0;
504
+ h[o++] = 1;
505
+ h[o++] = info.profileSpace << 6 | (info.tierFlag ? 1 : 0) << 5 | info.profileIdc;
506
+ h[o++] = info.profileCompatibilityFlags >>> 24 & 255;
507
+ h[o++] = info.profileCompatibilityFlags >>> 16 & 255;
508
+ h[o++] = info.profileCompatibilityFlags >>> 8 & 255;
509
+ h[o++] = info.profileCompatibilityFlags & 255;
510
+ h.set(info.constraintIndicatorFlags, o);
511
+ o += 6;
512
+ h[o++] = info.levelIdc;
513
+ h[o++] = 240;
514
+ h[o++] = 0;
515
+ h[o++] = 252;
516
+ h[o++] = 252 | info.chromaFormatIdc;
517
+ h[o++] = 248 | info.bitDepthLumaMinus8;
518
+ h[o++] = 248 | info.bitDepthChromaMinus8;
519
+ h[o++] = 0;
520
+ h[o++] = 0;
521
+ h[o++] = info.maxSubLayersMinus1 + 1 << 3 | (info.temporalIdNestingFlag ? 1 : 0) << 2 | 3;
522
+ h[o++] = arrays.length;
523
+ for (const a of arrays) {
524
+ h[o++] = a.type & 63;
525
+ h[o++] = 0;
526
+ h[o++] = 1;
527
+ h[o++] = a.nal.length >> 8 & 255;
528
+ h[o++] = a.nal.length & 255;
529
+ h.set(a.nal, o);
530
+ o += a.nal.length;
531
+ }
532
+ return h.subarray(0, o);
533
+ }
534
+ function extractHevcCodecDescription(keyframe) {
535
+ return generateHvcCFromParameterSets(extractHevcParameterSets(keyframe));
536
+ }
537
+ function hevcVclOnly(data) {
538
+ const nals = isAnnexB(data) ? splitAnnexBNalUnits(data) : splitAvccNalUnits(data);
539
+ const vcl = nals.filter((n) => n.length > 0 && hevcNalType(n) <= 31);
540
+ if (vcl.length === nals.length && !isAnnexB(data)) return data;
541
+ let size = 0;
542
+ for (const n of vcl) size += 4 + n.length;
543
+ const out = new Uint8Array(size);
544
+ let o = 0;
545
+ for (const n of vcl) {
546
+ out[o++] = n.length >> 24 & 255;
547
+ out[o++] = n.length >> 16 & 255;
548
+ out[o++] = n.length >> 8 & 255;
549
+ out[o++] = n.length & 255;
550
+ out.set(n, o);
551
+ o += n.length;
552
+ }
553
+ return out;
554
+ }
555
+ function isAnnexB(data) {
556
+ if (data.length >= 4 && data[0] === 0 && data[1] === 0 && (data[2] === 1 || data[2] === 0 && data[3] === 1)) {
557
+ return true;
558
+ }
559
+ return false;
560
+ }
561
+ function findAnnexBStartCode(data) {
562
+ for (let i = 0; i < data.length - 3; i++) {
563
+ if (data[i] === 0 && data[i + 1] === 0) {
564
+ if (data[i + 2] === 1) return i;
565
+ if (data[i + 2] === 0 && data[i + 3] === 1) return i;
566
+ }
567
+ }
568
+ return -1;
569
+ }
570
+ function splitAnnexBNalUnits(data) {
571
+ const nalUnits = [];
572
+ let i = 0;
573
+ while (i < data.length - 3) {
574
+ if (data[i] === 0 && data[i + 1] === 0) {
575
+ let scLen = 0;
576
+ if (data[i + 2] === 1) scLen = 3;
577
+ else if (data[i + 2] === 0 && i + 3 < data.length && data[i + 3] === 1) scLen = 4;
578
+ if (scLen > 0) {
579
+ const nalStart = i + scLen;
580
+ let nalEnd = data.length;
581
+ for (let j = nalStart + 1; j < data.length - 2; j++) {
582
+ if (data[j] === 0 && data[j + 1] === 0 && (data[j + 2] === 1 || data[j + 2] === 0 && j + 3 < data.length && data[j + 3] === 1)) {
583
+ nalEnd = j;
584
+ break;
585
+ }
586
+ }
587
+ if (nalEnd > nalStart) nalUnits.push(data.subarray(nalStart, nalEnd));
588
+ i = nalEnd;
589
+ continue;
590
+ }
591
+ }
592
+ i++;
593
+ }
594
+ return nalUnits;
595
+ }
596
+ function annexBToAvcc(data, spsPps) {
597
+ const nalUnits = splitAnnexBNalUnits(data);
598
+ if (nalUnits.length === 0) return data;
599
+ let extraSize = 0;
600
+ if (spsPps) {
601
+ extraSize = 4 + spsPps.sps.length + 4 + spsPps.pps.length;
602
+ }
603
+ const frameSize = nalUnits.reduce((sum, nal) => sum + 4 + nal.length, 0);
604
+ const output = new Uint8Array(extraSize + frameSize);
605
+ let w = 0;
606
+ if (spsPps) {
607
+ w = writeNalLength(output, w, spsPps.sps.length);
608
+ output.set(spsPps.sps, w);
609
+ w += spsPps.sps.length;
610
+ w = writeNalLength(output, w, spsPps.pps.length);
611
+ output.set(spsPps.pps, w);
612
+ w += spsPps.pps.length;
613
+ }
614
+ for (const nal of nalUnits) {
615
+ w = writeNalLength(output, w, nal.length);
616
+ output.set(nal, w);
617
+ w += nal.length;
618
+ }
619
+ return output;
620
+ }
621
+ function classifyH264Keyframe(data, options = {}) {
622
+ const nals = h264NalUnitsForKeyframeDetection(data, options);
623
+ if (nals.length === 0) return void 0;
624
+ let sawIntraSlice = false;
625
+ let sawNonIntraVcl = false;
626
+ let sawNal = false;
627
+ for (const nal of nals) {
628
+ sawNal = true;
629
+ const nalType = nal[0] !== void 0 ? nal[0] & 31 : -1;
630
+ if (nalType === 5 || nalType === 7) return true;
631
+ if (nalType === 1) {
632
+ if (isH264IntraSlice(nal)) sawIntraSlice = true;
633
+ else sawNonIntraVcl = true;
634
+ }
635
+ }
636
+ if (sawIntraSlice && !sawNonIntraVcl) return true;
637
+ return sawNal ? false : void 0;
638
+ }
639
+ function detectH264Keyframe(data, options = {}) {
640
+ return classifyH264Keyframe(data, options) === true;
641
+ }
642
+ function mmtpTimestampToMicros(rawTs) {
643
+ const ts = typeof rawTs === "bigint" ? rawTs >= 0n && rawTs <= 0xffffffffn ? Number(rawTs) : void 0 : Number.isSafeInteger(rawTs) && rawTs >= 0 && rawTs <= 4294967295 ? rawTs : void 0;
644
+ if (ts === void 0) {
645
+ throw new RangeError(`MMTP timestamp must be an unsigned 32-bit integer, got ${String(rawTs)}`);
646
+ }
647
+ if (ts === 0) return 0;
648
+ const seconds = ts >>> 16;
649
+ const frac = ts & 65535;
650
+ return seconds * 1e6 + Math.floor(frac * 1e6 / 65536);
651
+ }
652
+ function isFmp4InitSegment(data) {
653
+ let offset = 0;
654
+ let sawFtyp = false;
655
+ let sawMoov = false;
656
+ while (offset + 8 <= data.byteLength) {
657
+ const view = new DataView(data.buffer, data.byteOffset + offset, data.byteLength - offset);
658
+ let size = view.getUint32(0, false);
659
+ const type = String.fromCharCode(data[offset + 4], data[offset + 5], data[offset + 6], data[offset + 7]);
660
+ let headerSize = 8;
661
+ if (size === 1) {
662
+ if (offset + 16 > data.byteLength) return false;
663
+ const largeSize = view.getBigUint64(8, false);
664
+ if (largeSize > BigInt(Number.MAX_SAFE_INTEGER)) return false;
665
+ size = Number(largeSize);
666
+ headerSize = 16;
667
+ } else if (size === 0) {
668
+ size = data.byteLength - offset;
669
+ }
670
+ if (size < headerSize || offset + size > data.byteLength) return false;
671
+ if (type === "mmpu") return false;
672
+ if (type === "ftyp") sawFtyp = true;
673
+ if (type === "moov") {
674
+ if (!sawFtyp) return false;
675
+ sawMoov = true;
676
+ }
677
+ offset += size;
678
+ }
679
+ return offset === data.byteLength && sawFtyp && sawMoov;
680
+ }
681
+ function normalizeMmtpInitSegment(data) {
682
+ if (isFmp4InitSegment(data)) return data;
683
+ const parts = [];
684
+ let offset = 0;
685
+ let removedMpu = false;
686
+ while (offset + 8 <= data.byteLength) {
687
+ const view = new DataView(data.buffer, data.byteOffset + offset, data.byteLength - offset);
688
+ let size = view.getUint32(0, false);
689
+ let headerSize = 8;
690
+ if (size === 1) {
691
+ if (offset + 16 > data.byteLength) return void 0;
692
+ const largeSize = view.getBigUint64(8, false);
693
+ if (largeSize > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
694
+ size = Number(largeSize);
695
+ headerSize = 16;
696
+ } else if (size === 0) {
697
+ size = data.byteLength - offset;
698
+ }
699
+ if (size < headerSize || offset + size > data.byteLength) return void 0;
700
+ const type = String.fromCharCode(
701
+ data[offset + 4],
702
+ data[offset + 5],
703
+ data[offset + 6],
704
+ data[offset + 7]
705
+ );
706
+ if (type === "mmpu") removedMpu = true;
707
+ else parts.push(data.subarray(offset, offset + size));
708
+ offset += size;
709
+ }
710
+ if (!removedMpu || offset !== data.byteLength) return void 0;
711
+ const normalized = new Uint8Array(parts.reduce((total, part) => total + part.byteLength, 0));
712
+ let writeOffset = 0;
713
+ for (const part of parts) {
714
+ normalized.set(part, writeOffset);
715
+ writeOffset += part.byteLength;
716
+ }
717
+ return isFmp4InitSegment(normalized) ? normalized : void 0;
718
+ }
719
+ function hasIsoBmffMagic(data) {
720
+ for (let i = 0; i + 8 <= data.length && i < 32; i += 4) {
721
+ const tag = String.fromCharCode(data[i + 4], data[i + 5], data[i + 6], data[i + 7]);
722
+ if (tag === "ftyp" || tag === "moov") return true;
723
+ }
724
+ return false;
725
+ }
726
+ function findTrackStsdBoxes(data) {
727
+ const moov = findBox(data, 0, data.length, "moov");
728
+ if (!moov) return [];
729
+ const out = [];
730
+ for (const trak of findBoxes(data, moov.o + 8, moov.o + moov.sz, "trak")) {
731
+ const stsd = findNestedBox(data, trak.o + 8, trak.o + trak.sz, ["mdia", "minf", "stbl", "stsd"]);
732
+ if (stsd) out.push(stsd);
733
+ }
734
+ return out;
735
+ }
736
+ function findNestedBox(buf, start, end, path) {
737
+ let s = start;
738
+ let e = end;
739
+ let current;
740
+ for (const type of path) {
741
+ current = findBox(buf, s, e, type);
742
+ if (!current) return void 0;
743
+ s = current.o + 8;
744
+ e = current.o + current.sz;
745
+ }
746
+ return current;
747
+ }
748
+ function findBox(buf, start, end, type) {
749
+ return findBoxes(buf, start, end, type)[0];
750
+ }
751
+ function findBoxes(buf, start, end, type) {
752
+ const boxes = [];
753
+ let o = start;
754
+ while (o + 8 <= end) {
755
+ let sz = buf[o] << 24 | buf[o + 1] << 16 | buf[o + 2] << 8 | buf[o + 3];
756
+ const t = String.fromCharCode(buf[o + 4], buf[o + 5], buf[o + 6], buf[o + 7]);
757
+ if (sz === 0) sz = end - o;
758
+ if (sz < 8 || o + sz > end) break;
759
+ if (t === type) boxes.push({ o, sz });
760
+ o += sz;
761
+ }
762
+ return boxes;
763
+ }
764
+ function writeNalLength(buf, offset, len) {
765
+ buf[offset] = len >> 24 & 255;
766
+ buf[offset + 1] = len >> 16 & 255;
767
+ buf[offset + 2] = len >> 8 & 255;
768
+ buf[offset + 3] = len & 255;
769
+ return offset + 4;
770
+ }
771
+ function h264NalUnitsForKeyframeDetection(data, options) {
772
+ return splitH264SampleNalUnits(data, options).nals;
773
+ }
774
+ function splitPartialAvccNalUnits(data, lengthSize = 4) {
775
+ const nals = [];
776
+ let i = 0;
777
+ while (i + lengthSize < data.length) {
778
+ let len = 0;
779
+ for (let k = 0; k < lengthSize; k++) len = len << 8 | data[i + k];
780
+ i += lengthSize;
781
+ if (len <= 0 || i >= data.length) break;
782
+ const end = Math.min(i + len, data.length);
783
+ nals.push(data.subarray(i, end));
784
+ if (end < i + len) break;
785
+ i = end;
786
+ }
787
+ return nals;
788
+ }
789
+ function isLikelyRawH264NalUnit(data) {
790
+ if (data.length === 0) return false;
791
+ const header = data[0];
792
+ if ((header & 128) !== 0) return false;
793
+ const nalType = header & 31;
794
+ return nalType > 0 && nalType < 24;
795
+ }
796
+ function rawH264NalToAvcc(data) {
797
+ const out = new Uint8Array(4 + data.length);
798
+ new DataView(out.buffer, out.byteOffset, out.byteLength).setUint32(0, data.length);
799
+ out.set(data, 4);
800
+ return out;
801
+ }
802
+ function isH264IntraSlice(nal) {
803
+ const sliceType = readH264SliceType(nal);
804
+ return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
805
+ }
806
+ function readH264SliceType(nal) {
807
+ if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
808
+ const rbsp = removeEmulationPrevention(nal.subarray(1));
809
+ const state = { bitOffset: 0 };
810
+ if (readUnsignedExpGolomb(rbsp, state) === null) return null;
811
+ return readUnsignedExpGolomb(rbsp, state);
812
+ }
813
+ function readUnsignedExpGolomb(data, state) {
814
+ let leadingZeroBits = 0;
815
+ while (true) {
816
+ const bit = readBit(data, state);
817
+ if (bit === null) return null;
818
+ if (bit === 1) break;
819
+ leadingZeroBits++;
820
+ if (leadingZeroBits > 30) return null;
821
+ }
822
+ let suffix = 0;
823
+ for (let i = 0; i < leadingZeroBits; i++) {
824
+ const bit = readBit(data, state);
825
+ if (bit === null) return null;
826
+ suffix = suffix << 1 | bit;
827
+ }
828
+ return (1 << leadingZeroBits) - 1 + suffix;
829
+ }
830
+ function readBit(data, state) {
831
+ if (state.bitOffset >= data.length * 8) return null;
832
+ const byte = data[state.bitOffset >> 3];
833
+ const bit = byte >> 7 - (state.bitOffset & 7) & 1;
834
+ state.bitOffset++;
835
+ return bit;
836
+ }
837
+ function hex2(n) {
838
+ return n.toString(16).padStart(2, "0");
839
+ }
840
+ function pad2(n) {
841
+ return String(n).padStart(2, "0");
842
+ }
843
+ function codecStringFromAv1C(av1C) {
844
+ if (av1C.length < 4) return "av01.0.01M.08";
845
+ const profile = av1C[1] >>> 5 & 7;
846
+ const level = av1C[1] & 31;
847
+ const tier = (av1C[2] & 128) !== 0 ? "H" : "M";
848
+ let bitDepth = 8;
849
+ if ((av1C[2] & 64) !== 0) {
850
+ bitDepth = (av1C[2] & 32) !== 0 ? 12 : 10;
851
+ }
852
+ return `av01.${profile}.${pad2(level)}${tier}.${pad2(bitDepth)}`;
853
+ }
854
+ function codecStringFromVpcC(vpcC) {
855
+ if (vpcC.length < 3) return "vp09.00.10.08";
856
+ const offset = vpcC.length >= 7 && vpcC[0] <= 1 ? 4 : 0;
857
+ if (offset + 2 >= vpcC.length) return "vp09.00.10.08";
858
+ const profile = vpcC[offset];
859
+ const level = vpcC[offset + 1];
860
+ const bitDepth = vpcC[offset + 2] >>> 4 || 8;
861
+ return `vp09.${pad2(profile)}.${pad2(level)}.${pad2(bitDepth)}`;
862
+ }
863
+ function hevcCodecStringFromHvcC(c, sampleEntry) {
864
+ return formatHevcCodecString(
865
+ sampleEntry,
866
+ c[1] >> 6 & 3,
867
+ (c[1] >> 5 & 1) === 1,
868
+ c[1] & 31,
869
+ (c[2] << 24 | c[3] << 16 | c[4] << 8 | c[5]) >>> 0,
870
+ c.subarray(6, 12),
871
+ c[12]
872
+ );
873
+ }
874
+ var BitWriter = class {
875
+ constructor() {
876
+ this.buf = [];
877
+ this.byte = 0;
878
+ this.bit = 7;
879
+ }
880
+ u(val, bits) {
881
+ for (let i = bits - 1; i >= 0; i--) {
882
+ this.byte |= (val >> i & 1) << this.bit;
883
+ if (--this.bit < 0) {
884
+ this.buf.push(this.byte);
885
+ this.byte = 0;
886
+ this.bit = 7;
887
+ }
888
+ }
889
+ }
890
+ ue(val) {
891
+ const v = val + 1;
892
+ const bits = Math.floor(Math.log2(v)) + 1;
893
+ this.u(0, bits - 1);
894
+ this.u(v, bits);
895
+ }
896
+ se(val) {
897
+ this.ue(val <= 0 ? -val * 2 : val * 2 - 1);
898
+ }
899
+ finish() {
900
+ if (this.bit < 7) {
901
+ this.byte |= 1 << this.bit;
902
+ this.buf.push(this.byte);
903
+ }
904
+ return new Uint8Array(this.buf);
905
+ }
906
+ };
907
+ function resolveResolution(explicitW, explicitH, level) {
908
+ if (explicitW && explicitH) return { width: explicitW, height: explicitH };
909
+ const levelResolutions = {
910
+ 10: [176, 144],
911
+ 11: [352, 288],
912
+ 12: [352, 288],
913
+ 13: [352, 288],
914
+ 20: [352, 288],
915
+ 21: [720, 576],
916
+ 22: [720, 576],
917
+ 30: [1280, 720],
918
+ 31: [1280, 720],
919
+ 32: [1280, 1024],
920
+ 40: [1920, 1088],
921
+ 41: [1920, 1088],
922
+ 42: [2048, 1088],
923
+ 50: [4096, 2160],
924
+ 51: [4096, 2160],
925
+ 52: [4096, 2160]
926
+ };
927
+ const [w, h] = levelResolutions[level] ?? [1920, 1088];
928
+ return { width: explicitW ?? w, height: explicitH ?? h };
929
+ }
930
+ function buildMinimalSps(profile, constraint, level, width, height) {
931
+ const widthInMbs = Math.ceil(width / 16);
932
+ const heightInMapUnits = Math.ceil(height / 16);
933
+ const w = new BitWriter();
934
+ w.u(0, 1);
935
+ w.u(3, 2);
936
+ w.u(7, 5);
937
+ w.u(profile, 8);
938
+ w.u(constraint, 8);
939
+ w.u(level, 8);
940
+ w.ue(0);
941
+ if (profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44) {
942
+ w.ue(1);
943
+ w.ue(0);
944
+ w.ue(0);
945
+ w.u(0, 1);
946
+ w.u(0, 1);
947
+ }
948
+ w.ue(0);
949
+ w.ue(2);
950
+ w.ue(1);
951
+ w.u(0, 1);
952
+ w.ue(widthInMbs - 1);
953
+ w.ue(heightInMapUnits - 1);
954
+ w.u(1, 1);
955
+ w.u(1, 1);
956
+ const cropRight = widthInMbs * 16 - width;
957
+ const cropBottom = heightInMapUnits * 16 - height;
958
+ if (cropRight > 0 || cropBottom > 0) {
959
+ w.u(1, 1);
960
+ w.ue(0);
961
+ w.ue(cropRight / 2);
962
+ w.ue(0);
963
+ w.ue(cropBottom / 2);
964
+ } else {
965
+ w.u(0, 1);
966
+ }
967
+ w.u(0, 1);
968
+ return w.finish();
969
+ }
970
+ function buildMinimalPps(profile) {
971
+ const isHighProfile = profile === 100 || profile === 110 || profile === 122 || profile === 244 || profile === 44;
972
+ const w = new BitWriter();
973
+ w.u(0, 1);
974
+ w.u(3, 2);
975
+ w.u(8, 5);
976
+ w.ue(0);
977
+ w.ue(0);
978
+ w.u(isHighProfile ? 1 : 0, 1);
979
+ w.u(0, 1);
980
+ w.ue(0);
981
+ w.ue(0);
982
+ w.ue(0);
983
+ w.u(0, 1);
984
+ w.u(0, 2);
985
+ w.se(0);
986
+ w.se(0);
987
+ w.se(0);
988
+ w.u(1, 1);
989
+ w.u(0, 1);
990
+ w.u(0, 1);
991
+ if (isHighProfile) {
992
+ w.u(1, 1);
993
+ w.u(0, 1);
994
+ w.se(0);
995
+ }
996
+ return w.finish();
997
+ }
998
+ var ADTS_SAMPLE_RATES = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350];
999
+ function wrapAdtsFrame(raw, sampleRate, channels) {
1000
+ const sri = ADTS_SAMPLE_RATES.indexOf(sampleRate);
1001
+ const idx = sri >= 0 ? sri : 3;
1002
+ const len = 7 + raw.length;
1003
+ const out = new Uint8Array(len);
1004
+ out[0] = 255;
1005
+ out[1] = 241;
1006
+ out[2] = 1 << 6 | idx << 2 | channels >> 2;
1007
+ out[3] = (channels & 3) << 6 | len >> 11 & 3;
1008
+ out[4] = len >> 3 & 255;
1009
+ out[5] = (len & 7) << 5 | 31;
1010
+ out[6] = 252;
1011
+ out.set(raw, 7);
1012
+ return out;
1013
+ }
1014
+ function extractAacAscFromInitSegment(data) {
1015
+ if (!hasIsoBmffMagic(data)) return void 0;
1016
+ for (const stsd of findTrackStsdBoxes(data)) {
1017
+ const info = extractAacAscFromStsd(data, stsd);
1018
+ if (info) return info;
1019
+ }
1020
+ return void 0;
1021
+ }
1022
+ function extractAacAscFromStsd(data, stsd) {
1023
+ const s = stsd.o + 16;
1024
+ const e = stsd.o + stsd.sz;
1025
+ const mp4a = findBox(data, s, e, "mp4a");
1026
+ if (!mp4a || mp4a.sz < 36) return void 0;
1027
+ const esds = findBox(data, mp4a.o + 36, mp4a.o + mp4a.sz, "esds");
1028
+ if (!esds || esds.sz < 12) return void 0;
1029
+ const esdsPayload = data.subarray(esds.o + 8, esds.o + esds.sz);
1030
+ const asc = extractAudioSpecificConfig(esdsPayload);
1031
+ if (!asc || asc.length < 2) return void 0;
1032
+ const aot = asc[0] >> 3;
1033
+ return { codec: `mp4a.40.${aot}`, description: asc };
1034
+ }
1035
+ function extractAudioSpecificConfig(esds) {
1036
+ let offset = 4;
1037
+ while (offset < esds.length) {
1038
+ const tag = esds[offset++];
1039
+ let size = 0;
1040
+ for (let i = 0; i < 4 && offset < esds.length; i++) {
1041
+ const b = esds[offset++];
1042
+ size = size << 7 | b & 127;
1043
+ if ((b & 128) === 0) break;
1044
+ }
1045
+ if (tag === 5) {
1046
+ if (offset + size > esds.length) return void 0;
1047
+ return esds.subarray(offset, offset + size);
1048
+ }
1049
+ if (tag === 3) {
1050
+ offset += 3;
1051
+ } else if (tag === 4) {
1052
+ offset += 13;
1053
+ } else {
1054
+ offset += size;
1055
+ }
1056
+ }
1057
+ return void 0;
1058
+ }
1059
+ if (void 0) {
1060
+ const { describe, test, expect } = void 0;
1061
+ describe("codec-utils", () => {
1062
+ describe("isAnnexB", () => {
1063
+ test("4-byte start code", () => {
1064
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
1065
+ });
1066
+ test("3-byte start code", () => {
1067
+ expect(isAnnexB(new Uint8Array([0, 0, 1, 101]))).toBe(true);
1068
+ });
1069
+ test("rejects AVCC", () => {
1070
+ expect(isAnnexB(new Uint8Array([0, 0, 0, 10, 101]))).toBe(false);
1071
+ });
1072
+ });
1073
+ describe("findAnnexBStartCode", () => {
1074
+ test("at offset 0", () => {
1075
+ expect(findAnnexBStartCode(new Uint8Array([0, 0, 0, 1, 101]))).toBe(0);
1076
+ });
1077
+ test("at offset 5", () => {
1078
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204, 221, 238, 0, 0, 1, 101]))).toBe(5);
1079
+ });
1080
+ test("returns -1 when none", () => {
1081
+ expect(findAnnexBStartCode(new Uint8Array([170, 187, 204]))).toBe(-1);
1082
+ });
1083
+ });
1084
+ describe("splitAnnexBNalUnits", () => {
1085
+ test("splits two NALs", () => {
1086
+ const data = new Uint8Array([0, 0, 0, 1, 101, 170, 187, 0, 0, 0, 1, 65, 204]);
1087
+ const nals = splitAnnexBNalUnits(data);
1088
+ expect(nals.length).toBe(2);
1089
+ expect(nals[0]).toEqual(new Uint8Array([101, 170, 187]));
1090
+ expect(nals[1]).toEqual(new Uint8Array([65, 204]));
1091
+ });
1092
+ test("handles 3-byte start codes", () => {
1093
+ const nals = splitAnnexBNalUnits(new Uint8Array([0, 0, 1, 103, 66, 0, 0, 1, 104, 1]));
1094
+ expect(nals.length).toBe(2);
1095
+ });
1096
+ });
1097
+ describe("annexBToAvcc", () => {
1098
+ test("converts single NAL", () => {
1099
+ const annexB = new Uint8Array([0, 0, 0, 1, 65, 170, 187]);
1100
+ const avcc = annexBToAvcc(annexB);
1101
+ expect(avcc[3]).toBe(3);
1102
+ expect(avcc[4]).toBe(65);
1103
+ });
1104
+ test("prepends SPS/PPS", () => {
1105
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 1]);
1106
+ const avcc = annexBToAvcc(annexB, { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) });
1107
+ expect(avcc[3]).toBe(2);
1108
+ expect(avcc[4]).toBe(103);
1109
+ });
1110
+ });
1111
+ describe("detectH264Keyframe", () => {
1112
+ test("IDR in Annex-B", () => {
1113
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 101]))).toBe(true);
1114
+ });
1115
+ test("SPS in Annex-B", () => {
1116
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 103]))).toBe(true);
1117
+ });
1118
+ test("IDR in AVCC", () => {
1119
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 5, 101, 1, 2, 3, 4]))).toBe(true);
1120
+ });
1121
+ test("IDR after AVCC AUD", () => {
1122
+ expect(detectH264Keyframe(new Uint8Array([
1123
+ 0,
1124
+ 0,
1125
+ 0,
1126
+ 1,
1127
+ 9,
1128
+ 0,
1129
+ 0,
1130
+ 0,
1131
+ 2,
1132
+ 101,
1133
+ 170
1134
+ ]))).toBe(true);
1135
+ });
1136
+ test("non-IDR AVC I-slice in AVCC", () => {
1137
+ expect(detectH264Keyframe(new Uint8Array([
1138
+ 0,
1139
+ 0,
1140
+ 0,
1141
+ 2,
1142
+ 65,
1143
+ 136
1144
+ ]))).toBe(true);
1145
+ });
1146
+ test("raw H.264 IDR NAL", () => {
1147
+ expect(detectH264Keyframe(new Uint8Array([101, 136, 132]))).toBe(true);
1148
+ });
1149
+ test("raw H.264 non-IDR I-slice NAL", () => {
1150
+ expect(detectH264Keyframe(new Uint8Array([65, 136]))).toBe(true);
1151
+ });
1152
+ test("classifies partial length-prefixed IDR only when requested", () => {
1153
+ const partial = new Uint8Array([0, 0, 32, 0, 101]);
1154
+ expect(classifyH264Keyframe(partial)).toBeUndefined();
1155
+ expect(classifyH264Keyframe(partial, { allowPartialAvcc: true })).toBe(true);
1156
+ });
1157
+ test("rejects P-frame", () => {
1158
+ expect(detectH264Keyframe(new Uint8Array([0, 0, 0, 1, 65]))).toBe(false);
1159
+ });
1160
+ test("rejects AVCC sample with only non-IDR slices", () => {
1161
+ expect(detectH264Keyframe(new Uint8Array([
1162
+ 0,
1163
+ 0,
1164
+ 0,
1165
+ 2,
1166
+ 65,
1167
+ 192,
1168
+ 0,
1169
+ 0,
1170
+ 0,
1171
+ 2,
1172
+ 65,
1173
+ 192
1174
+ ]))).toBe(false);
1175
+ });
1176
+ });
1177
+ describe("avccToAnnexB", () => {
1178
+ test("converts with SPS/PPS on keyframe", () => {
1179
+ const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
1180
+ const spsPps = { sps: new Uint8Array([103, 66]), pps: new Uint8Array([104, 1]) };
1181
+ const annexB = avccToAnnexB(avcc, true, spsPps);
1182
+ expect(annexB[3]).toBe(1);
1183
+ expect(annexB[4]).toBe(103);
1184
+ });
1185
+ });
1186
+ describe("codecStringFromAvcC", () => {
1187
+ test("derives avc1.64002a", () => {
1188
+ expect(codecStringFromAvcC(new Uint8Array([1, 100, 0, 42]))).toBe("avc1.64002a");
1189
+ });
1190
+ });
1191
+ describe("extractAacAscFromInitSegment", () => {
1192
+ function buildMinimalAacInit(asc) {
1193
+ const box = (type, payload) => {
1194
+ const sz = 8 + payload.length;
1195
+ const out = new Uint8Array(sz);
1196
+ out[0] = sz >>> 24 & 255;
1197
+ out[1] = sz >>> 16 & 255;
1198
+ out[2] = sz >>> 8 & 255;
1199
+ out[3] = sz & 255;
1200
+ out[4] = type.charCodeAt(0);
1201
+ out[5] = type.charCodeAt(1);
1202
+ out[6] = type.charCodeAt(2);
1203
+ out[7] = type.charCodeAt(3);
1204
+ out.set(payload, 8);
1205
+ return out;
1206
+ };
1207
+ const concat = (...arrs) => {
1208
+ const total = arrs.reduce((n, a) => n + a.length, 0);
1209
+ const out = new Uint8Array(total);
1210
+ let off = 0;
1211
+ for (const a of arrs) {
1212
+ out.set(a, off);
1213
+ off += a.length;
1214
+ }
1215
+ return out;
1216
+ };
1217
+ const ftyp = box("ftyp", new Uint8Array([
1218
+ 105,
1219
+ 115,
1220
+ 111,
1221
+ 53,
1222
+ // 'iso5'
1223
+ 0,
1224
+ 0,
1225
+ 2,
1226
+ 0,
1227
+ // minor 0x200
1228
+ 105,
1229
+ 115,
1230
+ 111,
1231
+ 53,
1232
+ // 'iso5'
1233
+ 105,
1234
+ 115,
1235
+ 111,
1236
+ 54
1237
+ // 'iso6'
1238
+ ]));
1239
+ const dsi = new Uint8Array(2 + asc.length);
1240
+ dsi[0] = 5;
1241
+ dsi[1] = asc.length;
1242
+ dsi.set(asc, 2);
1243
+ const dcd = new Uint8Array(2 + 13 + dsi.length);
1244
+ dcd[0] = 4;
1245
+ dcd[1] = 13 + dsi.length;
1246
+ dcd[2] = 64;
1247
+ dcd[3] = 5 << 2 | 1;
1248
+ dcd.set(dsi, 15);
1249
+ const esd = new Uint8Array(2 + 3 + dcd.length);
1250
+ esd[0] = 3;
1251
+ esd[1] = 3 + dcd.length;
1252
+ esd.set(dcd, 5);
1253
+ const esdsPayload = new Uint8Array(4 + esd.length);
1254
+ esdsPayload.set(esd, 4);
1255
+ const esds = box("esds", esdsPayload);
1256
+ const mp4aFixed = new Uint8Array(28);
1257
+ mp4aFixed[7] = 1;
1258
+ mp4aFixed[16] = 0;
1259
+ mp4aFixed[17] = 1;
1260
+ mp4aFixed[18] = 0;
1261
+ mp4aFixed[19] = 16;
1262
+ mp4aFixed[24] = 187;
1263
+ mp4aFixed[25] = 128;
1264
+ const mp4a = box("mp4a", concat(mp4aFixed, esds));
1265
+ const stsdPayload = new Uint8Array(8 + mp4a.length);
1266
+ stsdPayload[7] = 1;
1267
+ stsdPayload.set(mp4a, 8);
1268
+ const stsd = box("stsd", stsdPayload);
1269
+ const stbl = box("stbl", stsd);
1270
+ const minf = box("minf", stbl);
1271
+ const mdia = box("mdia", minf);
1272
+ const trak = box("trak", mdia);
1273
+ const moov = box("moov", trak);
1274
+ return concat(ftyp, moov);
1275
+ }
1276
+ test("extracts AAC-LC mono 48k ASC and derives codec", () => {
1277
+ const asc = new Uint8Array([17, 136]);
1278
+ const init = buildMinimalAacInit(asc);
1279
+ const result = extractAacAscFromInitSegment(init);
1280
+ expect(result).toBeDefined();
1281
+ expect(result.codec).toBe("mp4a.40.2");
1282
+ expect(Array.from(result.description)).toEqual([17, 136]);
1283
+ });
1284
+ test("derives AOT 5 (HE-AAC) from ASC[0] >> 3", () => {
1285
+ const asc = new Uint8Array([41, 136]);
1286
+ const init = buildMinimalAacInit(asc);
1287
+ expect(extractAacAscFromInitSegment(init)?.codec).toBe("mp4a.40.5");
1288
+ });
1289
+ test("rejects data without ftyp/moov magic", () => {
1290
+ expect(extractAacAscFromInitSegment(new Uint8Array(64))).toBeUndefined();
1291
+ });
1292
+ test("rejects ftyp+moov with no audio (no mp4a sample entry)", () => {
1293
+ const ftyp = new Uint8Array([
1294
+ 0,
1295
+ 0,
1296
+ 0,
1297
+ 24,
1298
+ 102,
1299
+ 116,
1300
+ 121,
1301
+ 112,
1302
+ 105,
1303
+ 115,
1304
+ 111,
1305
+ 53,
1306
+ 0,
1307
+ 0,
1308
+ 2,
1309
+ 0,
1310
+ 105,
1311
+ 115,
1312
+ 111,
1313
+ 53,
1314
+ 105,
1315
+ 115,
1316
+ 111,
1317
+ 54
1318
+ ]);
1319
+ const moov = new Uint8Array([0, 0, 0, 8, 109, 111, 111, 118]);
1320
+ const cat = new Uint8Array(ftyp.length + moov.length);
1321
+ cat.set(ftyp);
1322
+ cat.set(moov, ftyp.length);
1323
+ expect(extractAacAscFromInitSegment(cat)).toBeUndefined();
1324
+ });
1325
+ });
1326
+ describe("hevc", () => {
1327
+ const vps = new Uint8Array([
1328
+ 64,
1329
+ 1,
1330
+ 12,
1331
+ 1,
1332
+ 255,
1333
+ 255,
1334
+ 1,
1335
+ 96,
1336
+ 0,
1337
+ 0,
1338
+ 3,
1339
+ 0,
1340
+ 144,
1341
+ 0,
1342
+ 0,
1343
+ 3,
1344
+ 0,
1345
+ 0,
1346
+ 3,
1347
+ 0,
1348
+ 60,
1349
+ 146,
1350
+ 128,
1351
+ 144
1352
+ ]);
1353
+ const sps = new Uint8Array([
1354
+ 66,
1355
+ 1,
1356
+ 1,
1357
+ 1,
1358
+ 96,
1359
+ 0,
1360
+ 0,
1361
+ 3,
1362
+ 0,
1363
+ 144,
1364
+ 0,
1365
+ 0,
1366
+ 3,
1367
+ 0,
1368
+ 0,
1369
+ 3,
1370
+ 0,
1371
+ 60,
1372
+ 160,
1373
+ 10,
1374
+ 8,
1375
+ 15,
1376
+ 22,
1377
+ 89,
1378
+ 42,
1379
+ 73,
1380
+ 50,
1381
+ 188,
1382
+ 5,
1383
+ 160,
1384
+ 32,
1385
+ 0,
1386
+ 0,
1387
+ 3,
1388
+ 0,
1389
+ 32,
1390
+ 0,
1391
+ 0,
1392
+ 3,
1393
+ 3,
1394
+ 193
1395
+ ]);
1396
+ const pps = new Uint8Array([68, 1, 193, 114, 180, 98, 64]);
1397
+ const idr = new Uint8Array([38, 1, 175, 6]);
1398
+ const lp = (...nals) => {
1399
+ const parts = [];
1400
+ for (const n of nals) {
1401
+ parts.push(n.length >> 24 & 255, n.length >> 16 & 255, n.length >> 8 & 255, n.length & 255, ...n);
1402
+ }
1403
+ return Uint8Array.from(parts);
1404
+ };
1405
+ test("isHevcCodec", () => {
1406
+ expect(isHevcCodec("hev1.1.6.L93.B0")).toBe(true);
1407
+ expect(isHevcCodec("hvc1.1.6.L93.B0")).toBe(true);
1408
+ expect(isHevcCodec("avc1.640033")).toBe(false);
1409
+ });
1410
+ test("removeEmulationPrevention strips 0x03", () => {
1411
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([0, 0, 3, 1])))).toEqual([0, 0, 1]);
1412
+ expect(Array.from(removeEmulationPrevention(new Uint8Array([170, 187])))).toEqual([170, 187]);
1413
+ });
1414
+ test("splitAvccNalUnits splits length-prefixed NALs", () => {
1415
+ const nals = splitAvccNalUnits(lp(vps, sps));
1416
+ expect(nals.length).toBe(2);
1417
+ expect(nals[0]).toEqual(vps);
1418
+ expect(nals[1]).toEqual(sps);
1419
+ });
1420
+ test("isCompleteAvccSample accepts complete length-prefixed NAL samples", () => {
1421
+ expect(isCompleteAvccSample(lp(new Uint8Array([9]), idr))).toBe(true);
1422
+ });
1423
+ test("isCompleteAvccSample rejects Annex-B start-code samples", () => {
1424
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 1, 101, 170]))).toBe(false);
1425
+ });
1426
+ test("isCompleteAvccSample rejects truncated length-prefixed samples", () => {
1427
+ expect(isCompleteAvccSample(new Uint8Array([0, 0, 0, 4, 101, 170]))).toBe(false);
1428
+ });
1429
+ test("normalizeH264SampleToAvcc leaves complete AVCC samples unchanged", () => {
1430
+ const avcc = lp(new Uint8Array([9]), idr);
1431
+ const normalized = normalizeH264SampleToAvcc(avcc);
1432
+ expect(normalized.format).toBe("avcc");
1433
+ expect(normalized.data).toBe(avcc);
1434
+ });
1435
+ test("normalizeH264SampleToAvcc converts a single raw H.264 NAL to AVCC", () => {
1436
+ const raw = new Uint8Array([101, 136, 132]);
1437
+ const normalized = normalizeH264SampleToAvcc(raw);
1438
+ expect(normalized.format).toBe("raw-nal");
1439
+ expect(normalized.data).toEqual(new Uint8Array([0, 0, 0, 3, 101, 136, 132]));
1440
+ });
1441
+ test("splitH264SampleNalUnits exposes Annex-B NALs without AVCC conversion", () => {
1442
+ const annexB = new Uint8Array([0, 0, 0, 1, 101, 136, 132]);
1443
+ const sample = splitH264SampleNalUnits(annexB);
1444
+ expect(sample.format).toBe("annexb");
1445
+ expect(sample.nals).toHaveLength(1);
1446
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136, 132]));
1447
+ });
1448
+ test("splitH264SampleNalUnits exposes single raw H.264 NALs without wrapping", () => {
1449
+ const raw = new Uint8Array([101, 136, 132]);
1450
+ const sample = splitH264SampleNalUnits(raw);
1451
+ expect(sample.format).toBe("raw-nal");
1452
+ expect(sample.nals).toEqual([raw]);
1453
+ });
1454
+ test("splitH264SampleNalUnits can expose partial AVCC NAL headers", () => {
1455
+ const partial = new Uint8Array([0, 0, 0, 5, 101, 136]);
1456
+ const sample = splitH264SampleNalUnits(partial, { allowPartialAvcc: true });
1457
+ expect(sample.format).toBe("partial-avcc");
1458
+ expect(sample.nals).toHaveLength(1);
1459
+ expect(sample.nals[0]).toEqual(new Uint8Array([101, 136]));
1460
+ });
1461
+ test("extractHevcParameterSets finds VPS/SPS/PPS (length-prefixed)", () => {
1462
+ const sets = extractHevcParameterSets(lp(vps, sps, pps, idr));
1463
+ expect(sets.vps).toEqual(vps);
1464
+ expect(sets.sps).toEqual(sps);
1465
+ expect(sets.pps).toEqual(pps);
1466
+ });
1467
+ test("extractHevcParameterSets finds VPS/SPS/PPS (Annex-B)", () => {
1468
+ const sc = new Uint8Array([0, 0, 0, 1]);
1469
+ const annexb = Uint8Array.from([...sc, ...vps, ...sc, ...sps, ...sc, ...pps, ...sc, ...idr]);
1470
+ const sets = extractHevcParameterSets(annexb);
1471
+ expect(sets.vps).toEqual(vps);
1472
+ expect(sets.sps).toEqual(sps);
1473
+ expect(sets.pps).toEqual(pps);
1474
+ });
1475
+ test("generateHvcCFromParameterSets builds a valid hvcC", () => {
1476
+ const hvcc = generateHvcCFromParameterSets({ vps, sps, pps });
1477
+ expect(hvcc).not.toBeNull();
1478
+ expect(hvcc[0]).toBe(1);
1479
+ expect(hvcc[1]).toBe(sps[3]);
1480
+ expect(hvcc[22]).toBe(3);
1481
+ expect(hvcc[23] & 63).toBe(32);
1482
+ expect(hvcc[24] << 8 | hvcc[25]).toBe(1);
1483
+ });
1484
+ test("generateHvcCFromParameterSets returns null without SPS/PPS", () => {
1485
+ expect(generateHvcCFromParameterSets({ vps })).toBeNull();
1486
+ });
1487
+ test("extractHevcCodecDescription end-to-end from keyframe", () => {
1488
+ const desc = extractHevcCodecDescription(lp(vps, sps, pps, idr));
1489
+ expect(desc).not.toBeNull();
1490
+ expect(desc[0]).toBe(1);
1491
+ });
1492
+ test("hevcVclOnly strips parameter-set NALs, keeps VCL", () => {
1493
+ const stripped = hevcVclOnly(lp(vps, sps, pps, idr));
1494
+ const nals = splitAvccNalUnits(stripped);
1495
+ expect(nals.length).toBe(1);
1496
+ expect(nals[0]).toEqual(idr);
1497
+ });
1498
+ test("hevcVclOnly is a no-op for VCL-only length-prefixed input", () => {
1499
+ const vclOnly = lp(idr);
1500
+ expect(hevcVclOnly(vclOnly)).toBe(vclOnly);
1501
+ });
1502
+ });
1503
+ });
1504
+ }
1505
+ export {
1506
+ HEVC_NAL_HEADER_LENGTH,
1507
+ HEVC_NAL_UNIT_TYPE,
1508
+ annexBToAvcc,
1509
+ avccToAnnexB,
1510
+ classifyH264Keyframe,
1511
+ classifyHevcKeyframe,
1512
+ codecStringFromAvcC,
1513
+ detectH264Keyframe,
1514
+ detectHevcKeyframe,
1515
+ extractAacAscFromInitSegment,
1516
+ extractAvcCFromInitSegment,
1517
+ extractCodecDescriptionFromAnnexB,
1518
+ extractHevcCodecDescription,
1519
+ extractHevcParameterSets,
1520
+ extractSpsPpsFromAvcC,
1521
+ findAnnexBStartCode,
1522
+ generateFallbackAvcC,
1523
+ generateHvcCFromParameterSets,
1524
+ hevcCodecStringFromSps,
1525
+ hevcNalUnitType,
1526
+ hevcVclOnly,
1527
+ isAnnexB,
1528
+ isCompleteAvccSample,
1529
+ isFmp4InitSegment,
1530
+ isHevcCodec,
1531
+ isHevcIrapNalUnitType,
1532
+ mmtpTimestampToMicros,
1533
+ normalizeH264SampleToAvcc,
1534
+ normalizeHevcSampleToLengthPrefixed,
1535
+ normalizeMmtpInitSegment,
1536
+ parseHevcSps,
1537
+ prepareHevcCmafSample,
1538
+ removeEmulationPrevention,
1539
+ splitAnnexBNalUnits,
1540
+ splitAvccNalUnits,
1541
+ splitH264SampleNalUnits,
1542
+ videoCodecFamily,
1543
+ videoSampleEntryFromCodecString,
1544
+ wrapAdtsFrame
1545
+ };
1546
+ //# sourceMappingURL=codec-utils.js.map