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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (678) hide show
  1. package/README.md +432 -0
  2. package/dist/.build-stamp +0 -0
  3. package/dist/__tests__/test-utils.d.ts +71 -0
  4. package/dist/__tests__/test-utils.d.ts.map +1 -0
  5. package/dist/align.d.ts +148 -0
  6. package/dist/align.d.ts.map +1 -0
  7. package/dist/align.js +88 -0
  8. package/dist/align.js.map +7 -0
  9. package/dist/audio-init-parser.d.ts +66 -0
  10. package/dist/audio-init-parser.d.ts.map +1 -0
  11. package/dist/audio-init-parser.js +118 -0
  12. package/dist/audio-init-parser.js.map +7 -0
  13. package/dist/audio-ring-buffer.d.ts +50 -0
  14. package/dist/audio-ring-buffer.d.ts.map +1 -0
  15. package/dist/audio-ring-buffer.js +93 -0
  16. package/dist/audio-ring-buffer.js.map +7 -0
  17. package/dist/authored-timing.d.ts +32 -0
  18. package/dist/authored-timing.d.ts.map +1 -0
  19. package/dist/authored-timing.js +32 -0
  20. package/dist/authored-timing.js.map +7 -0
  21. package/dist/browser-runtime.js +17109 -0
  22. package/dist/browser-runtime.js.map +7 -0
  23. package/dist/carp-catalog.d.ts +318 -0
  24. package/dist/carp-catalog.d.ts.map +1 -0
  25. package/dist/carp-catalog.js +549 -0
  26. package/dist/carp-catalog.js.map +7 -0
  27. package/dist/catalog-fec-params.d.ts +82 -0
  28. package/dist/catalog-fec-params.d.ts.map +1 -0
  29. package/dist/catalog-fec-params.js +66 -0
  30. package/dist/catalog-fec-params.js.map +7 -0
  31. package/dist/catalog-network-source.d.ts +19 -0
  32. package/dist/catalog-network-source.d.ts.map +1 -0
  33. package/dist/catalog-network-source.js +22 -0
  34. package/dist/catalog-network-source.js.map +7 -0
  35. package/dist/catalog-validator.d.ts +18 -0
  36. package/dist/catalog-validator.d.ts.map +1 -0
  37. package/dist/catalog-validator.js +7747 -0
  38. package/dist/catalog-validator.js.map +7 -0
  39. package/dist/cmaf-block-assembler.d.ts +168 -0
  40. package/dist/cmaf-block-assembler.d.ts.map +1 -0
  41. package/dist/cmaf-block-assembler.js +1755 -0
  42. package/dist/cmaf-block-assembler.js.map +7 -0
  43. package/dist/cmaf-group-batcher.d.ts +38 -0
  44. package/dist/cmaf-group-batcher.d.ts.map +1 -0
  45. package/dist/cmaf-group-batcher.js +195 -0
  46. package/dist/cmaf-group-batcher.js.map +7 -0
  47. package/dist/cmcd-producer.d.ts +104 -0
  48. package/dist/cmcd-producer.d.ts.map +1 -0
  49. package/dist/cmcd-producer.js +207 -0
  50. package/dist/cmcd-producer.js.map +7 -0
  51. package/dist/codec-utils.d.ts +235 -0
  52. package/dist/codec-utils.d.ts.map +1 -0
  53. package/dist/codec-utils.js +1225 -0
  54. package/dist/codec-utils.js.map +7 -0
  55. package/dist/fec-codec.d.ts +32 -0
  56. package/dist/fec-codec.d.ts.map +1 -0
  57. package/dist/fec-codec.js +47 -0
  58. package/dist/fec-codec.js.map +7 -0
  59. package/dist/fec-manager.d.ts +266 -0
  60. package/dist/fec-manager.d.ts.map +1 -0
  61. package/dist/fec-manager.js +1447 -0
  62. package/dist/fec-manager.js.map +7 -0
  63. package/dist/fec-starvation-detector.d.ts +59 -0
  64. package/dist/fec-starvation-detector.d.ts.map +1 -0
  65. package/dist/fec-starvation-detector.js +75 -0
  66. package/dist/fec-starvation-detector.js.map +7 -0
  67. package/dist/fec-worker-setup.d.ts +76 -0
  68. package/dist/fec-worker-setup.d.ts.map +1 -0
  69. package/dist/fec-worker-setup.js +603 -0
  70. package/dist/fec-worker-setup.js.map +7 -0
  71. package/dist/fmp4-completion.d.ts +30 -0
  72. package/dist/fmp4-completion.d.ts.map +1 -0
  73. package/dist/fmp4-completion.js +21 -0
  74. package/dist/fmp4-completion.js.map +7 -0
  75. package/dist/fmp4-reader.d.ts +37 -0
  76. package/dist/fmp4-reader.d.ts.map +1 -0
  77. package/dist/fmp4-reader.js +100 -0
  78. package/dist/fmp4-reader.js.map +7 -0
  79. package/dist/index.d.ts +47 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +330 -0
  82. package/dist/index.js.map +7 -0
  83. package/dist/iso-bmff-timing.d.ts +47 -0
  84. package/dist/iso-bmff-timing.d.ts.map +1 -0
  85. package/dist/iso-bmff-timing.js +526 -0
  86. package/dist/iso-bmff-timing.js.map +7 -0
  87. package/dist/loc.d.ts +68 -0
  88. package/dist/loc.d.ts.map +1 -0
  89. package/dist/loc.js +143 -0
  90. package/dist/loc.js.map +7 -0
  91. package/dist/manifest-auth-plan.d.ts +30 -0
  92. package/dist/manifest-auth-plan.d.ts.map +1 -0
  93. package/dist/manifest-auth-plan.js +1267 -0
  94. package/dist/manifest-auth-plan.js.map +7 -0
  95. package/dist/media-router.d.ts +338 -0
  96. package/dist/media-router.d.ts.map +1 -0
  97. package/dist/media-router.js +802 -0
  98. package/dist/media-router.js.map +7 -0
  99. package/dist/mfu-reassembler.d.ts +264 -0
  100. package/dist/mfu-reassembler.d.ts.map +1 -0
  101. package/dist/mfu-reassembler.js +2668 -0
  102. package/dist/mfu-reassembler.js.map +7 -0
  103. package/dist/mfu-reassembly-policy.d.ts +24 -0
  104. package/dist/mfu-reassembly-policy.d.ts.map +1 -0
  105. package/dist/mfu-reassembly-policy.js +99 -0
  106. package/dist/mfu-reassembly-policy.js.map +7 -0
  107. package/dist/mmtp-container-parser.d.ts +304 -0
  108. package/dist/mmtp-container-parser.d.ts.map +1 -0
  109. package/dist/mmtp-container-parser.js +5378 -0
  110. package/dist/mmtp-container-parser.js.map +7 -0
  111. package/dist/mmtp-container-parser.no-modules.js +7853 -0
  112. package/dist/mmtp-container-parser.no-modules.js.map +7 -0
  113. package/dist/mmtp-decode-pipeline.d.ts +96 -0
  114. package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
  115. package/dist/mmtp-decode-pipeline.js +5589 -0
  116. package/dist/mmtp-decode-pipeline.js.map +7 -0
  117. package/dist/mmtp-router.d.ts +383 -0
  118. package/dist/mmtp-router.d.ts.map +1 -0
  119. package/dist/mmtp-router.js +8384 -0
  120. package/dist/mmtp-router.js.map +7 -0
  121. package/dist/mmtp-to-cmaf.d.ts +166 -0
  122. package/dist/mmtp-to-cmaf.d.ts.map +1 -0
  123. package/dist/mmtp-to-cmaf.js +781 -0
  124. package/dist/mmtp-to-cmaf.js.map +7 -0
  125. package/dist/multicast-auth-catalog.d.ts +115 -0
  126. package/dist/multicast-auth-catalog.d.ts.map +1 -0
  127. package/dist/multicast-auth-catalog.js +202 -0
  128. package/dist/multicast-auth-catalog.js.map +7 -0
  129. package/dist/multicast-input.d.ts +107 -0
  130. package/dist/multicast-input.d.ts.map +1 -0
  131. package/dist/multicast-input.js +256 -0
  132. package/dist/multicast-input.js.map +7 -0
  133. package/dist/multicast-manager.d.ts +330 -0
  134. package/dist/multicast-manager.d.ts.map +1 -0
  135. package/dist/multicast-manager.js +11032 -0
  136. package/dist/multicast-manager.js.map +7 -0
  137. package/dist/multicast-transport.d.ts +62 -0
  138. package/dist/multicast-transport.d.ts.map +1 -0
  139. package/dist/multicast-transport.js +338 -0
  140. package/dist/multicast-transport.js.map +7 -0
  141. package/dist/multicast-unwrap.d.ts +57 -0
  142. package/dist/multicast-unwrap.d.ts.map +1 -0
  143. package/dist/multicast-unwrap.js +384 -0
  144. package/dist/multicast-unwrap.js.map +7 -0
  145. package/dist/no-modules.d.ts +9 -0
  146. package/dist/no-modules.d.ts.map +1 -0
  147. package/dist/no-modules.js +7819 -0
  148. package/dist/no-modules.js.map +7 -0
  149. package/dist/phase14-catalog-override.d.ts +126 -0
  150. package/dist/phase14-catalog-override.d.ts.map +1 -0
  151. package/dist/phase14-catalog-override.js +155 -0
  152. package/dist/phase14-catalog-override.js.map +7 -0
  153. package/dist/repair-fetch.d.ts +58 -0
  154. package/dist/repair-fetch.d.ts.map +1 -0
  155. package/dist/repair-fetch.js +117 -0
  156. package/dist/repair-fetch.js.map +7 -0
  157. package/dist/sample-combiner.d.ts +182 -0
  158. package/dist/sample-combiner.d.ts.map +1 -0
  159. package/dist/sample-combiner.js +571 -0
  160. package/dist/sample-combiner.js.map +7 -0
  161. package/dist/signaling.d.ts +29 -0
  162. package/dist/signaling.d.ts.map +1 -0
  163. package/dist/signaling.js +232 -0
  164. package/dist/signaling.js.map +7 -0
  165. package/dist/source-auth.d.ts +2 -0
  166. package/dist/source-auth.d.ts.map +1 -0
  167. package/dist/source-auth.js +1220 -0
  168. package/dist/source-auth.js.map +7 -0
  169. package/dist/switching-set-alignment.d.ts +61 -0
  170. package/dist/switching-set-alignment.d.ts.map +1 -0
  171. package/dist/switching-set-alignment.js +85 -0
  172. package/dist/switching-set-alignment.js.map +7 -0
  173. package/dist/timestamp-codec.d.ts +34 -0
  174. package/dist/timestamp-codec.d.ts.map +1 -0
  175. package/dist/timestamp-codec.js +456 -0
  176. package/dist/timestamp-codec.js.map +7 -0
  177. package/dist/track-pipeline-setup.d.ts +72 -0
  178. package/dist/track-pipeline-setup.d.ts.map +1 -0
  179. package/dist/track-pipeline-setup.js +306 -0
  180. package/dist/track-pipeline-setup.js.map +7 -0
  181. package/dist/track-pipeline.d.ts +121 -0
  182. package/dist/track-pipeline.d.ts.map +1 -0
  183. package/dist/track-pipeline.js +229 -0
  184. package/dist/track-pipeline.js.map +7 -0
  185. package/dist/track-session.d.ts +269 -0
  186. package/dist/track-session.d.ts.map +1 -0
  187. package/dist/track-session.js +597 -0
  188. package/dist/track-session.js.map +7 -0
  189. package/dist/transport-pool.d.ts +69 -0
  190. package/dist/transport-pool.d.ts.map +1 -0
  191. package/dist/transport-pool.js +88 -0
  192. package/dist/transport-pool.js.map +7 -0
  193. package/dist/wasm-mfu-reassembler.d.ts +81 -0
  194. package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
  195. package/dist/wasm-mfu-reassembler.js +1915 -0
  196. package/dist/wasm-mfu-reassembler.js.map +7 -0
  197. package/dist/wasm-mmtp-container-parser.d.ts +10 -0
  198. package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
  199. package/dist/wasm-mmtp-container-parser.js +5635 -0
  200. package/dist/wasm-mmtp-container-parser.js.map +7 -0
  201. package/node_modules/@blockcast/fec-worker/README.md +213 -0
  202. package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
  203. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +80 -0
  204. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
  205. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +270 -0
  206. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
  207. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +252 -0
  208. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
  209. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
  210. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
  211. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
  212. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
  213. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +565 -0
  214. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
  215. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
  216. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
  217. package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
  218. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
  219. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
  220. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
  221. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +349 -0
  222. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
  223. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
  224. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
  225. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
  226. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
  227. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +179 -0
  228. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
  229. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +47 -0
  230. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
  231. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
  232. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
  233. package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
  234. package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
  235. package/node_modules/@blockcast/fec-worker/package.json +59 -0
  236. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +309 -0
  237. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +268 -0
  238. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1048 -0
  239. package/node_modules/@blockcast/fec-worker/src/index.ts +32 -0
  240. package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +558 -0
  241. package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
  242. package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +194 -0
  243. package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
  244. package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  245. package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  246. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  247. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  248. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  249. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  250. package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  251. package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  252. package/node_modules/@blockcast/mmt-base/README.md +120 -0
  253. package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  254. package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  255. package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  256. package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  257. package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  258. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
  259. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  260. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
  261. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  262. package/node_modules/@blockcast/mmt-base/package.json +49 -0
  263. package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  264. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
  265. package/node_modules/@blockcast/mmt-fec/README.md +270 -0
  266. package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
  267. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +80 -0
  268. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
  269. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +294 -0
  270. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
  271. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +72 -0
  272. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
  273. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +192 -0
  274. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
  275. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
  276. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
  277. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
  278. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
  279. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
  280. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
  281. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
  282. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
  283. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +185 -0
  284. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
  285. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +273 -0
  286. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
  287. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +22 -0
  288. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
  289. package/node_modules/@blockcast/mmt-fec/dist/index.js +22 -0
  290. package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
  291. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
  292. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
  293. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
  294. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
  295. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +174 -0
  296. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
  297. package/node_modules/@blockcast/mmt-fec/dist/oti.js +256 -0
  298. package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
  299. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
  300. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
  301. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
  302. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
  303. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
  304. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  305. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
  306. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
  307. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
  308. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
  309. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
  310. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
  311. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +120 -0
  312. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  313. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
  314. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
  315. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
  316. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
  317. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
  318. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
  319. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
  320. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
  321. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
  322. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
  323. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
  324. package/node_modules/@blockcast/mmt-fec/package.json +79 -0
  325. package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +369 -0
  326. package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +277 -0
  327. package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
  328. package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
  329. package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +332 -0
  330. package/node_modules/@blockcast/mmt-fec/src/index.ts +77 -0
  331. package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
  332. package/node_modules/@blockcast/mmt-fec/src/oti.ts +319 -0
  333. package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
  334. package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
  335. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
  336. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
  337. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
  338. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
  339. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
  340. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
  341. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
  342. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
  343. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
  344. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
  345. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
  346. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
  347. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +90 -0
  348. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
  349. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +462 -0
  350. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
  351. package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
  352. package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
  353. package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
  354. package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
  355. package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +636 -0
  356. package/node_modules/@noble/hashes/LICENSE +21 -0
  357. package/node_modules/@noble/hashes/README.md +521 -0
  358. package/node_modules/@noble/hashes/_assert.d.ts +17 -0
  359. package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
  360. package/node_modules/@noble/hashes/_assert.js +18 -0
  361. package/node_modules/@noble/hashes/_assert.js.map +1 -0
  362. package/node_modules/@noble/hashes/_blake.d.ts +14 -0
  363. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  364. package/node_modules/@noble/hashes/_blake.js +50 -0
  365. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  366. package/node_modules/@noble/hashes/_md.d.ts +51 -0
  367. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  368. package/node_modules/@noble/hashes/_md.js +162 -0
  369. package/node_modules/@noble/hashes/_md.js.map +1 -0
  370. package/node_modules/@noble/hashes/_u64.d.ts +55 -0
  371. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  372. package/node_modules/@noble/hashes/_u64.js +90 -0
  373. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  374. package/node_modules/@noble/hashes/argon2.d.ts +32 -0
  375. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  376. package/node_modules/@noble/hashes/argon2.js +401 -0
  377. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  378. package/node_modules/@noble/hashes/blake1.d.ts +106 -0
  379. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  380. package/node_modules/@noble/hashes/blake1.js +459 -0
  381. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  382. package/node_modules/@noble/hashes/blake2.d.ts +116 -0
  383. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  384. package/node_modules/@noble/hashes/blake2.js +420 -0
  385. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  386. package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
  387. package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
  388. package/node_modules/@noble/hashes/blake2b.js +14 -0
  389. package/node_modules/@noble/hashes/blake2b.js.map +1 -0
  390. package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
  391. package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
  392. package/node_modules/@noble/hashes/blake2s.js +24 -0
  393. package/node_modules/@noble/hashes/blake2s.js.map +1 -0
  394. package/node_modules/@noble/hashes/blake3.d.ts +54 -0
  395. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  396. package/node_modules/@noble/hashes/blake3.js +255 -0
  397. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  398. package/node_modules/@noble/hashes/crypto.d.ts +2 -0
  399. package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
  400. package/node_modules/@noble/hashes/crypto.js +5 -0
  401. package/node_modules/@noble/hashes/crypto.js.map +1 -0
  402. package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
  403. package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
  404. package/node_modules/@noble/hashes/cryptoNode.js +18 -0
  405. package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
  406. package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
  407. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  408. package/node_modules/@noble/hashes/eskdf.js +166 -0
  409. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  410. package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
  411. package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
  412. package/node_modules/@noble/hashes/esm/_assert.js +15 -0
  413. package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
  414. package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
  415. package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
  416. package/node_modules/@noble/hashes/esm/_blake.js +45 -0
  417. package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
  418. package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
  419. package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
  420. package/node_modules/@noble/hashes/esm/_md.js +155 -0
  421. package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  422. package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
  423. package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
  424. package/node_modules/@noble/hashes/esm/_u64.js +67 -0
  425. package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  426. package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
  427. package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
  428. package/node_modules/@noble/hashes/esm/argon2.js +392 -0
  429. package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
  430. package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
  431. package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
  432. package/node_modules/@noble/hashes/esm/blake1.js +452 -0
  433. package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
  434. package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
  435. package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
  436. package/node_modules/@noble/hashes/esm/blake2.js +413 -0
  437. package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
  438. package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
  439. package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
  440. package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
  441. package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
  442. package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
  443. package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
  444. package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
  445. package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
  446. package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
  447. package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
  448. package/node_modules/@noble/hashes/esm/blake3.js +251 -0
  449. package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
  450. package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
  451. package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
  452. package/node_modules/@noble/hashes/esm/crypto.js +2 -0
  453. package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
  454. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
  455. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
  456. package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
  457. package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
  458. package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
  459. package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
  460. package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
  461. package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
  462. package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
  463. package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
  464. package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
  465. package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
  466. package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
  467. package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
  468. package/node_modules/@noble/hashes/esm/hmac.js +86 -0
  469. package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
  470. package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
  471. package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
  472. package/node_modules/@noble/hashes/esm/index.js +33 -0
  473. package/node_modules/@noble/hashes/esm/index.js.map +1 -0
  474. package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
  475. package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
  476. package/node_modules/@noble/hashes/esm/legacy.js +281 -0
  477. package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  478. package/node_modules/@noble/hashes/esm/package.json +10 -0
  479. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
  480. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
  481. package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
  482. package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
  483. package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
  484. package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
  485. package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
  486. package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
  487. package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
  488. package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
  489. package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
  490. package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
  491. package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
  492. package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
  493. package/node_modules/@noble/hashes/esm/sha1.js +11 -0
  494. package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
  495. package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
  496. package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
  497. package/node_modules/@noble/hashes/esm/sha2.js +375 -0
  498. package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  499. package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
  500. package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
  501. package/node_modules/@noble/hashes/esm/sha256.js +20 -0
  502. package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
  503. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
  504. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
  505. package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
  506. package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
  507. package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
  508. package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
  509. package/node_modules/@noble/hashes/esm/sha3.js +234 -0
  510. package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
  511. package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
  512. package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
  513. package/node_modules/@noble/hashes/esm/sha512.js +26 -0
  514. package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
  515. package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
  516. package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
  517. package/node_modules/@noble/hashes/esm/utils.js +281 -0
  518. package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  519. package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
  520. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  521. package/node_modules/@noble/hashes/hkdf.js +88 -0
  522. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  523. package/node_modules/@noble/hashes/hmac.d.ts +35 -0
  524. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  525. package/node_modules/@noble/hashes/hmac.js +91 -0
  526. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  527. package/node_modules/@noble/hashes/index.d.ts +1 -0
  528. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  529. package/node_modules/@noble/hashes/index.js +33 -0
  530. package/node_modules/@noble/hashes/index.js.map +1 -0
  531. package/node_modules/@noble/hashes/legacy.d.ts +71 -0
  532. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  533. package/node_modules/@noble/hashes/legacy.js +287 -0
  534. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  535. package/node_modules/@noble/hashes/package.json +266 -0
  536. package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
  537. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  538. package/node_modules/@noble/hashes/pbkdf2.js +101 -0
  539. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  540. package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
  541. package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
  542. package/node_modules/@noble/hashes/ripemd160.js +16 -0
  543. package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
  544. package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
  545. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  546. package/node_modules/@noble/hashes/scrypt.js +232 -0
  547. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  548. package/node_modules/@noble/hashes/sha1.d.ts +11 -0
  549. package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
  550. package/node_modules/@noble/hashes/sha1.js +14 -0
  551. package/node_modules/@noble/hashes/sha1.js.map +1 -0
  552. package/node_modules/@noble/hashes/sha2.d.ts +159 -0
  553. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  554. package/node_modules/@noble/hashes/sha2.js +384 -0
  555. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  556. package/node_modules/@noble/hashes/sha256.d.ts +20 -0
  557. package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
  558. package/node_modules/@noble/hashes/sha256.js +23 -0
  559. package/node_modules/@noble/hashes/sha256.js.map +1 -0
  560. package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
  561. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  562. package/node_modules/@noble/hashes/sha3-addons.js +402 -0
  563. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  564. package/node_modules/@noble/hashes/sha3.d.ts +53 -0
  565. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  566. package/node_modules/@noble/hashes/sha3.js +239 -0
  567. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  568. package/node_modules/@noble/hashes/sha512.d.ts +26 -0
  569. package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
  570. package/node_modules/@noble/hashes/sha512.js +29 -0
  571. package/node_modules/@noble/hashes/sha512.js.map +1 -0
  572. package/node_modules/@noble/hashes/src/_assert.ts +22 -0
  573. package/node_modules/@noble/hashes/src/_blake.ts +50 -0
  574. package/node_modules/@noble/hashes/src/_md.ts +176 -0
  575. package/node_modules/@noble/hashes/src/_u64.ts +91 -0
  576. package/node_modules/@noble/hashes/src/argon2.ts +497 -0
  577. package/node_modules/@noble/hashes/src/blake1.ts +534 -0
  578. package/node_modules/@noble/hashes/src/blake2.ts +486 -0
  579. package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
  580. package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
  581. package/node_modules/@noble/hashes/src/blake3.ts +272 -0
  582. package/node_modules/@noble/hashes/src/crypto.ts +9 -0
  583. package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
  584. package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
  585. package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
  586. package/node_modules/@noble/hashes/src/hmac.ts +94 -0
  587. package/node_modules/@noble/hashes/src/index.ts +31 -0
  588. package/node_modules/@noble/hashes/src/legacy.ts +293 -0
  589. package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
  590. package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
  591. package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
  592. package/node_modules/@noble/hashes/src/sha1.ts +10 -0
  593. package/node_modules/@noble/hashes/src/sha2.ts +402 -0
  594. package/node_modules/@noble/hashes/src/sha256.ts +24 -0
  595. package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
  596. package/node_modules/@noble/hashes/src/sha3.ts +258 -0
  597. package/node_modules/@noble/hashes/src/sha512.ts +34 -0
  598. package/node_modules/@noble/hashes/src/utils.ts +395 -0
  599. package/node_modules/@noble/hashes/utils.d.ts +161 -0
  600. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  601. package/node_modules/@noble/hashes/utils.js +313 -0
  602. package/node_modules/@noble/hashes/utils.js.map +1 -0
  603. package/package.json +203 -0
  604. package/schemas/catalog.schema.json +283 -0
  605. package/src/align.ts +235 -0
  606. package/src/audio-init-parser.ts +189 -0
  607. package/src/audio-ring-buffer.ts +120 -0
  608. package/src/authored-timing.ts +63 -0
  609. package/src/carp-catalog.ts +776 -0
  610. package/src/catalog-fec-params.ts +167 -0
  611. package/src/catalog-network-source.ts +49 -0
  612. package/src/catalog-validator.ts +34 -0
  613. package/src/cmaf-block-assembler.ts +1058 -0
  614. package/src/cmaf-group-batcher.ts +104 -0
  615. package/src/cmcd-producer.ts +329 -0
  616. package/src/codec-utils.ts +1539 -0
  617. package/src/fec-codec.ts +61 -0
  618. package/src/fec-manager.ts +1939 -0
  619. package/src/fec-starvation-detector.ts +128 -0
  620. package/src/fec-worker-setup.ts +177 -0
  621. package/src/fmp4-completion.ts +47 -0
  622. package/src/fmp4-reader.ts +112 -0
  623. package/src/index.ts +443 -0
  624. package/src/iso-bmff-timing.ts +688 -0
  625. package/src/loc.ts +181 -0
  626. package/src/manifest-auth-plan.ts +107 -0
  627. package/src/media-router.ts +1185 -0
  628. package/src/mfu-reassembler.ts +2842 -0
  629. package/src/mfu-reassembly-policy.ts +134 -0
  630. package/src/mmtp-container-parser.ts +1498 -0
  631. package/src/mmtp-decode-pipeline.ts +315 -0
  632. package/src/mmtp-router.ts +3027 -0
  633. package/src/mmtp-to-cmaf.ts +956 -0
  634. package/src/multicast-auth-catalog.ts +340 -0
  635. package/src/multicast-input.ts +439 -0
  636. package/src/multicast-manager.ts +1503 -0
  637. package/src/multicast-transport.ts +320 -0
  638. package/src/multicast-unwrap.ts +132 -0
  639. package/src/no-modules.ts +20 -0
  640. package/src/phase14-catalog-override.ts +336 -0
  641. package/src/repair-fetch.ts +217 -0
  642. package/src/sample-combiner.ts +846 -0
  643. package/src/signaling.ts +78 -0
  644. package/src/source-auth.ts +1 -0
  645. package/src/switching-set-alignment.ts +109 -0
  646. package/src/timestamp-codec.ts +265 -0
  647. package/src/track-pipeline-setup.ts +189 -0
  648. package/src/track-pipeline.ts +332 -0
  649. package/src/track-session.ts +778 -0
  650. package/src/transport-pool.ts +128 -0
  651. package/src/wasm-mfu-reassembler.ts +372 -0
  652. package/src/wasm-mmtp-container-parser.ts +23 -0
  653. package/test-vectors/align.json +199 -0
  654. package/test-vectors/catalog/README.md +25 -0
  655. package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
  656. package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
  657. package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
  658. package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
  659. package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
  660. package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
  661. package/test-vectors/catalog/negative/network-source-object.json +25 -0
  662. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +26 -0
  663. package/test-vectors/catalog/negative/repair-track-legacy-shape.json +18 -0
  664. package/test-vectors/catalog/negative/track-role-empty.json +16 -0
  665. package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
  666. package/test-vectors/catalog/positive/fec-multicast.json +51 -0
  667. package/test-vectors/catalog/positive/flat-av.json +30 -0
  668. package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
  669. package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
  670. package/test-vectors/catalog/positive/track-role.json +49 -0
  671. package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
  672. package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
  673. package/test-vectors/catalog-multicast-auth-v1.json +26 -0
  674. package/test-vectors/catalog-validation.json +148 -0
  675. package/test-vectors/catalog-validator-public-api.mjs +25 -0
  676. package/test-vectors/generate-source-auth-fixture.mjs +114 -0
  677. package/test-vectors/source-auth-v1.json +61 -0
  678. package/test-vectors/subsample-placement-v1.json +230 -0
