@blockcast/mmt-container 0.1.0-main.0399efef1f07

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 (694) hide show
  1. package/README.md +432 -0
  2. package/dist/.build-stamp +0 -0
  3. package/dist/__tests__/test-utils.d.ts +71 -0
  4. package/dist/__tests__/test-utils.d.ts.map +1 -0
  5. package/dist/align.d.ts +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 +93 -0
  16. package/dist/audio-ring-buffer.js.map +7 -0
  17. package/dist/authored-timing.d.ts +32 -0
  18. package/dist/authored-timing.d.ts.map +1 -0
  19. package/dist/authored-timing.js +32 -0
  20. package/dist/authored-timing.js.map +7 -0
  21. package/dist/browser-runtime.js +20087 -0
  22. package/dist/browser-runtime.js.map +7 -0
  23. package/dist/carp-catalog.d.ts +318 -0
  24. package/dist/carp-catalog.d.ts.map +1 -0
  25. package/dist/carp-catalog.js +873 -0
  26. package/dist/carp-catalog.js.map +7 -0
  27. package/dist/catalog-fec-params.d.ts +202 -0
  28. package/dist/catalog-fec-params.d.ts.map +1 -0
  29. package/dist/catalog-fec-params.js +568 -0
  30. package/dist/catalog-fec-params.js.map +7 -0
  31. package/dist/catalog-network-source.d.ts +19 -0
  32. package/dist/catalog-network-source.d.ts.map +1 -0
  33. package/dist/catalog-network-source.js +22 -0
  34. package/dist/catalog-network-source.js.map +7 -0
  35. package/dist/catalog-validator.d.ts +18 -0
  36. package/dist/catalog-validator.d.ts.map +1 -0
  37. package/dist/catalog-validator.js +7747 -0
  38. package/dist/catalog-validator.js.map +7 -0
  39. package/dist/cmaf-block-assembler.d.ts +217 -0
  40. package/dist/cmaf-block-assembler.d.ts.map +1 -0
  41. package/dist/cmaf-block-assembler.js +1769 -0
  42. package/dist/cmaf-block-assembler.js.map +7 -0
  43. package/dist/cmaf-group-batcher.d.ts +38 -0
  44. package/dist/cmaf-group-batcher.d.ts.map +1 -0
  45. package/dist/cmaf-group-batcher.js +195 -0
  46. package/dist/cmaf-group-batcher.js.map +7 -0
  47. package/dist/cmcd-producer.d.ts +104 -0
  48. package/dist/cmcd-producer.d.ts.map +1 -0
  49. package/dist/cmcd-producer.js +207 -0
  50. package/dist/cmcd-producer.js.map +7 -0
  51. package/dist/codec-utils.d.ts +248 -0
  52. package/dist/codec-utils.d.ts.map +1 -0
  53. package/dist/codec-utils.js +1268 -0
  54. package/dist/codec-utils.js.map +7 -0
  55. package/dist/fec-codec.d.ts +32 -0
  56. package/dist/fec-codec.d.ts.map +1 -0
  57. package/dist/fec-codec.js +47 -0
  58. package/dist/fec-codec.js.map +7 -0
  59. package/dist/fec-manager.d.ts +307 -0
  60. package/dist/fec-manager.d.ts.map +1 -0
  61. package/dist/fec-manager.js +1530 -0
  62. package/dist/fec-manager.js.map +7 -0
  63. package/dist/fec-starvation-detector.d.ts +59 -0
  64. package/dist/fec-starvation-detector.d.ts.map +1 -0
  65. package/dist/fec-starvation-detector.js +75 -0
  66. package/dist/fec-starvation-detector.js.map +7 -0
  67. package/dist/fec-worker-setup.d.ts +88 -0
  68. package/dist/fec-worker-setup.d.ts.map +1 -0
  69. package/dist/fec-worker-setup.js +614 -0
  70. package/dist/fec-worker-setup.js.map +7 -0
  71. package/dist/fmp4-completion.d.ts +30 -0
  72. package/dist/fmp4-completion.d.ts.map +1 -0
  73. package/dist/fmp4-completion.js +21 -0
  74. package/dist/fmp4-completion.js.map +7 -0
  75. package/dist/fmp4-reader.d.ts +37 -0
  76. package/dist/fmp4-reader.d.ts.map +1 -0
  77. package/dist/fmp4-reader.js +100 -0
  78. package/dist/fmp4-reader.js.map +7 -0
  79. package/dist/index.d.ts +47 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +380 -0
  82. package/dist/index.js.map +7 -0
  83. package/dist/iso-bmff-timing.d.ts +78 -0
  84. package/dist/iso-bmff-timing.d.ts.map +1 -0
  85. package/dist/iso-bmff-timing.js +618 -0
  86. package/dist/iso-bmff-timing.js.map +7 -0
  87. package/dist/loc.d.ts +68 -0
  88. package/dist/loc.d.ts.map +1 -0
  89. package/dist/loc.js +143 -0
  90. package/dist/loc.js.map +7 -0
  91. package/dist/manifest-auth-plan.d.ts +30 -0
  92. package/dist/manifest-auth-plan.d.ts.map +1 -0
  93. package/dist/manifest-auth-plan.js +1285 -0
  94. package/dist/manifest-auth-plan.js.map +7 -0
  95. package/dist/media-router.d.ts +251 -0
  96. package/dist/media-router.d.ts.map +1 -0
  97. package/dist/media-router.js +624 -0
  98. package/dist/media-router.js.map +7 -0
  99. package/dist/mfu-reassembler.d.ts +396 -0
  100. package/dist/mfu-reassembler.d.ts.map +1 -0
  101. package/dist/mfu-reassembler.js +3085 -0
  102. package/dist/mfu-reassembler.js.map +7 -0
  103. package/dist/mfu-reassembly-policy.d.ts +24 -0
  104. package/dist/mfu-reassembly-policy.d.ts.map +1 -0
  105. package/dist/mfu-reassembly-policy.js +99 -0
  106. package/dist/mfu-reassembly-policy.js.map +7 -0
  107. package/dist/mmtp-container-parser.d.ts +434 -0
  108. package/dist/mmtp-container-parser.d.ts.map +1 -0
  109. package/dist/mmtp-container-parser.js +6164 -0
  110. package/dist/mmtp-container-parser.js.map +7 -0
  111. package/dist/mmtp-container-parser.no-modules.js +8999 -0
  112. package/dist/mmtp-container-parser.no-modules.js.map +7 -0
  113. package/dist/mmtp-decode-pipeline.d.ts +132 -0
  114. package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
  115. package/dist/mmtp-decode-pipeline.js +6413 -0
  116. package/dist/mmtp-decode-pipeline.js.map +7 -0
  117. package/dist/mmtp-router.d.ts +390 -0
  118. package/dist/mmtp-router.d.ts.map +1 -0
  119. package/dist/mmtp-router.js +9242 -0
  120. package/dist/mmtp-router.js.map +7 -0
  121. package/dist/mmtp-to-cmaf.d.ts +181 -0
  122. package/dist/mmtp-to-cmaf.d.ts.map +1 -0
  123. package/dist/mmtp-to-cmaf.js +802 -0
  124. package/dist/mmtp-to-cmaf.js.map +7 -0
  125. package/dist/multicast-auth-catalog.d.ts +115 -0
  126. package/dist/multicast-auth-catalog.d.ts.map +1 -0
  127. package/dist/multicast-auth-catalog.js +202 -0
  128. package/dist/multicast-auth-catalog.js.map +7 -0
  129. package/dist/multicast-input.d.ts +107 -0
  130. package/dist/multicast-input.d.ts.map +1 -0
  131. package/dist/multicast-input.js +256 -0
  132. package/dist/multicast-input.js.map +7 -0
  133. package/dist/multicast-manager.d.ts +369 -0
  134. package/dist/multicast-manager.d.ts.map +1 -0
  135. package/dist/multicast-manager.js +13400 -0
  136. package/dist/multicast-manager.js.map +7 -0
  137. package/dist/multicast-transport.d.ts +61 -0
  138. package/dist/multicast-transport.d.ts.map +1 -0
  139. package/dist/multicast-transport.js +1665 -0
  140. package/dist/multicast-transport.js.map +7 -0
  141. package/dist/multicast-unwrap.d.ts +57 -0
  142. package/dist/multicast-unwrap.d.ts.map +1 -0
  143. package/dist/multicast-unwrap.js +384 -0
  144. package/dist/multicast-unwrap.js.map +7 -0
  145. package/dist/no-modules.d.ts +9 -0
  146. package/dist/no-modules.d.ts.map +1 -0
  147. package/dist/no-modules.js +8965 -0
  148. package/dist/no-modules.js.map +7 -0
  149. package/dist/phase14-catalog-override.d.ts +126 -0
  150. package/dist/phase14-catalog-override.d.ts.map +1 -0
  151. package/dist/phase14-catalog-override.js +155 -0
  152. package/dist/phase14-catalog-override.js.map +7 -0
  153. package/dist/repair-fetch.d.ts +58 -0
  154. package/dist/repair-fetch.d.ts.map +1 -0
  155. package/dist/repair-fetch.js +127 -0
  156. package/dist/repair-fetch.js.map +7 -0
  157. package/dist/repair-layers.d.ts +141 -0
  158. package/dist/repair-layers.d.ts.map +1 -0
  159. package/dist/repair-layers.js +303 -0
  160. package/dist/repair-layers.js.map +7 -0
  161. package/dist/sample-combiner.d.ts +212 -0
  162. package/dist/sample-combiner.d.ts.map +1 -0
  163. package/dist/sample-combiner.js +616 -0
  164. package/dist/sample-combiner.js.map +7 -0
  165. package/dist/signaling.d.ts +29 -0
  166. package/dist/signaling.d.ts.map +1 -0
  167. package/dist/signaling.js +232 -0
  168. package/dist/signaling.js.map +7 -0
  169. package/dist/source-auth.d.ts +2 -0
  170. package/dist/source-auth.d.ts.map +1 -0
  171. package/dist/source-auth.js +1238 -0
  172. package/dist/source-auth.js.map +7 -0
  173. package/dist/switching-set-alignment.d.ts +61 -0
  174. package/dist/switching-set-alignment.d.ts.map +1 -0
  175. package/dist/switching-set-alignment.js +85 -0
  176. package/dist/switching-set-alignment.js.map +7 -0
  177. package/dist/timestamp-codec.d.ts +34 -0
  178. package/dist/timestamp-codec.d.ts.map +1 -0
  179. package/dist/timestamp-codec.js +456 -0
  180. package/dist/timestamp-codec.js.map +7 -0
  181. package/dist/track-pipeline-setup.d.ts +72 -0
  182. package/dist/track-pipeline-setup.d.ts.map +1 -0
  183. package/dist/track-pipeline-setup.js +306 -0
  184. package/dist/track-pipeline-setup.js.map +7 -0
  185. package/dist/track-pipeline.d.ts +121 -0
  186. package/dist/track-pipeline.d.ts.map +1 -0
  187. package/dist/track-pipeline.js +229 -0
  188. package/dist/track-pipeline.js.map +7 -0
  189. package/dist/track-session.d.ts +398 -0
  190. package/dist/track-session.d.ts.map +1 -0
  191. package/dist/track-session.js +767 -0
  192. package/dist/track-session.js.map +7 -0
  193. package/dist/transport-pool.d.ts +69 -0
  194. package/dist/transport-pool.d.ts.map +1 -0
  195. package/dist/transport-pool.js +88 -0
  196. package/dist/transport-pool.js.map +7 -0
  197. package/dist/wasm-mfu-reassembler.d.ts +92 -0
  198. package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
  199. package/dist/wasm-mfu-reassembler.js +2139 -0
  200. package/dist/wasm-mfu-reassembler.js.map +7 -0
  201. package/dist/wasm-mmtp-container-parser.d.ts +10 -0
  202. package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
  203. package/dist/wasm-mmtp-container-parser.js +6418 -0
  204. package/dist/wasm-mmtp-container-parser.js.map +7 -0
  205. package/node_modules/@blockcast/fec-worker/README.md +213 -0
  206. package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
  207. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +87 -0
  208. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
  209. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +279 -0
  210. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
  211. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +252 -0
  212. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
  213. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
  214. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
  215. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
  216. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
  217. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +565 -0
  218. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
  219. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
  220. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
  221. package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
  222. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
  223. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
  224. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
  225. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +349 -0
  226. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
  227. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
  228. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
  229. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
  230. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
  231. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +179 -0
  232. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
  233. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +47 -0
  234. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
  235. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
  236. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
  237. package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
  238. package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
  239. package/node_modules/@blockcast/fec-worker/package.json +59 -0
  240. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +319 -0
  241. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +268 -0
  242. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1048 -0
  243. package/node_modules/@blockcast/fec-worker/src/index.ts +32 -0
  244. package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +558 -0
  245. package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
  246. package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +194 -0
  247. package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
  248. package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  249. package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  250. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  251. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  252. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  253. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  254. package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  255. package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  256. package/node_modules/@blockcast/mmt-base/README.md +120 -0
  257. package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  258. package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  259. package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  260. package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  261. package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  262. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +276 -0
  263. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  264. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +645 -0
  265. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  266. package/node_modules/@blockcast/mmt-base/package.json +49 -0
  267. package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  268. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +899 -0
  269. package/node_modules/@blockcast/mmt-fec/README.md +270 -0
  270. package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
  271. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +82 -0
  272. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
  273. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +296 -0
  274. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
  275. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +72 -0
  276. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
  277. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +192 -0
  278. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
  279. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
  280. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
  281. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
  282. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
  283. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
  284. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
  285. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
  286. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
  287. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +185 -0
  288. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
  289. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +273 -0
  290. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
  291. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +22 -0
  292. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
  293. package/node_modules/@blockcast/mmt-fec/dist/index.js +22 -0
  294. package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
  295. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
  296. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
  297. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
  298. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
  299. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +172 -0
  300. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
  301. package/node_modules/@blockcast/mmt-fec/dist/oti.js +254 -0
  302. package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
  303. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
  304. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
  305. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
  306. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
  307. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  308. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  309. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  310. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  311. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  312. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  313. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  314. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  315. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +120 -0
  316. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  317. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  318. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  319. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  320. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  321. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +276 -0
  322. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  323. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +645 -0
  324. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  325. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
  326. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  327. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +899 -0
  328. package/node_modules/@blockcast/mmt-fec/package.json +79 -0
  329. package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +371 -0
  330. package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +277 -0
  331. package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
  332. package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
  333. package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +332 -0
  334. package/node_modules/@blockcast/mmt-fec/src/index.ts +77 -0
  335. package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
  336. package/node_modules/@blockcast/mmt-fec/src/oti.ts +317 -0
  337. package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
  338. package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
  339. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
  340. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
  341. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
  342. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
  343. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
  344. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
  345. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
  346. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
  347. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
  348. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
  349. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
  350. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
  351. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +99 -0
  352. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
  353. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +492 -0
  354. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
  355. package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
  356. package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
  357. package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
  358. package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
  359. package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +669 -0
  360. package/node_modules/@noble/hashes/LICENSE +21 -0
  361. package/node_modules/@noble/hashes/README.md +521 -0
  362. package/node_modules/@noble/hashes/_assert.d.ts +17 -0
  363. package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
  364. package/node_modules/@noble/hashes/_assert.js +18 -0
  365. package/node_modules/@noble/hashes/_assert.js.map +1 -0
  366. package/node_modules/@noble/hashes/_blake.d.ts +14 -0
  367. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  368. package/node_modules/@noble/hashes/_blake.js +50 -0
  369. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  370. package/node_modules/@noble/hashes/_md.d.ts +51 -0
  371. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  372. package/node_modules/@noble/hashes/_md.js +162 -0
  373. package/node_modules/@noble/hashes/_md.js.map +1 -0
  374. package/node_modules/@noble/hashes/_u64.d.ts +55 -0
  375. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  376. package/node_modules/@noble/hashes/_u64.js +90 -0
  377. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  378. package/node_modules/@noble/hashes/argon2.d.ts +32 -0
  379. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  380. package/node_modules/@noble/hashes/argon2.js +401 -0
  381. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  382. package/node_modules/@noble/hashes/blake1.d.ts +106 -0
  383. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  384. package/node_modules/@noble/hashes/blake1.js +459 -0
  385. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  386. package/node_modules/@noble/hashes/blake2.d.ts +116 -0
  387. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  388. package/node_modules/@noble/hashes/blake2.js +420 -0
  389. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  390. package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
  391. package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
  392. package/node_modules/@noble/hashes/blake2b.js +14 -0
  393. package/node_modules/@noble/hashes/blake2b.js.map +1 -0
  394. package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
  395. package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
  396. package/node_modules/@noble/hashes/blake2s.js +24 -0
  397. package/node_modules/@noble/hashes/blake2s.js.map +1 -0
  398. package/node_modules/@noble/hashes/blake3.d.ts +54 -0
  399. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  400. package/node_modules/@noble/hashes/blake3.js +255 -0
  401. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  402. package/node_modules/@noble/hashes/crypto.d.ts +2 -0
  403. package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
  404. package/node_modules/@noble/hashes/crypto.js +5 -0
  405. package/node_modules/@noble/hashes/crypto.js.map +1 -0
  406. package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
  407. package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
  408. package/node_modules/@noble/hashes/cryptoNode.js +18 -0
  409. package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
  410. package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
  411. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  412. package/node_modules/@noble/hashes/eskdf.js +166 -0
  413. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  414. package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
  415. package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
  416. package/node_modules/@noble/hashes/esm/_assert.js +15 -0
  417. package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
  418. package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
  419. package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
  420. package/node_modules/@noble/hashes/esm/_blake.js +45 -0
  421. package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
  422. package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
  423. package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
  424. package/node_modules/@noble/hashes/esm/_md.js +155 -0
  425. package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  426. package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
  427. package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
  428. package/node_modules/@noble/hashes/esm/_u64.js +67 -0
  429. package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  430. package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
  431. package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
  432. package/node_modules/@noble/hashes/esm/argon2.js +392 -0
  433. package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
  434. package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
  435. package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
  436. package/node_modules/@noble/hashes/esm/blake1.js +452 -0
  437. package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
  438. package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
  439. package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
  440. package/node_modules/@noble/hashes/esm/blake2.js +413 -0
  441. package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
  442. package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
  443. package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
  444. package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
  445. package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
  446. package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
  447. package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
  448. package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
  449. package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
  450. package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
  451. package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
  452. package/node_modules/@noble/hashes/esm/blake3.js +251 -0
  453. package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
  454. package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
  455. package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
  456. package/node_modules/@noble/hashes/esm/crypto.js +2 -0
  457. package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
  458. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
  459. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
  460. package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
  461. package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
  462. package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
  463. package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
  464. package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
  465. package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
  466. package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
  467. package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
  468. package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
  469. package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
  470. package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
  471. package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
  472. package/node_modules/@noble/hashes/esm/hmac.js +86 -0
  473. package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
  474. package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
  475. package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
  476. package/node_modules/@noble/hashes/esm/index.js +33 -0
  477. package/node_modules/@noble/hashes/esm/index.js.map +1 -0
  478. package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
  479. package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
  480. package/node_modules/@noble/hashes/esm/legacy.js +281 -0
  481. package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  482. package/node_modules/@noble/hashes/esm/package.json +10 -0
  483. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
  484. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
  485. package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
  486. package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
  487. package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
  488. package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
  489. package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
  490. package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
  491. package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
  492. package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
  493. package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
  494. package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
  495. package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
  496. package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
  497. package/node_modules/@noble/hashes/esm/sha1.js +11 -0
  498. package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
  499. package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
  500. package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
  501. package/node_modules/@noble/hashes/esm/sha2.js +375 -0
  502. package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  503. package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
  504. package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
  505. package/node_modules/@noble/hashes/esm/sha256.js +20 -0
  506. package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
  507. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
  508. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
  509. package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
  510. package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
  511. package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
  512. package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
  513. package/node_modules/@noble/hashes/esm/sha3.js +234 -0
  514. package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
  515. package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
  516. package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
  517. package/node_modules/@noble/hashes/esm/sha512.js +26 -0
  518. package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
  519. package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
  520. package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
  521. package/node_modules/@noble/hashes/esm/utils.js +281 -0
  522. package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  523. package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
  524. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  525. package/node_modules/@noble/hashes/hkdf.js +88 -0
  526. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  527. package/node_modules/@noble/hashes/hmac.d.ts +35 -0
  528. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  529. package/node_modules/@noble/hashes/hmac.js +91 -0
  530. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  531. package/node_modules/@noble/hashes/index.d.ts +1 -0
  532. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  533. package/node_modules/@noble/hashes/index.js +33 -0
  534. package/node_modules/@noble/hashes/index.js.map +1 -0
  535. package/node_modules/@noble/hashes/legacy.d.ts +71 -0
  536. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  537. package/node_modules/@noble/hashes/legacy.js +287 -0
  538. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  539. package/node_modules/@noble/hashes/package.json +266 -0
  540. package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
  541. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  542. package/node_modules/@noble/hashes/pbkdf2.js +101 -0
  543. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  544. package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
  545. package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
  546. package/node_modules/@noble/hashes/ripemd160.js +16 -0
  547. package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
  548. package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
  549. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  550. package/node_modules/@noble/hashes/scrypt.js +232 -0
  551. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  552. package/node_modules/@noble/hashes/sha1.d.ts +11 -0
  553. package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
  554. package/node_modules/@noble/hashes/sha1.js +14 -0
  555. package/node_modules/@noble/hashes/sha1.js.map +1 -0
  556. package/node_modules/@noble/hashes/sha2.d.ts +159 -0
  557. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  558. package/node_modules/@noble/hashes/sha2.js +384 -0
  559. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  560. package/node_modules/@noble/hashes/sha256.d.ts +20 -0
  561. package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
  562. package/node_modules/@noble/hashes/sha256.js +23 -0
  563. package/node_modules/@noble/hashes/sha256.js.map +1 -0
  564. package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
  565. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  566. package/node_modules/@noble/hashes/sha3-addons.js +402 -0
  567. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  568. package/node_modules/@noble/hashes/sha3.d.ts +53 -0
  569. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  570. package/node_modules/@noble/hashes/sha3.js +239 -0
  571. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  572. package/node_modules/@noble/hashes/sha512.d.ts +26 -0
  573. package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
  574. package/node_modules/@noble/hashes/sha512.js +29 -0
  575. package/node_modules/@noble/hashes/sha512.js.map +1 -0
  576. package/node_modules/@noble/hashes/src/_assert.ts +22 -0
  577. package/node_modules/@noble/hashes/src/_blake.ts +50 -0
  578. package/node_modules/@noble/hashes/src/_md.ts +176 -0
  579. package/node_modules/@noble/hashes/src/_u64.ts +91 -0
  580. package/node_modules/@noble/hashes/src/argon2.ts +497 -0
  581. package/node_modules/@noble/hashes/src/blake1.ts +534 -0
  582. package/node_modules/@noble/hashes/src/blake2.ts +486 -0
  583. package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
  584. package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
  585. package/node_modules/@noble/hashes/src/blake3.ts +272 -0
  586. package/node_modules/@noble/hashes/src/crypto.ts +9 -0
  587. package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
  588. package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
  589. package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
  590. package/node_modules/@noble/hashes/src/hmac.ts +94 -0
  591. package/node_modules/@noble/hashes/src/index.ts +31 -0
  592. package/node_modules/@noble/hashes/src/legacy.ts +293 -0
  593. package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
  594. package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
  595. package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
  596. package/node_modules/@noble/hashes/src/sha1.ts +10 -0
  597. package/node_modules/@noble/hashes/src/sha2.ts +402 -0
  598. package/node_modules/@noble/hashes/src/sha256.ts +24 -0
  599. package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
  600. package/node_modules/@noble/hashes/src/sha3.ts +258 -0
  601. package/node_modules/@noble/hashes/src/sha512.ts +34 -0
  602. package/node_modules/@noble/hashes/src/utils.ts +395 -0
  603. package/node_modules/@noble/hashes/utils.d.ts +161 -0
  604. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  605. package/node_modules/@noble/hashes/utils.js +313 -0
  606. package/node_modules/@noble/hashes/utils.js.map +1 -0
  607. package/package.json +203 -0
  608. package/schemas/catalog.schema.json +360 -0
  609. package/src/align.ts +239 -0
  610. package/src/audio-init-parser.ts +189 -0
  611. package/src/audio-ring-buffer.ts +120 -0
  612. package/src/authored-timing.ts +63 -0
  613. package/src/carp-catalog.ts +845 -0
  614. package/src/catalog-fec-params.ts +535 -0
  615. package/src/catalog-network-source.ts +49 -0
  616. package/src/catalog-validator.ts +34 -0
  617. package/src/cmaf-block-assembler.ts +1167 -0
  618. package/src/cmaf-group-batcher.ts +104 -0
  619. package/src/cmcd-producer.ts +334 -0
  620. package/src/codec-utils.ts +1611 -0
  621. package/src/fec-codec.ts +61 -0
  622. package/src/fec-manager.ts +2081 -0
  623. package/src/fec-starvation-detector.ts +128 -0
  624. package/src/fec-worker-setup.ts +213 -0
  625. package/src/fmp4-completion.ts +47 -0
  626. package/src/fmp4-reader.ts +112 -0
  627. package/src/index.ts +486 -0
  628. package/src/iso-bmff-timing.ts +813 -0
  629. package/src/loc.ts +181 -0
  630. package/src/manifest-auth-plan.ts +107 -0
  631. package/src/media-router.ts +795 -0
  632. package/src/mfu-reassembler.ts +3741 -0
  633. package/src/mfu-reassembly-policy.ts +134 -0
  634. package/src/mmtp-container-parser.ts +1836 -0
  635. package/src/mmtp-decode-pipeline.ts +389 -0
  636. package/src/mmtp-router.ts +3136 -0
  637. package/src/mmtp-to-cmaf.ts +1024 -0
  638. package/src/multicast-auth-catalog.ts +340 -0
  639. package/src/multicast-input.ts +439 -0
  640. package/src/multicast-manager.ts +1720 -0
  641. package/src/multicast-transport.ts +321 -0
  642. package/src/multicast-unwrap.ts +132 -0
  643. package/src/no-modules.ts +20 -0
  644. package/src/phase14-catalog-override.ts +336 -0
  645. package/src/repair-fetch.ts +238 -0
  646. package/src/repair-layers.ts +490 -0
  647. package/src/sample-combiner.ts +938 -0
  648. package/src/signaling.ts +78 -0
  649. package/src/source-auth.ts +1 -0
  650. package/src/switching-set-alignment.ts +109 -0
  651. package/src/timestamp-codec.ts +265 -0
  652. package/src/track-pipeline-setup.ts +189 -0
  653. package/src/track-pipeline.ts +332 -0
  654. package/src/track-session.ts +994 -0
  655. package/src/transport-pool.ts +128 -0
  656. package/src/wasm-mfu-reassembler.ts +389 -0
  657. package/src/wasm-mmtp-container-parser.ts +23 -0
  658. package/test-vectors/align.json +199 -0
  659. package/test-vectors/catalog/README.md +40 -0
  660. package/test-vectors/catalog/negative/fec-enhancement-repair-removed.json +27 -0
  661. package/test-vectors/catalog/negative/fec-repair-layer-geometry.json +32 -0
  662. package/test-vectors/catalog/negative/fec-repair-layer-missing-symbols.json +30 -0
  663. package/test-vectors/catalog/negative/fec-repair-multiple-depends.json +31 -0
  664. package/test-vectors/catalog/negative/fec-repair-overlay-with-layer.json +33 -0
  665. package/test-vectors/catalog/negative/fec-repair-priority-out-of-band.json +23 -0
  666. package/test-vectors/catalog/negative/fec-repair-source-symbols-without-scope.json +32 -0
  667. package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
  668. package/test-vectors/catalog/negative/media-track-repair-layer.json +16 -0
  669. package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
  670. package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
  671. package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
  672. package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
  673. package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
  674. package/test-vectors/catalog/negative/network-source-object.json +25 -0
  675. package/test-vectors/catalog/negative/raptorq-source-symbols-over-max.json +23 -0
  676. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +26 -0
  677. package/test-vectors/catalog/negative/repair-track-legacy-shape.json +19 -0
  678. package/test-vectors/catalog/negative/track-role-empty.json +16 -0
  679. package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
  680. package/test-vectors/catalog/positive/fec-layered-repair.json +104 -0
  681. package/test-vectors/catalog/positive/fec-multicast.json +51 -0
  682. package/test-vectors/catalog/positive/flat-av.json +30 -0
  683. package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
  684. package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
  685. package/test-vectors/catalog/positive/track-role.json +49 -0
  686. package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
  687. package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
  688. package/test-vectors/catalog-multicast-auth-v1.json +26 -0
  689. package/test-vectors/catalog-validation.json +148 -0
  690. package/test-vectors/catalog-validator-public-api.mjs +25 -0
  691. package/test-vectors/generate-source-auth-fixture.mjs +114 -0
  692. package/test-vectors/source-auth-v1.json +61 -0
  693. package/test-vectors/source-contiguity-v1.json +131 -0
  694. package/test-vectors/subsample-placement-v1.json +230 -0
