@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.
- package/README.md +432 -0
- package/dist/.build-stamp +0 -0
- package/dist/__tests__/test-utils.d.ts +71 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/align.d.ts +148 -0
- package/dist/align.d.ts.map +1 -0
- package/dist/align.js +88 -0
- package/dist/align.js.map +7 -0
- package/dist/audio-init-parser.d.ts +66 -0
- package/dist/audio-init-parser.d.ts.map +1 -0
- package/dist/audio-init-parser.js +118 -0
- package/dist/audio-init-parser.js.map +7 -0
- package/dist/audio-ring-buffer.d.ts +50 -0
- package/dist/audio-ring-buffer.d.ts.map +1 -0
- package/dist/audio-ring-buffer.js +93 -0
- package/dist/audio-ring-buffer.js.map +7 -0
- package/dist/authored-timing.d.ts +32 -0
- package/dist/authored-timing.d.ts.map +1 -0
- package/dist/authored-timing.js +32 -0
- package/dist/authored-timing.js.map +7 -0
- package/dist/browser-runtime.js +17109 -0
- package/dist/browser-runtime.js.map +7 -0
- package/dist/carp-catalog.d.ts +318 -0
- package/dist/carp-catalog.d.ts.map +1 -0
- package/dist/carp-catalog.js +549 -0
- package/dist/carp-catalog.js.map +7 -0
- package/dist/catalog-fec-params.d.ts +82 -0
- package/dist/catalog-fec-params.d.ts.map +1 -0
- package/dist/catalog-fec-params.js +66 -0
- package/dist/catalog-fec-params.js.map +7 -0
- package/dist/catalog-network-source.d.ts +19 -0
- package/dist/catalog-network-source.d.ts.map +1 -0
- package/dist/catalog-network-source.js +22 -0
- package/dist/catalog-network-source.js.map +7 -0
- package/dist/catalog-validator.d.ts +18 -0
- package/dist/catalog-validator.d.ts.map +1 -0
- package/dist/catalog-validator.js +7747 -0
- package/dist/catalog-validator.js.map +7 -0
- package/dist/cmaf-block-assembler.d.ts +168 -0
- package/dist/cmaf-block-assembler.d.ts.map +1 -0
- package/dist/cmaf-block-assembler.js +1755 -0
- package/dist/cmaf-block-assembler.js.map +7 -0
- package/dist/cmaf-group-batcher.d.ts +38 -0
- package/dist/cmaf-group-batcher.d.ts.map +1 -0
- package/dist/cmaf-group-batcher.js +195 -0
- package/dist/cmaf-group-batcher.js.map +7 -0
- package/dist/cmcd-producer.d.ts +104 -0
- package/dist/cmcd-producer.d.ts.map +1 -0
- package/dist/cmcd-producer.js +207 -0
- package/dist/cmcd-producer.js.map +7 -0
- package/dist/codec-utils.d.ts +235 -0
- package/dist/codec-utils.d.ts.map +1 -0
- package/dist/codec-utils.js +1225 -0
- package/dist/codec-utils.js.map +7 -0
- package/dist/fec-codec.d.ts +32 -0
- package/dist/fec-codec.d.ts.map +1 -0
- package/dist/fec-codec.js +47 -0
- package/dist/fec-codec.js.map +7 -0
- package/dist/fec-manager.d.ts +266 -0
- package/dist/fec-manager.d.ts.map +1 -0
- package/dist/fec-manager.js +1447 -0
- package/dist/fec-manager.js.map +7 -0
- package/dist/fec-starvation-detector.d.ts +59 -0
- package/dist/fec-starvation-detector.d.ts.map +1 -0
- package/dist/fec-starvation-detector.js +75 -0
- package/dist/fec-starvation-detector.js.map +7 -0
- package/dist/fec-worker-setup.d.ts +76 -0
- package/dist/fec-worker-setup.d.ts.map +1 -0
- package/dist/fec-worker-setup.js +603 -0
- package/dist/fec-worker-setup.js.map +7 -0
- package/dist/fmp4-completion.d.ts +30 -0
- package/dist/fmp4-completion.d.ts.map +1 -0
- package/dist/fmp4-completion.js +21 -0
- package/dist/fmp4-completion.js.map +7 -0
- package/dist/fmp4-reader.d.ts +37 -0
- package/dist/fmp4-reader.d.ts.map +1 -0
- package/dist/fmp4-reader.js +100 -0
- package/dist/fmp4-reader.js.map +7 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +330 -0
- package/dist/index.js.map +7 -0
- package/dist/iso-bmff-timing.d.ts +47 -0
- package/dist/iso-bmff-timing.d.ts.map +1 -0
- package/dist/iso-bmff-timing.js +526 -0
- package/dist/iso-bmff-timing.js.map +7 -0
- package/dist/loc.d.ts +68 -0
- package/dist/loc.d.ts.map +1 -0
- package/dist/loc.js +143 -0
- package/dist/loc.js.map +7 -0
- package/dist/manifest-auth-plan.d.ts +30 -0
- package/dist/manifest-auth-plan.d.ts.map +1 -0
- package/dist/manifest-auth-plan.js +1267 -0
- package/dist/manifest-auth-plan.js.map +7 -0
- package/dist/media-router.d.ts +338 -0
- package/dist/media-router.d.ts.map +1 -0
- package/dist/media-router.js +802 -0
- package/dist/media-router.js.map +7 -0
- package/dist/mfu-reassembler.d.ts +264 -0
- package/dist/mfu-reassembler.d.ts.map +1 -0
- package/dist/mfu-reassembler.js +2668 -0
- package/dist/mfu-reassembler.js.map +7 -0
- package/dist/mfu-reassembly-policy.d.ts +24 -0
- package/dist/mfu-reassembly-policy.d.ts.map +1 -0
- package/dist/mfu-reassembly-policy.js +99 -0
- package/dist/mfu-reassembly-policy.js.map +7 -0
- package/dist/mmtp-container-parser.d.ts +304 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -0
- package/dist/mmtp-container-parser.js +5378 -0
- package/dist/mmtp-container-parser.js.map +7 -0
- package/dist/mmtp-container-parser.no-modules.js +7853 -0
- package/dist/mmtp-container-parser.no-modules.js.map +7 -0
- package/dist/mmtp-decode-pipeline.d.ts +96 -0
- package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
- package/dist/mmtp-decode-pipeline.js +5589 -0
- package/dist/mmtp-decode-pipeline.js.map +7 -0
- package/dist/mmtp-router.d.ts +383 -0
- package/dist/mmtp-router.d.ts.map +1 -0
- package/dist/mmtp-router.js +8384 -0
- package/dist/mmtp-router.js.map +7 -0
- package/dist/mmtp-to-cmaf.d.ts +166 -0
- package/dist/mmtp-to-cmaf.d.ts.map +1 -0
- package/dist/mmtp-to-cmaf.js +781 -0
- package/dist/mmtp-to-cmaf.js.map +7 -0
- package/dist/multicast-auth-catalog.d.ts +115 -0
- package/dist/multicast-auth-catalog.d.ts.map +1 -0
- package/dist/multicast-auth-catalog.js +202 -0
- package/dist/multicast-auth-catalog.js.map +7 -0
- package/dist/multicast-input.d.ts +107 -0
- package/dist/multicast-input.d.ts.map +1 -0
- package/dist/multicast-input.js +256 -0
- package/dist/multicast-input.js.map +7 -0
- package/dist/multicast-manager.d.ts +330 -0
- package/dist/multicast-manager.d.ts.map +1 -0
- package/dist/multicast-manager.js +11032 -0
- package/dist/multicast-manager.js.map +7 -0
- package/dist/multicast-transport.d.ts +62 -0
- package/dist/multicast-transport.d.ts.map +1 -0
- package/dist/multicast-transport.js +338 -0
- package/dist/multicast-transport.js.map +7 -0
- package/dist/multicast-unwrap.d.ts +57 -0
- package/dist/multicast-unwrap.d.ts.map +1 -0
- package/dist/multicast-unwrap.js +384 -0
- package/dist/multicast-unwrap.js.map +7 -0
- package/dist/no-modules.d.ts +9 -0
- package/dist/no-modules.d.ts.map +1 -0
- package/dist/no-modules.js +7819 -0
- package/dist/no-modules.js.map +7 -0
- package/dist/phase14-catalog-override.d.ts +126 -0
- package/dist/phase14-catalog-override.d.ts.map +1 -0
- package/dist/phase14-catalog-override.js +155 -0
- package/dist/phase14-catalog-override.js.map +7 -0
- package/dist/repair-fetch.d.ts +58 -0
- package/dist/repair-fetch.d.ts.map +1 -0
- package/dist/repair-fetch.js +117 -0
- package/dist/repair-fetch.js.map +7 -0
- package/dist/sample-combiner.d.ts +182 -0
- package/dist/sample-combiner.d.ts.map +1 -0
- package/dist/sample-combiner.js +571 -0
- package/dist/sample-combiner.js.map +7 -0
- package/dist/signaling.d.ts +29 -0
- package/dist/signaling.d.ts.map +1 -0
- package/dist/signaling.js +232 -0
- package/dist/signaling.js.map +7 -0
- package/dist/source-auth.d.ts +2 -0
- package/dist/source-auth.d.ts.map +1 -0
- package/dist/source-auth.js +1220 -0
- package/dist/source-auth.js.map +7 -0
- package/dist/switching-set-alignment.d.ts +61 -0
- package/dist/switching-set-alignment.d.ts.map +1 -0
- package/dist/switching-set-alignment.js +85 -0
- package/dist/switching-set-alignment.js.map +7 -0
- package/dist/timestamp-codec.d.ts +34 -0
- package/dist/timestamp-codec.d.ts.map +1 -0
- package/dist/timestamp-codec.js +456 -0
- package/dist/timestamp-codec.js.map +7 -0
- package/dist/track-pipeline-setup.d.ts +72 -0
- package/dist/track-pipeline-setup.d.ts.map +1 -0
- package/dist/track-pipeline-setup.js +306 -0
- package/dist/track-pipeline-setup.js.map +7 -0
- package/dist/track-pipeline.d.ts +121 -0
- package/dist/track-pipeline.d.ts.map +1 -0
- package/dist/track-pipeline.js +229 -0
- package/dist/track-pipeline.js.map +7 -0
- package/dist/track-session.d.ts +269 -0
- package/dist/track-session.d.ts.map +1 -0
- package/dist/track-session.js +597 -0
- package/dist/track-session.js.map +7 -0
- package/dist/transport-pool.d.ts +69 -0
- package/dist/transport-pool.d.ts.map +1 -0
- package/dist/transport-pool.js +88 -0
- package/dist/transport-pool.js.map +7 -0
- package/dist/wasm-mfu-reassembler.d.ts +81 -0
- package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
- package/dist/wasm-mfu-reassembler.js +1915 -0
- package/dist/wasm-mfu-reassembler.js.map +7 -0
- package/dist/wasm-mmtp-container-parser.d.ts +10 -0
- package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
- package/dist/wasm-mmtp-container-parser.js +5635 -0
- package/dist/wasm-mmtp-container-parser.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/README.md +213 -0
- package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +80 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +270 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +252 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +565 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
- package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +349 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +179 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +47 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/package.json +59 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +309 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +268 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1048 -0
- package/node_modules/@blockcast/fec-worker/src/index.ts +32 -0
- package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +558 -0
- package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
- package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +194 -0
- package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
- package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
- package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
- package/node_modules/@blockcast/mmt-base/README.md +120 -0
- package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/package.json +49 -0
- package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
- package/node_modules/@blockcast/mmt-fec/README.md +270 -0
- package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +80 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +294 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +72 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +192 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +185 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +273 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +22 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.js +22 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +174 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.js +256 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +120 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
- package/node_modules/@blockcast/mmt-fec/package.json +79 -0
- package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +369 -0
- package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +277 -0
- package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
- package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
- package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +332 -0
- package/node_modules/@blockcast/mmt-fec/src/index.ts +77 -0
- package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
- package/node_modules/@blockcast/mmt-fec/src/oti.ts +319 -0
- package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +90 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +462 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +636 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +521 -0
- package/node_modules/@noble/hashes/_assert.d.ts +17 -0
- package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_assert.js +18 -0
- package/node_modules/@noble/hashes/_assert.js.map +1 -0
- package/node_modules/@noble/hashes/_blake.d.ts +14 -0
- package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_blake.js +50 -0
- package/node_modules/@noble/hashes/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/_md.d.ts +51 -0
- package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_md.js +162 -0
- package/node_modules/@noble/hashes/_md.js.map +1 -0
- package/node_modules/@noble/hashes/_u64.d.ts +55 -0
- package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_u64.js +90 -0
- package/node_modules/@noble/hashes/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/argon2.d.ts +32 -0
- package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/argon2.js +401 -0
- package/node_modules/@noble/hashes/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/blake1.d.ts +106 -0
- package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake1.js +459 -0
- package/node_modules/@noble/hashes/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/blake2.d.ts +116 -0
- package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2.js +420 -0
- package/node_modules/@noble/hashes/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
- package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2b.js +14 -0
- package/node_modules/@noble/hashes/blake2b.js.map +1 -0
- package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
- package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2s.js +24 -0
- package/node_modules/@noble/hashes/blake2s.js.map +1 -0
- package/node_modules/@noble/hashes/blake3.d.ts +54 -0
- package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake3.js +255 -0
- package/node_modules/@noble/hashes/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/crypto.d.ts +2 -0
- package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/crypto.js +5 -0
- package/node_modules/@noble/hashes/crypto.js.map +1 -0
- package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
- package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
- package/node_modules/@noble/hashes/cryptoNode.js +18 -0
- package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
- package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/eskdf.js +166 -0
- package/node_modules/@noble/hashes/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
- package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_assert.js +15 -0
- package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
- package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_blake.js +45 -0
- package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
- package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_md.js +155 -0
- package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
- package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_u64.js +67 -0
- package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
- package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/argon2.js +392 -0
- package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
- package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake1.js +452 -0
- package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
- package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2.js +413 -0
- package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
- package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
- package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
- package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
- package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
- package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake3.js +251 -0
- package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/crypto.js +2 -0
- package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
- package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
- package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
- package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
- package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
- package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
- package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/hmac.js +86 -0
- package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/index.js +33 -0
- package/node_modules/@noble/hashes/esm/index.js.map +1 -0
- package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
- package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/legacy.js +281 -0
- package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/esm/package.json +10 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
- package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
- package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
- package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
- package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
- package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
- package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha1.js +11 -0
- package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
- package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha2.js +375 -0
- package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
- package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha256.js +20 -0
- package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
- package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3.js +234 -0
- package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
- package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha512.js +26 -0
- package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
- package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
- package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/utils.js +281 -0
- package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
- package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hkdf.js +88 -0
- package/node_modules/@noble/hashes/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/hmac.d.ts +35 -0
- package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hmac.js +91 -0
- package/node_modules/@noble/hashes/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/index.js +33 -0
- package/node_modules/@noble/hashes/index.js.map +1 -0
- package/node_modules/@noble/hashes/legacy.d.ts +71 -0
- package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/legacy.js +287 -0
- package/node_modules/@noble/hashes/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/package.json +266 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/pbkdf2.js +101 -0
- package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
- package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
- package/node_modules/@noble/hashes/ripemd160.js +16 -0
- package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
- package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/scrypt.js +232 -0
- package/node_modules/@noble/hashes/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/sha1.d.ts +11 -0
- package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha1.js +14 -0
- package/node_modules/@noble/hashes/sha1.js.map +1 -0
- package/node_modules/@noble/hashes/sha2.d.ts +159 -0
- package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha2.js +384 -0
- package/node_modules/@noble/hashes/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/sha256.d.ts +20 -0
- package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha256.js +23 -0
- package/node_modules/@noble/hashes/sha256.js.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.js +402 -0
- package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/sha3.d.ts +53 -0
- package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3.js +239 -0
- package/node_modules/@noble/hashes/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/sha512.d.ts +26 -0
- package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha512.js +29 -0
- package/node_modules/@noble/hashes/sha512.js.map +1 -0
- package/node_modules/@noble/hashes/src/_assert.ts +22 -0
- package/node_modules/@noble/hashes/src/_blake.ts +50 -0
- package/node_modules/@noble/hashes/src/_md.ts +176 -0
- package/node_modules/@noble/hashes/src/_u64.ts +91 -0
- package/node_modules/@noble/hashes/src/argon2.ts +497 -0
- package/node_modules/@noble/hashes/src/blake1.ts +534 -0
- package/node_modules/@noble/hashes/src/blake2.ts +486 -0
- package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
- package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
- package/node_modules/@noble/hashes/src/blake3.ts +272 -0
- package/node_modules/@noble/hashes/src/crypto.ts +9 -0
- package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
- package/node_modules/@noble/hashes/src/hmac.ts +94 -0
- package/node_modules/@noble/hashes/src/index.ts +31 -0
- package/node_modules/@noble/hashes/src/legacy.ts +293 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
- package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
- package/node_modules/@noble/hashes/src/sha1.ts +10 -0
- package/node_modules/@noble/hashes/src/sha2.ts +402 -0
- package/node_modules/@noble/hashes/src/sha256.ts +24 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
- package/node_modules/@noble/hashes/src/sha3.ts +258 -0
- package/node_modules/@noble/hashes/src/sha512.ts +34 -0
- package/node_modules/@noble/hashes/src/utils.ts +395 -0
- package/node_modules/@noble/hashes/utils.d.ts +161 -0
- package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/utils.js +313 -0
- package/node_modules/@noble/hashes/utils.js.map +1 -0
- package/package.json +203 -0
- package/schemas/catalog.schema.json +283 -0
- package/src/align.ts +235 -0
- package/src/audio-init-parser.ts +189 -0
- package/src/audio-ring-buffer.ts +120 -0
- package/src/authored-timing.ts +63 -0
- package/src/carp-catalog.ts +776 -0
- package/src/catalog-fec-params.ts +167 -0
- package/src/catalog-network-source.ts +49 -0
- package/src/catalog-validator.ts +34 -0
- package/src/cmaf-block-assembler.ts +1058 -0
- package/src/cmaf-group-batcher.ts +104 -0
- package/src/cmcd-producer.ts +329 -0
- package/src/codec-utils.ts +1539 -0
- package/src/fec-codec.ts +61 -0
- package/src/fec-manager.ts +1939 -0
- package/src/fec-starvation-detector.ts +128 -0
- package/src/fec-worker-setup.ts +177 -0
- package/src/fmp4-completion.ts +47 -0
- package/src/fmp4-reader.ts +112 -0
- package/src/index.ts +443 -0
- package/src/iso-bmff-timing.ts +688 -0
- package/src/loc.ts +181 -0
- package/src/manifest-auth-plan.ts +107 -0
- package/src/media-router.ts +1185 -0
- package/src/mfu-reassembler.ts +2842 -0
- package/src/mfu-reassembly-policy.ts +134 -0
- package/src/mmtp-container-parser.ts +1498 -0
- package/src/mmtp-decode-pipeline.ts +315 -0
- package/src/mmtp-router.ts +3027 -0
- package/src/mmtp-to-cmaf.ts +956 -0
- package/src/multicast-auth-catalog.ts +340 -0
- package/src/multicast-input.ts +439 -0
- package/src/multicast-manager.ts +1503 -0
- package/src/multicast-transport.ts +320 -0
- package/src/multicast-unwrap.ts +132 -0
- package/src/no-modules.ts +20 -0
- package/src/phase14-catalog-override.ts +336 -0
- package/src/repair-fetch.ts +217 -0
- package/src/sample-combiner.ts +846 -0
- package/src/signaling.ts +78 -0
- package/src/source-auth.ts +1 -0
- package/src/switching-set-alignment.ts +109 -0
- package/src/timestamp-codec.ts +265 -0
- package/src/track-pipeline-setup.ts +189 -0
- package/src/track-pipeline.ts +332 -0
- package/src/track-session.ts +778 -0
- package/src/transport-pool.ts +128 -0
- package/src/wasm-mfu-reassembler.ts +372 -0
- package/src/wasm-mmtp-container-parser.ts +23 -0
- package/test-vectors/align.json +199 -0
- package/test-vectors/catalog/README.md +25 -0
- package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
- package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
- package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
- package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
- package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
- package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
- package/test-vectors/catalog/negative/network-source-object.json +25 -0
- package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +26 -0
- package/test-vectors/catalog/negative/repair-track-legacy-shape.json +18 -0
- package/test-vectors/catalog/negative/track-role-empty.json +16 -0
- package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
- package/test-vectors/catalog/positive/fec-multicast.json +51 -0
- package/test-vectors/catalog/positive/flat-av.json +30 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
- package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
- package/test-vectors/catalog/positive/track-role.json +49 -0
- package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
- package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
- package/test-vectors/catalog-multicast-auth-v1.json +26 -0
- package/test-vectors/catalog-validation.json +148 -0
- package/test-vectors/catalog-validator-public-api.mjs +25 -0
- package/test-vectors/generate-source-auth-fixture.mjs +114 -0
- package/test-vectors/source-auth-v1.json +61 -0
- package/test-vectors/subsample-placement-v1.json +230 -0
|
@@ -0,0 +1,1503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facade composing FECManager + MmtpRouter + MulticastTransport.
|
|
3
|
+
*
|
|
4
|
+
* Public methods delegate to the decomposed components. Applications that
|
|
5
|
+
* need individual layers can use them directly:
|
|
6
|
+
* - FECManager — codec-agnostic FEC decode
|
|
7
|
+
* - MmtpRouter — MMTP packet parsing + frame routing
|
|
8
|
+
* - MulticastTransport — SSM join/socket/watchdog
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
FECManager,
|
|
13
|
+
MIN_INTERLEAVE_DEPTH_MS,
|
|
14
|
+
type FECManagerConfig,
|
|
15
|
+
type WasmFecDecoder,
|
|
16
|
+
} from "./fec-manager.js";
|
|
17
|
+
import {
|
|
18
|
+
MmtpRouter,
|
|
19
|
+
type FrameCallback,
|
|
20
|
+
type ManifestIdentityResolver,
|
|
21
|
+
type MmtpIngressContext,
|
|
22
|
+
type TrackPacketCallback,
|
|
23
|
+
} from "./mmtp-router.js";
|
|
24
|
+
import { MulticastTransport } from "./multicast-transport.js";
|
|
25
|
+
import { computeFecDeliveryWindowMs } from "./track-session.js";
|
|
26
|
+
import { deriveFecInterleaveDepth, FecBlockMapper } from "@blockcast/mmt-fec";
|
|
27
|
+
import type { FecWorkerClient, FecTrackStats } from "@blockcast/fec-worker";
|
|
28
|
+
import type { MfuReassemblerBackend } from "./mfu-reassembler.js";
|
|
29
|
+
import type { MfuReassemblyPolicy } from "./mfu-reassembly-policy.js";
|
|
30
|
+
import type {
|
|
31
|
+
ManifestObjectIdentity,
|
|
32
|
+
ManifestVerifier,
|
|
33
|
+
} from "@blockcast/mmt-manifest-verify";
|
|
34
|
+
import type {
|
|
35
|
+
BlockAssemblerConfig,
|
|
36
|
+
CmafBlockSample,
|
|
37
|
+
} from "./cmaf-block-assembler.js";
|
|
38
|
+
import {
|
|
39
|
+
hasSwitchingSetRole,
|
|
40
|
+
parseTrackRole,
|
|
41
|
+
validateSwitchingSet,
|
|
42
|
+
isFecCatalogConfig,
|
|
43
|
+
type FecCatalogConfig,
|
|
44
|
+
type TrackRole,
|
|
45
|
+
} from "./carp-catalog.js";
|
|
46
|
+
|
|
47
|
+
export interface MulticastEndpointConfig {
|
|
48
|
+
sourceAddress: string;
|
|
49
|
+
groupAddress: string;
|
|
50
|
+
port: number;
|
|
51
|
+
/** Explicit gateway transport policy. Omitted means gateway-selected auto mode. */
|
|
52
|
+
mode?: 'auto' | 'native' | 'tunnel';
|
|
53
|
+
/** AMT relay hostname/IP from catalog endpoint. */
|
|
54
|
+
relayAddress?: string;
|
|
55
|
+
/** AMT relay port from catalog endpoint. */
|
|
56
|
+
relayPort?: number;
|
|
57
|
+
/** AMT relay hostname/IP from player/UI overrides. */
|
|
58
|
+
amtRelay?: string;
|
|
59
|
+
amtRelayPort?: number;
|
|
60
|
+
/** MMTP packet IDs to forward before data enters the page transport queue. */
|
|
61
|
+
packetIds?: number[];
|
|
62
|
+
/** Exact catalog tracks carried by this physical multicast endpoint. */
|
|
63
|
+
tracks?: MmtpIngressContext["tracks"];
|
|
64
|
+
fecK?: number;
|
|
65
|
+
/** Number of repair symbols per FEC block (P). Used to size recovery reorder latency. */
|
|
66
|
+
fecRepairSymbols?: number;
|
|
67
|
+
/** Symbol size in bytes (T). NOT repair count. */
|
|
68
|
+
fecSymbolSize?: number;
|
|
69
|
+
/** Catalog fec.reorderToleranceMs — signaled jitter/reorder allowance, ADDED
|
|
70
|
+
* to the derived delivery window. Never a multiplier on the span, so one
|
|
71
|
+
* network yields the same slack on a wide video span and a narrow audio one.
|
|
72
|
+
*
|
|
73
|
+
* Absence widens the window by zero rather than throwing, unlike the datagram
|
|
74
|
+
* MFU deadline in hang-mmt-fec. The distinction is which way absence fails:
|
|
75
|
+
* there the tolerance IS the deadline's slack term and guessing one invents
|
|
76
|
+
* a reorder budget, so it must fail loud; here the window is already fully
|
|
77
|
+
* derived from other catalog values and the tolerance only widens it, so
|
|
78
|
+
* adding nothing is the identity and errs toward earlier failback. Do not
|
|
79
|
+
* "harmonize" this into a throw, and do not turn the zero into a default. */
|
|
80
|
+
fecReorderToleranceMs?: number;
|
|
81
|
+
fecInterleaveDepthMs?: number;
|
|
82
|
+
/** Aggregate endpoint bandwidth in bits per second from the multicast catalog. */
|
|
83
|
+
bandwidth?: number;
|
|
84
|
+
fps?: number;
|
|
85
|
+
/** Catalog-derived lower bound for packet-silence failback (for example, keyframe repair cadence). */
|
|
86
|
+
minimumFailbackWindowMs?: number;
|
|
87
|
+
}
|
|
88
|
+
export interface MulticastManagerOptions {
|
|
89
|
+
/**
|
|
90
|
+
* MFU reassembly timeout (ms). Threaded to the inner MmtpRouter (and its
|
|
91
|
+
* MmtpContainerParser). Caller derives from catalog `fec.interleaveDepthMs`,
|
|
92
|
+
* which is already in milliseconds — `moqenc_mmt.c` converts
|
|
93
|
+
* `depth_ms = fec_depth * (1000/fps)` before populating the catalog.
|
|
94
|
+
* Defaults to 1000ms (with parser warning) when omitted.
|
|
95
|
+
*/
|
|
96
|
+
mfuTimeoutMs?: number;
|
|
97
|
+
reassemblyPolicy?: MfuReassemblyPolicy;
|
|
98
|
+
reassembler?: MfuReassemblerBackend;
|
|
99
|
+
maxBufferedMfus?: number;
|
|
100
|
+
manifestVerifier?: ManifestVerifier;
|
|
101
|
+
manifestVerifierOwnership?: "caller" | "router";
|
|
102
|
+
resolveManifestIdentity?: (
|
|
103
|
+
packetId: number,
|
|
104
|
+
sbn: number,
|
|
105
|
+
esi: number,
|
|
106
|
+
catalogTrackName?: string,
|
|
107
|
+
) => ManifestObjectIdentity | null;
|
|
108
|
+
resolveManifestIdentityForRoute?: ManifestIdentityResolver;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface RepairBlockIdentity {
|
|
112
|
+
readonly packetId: number;
|
|
113
|
+
/** Non-empty catalog identity, or null when the producer has no track name. */
|
|
114
|
+
readonly catalogTrackName: string | null;
|
|
115
|
+
readonly sbn: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type RepairLifecycleEvent =
|
|
119
|
+
| {
|
|
120
|
+
readonly version: 1;
|
|
121
|
+
readonly type: "requested";
|
|
122
|
+
readonly block: RepairBlockIdentity;
|
|
123
|
+
}
|
|
124
|
+
| {
|
|
125
|
+
readonly version: 1;
|
|
126
|
+
readonly type: "recovered" | "failed";
|
|
127
|
+
readonly block: RepairBlockIdentity;
|
|
128
|
+
readonly symbols: {
|
|
129
|
+
readonly multicast: number;
|
|
130
|
+
readonly moq: number;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type RepairLifecycleObserver = (event: RepairLifecycleEvent) => void;
|
|
135
|
+
|
|
136
|
+
export interface RepairLifecycleSource {
|
|
137
|
+
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Minimal event shape accepted by application-owned event targets. */
|
|
141
|
+
export interface RepairLifecycleApplicationEvent {
|
|
142
|
+
readonly type: string;
|
|
143
|
+
readonly detail: RepairLifecycleEvent;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** DOM EventTarget event shape, including the Node 18 Event fallback. */
|
|
147
|
+
export interface RepairLifecycleDomEvent extends Event {
|
|
148
|
+
readonly detail: RepairLifecycleEvent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Structural target contract shared by DOM and Closure-style event targets. */
|
|
152
|
+
export interface RepairLifecycleEventTarget<
|
|
153
|
+
TEvent extends RepairLifecycleApplicationEvent,
|
|
154
|
+
> {
|
|
155
|
+
dispatchEvent(event: TEvent): unknown;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface RepairLifecycleEventOptions<
|
|
159
|
+
TEvent extends RepairLifecycleApplicationEvent = RepairLifecycleDomEvent,
|
|
160
|
+
> {
|
|
161
|
+
bubbles?: boolean;
|
|
162
|
+
composed?: boolean;
|
|
163
|
+
createEvent?: RepairLifecycleEventFactory<TEvent>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type RepairLifecycleEventFactory<
|
|
167
|
+
TEvent extends RepairLifecycleApplicationEvent = RepairLifecycleDomEvent,
|
|
168
|
+
> = (
|
|
169
|
+
type: typeof REPAIR_LIFECYCLE_EVENT_TYPE,
|
|
170
|
+
detail: RepairLifecycleEvent,
|
|
171
|
+
options: Readonly<{ bubbles: boolean; composed: boolean }>,
|
|
172
|
+
) => TEvent;
|
|
173
|
+
|
|
174
|
+
/** Public EventTarget event carrying an immutable RepairLifecycleEvent detail. */
|
|
175
|
+
export const REPAIR_LIFECYCLE_EVENT_TYPE = "repairlifecycle";
|
|
176
|
+
|
|
177
|
+
/** Diagnostic JSON-lines prefix. Never consume logs as a lifecycle API. */
|
|
178
|
+
export const REPAIR_LIFECYCLE_LOG_PREFIX =
|
|
179
|
+
"[MulticastManager] repair-lifecycle ";
|
|
180
|
+
|
|
181
|
+
function createDefaultRepairLifecycleEvent(
|
|
182
|
+
detail: RepairLifecycleEvent,
|
|
183
|
+
options: Readonly<{ bubbles: boolean; composed: boolean }>,
|
|
184
|
+
): RepairLifecycleDomEvent {
|
|
185
|
+
if (typeof globalThis.CustomEvent === "function") {
|
|
186
|
+
return new CustomEvent<RepairLifecycleEvent>(REPAIR_LIFECYCLE_EVENT_TYPE, {
|
|
187
|
+
detail,
|
|
188
|
+
...options,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const event = new Event(REPAIR_LIFECYCLE_EVENT_TYPE, options);
|
|
193
|
+
Object.defineProperty(event, "detail", {
|
|
194
|
+
value: detail,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
});
|
|
197
|
+
return event as RepairLifecycleDomEvent;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
201
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function isRepairBlockIdentity(value: unknown): value is RepairBlockIdentity {
|
|
205
|
+
if (!isRecord(value)) return false;
|
|
206
|
+
const packetId = value["packetId"];
|
|
207
|
+
const catalogTrackName = value["catalogTrackName"];
|
|
208
|
+
const sbn = value["sbn"];
|
|
209
|
+
return (
|
|
210
|
+
Number.isSafeInteger(packetId) &&
|
|
211
|
+
(packetId as number) >= 0 &&
|
|
212
|
+
(catalogTrackName === null ||
|
|
213
|
+
(typeof catalogTrackName === "string" && catalogTrackName.length > 0)) &&
|
|
214
|
+
Number.isSafeInteger(sbn) &&
|
|
215
|
+
(sbn as number) >= 0
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Runtime guard for observer, DOM-event, and cross-realm consumers. */
|
|
220
|
+
export function isRepairLifecycleEvent(
|
|
221
|
+
value: unknown,
|
|
222
|
+
): value is RepairLifecycleEvent {
|
|
223
|
+
if (!isRecord(value)) return false;
|
|
224
|
+
const version = value["version"];
|
|
225
|
+
const type = value["type"];
|
|
226
|
+
const block = value["block"];
|
|
227
|
+
const symbols = value["symbols"];
|
|
228
|
+
if (
|
|
229
|
+
version !== 1 ||
|
|
230
|
+
(type !== "requested" && type !== "recovered" && type !== "failed") ||
|
|
231
|
+
!isRepairBlockIdentity(block)
|
|
232
|
+
) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
if (type === "requested") return symbols === undefined;
|
|
236
|
+
if (!isRecord(symbols)) return false;
|
|
237
|
+
const multicast = symbols["multicast"];
|
|
238
|
+
const moq = symbols["moq"];
|
|
239
|
+
return (
|
|
240
|
+
Number.isSafeInteger(multicast) &&
|
|
241
|
+
(multicast as number) >= 0 &&
|
|
242
|
+
Number.isSafeInteger(moq) &&
|
|
243
|
+
(moq as number) >= 0
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Forward typed repair lifecycle observations through an application-owned
|
|
249
|
+
* EventTarget. The adapter retains no history; the returned function detaches
|
|
250
|
+
* the observer.
|
|
251
|
+
*/
|
|
252
|
+
export function forwardRepairLifecycleEvents<
|
|
253
|
+
TEvent extends RepairLifecycleApplicationEvent,
|
|
254
|
+
>(
|
|
255
|
+
source: RepairLifecycleSource,
|
|
256
|
+
target: RepairLifecycleEventTarget<TEvent>,
|
|
257
|
+
options: RepairLifecycleEventOptions<TEvent> & {
|
|
258
|
+
createEvent: RepairLifecycleEventFactory<TEvent>;
|
|
259
|
+
},
|
|
260
|
+
): () => void;
|
|
261
|
+
export function forwardRepairLifecycleEvents(
|
|
262
|
+
source: RepairLifecycleSource,
|
|
263
|
+
target: EventTarget,
|
|
264
|
+
options?: RepairLifecycleEventOptions,
|
|
265
|
+
): () => void;
|
|
266
|
+
export function forwardRepairLifecycleEvents(
|
|
267
|
+
source: RepairLifecycleSource,
|
|
268
|
+
target:
|
|
269
|
+
| EventTarget
|
|
270
|
+
| RepairLifecycleEventTarget<RepairLifecycleApplicationEvent>,
|
|
271
|
+
options: RepairLifecycleEventOptions<RepairLifecycleApplicationEvent> = {},
|
|
272
|
+
): () => void {
|
|
273
|
+
return source.addRepairLifecycleObserver((event) => {
|
|
274
|
+
const eventOptions = {
|
|
275
|
+
bubbles: options.bubbles ?? false,
|
|
276
|
+
composed: options.composed ?? false,
|
|
277
|
+
};
|
|
278
|
+
const forwardedEvent = options.createEvent
|
|
279
|
+
? options.createEvent(REPAIR_LIFECYCLE_EVENT_TYPE, event, eventOptions)
|
|
280
|
+
: createDefaultRepairLifecycleEvent(event, eventOptions);
|
|
281
|
+
(
|
|
282
|
+
target as RepairLifecycleEventTarget<RepairLifecycleApplicationEvent>
|
|
283
|
+
).dispatchEvent(forwardedEvent);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function repairBlockIdentity(
|
|
288
|
+
packetId: number,
|
|
289
|
+
sbn: number,
|
|
290
|
+
catalogTrackName?: string,
|
|
291
|
+
): RepairBlockIdentity {
|
|
292
|
+
if (!Number.isSafeInteger(packetId) || packetId < 0) {
|
|
293
|
+
throw new TypeError("packetId must be a non-negative safe integer");
|
|
294
|
+
}
|
|
295
|
+
if (!Number.isSafeInteger(sbn) || sbn < 0) {
|
|
296
|
+
throw new TypeError("sbn must be a non-negative safe integer");
|
|
297
|
+
}
|
|
298
|
+
if (
|
|
299
|
+
catalogTrackName !== undefined &&
|
|
300
|
+
(typeof catalogTrackName !== "string" || catalogTrackName.length === 0)
|
|
301
|
+
) {
|
|
302
|
+
throw new TypeError("catalogTrackName must be a non-empty string when provided");
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
packetId,
|
|
306
|
+
catalogTrackName: catalogTrackName ?? null,
|
|
307
|
+
sbn,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Reject a catalog geometry value that is present but not usable. Absent stays
|
|
313
|
+
* absent — an omitted field is resolved from the previously configured track or
|
|
314
|
+
* left unset — but a supplied non-finite/non-positive value is a catalog defect
|
|
315
|
+
* and must fail at configuration time rather than collapse a derived deadline
|
|
316
|
+
* to ~0 packets later.
|
|
317
|
+
*/
|
|
318
|
+
function assertPositiveGeometry(
|
|
319
|
+
label: string,
|
|
320
|
+
value: number | undefined,
|
|
321
|
+
): void {
|
|
322
|
+
if (value === undefined) return;
|
|
323
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`[MulticastManager] ${label}=${value}. ` +
|
|
326
|
+
`Derive a positive ${label} from the stream catalog.`,
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Repair-symbol count (P) may legitimately be 0; only reject malformed values. */
|
|
332
|
+
function assertNonNegativeGeometry(
|
|
333
|
+
label: string,
|
|
334
|
+
value: number | undefined,
|
|
335
|
+
): void {
|
|
336
|
+
if (value === undefined) return;
|
|
337
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
338
|
+
throw new Error(
|
|
339
|
+
`[MulticastManager] ${label}=${value}. ` +
|
|
340
|
+
`Derive a non-negative ${label} from the stream catalog.`,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* One contributor to the stream-global FEC timing reduction.
|
|
347
|
+
*
|
|
348
|
+
* FEC geometry is per-track, but a MulticastManager owns exactly one transport
|
|
349
|
+
* and one router, so the failback watchdog and the router's MFU/reorder timing
|
|
350
|
+
* are stream-global. They are reduced with `max` across every contributor:
|
|
351
|
+
* failback must not fire, and the router must not evict, while ANY configured
|
|
352
|
+
* track's FEC block could still complete.
|
|
353
|
+
*/
|
|
354
|
+
interface FecTimingContribution {
|
|
355
|
+
deliveryWindowMs?: number;
|
|
356
|
+
interleaveDepthMs?: number;
|
|
357
|
+
fps?: number;
|
|
358
|
+
k?: number;
|
|
359
|
+
repairSymbols?: number;
|
|
360
|
+
minimumFailbackWindowMs?: number;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function fecReorderWindowFrames(
|
|
364
|
+
fecInterleaveDepthMs?: number,
|
|
365
|
+
fps?: number,
|
|
366
|
+
_k?: number,
|
|
367
|
+
_repairSymbols?: number,
|
|
368
|
+
): number {
|
|
369
|
+
if (!fecInterleaveDepthMs || fecInterleaveDepthMs <= 0 || !fps || fps <= 0) return 0;
|
|
370
|
+
const frameMs = 1000 / fps;
|
|
371
|
+
// Reorder across the FEC block span: fecInterleaveDepthMs IS the full block
|
|
372
|
+
// span (§5.1), so this window admits any FEC-recovered frame from the block
|
|
373
|
+
// without holding frames longer than one block.
|
|
374
|
+
return deriveFecInterleaveDepth(fecInterleaveDepthMs, frameMs);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Catalog track descriptor for configureMultiTrack(). */
|
|
378
|
+
export interface MultiTrackCatalogTrack {
|
|
379
|
+
name: string;
|
|
380
|
+
altGroup?: number;
|
|
381
|
+
framerate?: number;
|
|
382
|
+
fec?: unknown;
|
|
383
|
+
/** PacketId for testability — in production, learned at subscribe time (Plan 03). */
|
|
384
|
+
packetId?: number;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Multi-track catalog shape accepted by configureMultiTrack(). */
|
|
388
|
+
export interface MultiTrackCatalog {
|
|
389
|
+
tracks: MultiTrackCatalogTrack[];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** Creates one stateful synchronous FEC decoder per physical catalog stream. */
|
|
393
|
+
export type WasmFecDecoderFactory = (
|
|
394
|
+
track: Readonly<MultiTrackCatalogTrack>,
|
|
395
|
+
) => WasmFecDecoder;
|
|
396
|
+
|
|
397
|
+
const DEFAULT_ALT_GROUP = "__default__";
|
|
398
|
+
|
|
399
|
+
type FecDiagnosticsGateway = {
|
|
400
|
+
reportFecDiagnostics?: (snapshot: unknown) => void;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
function publishFecDiagnostics(packetId: number, stats: FecTrackStats): boolean {
|
|
404
|
+
const gateway = (globalThis as typeof globalThis & {
|
|
405
|
+
multicast?: FecDiagnosticsGateway;
|
|
406
|
+
}).multicast;
|
|
407
|
+
if (typeof gateway?.reportFecDiagnostics !== "function") return false;
|
|
408
|
+
|
|
409
|
+
// Keep the control-plane payload bounded and JSON-safe. The Worker snapshot
|
|
410
|
+
// already bounds active blocks; the bridge needs only the current block tail
|
|
411
|
+
// and stable counters, not decoder internals or authentication failure text.
|
|
412
|
+
const snapshot = {
|
|
413
|
+
version: 1,
|
|
414
|
+
packetId,
|
|
415
|
+
observedAt: Date.now(),
|
|
416
|
+
stats: {
|
|
417
|
+
config: {
|
|
418
|
+
...stats.config,
|
|
419
|
+
resolution: stats.config.resolution
|
|
420
|
+
? { ...stats.config.resolution }
|
|
421
|
+
: undefined,
|
|
422
|
+
},
|
|
423
|
+
sourceSymbols: stats.sourceSymbols,
|
|
424
|
+
repairSymbols: stats.repairSymbols,
|
|
425
|
+
blocksComplete: stats.blocksComplete,
|
|
426
|
+
blocksRecovered: stats.blocksRecovered,
|
|
427
|
+
blocksFailed: stats.blocksFailed,
|
|
428
|
+
greenFillFrames: stats.greenFillFrames,
|
|
429
|
+
recoveryRate: stats.recoveryRate,
|
|
430
|
+
liveSbn: stats.liveSbn,
|
|
431
|
+
blocks: stats.blocks.slice(-8).map((block) => ({ ...block })),
|
|
432
|
+
interleaveWindowBlocks: stats.interleaveWindowBlocks,
|
|
433
|
+
avgRecoveryMs: stats.avgRecoveryMs,
|
|
434
|
+
maxRecoveryMs: stats.maxRecoveryMs,
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
gateway.reportFecDiagnostics(snapshot);
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function altGroupKey(track: MultiTrackCatalogTrack): string {
|
|
443
|
+
return track.altGroup === undefined ? DEFAULT_ALT_GROUP : String(track.altGroup);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export class MulticastManager {
|
|
447
|
+
readonly #fec: FECManager;
|
|
448
|
+
readonly #router: MmtpRouter;
|
|
449
|
+
readonly #transport: MulticastTransport<MmtpIngressContext>;
|
|
450
|
+
#reportedFecDiagnosticsFailure = false;
|
|
451
|
+
|
|
452
|
+
// ── Stream-global FEC timing reduction ──
|
|
453
|
+
//
|
|
454
|
+
// FEC geometry is per-track; the transport failback watchdog and the router's
|
|
455
|
+
// MFU/reorder timing are stream-global (one transport, one router). Both
|
|
456
|
+
// configuration entry points feed the same reduction so neither can silently
|
|
457
|
+
// clip the other: configureFec() supplies the baseline, configureTrackFec()
|
|
458
|
+
// supplies one entry per track, and #applyStreamGlobalFecTiming() takes the
|
|
459
|
+
// max across all of them.
|
|
460
|
+
#streamFecBaseline?: FecTimingContribution;
|
|
461
|
+
readonly #trackFecTiming = new Map<number, FecTimingContribution>();
|
|
462
|
+
|
|
463
|
+
// ── Phase 14: multi-track state (D-06, D-07, D-17, D-26, D-28) ──
|
|
464
|
+
|
|
465
|
+
/** Maps altGroup → track names sharing that altGroup. */
|
|
466
|
+
#switchingSets: Map<number, string[]> = new Map();
|
|
467
|
+
|
|
468
|
+
/** Repair packetIds that should not get their own FEC decoder (they ARE the repair source). */
|
|
469
|
+
#repairPacketIds: Set<number> = new Set();
|
|
470
|
+
|
|
471
|
+
/** Tracks physical-stream FEC blocks with an outstanding repair fetch. */
|
|
472
|
+
#repairInFlight: Set<string> = new Set();
|
|
473
|
+
|
|
474
|
+
/** Causal repair events; observers own any retention they require. */
|
|
475
|
+
#repairLifecycleObservers = new Set<RepairLifecycleObserver>();
|
|
476
|
+
|
|
477
|
+
#trackResetObservers = new Set<
|
|
478
|
+
(packetId: number, catalogTrackName: string) => void
|
|
479
|
+
>();
|
|
480
|
+
|
|
481
|
+
/** Callback fired when a repair fetch should be issued for a block. */
|
|
482
|
+
#onRepairSubscribeCb:
|
|
483
|
+
| ((sbn: number, packetId: number, catalogTrackName?: string) => void)
|
|
484
|
+
| null = null;
|
|
485
|
+
|
|
486
|
+
constructor(options?: MulticastManagerOptions) {
|
|
487
|
+
this.#fec = new FECManager();
|
|
488
|
+
this.#fec.addFecStatsObserver((packetId, stats) => {
|
|
489
|
+
try {
|
|
490
|
+
if (publishFecDiagnostics(packetId, stats)) {
|
|
491
|
+
this.#reportedFecDiagnosticsFailure = false;
|
|
492
|
+
}
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (!this.#reportedFecDiagnosticsFailure) {
|
|
495
|
+
this.#reportedFecDiagnosticsFailure = true;
|
|
496
|
+
console.warn('[MulticastManager] Failed to publish FEC diagnostics:', error);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
this.#router = new MmtpRouter({
|
|
501
|
+
fecManager: this.#fec,
|
|
502
|
+
mfuTimeoutMs: options?.mfuTimeoutMs,
|
|
503
|
+
reassemblyPolicy: options?.reassemblyPolicy,
|
|
504
|
+
reassembler: options?.reassembler,
|
|
505
|
+
maxBufferedMfus: options?.maxBufferedMfus,
|
|
506
|
+
manifestVerifier: options?.manifestVerifier,
|
|
507
|
+
manifestVerifierOwnership: options?.manifestVerifierOwnership,
|
|
508
|
+
resolveManifestIdentity: options?.resolveManifestIdentity,
|
|
509
|
+
resolveManifestIdentityForRoute: options?.resolveManifestIdentityForRoute,
|
|
510
|
+
onBlockFailed: (sbn, packetId, catalogTrackName) => {
|
|
511
|
+
const pathCount = this.#fec.blockPathCount(
|
|
512
|
+
sbn,
|
|
513
|
+
packetId,
|
|
514
|
+
catalogTrackName,
|
|
515
|
+
);
|
|
516
|
+
this.#emitRepairLifecycle({
|
|
517
|
+
version: 1,
|
|
518
|
+
type: "failed",
|
|
519
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
520
|
+
symbols: {
|
|
521
|
+
multicast: pathCount?.multicastSymbols ?? 0,
|
|
522
|
+
moq: pathCount?.moqSymbols ?? 0,
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
this.#transport = new MulticastTransport<MmtpIngressContext>((packet, ingress) => {
|
|
528
|
+
this.#router.feedPacket(packet, "multicast", undefined, ingress);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// Worker-path FEC recovery: route recovered source-symbol bytes through
|
|
532
|
+
// MmtpRouter so MFU reassembly + dedup runs. Without this wiring the
|
|
533
|
+
// FecWorkerClient's recovered frames fire FECManager.onBlockRecovered
|
|
534
|
+
// into a null callback and VideoDecoder never sees a real frame.
|
|
535
|
+
this.#fec.onBlockRecovered = (sbn, packetId, data, meta, recoveredTrackName) => {
|
|
536
|
+
const recovered = new Uint8Array(data);
|
|
537
|
+
const catalogTrackName = recoveredTrackName
|
|
538
|
+
?? this.#fec.catalogTrackNameForBlock(sbn, packetId);
|
|
539
|
+
if (catalogTrackName === undefined) {
|
|
540
|
+
this.#router.routeRecoveredSymbol(sbn, recovered, packetId, meta.esi);
|
|
541
|
+
} else {
|
|
542
|
+
this.#router.routeRecoveredSymbol(
|
|
543
|
+
sbn,
|
|
544
|
+
recovered,
|
|
545
|
+
packetId,
|
|
546
|
+
meta.esi,
|
|
547
|
+
catalogTrackName,
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// D-28: release the in-flight repair slot when a repair-requested block
|
|
553
|
+
// resolves (completes, recovers, or fails), and emit the gate log line.
|
|
554
|
+
// The request-side bridge (FECManager.onRepairNeeded) is wired in
|
|
555
|
+
// onRepairSubscribe() so repair deadlines only arm once a player has
|
|
556
|
+
// registered a fetcher — consumers without D-28 pay no timer cost.
|
|
557
|
+
this.#fec.onRepairResolved = (sbn, packetId, outcome, catalogTrackName) => {
|
|
558
|
+
this.clearRepairForBlock(sbn, packetId, catalogTrackName);
|
|
559
|
+
if (outcome === "failed") return;
|
|
560
|
+
const pathCount = this.#fec.blockPathCount(
|
|
561
|
+
sbn,
|
|
562
|
+
packetId,
|
|
563
|
+
catalogTrackName,
|
|
564
|
+
);
|
|
565
|
+
const multicastSymbols = pathCount?.multicastSymbols ?? 0;
|
|
566
|
+
const moqSymbols = pathCount?.moqSymbols ?? 0;
|
|
567
|
+
this.#emitRepairLifecycle({
|
|
568
|
+
version: 1,
|
|
569
|
+
type: "recovered",
|
|
570
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
571
|
+
symbols: {
|
|
572
|
+
multicast: multicastSymbols,
|
|
573
|
+
moq: moqSymbols,
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// ---------------------------------------------------------------------------
|
|
580
|
+
// Decomposed component accessors (for new code)
|
|
581
|
+
// ---------------------------------------------------------------------------
|
|
582
|
+
|
|
583
|
+
get fecManager(): FECManager {
|
|
584
|
+
return this.#fec;
|
|
585
|
+
}
|
|
586
|
+
get router(): MmtpRouter {
|
|
587
|
+
return this.#router;
|
|
588
|
+
}
|
|
589
|
+
get transport(): MulticastTransport {
|
|
590
|
+
return this.#transport;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// ---------------------------------------------------------------------------
|
|
594
|
+
// Stats
|
|
595
|
+
// ---------------------------------------------------------------------------
|
|
596
|
+
|
|
597
|
+
get reassembler() {
|
|
598
|
+
return this.#router.reassembler;
|
|
599
|
+
}
|
|
600
|
+
get diagnostics() {
|
|
601
|
+
return {
|
|
602
|
+
...this.#router.getDiagnostics(),
|
|
603
|
+
_fec: this.#fec.diagnostics,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
get stats() {
|
|
607
|
+
return this.#transport.stats;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
get fecStats() {
|
|
611
|
+
return this.#fec.fecStats;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** The raw WASM decoder for stats access */
|
|
615
|
+
get wasmDecoder() {
|
|
616
|
+
return this.#fec.wasmDecoder;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// ---------------------------------------------------------------------------
|
|
620
|
+
// FEC configuration (delegates to FECManager)
|
|
621
|
+
// ---------------------------------------------------------------------------
|
|
622
|
+
|
|
623
|
+
setFecDecoder(
|
|
624
|
+
packetId: number,
|
|
625
|
+
client: WasmFecDecoder,
|
|
626
|
+
k: number,
|
|
627
|
+
trackType: "video" | "audio" = "video",
|
|
628
|
+
config?: FECManagerConfig,
|
|
629
|
+
catalogTrackName?: string,
|
|
630
|
+
) {
|
|
631
|
+
const fecConfig = { ...config, k };
|
|
632
|
+
this.#fec.setFecDecoder(packetId, client, k, fecConfig, catalogTrackName);
|
|
633
|
+
this.#configureTrackMapper(packetId, fecConfig);
|
|
634
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Register a Worker-backed FEC decoder for a specific packetId (track).
|
|
639
|
+
* Worker-backed tracks decode asynchronously — recovered frames arrive via
|
|
640
|
+
* FECManager.onBlockRecovered callback instead of feedSourceSymbol return value.
|
|
641
|
+
*/
|
|
642
|
+
setFecWorker(
|
|
643
|
+
packetId: number,
|
|
644
|
+
client: FecWorkerClient,
|
|
645
|
+
trackType: "video" | "audio",
|
|
646
|
+
config: FECManagerConfig,
|
|
647
|
+
catalogTrackName?: string,
|
|
648
|
+
): void {
|
|
649
|
+
this.#fec.setFecWorker(packetId, client, config, catalogTrackName);
|
|
650
|
+
this.#configureTrackMapper(packetId, config);
|
|
651
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** Register callback for Worker-level FecTrackStats updates. */
|
|
655
|
+
setOnFecStatsUpdate(
|
|
656
|
+
cb: (packetId: number, stats: FecTrackStats) => void,
|
|
657
|
+
): void {
|
|
658
|
+
this.#fec.onFecStatsUpdate = cb;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
setFramerate(fps: number) {
|
|
662
|
+
this.#router.setFramerate(fps);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
#configureTrackMapper(packetId: number, config: FECManagerConfig): void {
|
|
666
|
+
const k = config.k;
|
|
667
|
+
const interleaveMs = config.interleaveDepthMs;
|
|
668
|
+
const fps = config.fps;
|
|
669
|
+
if (k && k > 0 && interleaveMs && interleaveMs > 0 && fps && fps > 0) {
|
|
670
|
+
this.#router.setFecMapper(
|
|
671
|
+
new FecBlockMapper({
|
|
672
|
+
k,
|
|
673
|
+
interleaveDepthMs: interleaveMs,
|
|
674
|
+
gopDurationMs: 1000 / fps,
|
|
675
|
+
}),
|
|
676
|
+
packetId,
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Reduce every registered FEC timing contributor to the stream-global
|
|
683
|
+
* deadlines and apply them to the single transport and single router.
|
|
684
|
+
*
|
|
685
|
+
* `max`, not `min` or last-write-wins: a narrower track must never pull the
|
|
686
|
+
* failback watchdog or the router's reorder window in under a wider track's
|
|
687
|
+
* still-completable FEC block. Recomputed on every registration so a track
|
|
688
|
+
* that arrives late widens the stream rather than being clipped by it.
|
|
689
|
+
*/
|
|
690
|
+
#applyStreamGlobalFecTiming(): void {
|
|
691
|
+
const contributions: FecTimingContribution[] = [
|
|
692
|
+
...(this.#streamFecBaseline ? [this.#streamFecBaseline] : []),
|
|
693
|
+
...this.#trackFecTiming.values(),
|
|
694
|
+
];
|
|
695
|
+
if (contributions.length === 0) return;
|
|
696
|
+
|
|
697
|
+
let deliveryWindowMs: number | undefined;
|
|
698
|
+
let minimumFailbackWindowMs: number | undefined;
|
|
699
|
+
let mfuTimeoutMs: number | undefined;
|
|
700
|
+
let reorderWindowFrames: number | undefined;
|
|
701
|
+
|
|
702
|
+
for (const c of contributions) {
|
|
703
|
+
if (c.deliveryWindowMs !== undefined) {
|
|
704
|
+
deliveryWindowMs = Math.max(deliveryWindowMs ?? 0, c.deliveryWindowMs);
|
|
705
|
+
}
|
|
706
|
+
if (c.minimumFailbackWindowMs !== undefined) {
|
|
707
|
+
minimumFailbackWindowMs = Math.max(
|
|
708
|
+
minimumFailbackWindowMs ?? 0,
|
|
709
|
+
c.minimumFailbackWindowMs,
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
// Only a valid §5.1 ms interleave may drive router timing. A sub-floor
|
|
713
|
+
// value is a raw frame count (no fps to convert with) and would collapse
|
|
714
|
+
// the MFU timeout to ~0 and the reorder window to a single frame; skip
|
|
715
|
+
// the derivation rather than clamp it, leaving previously-configured
|
|
716
|
+
// router timing untouched.
|
|
717
|
+
const interleaveOk =
|
|
718
|
+
c.interleaveDepthMs !== undefined &&
|
|
719
|
+
c.interleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS;
|
|
720
|
+
if (interleaveOk && c.deliveryWindowMs) {
|
|
721
|
+
mfuTimeoutMs = Math.max(mfuTimeoutMs ?? 0, c.deliveryWindowMs);
|
|
722
|
+
}
|
|
723
|
+
if (interleaveOk && c.fps && c.fps > 0) {
|
|
724
|
+
reorderWindowFrames = Math.max(
|
|
725
|
+
reorderWindowFrames ?? 0,
|
|
726
|
+
fecReorderWindowFrames(
|
|
727
|
+
c.interleaveDepthMs,
|
|
728
|
+
c.fps,
|
|
729
|
+
c.k,
|
|
730
|
+
c.repairSymbols,
|
|
731
|
+
),
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
const failbackWindowMs =
|
|
737
|
+
deliveryWindowMs === undefined
|
|
738
|
+
? minimumFailbackWindowMs
|
|
739
|
+
: Math.max(deliveryWindowMs, minimumFailbackWindowMs ?? 0);
|
|
740
|
+
if (failbackWindowMs !== undefined) {
|
|
741
|
+
this.#transport.setFailbackWindowMs(failbackWindowMs);
|
|
742
|
+
}
|
|
743
|
+
if (mfuTimeoutMs !== undefined) {
|
|
744
|
+
this.#router.setMfuTimeoutMs(mfuTimeoutMs);
|
|
745
|
+
}
|
|
746
|
+
if (reorderWindowFrames !== undefined) {
|
|
747
|
+
this.#router.setReorderWindow(reorderWindowFrames);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Configure one track's FEC geometry, block mapper, and block-inactivity
|
|
753
|
+
* deadline from that track's own catalog values, then re-reduce the
|
|
754
|
+
* stream-global deadlines across every registered track.
|
|
755
|
+
*
|
|
756
|
+
* This is the packet-specific replacement for the global `configureFec`
|
|
757
|
+
* side effects: per-track concerns stay per-track, and the genuinely
|
|
758
|
+
* stream-global ones (transport failback, router MFU timeout, router reorder
|
|
759
|
+
* window) become an explicit max reduction instead of a last-caller-wins race
|
|
760
|
+
* in which whichever track configured last silently set the whole stream's
|
|
761
|
+
* timing.
|
|
762
|
+
*/
|
|
763
|
+
configureTrackFec(
|
|
764
|
+
packetId: number,
|
|
765
|
+
config: Pick<
|
|
766
|
+
MulticastEndpointConfig,
|
|
767
|
+
| "fecK"
|
|
768
|
+
| "fecRepairSymbols"
|
|
769
|
+
| "fecSymbolSize"
|
|
770
|
+
| "fecInterleaveDepthMs"
|
|
771
|
+
| "fecReorderToleranceMs"
|
|
772
|
+
| "fps"
|
|
773
|
+
| "bandwidth"
|
|
774
|
+
| "minimumFailbackWindowMs"
|
|
775
|
+
>,
|
|
776
|
+
): void {
|
|
777
|
+
if (config.fecK === undefined || config.fecInterleaveDepthMs === undefined) {
|
|
778
|
+
throw new Error(
|
|
779
|
+
`[MulticastManager] configureTrackFec(${packetId}) requires fecK and ` +
|
|
780
|
+
"fecInterleaveDepthMs. Derive the per-track FEC geometry from the " +
|
|
781
|
+
"stream catalog.",
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
assertPositiveGeometry("fecK", config.fecK);
|
|
785
|
+
assertPositiveGeometry("fecInterleaveDepthMs", config.fecInterleaveDepthMs);
|
|
786
|
+
assertPositiveGeometry("fecSymbolSize", config.fecSymbolSize);
|
|
787
|
+
assertPositiveGeometry("fps", config.fps);
|
|
788
|
+
assertPositiveGeometry("bandwidth", config.bandwidth);
|
|
789
|
+
assertPositiveGeometry(
|
|
790
|
+
"minimumFailbackWindowMs",
|
|
791
|
+
config.minimumFailbackWindowMs,
|
|
792
|
+
);
|
|
793
|
+
assertNonNegativeGeometry("fecRepairSymbols", config.fecRepairSymbols);
|
|
794
|
+
// A tolerance is the network path's allowance, added to the encoder's
|
|
795
|
+
// span. These are public entry points: the catalog parser validates what it
|
|
796
|
+
// parses, but a direct caller reaches this arithmetic without passing
|
|
797
|
+
// through it. A negative value silently *shortens* the delivery window
|
|
798
|
+
// below the signaled span, and Infinity/NaN yields a window no block can
|
|
799
|
+
// ever miss -- the eviction bound stops bounding. Reuse the shared
|
|
800
|
+
// non-negative guard rather than an inline check: undefined must stay
|
|
801
|
+
// undefined (absent means the encoder never signaled one, and must not be
|
|
802
|
+
// defaulted), while a declared 0 is a real value that has to survive.
|
|
803
|
+
assertNonNegativeGeometry(
|
|
804
|
+
"fecReorderToleranceMs",
|
|
805
|
+
config.fecReorderToleranceMs,
|
|
806
|
+
);
|
|
807
|
+
|
|
808
|
+
// Same derivation as the stream-global path, but from THIS track's
|
|
809
|
+
// geometry. FECManager already stores a per-track timeoutMs
|
|
810
|
+
// (configureTrack/timeoutMsForPacket); it just never had the repair-symbol
|
|
811
|
+
// and bandwidth inputs needed to compute one.
|
|
812
|
+
const deliveryWindowMs =
|
|
813
|
+
config.fecInterleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS
|
|
814
|
+
? computeFecDeliveryWindowMs({
|
|
815
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
816
|
+
sourceSymbols: config.fecK,
|
|
817
|
+
repairSymbols: config.fecRepairSymbols,
|
|
818
|
+
symbolSize: config.fecSymbolSize,
|
|
819
|
+
mediaUnitsPerSecond: config.fps,
|
|
820
|
+
bandwidthBps: config.bandwidth,
|
|
821
|
+
}) + (config.fecReorderToleranceMs ?? 0)
|
|
822
|
+
: undefined;
|
|
823
|
+
|
|
824
|
+
const fecConfig: FECManagerConfig = {
|
|
825
|
+
k: config.fecK,
|
|
826
|
+
symbolSize: config.fecSymbolSize,
|
|
827
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
828
|
+
fps: config.fps,
|
|
829
|
+
timeoutMs: deliveryWindowMs,
|
|
830
|
+
};
|
|
831
|
+
this.#fec.configureTrack(packetId, fecConfig);
|
|
832
|
+
this.#configureTrackMapper(packetId, fecConfig);
|
|
833
|
+
|
|
834
|
+
this.#trackFecTiming.set(packetId, {
|
|
835
|
+
deliveryWindowMs,
|
|
836
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
837
|
+
fps: config.fps,
|
|
838
|
+
k: config.fecK,
|
|
839
|
+
repairSymbols: config.fecRepairSymbols,
|
|
840
|
+
minimumFailbackWindowMs: config.minimumFailbackWindowMs,
|
|
841
|
+
});
|
|
842
|
+
this.#applyStreamGlobalFecTiming();
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
configureFec(
|
|
846
|
+
config: Pick<
|
|
847
|
+
MulticastEndpointConfig,
|
|
848
|
+
| "fecK"
|
|
849
|
+
| "fecRepairSymbols"
|
|
850
|
+
| "fecSymbolSize"
|
|
851
|
+
| "fecInterleaveDepthMs"
|
|
852
|
+
| "fecReorderToleranceMs"
|
|
853
|
+
| "fps"
|
|
854
|
+
| "bandwidth"
|
|
855
|
+
| "minimumFailbackWindowMs"
|
|
856
|
+
>,
|
|
857
|
+
) {
|
|
858
|
+
const minimumFailbackWindowMs = config.minimumFailbackWindowMs;
|
|
859
|
+
if (
|
|
860
|
+
minimumFailbackWindowMs !== undefined &&
|
|
861
|
+
(!Number.isFinite(minimumFailbackWindowMs) || minimumFailbackWindowMs <= 0)
|
|
862
|
+
) {
|
|
863
|
+
throw new Error(
|
|
864
|
+
`[MulticastManager] minimumFailbackWindowMs=${minimumFailbackWindowMs}. ` +
|
|
865
|
+
"Derive a positive failback floor from the stream catalog.",
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
// A tolerance is the network path's allowance, added to the encoder's
|
|
869
|
+
// span. These are public entry points: the catalog parser validates what it
|
|
870
|
+
// parses, but a direct caller reaches this arithmetic without passing
|
|
871
|
+
// through it. A negative value silently *shortens* the delivery window
|
|
872
|
+
// below the signaled span, and Infinity/NaN yields a window no block can
|
|
873
|
+
// ever miss -- the eviction bound stops bounding. Reuse the shared
|
|
874
|
+
// non-negative guard rather than an inline check: undefined must stay
|
|
875
|
+
// undefined (absent means the encoder never signaled one, and must not be
|
|
876
|
+
// defaulted), while a declared 0 is a real value that has to survive.
|
|
877
|
+
assertNonNegativeGeometry(
|
|
878
|
+
"fecReorderToleranceMs",
|
|
879
|
+
config.fecReorderToleranceMs,
|
|
880
|
+
);
|
|
881
|
+
const deliveryWindowMs =
|
|
882
|
+
config.fecK &&
|
|
883
|
+
config.fecK > 0 &&
|
|
884
|
+
config.fecInterleaveDepthMs &&
|
|
885
|
+
config.fecInterleaveDepthMs >= MIN_INTERLEAVE_DEPTH_MS
|
|
886
|
+
? computeFecDeliveryWindowMs({
|
|
887
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
888
|
+
sourceSymbols: config.fecK,
|
|
889
|
+
repairSymbols: config.fecRepairSymbols,
|
|
890
|
+
symbolSize: config.fecSymbolSize,
|
|
891
|
+
mediaUnitsPerSecond: config.fps,
|
|
892
|
+
bandwidthBps: config.bandwidth,
|
|
893
|
+
}) + (config.fecReorderToleranceMs ?? 0)
|
|
894
|
+
: undefined;
|
|
895
|
+
this.#fec.configure({
|
|
896
|
+
k: config.fecK,
|
|
897
|
+
symbolSize: config.fecSymbolSize,
|
|
898
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
899
|
+
fps: config.fps,
|
|
900
|
+
timeoutMs: deliveryWindowMs,
|
|
901
|
+
});
|
|
902
|
+
// External-feed consumers own the multicast socket and call feedPacket()
|
|
903
|
+
// directly, so they never enter join(). Configure the transport watchdog
|
|
904
|
+
// here where both transport-owned and external-feed paths share the same
|
|
905
|
+
// catalog-derived FEC timing.
|
|
906
|
+
//
|
|
907
|
+
// This call supplies the stream-global BASELINE contribution. Any track
|
|
908
|
+
// registered via configureTrackFec() participates in the same max
|
|
909
|
+
// reduction, so a per-track window can only widen these deadlines, never
|
|
910
|
+
// narrow them below what this baseline already guarantees.
|
|
911
|
+
this.#streamFecBaseline = {
|
|
912
|
+
deliveryWindowMs,
|
|
913
|
+
interleaveDepthMs: config.fecInterleaveDepthMs,
|
|
914
|
+
fps: config.fps,
|
|
915
|
+
k: config.fecK,
|
|
916
|
+
repairSymbols: config.fecRepairSymbols,
|
|
917
|
+
minimumFailbackWindowMs,
|
|
918
|
+
};
|
|
919
|
+
this.#applyStreamGlobalFecTiming();
|
|
920
|
+
// Wire FecBlockMapper to MmtpRouter so SBN/ESI derivation works for FEC recovery.
|
|
921
|
+
//
|
|
922
|
+
// gopDurationMs MUST be the per-frame interval (1000/fps), NOT the
|
|
923
|
+
// interleaveDepthMs. Passing interleaveDepthMs collapses D to 1, which
|
|
924
|
+
// makes the mapper math equivalent to the no-mapper fallback
|
|
925
|
+
// (floor(ssId/k), ssId%k) and breaks SBN/ESI derivation for any interleaved
|
|
926
|
+
// FEC. Surfaced by BLO-3323 L14 (pim-multicast-gateway run 26373805710):
|
|
927
|
+
// with K=32 + interleaveDepthMs=1000ms but gopDurationMs=1000ms, blocks
|
|
928
|
+
// completed with only ~8 source + ~8 repair symbols (out of 40 expected at
|
|
929
|
+
// 25-30fps), so the WASM decoder failed to recover any block at 10% loss.
|
|
930
|
+
const k = config.fecK;
|
|
931
|
+
const interleaveMs = config.fecInterleaveDepthMs;
|
|
932
|
+
const fps = config.fps;
|
|
933
|
+
if (k && k > 0 && interleaveMs && interleaveMs > 0 && fps && fps > 0) {
|
|
934
|
+
const mapper = new FecBlockMapper({
|
|
935
|
+
k,
|
|
936
|
+
interleaveDepthMs: interleaveMs,
|
|
937
|
+
gopDurationMs: 1000 / fps,
|
|
938
|
+
});
|
|
939
|
+
this.#router.setFecMapper(mapper);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// ---------------------------------------------------------------------------
|
|
944
|
+
// Track configuration (delegates to MmtpRouter)
|
|
945
|
+
// ---------------------------------------------------------------------------
|
|
946
|
+
|
|
947
|
+
// Track type discovery callback — fires when setPacketIdType is called.
|
|
948
|
+
// Players wire this to MediaRouter.registerTrackTypeFromInit() for
|
|
949
|
+
// init data authority (authoritative until next catalog update).
|
|
950
|
+
#onTrackTypeDiscovered:
|
|
951
|
+
| ((packetId: number, trackType: "video" | "audio") => void)
|
|
952
|
+
| null = null;
|
|
953
|
+
|
|
954
|
+
/** Register callback for track type discovery (from init data / inline signaling). */
|
|
955
|
+
onTrackTypeDiscovered(
|
|
956
|
+
cb: (packetId: number, trackType: "video" | "audio") => void,
|
|
957
|
+
): void {
|
|
958
|
+
this.#onTrackTypeDiscovered = cb;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
setPacketIdType(packetId: number, trackType: "video" | "audio") {
|
|
962
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
963
|
+
this.#onTrackTypeDiscovered?.(packetId, trackType);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Set the keyframe loss timeout on the inner MmtpRouter.
|
|
968
|
+
* Must be called BEFORE setPacketIdType('video').
|
|
969
|
+
* Derive from explicit keyframe/group duration:
|
|
970
|
+
* Math.ceil(groupDurationMs * KEYFRAME_LOST_TIMEOUT_SLACK).
|
|
971
|
+
*/
|
|
972
|
+
setKeyframeLostTimeoutMs(ms: number): void {
|
|
973
|
+
this.#router.setKeyframeLostTimeoutMs(ms);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
setMfuTimeoutMs(ms: number): void {
|
|
977
|
+
this.#router.setMfuTimeoutMs(ms);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
setTrackCodec(packetId: number, codec: string) {
|
|
981
|
+
this.#router.setTrackCodec(packetId, codec);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// ---------------------------------------------------------------------------
|
|
985
|
+
// Callbacks (delegates to MmtpRouter)
|
|
986
|
+
// ---------------------------------------------------------------------------
|
|
987
|
+
|
|
988
|
+
onVideoFrame(cb: FrameCallback) {
|
|
989
|
+
this.#router.onVideoFrame(cb);
|
|
990
|
+
}
|
|
991
|
+
onAudioFrame(cb: FrameCallback) {
|
|
992
|
+
this.#router.onAudioFrame(cb);
|
|
993
|
+
}
|
|
994
|
+
onTrackFrame(packetId: number, cb: FrameCallback) {
|
|
995
|
+
this.#router.onTrackFrame(packetId, cb);
|
|
996
|
+
}
|
|
997
|
+
onTrackPacket(packetId: number, cb: TrackPacketCallback) {
|
|
998
|
+
this.#router.onTrackPacket(packetId, cb);
|
|
999
|
+
}
|
|
1000
|
+
onInitSegment(cb: (data: Uint8Array) => void) {
|
|
1001
|
+
this.#router.onInitSegment(cb);
|
|
1002
|
+
}
|
|
1003
|
+
onTrackInit(packetId: number, cb: (data: Uint8Array) => void) {
|
|
1004
|
+
this.#router.onTrackInit(packetId, cb);
|
|
1005
|
+
}
|
|
1006
|
+
onFecBlockStarted(cb: (sbn: number, packetId: number) => void) {
|
|
1007
|
+
this.#router.onFecBlockStarted(cb);
|
|
1008
|
+
}
|
|
1009
|
+
/** Unrecoverable-FEC-block signal. Players drive decoder recovery from this
|
|
1010
|
+
* (a starved decoder cannot resync on its own once the block is abandoned). */
|
|
1011
|
+
onFecBlockFailed(
|
|
1012
|
+
cb: (sbn: number, packetId: number, catalogTrackName?: string) => void,
|
|
1013
|
+
) {
|
|
1014
|
+
this.#router.onFecBlockFailed(cb);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// ---------------------------------------------------------------------------
|
|
1018
|
+
// MSE integration (delegates to MmtpRouter)
|
|
1019
|
+
// ---------------------------------------------------------------------------
|
|
1020
|
+
|
|
1021
|
+
enableMseAssembler(
|
|
1022
|
+
packetId: number,
|
|
1023
|
+
config: Omit<BlockAssemblerConfig, "k">,
|
|
1024
|
+
catalogTrackName?: string,
|
|
1025
|
+
) {
|
|
1026
|
+
return this.#router.enableMseAssembler(packetId, config, catalogTrackName);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
onMseSegment(packetId: number, cb: (segment: Uint8Array) => void, catalogTrackName?: string) {
|
|
1030
|
+
this.#router.onMseSegment(packetId, cb, catalogTrackName);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
onMseSample(packetId: number, cb: (sample: CmafBlockSample) => void, catalogTrackName?: string) {
|
|
1034
|
+
this.#router.onMseSample(packetId, cb, catalogTrackName);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
onMseInitSegment(packetId: number, cb: (init: Uint8Array) => void, catalogTrackName?: string) {
|
|
1038
|
+
this.#router.onMseInitSegment(packetId, cb, catalogTrackName);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
emitMseInit(packetId: number, catalogTrackName?: string) {
|
|
1042
|
+
this.#router.emitMseInit(packetId, catalogTrackName);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
markExternalVideoSync(packetId?: number, catalogTrackName?: string) {
|
|
1046
|
+
this.#router.markExternalVideoSync(packetId, catalogTrackName);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// ---------------------------------------------------------------------------
|
|
1050
|
+
// Transport (delegates to MulticastTransport)
|
|
1051
|
+
// ---------------------------------------------------------------------------
|
|
1052
|
+
|
|
1053
|
+
onTakeover(cb: () => void) {
|
|
1054
|
+
this.#transport.onTakeover(cb);
|
|
1055
|
+
}
|
|
1056
|
+
onFailback(cb: () => void) {
|
|
1057
|
+
this.#transport.onFailback(cb);
|
|
1058
|
+
}
|
|
1059
|
+
confirmVideo() {
|
|
1060
|
+
this.#transport.confirmVideo();
|
|
1061
|
+
}
|
|
1062
|
+
confirmAudio() {
|
|
1063
|
+
this.#transport.confirmAudio();
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
static isAvailable(): boolean {
|
|
1067
|
+
return MulticastTransport.isAvailable();
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
async join(config: MulticastEndpointConfig): Promise<boolean> {
|
|
1071
|
+
// Configure every FEC/MFU deadline before subscribing so direct-feed and
|
|
1072
|
+
// transport-owned consumers use the same catalog-derived delivery window.
|
|
1073
|
+
this.configureFec(config);
|
|
1074
|
+
|
|
1075
|
+
// Every transport join starts at an arbitrary multicast symbol. Reset only
|
|
1076
|
+
// join-boundary classification; retain configured tracks, decoders, and
|
|
1077
|
+
// cumulative diagnostics across failback/rejoin cycles.
|
|
1078
|
+
this.#fec.beginMulticastJoin();
|
|
1079
|
+
const selectedPacketIds = config.packetIds?.length
|
|
1080
|
+
? new Set(config.packetIds)
|
|
1081
|
+
: null;
|
|
1082
|
+
const catalogTracks = config.tracks?.filter(({ packetId }) =>
|
|
1083
|
+
selectedPacketIds === null || selectedPacketIds.has(packetId));
|
|
1084
|
+
const ingressTracks = catalogTracks
|
|
1085
|
+
? catalogTracks
|
|
1086
|
+
: selectedPacketIds === null
|
|
1087
|
+
? undefined
|
|
1088
|
+
: [...selectedPacketIds].map((packetId) => ({ name: "", packetId }));
|
|
1089
|
+
const ingress = ingressTracks === undefined
|
|
1090
|
+
? undefined
|
|
1091
|
+
: {
|
|
1092
|
+
tracks: Object.freeze(
|
|
1093
|
+
ingressTracks.map(({ name, packetId }) =>
|
|
1094
|
+
Object.freeze({ name, packetId }),
|
|
1095
|
+
),
|
|
1096
|
+
),
|
|
1097
|
+
};
|
|
1098
|
+
const transportConfig = {
|
|
1099
|
+
sourceAddress: config.sourceAddress,
|
|
1100
|
+
groupAddress: config.groupAddress,
|
|
1101
|
+
port: config.port,
|
|
1102
|
+
mode: config.mode,
|
|
1103
|
+
amtRelay: config.amtRelay ?? config.relayAddress,
|
|
1104
|
+
amtRelayPort: config.amtRelayPort ?? config.relayPort,
|
|
1105
|
+
packetIds: config.packetIds,
|
|
1106
|
+
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId })),
|
|
1107
|
+
};
|
|
1108
|
+
return ingress === undefined
|
|
1109
|
+
? this.#transport.join(transportConfig)
|
|
1110
|
+
: this.#transport.join(transportConfig, ingress);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/** Feed a raw packet from an external source (AMT tunnel, ASM subscription).
|
|
1114
|
+
*
|
|
1115
|
+
* For MoQ-unicast-fallback mode (no SSM bridge), call
|
|
1116
|
+
* `manager.router.feedPacket(packet, "moq")` directly to bypass
|
|
1117
|
+
* MulticastTransport's takeover/watchdog/failback gates while preserving
|
|
1118
|
+
* transport attribution in FEC path counters.
|
|
1119
|
+
* The `router` accessor above is already public.
|
|
1120
|
+
*/
|
|
1121
|
+
feedPacket(data: ArrayBuffer | Uint8Array, ingress?: MmtpIngressContext) {
|
|
1122
|
+
this.#transport.feedPacket(data, ingress);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/** Process a repair packet from MoQ (reliable QUIC). */
|
|
1126
|
+
processRepairFromMoQ(
|
|
1127
|
+
packet: Uint8Array,
|
|
1128
|
+
ownerPacketId?: number,
|
|
1129
|
+
catalogTrackName?: string,
|
|
1130
|
+
) {
|
|
1131
|
+
this.#router.feedRepairPacket(packet, ownerPacketId, catalogTrackName);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** Route a Worker-recovered FEC block through the MMTP parser + dedup pipeline. */
|
|
1135
|
+
routeRecoveredBlock(
|
|
1136
|
+
blockId: number,
|
|
1137
|
+
data: Uint8Array,
|
|
1138
|
+
packetId: number,
|
|
1139
|
+
catalogTrackName?: string,
|
|
1140
|
+
) {
|
|
1141
|
+
this.#router.routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/** Route one Worker-recovered source symbol through the MMTP parser + dedup pipeline. */
|
|
1145
|
+
routeRecoveredSymbol(
|
|
1146
|
+
blockId: number,
|
|
1147
|
+
data: Uint8Array,
|
|
1148
|
+
packetId: number,
|
|
1149
|
+
esi = 0,
|
|
1150
|
+
catalogTrackName?: string,
|
|
1151
|
+
) {
|
|
1152
|
+
this.#router.routeRecoveredSymbol(blockId, data, packetId, esi, catalogTrackName);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// ---------------------------------------------------------------------------
|
|
1156
|
+
// Phase 14: multi-track catalog ingest (D-04, D-06, D-07, D-17, D-26, D-28)
|
|
1157
|
+
// ---------------------------------------------------------------------------
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Configure the manager for a multi-track (base/delta/repair) CMAF switching set.
|
|
1161
|
+
*
|
|
1162
|
+
* D-04: Validates completeness via validateSwitchingSet — throws if incomplete.
|
|
1163
|
+
* D-07: Applies per-track FEC configs (base+delta get decoders; repair does not).
|
|
1164
|
+
* D-17: Builds altGroup → track-name index for getSwitchingSet().
|
|
1165
|
+
* D-26: Registers packetId → TrackRole on MmtpRouter for block-complete fanout.
|
|
1166
|
+
*
|
|
1167
|
+
* @param catalog - Multi-track catalog (tracks array with name, altGroup, fec, packetId).
|
|
1168
|
+
* @param wasmDecoderSource - One WASM FEC decoder for a single FEC stream, or
|
|
1169
|
+
* a factory returning a distinct decoder per stream.
|
|
1170
|
+
*/
|
|
1171
|
+
configureMultiTrack(
|
|
1172
|
+
catalog: MultiTrackCatalog,
|
|
1173
|
+
wasmDecoderSource?: WasmFecDecoder | WasmFecDecoderFactory,
|
|
1174
|
+
): void {
|
|
1175
|
+
// D-06: Build the set of repair track names from explicit fec.repairTrack pointers FIRST.
|
|
1176
|
+
// This allows publisher-chosen repair track names (e.g. "video/repair-alt") that
|
|
1177
|
+
// don't match the standard "/repair" suffix convention. The explicit pointer wins
|
|
1178
|
+
// over the naming convention — a track pointed to by repairTrack is always 'repair'.
|
|
1179
|
+
const explicitRepairNamesByGroup = new Map<string, Set<string>>();
|
|
1180
|
+
const trackNamesByGroup = new Map<string, string[]>();
|
|
1181
|
+
for (const track of catalog.tracks) {
|
|
1182
|
+
const groupKey = altGroupKey(track);
|
|
1183
|
+
const groupNames = trackNamesByGroup.get(groupKey) ?? [];
|
|
1184
|
+
groupNames.push(track.name);
|
|
1185
|
+
trackNamesByGroup.set(groupKey, groupNames);
|
|
1186
|
+
|
|
1187
|
+
if (
|
|
1188
|
+
track.fec !== undefined &&
|
|
1189
|
+
isFecCatalogConfig(track.fec) &&
|
|
1190
|
+
track.fec.repairTrack
|
|
1191
|
+
) {
|
|
1192
|
+
const explicitRepairNames =
|
|
1193
|
+
explicitRepairNamesByGroup.get(groupKey) ?? new Set<string>();
|
|
1194
|
+
explicitRepairNames.add(track.fec.repairTrack);
|
|
1195
|
+
explicitRepairNamesByGroup.set(groupKey, explicitRepairNames);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
const hasSwitchingSetByGroup = new Map<string, boolean>();
|
|
1200
|
+
for (const [groupKey, trackNames] of trackNamesByGroup) {
|
|
1201
|
+
hasSwitchingSetByGroup.set(groupKey, hasSwitchingSetRole(trackNames));
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// Resolve role for each track — explicit pointer wins over naming convention.
|
|
1205
|
+
// Normalize non-standard repair names to 'repair' before calling validateSwitchingSet,
|
|
1206
|
+
// which relies on parseTrackRole and would throw on custom repair-track names.
|
|
1207
|
+
const resolvedRoles: TrackRole[] = catalog.tracks.map((track) => {
|
|
1208
|
+
const groupKey = altGroupKey(track);
|
|
1209
|
+
const hasSwitchingSet = hasSwitchingSetByGroup.get(groupKey) ?? false;
|
|
1210
|
+
const explicitRepairNames = explicitRepairNamesByGroup.get(groupKey);
|
|
1211
|
+
if (explicitRepairNames?.has(track.name)) return "repair";
|
|
1212
|
+
if (!hasSwitchingSet) return "single";
|
|
1213
|
+
return parseTrackRole(track.name);
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
// D-04: Validate completeness per altGroup using resolved roles.
|
|
1217
|
+
// We replicate validateSwitchingSet logic here to avoid re-calling parseTrackRole
|
|
1218
|
+
// (which would throw on explicit-pointer repair track names like "video/repair-alt").
|
|
1219
|
+
const resolvedRolesByGroup = new Map<string, TrackRole[]>();
|
|
1220
|
+
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
1221
|
+
const groupKey = altGroupKey(catalog.tracks[i]!);
|
|
1222
|
+
const roles = resolvedRolesByGroup.get(groupKey) ?? [];
|
|
1223
|
+
roles.push(resolvedRoles[i]!);
|
|
1224
|
+
resolvedRolesByGroup.set(groupKey, roles);
|
|
1225
|
+
}
|
|
1226
|
+
for (const [groupKey, roles] of resolvedRolesByGroup) {
|
|
1227
|
+
if (!(hasSwitchingSetByGroup.get(groupKey) ?? false)) continue;
|
|
1228
|
+
|
|
1229
|
+
const presentRoles = new Set(roles.filter((r) => r !== "single"));
|
|
1230
|
+
const required: Array<"base" | "delta" | "repair"> = [
|
|
1231
|
+
"base",
|
|
1232
|
+
"delta",
|
|
1233
|
+
"repair",
|
|
1234
|
+
];
|
|
1235
|
+
const missing = required.filter((r) => !presentRoles.has(r));
|
|
1236
|
+
if (missing.length > 0) {
|
|
1237
|
+
throw new Error(
|
|
1238
|
+
`[MulticastManager] incomplete switching set: missing ${missing.join(", ")}`,
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
const fecTrackIndexes: number[] = [];
|
|
1244
|
+
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
1245
|
+
const track = catalog.tracks[i]!;
|
|
1246
|
+
if (resolvedRoles[i] === "repair" || track.fec === undefined) continue;
|
|
1247
|
+
if (!isFecCatalogConfig(track.fec)) {
|
|
1248
|
+
throw new Error(
|
|
1249
|
+
`[MulticastManager] invalid fec config for track '${track.name}'`,
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
if (track.packetId !== undefined) fecTrackIndexes.push(i);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// Stateful decoders cannot span physical streams: resetting one stream
|
|
1256
|
+
// would otherwise clear or disable every peer sharing that instance.
|
|
1257
|
+
const fecDecoders = new Map<number, WasmFecDecoder>();
|
|
1258
|
+
if (wasmDecoderSource !== undefined && fecTrackIndexes.length > 0) {
|
|
1259
|
+
if (typeof wasmDecoderSource !== "function") {
|
|
1260
|
+
if (fecTrackIndexes.length > 1) {
|
|
1261
|
+
throw new Error(
|
|
1262
|
+
"[MulticastManager] multiple FEC streams require a decoder factory",
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
fecDecoders.set(fecTrackIndexes[0]!, wasmDecoderSource);
|
|
1266
|
+
} else {
|
|
1267
|
+
const clients = new Set<WasmFecDecoder>();
|
|
1268
|
+
for (const index of fecTrackIndexes) {
|
|
1269
|
+
const client = wasmDecoderSource(catalog.tracks[index]!);
|
|
1270
|
+
if (clients.has(client)) {
|
|
1271
|
+
throw new Error(
|
|
1272
|
+
"[MulticastManager] decoder factory must return one client per physical stream",
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
clients.add(client);
|
|
1276
|
+
fecDecoders.set(index, client);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// Reset switching-set index and repair packetId set.
|
|
1282
|
+
this.#switchingSets.clear();
|
|
1283
|
+
this.#repairPacketIds.clear();
|
|
1284
|
+
this.#router.clearRepairPacketIdOwners();
|
|
1285
|
+
const catalogTracksByName = new Map(
|
|
1286
|
+
catalog.tracks.map((track) => [track.name, track] as const),
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1289
|
+
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
1290
|
+
const track = catalog.tracks[i]!;
|
|
1291
|
+
const role = resolvedRoles[i]!;
|
|
1292
|
+
|
|
1293
|
+
// D-17: Build altGroup → track-name index.
|
|
1294
|
+
if (track.altGroup !== undefined) {
|
|
1295
|
+
const existing = this.#switchingSets.get(track.altGroup) ?? [];
|
|
1296
|
+
existing.push(track.name);
|
|
1297
|
+
this.#switchingSets.set(track.altGroup, existing);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// D-26: Register packetId → role on MmtpRouter (if packetId provided at ingest time).
|
|
1301
|
+
if (track.packetId !== undefined) {
|
|
1302
|
+
this.#router.setPacketIdRole(track.packetId, role);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (role === "repair") {
|
|
1306
|
+
// D-06: Repair track is the repair source — no FEC decoder registered on it.
|
|
1307
|
+
if (track.packetId !== undefined) {
|
|
1308
|
+
this.#repairPacketIds.add(track.packetId);
|
|
1309
|
+
}
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
// D-07: Apply per-track FEC config for non-repair tracks.
|
|
1314
|
+
if (track.fec !== undefined) {
|
|
1315
|
+
const fecCfg = track.fec as FecCatalogConfig;
|
|
1316
|
+
const repairTrack = catalogTracksByName.get(fecCfg.repairTrack);
|
|
1317
|
+
if (track.packetId !== undefined && repairTrack?.packetId !== undefined) {
|
|
1318
|
+
this.#router.setRepairPacketIdOwner(repairTrack.packetId, track.packetId);
|
|
1319
|
+
}
|
|
1320
|
+
const wasmDecoder = fecDecoders.get(i);
|
|
1321
|
+
if (track.packetId !== undefined && wasmDecoder !== undefined) {
|
|
1322
|
+
// trackType: base/delta/single video tracks are 'video'; audio would be 'audio'.
|
|
1323
|
+
// At this layer we treat all content tracks as 'video' — audio tracks typically
|
|
1324
|
+
// have no FEC in Phase 14 (D-26 covers video base+delta only). Callers that need
|
|
1325
|
+
// audio FEC can call setFecDecoder() directly after configureMultiTrack().
|
|
1326
|
+
this.#fec.setFecDecoder(
|
|
1327
|
+
track.packetId,
|
|
1328
|
+
wasmDecoder,
|
|
1329
|
+
fecCfg.sourceSymbols,
|
|
1330
|
+
{
|
|
1331
|
+
k: fecCfg.sourceSymbols,
|
|
1332
|
+
symbolSize: fecCfg.symbolSize,
|
|
1333
|
+
interleaveDepthMs: fecCfg.interleaveDepthMs,
|
|
1334
|
+
fps: track.framerate,
|
|
1335
|
+
},
|
|
1336
|
+
track.name,
|
|
1337
|
+
);
|
|
1338
|
+
this.#configureTrackMapper(track.packetId, {
|
|
1339
|
+
k: fecCfg.sourceSymbols,
|
|
1340
|
+
symbolSize: fecCfg.symbolSize,
|
|
1341
|
+
interleaveDepthMs: fecCfg.interleaveDepthMs,
|
|
1342
|
+
fps: track.framerate,
|
|
1343
|
+
});
|
|
1344
|
+
this.#router.setPacketIdType(track.packetId, "video");
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Return the track names belonging to the given altGroup switching set.
|
|
1352
|
+
* D-17: altGroup groups base+delta+repair into one switching set.
|
|
1353
|
+
*
|
|
1354
|
+
* @param altGroup - The altGroup number to look up.
|
|
1355
|
+
* @returns Array of track names in that switching set (empty if none).
|
|
1356
|
+
*/
|
|
1357
|
+
getSwitchingSet(altGroup: number): string[] {
|
|
1358
|
+
return this.#switchingSets.get(altGroup) ?? [];
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Register callback fired when a repair fetch should be issued for an FEC block.
|
|
1363
|
+
*
|
|
1364
|
+
* D-28: At most one outstanding repair fetch per (packetId, sbn) block.
|
|
1365
|
+
* clearRepairForBlock fires automatically when the block resolves (via
|
|
1366
|
+
* FECManager.onRepairResolved); call it manually only on fetch failure
|
|
1367
|
+
* paths the FEC layer cannot observe (fetch error, range not retained,
|
|
1368
|
+
* transport timeout) so a stuck fetch cannot wedge the block's slot.
|
|
1369
|
+
*
|
|
1370
|
+
* Registering also arms the FEC repair deadline: each block gets a one-shot
|
|
1371
|
+
* timer for the derived K-symbol source-production horizon; a block still
|
|
1372
|
+
* short of K when it fires requests repair here. Failure accounting timing
|
|
1373
|
+
* is unchanged.
|
|
1374
|
+
*/
|
|
1375
|
+
onRepairSubscribe(
|
|
1376
|
+
cb: (sbn: number, packetId: number, catalogTrackName?: string) => void,
|
|
1377
|
+
): void {
|
|
1378
|
+
this.#onRepairSubscribeCb = cb;
|
|
1379
|
+
this.#fec.onRepairNeeded = (sbn, packetId, catalogTrackName) => {
|
|
1380
|
+
this.requestRepairForBlock(sbn, packetId, catalogTrackName);
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Observe causal repair lifecycle events without retaining snapshots in the
|
|
1386
|
+
* transport. Returns an unsubscribe function.
|
|
1387
|
+
*/
|
|
1388
|
+
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void {
|
|
1389
|
+
this.#repairLifecycleObservers.add(observer);
|
|
1390
|
+
return () => this.#repairLifecycleObservers.delete(observer);
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/** Observe per-stream epoch resets (used by repair transports to abort I/O). */
|
|
1394
|
+
addTrackResetObserver(
|
|
1395
|
+
observer: (packetId: number, catalogTrackName: string) => void,
|
|
1396
|
+
): () => void {
|
|
1397
|
+
this.#trackResetObservers.add(observer);
|
|
1398
|
+
return () => this.#trackResetObservers.delete(observer);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/** Begin a fresh retained-replay epoch for one physical media stream. */
|
|
1402
|
+
resetTrack(packetId: number, catalogTrackName: string): void {
|
|
1403
|
+
if (!catalogTrackName) {
|
|
1404
|
+
throw new Error('[MulticastManager] catalogTrackName is required for track reset');
|
|
1405
|
+
}
|
|
1406
|
+
for (const observer of this.#trackResetObservers) {
|
|
1407
|
+
try {
|
|
1408
|
+
observer(packetId, catalogTrackName);
|
|
1409
|
+
} catch (error) {
|
|
1410
|
+
console.warn('[MulticastManager] track reset observer failed', error);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
for (const key of this.#repairInFlight) {
|
|
1414
|
+
try {
|
|
1415
|
+
const [keyPacketId, keyTrackName] = JSON.parse(key);
|
|
1416
|
+
if (keyPacketId === packetId && keyTrackName === catalogTrackName) {
|
|
1417
|
+
this.#repairInFlight.delete(key);
|
|
1418
|
+
}
|
|
1419
|
+
} catch {
|
|
1420
|
+
// Internal keys are JSON tuples; preserve unknown legacy entries.
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
this.#fec.resetTrack(packetId, catalogTrackName);
|
|
1424
|
+
this.#router.resetTrack(packetId, catalogTrackName);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
/**
|
|
1428
|
+
* Request a repair-track fetch for the given FEC block.
|
|
1429
|
+
*
|
|
1430
|
+
* D-28: duplicate requests for the same (packetId, sbn) are suppressed
|
|
1431
|
+
* until clearRepairForBlock is called.
|
|
1432
|
+
*
|
|
1433
|
+
* @param sbn - Source Block Number identifying the FEC block needing repair.
|
|
1434
|
+
* @param packetId - MMTP packet_id owning the block (video/audio tracks have
|
|
1435
|
+
* independent SBN spaces, so the in-flight key must be composite).
|
|
1436
|
+
*/
|
|
1437
|
+
requestRepairForBlock(
|
|
1438
|
+
sbn: number,
|
|
1439
|
+
packetId: number,
|
|
1440
|
+
catalogTrackName?: string,
|
|
1441
|
+
): void {
|
|
1442
|
+
// D-28: at most one outstanding fetch per FEC block (per packetId:sbn).
|
|
1443
|
+
// Different blocks are independent and are NOT blocked by each other.
|
|
1444
|
+
const block = repairBlockIdentity(packetId, sbn, catalogTrackName);
|
|
1445
|
+
const key = JSON.stringify([packetId, block.catalogTrackName, sbn]);
|
|
1446
|
+
if (this.#repairInFlight.has(key)) return;
|
|
1447
|
+
this.#repairInFlight.add(key);
|
|
1448
|
+
this.#emitRepairLifecycle({
|
|
1449
|
+
version: 1,
|
|
1450
|
+
type: "requested",
|
|
1451
|
+
block,
|
|
1452
|
+
});
|
|
1453
|
+
if (catalogTrackName === undefined) {
|
|
1454
|
+
this.#onRepairSubscribeCb?.(sbn, packetId);
|
|
1455
|
+
} else {
|
|
1456
|
+
this.#onRepairSubscribeCb?.(sbn, packetId, catalogTrackName);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Clear in-flight repair state for the given block.
|
|
1462
|
+
* Fired automatically when the block resolves; safe to call redundantly.
|
|
1463
|
+
*/
|
|
1464
|
+
clearRepairForBlock(
|
|
1465
|
+
sbn: number,
|
|
1466
|
+
packetId: number,
|
|
1467
|
+
catalogTrackName?: string,
|
|
1468
|
+
): void {
|
|
1469
|
+
this.#repairInFlight.delete(
|
|
1470
|
+
JSON.stringify([packetId, catalogTrackName ?? null, sbn]),
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
#emitRepairLifecycle(event: RepairLifecycleEvent): void {
|
|
1475
|
+
const immutableEvent = Object.freeze({
|
|
1476
|
+
...event,
|
|
1477
|
+
block: Object.freeze({...event.block}),
|
|
1478
|
+
...(event.type === "requested"
|
|
1479
|
+
? {}
|
|
1480
|
+
: {symbols: Object.freeze({...event.symbols})}),
|
|
1481
|
+
}) as RepairLifecycleEvent;
|
|
1482
|
+
// Serialize before invoking observers so a re-entrant observer cannot log
|
|
1483
|
+
// a resolution before the request that caused it.
|
|
1484
|
+
console.info(
|
|
1485
|
+
`${REPAIR_LIFECYCLE_LOG_PREFIX}${JSON.stringify(immutableEvent)}`,
|
|
1486
|
+
);
|
|
1487
|
+
for (const observer of this.#repairLifecycleObservers) {
|
|
1488
|
+
try {
|
|
1489
|
+
observer(immutableEvent);
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
console.warn("[MulticastManager] repair lifecycle observer failed", error);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
dispose() {
|
|
1497
|
+
this.#trackResetObservers.clear();
|
|
1498
|
+
this.#repairLifecycleObservers.clear();
|
|
1499
|
+
this.#transport.dispose();
|
|
1500
|
+
this.#router.dispose();
|
|
1501
|
+
this.#fec.dispose();
|
|
1502
|
+
}
|
|
1503
|
+
}
|