@@ -0,0 +1,1447 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ 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);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+ var __privateWrapper = (obj, member, setter, getter) => ({
10
+ set _(value) {
11
+ __privateSet(obj, member, value, setter);
12
+ },
13
+ get _() {
14
+ return __privateGet(obj, member, getter);
15
+ }
16
+ });
17
+
18
+ // src/track-session.ts
19
+ import { deriveFecInterleaveDepth } from "@blockcast/mmt-fec";
20
+ function computeFecDeliveryWindowMs(config) {
21
+ const fecInterleaveMs = config.interleaveDepthMs;
22
+ const fecK = config.sourceSymbols;
23
+ if (fecInterleaveMs <= 0) {
24
+ throw new Error(
25
+ `[TrackSession] fecInterleaveMs=${fecInterleaveMs}. Derive a positive FEC interleave window from the stream catalog.`
26
+ );
27
+ }
28
+ if (fecK <= 0) {
29
+ throw new Error(
30
+ `[TrackSession] fecK=${fecK}. Derive a positive FEC source-symbol count from the stream catalog.`
31
+ );
32
+ }
33
+ const spansMs = [fecInterleaveMs];
34
+ if (config.mediaUnitsPerSecond && config.mediaUnitsPerSecond > 0) {
35
+ const mediaUnitMs = 1e3 / config.mediaUnitsPerSecond;
36
+ const interleaveUnits = deriveFecInterleaveDepth(fecInterleaveMs, mediaUnitMs);
37
+ const deliverySymbols = fecK + Math.max(0, config.repairSymbols ?? 0);
38
+ spansMs.push(deliverySymbols * interleaveUnits * mediaUnitMs);
39
+ }
40
+ if (config.symbolSize && config.symbolSize > 0 && config.bandwidthBps && config.bandwidthBps > 0) {
41
+ const repairSymbols = Math.max(0, config.repairSymbols ?? 0);
42
+ spansMs.push(
43
+ (fecK + repairSymbols) * config.symbolSize * 8 * 1e3 / config.bandwidthBps
44
+ );
45
+ }
46
+ const coreMs = Math.max(...spansMs);
47
+ const marginMs = config.jitterBufferMs !== void 0 && config.jitterBufferMs >= 0 ? config.jitterBufferMs : fecInterleaveMs;
48
+ return Math.ceil(coreMs) + Math.ceil(marginMs);
49
+ }
50
+
51
+ // src/fec-manager.ts
52
+ import { deriveFecInterleaveDepth as deriveFecInterleaveDepth2 } from "@blockcast/mmt-fec";
53
+ var MIN_INTERLEAVE_DEPTH_MS = 33;
54
+ var WORKER_ERROR_LOG_CAP = 5;
55
+ var WORKER_ERROR_KIND_CAP = 32;
56
+ var WORKER_ERROR_OVERFLOW_KIND = "other";
57
+ var STARTUP_REPAIR_WAIT_SOURCE_BOUNDARIES = 2;
58
+ function newFecCounters() {
59
+ return {
60
+ sourcePackets: 0,
61
+ repairPackets: 0,
62
+ duplicateSymbols: 0,
63
+ blocksClean: 0,
64
+ blocksRecovered: 0,
65
+ blocksFailed: 0,
66
+ greenFillFrames: 0
67
+ };
68
+ }
69
+ var _fecDecoders, _workerClients, _syncDecoderBlockOwners, _decoderBlockOwners, _fecK, _fecSymbolSize, _fecTimeoutMs, _trackConfigs, _fecStats, _fecTrackStats, _fecWorkerStats, _fecStatsObservers, _activeBlocks, _activeBlockDeadlinesMs, _activeBlockTimeoutOwners, _lifecycleTrace, _pendingWorkerCleanups, _pendingWorkerCleanupClients, _blockSourceCounts, _blockSourceEsis, _blockRepairRsIds, _completedBlocks, _seenSymbols, _blockPathCounts, _blockCatalogTrackNames, _startupAlignedPackets, _startupPartialBlocks, _startupRequireRepairReady, _startupRepairReadyPackets, _startupRepairBoundaryCounts, _startupRepairFailOpenPackets, _cleanlyCompletedBlocks, _repairRequestedBlocks, _repairDeadlines, _workerRecoveredBlocks, _fpsDetected, _fecFps, _fecInterleaveDepthMs, _workerErrorCounts, _repairSymbolSizeMismatchCount, _FECManager_instances, streamKey_fn, belongsToPacket_fn, belongsToStream_fn, packetIdsForStreamKeys_fn, blockKey_fn, parseBlockKey_fn, decoderForPacket_fn, workerForPacket_fn, claimDecoderBlock_fn, decoderBlockCatalogTrackName_fn, resetDecoderBlockOwners_fn, discardFecDecoderClient_fn, assertExclusiveDecoderClient_fn, statsForPacket_fn, markPathBlockComplete_fn, clearRepairDeadline_fn, requestRepair_fn, traceLifecycle_fn, defaultTrackConfig_fn, resolveTrackConfig_fn, computeTimeout_fn, repairDeadlineMs_fn, repairGraceMs_fn, armBlockTimeout_fn, upsertTrackConfig_fn, normalizeSymbolData_fn, blockKeysFor_fn, observeBlockCatalogTrackName_fn, markStartupPartial_fn, routeSyncCleanup_fn, failBlock_fn;
70
+ var FECManager = class {
71
+ constructor() {
72
+ __privateAdd(this, _FECManager_instances);
73
+ // Per-track WASM RaptorQ decoders, keyed by physical stream identity.
74
+ __privateAdd(this, _fecDecoders, /* @__PURE__ */ new Map());
75
+ /** @deprecated Use setFecDecoder(packetId, ...). Backwards-compat shim. */
76
+ // Per-track Worker-backed FEC decoders, keyed by physical stream identity.
77
+ // Worker-backed tracks use async decode — recovered frames arrive via onFrame callback,
78
+ // not synchronous return from feedSourceSymbol/feedRepairSymbol.
79
+ __privateAdd(this, _workerClients, /* @__PURE__ */ new Map());
80
+ // Worker setup can finish while an interleaved block is already collecting
81
+ // on the sync decoder. Keep that block on its original decoder so later
82
+ // source/repair symbols do not split across two RaptorQ states.
83
+ __privateAdd(this, _syncDecoderBlockOwners, /* @__PURE__ */ new Map());
84
+ __privateAdd(this, _decoderBlockOwners, /* @__PURE__ */ new WeakMap());
85
+ __privateAdd(this, _fecK, 4);
86
+ __privateAdd(this, _fecSymbolSize, 0);
87
+ __privateAdd(this, _fecTimeoutMs, 500);
88
+ // default 500ms; refined by setFramerate() when fps known
89
+ __privateAdd(this, _trackConfigs, /* @__PURE__ */ new Map());
90
+ __privateAdd(this, _fecStats, newFecCounters());
91
+ __privateAdd(this, _fecTrackStats, /* @__PURE__ */ new Map());
92
+ __privateAdd(this, _fecWorkerStats, /* @__PURE__ */ new Map());
93
+ __privateAdd(this, _fecStatsObservers, /* @__PURE__ */ new Set());
94
+ // Block inactivity tracking: (packetId, SBN) -> timer. The deadline is
95
+ // derived from catalog geometry and refreshed on progress; only an idle
96
+ // block fails.
97
+ __privateAdd(this, _activeBlocks, /* @__PURE__ */ new Map());
98
+ __privateAdd(this, _activeBlockDeadlinesMs, /* @__PURE__ */ new Map());
99
+ __privateAdd(this, _activeBlockTimeoutOwners, /* @__PURE__ */ new Map());
100
+ __privateAdd(this, _lifecycleTrace, []);
101
+ // Worker-backed timeouts enqueue cleanup behind all prior symbol messages.
102
+ // Failure remains pending until cleanupComplete acknowledges that queue drain.
103
+ __privateAdd(this, _pendingWorkerCleanups, /* @__PURE__ */ new Set());
104
+ __privateAdd(this, _pendingWorkerCleanupClients, /* @__PURE__ */ new Map());
105
+ // Source symbol count per track-scoped block — marks complete when K symbols arrive.
106
+ __privateAdd(this, _blockSourceCounts, /* @__PURE__ */ new Map());
107
+ __privateAdd(this, _blockSourceEsis, /* @__PURE__ */ new Map());
108
+ __privateAdd(this, _blockRepairRsIds, /* @__PURE__ */ new Map());
109
+ // Blocks already recovered — prevents late source symbols from restarting timeouts.
110
+ // WASM removes blocks after recovery; late symbols create empty blocks returning null,
111
+ // which would falsely start new timeouts without this guard.
112
+ __privateAdd(this, _completedBlocks, /* @__PURE__ */ new Set());
113
+ __privateAdd(this, _seenSymbols, /* @__PURE__ */ new Set());
114
+ __privateAdd(this, _blockPathCounts, /* @__PURE__ */ new Map());
115
+ // Exact catalog identity observed on accepted symbols for each FEC block.
116
+ // Conflicting identities collapse to null so recovery fails closed.
117
+ __privateAdd(this, _blockCatalogTrackNames, /* @__PURE__ */ new Map());
118
+ // A receiver joins an already-running live stream in the middle of D
119
+ // interleaved source blocks. This applies to both multicast and reliable MoQ:
120
+ // a MoQ group boundary is not an FEC ESI=0 boundary. Those blocks are not
121
+ // packet loss because their earlier ESIs predate the subscription. Ignore
122
+ // each such block until ESI=0 establishes a complete boundary for the track.
123
+ // After that boundary, a first observed ESI>0 is real delivery loss and must
124
+ // continue through normal FEC recovery/failure accounting.
125
+ __privateAdd(this, _startupAlignedPackets, /* @__PURE__ */ new Set());
126
+ __privateAdd(this, _startupPartialBlocks, /* @__PURE__ */ new Set());
127
+ // A live multicast join can observe an ESI=0 source boundary before the
128
+ // repair lane catches up. Returning false here also drops that media packet
129
+ // at MmtpRouter, so the readiness probe is multicast-only and bounded: an
130
+ // actual multicast repair unlocks the next boundary, while a second source
131
+ // boundary fails open. Reliable MoQ media continues through normal startup
132
+ // alignment and retained MoQ repair cannot prove multicast readiness.
133
+ __privateAdd(this, _startupRequireRepairReady, false);
134
+ __privateAdd(this, _startupRepairReadyPackets, /* @__PURE__ */ new Set());
135
+ __privateAdd(this, _startupRepairBoundaryCounts, /* @__PURE__ */ new Map());
136
+ __privateAdd(this, _startupRepairFailOpenPackets, /* @__PURE__ */ new Set());
137
+ // SBNs that reached K source-symbol arrivals via trackBlock. Used by the
138
+ // worker recovery suppression check (see onFrame handler below) so we only
139
+ // suppress `recovered=true` emits for blocks that ALSO completed cleanly
140
+ // via source symbols. Separating this from #completedBlocks (which is also
141
+ // populated by every worker frame emit, by failed timeouts, and by external
142
+ // callers) was the BLO-3323 L15 fix: the prior predicate caused blocksRecovered
143
+ // to stay at 0 because the SBN was always in #completedBlocks by the time the
144
+ // worker fired recovered=true.
145
+ __privateAdd(this, _cleanlyCompletedBlocks, /* @__PURE__ */ new Set());
146
+ // D-28: blocks whose repair deadline already fired onRepairNeeded. At most
147
+ // one repair request per block; entries are removed when the block
148
+ // completes, recovers, or fails.
149
+ __privateAdd(this, _repairRequestedBlocks, /* @__PURE__ */ new Set());
150
+ // D-28: repair-deadline timers refreshed by accepted source progress until
151
+ // the first repair request. A `null` value marks a deadline that already
152
+ // fired (never re-armed). At most K accepted source symbols can refresh the
153
+ // horizon, so browser scheduling delay cannot create an early loss signal
154
+ // and repair traffic cannot keep a block alive indefinitely.
155
+ __privateAdd(this, _repairDeadlines, /* @__PURE__ */ new Map());
156
+ // Worker recovery emits all K source symbols. Track recovery once per block
157
+ // while routing only ESI slots that were absent from the direct source path.
158
+ __privateAdd(this, _workerRecoveredBlocks, /* @__PURE__ */ new Set());
159
+ // Framerate detection state
160
+ __privateAdd(this, _fpsDetected, false);
161
+ __privateAdd(this, _fecFps);
162
+ __privateAdd(this, _fecInterleaveDepthMs, 0);
163
+ // Worker error log rate-limiter — bounds console.warn output and exported
164
+ // error cardinality when the FEC Worker emits the same failure repeatedly
165
+ // with volatile packet details (e.g. ssStart) in the message text.
166
+ // Stable Worker codes aggregate those messages; uncoded/legacy messages are
167
+ // capped into an `other` bucket. This also covers wasm-bindgen
168
+ // "recursive use of an object" bubbled from add_source/add_repair during
169
+ // overlapping message processing). Without this, Point 5 of the 7-point
170
+ // validation harness — which caps headless warnings at 500 — fails even
171
+ // though the errors are duplicates of a single underlying event.
172
+ __privateAdd(this, _workerErrorCounts, /* @__PURE__ */ new Map());
173
+ __privateAdd(this, _repairSymbolSizeMismatchCount, 0);
174
+ // Event callbacks — block lifecycle notifications for MmtpRouter wiring.
175
+ // NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
176
+ // feedSourceSymbol/feedRepairSymbol return values. For Worker path, recovery
177
+ // arrives via onBlockRecovered callback.
178
+ this.onBlockStarted = null;
179
+ this.onBlockComplete = null;
180
+ this.onBlockFailed = null;
181
+ // D-28 on-demand repair callbacks. When onRepairNeeded is registered, each
182
+ // block arms a one-shot repair deadline after the derived K-symbol source
183
+ // horizon; a block still short of K when it fires requests a per-SBN MoQ
184
+ // repair fetch upstream. The inactivity fail bound is unchanged either way —
185
+ // repair and failure are orthogonal timers, so wiring D-28 never delays
186
+ // failure accounting. onRepairResolved fires when a repair-requested block
187
+ // leaves the active set, with the outcome ("completed" after clean completion
188
+ // or recovery, "failed" at the fail bound) so the upstream in-flight slot
189
+ // (MulticastManager.clearRepairForBlock) can be released and logged.
190
+ this.onRepairNeeded = null;
191
+ this.onRepairResolved = null;
192
+ // Worker-path callbacks — async recovery and stats from FecWorkerClient.
193
+ this.onBlockRecovered = null;
194
+ this.onFecStatsUpdate = null;
195
+ this.onGreenFill = null;
196
+ }
197
+ // -----------------------------------------------------------------------
198
+ // Accessors
199
+ // -----------------------------------------------------------------------
200
+ /** Internal state for diagnostics — not part of the public stats API. */
201
+ get diagnostics() {
202
+ return {
203
+ timeoutMs: __privateGet(this, _fecTimeoutMs),
204
+ activeBlocks: __privateGet(this, _activeBlocks).size,
205
+ completedBlocks: __privateGet(this, _completedBlocks).size,
206
+ pendingCounts: Object.fromEntries(__privateGet(this, _blockSourceCounts)),
207
+ fpsDetected: __privateGet(this, _fpsDetected),
208
+ interleaveDepthMs: __privateGet(this, _fecInterleaveDepthMs),
209
+ startupAlignedPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupAlignedPackets)),
210
+ startupPartialBlocks: __privateGet(this, _startupPartialBlocks).size,
211
+ startupRepairReadyPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairReadyPackets)),
212
+ startupRepairFailOpenPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairFailOpenPackets)),
213
+ pendingWorkerCleanups: __privateGet(this, _pendingWorkerCleanups).size,
214
+ repairTrackedBlocks: __privateGet(this, _blockRepairRsIds).size,
215
+ lifecycleTrace: __privateGet(this, _lifecycleTrace).map((entry) => ({ ...entry }))
216
+ };
217
+ }
218
+ get fecStats() {
219
+ const s = __privateGet(this, _fecStats);
220
+ const affected = s.blocksRecovered + s.blocksFailed;
221
+ const total = s.blocksClean + affected;
222
+ const tracks = [...__privateGet(this, _fecTrackStats).entries()].sort(([left], [right]) => left - right).map(([packetId, stats]) => {
223
+ const trackAffected = stats.blocksRecovered + stats.blocksFailed;
224
+ const trackTotal = stats.blocksClean + trackAffected;
225
+ return {
226
+ ...stats,
227
+ packetId,
228
+ blocksComplete: trackTotal,
229
+ k: __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).k,
230
+ recoveryRate: trackAffected > 0 ? stats.blocksRecovered / trackAffected * 100 : 100,
231
+ packetLossRate: trackTotal > 0 ? trackAffected / trackTotal * 100 : 0
232
+ };
233
+ });
234
+ return {
235
+ ...s,
236
+ blocksComplete: total,
237
+ mixedPathBlocks: Array.from(__privateGet(this, _blockPathCounts).values()).filter(
238
+ (block) => block.multicastSymbols > 0 && block.moqSymbols > 0
239
+ ).length,
240
+ recentBlockPathCounts: Array.from(__privateGet(this, _blockPathCounts).values()).slice(-24),
241
+ k: __privateGet(this, _fecK),
242
+ // True recovery rate: of blocks that HAD loss, how many were recovered?
243
+ recoveryRate: affected > 0 ? s.blocksRecovered / affected * 100 : 100,
244
+ packetLossRate: total > 0 ? affected / total * 100 : 0,
245
+ tracks,
246
+ workers: [...__privateGet(this, _fecWorkerStats).entries()].sort(([left], [right]) => left - right).map(([packetId, stats]) => ({
247
+ ...stats,
248
+ config: {
249
+ ...stats.config,
250
+ resolution: stats.config.resolution ? { ...stats.config.resolution } : void 0
251
+ },
252
+ blocks: stats.blocks.map((block) => ({ ...block })),
253
+ decoder: stats.decoder ? { ...stats.decoder } : void 0,
254
+ altaFailedDetails: stats.altaFailedDetails?.map((detail) => ({ ...detail })),
255
+ packetId
256
+ })),
257
+ repairSymbolSizeMismatches: __privateGet(this, _repairSymbolSizeMismatchCount),
258
+ workerErrors: Object.fromEntries(__privateGet(this, _workerErrorCounts))
259
+ };
260
+ }
261
+ /**
262
+ * Observe Worker-backed per-track snapshots without taking ownership of the
263
+ * legacy single-callback slot. Infrastructure diagnostics and a player may
264
+ * therefore consume the same source event without wrapping or replacing one
265
+ * another's callback.
266
+ */
267
+ addFecStatsObserver(observer) {
268
+ __privateGet(this, _fecStatsObservers).add(observer);
269
+ return () => __privateGet(this, _fecStatsObservers).delete(observer);
270
+ }
271
+ /** Start a new multicast transport join without discarding track/decoder state. */
272
+ beginMulticastJoin() {
273
+ __privateGet(this, _startupAlignedPackets).clear();
274
+ __privateGet(this, _startupPartialBlocks).clear();
275
+ __privateSet(this, _startupRequireRepairReady, true);
276
+ __privateGet(this, _startupRepairReadyPackets).clear();
277
+ __privateGet(this, _startupRepairBoundaryCounts).clear();
278
+ __privateGet(this, _startupRepairFailOpenPackets).clear();
279
+ }
280
+ /** Begin a fresh decode epoch for one physical stream. */
281
+ resetTrack(packetId, catalogTrackName) {
282
+ if (!Number.isInteger(packetId) || packetId < 0) {
283
+ throw new Error(`[FECManager] invalid packetId for reset: ${packetId}`);
284
+ }
285
+ if (!catalogTrackName) {
286
+ throw new Error("[FECManager] catalogTrackName is required for track reset");
287
+ }
288
+ const resetMap = (map) => {
289
+ for (const key of map.keys()) {
290
+ if (!__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) continue;
291
+ map.delete(key);
292
+ }
293
+ };
294
+ const resetTimerMap = (map) => {
295
+ for (const [key, timer] of map) {
296
+ if (!__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) continue;
297
+ if (timer != null) clearTimeout(timer);
298
+ map.delete(key);
299
+ }
300
+ };
301
+ const resetSet = (set) => {
302
+ for (const key of set) {
303
+ if (__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) set.delete(key);
304
+ }
305
+ };
306
+ resetTimerMap(__privateGet(this, _activeBlocks));
307
+ resetTimerMap(__privateGet(this, _repairDeadlines));
308
+ resetMap(__privateGet(this, _activeBlockDeadlinesMs));
309
+ resetMap(__privateGet(this, _activeBlockTimeoutOwners));
310
+ resetMap(__privateGet(this, _pendingWorkerCleanupClients));
311
+ resetMap(__privateGet(this, _blockSourceCounts));
312
+ resetMap(__privateGet(this, _blockSourceEsis));
313
+ resetMap(__privateGet(this, _blockRepairRsIds));
314
+ resetMap(__privateGet(this, _blockPathCounts));
315
+ resetMap(__privateGet(this, _blockCatalogTrackNames));
316
+ resetMap(__privateGet(this, _syncDecoderBlockOwners));
317
+ resetMap(__privateGet(this, _startupRepairBoundaryCounts));
318
+ resetSet(__privateGet(this, _pendingWorkerCleanups));
319
+ resetSet(__privateGet(this, _completedBlocks));
320
+ resetSet(__privateGet(this, _cleanlyCompletedBlocks));
321
+ resetSet(__privateGet(this, _repairRequestedBlocks));
322
+ resetSet(__privateGet(this, _workerRecoveredBlocks));
323
+ resetSet(__privateGet(this, _startupAlignedPackets));
324
+ resetSet(__privateGet(this, _startupPartialBlocks));
325
+ resetSet(__privateGet(this, _startupRepairReadyPackets));
326
+ resetSet(__privateGet(this, _startupRepairFailOpenPackets));
327
+ resetSet(__privateGet(this, _seenSymbols));
328
+ const decoderClients = /* @__PURE__ */ new Set();
329
+ for (const [key, entry] of __privateGet(this, _fecDecoders)) {
330
+ if (__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) {
331
+ decoderClients.add(entry.client);
332
+ }
333
+ }
334
+ const clients = /* @__PURE__ */ new Set();
335
+ for (const client of decoderClients) {
336
+ if (typeof client.flush === "function" && typeof client.reset_stats === "function") {
337
+ try {
338
+ client.flush();
339
+ client.reset_stats();
340
+ clients.add(client);
341
+ } catch {
342
+ __privateMethod(this, _FECManager_instances, discardFecDecoderClient_fn).call(this, client);
343
+ }
344
+ } else {
345
+ __privateMethod(this, _FECManager_instances, discardFecDecoderClient_fn).call(this, client);
346
+ }
347
+ }
348
+ for (const [key, client] of __privateGet(this, _workerClients)) {
349
+ if (!__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) continue;
350
+ client.reset();
351
+ clients.add(client);
352
+ }
353
+ for (const client of clients) __privateMethod(this, _FECManager_instances, resetDecoderBlockOwners_fn).call(this, client, catalogTrackName);
354
+ }
355
+ /** Record a transport symbol and reject later duplicates of the same packetId/SBN/ESI. */
356
+ feedSymbolFromSource(packetId, sbn, esi, _data, source, catalogTrackName) {
357
+ const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
358
+ const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
359
+ const k = this.kForPacket(packetId);
360
+ const isSourceSymbol = esi >= 0 && esi < k;
361
+ const isStartupPartial = __privateGet(this, _startupPartialBlocks).has(blockKey);
362
+ const awaitingMulticastRepair = __privateGet(this, _startupRequireRepairReady) && source === "multicast" && !__privateGet(this, _startupRepairReadyPackets).has(streamKey) && !__privateGet(this, _startupRepairFailOpenPackets).has(streamKey);
363
+ if (awaitingMulticastRepair) {
364
+ if (!isSourceSymbol) {
365
+ __privateGet(this, _startupRepairReadyPackets).add(streamKey);
366
+ __privateGet(this, _startupRepairBoundaryCounts).delete(streamKey);
367
+ __privateMethod(this, _FECManager_instances, markStartupPartial_fn).call(this, blockKey);
368
+ return false;
369
+ }
370
+ if (esi === 0) {
371
+ const boundaries = (__privateGet(this, _startupRepairBoundaryCounts).get(streamKey) ?? 0) + 1;
372
+ __privateGet(this, _startupRepairBoundaryCounts).set(streamKey, boundaries);
373
+ if (boundaries >= STARTUP_REPAIR_WAIT_SOURCE_BOUNDARIES) {
374
+ __privateGet(this, _startupRepairBoundaryCounts).delete(streamKey);
375
+ __privateGet(this, _startupRepairFailOpenPackets).add(streamKey);
376
+ } else {
377
+ __privateMethod(this, _FECManager_instances, markStartupPartial_fn).call(this, blockKey);
378
+ return false;
379
+ }
380
+ } else {
381
+ __privateMethod(this, _FECManager_instances, markStartupPartial_fn).call(this, blockKey);
382
+ return false;
383
+ }
384
+ }
385
+ if (isSourceSymbol && esi === 0) {
386
+ __privateGet(this, _startupPartialBlocks).delete(blockKey);
387
+ __privateGet(this, _startupAlignedPackets).add(streamKey);
388
+ } else if (isStartupPartial || !__privateGet(this, _startupAlignedPackets).has(streamKey)) {
389
+ __privateMethod(this, _FECManager_instances, markStartupPartial_fn).call(this, blockKey);
390
+ return false;
391
+ }
392
+ if (__privateGet(this, _completedBlocks).has(blockKey)) {
393
+ __privateGet(this, _fecStats).duplicateSymbols++;
394
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).duplicateSymbols++;
395
+ return false;
396
+ }
397
+ const symbolKey = `${blockKey}:${esi}`;
398
+ if (__privateGet(this, _seenSymbols).has(symbolKey)) {
399
+ __privateGet(this, _fecStats).duplicateSymbols++;
400
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).duplicateSymbols++;
401
+ return false;
402
+ }
403
+ __privateGet(this, _seenSymbols).add(symbolKey);
404
+ const counts = __privateGet(this, _blockPathCounts).get(blockKey) ?? {
405
+ packetId,
406
+ sbn,
407
+ ...catalogTrackName === void 0 ? {} : { catalogTrackName },
408
+ multicastSymbols: 0,
409
+ moqSymbols: 0,
410
+ complete: false
411
+ };
412
+ if (source === "multicast") counts.multicastSymbols++;
413
+ else counts.moqSymbols++;
414
+ __privateGet(this, _blockPathCounts).set(blockKey, counts);
415
+ __privateMethod(this, _FECManager_instances, observeBlockCatalogTrackName_fn).call(this, blockKey, catalogTrackName);
416
+ if (__privateGet(this, _seenSymbols).size > 4096) {
417
+ __privateSet(this, _seenSymbols, new Set(Array.from(__privateGet(this, _seenSymbols)).slice(-2048)));
418
+ }
419
+ if (__privateGet(this, _blockPathCounts).size > 512) {
420
+ __privateSet(this, _blockPathCounts, new Map(Array.from(__privateGet(this, _blockPathCounts)).slice(-256)));
421
+ }
422
+ if (__privateGet(this, _blockCatalogTrackNames).size > 512) {
423
+ __privateSet(this, _blockCatalogTrackNames, new Map(
424
+ Array.from(__privateGet(this, _blockCatalogTrackNames)).slice(-256)
425
+ ));
426
+ }
427
+ return true;
428
+ }
429
+ /** Exact catalog identity retained for async recovery, if unambiguous. */
430
+ catalogTrackNameForBlock(sbn, packetId, catalogTrackName) {
431
+ if (catalogTrackName !== void 0) {
432
+ return __privateGet(this, _blockCatalogTrackNames).get(
433
+ __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName)
434
+ ) ?? void 0;
435
+ }
436
+ const names = /* @__PURE__ */ new Set();
437
+ for (const [key, name] of __privateGet(this, _blockCatalogTrackNames)) {
438
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
439
+ if (block.packetId === packetId && block.sbn === sbn && name !== null) names.add(name);
440
+ }
441
+ return names.size === 1 ? [...names][0] : void 0;
442
+ }
443
+ /** Per-block state snapshot for FecBlockGrid visualization.
444
+ * Returns the most recent blocks (active + recently completed). */
445
+ getBlockStates() {
446
+ const blocks = [];
447
+ for (const [key] of __privateGet(this, _activeBlocks)) {
448
+ const { packetId, sbn } = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
449
+ const count = __privateGet(this, _blockSourceCounts).get(key) ?? 0;
450
+ const k = this.kForPacket(packetId);
451
+ blocks.push({ sbn, packetId, state: "collecting", sourceCount: count, k, progress: k > 0 ? Math.min(count / k, 1) : 0 });
452
+ }
453
+ const completed = [...__privateGet(this, _completedBlocks)].slice(-16);
454
+ for (const key of completed) {
455
+ const { packetId, sbn } = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
456
+ if (!__privateGet(this, _activeBlocks).has(key)) {
457
+ const k = this.kForPacket(packetId);
458
+ blocks.push({ sbn, packetId, state: "complete", sourceCount: k, k, progress: 1 });
459
+ }
460
+ }
461
+ blocks.sort((a, b) => a.sbn - b.sbn || (a.packetId ?? 0) - (b.packetId ?? 0));
462
+ return blocks.slice(-24);
463
+ }
464
+ /** The raw WASM decoder for stats access (first registered decoder) */
465
+ get wasmDecoder() {
466
+ return __privateGet(this, _fecDecoders).values().next().value?.client ?? null;
467
+ }
468
+ get k() {
469
+ return __privateGet(this, _fecK);
470
+ }
471
+ kForPacket(packetId) {
472
+ return __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).k;
473
+ }
474
+ /** FEC symbol size in bytes. */
475
+ get symbolSize() {
476
+ return __privateGet(this, _fecSymbolSize);
477
+ }
478
+ symbolSizeForPacket(packetId) {
479
+ return __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).symbolSize;
480
+ }
481
+ /** FEC interleave window in milliseconds (0 = no interleaving). */
482
+ get interleaveDepthMs() {
483
+ return __privateGet(this, _fecInterleaveDepthMs);
484
+ }
485
+ interleaveDepthMsForPacket(packetId) {
486
+ return __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).interleaveDepthMs;
487
+ }
488
+ /** Resolved per-track block fail bound in milliseconds. */
489
+ timeoutMsForPacket(packetId) {
490
+ return __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).timeoutMs;
491
+ }
492
+ /** Resolved per-track D-28 repair request deadline in milliseconds. */
493
+ repairDeadlineMsForPacket(packetId) {
494
+ return __privateMethod(this, _FECManager_instances, repairDeadlineMs_fn).call(this, __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId));
495
+ }
496
+ /** Remaining fetch budget for a specific repair-requested block. */
497
+ repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName) {
498
+ const deadlineMs = __privateGet(this, _activeBlockDeadlinesMs).get(
499
+ __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName)
500
+ );
501
+ if (deadlineMs !== void 0) {
502
+ return Math.max(1, Math.ceil(deadlineMs - performance.now()));
503
+ }
504
+ const trackConfig = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId);
505
+ return Math.max(1, trackConfig.timeoutMs - __privateMethod(this, _FECManager_instances, repairDeadlineMs_fn).call(this, trackConfig));
506
+ }
507
+ // -----------------------------------------------------------------------
508
+ // Configuration
509
+ // -----------------------------------------------------------------------
510
+ /** Configure FEC parameters. */
511
+ configure(config) {
512
+ if (config.k != null) __privateSet(this, _fecK, config.k);
513
+ if (config.symbolSize != null && config.symbolSize > 0) __privateSet(this, _fecSymbolSize, config.symbolSize);
514
+ if (config.interleaveDepthMs != null) __privateSet(this, _fecInterleaveDepthMs, config.interleaveDepthMs);
515
+ if (config.fps != null && Number.isFinite(config.fps) && config.fps > 0) {
516
+ __privateSet(this, _fecFps, config.fps);
517
+ }
518
+ if (config.interleaveDepthMs != null && config.interleaveDepthMs > 0 && config.interleaveDepthMs < MIN_INTERLEAVE_DEPTH_MS) {
519
+ console.warn(`[FECManager] interleaveDepthMs=${config.interleaveDepthMs} looks like frame count, not milliseconds (\xA75.1 requires ms). Expected range: ${MIN_INTERLEAVE_DEPTH_MS}-10000ms.`);
520
+ }
521
+ if (config.timeoutMs != null && config.timeoutMs > 0) {
522
+ __privateSet(this, _fecTimeoutMs, config.timeoutMs);
523
+ } else if (config.interleaveDepthMs != null && config.interleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS) {
524
+ __privateSet(this, _fecTimeoutMs, computeFecDeliveryWindowMs({
525
+ interleaveDepthMs: config.interleaveDepthMs,
526
+ sourceSymbols: __privateGet(this, _fecK),
527
+ symbolSize: __privateGet(this, _fecSymbolSize),
528
+ mediaUnitsPerSecond: config.fps
529
+ }));
530
+ }
531
+ for (const [packetId, track] of __privateGet(this, _trackConfigs)) {
532
+ if (track.timeoutMs < __privateGet(this, _fecTimeoutMs)) {
533
+ __privateGet(this, _trackConfigs).set(packetId, { ...track, timeoutMs: __privateGet(this, _fecTimeoutMs) });
534
+ }
535
+ }
536
+ }
537
+ /** Configure FEC parameters for one packetId without changing legacy defaults. */
538
+ configureTrack(packetId, config) {
539
+ __privateMethod(this, _FECManager_instances, upsertTrackConfig_fn).call(this, packetId, config);
540
+ }
541
+ /** Register a FEC decoder for a specific packetId (track). */
542
+ setFecDecoder(packetId, client, k, config, catalogTrackName) {
543
+ const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
544
+ __privateMethod(this, _FECManager_instances, assertExclusiveDecoderClient_fn).call(this, streamKey, client, [...__privateGet(this, _fecDecoders)].map(([key, entry]) => [key, entry.client]), "decoder");
545
+ const trackConfig = __privateMethod(this, _FECManager_instances, upsertTrackConfig_fn).call(this, packetId, { ...config, k });
546
+ __privateGet(this, _fecDecoders).set(streamKey, { client, k: trackConfig.k });
547
+ }
548
+ /**
549
+ * Register a Worker-backed FEC decoder for a specific packetId (track).
550
+ *
551
+ * Worker-backed tracks decode asynchronously — feedSourceSymbol/feedRepairSymbol
552
+ * return null immediately, and recovered frames arrive via the onBlockRecovered callback.
553
+ *
554
+ * Takes precedence over sync WASM decoders for the same packetId.
555
+ */
556
+ setFecWorker(packetId, client, config, catalogTrackName) {
557
+ const k = config?.k;
558
+ if (k === void 0 || !Number.isFinite(k) || k <= 0) {
559
+ throw new Error(`[FECManager] packetId=${packetId} Worker requires an explicit positive k`);
560
+ }
561
+ const symbolSize = config.symbolSize;
562
+ if (symbolSize === void 0 || !Number.isFinite(symbolSize) || symbolSize <= 0) {
563
+ throw new Error(
564
+ `[FECManager] packetId=${packetId} Worker requires an explicit positive symbolSize`
565
+ );
566
+ }
567
+ const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
568
+ __privateMethod(this, _FECManager_instances, assertExclusiveDecoderClient_fn).call(this, streamKey, client, __privateGet(this, _workerClients), "worker");
569
+ if (config) __privateMethod(this, _FECManager_instances, upsertTrackConfig_fn).call(this, packetId, config);
570
+ const workerK = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).k;
571
+ __privateGet(this, _workerClients).set(streamKey, client);
572
+ client.onFrame((data, meta) => {
573
+ if (meta.recovered) {
574
+ if (!Number.isInteger(meta.esi) || meta.esi < 0 || meta.esi >= workerK) {
575
+ const kind = "recovered-symbol-missing-esi";
576
+ const seen = __privateGet(this, _workerErrorCounts).get(kind) ?? 0;
577
+ __privateGet(this, _workerErrorCounts).set(kind, seen + 1);
578
+ if (seen < WORKER_ERROR_LOG_CAP) {
579
+ console.warn(
580
+ `[FECManager] Dropping recovered symbol without valid ESI: pid=${packetId} sbn=${meta.sbn} esi=${String(meta.esi)}`
581
+ );
582
+ }
583
+ return;
584
+ }
585
+ const esi = meta.esi;
586
+ const recoveredCatalogTrackName = catalogTrackName ?? __privateMethod(this, _FECManager_instances, decoderBlockCatalogTrackName_fn).call(this, client, meta.sbn);
587
+ if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, client, meta.sbn, recoveredCatalogTrackName)) return;
588
+ const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, meta.sbn, packetId, recoveredCatalogTrackName);
589
+ const cleanlyCompleted = __privateGet(this, _cleanlyCompletedBlocks).has(blockKey);
590
+ if (!cleanlyCompleted) {
591
+ if (!__privateGet(this, _workerRecoveredBlocks).has(blockKey)) {
592
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "recovered", meta.sbn, packetId, recoveredCatalogTrackName);
593
+ __privateGet(this, _workerRecoveredBlocks).add(blockKey);
594
+ __privateGet(this, _fecStats).blocksRecovered++;
595
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).blocksRecovered++;
596
+ if (__privateGet(this, _workerRecoveredBlocks).size > 1e3) {
597
+ const stale = Array.from(__privateGet(this, _workerRecoveredBlocks)).slice(0, 500);
598
+ for (const key of stale) __privateGet(this, _workerRecoveredBlocks).delete(key);
599
+ }
600
+ }
601
+ const symbolKey = `${blockKey}:${esi}`;
602
+ if (!__privateGet(this, _seenSymbols).has(symbolKey)) {
603
+ __privateGet(this, _seenSymbols).add(symbolKey);
604
+ this.onBlockRecovered?.(
605
+ meta.sbn,
606
+ packetId,
607
+ data,
608
+ meta,
609
+ recoveredCatalogTrackName
610
+ );
611
+ }
612
+ }
613
+ if (esi >= workerK - 1 && !__privateGet(this, _completedBlocks).has(blockKey)) {
614
+ this.cancelBlockTimeout(meta.sbn, packetId, recoveredCatalogTrackName);
615
+ if (recoveredCatalogTrackName === void 0) {
616
+ this.onBlockComplete?.(meta.sbn, packetId);
617
+ } else {
618
+ this.onBlockComplete?.(
619
+ meta.sbn,
620
+ packetId,
621
+ recoveredCatalogTrackName
622
+ );
623
+ }
624
+ }
625
+ } else {
626
+ const completedCatalogTrackName = catalogTrackName ?? __privateMethod(this, _FECManager_instances, decoderBlockCatalogTrackName_fn).call(this, client, meta.sbn);
627
+ this.markBlockCompleted(meta.sbn, packetId, completedCatalogTrackName);
628
+ }
629
+ });
630
+ client.onSnapshot((stats) => {
631
+ __privateGet(this, _fecWorkerStats).set(packetId, stats);
632
+ try {
633
+ this.onFecStatsUpdate?.(packetId, stats);
634
+ } catch (error) {
635
+ console.warn("[FECManager] FEC stats callback failed:", error);
636
+ }
637
+ for (const observer of __privateGet(this, _fecStatsObservers)) {
638
+ try {
639
+ observer(packetId, stats);
640
+ } catch (error) {
641
+ console.warn("[FECManager] FEC stats observer failed:", error);
642
+ }
643
+ }
644
+ });
645
+ client.onGreenFill((sbn, data) => {
646
+ __privateGet(this, _fecStats).greenFillFrames++;
647
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).greenFillFrames++;
648
+ this.onGreenFill?.(sbn, packetId, data);
649
+ });
650
+ client.onCleanupComplete((sbn) => {
651
+ const cleanupKeys = [...__privateGet(this, _pendingWorkerCleanups)].filter((key) => {
652
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
653
+ return block.packetId === packetId && block.sbn === sbn && __privateGet(this, _pendingWorkerCleanupClients).get(key) === client;
654
+ });
655
+ for (const key of cleanupKeys) {
656
+ __privateGet(this, _pendingWorkerCleanups).delete(key);
657
+ __privateGet(this, _pendingWorkerCleanupClients).delete(key);
658
+ if (__privateGet(this, _completedBlocks).has(key)) continue;
659
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
660
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "cleanup-ack", sbn, packetId, block.catalogTrackName);
661
+ __privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, block.catalogTrackName);
662
+ }
663
+ });
664
+ client.onError((msg, code) => {
665
+ const requestedKind = code ?? msg;
666
+ const kind = __privateGet(this, _workerErrorCounts).has(requestedKind) || __privateGet(this, _workerErrorCounts).size < WORKER_ERROR_KIND_CAP - 1 ? requestedKind : WORKER_ERROR_OVERFLOW_KIND;
667
+ const seen = __privateGet(this, _workerErrorCounts).get(kind) ?? 0;
668
+ __privateGet(this, _workerErrorCounts).set(kind, seen + 1);
669
+ if (seen < WORKER_ERROR_LOG_CAP) {
670
+ console.warn("[FECManager] Worker error:", msg);
671
+ } else if (seen === WORKER_ERROR_LOG_CAP) {
672
+ console.warn(
673
+ `[FECManager] Worker error (suppressing further copies of ${kind}): ${msg}`
674
+ );
675
+ }
676
+ });
677
+ }
678
+ /** Called by player when framerate is known (from decoder output). Refines FEC block timeout. */
679
+ setFramerate(fps) {
680
+ if (__privateGet(this, _fpsDetected) || fps <= 0) return;
681
+ __privateSet(this, _fpsDetected, true);
682
+ __privateSet(this, _fecFps, fps);
683
+ if (__privateGet(this, _fecInterleaveDepthMs) >= MIN_INTERLEAVE_DEPTH_MS) {
684
+ __privateSet(this, _fecTimeoutMs, computeFecDeliveryWindowMs({
685
+ interleaveDepthMs: __privateGet(this, _fecInterleaveDepthMs),
686
+ sourceSymbols: __privateGet(this, _fecK),
687
+ symbolSize: __privateGet(this, _fecSymbolSize),
688
+ mediaUnitsPerSecond: fps
689
+ }));
690
+ }
691
+ for (const [packetId, config] of __privateGet(this, _trackConfigs)) {
692
+ if (config.fps !== void 0 || config.interleaveDepthMs < MIN_INTERLEAVE_DEPTH_MS) continue;
693
+ __privateGet(this, _trackConfigs).set(packetId, {
694
+ ...config,
695
+ fps,
696
+ timeoutMs: Math.max(
697
+ __privateGet(this, _fecTimeoutMs),
698
+ computeFecDeliveryWindowMs({
699
+ interleaveDepthMs: config.interleaveDepthMs,
700
+ sourceSymbols: config.k,
701
+ symbolSize: config.symbolSize,
702
+ mediaUnitsPerSecond: fps
703
+ })
704
+ )
705
+ });
706
+ }
707
+ }
708
+ // -----------------------------------------------------------------------
709
+ // Symbol feeding (codec-agnostic)
710
+ // -----------------------------------------------------------------------
711
+ /**
712
+ * Feed a source symbol to the WASM FEC decoder.
713
+ *
714
+ * Does NOT track block source counts or fire lifecycle events — call
715
+ * `trackBlock()` separately BEFORE this method (MmtpRouter does this).
716
+ *
717
+ * @returns Recovered block data if WASM completed the block, else null.
718
+ * Caller is responsible for routing recovered data and updating
719
+ * block completion state via `markBlockCompleted()`.
720
+ */
721
+ feedSourceSymbol(packetId, ssId, symbolData, alta, catalogTrackName) {
722
+ __privateGet(this, _fecStats).sourcePackets++;
723
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).sourcePackets++;
724
+ const fecData = __privateMethod(this, _FECManager_instances, normalizeSymbolData_fn).call(this, packetId, symbolData);
725
+ const sbn = Math.floor(ssId / this.kForPacket(packetId));
726
+ const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
727
+ const syncBlockOwner = __privateGet(this, _syncDecoderBlockOwners).get(blockKey);
728
+ const workerClient = __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName);
729
+ if (workerClient && !syncBlockOwner) {
730
+ if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
731
+ const buf = fecData.buffer.slice(
732
+ fecData.byteOffset,
733
+ fecData.byteOffset + fecData.byteLength
734
+ );
735
+ if (alta) {
736
+ const authBuf = alta.auth.buffer.slice(
737
+ alta.auth.byteOffset,
738
+ alta.auth.byteOffset + alta.auth.byteLength
739
+ );
740
+ workerClient.feedSource(ssId, buf, performance.now(), {
741
+ auth: authBuf,
742
+ payloadEnd: alta.payloadEnd
743
+ });
744
+ } else {
745
+ workerClient.feedSource(ssId, buf, performance.now());
746
+ }
747
+ return null;
748
+ }
749
+ const entry = __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, packetId, catalogTrackName);
750
+ const client = syncBlockOwner ?? entry?.client;
751
+ if (!client) return null;
752
+ if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, client, sbn, catalogTrackName)) return null;
753
+ __privateGet(this, _syncDecoderBlockOwners).set(blockKey, client);
754
+ let recovered = null;
755
+ try {
756
+ recovered = client.add_source(ssId, fecData, performance.now());
757
+ } catch {
758
+ }
759
+ if (recovered || __privateGet(this, _completedBlocks).has(blockKey)) {
760
+ __privateGet(this, _syncDecoderBlockOwners).delete(blockKey);
761
+ }
762
+ return recovered;
763
+ }
764
+ /**
765
+ * Feed a repair symbol to the WASM FEC decoder.
766
+ *
767
+ * @returns Recovered block data if repair completed the block, else null.
768
+ * Caller is responsible for routing recovered data and updating
769
+ * block completion state via `markBlockCompleted()`.
770
+ */
771
+ feedRepairSymbol(packetId, ssStart, ssbLength, rsId, repairData, catalogTrackName) {
772
+ __privateGet(this, _fecStats).repairPackets++;
773
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).repairPackets++;
774
+ const symbolSize = this.symbolSizeForPacket(packetId);
775
+ if (symbolSize > 0 && repairData.byteLength !== symbolSize) {
776
+ __privateWrapper(this, _repairSymbolSizeMismatchCount)._++;
777
+ if (__privateGet(this, _repairSymbolSizeMismatchCount) <= 5 || __privateGet(this, _repairSymbolSizeMismatchCount) % 100 === 0) {
778
+ console.warn(
779
+ `[FECManager] Dropping repair symbol with invalid size: got ${repairData.byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
780
+ );
781
+ }
782
+ return null;
783
+ }
784
+ const fecData = repairData;
785
+ if (ssbLength > 1) {
786
+ this.noteBlockActivity(
787
+ Math.floor(ssStart / ssbLength),
788
+ packetId,
789
+ catalogTrackName
790
+ );
791
+ }
792
+ const sbn = ssbLength > 0 ? Math.floor(ssStart / ssbLength) : 0;
793
+ const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
794
+ if (__privateGet(this, _completedBlocks).has(blockKey)) return null;
795
+ const syncBlockOwner = __privateGet(this, _syncDecoderBlockOwners).get(blockKey);
796
+ let repairIds = __privateGet(this, _blockRepairRsIds).get(blockKey);
797
+ if (!repairIds) {
798
+ repairIds = /* @__PURE__ */ new Set();
799
+ __privateGet(this, _blockRepairRsIds).set(blockKey, repairIds);
800
+ }
801
+ repairIds.add(rsId);
802
+ if (__privateGet(this, _repairRequestedBlocks).has(blockKey)) {
803
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "repair-arrived", sbn, packetId, catalogTrackName, rsId);
804
+ }
805
+ const workerClient = __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName);
806
+ if (workerClient && !syncBlockOwner) {
807
+ if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
808
+ const buf = fecData.buffer.slice(
809
+ fecData.byteOffset,
810
+ fecData.byteOffset + fecData.byteLength
811
+ );
812
+ workerClient.feedRepair(ssStart, ssbLength, rsId, buf, performance.now());
813
+ return null;
814
+ }
815
+ const entry = __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, packetId, catalogTrackName);
816
+ const client = syncBlockOwner ?? entry?.client;
817
+ if (!client) return null;
818
+ if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, client, sbn, catalogTrackName)) return null;
819
+ __privateGet(this, _syncDecoderBlockOwners).set(blockKey, client);
820
+ let recovered = null;
821
+ try {
822
+ recovered = client.add_repair(ssStart, ssbLength, rsId, fecData, performance.now());
823
+ } catch {
824
+ }
825
+ if (recovered) __privateGet(this, _syncDecoderBlockOwners).delete(blockKey);
826
+ return recovered;
827
+ }
828
+ /**
829
+ * Unified symbol feeder. Dispatches to feedSourceSymbol or feedRepairSymbol.
830
+ */
831
+ feedSymbol(packetId, symbolId, data, isRepair) {
832
+ if (isRepair) {
833
+ return this.feedRepairSymbol(packetId, symbolId, 1, symbolId, data);
834
+ }
835
+ return this.feedSourceSymbol(packetId, symbolId, data);
836
+ }
837
+ // -----------------------------------------------------------------------
838
+ // Block lifecycle
839
+ // -----------------------------------------------------------------------
840
+ /**
841
+ * Track a source symbol for an FEC block. Refreshes the inactivity deadline
842
+ * on each symbol and marks the block clean when K source symbols arrive.
843
+ */
844
+ trackBlock(sbn, packetId, catalogTrackName, esi) {
845
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
846
+ const trackConfig = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId);
847
+ const k = trackConfig.k;
848
+ if (__privateGet(this, _completedBlocks).has(key)) return;
849
+ const count = (__privateGet(this, _blockSourceCounts).get(key) ?? 0) + 1;
850
+ __privateGet(this, _blockSourceCounts).set(key, count);
851
+ if (Number.isInteger(esi) && esi >= 0 && esi < k) {
852
+ let sourceEsis = __privateGet(this, _blockSourceEsis).get(key);
853
+ if (!sourceEsis) {
854
+ sourceEsis = /* @__PURE__ */ new Set();
855
+ __privateGet(this, _blockSourceEsis).set(key, sourceEsis);
856
+ }
857
+ sourceEsis.add(esi);
858
+ }
859
+ if (count === 1) {
860
+ if (catalogTrackName === void 0) {
861
+ this.onBlockStarted?.(sbn, packetId);
862
+ } else {
863
+ this.onBlockStarted?.(sbn, packetId, catalogTrackName);
864
+ }
865
+ }
866
+ if (k > 0 && count >= k) {
867
+ __privateGet(this, _fecStats).blocksClean++;
868
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).blocksClean++;
869
+ this.cancelBlockTimeout(sbn, packetId, catalogTrackName);
870
+ __privateGet(this, _blockSourceCounts).delete(key);
871
+ __privateGet(this, _blockSourceEsis).delete(key);
872
+ __privateGet(this, _blockRepairRsIds).delete(key);
873
+ __privateGet(this, _completedBlocks).add(key);
874
+ __privateGet(this, _cleanlyCompletedBlocks).add(key);
875
+ __privateMethod(this, _FECManager_instances, markPathBlockComplete_fn).call(this, sbn, packetId, catalogTrackName);
876
+ if (catalogTrackName === void 0) {
877
+ this.onBlockComplete?.(sbn, packetId);
878
+ } else {
879
+ this.onBlockComplete?.(sbn, packetId, catalogTrackName);
880
+ }
881
+ queueMicrotask(() => __privateGet(this, _syncDecoderBlockOwners).delete(key));
882
+ return;
883
+ }
884
+ this.noteBlockActivity(sbn, packetId, catalogTrackName, true);
885
+ }
886
+ /** Refresh deadlines after accepted block activity. */
887
+ noteBlockActivity(sbn, packetId, catalogTrackName, sourceProgress = false) {
888
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
889
+ if (__privateGet(this, _completedBlocks).has(key)) return;
890
+ if (__privateGet(this, _pendingWorkerCleanups).has(key)) return;
891
+ if (__privateGet(this, _repairRequestedBlocks).has(key)) return;
892
+ const trackConfig = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId);
893
+ const timeoutMs = trackConfig.timeoutMs;
894
+ if (timeoutMs <= 0) return;
895
+ const repairDeadline = __privateGet(this, _repairDeadlines).get(key);
896
+ if (this.onRepairNeeded && (repairDeadline === void 0 || sourceProgress)) {
897
+ if (repairDeadline != null) clearTimeout(repairDeadline);
898
+ __privateGet(this, _repairDeadlines).set(
899
+ key,
900
+ setTimeout(() => {
901
+ __privateMethod(this, _FECManager_instances, requestRepair_fn).call(this, sbn, packetId, catalogTrackName);
902
+ }, __privateMethod(this, _FECManager_instances, repairDeadlineMs_fn).call(this, trackConfig))
903
+ );
904
+ }
905
+ __privateMethod(this, _FECManager_instances, armBlockTimeout_fn).call(this, sbn, packetId, catalogTrackName, timeoutMs);
906
+ }
907
+ /** Check whether a block has already been completed (clean or recovered). */
908
+ isBlockCompleted(sbn, packetId, catalogTrackName) {
909
+ return __privateMethod(this, _FECManager_instances, blockKeysFor_fn).call(this, sbn, packetId, catalogTrackName).some((key) => __privateGet(this, _completedBlocks).has(key));
910
+ }
911
+ /** Mark a block as completed externally (e.g., after routing recovered data). */
912
+ markBlockCompleted(sbn, packetId, catalogTrackName) {
913
+ for (const key of __privateMethod(this, _FECManager_instances, blockKeysFor_fn).call(this, sbn, packetId, catalogTrackName)) {
914
+ __privateGet(this, _completedBlocks).add(key);
915
+ __privateGet(this, _pendingWorkerCleanups).delete(key);
916
+ __privateGet(this, _pendingWorkerCleanupClients).delete(key);
917
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
918
+ __privateMethod(this, _FECManager_instances, markPathBlockComplete_fn).call(this, block.sbn, block.packetId, block.catalogTrackName);
919
+ __privateMethod(this, _FECManager_instances, clearRepairDeadline_fn).call(this, key);
920
+ if (__privateGet(this, _repairRequestedBlocks).delete(key)) {
921
+ if (block.catalogTrackName === void 0) {
922
+ this.onRepairResolved?.(block.sbn, block.packetId, "completed");
923
+ } else {
924
+ this.onRepairResolved?.(
925
+ block.sbn,
926
+ block.packetId,
927
+ "completed",
928
+ block.catalogTrackName
929
+ );
930
+ }
931
+ }
932
+ __privateGet(this, _blockSourceCounts).delete(key);
933
+ __privateGet(this, _blockSourceEsis).delete(key);
934
+ __privateGet(this, _blockRepairRsIds).delete(key);
935
+ const timer = __privateGet(this, _activeBlocks).get(key);
936
+ if (timer) {
937
+ clearTimeout(timer);
938
+ __privateGet(this, _activeBlocks).delete(key);
939
+ }
940
+ __privateGet(this, _activeBlockDeadlinesMs).delete(key);
941
+ __privateGet(this, _activeBlockTimeoutOwners).delete(key);
942
+ }
943
+ }
944
+ /** Increment blocksRecovered stat (called by MmtpRouter after routing recovery). */
945
+ countRecovery(packetId) {
946
+ __privateGet(this, _fecStats).blocksRecovered++;
947
+ if (packetId != null) __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).blocksRecovered++;
948
+ }
949
+ /**
950
+ * Strict delivery provenance for one FEC block.
951
+ *
952
+ * A recovered symbol is a function of every symbol that entered its block,
953
+ * so it can only be attributed to multicast when NO symbol in that block
954
+ * arrived over MoQ. Repair symbols routinely arrive over reliable QUIC
955
+ * (`MmtpRouter.feedRepairPacket`), so a block that recovered with MoQ help
956
+ * produced bytes that never crossed a multicast socket.
957
+ *
958
+ * An untracked block returns 'unknown' rather than a guess: absence of
959
+ * evidence is not evidence of multicast.
960
+ */
961
+ blockDeliveryProvenance(sbn, packetId, catalogTrackName) {
962
+ const counts = this.blockPathCount(sbn, packetId, catalogTrackName);
963
+ if (!counts) return "unknown";
964
+ if (counts.moqSymbols > 0) return "mixed";
965
+ if (counts.multicastSymbols > 0) return "multicast";
966
+ return "unknown";
967
+ }
968
+ /** Per-path symbol counts for one block (D-28 gate logging), if tracked. */
969
+ blockPathCount(sbn, packetId, catalogTrackName) {
970
+ return __privateGet(this, _blockPathCounts).get(
971
+ __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName)
972
+ ) ?? null;
973
+ }
974
+ /** Cancel block timeout (block completed via clean reception or FEC recovery). */
975
+ cancelBlockTimeout(sbn, packetId, catalogTrackName) {
976
+ for (const key of __privateMethod(this, _FECManager_instances, blockKeysFor_fn).call(this, sbn, packetId, catalogTrackName)) {
977
+ __privateGet(this, _completedBlocks).add(key);
978
+ __privateGet(this, _pendingWorkerCleanups).delete(key);
979
+ __privateGet(this, _pendingWorkerCleanupClients).delete(key);
980
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
981
+ __privateMethod(this, _FECManager_instances, markPathBlockComplete_fn).call(this, block.sbn, block.packetId, block.catalogTrackName);
982
+ __privateMethod(this, _FECManager_instances, clearRepairDeadline_fn).call(this, key);
983
+ if (__privateGet(this, _repairRequestedBlocks).delete(key)) {
984
+ if (block.catalogTrackName === void 0) {
985
+ this.onRepairResolved?.(block.sbn, block.packetId, "completed");
986
+ } else {
987
+ this.onRepairResolved?.(
988
+ block.sbn,
989
+ block.packetId,
990
+ "completed",
991
+ block.catalogTrackName
992
+ );
993
+ }
994
+ }
995
+ __privateGet(this, _blockSourceCounts).delete(key);
996
+ __privateGet(this, _blockSourceEsis).delete(key);
997
+ __privateGet(this, _blockRepairRsIds).delete(key);
998
+ const timer = __privateGet(this, _activeBlocks).get(key);
999
+ if (timer) {
1000
+ clearTimeout(timer);
1001
+ __privateGet(this, _activeBlocks).delete(key);
1002
+ }
1003
+ __privateGet(this, _activeBlockDeadlinesMs).delete(key);
1004
+ __privateGet(this, _activeBlockTimeoutOwners).delete(key);
1005
+ }
1006
+ if (__privateGet(this, _completedBlocks).size > 1e3) {
1007
+ const iter = __privateGet(this, _completedBlocks).values();
1008
+ for (let i = 0; i < 500; i++) iter.next();
1009
+ const keep = /* @__PURE__ */ new Set();
1010
+ for (const v of iter) keep.add(v);
1011
+ __privateSet(this, _completedBlocks, keep);
1012
+ }
1013
+ }
1014
+ // -----------------------------------------------------------------------
1015
+ // Cleanup
1016
+ // -----------------------------------------------------------------------
1017
+ dispose() {
1018
+ for (const timer of __privateGet(this, _activeBlocks).values()) clearTimeout(timer);
1019
+ __privateGet(this, _activeBlocks).clear();
1020
+ __privateGet(this, _activeBlockDeadlinesMs).clear();
1021
+ __privateGet(this, _activeBlockTimeoutOwners).clear();
1022
+ __privateGet(this, _pendingWorkerCleanups).clear();
1023
+ __privateGet(this, _pendingWorkerCleanupClients).clear();
1024
+ for (const timer of __privateGet(this, _repairDeadlines).values()) {
1025
+ if (timer != null) clearTimeout(timer);
1026
+ }
1027
+ __privateGet(this, _repairDeadlines).clear();
1028
+ __privateGet(this, _blockSourceCounts).clear();
1029
+ __privateGet(this, _blockSourceEsis).clear();
1030
+ __privateGet(this, _blockRepairRsIds).clear();
1031
+ __privateGet(this, _completedBlocks).clear();
1032
+ __privateGet(this, _cleanlyCompletedBlocks).clear();
1033
+ __privateGet(this, _repairRequestedBlocks).clear();
1034
+ __privateGet(this, _workerRecoveredBlocks).clear();
1035
+ __privateGet(this, _syncDecoderBlockOwners).clear();
1036
+ __privateGet(this, _startupAlignedPackets).clear();
1037
+ __privateGet(this, _startupPartialBlocks).clear();
1038
+ __privateSet(this, _startupRequireRepairReady, false);
1039
+ __privateGet(this, _startupRepairReadyPackets).clear();
1040
+ __privateGet(this, _startupRepairBoundaryCounts).clear();
1041
+ __privateGet(this, _startupRepairFailOpenPackets).clear();
1042
+ __privateGet(this, _seenSymbols).clear();
1043
+ __privateGet(this, _blockPathCounts).clear();
1044
+ __privateGet(this, _blockCatalogTrackNames).clear();
1045
+ __privateGet(this, _trackConfigs).clear();
1046
+ __privateGet(this, _fecDecoders).clear();
1047
+ for (const client of new Set(__privateGet(this, _workerClients).values())) client.dispose();
1048
+ __privateGet(this, _workerClients).clear();
1049
+ }
1050
+ };
1051
+ _fecDecoders = new WeakMap();
1052
+ _workerClients = new WeakMap();
1053
+ _syncDecoderBlockOwners = new WeakMap();
1054
+ _decoderBlockOwners = new WeakMap();
1055
+ _fecK = new WeakMap();
1056
+ _fecSymbolSize = new WeakMap();
1057
+ _fecTimeoutMs = new WeakMap();
1058
+ _trackConfigs = new WeakMap();
1059
+ _fecStats = new WeakMap();
1060
+ _fecTrackStats = new WeakMap();
1061
+ _fecWorkerStats = new WeakMap();
1062
+ _fecStatsObservers = new WeakMap();
1063
+ _activeBlocks = new WeakMap();
1064
+ _activeBlockDeadlinesMs = new WeakMap();
1065
+ _activeBlockTimeoutOwners = new WeakMap();
1066
+ _lifecycleTrace = new WeakMap();
1067
+ _pendingWorkerCleanups = new WeakMap();
1068
+ _pendingWorkerCleanupClients = new WeakMap();
1069
+ _blockSourceCounts = new WeakMap();
1070
+ _blockSourceEsis = new WeakMap();
1071
+ _blockRepairRsIds = new WeakMap();
1072
+ _completedBlocks = new WeakMap();
1073
+ _seenSymbols = new WeakMap();
1074
+ _blockPathCounts = new WeakMap();
1075
+ _blockCatalogTrackNames = new WeakMap();
1076
+ _startupAlignedPackets = new WeakMap();
1077
+ _startupPartialBlocks = new WeakMap();
1078
+ _startupRequireRepairReady = new WeakMap();
1079
+ _startupRepairReadyPackets = new WeakMap();
1080
+ _startupRepairBoundaryCounts = new WeakMap();
1081
+ _startupRepairFailOpenPackets = new WeakMap();
1082
+ _cleanlyCompletedBlocks = new WeakMap();
1083
+ _repairRequestedBlocks = new WeakMap();
1084
+ _repairDeadlines = new WeakMap();
1085
+ _workerRecoveredBlocks = new WeakMap();
1086
+ _fpsDetected = new WeakMap();
1087
+ _fecFps = new WeakMap();
1088
+ _fecInterleaveDepthMs = new WeakMap();
1089
+ _workerErrorCounts = new WeakMap();
1090
+ _repairSymbolSizeMismatchCount = new WeakMap();
1091
+ _FECManager_instances = new WeakSet();
1092
+ streamKey_fn = function(packetId, catalogTrackName) {
1093
+ return catalogTrackName === void 0 ? `${packetId}` : `${packetId}:${encodeURIComponent(catalogTrackName)}`;
1094
+ };
1095
+ belongsToPacket_fn = function(key, packetId) {
1096
+ return Number(key.split(":", 1)[0]) === packetId;
1097
+ };
1098
+ belongsToStream_fn = function(key, packetId, catalogTrackName) {
1099
+ if (!__privateMethod(this, _FECManager_instances, belongsToPacket_fn).call(this, key, packetId)) return false;
1100
+ const parts = key.split(":");
1101
+ const encodedTrackName = encodeURIComponent(catalogTrackName);
1102
+ if (parts.length === 2) return parts[1] === encodedTrackName;
1103
+ if (parts.length >= 3) return parts[2] === encodedTrackName;
1104
+ return false;
1105
+ };
1106
+ packetIdsForStreamKeys_fn = function(keys) {
1107
+ return [...new Set([...keys].map((key) => Number(key.split(":", 1)[0])))];
1108
+ };
1109
+ blockKey_fn = function(sbn, packetId, catalogTrackName) {
1110
+ const base = `${packetId}:${sbn}`;
1111
+ return catalogTrackName === void 0 ? base : `${base}:${encodeURIComponent(catalogTrackName)}`;
1112
+ };
1113
+ parseBlockKey_fn = function(key) {
1114
+ const [packetIdText, sbnText, ...catalogParts] = key.split(":");
1115
+ const catalogTrackName = catalogParts.length > 0 ? decodeURIComponent(catalogParts.join(":")) : void 0;
1116
+ return {
1117
+ packetId: Number(packetIdText) || 0,
1118
+ sbn: Number(sbnText) || 0,
1119
+ ...catalogTrackName === void 0 ? {} : { catalogTrackName }
1120
+ };
1121
+ };
1122
+ decoderForPacket_fn = function(packetId, catalogTrackName) {
1123
+ return __privateGet(this, _fecDecoders).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName)) ?? __privateGet(this, _fecDecoders).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId));
1124
+ };
1125
+ workerForPacket_fn = function(packetId, catalogTrackName) {
1126
+ return __privateGet(this, _workerClients).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName)) ?? __privateGet(this, _workerClients).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId));
1127
+ };
1128
+ claimDecoderBlock_fn = function(client, sbn, catalogTrackName) {
1129
+ let blocks = __privateGet(this, _decoderBlockOwners).get(client);
1130
+ if (!blocks) {
1131
+ blocks = /* @__PURE__ */ new Map();
1132
+ __privateGet(this, _decoderBlockOwners).set(client, blocks);
1133
+ }
1134
+ const owner = blocks.get(sbn);
1135
+ if (!owner) {
1136
+ blocks.set(sbn, { catalogTrackName, conflicted: false });
1137
+ if (blocks.size > 512) {
1138
+ const stale = [...blocks.keys()].slice(0, 256);
1139
+ for (const key of stale) blocks.delete(key);
1140
+ }
1141
+ return true;
1142
+ }
1143
+ if (owner.conflicted) return false;
1144
+ if (owner.catalogTrackName === catalogTrackName) return true;
1145
+ owner.conflicted = true;
1146
+ return false;
1147
+ };
1148
+ decoderBlockCatalogTrackName_fn = function(client, sbn) {
1149
+ const owner = __privateGet(this, _decoderBlockOwners).get(client)?.get(sbn);
1150
+ return owner?.conflicted ? void 0 : owner?.catalogTrackName;
1151
+ };
1152
+ resetDecoderBlockOwners_fn = function(client, catalogTrackName) {
1153
+ const blocks = __privateGet(this, _decoderBlockOwners).get(client);
1154
+ if (!blocks) return;
1155
+ for (const [sbn, owner] of blocks) {
1156
+ if (owner.catalogTrackName === catalogTrackName || owner.conflicted) {
1157
+ blocks.delete(sbn);
1158
+ }
1159
+ }
1160
+ if (blocks.size === 0) __privateGet(this, _decoderBlockOwners).delete(client);
1161
+ };
1162
+ discardFecDecoderClient_fn = function(client) {
1163
+ for (const [key, entry] of __privateGet(this, _fecDecoders)) {
1164
+ if (entry.client === client) __privateGet(this, _fecDecoders).delete(key);
1165
+ }
1166
+ __privateGet(this, _decoderBlockOwners).delete(client);
1167
+ };
1168
+ assertExclusiveDecoderClient_fn = function(streamKey, client, registrations, kind) {
1169
+ for (const [registeredKey, registeredClient] of registrations) {
1170
+ if (registeredClient !== client || registeredKey === streamKey) continue;
1171
+ throw new Error(
1172
+ `[FECManager] ${kind} client is already registered for stream ${registeredKey}; create one client per physical stream`
1173
+ );
1174
+ }
1175
+ };
1176
+ statsForPacket_fn = function(packetId) {
1177
+ let stats = __privateGet(this, _fecTrackStats).get(packetId);
1178
+ if (!stats) {
1179
+ stats = newFecCounters();
1180
+ __privateGet(this, _fecTrackStats).set(packetId, stats);
1181
+ }
1182
+ return stats;
1183
+ };
1184
+ markPathBlockComplete_fn = function(sbn, packetId, catalogTrackName) {
1185
+ const block = __privateGet(this, _blockPathCounts).get(__privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName));
1186
+ if (block) block.complete = true;
1187
+ };
1188
+ /** Cancel and forget a block's D-28 repair-deadline timer. */
1189
+ clearRepairDeadline_fn = function(key) {
1190
+ const timer = __privateGet(this, _repairDeadlines).get(key);
1191
+ if (timer != null) clearTimeout(timer);
1192
+ __privateGet(this, _repairDeadlines).delete(key);
1193
+ };
1194
+ requestRepair_fn = function(sbn, packetId, catalogTrackName) {
1195
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
1196
+ if (__privateGet(this, _completedBlocks).has(key) || !this.onRepairNeeded || __privateGet(this, _repairRequestedBlocks).has(key)) return;
1197
+ const deadline = __privateGet(this, _repairDeadlines).get(key);
1198
+ if (deadline) clearTimeout(deadline);
1199
+ __privateGet(this, _repairDeadlines).set(key, null);
1200
+ __privateGet(this, _repairRequestedBlocks).add(key);
1201
+ const config = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId);
1202
+ const graceMs = __privateMethod(this, _FECManager_instances, repairGraceMs_fn).call(this, config);
1203
+ const now = performance.now();
1204
+ const currentDeadline = __privateGet(this, _activeBlockDeadlinesMs).get(key) ?? now;
1205
+ __privateMethod(this, _FECManager_instances, armBlockTimeout_fn).call(this, sbn, packetId, catalogTrackName, Math.max(1, Math.ceil(Math.max(now, currentDeadline) + graceMs - now)));
1206
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "repair-requested", sbn, packetId, catalogTrackName);
1207
+ if (catalogTrackName === void 0) {
1208
+ this.onRepairNeeded(sbn, packetId);
1209
+ } else {
1210
+ this.onRepairNeeded(sbn, packetId, catalogTrackName);
1211
+ }
1212
+ };
1213
+ traceLifecycle_fn = function(event, sbn, packetId, catalogTrackName, rsId) {
1214
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
1215
+ const deadline = __privateGet(this, _activeBlockDeadlinesMs).get(key);
1216
+ const decoderPath = __privateGet(this, _syncDecoderBlockOwners).has(key) ? "sync" : __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName) ? "worker" : __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, packetId, catalogTrackName) ? "sync" : "none";
1217
+ __privateGet(this, _lifecycleTrace).push({
1218
+ atMs: Date.now(),
1219
+ event,
1220
+ packetId,
1221
+ sbn,
1222
+ ...catalogTrackName === void 0 ? {} : { catalogTrackName },
1223
+ sourceCount: __privateGet(this, _blockSourceCounts).get(key) ?? 0,
1224
+ sourceEsis: [...__privateGet(this, _blockSourceEsis).get(key) ?? []].sort((a, b) => a - b),
1225
+ repairRsIds: [...__privateGet(this, _blockRepairRsIds).get(key) ?? []].sort((a, b) => a - b),
1226
+ decoderPath,
1227
+ ...deadline === void 0 ? {} : { deadlineRemainingMs: Math.max(0, deadline - performance.now()) },
1228
+ pendingCleanup: __privateGet(this, _pendingWorkerCleanups).has(key),
1229
+ ...rsId === void 0 ? {} : { rsId }
1230
+ });
1231
+ if (__privateGet(this, _lifecycleTrace).length > 64) __privateGet(this, _lifecycleTrace).splice(0, 32);
1232
+ };
1233
+ defaultTrackConfig_fn = function() {
1234
+ return {
1235
+ k: __privateGet(this, _fecK),
1236
+ symbolSize: __privateGet(this, _fecSymbolSize),
1237
+ interleaveDepthMs: __privateGet(this, _fecInterleaveDepthMs),
1238
+ fps: __privateGet(this, _fecFps),
1239
+ timeoutMs: __privateGet(this, _fecTimeoutMs)
1240
+ };
1241
+ };
1242
+ resolveTrackConfig_fn = function(packetId) {
1243
+ return __privateGet(this, _trackConfigs).get(packetId) ?? __privateMethod(this, _FECManager_instances, defaultTrackConfig_fn).call(this);
1244
+ };
1245
+ computeTimeout_fn = function(config) {
1246
+ if (config.timeoutMs && config.timeoutMs > 0) return config.timeoutMs;
1247
+ if (config.interleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS) {
1248
+ return Math.max(
1249
+ __privateGet(this, _fecTimeoutMs),
1250
+ computeFecDeliveryWindowMs({
1251
+ interleaveDepthMs: config.interleaveDepthMs,
1252
+ sourceSymbols: config.k,
1253
+ mediaUnitsPerSecond: config.fps
1254
+ })
1255
+ );
1256
+ }
1257
+ return __privateGet(this, _fecTimeoutMs);
1258
+ };
1259
+ repairDeadlineMs_fn = function(config) {
1260
+ const halfFailBoundMs = Math.ceil(config.timeoutMs / 2);
1261
+ if (config.k > 0 && config.interleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS && config.fps !== void 0 && Number.isFinite(config.fps) && config.fps > 0) {
1262
+ const mediaUnitMs = 1e3 / config.fps;
1263
+ const interleaveUnits = deriveFecInterleaveDepth2(
1264
+ config.interleaveDepthMs,
1265
+ mediaUnitMs
1266
+ );
1267
+ const sourceHorizonMs = Math.ceil(config.k * interleaveUnits * mediaUnitMs);
1268
+ if (sourceHorizonMs < config.timeoutMs) return sourceHorizonMs;
1269
+ }
1270
+ return halfFailBoundMs;
1271
+ };
1272
+ repairGraceMs_fn = function(config) {
1273
+ return Math.max(1, config.timeoutMs - __privateMethod(this, _FECManager_instances, repairDeadlineMs_fn).call(this, config));
1274
+ };
1275
+ armBlockTimeout_fn = function(sbn, packetId, catalogTrackName, delayMs) {
1276
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
1277
+ const current = __privateGet(this, _activeBlocks).get(key);
1278
+ if (current) clearTimeout(current);
1279
+ const boundedDelayMs = Math.max(1, Math.ceil(delayMs));
1280
+ __privateGet(this, _activeBlockDeadlinesMs).set(key, performance.now() + boundedDelayMs);
1281
+ const owner = {};
1282
+ __privateGet(this, _activeBlockTimeoutOwners).set(key, owner);
1283
+ const timer = setTimeout(() => {
1284
+ if (__privateGet(this, _activeBlockTimeoutOwners).get(key) !== owner) return;
1285
+ __privateGet(this, _activeBlocks).delete(key);
1286
+ __privateGet(this, _activeBlockDeadlinesMs).delete(key);
1287
+ __privateGet(this, _activeBlockTimeoutOwners).delete(key);
1288
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "timeout-queued", sbn, packetId, catalogTrackName);
1289
+ const syncOwner = __privateGet(this, _syncDecoderBlockOwners).get(key);
1290
+ if (syncOwner) {
1291
+ __privateMethod(this, _FECManager_instances, routeSyncCleanup_fn).call(this, syncOwner, sbn, packetId);
1292
+ __privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, catalogTrackName);
1293
+ return;
1294
+ }
1295
+ const workerClient = __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName);
1296
+ if (workerClient) {
1297
+ __privateGet(this, _pendingWorkerCleanups).add(key);
1298
+ __privateGet(this, _pendingWorkerCleanupClients).set(key, workerClient);
1299
+ workerClient.cleanup(sbn);
1300
+ } else {
1301
+ const decoder = __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, packetId, catalogTrackName)?.client;
1302
+ if (decoder) {
1303
+ __privateMethod(this, _FECManager_instances, routeSyncCleanup_fn).call(this, decoder, sbn, packetId);
1304
+ __privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, catalogTrackName);
1305
+ } else {
1306
+ __privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, catalogTrackName);
1307
+ }
1308
+ }
1309
+ }, boundedDelayMs);
1310
+ __privateGet(this, _activeBlocks).set(key, timer);
1311
+ };
1312
+ upsertTrackConfig_fn = function(packetId, config) {
1313
+ const previous = __privateGet(this, _trackConfigs).get(packetId) ?? __privateMethod(this, _FECManager_instances, defaultTrackConfig_fn).call(this);
1314
+ const timingChanged = config.k !== void 0 || config.interleaveDepthMs !== void 0 || config.fps !== void 0;
1315
+ const next = {
1316
+ k: config.k ?? previous.k,
1317
+ symbolSize: config.symbolSize != null && config.symbolSize > 0 ? config.symbolSize : previous.symbolSize,
1318
+ interleaveDepthMs: config.interleaveDepthMs ?? previous.interleaveDepthMs,
1319
+ fps: config.fps ?? previous.fps,
1320
+ timeoutMs: config.timeoutMs ?? (timingChanged ? 0 : previous.timeoutMs)
1321
+ };
1322
+ next.timeoutMs = __privateMethod(this, _FECManager_instances, computeTimeout_fn).call(this, next);
1323
+ __privateGet(this, _trackConfigs).set(packetId, next);
1324
+ return next;
1325
+ };
1326
+ normalizeSymbolData_fn = function(packetId, data) {
1327
+ const symbolSize = this.symbolSizeForPacket(packetId);
1328
+ if (symbolSize <= 0 || data.byteLength === symbolSize) return data;
1329
+ const normalized = new Uint8Array(symbolSize);
1330
+ normalized.set(data.subarray(0, symbolSize));
1331
+ return normalized;
1332
+ };
1333
+ blockKeysFor_fn = function(sbn, packetId, catalogTrackName) {
1334
+ if (packetId != null && catalogTrackName !== void 0) {
1335
+ return [__privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName)];
1336
+ }
1337
+ const keys = /* @__PURE__ */ new Set();
1338
+ for (const source of [
1339
+ __privateGet(this, _activeBlocks),
1340
+ __privateGet(this, _blockSourceCounts),
1341
+ __privateGet(this, _blockCatalogTrackNames)
1342
+ ]) {
1343
+ for (const key of source.keys()) {
1344
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
1345
+ if (block.sbn === sbn && (packetId === void 0 || block.packetId === packetId)) keys.add(key);
1346
+ }
1347
+ }
1348
+ for (const source of [__privateGet(this, _completedBlocks), __privateGet(this, _cleanlyCompletedBlocks)]) {
1349
+ for (const key of source) {
1350
+ const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
1351
+ if (block.sbn === sbn && (packetId === void 0 || block.packetId === packetId)) keys.add(key);
1352
+ }
1353
+ }
1354
+ if (packetId !== void 0) {
1355
+ if (keys.size === 0) return [__privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId)];
1356
+ return keys.size === 1 ? [...keys] : [];
1357
+ }
1358
+ return keys.size > 0 ? [...keys] : [__privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, 0, catalogTrackName)];
1359
+ };
1360
+ observeBlockCatalogTrackName_fn = function(blockKey, catalogTrackName) {
1361
+ if (catalogTrackName === void 0) return;
1362
+ if (!__privateGet(this, _blockCatalogTrackNames).has(blockKey)) {
1363
+ __privateGet(this, _blockCatalogTrackNames).set(blockKey, catalogTrackName);
1364
+ return;
1365
+ }
1366
+ if (__privateGet(this, _blockCatalogTrackNames).get(blockKey) !== catalogTrackName) {
1367
+ __privateGet(this, _blockCatalogTrackNames).set(blockKey, null);
1368
+ }
1369
+ };
1370
+ markStartupPartial_fn = function(blockKey) {
1371
+ __privateGet(this, _startupPartialBlocks).add(blockKey);
1372
+ if (__privateGet(this, _startupPartialBlocks).size > 128) {
1373
+ __privateSet(this, _startupPartialBlocks, new Set(
1374
+ Array.from(__privateGet(this, _startupPartialBlocks)).slice(-64)
1375
+ ));
1376
+ }
1377
+ };
1378
+ routeSyncCleanup_fn = function(decoder, sbn, packetId) {
1379
+ let framed;
1380
+ try {
1381
+ framed = decoder.cleanup_blocks_detailed(Uint32Array.of(sbn));
1382
+ } catch (error) {
1383
+ console.warn(`[FECManager] Scoped cleanup failed for SBN ${sbn}:`, error);
1384
+ return;
1385
+ }
1386
+ const view = new DataView(framed.buffer, framed.byteOffset, framed.byteLength);
1387
+ let offset = 0;
1388
+ while (offset < framed.byteLength) {
1389
+ if (framed.byteLength - offset < 8) {
1390
+ console.warn(`[FECManager] Scoped cleanup returned a truncated record for SBN ${sbn}`);
1391
+ return;
1392
+ }
1393
+ const fillSbn = view.getUint32(offset, false);
1394
+ const length = view.getUint32(offset + 4, false);
1395
+ offset += 8;
1396
+ if (length > framed.byteLength - offset) {
1397
+ console.warn(`[FECManager] Scoped cleanup returned a truncated payload for SBN ${sbn}`);
1398
+ return;
1399
+ }
1400
+ const data = framed.slice(offset, offset + length).buffer;
1401
+ offset += length;
1402
+ __privateGet(this, _fecStats).greenFillFrames++;
1403
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).greenFillFrames++;
1404
+ this.onGreenFill?.(fillSbn, packetId, data);
1405
+ }
1406
+ };
1407
+ failBlock_fn = function(sbn, packetId, countGreenFill, catalogTrackName) {
1408
+ const key = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
1409
+ __privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "failed", sbn, packetId, catalogTrackName);
1410
+ __privateMethod(this, _FECManager_instances, clearRepairDeadline_fn).call(this, key);
1411
+ const activeTimer = __privateGet(this, _activeBlocks).get(key);
1412
+ if (activeTimer) {
1413
+ clearTimeout(activeTimer);
1414
+ __privateGet(this, _activeBlocks).delete(key);
1415
+ }
1416
+ __privateGet(this, _activeBlockDeadlinesMs).delete(key);
1417
+ if (__privateGet(this, _repairRequestedBlocks).delete(key)) {
1418
+ if (catalogTrackName === void 0) {
1419
+ this.onRepairResolved?.(sbn, packetId, "failed");
1420
+ } else {
1421
+ this.onRepairResolved?.(sbn, packetId, "failed", catalogTrackName);
1422
+ }
1423
+ }
1424
+ __privateGet(this, _blockSourceCounts).delete(key);
1425
+ __privateGet(this, _blockSourceEsis).delete(key);
1426
+ __privateGet(this, _blockRepairRsIds).delete(key);
1427
+ __privateGet(this, _activeBlockTimeoutOwners).delete(key);
1428
+ __privateGet(this, _syncDecoderBlockOwners).delete(key);
1429
+ __privateGet(this, _completedBlocks).add(key);
1430
+ __privateMethod(this, _FECManager_instances, markPathBlockComplete_fn).call(this, sbn, packetId, catalogTrackName);
1431
+ __privateGet(this, _fecStats).blocksFailed++;
1432
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).blocksFailed++;
1433
+ if (countGreenFill) {
1434
+ __privateGet(this, _fecStats).greenFillFrames++;
1435
+ __privateMethod(this, _FECManager_instances, statsForPacket_fn).call(this, packetId).greenFillFrames++;
1436
+ }
1437
+ if (catalogTrackName === void 0) {
1438
+ this.onBlockFailed?.(sbn, packetId);
1439
+ } else {
1440
+ this.onBlockFailed?.(sbn, packetId, catalogTrackName);
1441
+ }
1442
+ };
1443
+ export {
1444
+ FECManager,
1445
+ MIN_INTERLEAVE_DEPTH_MS
1446
+ };
1447
+ //# sourceMappingURL=fec-manager.js.map