@@ -0,0 +1,1665 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
+ var __privateWrapper = (obj, member, setter, getter) => ({
13
+ set _(value) {
14
+ __privateSet(obj, member, value, setter);
15
+ },
16
+ get _() {
17
+ return __privateGet(obj, member, getter);
18
+ }
19
+ });
20
+
21
+ // node_modules/@blockcast/mmt-transport/dist/types.js
22
+ var MoqFecAlgorithm;
23
+ (function(MoqFecAlgorithm2) {
24
+ MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
25
+ MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
26
+ MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
27
+ })(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
28
+
29
+ // node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
30
+ var DRIADDiscovery = class {
31
+ constructor() {
32
+ __publicField(this, "cache", /* @__PURE__ */ new Map());
33
+ __publicField(this, "cacheExpiry", 3e5);
34
+ }
35
+ // 5 minutes
36
+ /**
37
+ * Discover AMT relays for a multicast source address (RFC 8777)
38
+ *
39
+ * @param source - The multicast source IP address (NOT the group!)
40
+ * @returns Array of discovered AMT relays that can tunnel traffic from this source
41
+ */
42
+ async discoverRelays(source) {
43
+ const cached = this.cache.get(source);
44
+ if (cached) {
45
+ return cached;
46
+ }
47
+ try {
48
+ const reversedSource = source.split(".").reverse().join(".");
49
+ const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
50
+ console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
51
+ const relays = await this.queryDRIADProxy(source);
52
+ if (relays.length > 0) {
53
+ this.cache.set(source, relays);
54
+ setTimeout(() => this.cache.delete(source), this.cacheExpiry);
55
+ }
56
+ return relays;
57
+ } catch (error) {
58
+ console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
59
+ return [];
60
+ }
61
+ }
62
+ /**
63
+ * Query DRIAD proxy service (browser-compatible)
64
+ */
65
+ async queryDRIADProxy(source) {
66
+ const proxyEndpoints = [
67
+ "https://driad.amt.net/api/v1/relays",
68
+ "https://multicast-gateway.cloudflare.com/driad"
69
+ ];
70
+ for (const endpoint of proxyEndpoints) {
71
+ try {
72
+ const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
73
+ method: "GET",
74
+ headers: { Accept: "application/json" },
75
+ signal: AbortSignal.timeout(5e3)
76
+ });
77
+ if (response.ok) {
78
+ const data = await response.json();
79
+ return data.relays || [];
80
+ }
81
+ } catch {
82
+ }
83
+ }
84
+ const dohRelay = await this.queryDNSOverHTTPS(source);
85
+ if (dohRelay) {
86
+ return [dohRelay];
87
+ }
88
+ return [];
89
+ }
90
+ /**
91
+ * Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
92
+ */
93
+ async queryDNSOverHTTPS(source) {
94
+ try {
95
+ const reversedSource = source.split(".").reverse().join(".");
96
+ const queryName = `${reversedSource}.amt.in-addr.arpa`;
97
+ const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
98
+ const response = await fetch(dohUrl, {
99
+ headers: { Accept: "application/dns-json" },
100
+ signal: AbortSignal.timeout(3e3)
101
+ });
102
+ if (!response.ok) {
103
+ return null;
104
+ }
105
+ const result = await response.json();
106
+ if (result.Answer && result.Answer.length > 0) {
107
+ return {
108
+ host: result.Answer[0].data,
109
+ port: 2268,
110
+ priority: 10,
111
+ weight: 100,
112
+ asn: 0
113
+ };
114
+ }
115
+ return null;
116
+ } catch (error) {
117
+ console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
118
+ return null;
119
+ }
120
+ }
121
+ /**
122
+ * Select best relay based on RTT measurements
123
+ */
124
+ async selectBestRelay(relays) {
125
+ if (relays.length === 0)
126
+ return null;
127
+ const measured = await Promise.all(relays.map(async (relay) => {
128
+ const rtt = await this.measureRTT(relay.host, relay.port);
129
+ return { ...relay, rtt };
130
+ }));
131
+ measured.sort((a, b) => {
132
+ if (a.priority !== b.priority)
133
+ return a.priority - b.priority;
134
+ return (a.rtt || Infinity) - (b.rtt || Infinity);
135
+ });
136
+ console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
137
+ return measured[0];
138
+ }
139
+ async measureRTT(host, _port) {
140
+ const start = performance.now();
141
+ try {
142
+ await fetch(`https://${host}/health`, {
143
+ method: "HEAD",
144
+ signal: AbortSignal.timeout(2e3),
145
+ mode: "no-cors"
146
+ });
147
+ return performance.now() - start;
148
+ } catch {
149
+ return Infinity;
150
+ }
151
+ }
152
+ /**
153
+ * Clear the relay cache
154
+ */
155
+ clearCache() {
156
+ this.cache.clear();
157
+ }
158
+ /**
159
+ * Get cached relays for a source address
160
+ */
161
+ getCached(source) {
162
+ return this.cache.get(source);
163
+ }
164
+ };
165
+ var driadDiscovery = new DRIADDiscovery();
166
+
167
+ // node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
168
+ function endpointKey(endpoint) {
169
+ return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
170
+ }
171
+ function carriesMedia(endpoint) {
172
+ return endpoint.carriesMedia !== false;
173
+ }
174
+ function selectMulticastTier(endpoints, estimate) {
175
+ const media = endpoints.filter(carriesMedia);
176
+ if (media.length <= 1)
177
+ return media[0];
178
+ const ranked = media.filter((endpoint) => typeof endpoint.bandwidth === "number" && endpoint.bandwidth > 0).sort((a, b) => a.bandwidth - b.bandwidth);
179
+ if (ranked.length < 2)
180
+ return media[0];
181
+ if (estimate === void 0)
182
+ return ranked[0];
183
+ const budget = estimate * 0.8;
184
+ let selected;
185
+ for (const endpoint of ranked) {
186
+ if (endpoint.bandwidth <= budget)
187
+ selected = endpoint;
188
+ }
189
+ return selected ?? ranked[0];
190
+ }
191
+
192
+ // node_modules/@blockcast/mmt-transport/dist/abr-controller.js
193
+ var QUALITY_LEVELS = [
194
+ { name: "240p", bitrate: 3e5, width: 426, height: 240, fps: 15 },
195
+ { name: "360p", bitrate: 5e5, width: 640, height: 360, fps: 24 },
196
+ { name: "480p", bitrate: 1e6, width: 854, height: 480, fps: 30 },
197
+ { name: "720p", bitrate: 25e5, width: 1280, height: 720, fps: 30 },
198
+ { name: "1080p", bitrate: 5e6, width: 1920, height: 1080, fps: 30 },
199
+ { name: "1440p", bitrate: 8e6, width: 2560, height: 1440, fps: 30 },
200
+ { name: "4K", bitrate: 15e6, width: 3840, height: 2160, fps: 30 }
201
+ ];
202
+ var AdaptiveBitrateController = class {
203
+ constructor(initialQuality) {
204
+ __publicField(this, "currentQualityIndex");
205
+ __publicField(this, "history", []);
206
+ __publicField(this, "historyWindow", 1e4);
207
+ // 10 second window
208
+ __publicField(this, "upgradeThreshold", 0.8);
209
+ // 80% of target bitrate sustained
210
+ __publicField(this, "downgradeThreshold", 0.5);
211
+ // 50% of target bitrate triggers downgrade
212
+ __publicField(this, "stabilityPeriod", 5e3);
213
+ // Wait 5s before upgrading
214
+ __publicField(this, "lastQualityChange", 0);
215
+ __publicField(this, "onQualityChange");
216
+ // FEC stats for effective loss rate calculation
217
+ __publicField(this, "fecStats", {
218
+ rawLossRate: 0,
219
+ effectiveLossRate: 0,
220
+ recoveryRate: 1,
221
+ fecEnabled: false
222
+ });
223
+ this.currentQualityIndex = initialQuality ? QUALITY_LEVELS.findIndex((q) => q.name === initialQuality.name) : 0;
224
+ if (this.currentQualityIndex < 0)
225
+ this.currentQualityIndex = 0;
226
+ }
227
+ setCallback(callback) {
228
+ this.onQualityChange = callback;
229
+ }
230
+ getCurrentQuality() {
231
+ return QUALITY_LEVELS[this.currentQualityIndex];
232
+ }
233
+ /** Selects the multicast (S,G) tier without replacing a player's unicast ABR manager. */
234
+ selectMulticastTier(endpoints, estimate = this.getMetrics().measuredBitrate || void 0) {
235
+ return selectMulticastTier(endpoints, estimate);
236
+ }
237
+ /**
238
+ * Record network sample for bitrate adaptation
239
+ *
240
+ * @param bytesReceived - Bytes received in this sample
241
+ * @param packetsLost - Packets lost (raw, before FEC recovery)
242
+ */
243
+ recordSample(bytesReceived, packetsLost) {
244
+ const now = Date.now();
245
+ this.history.push({ timestamp: now, bytesReceived, packetsLost });
246
+ this.history = this.history.filter((s) => now - s.timestamp < this.historyWindow);
247
+ const { measuredBitrate, lossRate: rawLossRate } = this.calculateMetrics();
248
+ const currentQuality = this.getCurrentQuality();
249
+ const effectiveLossRate = this.fecStats.fecEnabled ? this.fecStats.effectiveLossRate : rawLossRate;
250
+ if (now - this.lastQualityChange < this.stabilityPeriod) {
251
+ return;
252
+ }
253
+ if (effectiveLossRate > 0.05 || measuredBitrate < currentQuality.bitrate * this.downgradeThreshold) {
254
+ this.downgrade();
255
+ return;
256
+ }
257
+ if (measuredBitrate > currentQuality.bitrate * this.upgradeThreshold && effectiveLossRate < 0.01 && this.currentQualityIndex < QUALITY_LEVELS.length - 1) {
258
+ this.upgrade();
259
+ }
260
+ }
261
+ /**
262
+ * Update FEC statistics for ABR decisions
263
+ *
264
+ * Per draft-ramadan-moq-fec-00, ABR should use the effective loss rate
265
+ * (after FEC recovery) rather than raw transport loss rate.
266
+ *
267
+ * @param stats - FEC statistics from the FEC decoder
268
+ */
269
+ setFecStats(stats) {
270
+ this.fecStats = stats;
271
+ }
272
+ /**
273
+ * Get current FEC statistics
274
+ */
275
+ getFecStats() {
276
+ return { ...this.fecStats };
277
+ }
278
+ calculateMetrics() {
279
+ if (this.history.length < 2) {
280
+ return { measuredBitrate: 0, lossRate: 0 };
281
+ }
282
+ const totalBytes = this.history.reduce((sum, s) => sum + s.bytesReceived, 0);
283
+ const totalLost = this.history.reduce((sum, s) => sum + s.packetsLost, 0);
284
+ const duration = (this.history[this.history.length - 1].timestamp - this.history[0].timestamp) / 1e3;
285
+ const measuredBitrate = duration > 0 ? totalBytes * 8 / duration : 0;
286
+ const lossRate = totalLost / (this.history.length + totalLost);
287
+ return { measuredBitrate, lossRate };
288
+ }
289
+ upgrade() {
290
+ if (this.currentQualityIndex >= QUALITY_LEVELS.length - 1)
291
+ return;
292
+ this.currentQualityIndex++;
293
+ this.lastQualityChange = Date.now();
294
+ const newQuality = this.getCurrentQuality();
295
+ console.log(`[ABR] Upgrading to ${newQuality.name} (${newQuality.bitrate / 1e6}Mbps)`);
296
+ this.onQualityChange?.(newQuality);
297
+ }
298
+ downgrade() {
299
+ if (this.currentQualityIndex <= 0)
300
+ return;
301
+ this.currentQualityIndex--;
302
+ this.lastQualityChange = Date.now();
303
+ const newQuality = this.getCurrentQuality();
304
+ console.log(`[ABR] Downgrading to ${newQuality.name} (${newQuality.bitrate / 1e6}Mbps)`);
305
+ this.onQualityChange?.(newQuality);
306
+ }
307
+ /**
308
+ * Force quality level (for testing)
309
+ */
310
+ setQuality(name) {
311
+ const index = QUALITY_LEVELS.findIndex((q) => q.name === name);
312
+ if (index >= 0) {
313
+ this.currentQualityIndex = index;
314
+ this.lastQualityChange = Date.now();
315
+ this.onQualityChange?.(this.getCurrentQuality());
316
+ }
317
+ }
318
+ /**
319
+ * Get current metrics including both raw and effective loss rates
320
+ */
321
+ getMetrics() {
322
+ const { measuredBitrate, lossRate: rawLossRate } = this.calculateMetrics();
323
+ return {
324
+ measuredBitrate,
325
+ rawLossRate,
326
+ effectiveLossRate: this.fecStats.fecEnabled ? this.fecStats.effectiveLossRate : rawLossRate,
327
+ fecEnabled: this.fecStats.fecEnabled,
328
+ sampleCount: this.history.length
329
+ };
330
+ }
331
+ /**
332
+ * Reset history and start fresh
333
+ */
334
+ reset() {
335
+ this.history = [];
336
+ this.lastQualityChange = 0;
337
+ }
338
+ };
339
+
340
+ // node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
341
+ var DEFAULT_DWELL_MS = 3e3;
342
+ var DEFAULT_JOIN_DEADLINE_MS = 5e3;
343
+ var _state, _current, _target, _estimate, _favored, _joinStartedAt, _lastCommittedTimestamp, _dwellMs, _joinDeadlineMs, _MulticastOrchestrator_instances, now_fn;
344
+ var MulticastOrchestrator = class {
345
+ constructor(options) {
346
+ __privateAdd(this, _MulticastOrchestrator_instances);
347
+ __publicField(this, "options");
348
+ __privateAdd(this, _state, "stable");
349
+ __privateAdd(this, _current);
350
+ __privateAdd(this, _target);
351
+ __privateAdd(this, _estimate);
352
+ __privateAdd(this, _favored);
353
+ __privateAdd(this, _joinStartedAt, 0);
354
+ __privateAdd(this, _lastCommittedTimestamp, Number.NEGATIVE_INFINITY);
355
+ __privateAdd(this, _dwellMs);
356
+ __privateAdd(this, _joinDeadlineMs);
357
+ this.options = options;
358
+ __privateSet(this, _dwellMs, options.dwellMs ?? DEFAULT_DWELL_MS);
359
+ __privateSet(this, _joinDeadlineMs, options.joinDeadlineMs ?? DEFAULT_JOIN_DEADLINE_MS);
360
+ if (!Number.isFinite(__privateGet(this, _dwellMs)) || !Number.isFinite(__privateGet(this, _joinDeadlineMs)) || __privateGet(this, _dwellMs) <= 0 || __privateGet(this, _joinDeadlineMs) <= 0) {
361
+ throw new Error("Multicast dwell and join deadline must be positive");
362
+ }
363
+ }
364
+ get state() {
365
+ return __privateGet(this, _state);
366
+ }
367
+ get current() {
368
+ return __privateGet(this, _current);
369
+ }
370
+ get target() {
371
+ return __privateGet(this, _target);
372
+ }
373
+ get estimate() {
374
+ return __privateGet(this, _estimate);
375
+ }
376
+ start() {
377
+ __privateGet(this, _current) ?? __privateSet(this, _current, this.options.initialEndpoint ?? selectMulticastTier(this.options.endpoints, void 0));
378
+ return __privateGet(this, _current);
379
+ }
380
+ onGoodput(sample) {
381
+ const bitrate = sample.bitrate;
382
+ if (!__privateGet(this, _current) || this.options.adaptive === false)
383
+ return void 0;
384
+ if (__privateGet(this, _state) === "joining")
385
+ return this.poll();
386
+ if (bitrate === void 0 || !Number.isFinite(bitrate))
387
+ return void 0;
388
+ __privateSet(this, _estimate, bitrate);
389
+ const desired = selectMulticastTier(this.options.endpoints, bitrate);
390
+ if (!desired)
391
+ return void 0;
392
+ const desiredKey = endpointKey(desired);
393
+ if (desiredKey === endpointKey(__privateGet(this, _current))) {
394
+ if (__privateGet(this, _favored)?.source === "goodput")
395
+ __privateSet(this, _favored, void 0);
396
+ return void 0;
397
+ }
398
+ if (typeof desired.bandwidth !== "number" || typeof __privateGet(this, _current).bandwidth !== "number" || desired.bandwidth >= __privateGet(this, _current).bandwidth) {
399
+ if (__privateGet(this, _favored)?.source === "goodput")
400
+ __privateSet(this, _favored, void 0);
401
+ return void 0;
402
+ }
403
+ const now = __privateMethod(this, _MulticastOrchestrator_instances, now_fn).call(this);
404
+ if (!__privateGet(this, _favored) || __privateGet(this, _favored).key !== desiredKey || __privateGet(this, _favored).source !== "goodput") {
405
+ __privateSet(this, _favored, { key: desiredKey, since: now, source: "goodput" });
406
+ return void 0;
407
+ }
408
+ if (now - __privateGet(this, _favored).since < __privateGet(this, _dwellMs))
409
+ return void 0;
410
+ __privateSet(this, _state, "joining");
411
+ __privateSet(this, _target, desired);
412
+ __privateSet(this, _joinStartedAt, now);
413
+ __privateSet(this, _favored, void 0);
414
+ return { kind: "join-target", current: __privateGet(this, _current), target: desired };
415
+ }
416
+ onHeadroom(sample) {
417
+ if (!__privateGet(this, _current) || this.options.adaptive === false || __privateGet(this, _state) === "joining")
418
+ return void 0;
419
+ if (!sample.healthy) {
420
+ if (__privateGet(this, _favored)?.source === "headroom")
421
+ __privateSet(this, _favored, void 0);
422
+ return void 0;
423
+ }
424
+ if (__privateGet(this, _favored)?.source === "goodput")
425
+ return void 0;
426
+ const currentBandwidth = __privateGet(this, _current).bandwidth;
427
+ if (typeof currentBandwidth !== "number")
428
+ return void 0;
429
+ const desired = this.options.endpoints.filter((endpoint) => carriesMedia(endpoint) && typeof endpoint.bandwidth === "number" && endpoint.bandwidth > currentBandwidth).sort((a, b) => a.bandwidth - b.bandwidth)[0];
430
+ if (!desired) {
431
+ __privateSet(this, _favored, void 0);
432
+ return void 0;
433
+ }
434
+ const desiredKey = endpointKey(desired);
435
+ if (desiredKey === endpointKey(__privateGet(this, _current))) {
436
+ __privateSet(this, _favored, void 0);
437
+ return void 0;
438
+ }
439
+ const now = __privateMethod(this, _MulticastOrchestrator_instances, now_fn).call(this);
440
+ if (!__privateGet(this, _favored) || __privateGet(this, _favored).key !== desiredKey) {
441
+ __privateSet(this, _favored, { key: desiredKey, since: now, source: "headroom" });
442
+ return void 0;
443
+ }
444
+ if (now - __privateGet(this, _favored).since < __privateGet(this, _dwellMs))
445
+ return void 0;
446
+ __privateSet(this, _state, "joining");
447
+ __privateSet(this, _target, desired);
448
+ __privateSet(this, _joinStartedAt, now);
449
+ __privateSet(this, _favored, void 0);
450
+ return { kind: "join-target", current: __privateGet(this, _current), target: desired };
451
+ }
452
+ onTierPacket(packet) {
453
+ if (!__privateGet(this, _current))
454
+ return void 0;
455
+ if (packet.endpointKey === endpointKey(__privateGet(this, _current)) && Number.isFinite(packet.timestamp)) {
456
+ __privateSet(this, _lastCommittedTimestamp, Math.max(__privateGet(this, _lastCommittedTimestamp), packet.timestamp));
457
+ }
458
+ if (__privateGet(this, _state) !== "joining" || !__privateGet(this, _target))
459
+ return void 0;
460
+ const expired = this.poll();
461
+ if (expired)
462
+ return expired;
463
+ if (packet.endpointKey !== endpointKey(__privateGet(this, _target)) || !packet.keyframe || !packet.hasValidCodecConfig || !Number.isFinite(packet.timestamp) || packet.timestamp < __privateGet(this, _lastCommittedTimestamp))
464
+ return void 0;
465
+ const command = {
466
+ kind: "commit-swap",
467
+ target: __privateGet(this, _target),
468
+ old: __privateGet(this, _current)
469
+ };
470
+ __privateSet(this, _lastCommittedTimestamp, packet.timestamp);
471
+ __privateSet(this, _current, __privateGet(this, _target));
472
+ __privateSet(this, _target, void 0);
473
+ __privateSet(this, _state, "stable");
474
+ return command;
475
+ }
476
+ poll() {
477
+ if (__privateGet(this, _state) !== "joining" || !__privateGet(this, _target) || !__privateGet(this, _current))
478
+ return void 0;
479
+ if (__privateMethod(this, _MulticastOrchestrator_instances, now_fn).call(this) - __privateGet(this, _joinStartedAt) < __privateGet(this, _joinDeadlineMs))
480
+ return void 0;
481
+ return this.cancel();
482
+ }
483
+ cancel() {
484
+ if (__privateGet(this, _state) !== "joining" || !__privateGet(this, _target) || !__privateGet(this, _current))
485
+ return void 0;
486
+ const command = {
487
+ kind: "abandon-join",
488
+ current: __privateGet(this, _current),
489
+ target: __privateGet(this, _target)
490
+ };
491
+ __privateSet(this, _target, void 0);
492
+ __privateSet(this, _state, "stable");
493
+ return command;
494
+ }
495
+ };
496
+ _state = new WeakMap();
497
+ _current = new WeakMap();
498
+ _target = new WeakMap();
499
+ _estimate = new WeakMap();
500
+ _favored = new WeakMap();
501
+ _joinStartedAt = new WeakMap();
502
+ _lastCommittedTimestamp = new WeakMap();
503
+ _dwellMs = new WeakMap();
504
+ _joinDeadlineMs = new WeakMap();
505
+ _MulticastOrchestrator_instances = new WeakSet();
506
+ now_fn = function() {
507
+ const now = this.options.now();
508
+ if (!Number.isFinite(now))
509
+ throw new Error("Multicast orchestrator clock must be finite");
510
+ return now;
511
+ };
512
+
513
+ // node_modules/@blockcast/mmt-transport/dist/endpoint-config.js
514
+ function toWindowMulticastSubscribeConfig(input) {
515
+ if (input.mode !== void 0 && !["auto", "native", "tunnel"].includes(input.mode)) {
516
+ throw new TypeError(`Unsupported multicast mode: ${String(input.mode)}`);
517
+ }
518
+ const base = {
519
+ group: input.group,
520
+ port: input.port,
521
+ ...input.source?.trim() ? { source: input.source.trim() } : {},
522
+ consume: "bytes",
523
+ ...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
524
+ };
525
+ const relay = input.amtRelay?.trim();
526
+ const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && relay !== void 0 && relay !== "";
527
+ if (!wantsAmt) {
528
+ const native = {
529
+ ...base,
530
+ origin: "ip-multicast",
531
+ ...input.tracks?.length ? { tracks: input.tracks.map(({ name, packetId }) => ({ name, packetId })) } : {}
532
+ };
533
+ return native;
534
+ }
535
+ const relayPort = input.amtRelayPort;
536
+ if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
537
+ throw new TypeError("AMT requires a resolved relay and a valid relay port");
538
+ }
539
+ return {
540
+ ...base,
541
+ origin: "amt",
542
+ relay,
543
+ relayPort
544
+ };
545
+ }
546
+ function isValidMulticastGroupAddress(address) {
547
+ const value = address?.trim().toLowerCase();
548
+ if (!value)
549
+ return false;
550
+ if (value.startsWith("ff"))
551
+ return isValidIpv6MulticastAddress(value);
552
+ const parts = value.split(".");
553
+ if (parts.length !== 4)
554
+ return false;
555
+ const octets = parts.map((part) => {
556
+ if (!/^\d+$/.test(part))
557
+ return Number.NaN;
558
+ const octet = Number(part);
559
+ return Number.isInteger(octet) && octet >= 0 && octet <= 255 ? octet : Number.NaN;
560
+ });
561
+ return octets.every(Number.isInteger) && octets[0] >= 224 && octets[0] <= 239;
562
+ }
563
+ function normalizeMulticastEndpoint(endpoint) {
564
+ const groupAddress = endpoint.groupAddress.trim().toLowerCase();
565
+ const sourceAddress = endpoint.sourceAddress?.trim().toLowerCase() || void 0;
566
+ const amtRelay = endpoint.amtRelay?.trim().toLowerCase() || void 0;
567
+ if (!isValidMulticastGroupAddress(groupAddress) || !isPositivePort(endpoint.port))
568
+ return void 0;
569
+ if (endpoint.mode && !["auto", "native", "tunnel"].includes(endpoint.mode))
570
+ return void 0;
571
+ if (endpoint.amtRelayPort !== void 0 && !isPositivePort(endpoint.amtRelayPort))
572
+ return void 0;
573
+ return {
574
+ groupAddress,
575
+ ...sourceAddress ? { sourceAddress } : {},
576
+ port: endpoint.port,
577
+ ...endpoint.mode ? { mode: endpoint.mode } : {},
578
+ ...amtRelay ? { amtRelay } : {},
579
+ ...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
580
+ };
581
+ }
582
+ function multicastEndpointKey(endpoint) {
583
+ const normalized = normalizeMulticastEndpoint(endpoint);
584
+ if (!normalized)
585
+ throw new Error("Invalid multicast endpoint");
586
+ return JSON.stringify([
587
+ normalized.sourceAddress ?? "",
588
+ normalized.groupAddress,
589
+ normalized.port,
590
+ normalized.mode ?? "auto",
591
+ normalized.amtRelay ?? "",
592
+ normalized.amtRelayPort ?? ""
593
+ ]);
594
+ }
595
+ function isValidIpv6MulticastAddress(value) {
596
+ if (!/^[0-9a-f:]+$/.test(value))
597
+ return false;
598
+ const compressed = value.includes("::");
599
+ if (value.indexOf("::") !== value.lastIndexOf("::"))
600
+ return false;
601
+ const groups = value.split(":").filter(Boolean);
602
+ if (groups.length === 0 || groups.length > 8)
603
+ return false;
604
+ if (!compressed && groups.length !== 8)
605
+ return false;
606
+ return groups.every((group) => /^[0-9a-f]{1,4}$/.test(group));
607
+ }
608
+ function isPositivePort(port) {
609
+ return Number.isInteger(port) && port > 0 && port <= 65535;
610
+ }
611
+
612
+ // node_modules/@blockcast/mmt-transport/dist/multicast-subscription-pool.js
613
+ var _entries, _gatewayIds, _nextGatewayId, _MulticastSubscriptionPool_instances, createEntry_fn, gatewayId_fn, detach_fn, dispatch_fn;
614
+ var MulticastSubscriptionPool = class {
615
+ constructor() {
616
+ __privateAdd(this, _MulticastSubscriptionPool_instances);
617
+ __privateAdd(this, _entries, /* @__PURE__ */ new Map());
618
+ __privateAdd(this, _gatewayIds, /* @__PURE__ */ new WeakMap());
619
+ __privateAdd(this, _nextGatewayId, 1);
620
+ }
621
+ async acquire(gateway, config, consumer) {
622
+ const endpoint = normalizeMulticastEndpoint({
623
+ groupAddress: config.group,
624
+ sourceAddress: config.source,
625
+ port: config.port,
626
+ mode: config.mode,
627
+ amtRelay: config.amtRelay,
628
+ amtRelayPort: config.amtRelayPort
629
+ });
630
+ if (!endpoint)
631
+ throw new Error("Invalid multicast endpoint");
632
+ if (typeof gateway.subscribe !== "function")
633
+ throw new Error("window.multicast.subscribe unavailable");
634
+ const key = multicastEndpointKey(endpoint);
635
+ const internalKey = `${__privateMethod(this, _MulticastSubscriptionPool_instances, gatewayId_fn).call(this, gateway)}|${key}`;
636
+ let record = __privateGet(this, _entries).get(internalKey);
637
+ if (!record) {
638
+ record = { claims: 0, entry: Promise.resolve(null) };
639
+ const createdRecord = record;
640
+ record.entry = __privateMethod(this, _MulticastSubscriptionPool_instances, createEntry_fn).call(this, gateway, endpoint, (entry2) => {
641
+ if (__privateGet(this, _entries).get(internalKey) === createdRecord)
642
+ __privateGet(this, _entries).delete(internalKey);
643
+ __privateMethod(this, _MulticastSubscriptionPool_instances, detach_fn).call(this, entry2);
644
+ }).catch((error) => {
645
+ if (__privateGet(this, _entries).get(internalKey) === createdRecord)
646
+ __privateGet(this, _entries).delete(internalKey);
647
+ throw error;
648
+ });
649
+ __privateGet(this, _entries).set(internalKey, record);
650
+ }
651
+ record.claims++;
652
+ let entry;
653
+ try {
654
+ entry = await record.entry;
655
+ } catch (error) {
656
+ record.claims--;
657
+ throw error;
658
+ }
659
+ if (entry.closed) {
660
+ record.claims--;
661
+ return this.acquire(gateway, config, consumer);
662
+ }
663
+ const token = Symbol(key);
664
+ entry.consumers.set(token, consumer);
665
+ let released = false;
666
+ return {
667
+ key,
668
+ release: async () => {
669
+ if (released)
670
+ return;
671
+ released = true;
672
+ entry.consumers.delete(token);
673
+ record.claims--;
674
+ if (record.claims > 0)
675
+ return;
676
+ if (__privateGet(this, _entries).get(internalKey) === record)
677
+ __privateGet(this, _entries).delete(internalKey);
678
+ __privateMethod(this, _MulticastSubscriptionPool_instances, detach_fn).call(this, entry);
679
+ if (!entry.closed)
680
+ await entry.subscription.unsubscribe();
681
+ }
682
+ };
683
+ }
684
+ get size() {
685
+ return __privateGet(this, _entries).size;
686
+ }
687
+ };
688
+ _entries = new WeakMap();
689
+ _gatewayIds = new WeakMap();
690
+ _nextGatewayId = new WeakMap();
691
+ _MulticastSubscriptionPool_instances = new WeakSet();
692
+ createEntry_fn = async function(gateway, endpoint, onClosed) {
693
+ const subscription = await gateway.subscribe(toWindowMulticastSubscribeConfig({
694
+ group: endpoint.groupAddress,
695
+ ...endpoint.sourceAddress ? { source: endpoint.sourceAddress } : {},
696
+ port: endpoint.port,
697
+ ...endpoint.mode ? { mode: endpoint.mode } : {},
698
+ ...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
699
+ ...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
700
+ }));
701
+ const consumers = /* @__PURE__ */ new Map();
702
+ let entry;
703
+ const bytesListener = (event) => {
704
+ __privateMethod(this, _MulticastSubscriptionPool_instances, dispatch_fn).call(this, consumers, (consumer) => consumer.onBytes(event.detail));
705
+ };
706
+ const stateListener = (event) => {
707
+ __privateMethod(this, _MulticastSubscriptionPool_instances, dispatch_fn).call(this, consumers, (consumer) => consumer.onState?.(event.detail));
708
+ if (event.detail === "closed" && !entry.closed) {
709
+ entry.closed = true;
710
+ onClosed(entry);
711
+ }
712
+ };
713
+ const errorListener = (event) => {
714
+ const error = event.detail instanceof Error ? event.detail : new Error(String(event.detail));
715
+ __privateMethod(this, _MulticastSubscriptionPool_instances, dispatch_fn).call(this, consumers, (consumer) => consumer.onError?.(error));
716
+ };
717
+ entry = { subscription, consumers, bytesListener, stateListener, errorListener, closed: false };
718
+ subscription.addEventListener("bytes", bytesListener);
719
+ subscription.addEventListener("state", stateListener);
720
+ subscription.addEventListener("error", errorListener);
721
+ return entry;
722
+ };
723
+ gatewayId_fn = function(gateway) {
724
+ const object = gateway;
725
+ let id = __privateGet(this, _gatewayIds).get(object);
726
+ if (!id) {
727
+ id = __privateWrapper(this, _nextGatewayId)._++;
728
+ __privateGet(this, _gatewayIds).set(object, id);
729
+ }
730
+ return id;
731
+ };
732
+ detach_fn = function(entry) {
733
+ entry.subscription.removeEventListener("bytes", entry.bytesListener);
734
+ entry.subscription.removeEventListener("state", entry.stateListener);
735
+ entry.subscription.removeEventListener("error", entry.errorListener);
736
+ };
737
+ dispatch_fn = function(consumers, callback) {
738
+ for (const consumer of consumers.values()) {
739
+ try {
740
+ callback(consumer);
741
+ } catch (error) {
742
+ console.error("[Transport] multicast consumer callback failed", error);
743
+ }
744
+ }
745
+ };
746
+ var multicastSubscriptionPool = new MulticastSubscriptionPool();
747
+
748
+ // node_modules/@blockcast/mmt-transport/dist/transport-manager.js
749
+ var TransportManager = class {
750
+ constructor() {
751
+ __publicField(this, "state", {
752
+ mode: "disconnected",
753
+ connected: false,
754
+ packetsReceived: 0,
755
+ bytesReceived: 0,
756
+ lastPacketTime: 0
757
+ });
758
+ __publicField(this, "capabilities", null);
759
+ __publicField(this, "subscription", null);
760
+ __publicField(this, "driad", new DRIADDiscovery());
761
+ __publicField(this, "abr");
762
+ __publicField(this, "multicastOrchestrator", null);
763
+ __publicField(this, "onOrchestratorCommand");
764
+ __publicField(this, "connectionGeneration", 0);
765
+ __publicField(this, "onPacket");
766
+ __publicField(this, "onError");
767
+ __publicField(this, "onStateChange");
768
+ this.abr = new AdaptiveBitrateController();
769
+ }
770
+ getWindow() {
771
+ return typeof window === "undefined" ? void 0 : window;
772
+ }
773
+ getWindowMulticastGateway() {
774
+ return this.getWindow()?.multicast;
775
+ }
776
+ async getGatewayCapabilities(gateway) {
777
+ if (!gateway?.capabilities)
778
+ return void 0;
779
+ try {
780
+ return typeof gateway.capabilities === "function" ? await gateway.capabilities() : gateway.capabilities;
781
+ } catch (error) {
782
+ console.warn("[Transport] window.multicast capabilities failed:", error);
783
+ return void 0;
784
+ }
785
+ }
786
+ async gatewaySupportsBytes(gateway) {
787
+ if (typeof gateway?.subscribe !== "function")
788
+ return false;
789
+ if (!gateway.capabilities)
790
+ return true;
791
+ const capabilities = await this.getGatewayCapabilities(gateway);
792
+ if (!capabilities)
793
+ return false;
794
+ const consumeModes = capabilities.consumeModes;
795
+ return !consumeModes || consumeModes.includes("bytes");
796
+ }
797
+ /**
798
+ * Detect available transport capabilities
799
+ */
800
+ async detectCapabilities() {
801
+ if (this.capabilities)
802
+ return this.capabilities;
803
+ const gateway = this.getWindowMulticastGateway();
804
+ const hasGatewayBytes = await this.gatewaySupportsBytes(gateway);
805
+ const win = this.getWindow();
806
+ this.capabilities = {
807
+ nativeSSM: hasGatewayBytes,
808
+ nativeIGMP: hasGatewayBytes,
809
+ directSockets: typeof win?.UDPSocket !== "undefined",
810
+ amt: false,
811
+ driad: true,
812
+ // DRIAD uses HTTP proxy, always available
813
+ fecDecode: false
814
+ };
815
+ console.log("[Transport] Capabilities:", this.capabilities);
816
+ return this.capabilities;
817
+ }
818
+ /**
819
+ * Connect using best available transport
820
+ *
821
+ * Promotion hierarchy:
822
+ * 1. window.multicast gateway bytes
823
+ * 2. AMT proxy (specified or discovered via DRIAD)
824
+ * 3. MOQ WebTransport (final fallback)
825
+ */
826
+ async connect(config) {
827
+ const generation = ++this.connectionGeneration;
828
+ this.subscription?.close();
829
+ this.subscription = null;
830
+ this.state = {
831
+ mode: "disconnected",
832
+ connected: false,
833
+ packetsReceived: 0,
834
+ bytesReceived: 0,
835
+ lastPacketTime: 0
836
+ };
837
+ this.onStateChange?.(this.state);
838
+ const endpoint = normalizeMulticastEndpoint({
839
+ groupAddress: config.group,
840
+ sourceAddress: config.source,
841
+ port: config.port,
842
+ mode: config.mode,
843
+ amtRelay: config.amtRelay,
844
+ amtRelayPort: config.amtRelayPort
845
+ });
846
+ if (!endpoint) {
847
+ const error = new Error("Invalid multicast endpoint configuration");
848
+ this.onError?.(error);
849
+ return false;
850
+ }
851
+ config = {
852
+ ...config,
853
+ group: endpoint.groupAddress,
854
+ source: endpoint.sourceAddress ?? "",
855
+ mode: endpoint.mode,
856
+ amtRelay: endpoint.amtRelay,
857
+ amtRelayPort: endpoint.amtRelayPort
858
+ };
859
+ const caps = await this.detectCapabilities();
860
+ if (generation !== this.connectionGeneration)
861
+ return false;
862
+ if (config.initialQuality) {
863
+ this.abr = new AdaptiveBitrateController(config.initialQuality);
864
+ }
865
+ this.abr.setCallback((quality) => {
866
+ this.state.quality = quality;
867
+ this.subscription?.onqualitychange?.(quality);
868
+ this.onStateChange?.(this.state);
869
+ });
870
+ let connected = false;
871
+ if (caps.nativeSSM || caps.nativeIGMP) {
872
+ console.log("[Transport] Attempting window.multicast...");
873
+ connected = await this.connectWindowMulticast(config, generation);
874
+ if (connected) {
875
+ if (generation !== this.connectionGeneration)
876
+ return false;
877
+ this.state.mode = "multicast";
878
+ return true;
879
+ }
880
+ }
881
+ if (!connected) {
882
+ console.log("[Transport] Attempting AMT tunnel...");
883
+ connected = await this.connectAmt(config, generation);
884
+ if (connected) {
885
+ if (generation !== this.connectionGeneration)
886
+ return false;
887
+ this.state.mode = "amt";
888
+ return true;
889
+ }
890
+ }
891
+ console.log("[Transport] All multicast transports failed, falling back to MOQ");
892
+ return false;
893
+ }
894
+ /**
895
+ * Connect via the lowercase window.multicast bytes gateway.
896
+ */
897
+ async connectWindowMulticast(config, generation) {
898
+ try {
899
+ const gateway = this.getWindowMulticastGateway();
900
+ if (typeof gateway?.subscribe !== "function")
901
+ return false;
902
+ const lease = await multicastSubscriptionPool.acquire(gateway, config, {
903
+ onBytes: (data) => {
904
+ if (generation === this.connectionGeneration)
905
+ this.handlePacket(data);
906
+ },
907
+ onState: (state) => {
908
+ if (generation !== this.connectionGeneration)
909
+ return;
910
+ this.state.connected = state !== "closed";
911
+ this.onStateChange?.(this.state);
912
+ },
913
+ onError: (error) => {
914
+ if (generation !== this.connectionGeneration)
915
+ return;
916
+ console.error("[Transport] window.multicast error:", error);
917
+ this.onError?.(error);
918
+ }
919
+ });
920
+ if (generation !== this.connectionGeneration) {
921
+ await lease.release();
922
+ return false;
923
+ }
924
+ this.subscription = {
925
+ id: lease.key,
926
+ config,
927
+ close: () => {
928
+ void lease.release();
929
+ }
930
+ };
931
+ this.state = {
932
+ mode: "multicast",
933
+ connected: true,
934
+ group: config.group,
935
+ source: config.source,
936
+ quality: this.abr.getCurrentQuality(),
937
+ packetsReceived: 0,
938
+ bytesReceived: 0,
939
+ lastPacketTime: 0
940
+ };
941
+ console.log(`[Transport] Connected via window.multicast: (${config.source}, ${config.group})`);
942
+ this.onStateChange?.(this.state);
943
+ return true;
944
+ } catch (error) {
945
+ console.warn("[Transport] window.multicast failed:", error);
946
+ return false;
947
+ }
948
+ }
949
+ /**
950
+ * Connect via AMT proxy (with optional DRIAD discovery)
951
+ */
952
+ async connectAmt(config, generation) {
953
+ try {
954
+ let amtRelay = config.amtRelay;
955
+ if (!amtRelay && config.driadEnabled !== false && config.source) {
956
+ console.log(`[Transport] Discovering AMT relay via DRIAD for source ${config.source}...`);
957
+ const relays = await this.driad.discoverRelays(config.source);
958
+ if (generation !== this.connectionGeneration)
959
+ return false;
960
+ const bestRelay = await this.driad.selectBestRelay(relays);
961
+ if (generation !== this.connectionGeneration)
962
+ return false;
963
+ if (bestRelay) {
964
+ amtRelay = bestRelay.host;
965
+ this.state.amtRelay = amtRelay;
966
+ }
967
+ }
968
+ if (!amtRelay) {
969
+ console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
970
+ return false;
971
+ }
972
+ return await this.connectAmtProxy(config, amtRelay, generation);
973
+ } catch (error) {
974
+ console.warn("[Transport] AMT connection failed:", error);
975
+ return false;
976
+ }
977
+ }
978
+ /**
979
+ * Connect via WebSocket-based AMT proxy (browser fallback)
980
+ */
981
+ async connectAmtProxy(config, amtRelay, generation) {
982
+ try {
983
+ const relayHost = amtRelay.includes(":") && !amtRelay.startsWith("[") ? `[${amtRelay}]` : amtRelay;
984
+ const relayAuthority = config.amtRelayPort ? `${relayHost}:${config.amtRelayPort}` : relayHost;
985
+ const wsUrl = new URL(`wss://${relayAuthority}/amt-proxy`);
986
+ wsUrl.searchParams.set("group", config.group);
987
+ wsUrl.searchParams.set("source", config.source || "");
988
+ wsUrl.searchParams.set("port", String(config.port));
989
+ const ws = new WebSocket(wsUrl);
990
+ return new Promise((resolve, reject) => {
991
+ ws.binaryType = "arraybuffer";
992
+ const timeout = setTimeout(() => {
993
+ ws.close();
994
+ reject(new Error("AMT proxy connection timeout"));
995
+ }, 1e4);
996
+ ws.onopen = () => {
997
+ clearTimeout(timeout);
998
+ if (generation !== this.connectionGeneration) {
999
+ ws.close();
1000
+ resolve(false);
1001
+ return;
1002
+ }
1003
+ console.log(`[Transport] Connected to AMT proxy: ${amtRelay}`);
1004
+ this.subscription = {
1005
+ id: `amt-proxy-${Date.now()}`,
1006
+ config,
1007
+ close: () => ws.close()
1008
+ };
1009
+ this.state = {
1010
+ mode: "amt",
1011
+ connected: true,
1012
+ group: config.group,
1013
+ source: config.source,
1014
+ amtRelay,
1015
+ quality: this.abr.getCurrentQuality(),
1016
+ packetsReceived: 0,
1017
+ bytesReceived: 0,
1018
+ lastPacketTime: 0
1019
+ };
1020
+ this.onStateChange?.(this.state);
1021
+ resolve(true);
1022
+ };
1023
+ ws.onmessage = (event) => {
1024
+ if (generation === this.connectionGeneration && event.data instanceof ArrayBuffer) {
1025
+ this.handlePacket(event.data);
1026
+ }
1027
+ };
1028
+ ws.onerror = (error) => {
1029
+ clearTimeout(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1031
+ resolve(false);
1032
+ return;
1033
+ }
1034
+ console.error("[Transport] AMT proxy error:", error);
1035
+ reject(error);
1036
+ };
1037
+ ws.onclose = () => {
1038
+ clearTimeout(timeout);
1039
+ if (generation !== this.connectionGeneration) {
1040
+ resolve(false);
1041
+ return;
1042
+ }
1043
+ this.state.connected = false;
1044
+ this.onStateChange?.(this.state);
1045
+ resolve(false);
1046
+ };
1047
+ });
1048
+ } catch (error) {
1049
+ console.warn("[Transport] AMT proxy failed:", error);
1050
+ return false;
1051
+ }
1052
+ }
1053
+ /**
1054
+ * Handle received packet
1055
+ */
1056
+ handlePacket(data) {
1057
+ this.state.packetsReceived++;
1058
+ this.state.bytesReceived += data.byteLength;
1059
+ this.state.lastPacketTime = Date.now();
1060
+ this.abr.recordSample(data.byteLength, 0);
1061
+ this.onPacket?.(data);
1062
+ }
1063
+ /**
1064
+ * Get current transport state
1065
+ */
1066
+ getState() {
1067
+ return { ...this.state };
1068
+ }
1069
+ /**
1070
+ * Get current quality level
1071
+ */
1072
+ getQuality() {
1073
+ return this.abr.getCurrentQuality();
1074
+ }
1075
+ /**
1076
+ * Force quality level
1077
+ */
1078
+ setQuality(name) {
1079
+ this.abr.setQuality(name);
1080
+ }
1081
+ /** Configures multicast-only ABR while leaving the caller's MoQ ABR untouched. */
1082
+ configureMulticastTiers(options, onCommand) {
1083
+ this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
1084
+ this.multicastOrchestrator = new MulticastOrchestrator(options);
1085
+ this.onOrchestratorCommand = onCommand;
1086
+ return this.multicastOrchestrator.start();
1087
+ }
1088
+ recordMulticastGoodput(bitrate) {
1089
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onGoodput({ bitrate }));
1090
+ }
1091
+ recordMulticastHeadroom(healthy) {
1092
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onHeadroom({ healthy }));
1093
+ }
1094
+ recordMulticastTierPacket(packet) {
1095
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onTierPacket(packet));
1096
+ }
1097
+ pollMulticastTierSwitch() {
1098
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
1099
+ }
1100
+ /**
1101
+ * Set packet callback
1102
+ */
1103
+ setPacketCallback(callback) {
1104
+ this.onPacket = callback;
1105
+ }
1106
+ /**
1107
+ * Set error callback
1108
+ */
1109
+ setErrorCallback(callback) {
1110
+ this.onError = callback;
1111
+ }
1112
+ /**
1113
+ * Set state change callback
1114
+ */
1115
+ setStateCallback(callback) {
1116
+ this.onStateChange = callback;
1117
+ }
1118
+ /**
1119
+ * Disconnect
1120
+ */
1121
+ disconnect() {
1122
+ this.connectionGeneration++;
1123
+ this.subscription?.close();
1124
+ this.subscription = null;
1125
+ this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
1126
+ this.multicastOrchestrator = null;
1127
+ this.onOrchestratorCommand = void 0;
1128
+ this.state = {
1129
+ mode: "disconnected",
1130
+ connected: false,
1131
+ packetsReceived: 0,
1132
+ bytesReceived: 0,
1133
+ lastPacketTime: 0
1134
+ };
1135
+ this.onStateChange?.(this.state);
1136
+ }
1137
+ dispatchOrchestratorCommand(command) {
1138
+ if (command)
1139
+ this.onOrchestratorCommand?.(command);
1140
+ return command;
1141
+ }
1142
+ };
1143
+ var transportManager = new TransportManager();
1144
+
1145
+ // node_modules/@blockcast/mmt-transport/dist/moqt-priority.js
1146
+ var MAX_MOQT_PRIORITY = 255;
1147
+ function moqtPriority(value, field) {
1148
+ if (!Number.isInteger(value) || value < 0 || value > MAX_MOQT_PRIORITY) {
1149
+ throw new RangeError(`${field} must be an integer in [0, ${MAX_MOQT_PRIORITY}], got ${value}`);
1150
+ }
1151
+ return value;
1152
+ }
1153
+ function moqtSubscriberPriority(value) {
1154
+ return moqtPriority(value, "MOQT subscriber priority");
1155
+ }
1156
+ function moqtPublisherPriority(value) {
1157
+ return moqtPriority(value, "MOQT publisher priority");
1158
+ }
1159
+ var MOQT_SUBSCRIBER_PRIORITY = Object.freeze({
1160
+ catalog: moqtSubscriberPriority(0),
1161
+ deadlineRepair: moqtSubscriberPriority(0),
1162
+ audio: moqtSubscriberPriority(1),
1163
+ video: moqtSubscriberPriority(2),
1164
+ backgroundRepair: moqtSubscriberPriority(3)
1165
+ });
1166
+ var MOQT_PUBLISHER_PRIORITY = Object.freeze({
1167
+ catalog: moqtPublisherPriority(32),
1168
+ source: moqtPublisherPriority(128),
1169
+ repair: moqtPublisherPriority(240)
1170
+ });
1171
+
1172
+ // node_modules/@blockcast/mmt-transport/dist/amt-gateway.js
1173
+ var DEFAULT_AMT_PORT = 2268;
1174
+ var AMTGatewayManager = class {
1175
+ constructor() {
1176
+ __publicField(this, "subscriptions", /* @__PURE__ */ new Map());
1177
+ __publicField(this, "messageHandler");
1178
+ __publicField(this, "pendingPackets", /* @__PURE__ */ new Map());
1179
+ __publicField(this, "driad", new DRIADDiscovery());
1180
+ this.messageHandler = (event) => {
1181
+ const data = event.data;
1182
+ console.log(`[AMT] SW message received:`, data.type);
1183
+ if (data.type === "UDP_PACKET") {
1184
+ this.handlePacket(data);
1185
+ } else if (data.type === "SOCKET_ERROR") {
1186
+ this.handleSocketError(data);
1187
+ } else if (data.type === "DEBUG_LOG") {
1188
+ console.log(`[AMT SW Debug] ${data.message}`);
1189
+ }
1190
+ };
1191
+ if (typeof navigator !== "undefined" && navigator.serviceWorker) {
1192
+ navigator.serviceWorker.addEventListener("message", this.messageHandler);
1193
+ console.log("[AMT] Registered service worker message handler");
1194
+ } else {
1195
+ console.warn("[AMT] Service worker not available");
1196
+ }
1197
+ }
1198
+ /**
1199
+ * Subscribe via AMT tunnel
1200
+ */
1201
+ async subscribe(config) {
1202
+ const { key } = config;
1203
+ const keyStr = this.getKeyString(key);
1204
+ if (this.subscriptions.has(keyStr)) {
1205
+ console.log(`[AMT] Reusing existing subscription to ${keyStr}`);
1206
+ return keyStr;
1207
+ }
1208
+ try {
1209
+ let relayAddress;
1210
+ let discoveryMethod;
1211
+ const relayPort = config.relayPort || DEFAULT_AMT_PORT;
1212
+ if (config.relayAddress) {
1213
+ relayAddress = config.relayAddress;
1214
+ discoveryMethod = "manual";
1215
+ console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
1216
+ } else if (key.source) {
1217
+ console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
1218
+ const relays = await this.driad.discoverRelays(key.source);
1219
+ const bestRelay = await this.driad.selectBestRelay(relays);
1220
+ if (!bestRelay) {
1221
+ throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
1222
+ }
1223
+ relayAddress = bestRelay.host;
1224
+ discoveryMethod = "driad";
1225
+ console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
1226
+ } else {
1227
+ throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
1228
+ }
1229
+ const subscriptionId = keyStr;
1230
+ this.pendingPackets.set(subscriptionId, []);
1231
+ const subscription = {
1232
+ key,
1233
+ subscriptionId,
1234
+ config,
1235
+ handshakeComplete: false,
1236
+ relay: {
1237
+ address: relayAddress,
1238
+ port: relayPort,
1239
+ discoveryMethod,
1240
+ discoveredAt: Date.now()
1241
+ }
1242
+ };
1243
+ this.subscriptions.set(keyStr, subscription);
1244
+ console.log(`[AMT] Subscription created for ${keyStr} via ${relayAddress}:${relayPort}`);
1245
+ return keyStr;
1246
+ } catch (error) {
1247
+ const subscription = this.subscriptions.get(keyStr);
1248
+ if (subscription) {
1249
+ this.subscriptions.delete(keyStr);
1250
+ this.pendingPackets.delete(subscription.subscriptionId);
1251
+ }
1252
+ throw new Error(`Failed to subscribe via AMT: ${error instanceof Error ? error.message : String(error)}`);
1253
+ }
1254
+ }
1255
+ /**
1256
+ * Unsubscribe from AMT tunnel
1257
+ */
1258
+ async unsubscribe(handle) {
1259
+ const subscription = this.subscriptions.get(handle);
1260
+ if (!subscription) {
1261
+ throw new Error(`Subscription ${handle} not found`);
1262
+ }
1263
+ try {
1264
+ if (subscription.keepAliveTimer) {
1265
+ clearInterval(subscription.keepAliveTimer);
1266
+ }
1267
+ console.log(`[AMT] Unsubscribed from ${handle}`);
1268
+ } catch (error) {
1269
+ console.error("[AMT] Error during unsubscribe:", error);
1270
+ } finally {
1271
+ this.subscriptions.delete(handle);
1272
+ this.pendingPackets.delete(subscription.subscriptionId);
1273
+ }
1274
+ }
1275
+ /**
1276
+ * Get list of active subscriptions
1277
+ */
1278
+ getSubscriptions() {
1279
+ return Array.from(this.subscriptions.keys());
1280
+ }
1281
+ /**
1282
+ * Handle packet from service worker
1283
+ */
1284
+ handlePacket(message) {
1285
+ const { subscriptionId, data } = message;
1286
+ if (!subscriptionId)
1287
+ return;
1288
+ const subscription = this.subscriptions.get(subscriptionId);
1289
+ if (!subscription) {
1290
+ console.warn(`[AMT] Received packet for unknown subscription: ${subscriptionId}`);
1291
+ return;
1292
+ }
1293
+ if (!subscription.handshakeComplete) {
1294
+ const queue = this.pendingPackets.get(subscriptionId);
1295
+ const packetData2 = data;
1296
+ if (queue) {
1297
+ queue.push({
1298
+ data: packetData2.data,
1299
+ remoteAddress: packetData2.remoteAddress,
1300
+ remotePort: packetData2.remotePort
1301
+ });
1302
+ }
1303
+ return;
1304
+ }
1305
+ const packetData = data;
1306
+ const metadata = {
1307
+ sourceAddress: subscription.relay?.address || "unknown",
1308
+ sourcePort: subscription.relay?.port || 0,
1309
+ transport: "tunnel",
1310
+ timestamp: performance.now()
1311
+ };
1312
+ subscription.config.onPacket(packetData.data, metadata);
1313
+ }
1314
+ /**
1315
+ * Handle socket error from service worker
1316
+ */
1317
+ handleSocketError(message) {
1318
+ const { subscriptionId, error } = message;
1319
+ if (!subscriptionId)
1320
+ return;
1321
+ const subscription = this.subscriptions.get(subscriptionId);
1322
+ if (!subscription) {
1323
+ console.warn(`[AMT] Received error for unknown subscription: ${subscriptionId}`);
1324
+ return;
1325
+ }
1326
+ subscription.config.onError(new Error(error || "Unknown error"));
1327
+ }
1328
+ /**
1329
+ * Cleanup on destroy
1330
+ */
1331
+ destroy() {
1332
+ if (this.messageHandler && typeof navigator !== "undefined" && navigator.serviceWorker) {
1333
+ navigator.serviceWorker.removeEventListener("message", this.messageHandler);
1334
+ }
1335
+ const handles = Array.from(this.subscriptions.keys());
1336
+ for (const handle of handles) {
1337
+ this.unsubscribe(handle).catch((err) => {
1338
+ console.error(`[AMT] Error unsubscribing ${handle}:`, err);
1339
+ });
1340
+ }
1341
+ }
1342
+ /**
1343
+ * Get key string for HashMap
1344
+ */
1345
+ getKeyString(key) {
1346
+ const source = key.source ? `@${key.source}` : "";
1347
+ return `${key.group}:${key.port}${source}`;
1348
+ }
1349
+ };
1350
+ var amtGatewayManager = new AMTGatewayManager();
1351
+
1352
+ // ../mmt-alta-parse/dist/index.js
1353
+ var MPU_HEADER_SIZE = 8;
1354
+ var MPU_LENGTH_FIELD_SIZE = 2;
1355
+ var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
1356
+
1357
+ // ../mmt-base/dist/mmtp.js
1358
+ var MMTP_HEADER_SIZE = 12;
1359
+ var MPU_HEADER_SIZE2 = 8;
1360
+ var MPU_LENGTH_FIELD_SIZE2 = 2;
1361
+ var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
1362
+ function parseMMTPHeader(buffer) {
1363
+ if (buffer.length < MMTP_HEADER_SIZE) {
1364
+ throw new Error(`MMTP packet too small: ${buffer.length} bytes`);
1365
+ }
1366
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1367
+ const version = buffer[0] >> 6 & 3;
1368
+ if (version !== 0) {
1369
+ throw new Error(`Unsupported MMTP version: ${version}`);
1370
+ }
1371
+ const fecType = buffer[0] >> 3 & 3;
1372
+ const packetCounterFlag = (buffer[0] & 32) !== 0;
1373
+ const extensionFlag = (buffer[0] & 2) !== 0;
1374
+ const rapFlag = (buffer[0] & 1) === 1;
1375
+ const packetType = buffer[1] & 63;
1376
+ let offset = 2;
1377
+ const packetId = view.getUint16(offset, false);
1378
+ offset += 2;
1379
+ const timestamp = BigInt(view.getUint32(offset, false));
1380
+ offset += 4;
1381
+ const sequenceNumber = view.getUint32(offset, false);
1382
+ offset += 4;
1383
+ let packetCounter;
1384
+ if (packetCounterFlag) {
1385
+ if (offset + 4 > buffer.length)
1386
+ throw new Error("MMTP packet truncated in packet_counter");
1387
+ packetCounter = view.getUint32(offset, false);
1388
+ offset += 4;
1389
+ }
1390
+ let extension;
1391
+ if (extensionFlag) {
1392
+ if (offset + 4 > buffer.length)
1393
+ throw new Error("MMTP packet truncated in header extension");
1394
+ const type = view.getUint16(offset, false);
1395
+ const length = view.getUint16(offset + 2, false);
1396
+ offset += 4;
1397
+ if (offset + length > buffer.length)
1398
+ throw new Error("MMTP packet truncated in header extension value");
1399
+ extension = { type, data: buffer.subarray(offset, offset + length) };
1400
+ offset += length;
1401
+ }
1402
+ return {
1403
+ version,
1404
+ packetType,
1405
+ packetId,
1406
+ timestamp,
1407
+ sequenceNumber,
1408
+ payloadLength: buffer.length - offset,
1409
+ fecType,
1410
+ packetCounterFlag,
1411
+ packetCounter,
1412
+ extensionFlag,
1413
+ extension,
1414
+ headerLength: offset,
1415
+ rapFlag
1416
+ };
1417
+ }
1418
+
1419
+ // src/multicast-transport.ts
1420
+ var MAX_TRACKED_DROPPED_PIDS = 16;
1421
+ function getMulticastGlobals() {
1422
+ return globalThis;
1423
+ }
1424
+ function hasMulticastGateway() {
1425
+ return typeof getMulticastGlobals().multicast?.subscribe === "function";
1426
+ }
1427
+ function normalizeBytesEventDetail(detail) {
1428
+ const value = detail && typeof detail === "object" && "data" in detail ? detail.data : detail;
1429
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
1430
+ if (ArrayBuffer.isView(value)) {
1431
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
1432
+ }
1433
+ return null;
1434
+ }
1435
+ var _onPacket, _subscription, _bytesListener, _resolvedTransport, _videoConfirmed, _audioConfirmed, _watchdog, _failbackWindowMs, _onTakeover, _onFailback, _disposed, _stats, _droppedPidCounts, _packetIds, _joinGeneration, _MulticastTransport_instances, releaseSubscription_fn, acceptPacket_fn, recordUnregisteredPidDrop_fn, checkTakeover_fn, resetWatchdog_fn;
1436
+ var _MulticastTransport = class _MulticastTransport {
1437
+ constructor(onPacket) {
1438
+ __privateAdd(this, _MulticastTransport_instances);
1439
+ __privateAdd(this, _onPacket);
1440
+ __privateAdd(this, _subscription, null);
1441
+ __privateAdd(this, _bytesListener, null);
1442
+ __privateAdd(this, _resolvedTransport);
1443
+ __privateAdd(this, _videoConfirmed, false);
1444
+ __privateAdd(this, _audioConfirmed, false);
1445
+ __privateAdd(this, _watchdog, null);
1446
+ __privateAdd(this, _failbackWindowMs, null);
1447
+ __privateAdd(this, _onTakeover, null);
1448
+ __privateAdd(this, _onFailback, null);
1449
+ __privateAdd(this, _disposed, false);
1450
+ __privateAdd(this, _stats, {
1451
+ packetsReceived: 0,
1452
+ bytesReceived: 0,
1453
+ packetsDroppedUnregisteredPid: 0,
1454
+ packetsDroppedUnparseable: 0
1455
+ });
1456
+ __privateAdd(this, _droppedPidCounts, /* @__PURE__ */ new Map());
1457
+ __privateAdd(this, _packetIds, null);
1458
+ __privateAdd(this, _joinGeneration, 0);
1459
+ __privateSet(this, _onPacket, onPacket);
1460
+ }
1461
+ static isAvailable() {
1462
+ return hasMulticastGateway();
1463
+ }
1464
+ async join(config, context) {
1465
+ const generation = ++__privateWrapper(this, _joinGeneration)._;
1466
+ __privateMethod(this, _MulticastTransport_instances, releaseSubscription_fn).call(this);
1467
+ if (__privateGet(this, _disposed)) return false;
1468
+ if (!_MulticastTransport.isAvailable()) {
1469
+ console.warn("[MulticastTransport] Multicast API not available");
1470
+ return false;
1471
+ }
1472
+ try {
1473
+ const packetIds = config.packetIds?.length ? new Set(config.packetIds) : null;
1474
+ console.log(
1475
+ `[MulticastTransport] window.multicast.subscribe(${config.sourceAddress}, ${config.groupAddress}, ${config.port})`
1476
+ );
1477
+ const subscribeConfig = toWindowMulticastSubscribeConfig({
1478
+ source: config.sourceAddress,
1479
+ group: config.groupAddress,
1480
+ port: config.port,
1481
+ mode: config.mode,
1482
+ amtRelay: config.amtRelay,
1483
+ amtRelayPort: config.amtRelayPort,
1484
+ packetIds: config.packetIds,
1485
+ tracks: config.tracks
1486
+ });
1487
+ const subscription = await getMulticastGlobals().multicast.subscribe(subscribeConfig);
1488
+ console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription);
1489
+ if (__privateGet(this, _disposed) || generation !== __privateGet(this, _joinGeneration)) {
1490
+ void subscription.unsubscribe();
1491
+ return false;
1492
+ }
1493
+ if (typeof subscription.addEventListener !== "function") {
1494
+ if (typeof subscription.unsubscribe === "function") {
1495
+ void subscription.unsubscribe();
1496
+ }
1497
+ throw new Error("window.multicast subscription does not support bytes events");
1498
+ }
1499
+ const onBytes = (event) => {
1500
+ if (__privateGet(this, _disposed) || generation !== __privateGet(this, _joinGeneration)) return;
1501
+ const packet = normalizeBytesEventDetail(event.detail);
1502
+ if (!packet) {
1503
+ __privateGet(this, _stats).packetsDroppedUnparseable++;
1504
+ return;
1505
+ }
1506
+ if (!__privateMethod(this, _MulticastTransport_instances, acceptPacket_fn).call(this, packet)) return;
1507
+ __privateGet(this, _stats).packetsReceived++;
1508
+ __privateGet(this, _stats).bytesReceived += packet.byteLength;
1509
+ __privateGet(this, _onPacket).call(this, packet, context);
1510
+ __privateMethod(this, _MulticastTransport_instances, resetWatchdog_fn).call(this);
1511
+ };
1512
+ __privateSet(this, _subscription, subscription);
1513
+ __privateSet(this, _bytesListener, onBytes);
1514
+ __privateSet(this, _packetIds, packetIds);
1515
+ __privateSet(this, _resolvedTransport, subscribeConfig.origin === "amt" ? "amt" : "native");
1516
+ subscription.addEventListener("bytes", onBytes);
1517
+ __privateMethod(this, _MulticastTransport_instances, resetWatchdog_fn).call(this);
1518
+ console.log(
1519
+ `[MulticastTransport] Joined ${config.groupAddress}:${config.port}`
1520
+ );
1521
+ return true;
1522
+ } catch (err) {
1523
+ if (__privateGet(this, _disposed) || generation !== __privateGet(this, _joinGeneration)) return false;
1524
+ __privateMethod(this, _MulticastTransport_instances, releaseSubscription_fn).call(this);
1525
+ console.error("[MulticastTransport] Failed to join SSM group:", err);
1526
+ return false;
1527
+ }
1528
+ }
1529
+ /** Feed a raw packet from an external source (e.g., AMT tunnel or ASM subscription). */
1530
+ feedPacket(data, context) {
1531
+ if (__privateGet(this, _disposed)) return;
1532
+ const packet = data instanceof Uint8Array ? data : new Uint8Array(data);
1533
+ if (!__privateMethod(this, _MulticastTransport_instances, acceptPacket_fn).call(this, packet)) return;
1534
+ __privateGet(this, _stats).packetsReceived++;
1535
+ __privateGet(this, _stats).bytesReceived += packet.byteLength;
1536
+ __privateGet(this, _onPacket).call(this, packet, context);
1537
+ __privateMethod(this, _MulticastTransport_instances, resetWatchdog_fn).call(this);
1538
+ }
1539
+ confirmVideo() {
1540
+ __privateSet(this, _videoConfirmed, true);
1541
+ __privateMethod(this, _MulticastTransport_instances, checkTakeover_fn).call(this);
1542
+ }
1543
+ confirmAudio() {
1544
+ __privateSet(this, _audioConfirmed, true);
1545
+ __privateMethod(this, _MulticastTransport_instances, checkTakeover_fn).call(this);
1546
+ }
1547
+ onTakeover(cb) {
1548
+ __privateSet(this, _onTakeover, cb);
1549
+ }
1550
+ onFailback(cb) {
1551
+ __privateSet(this, _onFailback, cb);
1552
+ }
1553
+ setFailbackWindowMs(windowMs) {
1554
+ if (!Number.isFinite(windowMs) || windowMs <= 0) {
1555
+ throw new Error(
1556
+ `[MulticastTransport] failbackWindowMs=${windowMs}. Derive a positive failback window from the stream catalog.`
1557
+ );
1558
+ }
1559
+ __privateSet(this, _failbackWindowMs, windowMs);
1560
+ }
1561
+ get stats() {
1562
+ return __privateGet(this, _stats);
1563
+ }
1564
+ /**
1565
+ * Per-PID drop breakdown, newest-capped at MAX_TRACKED_DROPPED_PIDS distinct
1566
+ * PIDs. This is what names the offender: `packetsDroppedUnregisteredPid`
1567
+ * says the ingress filter fired, this says it fired on 0x8001.
1568
+ */
1569
+ get droppedPacketIds() {
1570
+ return __privateGet(this, _droppedPidCounts);
1571
+ }
1572
+ get resolvedTransport() {
1573
+ return __privateGet(this, _resolvedTransport);
1574
+ }
1575
+ dispose() {
1576
+ ++__privateWrapper(this, _joinGeneration)._;
1577
+ __privateSet(this, _disposed, true);
1578
+ __privateMethod(this, _MulticastTransport_instances, releaseSubscription_fn).call(this);
1579
+ }
1580
+ };
1581
+ _onPacket = new WeakMap();
1582
+ _subscription = new WeakMap();
1583
+ _bytesListener = new WeakMap();
1584
+ _resolvedTransport = new WeakMap();
1585
+ _videoConfirmed = new WeakMap();
1586
+ _audioConfirmed = new WeakMap();
1587
+ _watchdog = new WeakMap();
1588
+ _failbackWindowMs = new WeakMap();
1589
+ _onTakeover = new WeakMap();
1590
+ _onFailback = new WeakMap();
1591
+ _disposed = new WeakMap();
1592
+ _stats = new WeakMap();
1593
+ _droppedPidCounts = new WeakMap();
1594
+ _packetIds = new WeakMap();
1595
+ _joinGeneration = new WeakMap();
1596
+ _MulticastTransport_instances = new WeakSet();
1597
+ releaseSubscription_fn = function() {
1598
+ if (__privateGet(this, _watchdog)) clearTimeout(__privateGet(this, _watchdog));
1599
+ __privateSet(this, _watchdog, null);
1600
+ if (__privateGet(this, _subscription)) {
1601
+ if (__privateGet(this, _bytesListener)) {
1602
+ __privateGet(this, _subscription).removeEventListener("bytes", __privateGet(this, _bytesListener));
1603
+ }
1604
+ void __privateGet(this, _subscription).unsubscribe();
1605
+ }
1606
+ __privateSet(this, _subscription, null);
1607
+ __privateSet(this, _bytesListener, null);
1608
+ __privateSet(this, _resolvedTransport, void 0);
1609
+ __privateSet(this, _packetIds, null);
1610
+ };
1611
+ acceptPacket_fn = function(packet) {
1612
+ if (!__privateGet(this, _packetIds)) return true;
1613
+ let packetId;
1614
+ try {
1615
+ packetId = parseMMTPHeader(packet).packetId;
1616
+ } catch {
1617
+ __privateGet(this, _stats).packetsDroppedUnparseable++;
1618
+ return false;
1619
+ }
1620
+ if (__privateGet(this, _packetIds).has(packetId)) return true;
1621
+ __privateMethod(this, _MulticastTransport_instances, recordUnregisteredPidDrop_fn).call(this, packetId);
1622
+ return false;
1623
+ };
1624
+ recordUnregisteredPidDrop_fn = function(packetId) {
1625
+ __privateGet(this, _stats).packetsDroppedUnregisteredPid++;
1626
+ const seen = __privateGet(this, _droppedPidCounts).get(packetId);
1627
+ if (seen !== void 0) {
1628
+ __privateGet(this, _droppedPidCounts).set(packetId, seen + 1);
1629
+ return;
1630
+ }
1631
+ if (__privateGet(this, _droppedPidCounts).size >= MAX_TRACKED_DROPPED_PIDS) return;
1632
+ __privateGet(this, _droppedPidCounts).set(packetId, 1);
1633
+ console.warn(
1634
+ `[MulticastTransport] Dropping packetId=${packetId} (0x${packetId.toString(16)}): not in the advertised set [${[...__privateGet(this, _packetIds)].join(", ")}]. If this is an FEC repair leg, the catalog is not advertising its packetId.`
1635
+ );
1636
+ };
1637
+ checkTakeover_fn = function() {
1638
+ if (__privateGet(this, _videoConfirmed) && __privateGet(this, _audioConfirmed) && __privateGet(this, _onTakeover)) {
1639
+ const cb = __privateGet(this, _onTakeover);
1640
+ __privateSet(this, _onTakeover, null);
1641
+ cb();
1642
+ }
1643
+ };
1644
+ resetWatchdog_fn = function() {
1645
+ if (__privateGet(this, _watchdog)) clearTimeout(__privateGet(this, _watchdog));
1646
+ if (!__privateGet(this, _onFailback)) return;
1647
+ if (__privateGet(this, _failbackWindowMs) === null) {
1648
+ throw new Error(
1649
+ "[MulticastTransport] Failback watchdog requires a catalog-derived window"
1650
+ );
1651
+ }
1652
+ __privateSet(this, _watchdog, setTimeout(() => {
1653
+ if (!__privateGet(this, _disposed) && __privateGet(this, _onFailback)) {
1654
+ console.warn(
1655
+ `[MulticastTransport] No packets for ${__privateGet(this, _failbackWindowMs)}ms; failing back to MoQ`
1656
+ );
1657
+ __privateGet(this, _onFailback).call(this);
1658
+ }
1659
+ }, __privateGet(this, _failbackWindowMs)));
1660
+ };
1661
+ var MulticastTransport = _MulticastTransport;
1662
+ export {
1663
+ MulticastTransport
1664
+ };
1665
+ //# sourceMappingURL=multicast-transport.js.map