@blockcast/mmt-container 0.4.0 → 0.4.1-main.cbe342dbdd9c
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 +36 -20
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +1839 -692
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +8 -0
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +98 -234
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +121 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +421 -66
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +331 -1171
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1137 -317
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +159 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +531 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +39 -6
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +184 -27
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +347 -132
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +94 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +877 -357
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +108 -238
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +1086 -301
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/source-auth.js +2710 -7
- package/dist/source-auth.js.map +4 -4
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -9
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +17 -0
- package/src/fec-manager.ts +452 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/index.ts +27 -10
- package/src/iso-block-locator.ts +110 -7
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +166 -7
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +267 -21
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +7 -1
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/src/fec-codec.ts +0 -61
package/dist/browser-runtime.js
CHANGED
|
@@ -655,26 +655,30 @@ function isEmptyOrExactLegacyTrailer(payload, start, end) {
|
|
|
655
655
|
const authLength = view2.getUint16(2, false);
|
|
656
656
|
return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end;
|
|
657
657
|
}
|
|
658
|
-
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options) {
|
|
658
|
+
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options, rapFlag = false) {
|
|
659
659
|
if (declaredEnd > payload.length)
|
|
660
660
|
return null;
|
|
661
661
|
if (options?.skipFecId) {
|
|
662
|
-
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false } : null;
|
|
662
|
+
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false, hasOverlayFecId: false } : null;
|
|
663
663
|
}
|
|
664
|
+
const overlay = options?.overlayDeclared === true && rapFlag;
|
|
664
665
|
if (fecType === 1) {
|
|
665
|
-
const fecStart = payload.length -
|
|
666
|
+
const fecStart = payload.length - sourceFecTrailerSize(overlay);
|
|
666
667
|
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
667
668
|
return null;
|
|
668
669
|
}
|
|
669
|
-
return { hasFecId: true };
|
|
670
|
+
return { hasFecId: true, hasOverlayFecId: overlay };
|
|
670
671
|
}
|
|
671
|
-
if (fecType !== 0)
|
|
672
|
+
if (fecType !== 0 || overlay)
|
|
672
673
|
return null;
|
|
673
674
|
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
674
|
-
return { hasFecId: false };
|
|
675
|
+
return { hasFecId: false, hasOverlayFecId: false };
|
|
675
676
|
}
|
|
676
677
|
return null;
|
|
677
678
|
}
|
|
679
|
+
function sourceFecTrailerSize(overlay) {
|
|
680
|
+
return overlay ? 2 * SOURCE_FEC_PAYLOAD_ID_SIZE : SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
681
|
+
}
|
|
678
682
|
function extractNALUnit(mmtpPacket) {
|
|
679
683
|
const extraction = extractMFUPayload(mmtpPacket);
|
|
680
684
|
if (!extraction)
|
|
@@ -733,15 +737,16 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
733
737
|
if ("rejection" in layoutResult)
|
|
734
738
|
return layoutResult;
|
|
735
739
|
const { layout } = layoutResult;
|
|
736
|
-
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options);
|
|
740
|
+
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options, header.rapFlag);
|
|
737
741
|
if (!trailerLayout) {
|
|
738
742
|
if (!options?.skipFecId && header.fecType === 1) {
|
|
739
743
|
const observed = payload.length - layout.dataEnd;
|
|
740
|
-
|
|
744
|
+
const expected = sourceFecTrailerSize(options?.overlayDeclared === true && header.rapFlag);
|
|
745
|
+
if (observed !== expected) {
|
|
741
746
|
return {
|
|
742
747
|
rejection: {
|
|
743
748
|
gate: "source-fec-payload-id-width-mismatch",
|
|
744
|
-
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${
|
|
749
|
+
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${expected} (payload=${payload.length}, declaredEnd=${layout.dataEnd})`
|
|
745
750
|
}
|
|
746
751
|
};
|
|
747
752
|
}
|
|
@@ -771,10 +776,13 @@ function extractPlannedMfu(mmtpPacket, result) {
|
|
|
771
776
|
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE) : null;
|
|
772
777
|
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false) : null;
|
|
773
778
|
const data = payload.subarray(mfuOffset, dataEnd);
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
779
|
+
const trailerStart = mmtpPacket.length - sourceFecTrailerSize(trailerLayout.hasOverlayFecId);
|
|
780
|
+
const ssIdAt = (offset) => ({
|
|
781
|
+
ssId: new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + offset, 4).getUint32(0, false)
|
|
782
|
+
});
|
|
783
|
+
const fecPayloadId = trailerLayout.hasFecId ? ssIdAt(trailerStart) : null;
|
|
784
|
+
const overlayFecPayloadId = trailerLayout.hasOverlayFecId ? ssIdAt(trailerStart + SOURCE_FEC_PAYLOAD_ID_SIZE) : null;
|
|
785
|
+
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId, overlayFecPayloadId };
|
|
778
786
|
}
|
|
779
787
|
function extractTimestamp(mmtpPacket) {
|
|
780
788
|
const { header } = unwrapMMTP(mmtpPacket);
|
|
@@ -999,19 +1007,275 @@ function catalogFecAvailable(fec) {
|
|
|
999
1007
|
const block = recordOf(fec);
|
|
1000
1008
|
if (block === void 0)
|
|
1001
1009
|
return true;
|
|
1010
|
+
if (fecAlgorithmUnimplemented(block["algorithm"]))
|
|
1011
|
+
return false;
|
|
1002
1012
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
1003
1013
|
const profile = block["blockProfile"];
|
|
1004
1014
|
const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
|
|
1005
1015
|
return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
|
|
1006
1016
|
}
|
|
1017
|
+
function fecAlgorithmUnimplemented(algorithm) {
|
|
1018
|
+
return typeof algorithm === "string" && algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon";
|
|
1019
|
+
}
|
|
1007
1020
|
function isPositiveSafeInteger(value) {
|
|
1008
1021
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1009
1022
|
}
|
|
1023
|
+
var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
|
|
1010
1024
|
function catalogFecDeclaresUnconfigurableInstance(fec) {
|
|
1011
1025
|
const block = recordOf(fec);
|
|
1012
|
-
if (block === void 0 || block["algorithm"] === "none")
|
|
1026
|
+
if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"]))
|
|
1013
1027
|
return false;
|
|
1014
|
-
|
|
1028
|
+
if (!(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"])))
|
|
1029
|
+
return true;
|
|
1030
|
+
return block["blockProfile"] === "iso-ssbg1-v1" && block["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// ../mmt-base/dist/multicast-catalog.js
|
|
1034
|
+
var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
1035
|
+
var UINT32_MAX = 4294967295;
|
|
1036
|
+
var AUTH_MEMBERS = /* @__PURE__ */ new Set(["scheme", "version", "sig", "keys", "minEpoch"]);
|
|
1037
|
+
var KEY_MEMBERS = /* @__PURE__ */ new Set(["kid", "publicKey", "firstEpoch"]);
|
|
1038
|
+
var ENDPOINT_AUTH_MEMBERS = /* @__PURE__ */ new Set([
|
|
1039
|
+
"manifestPort",
|
|
1040
|
+
"streamId",
|
|
1041
|
+
"senderAddress",
|
|
1042
|
+
"maxAuthDelayMs",
|
|
1043
|
+
"manifestTimerMs",
|
|
1044
|
+
"manifestTrack"
|
|
1045
|
+
]);
|
|
1046
|
+
function isObject(value) {
|
|
1047
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1048
|
+
}
|
|
1049
|
+
function isNonEmptyString(value) {
|
|
1050
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
1051
|
+
}
|
|
1052
|
+
function isIntegerIn(value, min, max) {
|
|
1053
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
1054
|
+
}
|
|
1055
|
+
function multicastEndpointSource(endpoint) {
|
|
1056
|
+
if (!isObject(endpoint))
|
|
1057
|
+
return void 0;
|
|
1058
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
1059
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress))
|
|
1060
|
+
return void 0;
|
|
1061
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
1062
|
+
const protocol = endpoint["protocol"];
|
|
1063
|
+
if (protocol !== void 0 && protocol !== mode)
|
|
1064
|
+
return void 0;
|
|
1065
|
+
const auth = endpoint["auth"];
|
|
1066
|
+
const senderAddress = isObject(auth) ? auth["senderAddress"] : void 0;
|
|
1067
|
+
if (mode === "ssm")
|
|
1068
|
+
return senderAddress === void 0 ? { mode, source: sourceAddress } : void 0;
|
|
1069
|
+
if (auth === void 0)
|
|
1070
|
+
return { mode };
|
|
1071
|
+
return isNonEmptyString(senderAddress) ? { mode, source: senderAddress } : void 0;
|
|
1072
|
+
}
|
|
1073
|
+
function authIssues(auth) {
|
|
1074
|
+
const base = "$.multicast.auth";
|
|
1075
|
+
const issue = (path, message) => [
|
|
1076
|
+
{ code: "multicast_auth", path: `${base}${path}`, message }
|
|
1077
|
+
];
|
|
1078
|
+
if (!isObject(auth))
|
|
1079
|
+
return issue("", "auth must be an object");
|
|
1080
|
+
const unknown = Object.keys(auth).filter((key) => !AUTH_MEMBERS.has(key));
|
|
1081
|
+
if (unknown.length > 0) {
|
|
1082
|
+
return issue("", `auth has unknown member(s) ${unknown.join(", ")}; draft -01 7.2.6 defines scheme, version, sig, keys and minEpoch`);
|
|
1083
|
+
}
|
|
1084
|
+
if (auth["scheme"] !== "bc-provenance")
|
|
1085
|
+
return issue(".scheme", 'scheme must be "bc-provenance"');
|
|
1086
|
+
if (auth["version"] !== 2)
|
|
1087
|
+
return issue(".version", "version must be 2 (bc-provenance version 2, draft -01 7.2)");
|
|
1088
|
+
if (auth["sig"] !== "ed25519")
|
|
1089
|
+
return issue(".sig", 'sig must be "ed25519"');
|
|
1090
|
+
const keys = auth["keys"];
|
|
1091
|
+
if (!Array.isArray(keys) || keys.length < 1 || keys.length > 4) {
|
|
1092
|
+
return issue(".keys", "keys must be an array of one to four {kid, publicKey, firstEpoch} objects");
|
|
1093
|
+
}
|
|
1094
|
+
const kids = /* @__PURE__ */ new Set();
|
|
1095
|
+
const firstEpochs = /* @__PURE__ */ new Set();
|
|
1096
|
+
for (let index = 0; index < keys.length; index++) {
|
|
1097
|
+
const key = keys[index];
|
|
1098
|
+
const at = `.keys[${index}]`;
|
|
1099
|
+
if (!isObject(key) || Object.keys(key).some((member) => !KEY_MEMBERS.has(member))) {
|
|
1100
|
+
return issue(at, "a key is exactly {kid, publicKey, firstEpoch}");
|
|
1101
|
+
}
|
|
1102
|
+
if (!isIntegerIn(key["kid"], 0, UINT32_MAX))
|
|
1103
|
+
return issue(`${at}.kid`, "kid must be an unsigned 32-bit integer");
|
|
1104
|
+
if (typeof key["publicKey"] !== "string" || !ED25519_PUBLIC_KEY_BASE64URL.test(key["publicKey"])) {
|
|
1105
|
+
return issue(`${at}.publicKey`, "publicKey must be a 32-octet Ed25519 key in canonical unpadded base64url");
|
|
1106
|
+
}
|
|
1107
|
+
if (!isIntegerIn(key["firstEpoch"], 0, UINT32_MAX)) {
|
|
1108
|
+
return issue(`${at}.firstEpoch`, "firstEpoch must be an unsigned 32-bit integer");
|
|
1109
|
+
}
|
|
1110
|
+
if (kids.has(key["kid"]))
|
|
1111
|
+
return issue(`${at}.kid`, `kid ${key["kid"]} is repeated; the catalog holds no key set`);
|
|
1112
|
+
if (firstEpochs.has(key["firstEpoch"])) {
|
|
1113
|
+
return issue(`${at}.firstEpoch`, `firstEpoch ${key["firstEpoch"]} is repeated; the catalog holds no key set`);
|
|
1114
|
+
}
|
|
1115
|
+
kids.add(key["kid"]);
|
|
1116
|
+
firstEpochs.add(key["firstEpoch"]);
|
|
1117
|
+
}
|
|
1118
|
+
if (!isIntegerIn(auth["minEpoch"], 0, UINT32_MAX)) {
|
|
1119
|
+
return issue(".minEpoch", "minEpoch must be an unsigned 32-bit integer");
|
|
1120
|
+
}
|
|
1121
|
+
return [];
|
|
1122
|
+
}
|
|
1123
|
+
function endpointAuthIssue(endpoint, mode, at) {
|
|
1124
|
+
const auth = endpoint["auth"];
|
|
1125
|
+
if (!isObject(auth))
|
|
1126
|
+
return { path: `${at}.auth`, message: "auth must be an object" };
|
|
1127
|
+
const unknown = Object.keys(auth).filter((key) => !ENDPOINT_AUTH_MEMBERS.has(key));
|
|
1128
|
+
if (unknown.length > 0)
|
|
1129
|
+
return { path: `${at}.auth`, message: `auth has unknown member(s) ${unknown.join(", ")}` };
|
|
1130
|
+
if (!isIntegerIn(auth["manifestPort"], 1, 65535)) {
|
|
1131
|
+
return { path: `${at}.auth.manifestPort`, message: "manifestPort must be an integer from 1 to 65535" };
|
|
1132
|
+
}
|
|
1133
|
+
if (!isIntegerIn(auth["streamId"], 0, UINT32_MAX)) {
|
|
1134
|
+
return { path: `${at}.auth.streamId`, message: "streamId must be an unsigned 32-bit integer" };
|
|
1135
|
+
}
|
|
1136
|
+
if (mode === "ssm" && auth["senderAddress"] !== void 0) {
|
|
1137
|
+
return { path: `${at}.auth.senderAddress`, message: "senderAddress must not appear on an SSM endpoint; S is sourceAddress" };
|
|
1138
|
+
}
|
|
1139
|
+
if (mode === "asm" && !isNonEmptyString(auth["senderAddress"])) {
|
|
1140
|
+
return { path: `${at}.auth.senderAddress`, message: "a protected ASM endpoint requires senderAddress" };
|
|
1141
|
+
}
|
|
1142
|
+
if (auth["maxAuthDelayMs"] !== void 0 && !isIntegerIn(auth["maxAuthDelayMs"], 50, 1e3)) {
|
|
1143
|
+
return { path: `${at}.auth.maxAuthDelayMs`, message: "maxAuthDelayMs must be an integer from 50 to 1000" };
|
|
1144
|
+
}
|
|
1145
|
+
if (auth["manifestTimerMs"] !== void 0 && !isIntegerIn(auth["manifestTimerMs"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
1146
|
+
return { path: `${at}.auth.manifestTimerMs`, message: "manifestTimerMs must be an integer of at least 1" };
|
|
1147
|
+
}
|
|
1148
|
+
if (auth["manifestTrack"] !== void 0 && !isNonEmptyString(auth["manifestTrack"])) {
|
|
1149
|
+
return { path: `${at}.auth.manifestTrack`, message: "manifestTrack must be a non-empty string" };
|
|
1150
|
+
}
|
|
1151
|
+
if (!isIntegerIn(endpoint["bandwidth"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
1152
|
+
return { path: `${at}.bandwidth`, message: "a protected endpoint requires bandwidth, which bounds the receiver's hold queues" };
|
|
1153
|
+
}
|
|
1154
|
+
return void 0;
|
|
1155
|
+
}
|
|
1156
|
+
var CATALOG_NAMESPACE = /* @__PURE__ */ Symbol.for("@blockcast/mmt-base/catalogNamespace");
|
|
1157
|
+
function multicastCatalogIssues(catalog, options = {}) {
|
|
1158
|
+
if (!isObject(catalog))
|
|
1159
|
+
return [];
|
|
1160
|
+
const issues = [];
|
|
1161
|
+
if ("multicast.auth" in catalog) {
|
|
1162
|
+
issues.push({
|
|
1163
|
+
code: "multicast_auth",
|
|
1164
|
+
path: '$["multicast.auth"]',
|
|
1165
|
+
message: 'the root "multicast.auth" key is retired; declare auth as multicast.auth (draft -01 7.2.6)'
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
const multicast = catalog["multicast"];
|
|
1169
|
+
if (!isObject(multicast))
|
|
1170
|
+
return issues;
|
|
1171
|
+
const protectedCatalog = multicast["auth"] !== void 0;
|
|
1172
|
+
if (protectedCatalog)
|
|
1173
|
+
issues.push(...authIssues(multicast["auth"]));
|
|
1174
|
+
const endpoints = multicast["endpoints"];
|
|
1175
|
+
if (!Array.isArray(endpoints))
|
|
1176
|
+
return issues;
|
|
1177
|
+
const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
|
|
1178
|
+
const namespaceOf = /* @__PURE__ */ new Map();
|
|
1179
|
+
for (const track of tracks) {
|
|
1180
|
+
if (isObject(track) && typeof track["name"] === "string")
|
|
1181
|
+
namespaceOf.set(track["name"], track["namespace"]);
|
|
1182
|
+
}
|
|
1183
|
+
const tagged = catalog[CATALOG_NAMESPACE];
|
|
1184
|
+
let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : void 0);
|
|
1185
|
+
const sources = [];
|
|
1186
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
1187
|
+
const endpoint = endpoints[index];
|
|
1188
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
1189
|
+
const fail = (code, path, message) => {
|
|
1190
|
+
issues.push({ code, path, message, endpointIndex: index });
|
|
1191
|
+
};
|
|
1192
|
+
sources.push(void 0);
|
|
1193
|
+
if (!isObject(endpoint)) {
|
|
1194
|
+
fail("multicast_endpoint", at, "endpoint must be an object");
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
const protocol = endpoint["protocol"];
|
|
1198
|
+
if (protocol !== void 0 && protocol !== "ssm" && protocol !== "asm") {
|
|
1199
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol must be "ssm" or "asm"; a bearer such as ${JSON.stringify(protocol)} is a networkSource entry (draft -01 4.2)`);
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
const hasAuth = endpoint["auth"] !== void 0;
|
|
1203
|
+
if (protectedCatalog !== hasAuth) {
|
|
1204
|
+
fail("multicast_endpoint_auth", `${at}.auth`, protectedCatalog ? "every endpoint requires auth when multicast carries auth; a receiver ignores this endpoint" : "auth names no key without multicast.auth; a receiver ignores this endpoint");
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
1208
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress)) {
|
|
1209
|
+
fail("multicast_endpoint", `${at}.sourceAddress`, "sourceAddress must be a non-empty string");
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
1213
|
+
if (protocol !== void 0 && protocol !== mode) {
|
|
1214
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol ${JSON.stringify(protocol)} disagrees with sourceAddress, which selects ${mode}`);
|
|
1215
|
+
continue;
|
|
1216
|
+
}
|
|
1217
|
+
if (!isIntegerIn(endpoint["port"], 1, 65535)) {
|
|
1218
|
+
fail("multicast_endpoint", `${at}.port`, "port must be an integer from 1 to 65535");
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
if (hasAuth) {
|
|
1222
|
+
const authIssue = endpointAuthIssue(endpoint, mode, at);
|
|
1223
|
+
if (authIssue) {
|
|
1224
|
+
fail("multicast_endpoint_auth", authIssue.path, authIssue.message);
|
|
1225
|
+
continue;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
sources[index] = multicastEndpointSource(endpoint);
|
|
1229
|
+
const refs = Array.isArray(endpoint["tracks"]) ? endpoint["tracks"] : [];
|
|
1230
|
+
for (let refIndex = 0; refIndex < refs.length; refIndex++) {
|
|
1231
|
+
const ref = refs[refIndex];
|
|
1232
|
+
const name = isObject(ref) ? ref["name"] : ref;
|
|
1233
|
+
if (typeof name !== "string")
|
|
1234
|
+
continue;
|
|
1235
|
+
const namespace = namespaceOf.get(name);
|
|
1236
|
+
if (typeof namespace !== "string")
|
|
1237
|
+
continue;
|
|
1238
|
+
referenceNamespace ??= namespace;
|
|
1239
|
+
if (namespace !== referenceNamespace) {
|
|
1240
|
+
fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} declares namespace ${JSON.stringify(namespace)}, not the catalog track's ${JSON.stringify(referenceNamespace)}`);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
const tupleOf = (index) => {
|
|
1245
|
+
const endpoint = endpoints[index];
|
|
1246
|
+
const auth = endpoint["auth"];
|
|
1247
|
+
return {
|
|
1248
|
+
sg: JSON.stringify([sources[index].source ?? null, endpoint["groupAddress"]]),
|
|
1249
|
+
port: endpoint["port"],
|
|
1250
|
+
manifestPort: isObject(auth) ? auth["manifestPort"] : void 0
|
|
1251
|
+
};
|
|
1252
|
+
};
|
|
1253
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
1254
|
+
if (!sources[index])
|
|
1255
|
+
continue;
|
|
1256
|
+
const own = tupleOf(index);
|
|
1257
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
1258
|
+
if (own.manifestPort !== void 0 && own.manifestPort === own.port) {
|
|
1259
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: "manifestPort must differ from the endpoint's own port", endpointIndex: index });
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
for (let other = 0; other < endpoints.length; other++) {
|
|
1263
|
+
if (other === index || !sources[other])
|
|
1264
|
+
continue;
|
|
1265
|
+
const peer = tupleOf(other);
|
|
1266
|
+
if (peer.sg !== own.sg)
|
|
1267
|
+
continue;
|
|
1268
|
+
if (peer.port === own.port) {
|
|
1269
|
+
issues.push({ code: "multicast_endpoint", path: `${at}.port`, message: `(S, G, port) is shared with endpoint ${other}; one endpoint object per multicast tuple`, endpointIndex: index });
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
if (own.manifestPort !== void 0 && (own.manifestPort === peer.port || own.manifestPort === peer.manifestPort)) {
|
|
1273
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: `manifestPort is a port or manifestPort of endpoint ${other} on the same (S, G)`, endpointIndex: index });
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return issues;
|
|
1015
1279
|
}
|
|
1016
1280
|
|
|
1017
1281
|
// src/mfu-reassembler.ts
|
|
@@ -3886,8 +4150,14 @@ var SampleCombiner = class {
|
|
|
3886
4150
|
/**
|
|
3887
4151
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
3888
4152
|
* constituent data unit has arrived and totals the authored size.
|
|
4153
|
+
*
|
|
4154
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
4155
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
4156
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
4157
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
4158
|
+
* fragments, or one decoded before its source copy arrived.
|
|
3889
4159
|
*/
|
|
3890
|
-
addMfu(mfu) {
|
|
4160
|
+
addMfu(mfu, sampleSize) {
|
|
3891
4161
|
if (mfu.movieFragmentSequenceNumber === void 0 || mfu.sampleNumber === void 0) {
|
|
3892
4162
|
this.#stats.passthroughSamples++;
|
|
3893
4163
|
return fromPassthrough(mfu);
|
|
@@ -3903,7 +4173,7 @@ var SampleCombiner = class {
|
|
|
3903
4173
|
return null;
|
|
3904
4174
|
}
|
|
3905
4175
|
const dataLen = mfu.data.byteLength;
|
|
3906
|
-
const authoredSize = this.#authoredSizes.get(key);
|
|
4176
|
+
const authoredSize = this.#authoredSizes.get(key) ?? sampleSize;
|
|
3907
4177
|
if (offset === 0 && !this.#pending.has(key)) {
|
|
3908
4178
|
const passesThrough = authoredSize === void 0 ? !this.#requireAuthoredSize : dataLen === authoredSize;
|
|
3909
4179
|
if (passesThrough) {
|
|
@@ -4197,6 +4467,12 @@ if (void 0) {
|
|
|
4197
4467
|
const out = c.addMfu(mfu(1, 9, 17, 5, [6, 7, 8, 9, 10], 1001n, false));
|
|
4198
4468
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
4199
4469
|
});
|
|
4470
|
+
test("a size handed with the data unit completes a sample no head registered", () => {
|
|
4471
|
+
const c = combiner({ requireAuthoredSize: true });
|
|
4472
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5);
|
|
4473
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
|
|
4474
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull();
|
|
4475
|
+
});
|
|
4200
4476
|
test("duplicate offset is rejected", () => {
|
|
4201
4477
|
const c = combiner();
|
|
4202
4478
|
c.registerAuthoredSize(void 0, 1, 9, 17, 10);
|
|
@@ -6003,197 +6279,6 @@ if (void 0) {
|
|
|
6003
6279
|
});
|
|
6004
6280
|
}
|
|
6005
6281
|
|
|
6006
|
-
// src/multicast-auth-catalog.ts
|
|
6007
|
-
var RAW_ED25519_KEY_LENGTH = 32;
|
|
6008
|
-
var SOURCE_AUTH_SCOPE_LENGTH = 32;
|
|
6009
|
-
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
6010
|
-
function encodeBase64Url(bytes) {
|
|
6011
|
-
let output = "";
|
|
6012
|
-
for (let i = 0; i < bytes.length; i += 3) {
|
|
6013
|
-
const b0 = bytes[i];
|
|
6014
|
-
const b1 = bytes[i + 1];
|
|
6015
|
-
const b2 = bytes[i + 2];
|
|
6016
|
-
output += BASE64URL_ALPHABET[b0 >> 2];
|
|
6017
|
-
output += BASE64URL_ALPHABET[(b0 & 3) << 4 | (b1 === void 0 ? 0 : b1 >> 4)];
|
|
6018
|
-
if (b1 === void 0) break;
|
|
6019
|
-
output += BASE64URL_ALPHABET[(b1 & 15) << 2 | (b2 === void 0 ? 0 : b2 >> 6)];
|
|
6020
|
-
if (b2 === void 0) break;
|
|
6021
|
-
output += BASE64URL_ALPHABET[b2 & 63];
|
|
6022
|
-
}
|
|
6023
|
-
return output;
|
|
6024
|
-
}
|
|
6025
|
-
var BASE64URL_DECODE_TABLE = (() => {
|
|
6026
|
-
const table = new Int8Array(128).fill(-1);
|
|
6027
|
-
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
6028
|
-
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
6029
|
-
}
|
|
6030
|
-
return table;
|
|
6031
|
-
})();
|
|
6032
|
-
function decodeBase64Url(text) {
|
|
6033
|
-
if (text.length % 4 === 1) {
|
|
6034
|
-
throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text}"`);
|
|
6035
|
-
}
|
|
6036
|
-
const bytes = [];
|
|
6037
|
-
let buffer = 0;
|
|
6038
|
-
let bits = 0;
|
|
6039
|
-
for (let i = 0; i < text.length; i++) {
|
|
6040
|
-
const code = text.charCodeAt(i);
|
|
6041
|
-
const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
|
|
6042
|
-
if (value === void 0 || value < 0) {
|
|
6043
|
-
throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text}"`);
|
|
6044
|
-
}
|
|
6045
|
-
buffer = buffer << 6 | value;
|
|
6046
|
-
bits += 6;
|
|
6047
|
-
if (bits >= 8) {
|
|
6048
|
-
bits -= 8;
|
|
6049
|
-
bytes.push(buffer >> bits & 255);
|
|
6050
|
-
}
|
|
6051
|
-
}
|
|
6052
|
-
const decoded = Uint8Array.from(bytes);
|
|
6053
|
-
if (encodeBase64Url(decoded) !== text) {
|
|
6054
|
-
throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text}"`);
|
|
6055
|
-
}
|
|
6056
|
-
return decoded;
|
|
6057
|
-
}
|
|
6058
|
-
function decodeAuthScope(authScope) {
|
|
6059
|
-
const bytes = decodeBase64Url(authScope);
|
|
6060
|
-
if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
|
|
6061
|
-
throw new Error(
|
|
6062
|
-
`[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
6063
|
-
);
|
|
6064
|
-
}
|
|
6065
|
-
return bytes;
|
|
6066
|
-
}
|
|
6067
|
-
function decodeEd25519PublicKey(publicKey) {
|
|
6068
|
-
const bytes = decodeBase64Url(publicKey);
|
|
6069
|
-
if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
|
|
6070
|
-
throw new Error(
|
|
6071
|
-
`[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
6072
|
-
);
|
|
6073
|
-
}
|
|
6074
|
-
return bytes;
|
|
6075
|
-
}
|
|
6076
|
-
function isNonEmptyString(value) {
|
|
6077
|
-
return typeof value === "string" && value.length > 0;
|
|
6078
|
-
}
|
|
6079
|
-
function isValidAuthScopeField(value) {
|
|
6080
|
-
if (!isNonEmptyString(value)) return false;
|
|
6081
|
-
try {
|
|
6082
|
-
decodeAuthScope(value);
|
|
6083
|
-
return true;
|
|
6084
|
-
} catch {
|
|
6085
|
-
return false;
|
|
6086
|
-
}
|
|
6087
|
-
}
|
|
6088
|
-
function isValidPublicKeyField(value) {
|
|
6089
|
-
if (!isNonEmptyString(value)) return false;
|
|
6090
|
-
try {
|
|
6091
|
-
decodeEd25519PublicKey(value);
|
|
6092
|
-
return true;
|
|
6093
|
-
} catch {
|
|
6094
|
-
return false;
|
|
6095
|
-
}
|
|
6096
|
-
}
|
|
6097
|
-
function hasOnlyKeys(object2, allowed) {
|
|
6098
|
-
const allowedKeys = new Set(allowed);
|
|
6099
|
-
return Object.keys(object2).every((key) => allowedKeys.has(key));
|
|
6100
|
-
}
|
|
6101
|
-
function isMulticastAuthTrackConfig(obj) {
|
|
6102
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
6103
|
-
const o = obj;
|
|
6104
|
-
return hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) && isNonEmptyString(o["mediaTrack"]) && isNonEmptyString(o["manifestTrack"]) && o["mediaTrack"] !== o["manifestTrack"] && isValidAuthScopeField(o["authScope"]) && isNonEmptyString(o["sourceSymbolFormat"]);
|
|
6105
|
-
}
|
|
6106
|
-
var VALID_COMPACTION = /* @__PURE__ */ new Set(["merkle", "none"]);
|
|
6107
|
-
var VALID_ENFORCEMENT = /* @__PURE__ */ new Set(["shadow", "enforce"]);
|
|
6108
|
-
function hasUniqueMulticastAuthTrackBindings(tracks) {
|
|
6109
|
-
const bindings = tracks.flatMap((track) => {
|
|
6110
|
-
if (typeof track !== "object" || track === null) return [];
|
|
6111
|
-
const value = track;
|
|
6112
|
-
if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
|
|
6113
|
-
return [];
|
|
6114
|
-
}
|
|
6115
|
-
return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
|
|
6116
|
-
});
|
|
6117
|
-
return new Set(bindings).size === bindings.length;
|
|
6118
|
-
}
|
|
6119
|
-
function isMulticastAuthConfig(obj) {
|
|
6120
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
6121
|
-
const o = obj;
|
|
6122
|
-
if (o["scheme"] !== "bc-provenance") return false;
|
|
6123
|
-
if (o["hash"] !== "blake3") return false;
|
|
6124
|
-
if (o["sig"] !== "ed25519") return false;
|
|
6125
|
-
if (!hasOnlyKeys(o, ["scheme", "hash", "sig", "publicKey", "keyId", "previousKey", "compaction", "enforcement", "tracks"])) return false;
|
|
6126
|
-
if (!isValidPublicKeyField(o["publicKey"])) return false;
|
|
6127
|
-
if (!isNonEmptyString(o["keyId"])) return false;
|
|
6128
|
-
if (o["previousKey"] !== void 0 && !isValidPublicKeyField(o["previousKey"])) return false;
|
|
6129
|
-
if (o["previousKey"] === o["publicKey"]) return false;
|
|
6130
|
-
if (typeof o["compaction"] !== "string" || !VALID_COMPACTION.has(o["compaction"])) return false;
|
|
6131
|
-
if (o["enforcement"] !== void 0) {
|
|
6132
|
-
if (typeof o["enforcement"] !== "string" || !VALID_ENFORCEMENT.has(o["enforcement"])) return false;
|
|
6133
|
-
}
|
|
6134
|
-
if (!Array.isArray(o["tracks"]) || o["tracks"].length === 0) return false;
|
|
6135
|
-
const tracks = o["tracks"];
|
|
6136
|
-
if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
|
|
6137
|
-
const typedTracks = tracks;
|
|
6138
|
-
const scopes = typedTracks.map((t) => t.authScope);
|
|
6139
|
-
if (new Set(scopes).size !== scopes.length) return false;
|
|
6140
|
-
if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
|
|
6141
|
-
const manifestTracks = typedTracks.map((t) => t.manifestTrack);
|
|
6142
|
-
if (new Set(manifestTracks).size !== manifestTracks.length) return false;
|
|
6143
|
-
return true;
|
|
6144
|
-
}
|
|
6145
|
-
function resolveMulticastAuthMode(playerMode, auth) {
|
|
6146
|
-
if (playerMode !== void 0) return playerMode;
|
|
6147
|
-
if (auth === void 0) return "off";
|
|
6148
|
-
return auth.enforcement ?? "shadow";
|
|
6149
|
-
}
|
|
6150
|
-
function resolveMulticastAuthCatalog(catalog, playerMode) {
|
|
6151
|
-
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
|
|
6152
|
-
throw new Error("[multicast-auth-catalog] catalog must be an object");
|
|
6153
|
-
}
|
|
6154
|
-
const root = catalog;
|
|
6155
|
-
const rawAuth = root["multicast.auth"];
|
|
6156
|
-
if (rawAuth === void 0) {
|
|
6157
|
-
if (playerMode === "enforce") {
|
|
6158
|
-
throw new Error("[multicast-auth-catalog] player enforce mode requires multicast.auth");
|
|
6159
|
-
}
|
|
6160
|
-
return void 0;
|
|
6161
|
-
}
|
|
6162
|
-
if (!isMulticastAuthConfig(rawAuth)) {
|
|
6163
|
-
throw new Error("[multicast-auth-catalog] invalid multicast.auth v2 block");
|
|
6164
|
-
}
|
|
6165
|
-
const rawTracks = root["tracks"];
|
|
6166
|
-
if (!Array.isArray(rawTracks)) {
|
|
6167
|
-
throw new Error("[multicast-auth-catalog] catalog tracks must be an array");
|
|
6168
|
-
}
|
|
6169
|
-
const catalogTrackNames = new Set(
|
|
6170
|
-
rawTracks.flatMap(
|
|
6171
|
-
(track) => typeof track === "object" && track !== null && typeof track["name"] === "string" ? [track["name"]] : []
|
|
6172
|
-
)
|
|
6173
|
-
);
|
|
6174
|
-
for (const track of rawAuth.tracks) {
|
|
6175
|
-
if (!catalogTrackNames.has(track.mediaTrack)) {
|
|
6176
|
-
throw new Error(`[multicast-auth-catalog] unknown mediaTrack "${track.mediaTrack}"`);
|
|
6177
|
-
}
|
|
6178
|
-
if (!catalogTrackNames.has(track.manifestTrack)) {
|
|
6179
|
-
throw new Error(`[multicast-auth-catalog] unknown manifestTrack "${track.manifestTrack}"`);
|
|
6180
|
-
}
|
|
6181
|
-
}
|
|
6182
|
-
return {
|
|
6183
|
-
keyId: rawAuth.keyId,
|
|
6184
|
-
acceptedPublicKeys: [
|
|
6185
|
-
decodeEd25519PublicKey(rawAuth.publicKey),
|
|
6186
|
-
...rawAuth.previousKey === void 0 ? [] : [decodeEd25519PublicKey(rawAuth.previousKey)]
|
|
6187
|
-
],
|
|
6188
|
-
mode: resolveMulticastAuthMode(playerMode, rawAuth),
|
|
6189
|
-
compaction: rawAuth.compaction,
|
|
6190
|
-
tracks: rawAuth.tracks.map((track) => ({
|
|
6191
|
-
...track,
|
|
6192
|
-
authScope: decodeAuthScope(track.authScope)
|
|
6193
|
-
}))
|
|
6194
|
-
};
|
|
6195
|
-
}
|
|
6196
|
-
|
|
6197
6282
|
// src/repair-layers.ts
|
|
6198
6283
|
var REPAIR_PRIORITY_MIN = 192;
|
|
6199
6284
|
var REPAIR_PRIORITY_MAX = 255;
|
|
@@ -6201,6 +6286,7 @@ var DEFAULT_REPAIR_PRIORITY = 240;
|
|
|
6201
6286
|
var MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
|
|
6202
6287
|
var MAX_REPAIR_SYMBOLS = 16777215;
|
|
6203
6288
|
var MAX_ENCODING_SYMBOL_ID = 16777215;
|
|
6289
|
+
var MAX_REED_SOLOMON_BLOCK_SYMBOLS = 255;
|
|
6204
6290
|
var RepairContractError = class extends Error {
|
|
6205
6291
|
constructor(code, path, message) {
|
|
6206
6292
|
super(`[repair-layers:${code}] ${path}: ${message}`);
|
|
@@ -6383,11 +6469,12 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
|
|
|
6383
6469
|
if (layered && !positiveInteger(source.sourceSymbols)) {
|
|
6384
6470
|
fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
|
|
6385
6471
|
}
|
|
6386
|
-
|
|
6472
|
+
const reedSolomon = source.algorithm === "reed-solomon";
|
|
6473
|
+
if (layered && source.algorithm !== "raptorq" && !reedSolomon) {
|
|
6387
6474
|
fail(
|
|
6388
6475
|
"track_fec",
|
|
6389
6476
|
`${source.path}.algorithm`,
|
|
6390
|
-
"repair layers and overlays are defined only for raptorq
|
|
6477
|
+
"repair layers and overlays are defined only for raptorq and reed-solomon (draft-ramadan-moq-fec-01 6.3.4 rule 7)"
|
|
6391
6478
|
);
|
|
6392
6479
|
}
|
|
6393
6480
|
let layerZeroPriority = DEFAULT_REPAIR_PRIORITY;
|
|
@@ -6446,6 +6533,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
|
|
|
6446
6533
|
`overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
6447
6534
|
);
|
|
6448
6535
|
}
|
|
6536
|
+
if (reedSolomon && sourceSymbols + repairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
6537
|
+
fail(
|
|
6538
|
+
"track_fec_bounds",
|
|
6539
|
+
`${d.path}.repairSymbols`,
|
|
6540
|
+
`reed-solomon overlay sourceSymbols + repairSymbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
|
|
6541
|
+
);
|
|
6542
|
+
}
|
|
6449
6543
|
overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority });
|
|
6450
6544
|
}
|
|
6451
6545
|
let offset = layerZeroSymbols;
|
|
@@ -6490,6 +6584,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
|
|
|
6490
6584
|
`sourceSymbols + total base repair symbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
6491
6585
|
);
|
|
6492
6586
|
}
|
|
6587
|
+
if (reedSolomon && k + totalBaseRepairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
6588
|
+
fail(
|
|
6589
|
+
"track_fec_bounds",
|
|
6590
|
+
`${source.path}.sourceSymbols`,
|
|
6591
|
+
`reed-solomon sourceSymbols + total base repair symbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
|
|
6592
|
+
);
|
|
6593
|
+
}
|
|
6493
6594
|
return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
|
|
6494
6595
|
}
|
|
6495
6596
|
|
|
@@ -6537,7 +6638,7 @@ function isFecCatalogGeometry(obj) {
|
|
|
6537
6638
|
const o = obj;
|
|
6538
6639
|
const algorithm = o["algorithm"];
|
|
6539
6640
|
const symbolSize = o["symbolSize"];
|
|
6540
|
-
return typeof algorithm === "string" &&
|
|
6641
|
+
return typeof algorithm === "string" && algorithm.length > 0 && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
|
|
6541
6642
|
}
|
|
6542
6643
|
function isFecCatalogConfig(obj) {
|
|
6543
6644
|
if (!isFecCatalogGeometry(obj)) return false;
|
|
@@ -6552,8 +6653,7 @@ function isMulticastTrackObject(obj) {
|
|
|
6552
6653
|
function isMulticastEndpoint(obj) {
|
|
6553
6654
|
if (typeof obj !== "object" || obj === null) return false;
|
|
6554
6655
|
const o = obj;
|
|
6555
|
-
|
|
6556
|
-
return typeof protocol === "string" && (protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
|
|
6656
|
+
return multicastEndpointSource(o) !== void 0 && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
|
|
6557
6657
|
}
|
|
6558
6658
|
function isMulticastCatalogConfig(obj) {
|
|
6559
6659
|
if (typeof obj !== "object" || obj === null) return false;
|
|
@@ -6657,13 +6757,22 @@ var CmsfCatalogValidationError = class extends Error {
|
|
|
6657
6757
|
function catalogError(code, path, message) {
|
|
6658
6758
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
6659
6759
|
}
|
|
6660
|
-
function
|
|
6760
|
+
function validateNetworkSourceRelays(sources, path) {
|
|
6761
|
+
if (!Array.isArray(sources)) return;
|
|
6762
|
+
sources.forEach((source, i) => {
|
|
6763
|
+
const s = source;
|
|
6764
|
+
if (s?.["type"] === "amt" && s["discovery"] === "driad" && s["relay"] !== void 0) {
|
|
6765
|
+
catalogError("multicast_network_source", `${path}[${i}].relay`, 'relay must be omitted with discovery "driad"');
|
|
6766
|
+
}
|
|
6767
|
+
});
|
|
6768
|
+
}
|
|
6769
|
+
function validateCmsfMmtpCatalog(value, options = {}) {
|
|
6661
6770
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
6662
6771
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
6663
6772
|
}
|
|
6664
6773
|
const catalog = value;
|
|
6665
6774
|
const rawVersion = catalog["version"];
|
|
6666
|
-
const normalizedVersion = typeof rawVersion === "string" ? Number.isFinite(Number(rawVersion)) ? Number(rawVersion) : rawVersion.startsWith("draft-ietf-moq-catalogformat") ? 1 : NaN : rawVersion;
|
|
6775
|
+
const normalizedVersion = typeof rawVersion === "string" ? Number.isFinite(Number(rawVersion)) ? Number(rawVersion) : rawVersion.startsWith("draft-ietf-moq-catalogformat") || rawVersion === "draft-01" ? 1 : NaN : rawVersion;
|
|
6667
6776
|
if (!Number.isInteger(normalizedVersion) || normalizedVersion <= 0) {
|
|
6668
6777
|
catalogError("catalog_version", "$.version", "version must be a positive integer or a recognized format tag");
|
|
6669
6778
|
}
|
|
@@ -6678,6 +6787,22 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6678
6787
|
"commonTrackFields is retired; every track carries its own fields"
|
|
6679
6788
|
);
|
|
6680
6789
|
}
|
|
6790
|
+
const initDataList = catalog["initDataList"];
|
|
6791
|
+
if (initDataList !== void 0) {
|
|
6792
|
+
if (!Array.isArray(initDataList)) {
|
|
6793
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
6794
|
+
}
|
|
6795
|
+
initDataList.forEach((entry, i) => {
|
|
6796
|
+
const e = entry;
|
|
6797
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
6798
|
+
if (typeof e !== "object" || e === null || Array.isArray(e) || typeof e["id"] !== "string" || e["id"].length === 0 || typeof e["type"] !== "string" || e["type"].length === 0) {
|
|
6799
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
6800
|
+
}
|
|
6801
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
6802
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
6803
|
+
}
|
|
6804
|
+
});
|
|
6805
|
+
}
|
|
6681
6806
|
const tracks = catalog["tracks"];
|
|
6682
6807
|
const trackRecords = [];
|
|
6683
6808
|
const positiveInteger3 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
@@ -6729,6 +6854,14 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6729
6854
|
if (keyframeIntervalMs !== void 0 && !positiveNumber2(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger3(keyframeIntervalTicks)) {
|
|
6730
6855
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
6731
6856
|
}
|
|
6857
|
+
const anchor = track["presentationAnchorTicks"];
|
|
6858
|
+
if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
|
|
6859
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
6860
|
+
}
|
|
6861
|
+
const initRef = track["initRef"];
|
|
6862
|
+
if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
6863
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
6864
|
+
}
|
|
6732
6865
|
if (packaging === "fec-repair") {
|
|
6733
6866
|
rejectRepairTrackGeometry(path, track, catalogError);
|
|
6734
6867
|
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
@@ -6736,9 +6869,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6736
6869
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
6737
6870
|
}
|
|
6738
6871
|
if (packaging === "mmtp") {
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
6872
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
6873
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
6742
6874
|
}
|
|
6743
6875
|
if (!positiveInteger3(timescale)) {
|
|
6744
6876
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -6761,8 +6893,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6761
6893
|
}
|
|
6762
6894
|
const config = fec;
|
|
6763
6895
|
const algorithm = config["algorithm"];
|
|
6764
|
-
if (
|
|
6765
|
-
catalogError("track_fec", `${path}.fec.algorithm`, "
|
|
6896
|
+
if (typeof algorithm !== "string" || algorithm.length === 0) {
|
|
6897
|
+
catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
|
|
6766
6898
|
}
|
|
6767
6899
|
if ("interleaveDepth" in config || "interleaveMs" in config) {
|
|
6768
6900
|
catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
|
|
@@ -6791,6 +6923,9 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6791
6923
|
}
|
|
6792
6924
|
}
|
|
6793
6925
|
readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
|
|
6926
|
+
if (algorithm !== "none" && config["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE) {
|
|
6927
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
|
|
6928
|
+
}
|
|
6794
6929
|
}
|
|
6795
6930
|
}
|
|
6796
6931
|
const repairDescriptors = trackRecords.flatMap(
|
|
@@ -6840,19 +6975,34 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6840
6975
|
const timescale = BigInt(track["timescale"]);
|
|
6841
6976
|
const durationTicks = track["groupDurationTicks"];
|
|
6842
6977
|
const ticks = durationTicks !== void 0 ? BigInt(durationTicks) : BigInt(track["groupDurationMs"]) * timescale / 1000n;
|
|
6843
|
-
const
|
|
6844
|
-
|
|
6845
|
-
|
|
6978
|
+
const framerate = track["framerate"];
|
|
6979
|
+
const intraOnly = positiveNumber2(framerate) && Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
|
|
6980
|
+
const members = switchingSets.get(altGroup) ?? [];
|
|
6981
|
+
members.push({ index, name: track["name"], ticks, timescale, intraOnly });
|
|
6982
|
+
switchingSets.set(altGroup, members);
|
|
6983
|
+
}
|
|
6984
|
+
for (const [altGroup, members] of switchingSets) {
|
|
6985
|
+
const anchor = members.find((member) => !member.intraOnly) ?? members[0];
|
|
6986
|
+
for (const member of members) {
|
|
6987
|
+
if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
|
|
6988
|
+
const nests = member.intraOnly && !anchor.intraOnly && anchor.ticks * member.timescale % (member.ticks * anchor.timescale) === 0n;
|
|
6989
|
+
if (!nests) {
|
|
6990
|
+
catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
|
|
6991
|
+
}
|
|
6846
6992
|
}
|
|
6847
|
-
if (!anchor) switchingSets.set(altGroup, { name: track["name"], ticks, timescale });
|
|
6848
6993
|
}
|
|
6849
6994
|
const multicast = catalog["multicast"];
|
|
6850
6995
|
if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
|
|
6996
|
+
validateNetworkSourceRelays(multicast["networkSource"], "$.multicast.networkSource");
|
|
6851
6997
|
const endpoints = multicast["endpoints"];
|
|
6852
6998
|
if (Array.isArray(endpoints)) {
|
|
6853
6999
|
for (let endpointIndex = 0; endpointIndex < endpoints.length; endpointIndex++) {
|
|
6854
7000
|
const endpoint = endpoints[endpointIndex];
|
|
6855
7001
|
if (typeof endpoint !== "object" || endpoint === null || Array.isArray(endpoint)) continue;
|
|
7002
|
+
validateNetworkSourceRelays(
|
|
7003
|
+
endpoint["networkSource"],
|
|
7004
|
+
`$.multicast.endpoints[${endpointIndex}].networkSource`
|
|
7005
|
+
);
|
|
6856
7006
|
if ("relayAddress" in endpoint) {
|
|
6857
7007
|
catalogError(
|
|
6858
7008
|
"multicast_relay_address",
|
|
@@ -6892,15 +7042,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6892
7042
|
}
|
|
6893
7043
|
}
|
|
6894
7044
|
}
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
} catch (error) {
|
|
6898
|
-
catalogError(
|
|
6899
|
-
"multicast_auth",
|
|
6900
|
-
"$.multicast.auth",
|
|
6901
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block"
|
|
6902
|
-
);
|
|
6903
|
-
}
|
|
7045
|
+
const [multicastIssue] = multicastCatalogIssues(catalog, options);
|
|
7046
|
+
if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
|
|
6904
7047
|
validateArchive(catalog);
|
|
6905
7048
|
return catalog;
|
|
6906
7049
|
}
|
|
@@ -6926,7 +7069,7 @@ function resolveGroupDurationTicks(timing, timescale) {
|
|
|
6926
7069
|
const product = timing.groupDurationMs * timescale;
|
|
6927
7070
|
if (product % 1e3 !== 0) {
|
|
6928
7071
|
throw new Error(
|
|
6929
|
-
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-
|
|
7072
|
+
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-01 \xA74.4.2)`
|
|
6930
7073
|
);
|
|
6931
7074
|
}
|
|
6932
7075
|
return product / 1e3;
|
|
@@ -6947,189 +7090,6 @@ function validateSwitchingSetTiming(tracks) {
|
|
|
6947
7090
|
return { ok: false, expectedTicks, mismatches };
|
|
6948
7091
|
}
|
|
6949
7092
|
|
|
6950
|
-
// node_modules/@blockcast/mmt-transport/dist/types.js
|
|
6951
|
-
var MoqFecAlgorithm;
|
|
6952
|
-
(function(MoqFecAlgorithm2) {
|
|
6953
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
|
|
6954
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
|
|
6955
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
6956
|
-
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
6957
|
-
|
|
6958
|
-
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
6959
|
-
var MPU_HEADER_SIZE2 = 8;
|
|
6960
|
-
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
6961
|
-
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
6962
|
-
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
6963
|
-
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
6964
|
-
|
|
6965
|
-
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
6966
|
-
var DEFAULT_AMT_RELAY_PORT2 = 2268;
|
|
6967
|
-
|
|
6968
|
-
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
6969
|
-
var NTP_SHORT_BITS2 = 32;
|
|
6970
|
-
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
6971
|
-
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
6972
|
-
function isNtpShort(value) {
|
|
6973
|
-
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
6974
|
-
}
|
|
6975
|
-
function compareNtpShort(a, b) {
|
|
6976
|
-
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
6977
|
-
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
6978
|
-
}
|
|
6979
|
-
if (a === b)
|
|
6980
|
-
return "equal";
|
|
6981
|
-
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
6982
|
-
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
6983
|
-
return "after";
|
|
6984
|
-
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
6985
|
-
return "before";
|
|
6986
|
-
return "unordered";
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6989
|
-
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
6990
|
-
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
6991
|
-
"iso-ssbg1-v1"
|
|
6992
|
-
]);
|
|
6993
|
-
|
|
6994
|
-
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
6995
|
-
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
6996
|
-
|
|
6997
|
-
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
6998
|
-
var DRIADDiscovery = class {
|
|
6999
|
-
cache = /* @__PURE__ */ new Map();
|
|
7000
|
-
cacheExpiry = 3e5;
|
|
7001
|
-
// 5 minutes
|
|
7002
|
-
/**
|
|
7003
|
-
* Discover AMT relays for a multicast source address (RFC 8777)
|
|
7004
|
-
*
|
|
7005
|
-
* @param source - The multicast source IP address (NOT the group!)
|
|
7006
|
-
* @returns Array of discovered AMT relays that can tunnel traffic from this source
|
|
7007
|
-
*/
|
|
7008
|
-
async discoverRelays(source) {
|
|
7009
|
-
const cached = this.cache.get(source);
|
|
7010
|
-
if (cached) {
|
|
7011
|
-
return cached;
|
|
7012
|
-
}
|
|
7013
|
-
try {
|
|
7014
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
7015
|
-
const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
|
|
7016
|
-
console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
|
|
7017
|
-
const relays = await this.queryDRIADProxy(source);
|
|
7018
|
-
if (relays.length > 0) {
|
|
7019
|
-
this.cache.set(source, relays);
|
|
7020
|
-
setTimeout(() => this.cache.delete(source), this.cacheExpiry);
|
|
7021
|
-
}
|
|
7022
|
-
return relays;
|
|
7023
|
-
} catch (error) {
|
|
7024
|
-
console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
|
|
7025
|
-
return [];
|
|
7026
|
-
}
|
|
7027
|
-
}
|
|
7028
|
-
/**
|
|
7029
|
-
* Query DRIAD proxy service (browser-compatible)
|
|
7030
|
-
*/
|
|
7031
|
-
async queryDRIADProxy(source) {
|
|
7032
|
-
const proxyEndpoints = [
|
|
7033
|
-
"https://driad.amt.net/api/v1/relays",
|
|
7034
|
-
"https://multicast-gateway.cloudflare.com/driad"
|
|
7035
|
-
];
|
|
7036
|
-
for (const endpoint of proxyEndpoints) {
|
|
7037
|
-
try {
|
|
7038
|
-
const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
|
|
7039
|
-
method: "GET",
|
|
7040
|
-
headers: { Accept: "application/json" },
|
|
7041
|
-
signal: AbortSignal.timeout(5e3)
|
|
7042
|
-
});
|
|
7043
|
-
if (response.ok) {
|
|
7044
|
-
const data = await response.json();
|
|
7045
|
-
return data.relays || [];
|
|
7046
|
-
}
|
|
7047
|
-
} catch {
|
|
7048
|
-
}
|
|
7049
|
-
}
|
|
7050
|
-
const dohRelay = await this.queryDNSOverHTTPS(source);
|
|
7051
|
-
if (dohRelay) {
|
|
7052
|
-
return [dohRelay];
|
|
7053
|
-
}
|
|
7054
|
-
return [];
|
|
7055
|
-
}
|
|
7056
|
-
/**
|
|
7057
|
-
* Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
|
|
7058
|
-
*/
|
|
7059
|
-
async queryDNSOverHTTPS(source) {
|
|
7060
|
-
try {
|
|
7061
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
7062
|
-
const queryName = `${reversedSource}.amt.in-addr.arpa`;
|
|
7063
|
-
const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
|
|
7064
|
-
const response = await fetch(dohUrl, {
|
|
7065
|
-
headers: { Accept: "application/dns-json" },
|
|
7066
|
-
signal: AbortSignal.timeout(3e3)
|
|
7067
|
-
});
|
|
7068
|
-
if (!response.ok) {
|
|
7069
|
-
return null;
|
|
7070
|
-
}
|
|
7071
|
-
const result = await response.json();
|
|
7072
|
-
if (result.Answer && result.Answer.length > 0) {
|
|
7073
|
-
return {
|
|
7074
|
-
host: result.Answer[0].data,
|
|
7075
|
-
port: DEFAULT_AMT_RELAY_PORT2,
|
|
7076
|
-
priority: 10,
|
|
7077
|
-
weight: 100,
|
|
7078
|
-
asn: 0
|
|
7079
|
-
};
|
|
7080
|
-
}
|
|
7081
|
-
return null;
|
|
7082
|
-
} catch (error) {
|
|
7083
|
-
console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
|
|
7084
|
-
return null;
|
|
7085
|
-
}
|
|
7086
|
-
}
|
|
7087
|
-
/**
|
|
7088
|
-
* Select best relay based on RTT measurements
|
|
7089
|
-
*/
|
|
7090
|
-
async selectBestRelay(relays) {
|
|
7091
|
-
if (relays.length === 0)
|
|
7092
|
-
return null;
|
|
7093
|
-
const measured = await Promise.all(relays.map(async (relay) => {
|
|
7094
|
-
const rtt = await this.measureRTT(relay.host, relay.port);
|
|
7095
|
-
return { ...relay, rtt };
|
|
7096
|
-
}));
|
|
7097
|
-
measured.sort((a, b) => {
|
|
7098
|
-
if (a.priority !== b.priority)
|
|
7099
|
-
return a.priority - b.priority;
|
|
7100
|
-
return (a.rtt || Infinity) - (b.rtt || Infinity);
|
|
7101
|
-
});
|
|
7102
|
-
console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
|
|
7103
|
-
return measured[0];
|
|
7104
|
-
}
|
|
7105
|
-
async measureRTT(host, _port) {
|
|
7106
|
-
const start = performance.now();
|
|
7107
|
-
try {
|
|
7108
|
-
await fetch(`https://${host}/health`, {
|
|
7109
|
-
method: "HEAD",
|
|
7110
|
-
signal: AbortSignal.timeout(2e3),
|
|
7111
|
-
mode: "no-cors"
|
|
7112
|
-
});
|
|
7113
|
-
return performance.now() - start;
|
|
7114
|
-
} catch {
|
|
7115
|
-
return Infinity;
|
|
7116
|
-
}
|
|
7117
|
-
}
|
|
7118
|
-
/**
|
|
7119
|
-
* Clear the relay cache
|
|
7120
|
-
*/
|
|
7121
|
-
clearCache() {
|
|
7122
|
-
this.cache.clear();
|
|
7123
|
-
}
|
|
7124
|
-
/**
|
|
7125
|
-
* Get cached relays for a source address
|
|
7126
|
-
*/
|
|
7127
|
-
getCached(source) {
|
|
7128
|
-
return this.cache.get(source);
|
|
7129
|
-
}
|
|
7130
|
-
};
|
|
7131
|
-
var driadDiscovery = new DRIADDiscovery();
|
|
7132
|
-
|
|
7133
7093
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
7134
7094
|
function endpointKey(endpoint) {
|
|
7135
7095
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -7260,8 +7220,8 @@ var AdaptiveBitrateController = class {
|
|
|
7260
7220
|
/**
|
|
7261
7221
|
* Update FEC statistics for ABR decisions
|
|
7262
7222
|
*
|
|
7263
|
-
*
|
|
7264
|
-
*
|
|
7223
|
+
* ABR uses the effective loss rate (after FEC recovery) rather than the
|
|
7224
|
+
* raw transport loss rate.
|
|
7265
7225
|
*
|
|
7266
7226
|
* @param stats - FEC statistics from the FEC decoder
|
|
7267
7227
|
*/
|
|
@@ -7337,6 +7297,45 @@ var AdaptiveBitrateController = class {
|
|
|
7337
7297
|
}
|
|
7338
7298
|
};
|
|
7339
7299
|
|
|
7300
|
+
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
7301
|
+
var MPU_HEADER_SIZE2 = 8;
|
|
7302
|
+
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
7303
|
+
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
7304
|
+
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
7305
|
+
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
7306
|
+
|
|
7307
|
+
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
7308
|
+
var DEFAULT_AMT_RELAY_PORT2 = 2268;
|
|
7309
|
+
|
|
7310
|
+
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
7311
|
+
var NTP_SHORT_BITS2 = 32;
|
|
7312
|
+
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
7313
|
+
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
7314
|
+
function isNtpShort(value) {
|
|
7315
|
+
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
7316
|
+
}
|
|
7317
|
+
function compareNtpShort(a, b) {
|
|
7318
|
+
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
7319
|
+
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
7320
|
+
}
|
|
7321
|
+
if (a === b)
|
|
7322
|
+
return "equal";
|
|
7323
|
+
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
7324
|
+
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
7325
|
+
return "after";
|
|
7326
|
+
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
7327
|
+
return "before";
|
|
7328
|
+
return "unordered";
|
|
7329
|
+
}
|
|
7330
|
+
|
|
7331
|
+
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
7332
|
+
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
7333
|
+
"iso-ssbg1-v1"
|
|
7334
|
+
]);
|
|
7335
|
+
|
|
7336
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
7337
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
7338
|
+
|
|
7340
7339
|
// node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
|
|
7341
7340
|
var DEFAULT_DWELL_MS = 3e3;
|
|
7342
7341
|
var DEFAULT_JOIN_DEADLINE_MS = 5e3;
|
|
@@ -7574,8 +7573,23 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7574
7573
|
consume: "bytes",
|
|
7575
7574
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
7576
7575
|
};
|
|
7576
|
+
if (input.atsc3) {
|
|
7577
|
+
const { frequency, plpId, serviceId } = input.atsc3;
|
|
7578
|
+
if (!Number.isInteger(frequency) || frequency < 1) {
|
|
7579
|
+
throw new TypeError(`ATSC3 tuning requires a positive integer frequency in kHz, got ${String(frequency)}`);
|
|
7580
|
+
}
|
|
7581
|
+
return {
|
|
7582
|
+
...base,
|
|
7583
|
+
origin: "tuner",
|
|
7584
|
+
standard: "atsc3",
|
|
7585
|
+
frequency,
|
|
7586
|
+
...plpId !== void 0 ? { plpId } : {},
|
|
7587
|
+
...serviceId !== void 0 ? { serviceId } : {}
|
|
7588
|
+
};
|
|
7589
|
+
}
|
|
7577
7590
|
const relay = input.amtRelay?.trim();
|
|
7578
|
-
const
|
|
7591
|
+
const driad = !relay && input.amtDiscovery === "driad";
|
|
7592
|
+
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
7579
7593
|
if (!wantsAmt) {
|
|
7580
7594
|
const native = {
|
|
7581
7595
|
...base,
|
|
@@ -7585,6 +7599,20 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7585
7599
|
return native;
|
|
7586
7600
|
}
|
|
7587
7601
|
const relayPort = input.amtRelayPort;
|
|
7602
|
+
if (driad) {
|
|
7603
|
+
if (!base.source)
|
|
7604
|
+
throw new TypeError("AMT DRIAD discovery requires a source address");
|
|
7605
|
+
if (relayPort !== void 0 && !isPositivePort(relayPort)) {
|
|
7606
|
+
throw new TypeError("AMT DRIAD discovery requires a valid relay port when one is given");
|
|
7607
|
+
}
|
|
7608
|
+
return {
|
|
7609
|
+
...base,
|
|
7610
|
+
source: base.source,
|
|
7611
|
+
origin: "amt",
|
|
7612
|
+
discovery: "driad",
|
|
7613
|
+
...relayPort !== void 0 ? { relayPort } : {}
|
|
7614
|
+
};
|
|
7615
|
+
}
|
|
7588
7616
|
if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
|
|
7589
7617
|
throw new TypeError("AMT requires a resolved relay and a valid relay port");
|
|
7590
7618
|
}
|
|
@@ -7628,7 +7656,8 @@ function normalizeMulticastEndpoint(endpoint) {
|
|
|
7628
7656
|
port: endpoint.port,
|
|
7629
7657
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
7630
7658
|
...amtRelay ? { amtRelay } : {},
|
|
7631
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
7659
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
7660
|
+
...endpoint.amtDiscovery === "driad" ? { amtDiscovery: "driad" } : {}
|
|
7632
7661
|
};
|
|
7633
7662
|
}
|
|
7634
7663
|
function multicastEndpointKey(endpoint) {
|
|
@@ -7641,7 +7670,9 @@ function multicastEndpointKey(endpoint) {
|
|
|
7641
7670
|
normalized.port,
|
|
7642
7671
|
normalized.mode ?? "auto",
|
|
7643
7672
|
normalized.amtRelay ?? "",
|
|
7644
|
-
normalized.amtRelayPort ?? ""
|
|
7673
|
+
normalized.amtRelayPort ?? "",
|
|
7674
|
+
// A DRIAD join is a different gateway subscription from a native one.
|
|
7675
|
+
...normalized.amtDiscovery ? [normalized.amtDiscovery] : []
|
|
7645
7676
|
]);
|
|
7646
7677
|
}
|
|
7647
7678
|
function isMulticastTrackPacketId(value) {
|
|
@@ -7681,7 +7712,8 @@ var MulticastSubscriptionPool = class {
|
|
|
7681
7712
|
port: config.port,
|
|
7682
7713
|
mode: config.mode,
|
|
7683
7714
|
amtRelay: config.amtRelay,
|
|
7684
|
-
amtRelayPort: config.amtRelayPort
|
|
7715
|
+
amtRelayPort: config.amtRelayPort,
|
|
7716
|
+
amtDiscovery: config.amtDiscovery
|
|
7685
7717
|
});
|
|
7686
7718
|
if (!endpoint)
|
|
7687
7719
|
throw new Error("Invalid multicast endpoint");
|
|
@@ -7747,7 +7779,8 @@ var MulticastSubscriptionPool = class {
|
|
|
7747
7779
|
port: endpoint.port,
|
|
7748
7780
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
7749
7781
|
...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
|
|
7750
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
7782
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
7783
|
+
...endpoint.amtDiscovery ? { amtDiscovery: endpoint.amtDiscovery } : {}
|
|
7751
7784
|
}));
|
|
7752
7785
|
const consumers = /* @__PURE__ */ new Map();
|
|
7753
7786
|
let entry;
|
|
@@ -7827,7 +7860,6 @@ var TransportManager = class {
|
|
|
7827
7860
|
};
|
|
7828
7861
|
capabilities = null;
|
|
7829
7862
|
subscription = null;
|
|
7830
|
-
driad = new DRIADDiscovery();
|
|
7831
7863
|
/** Built by `connect()` from the caller's ladder; there is no built-in one. */
|
|
7832
7864
|
abr = null;
|
|
7833
7865
|
multicastOrchestrator = null;
|
|
@@ -7877,8 +7909,8 @@ var TransportManager = class {
|
|
|
7877
7909
|
nativeIGMP: hasGatewayBytes,
|
|
7878
7910
|
directSockets: typeof win?.UDPSocket !== "undefined",
|
|
7879
7911
|
amt: false,
|
|
7880
|
-
driad:
|
|
7881
|
-
//
|
|
7912
|
+
driad: hasGatewayBytes,
|
|
7913
|
+
// the gateway runs RFC 8777 discovery
|
|
7882
7914
|
fecDecode: false
|
|
7883
7915
|
};
|
|
7884
7916
|
console.log("[Transport] Capabilities:", this.capabilities);
|
|
@@ -7889,7 +7921,7 @@ var TransportManager = class {
|
|
|
7889
7921
|
*
|
|
7890
7922
|
* Promotion hierarchy:
|
|
7891
7923
|
* 1. window.multicast gateway bytes
|
|
7892
|
-
* 2. AMT
|
|
7924
|
+
* 2. AMT: a configured relay via the AMT proxy, else gateway DRIAD discovery
|
|
7893
7925
|
* 3. MOQ WebTransport (final fallback)
|
|
7894
7926
|
*
|
|
7895
7927
|
* The ABR ladder (`abrLadder`) and initial rendition (`initialQuality`)
|
|
@@ -7983,7 +8015,7 @@ var TransportManager = class {
|
|
|
7983
8015
|
/**
|
|
7984
8016
|
* Connect via the lowercase window.multicast bytes gateway.
|
|
7985
8017
|
*/
|
|
7986
|
-
async connectWindowMulticast(config, generation) {
|
|
8018
|
+
async connectWindowMulticast(config, generation, mode = "multicast") {
|
|
7987
8019
|
try {
|
|
7988
8020
|
const gateway = this.getWindowMulticastGateway();
|
|
7989
8021
|
if (typeof gateway?.subscribe !== "function")
|
|
@@ -8018,7 +8050,7 @@ var TransportManager = class {
|
|
|
8018
8050
|
}
|
|
8019
8051
|
};
|
|
8020
8052
|
this.state = {
|
|
8021
|
-
mode
|
|
8053
|
+
mode,
|
|
8022
8054
|
connected: true,
|
|
8023
8055
|
group: config.group,
|
|
8024
8056
|
source: config.source,
|
|
@@ -8036,29 +8068,19 @@ var TransportManager = class {
|
|
|
8036
8068
|
}
|
|
8037
8069
|
}
|
|
8038
8070
|
/**
|
|
8039
|
-
* Connect via AMT proxy
|
|
8071
|
+
* Connect via AMT: a configured relay goes through the AMT proxy; with no
|
|
8072
|
+
* relay, the window.multicast gateway discovers one per RFC 8777 (DRIAD).
|
|
8040
8073
|
*/
|
|
8041
8074
|
async connectAmt(config, generation) {
|
|
8042
8075
|
try {
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
const relays = await this.driad.discoverRelays(config.source);
|
|
8047
|
-
if (generation !== this.connectionGeneration)
|
|
8048
|
-
return false;
|
|
8049
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
8050
|
-
if (generation !== this.connectionGeneration)
|
|
8051
|
-
return false;
|
|
8052
|
-
if (bestRelay) {
|
|
8053
|
-
amtRelay = bestRelay.host;
|
|
8054
|
-
this.state.amtRelay = amtRelay;
|
|
8055
|
-
}
|
|
8056
|
-
}
|
|
8057
|
-
if (!amtRelay) {
|
|
8076
|
+
if (config.amtRelay)
|
|
8077
|
+
return await this.connectAmtProxy(config, config.amtRelay, generation);
|
|
8078
|
+
if (config.driadEnabled === false || !config.source || config.mode === "native") {
|
|
8058
8079
|
console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
|
|
8059
8080
|
return false;
|
|
8060
8081
|
}
|
|
8061
|
-
|
|
8082
|
+
console.log(`[Transport] Asking the gateway for a DRIAD relay for source ${config.source}...`);
|
|
8083
|
+
return await this.connectWindowMulticast({ ...config, amtDiscovery: "driad" }, generation, "amt");
|
|
8062
8084
|
} catch (error) {
|
|
8063
8085
|
console.warn("[Transport] AMT connection failed:", error);
|
|
8064
8086
|
return false;
|
|
@@ -8289,7 +8311,6 @@ var AMTGatewayManager = class {
|
|
|
8289
8311
|
subscriptions = /* @__PURE__ */ new Map();
|
|
8290
8312
|
messageHandler;
|
|
8291
8313
|
pendingPackets = /* @__PURE__ */ new Map();
|
|
8292
|
-
driad = new DRIADDiscovery();
|
|
8293
8314
|
constructor() {
|
|
8294
8315
|
this.messageHandler = (event) => {
|
|
8295
8316
|
const data = event.data;
|
|
@@ -8320,26 +8341,12 @@ var AMTGatewayManager = class {
|
|
|
8320
8341
|
return keyStr;
|
|
8321
8342
|
}
|
|
8322
8343
|
try {
|
|
8323
|
-
|
|
8324
|
-
let discoveryMethod;
|
|
8344
|
+
const relayAddress = config.relayAddress;
|
|
8325
8345
|
const relayPort = config.relayPort || DEFAULT_AMT_RELAY_PORT2;
|
|
8326
|
-
if (
|
|
8327
|
-
|
|
8328
|
-
discoveryMethod = "manual";
|
|
8329
|
-
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
8330
|
-
} else if (key.source) {
|
|
8331
|
-
console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
|
|
8332
|
-
const relays = await this.driad.discoverRelays(key.source);
|
|
8333
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
8334
|
-
if (!bestRelay) {
|
|
8335
|
-
throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
|
|
8336
|
-
}
|
|
8337
|
-
relayAddress = bestRelay.host;
|
|
8338
|
-
discoveryMethod = "driad";
|
|
8339
|
-
console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
|
|
8340
|
-
} else {
|
|
8341
|
-
throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
|
|
8346
|
+
if (!relayAddress) {
|
|
8347
|
+
throw new Error(`AMT relay address required: this manager does no relay discovery. For RFC 8777 DRIAD discovery, join through window.multicast with amtDiscovery: "driad".`);
|
|
8342
8348
|
}
|
|
8349
|
+
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
8343
8350
|
const subscriptionId = keyStr;
|
|
8344
8351
|
this.pendingPackets.set(subscriptionId, []);
|
|
8345
8352
|
const subscription = {
|
|
@@ -8350,7 +8357,7 @@ var AMTGatewayManager = class {
|
|
|
8350
8357
|
relay: {
|
|
8351
8358
|
address: relayAddress,
|
|
8352
8359
|
port: relayPort,
|
|
8353
|
-
discoveryMethod,
|
|
8360
|
+
discoveryMethod: "manual",
|
|
8354
8361
|
discoveredAt: Date.now()
|
|
8355
8362
|
}
|
|
8356
8363
|
};
|
|
@@ -8825,25 +8832,20 @@ function multicastFromConfig(input) {
|
|
|
8825
8832
|
);
|
|
8826
8833
|
}
|
|
8827
8834
|
}
|
|
8828
|
-
const
|
|
8829
|
-
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint2(ep, idx, seenTuples));
|
|
8835
|
+
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint2(ep, idx));
|
|
8830
8836
|
const out = { endpoints };
|
|
8831
8837
|
const { entries: networkSource, relayFrom } = resolveNetworkSource(input);
|
|
8832
8838
|
networkSource.forEach(validateNetworkSourceEntry);
|
|
8833
8839
|
if (networkSource.length > 0) out.networkSource = networkSource;
|
|
8834
8840
|
const amtRelays = new Set(
|
|
8835
|
-
networkSource.flatMap((s) => s.type === "amt" && s.
|
|
8841
|
+
networkSource.flatMap((s) => s.type === "amt" && s.relay?.trim() ? [s.relay.trim()] : []).slice(0, 1)
|
|
8836
8842
|
);
|
|
8837
8843
|
input.endpoints.forEach((ep, idx) => {
|
|
8838
8844
|
const relay = ep.relayAddress?.trim();
|
|
8839
8845
|
if (!relay || amtRelays.has(relay)) return;
|
|
8840
|
-
const demoted = networkSource.some(
|
|
8841
|
-
(s) => s.type === "amt" && s.discovery === "driad" && s.relay?.trim() === relay
|
|
8842
|
-
);
|
|
8843
8846
|
const shadowed = networkSource.some(
|
|
8844
|
-
(s) => s.type === "amt" && s.
|
|
8847
|
+
(s) => s.type === "amt" && s.relay?.trim() === relay
|
|
8845
8848
|
);
|
|
8846
|
-
const derived = input.networkSource === void 0;
|
|
8847
8849
|
const fromAmtFallback = ", derived from amtFallback/MOQCAST_MULTICAST_AMT_*";
|
|
8848
8850
|
const fromRelay = relayFrom === "amtFallback.relayDns" ? fromAmtFallback : relayFrom === "endpoint.relayAddress" ? ", derived from the endpoint relayAddress values" : "";
|
|
8849
8851
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
@@ -8851,7 +8853,7 @@ function multicastFromConfig(input) {
|
|
|
8851
8853
|
throw new MulticastInputError(
|
|
8852
8854
|
"conflicting_amt_relay",
|
|
8853
8855
|
idx,
|
|
8854
|
-
`endpoint[${idx}] relayAddress ${JSON.stringify(relay)} ` + (
|
|
8856
|
+
`endpoint[${idx}] relayAddress ${JSON.stringify(relay)} ` + (shadowed ? `is carried by a multicast.networkSource AMT entry that is not the first one: both readers join the first AMT entry (${[...amtRelays].join(", ")}) and ignore the rest, so this relay is never joined; keep a single AMT entry, or put this one first` : `is not the relay of any multicast.networkSource AMT entry (${[...amtRelays].join(", ") || "none"})${fromRelay}; ` + (outranked ? `amtFallback.relayDns/MOQCAST_MULTICAST_AMT_RELAY_DNS (${relayDns}) outranks an endpoint relay when networkSource is derived -- drop one, or make them agree` : "networkSource is catalog-level and cannot represent per-endpoint relays"))
|
|
8855
8857
|
);
|
|
8856
8858
|
});
|
|
8857
8859
|
input.endpoints.forEach((ep, idx) => {
|
|
@@ -8860,9 +8862,20 @@ function multicastFromConfig(input) {
|
|
|
8860
8862
|
throw new MulticastInputError(
|
|
8861
8863
|
ep.protocol === "amt" ? "amt_requires_relay" : "atsc3_requires_tuning",
|
|
8862
8864
|
idx,
|
|
8863
|
-
`endpoint[${idx}] protocol=${ep.protocol} requires a multicast.networkSource entry of type "${ep.protocol}"` + (ep.protocol === "atsc3" ? " carrying
|
|
8865
|
+
`endpoint[${idx}] protocol=${ep.protocol} requires a multicast.networkSource entry of type "${ep.protocol}"` + (ep.protocol === "atsc3" ? " carrying at least its frequency (kHz) \u2014 an ATSC3 endpoint is not tunable without it" : "")
|
|
8864
8866
|
);
|
|
8865
8867
|
});
|
|
8868
|
+
input.endpoints.forEach((ep, idx) => {
|
|
8869
|
+
if (ep.protocol !== "amt" && ep.protocol !== "atsc3") return;
|
|
8870
|
+
endpoints[idx].networkSource = networkSource.filter((s) => s.type === ep.protocol).map((s) => ({ ...s }));
|
|
8871
|
+
});
|
|
8872
|
+
if (input.auth !== void 0) out.auth = input.auth;
|
|
8873
|
+
const [issue] = multicastCatalogIssues({ multicast: out });
|
|
8874
|
+
if (issue) {
|
|
8875
|
+
const kind = issue.code === "multicast_auth" ? "invalid_multicast_auth" : issue.code === "multicast_endpoint_auth" ? "invalid_endpoint_auth" : issue.path.endsWith(".port") ? "duplicate_endpoint_tuple" : "protocol_source_mismatch";
|
|
8876
|
+
const where = issue.endpointIndex === void 0 ? "" : `endpoint[${issue.endpointIndex}] `;
|
|
8877
|
+
throw new MulticastInputError(kind, issue.endpointIndex ?? null, `${where}${issue.path.replace("$.multicast.", "")}: ${issue.message}`);
|
|
8878
|
+
}
|
|
8866
8879
|
if (input.enabled !== void 0) out.enabled = input.enabled;
|
|
8867
8880
|
if (input.version !== void 0) out.version = input.version;
|
|
8868
8881
|
if (input.validUntil !== void 0) out.validUntil = input.validUntil;
|
|
@@ -8874,10 +8887,10 @@ function resolveNetworkSource(input) {
|
|
|
8874
8887
|
}
|
|
8875
8888
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
8876
8889
|
const relay = relayDns || input.endpoints.map((ep) => ep.relayAddress?.trim()).find((r) => !!r);
|
|
8877
|
-
const discovery = input.amtFallback?.discovery
|
|
8878
|
-
if (discovery === void 0) return { entries: [], relayFrom: null };
|
|
8890
|
+
const discovery = input.amtFallback?.discovery;
|
|
8891
|
+
if (discovery === void 0 && !relay) return { entries: [], relayFrom: null };
|
|
8879
8892
|
return {
|
|
8880
|
-
entries: [{ type: "amt", discovery, ...relay ? { relay } : {} }],
|
|
8893
|
+
entries: [{ type: "amt", ...discovery ? { discovery } : {}, ...relay ? { relay } : {} }],
|
|
8881
8894
|
relayFrom: !relay ? null : relayDns ? "amtFallback.relayDns" : "endpoint.relayAddress"
|
|
8882
8895
|
};
|
|
8883
8896
|
}
|
|
@@ -8890,8 +8903,11 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8890
8903
|
const extra = Object.keys(s).filter((k) => !keys.has(k) && s[k] !== void 0);
|
|
8891
8904
|
if (extra.length > 0) throw err("invalid_network_source", `has keys the schema rejects: ${extra.join(", ")}`);
|
|
8892
8905
|
if (s.type === "amt") {
|
|
8893
|
-
if (s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8894
|
-
throw err(
|
|
8906
|
+
if (s.discovery !== void 0 && s.discovery !== "dns" && s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8907
|
+
throw err(
|
|
8908
|
+
"invalid_amt_discovery",
|
|
8909
|
+
`discovery must be "dns", "driad" or "manual" when present; got ${JSON.stringify(s.discovery)}`
|
|
8910
|
+
);
|
|
8895
8911
|
}
|
|
8896
8912
|
if (s.relay !== void 0) {
|
|
8897
8913
|
const relay = typeof s.relay === "string" ? s.relay.trim() : "";
|
|
@@ -8900,8 +8916,14 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8900
8916
|
}
|
|
8901
8917
|
s.relay = relay;
|
|
8902
8918
|
}
|
|
8903
|
-
if (s.discovery === "manual" && s.relay === void 0) {
|
|
8904
|
-
throw err("amt_requires_relay", `discovery="
|
|
8919
|
+
if ((s.discovery === "dns" || s.discovery === "manual") && s.relay === void 0) {
|
|
8920
|
+
throw err("amt_requires_relay", `discovery="${s.discovery}" requires a relay ("driad" resolves it at runtime)`);
|
|
8921
|
+
}
|
|
8922
|
+
if (s.discovery === "driad" && s.relay !== void 0) {
|
|
8923
|
+
throw err(
|
|
8924
|
+
"invalid_network_source",
|
|
8925
|
+
`discovery="driad" must omit relay: DRIAD supplies the relay candidates (draft -01 4.2.1); drop the relay (amtFallback.relayDns / endpoint relayAddress on the derived path), or use "dns" or "manual"`
|
|
8926
|
+
);
|
|
8905
8927
|
}
|
|
8906
8928
|
if (s.port !== void 0 && (!Number.isInteger(s.port) || s.port < 1 || s.port > 65535)) {
|
|
8907
8929
|
throw err("invalid_port", `port must be 1..65535; got ${s.port}`);
|
|
@@ -8910,13 +8932,15 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8910
8932
|
}
|
|
8911
8933
|
const inRange = (v, min, max) => Number.isInteger(v) && v >= min && v <= max;
|
|
8912
8934
|
if (!inRange(s.frequency, 1, Number.MAX_SAFE_INTEGER)) {
|
|
8913
|
-
throw err("invalid_network_source", `frequency must be a positive integer; got ${s.frequency}`);
|
|
8935
|
+
throw err("invalid_network_source", `frequency must be a positive integer in kHz; got ${s.frequency}`);
|
|
8936
|
+
}
|
|
8937
|
+
if (s.plpId !== void 0 && !inRange(s.plpId, 0, 63)) {
|
|
8938
|
+
throw err("invalid_network_source", `plpId must be 0..63; got ${s.plpId}`);
|
|
8914
8939
|
}
|
|
8915
|
-
if (!inRange(s.
|
|
8916
|
-
if (!inRange(s.serviceId, 0, 65535)) {
|
|
8940
|
+
if (s.serviceId !== void 0 && !inRange(s.serviceId, 0, 65535)) {
|
|
8917
8941
|
throw err("invalid_network_source", `serviceId must be 0..65535; got ${s.serviceId}`);
|
|
8918
8942
|
}
|
|
8919
|
-
if (typeof s.slsUri !== "string" || !isAbsoluteUri(s.slsUri)) {
|
|
8943
|
+
if (s.slsUri !== void 0 && (typeof s.slsUri !== "string" || !isAbsoluteUri(s.slsUri))) {
|
|
8920
8944
|
throw err("invalid_network_source", `slsUri must be an absolute URI; got ${JSON.stringify(s.slsUri)}`);
|
|
8921
8945
|
}
|
|
8922
8946
|
}
|
|
@@ -8928,7 +8952,7 @@ function isAbsoluteUri(value) {
|
|
|
8928
8952
|
return false;
|
|
8929
8953
|
}
|
|
8930
8954
|
}
|
|
8931
|
-
function validateEndpoint2(ep, idx
|
|
8955
|
+
function validateEndpoint2(ep, idx) {
|
|
8932
8956
|
if (ep.protocol === "ssm" && (!ep.sourceAddress || ep.sourceAddress.length === 0)) {
|
|
8933
8957
|
throw new MulticastInputError(
|
|
8934
8958
|
"ssm_requires_source",
|
|
@@ -8936,6 +8960,13 @@ function validateEndpoint2(ep, idx, seenTuples) {
|
|
|
8936
8960
|
`endpoint[${idx}] protocol=ssm requires sourceAddress`
|
|
8937
8961
|
);
|
|
8938
8962
|
}
|
|
8963
|
+
if (ep.protocol === "asm" && ep.sourceAddress !== void 0) {
|
|
8964
|
+
throw new MulticastInputError(
|
|
8965
|
+
"protocol_source_mismatch",
|
|
8966
|
+
idx,
|
|
8967
|
+
`endpoint[${idx}] protocol=asm with sourceAddress "${ep.sourceAddress}"; sourceAddress selects SSM (draft -01 4.1)`
|
|
8968
|
+
);
|
|
8969
|
+
}
|
|
8939
8970
|
if (!isMulticastGroupAddress(ep.groupAddress)) {
|
|
8940
8971
|
throw new MulticastInputError(
|
|
8941
8972
|
"invalid_group_address",
|
|
@@ -8995,23 +9026,15 @@ function validateEndpoint2(ep, idx, seenTuples) {
|
|
|
8995
9026
|
`endpoint[${idx}] bandwidth must be positive; got ${ep.bandwidth}`
|
|
8996
9027
|
);
|
|
8997
9028
|
}
|
|
8998
|
-
const tupleKey = `${ep.sourceAddress ?? ""}|${ep.groupAddress}|${ep.port}`;
|
|
8999
|
-
if (seenTuples.has(tupleKey)) {
|
|
9000
|
-
throw new MulticastInputError(
|
|
9001
|
-
"duplicate_endpoint_tuple",
|
|
9002
|
-
idx,
|
|
9003
|
-
`endpoint[${idx}] duplicates (sourceAddress, groupAddress, port) tuple "${tupleKey}"`
|
|
9004
|
-
);
|
|
9005
|
-
}
|
|
9006
|
-
seenTuples.add(tupleKey);
|
|
9007
9029
|
const out = {
|
|
9008
|
-
protocol: ep.
|
|
9030
|
+
protocol: ep.sourceAddress === void 0 ? "asm" : "ssm",
|
|
9009
9031
|
groupAddress: ep.groupAddress,
|
|
9010
9032
|
port: ep.port,
|
|
9011
9033
|
tracks: ep.tracks.map((t) => ({ name: t.name, packetId: t.packetId }))
|
|
9012
9034
|
};
|
|
9013
9035
|
if (ep.sourceAddress !== void 0) out.sourceAddress = ep.sourceAddress;
|
|
9014
9036
|
if (ep.bandwidth !== void 0) out.bandwidth = ep.bandwidth;
|
|
9037
|
+
if (ep.auth !== void 0) out.auth = { ...ep.auth };
|
|
9015
9038
|
return out;
|
|
9016
9039
|
}
|
|
9017
9040
|
function isMulticastGroupAddress(addr) {
|
|
@@ -9054,9 +9077,9 @@ function multicastFromEnv(env = globalThis.process?.env ?? {}) {
|
|
|
9054
9077
|
endpoints,
|
|
9055
9078
|
...hasCatalogAmt ? {
|
|
9056
9079
|
amtFallback: {
|
|
9057
|
-
//
|
|
9058
|
-
//
|
|
9059
|
-
discovery: amtDiscovery
|
|
9080
|
+
// No default: an omitted discovery with a relay hostname is
|
|
9081
|
+
// "dns" (draft-ramadan-moq-multicast-01 4.2.1).
|
|
9082
|
+
...amtDiscovery ? { discovery: amtDiscovery } : {},
|
|
9060
9083
|
...amtRelayDns ? { relayDns: amtRelayDns } : {}
|
|
9061
9084
|
}
|
|
9062
9085
|
} : {}
|
|
@@ -9224,7 +9247,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9224
9247
|
if (ot.role !== void 0 && existing.role === void 0) existing.role = ot.role;
|
|
9225
9248
|
if (existing.packaging === "mmtp") {
|
|
9226
9249
|
const mode = existing.mmtpMode ?? ot.mmtpMode;
|
|
9227
|
-
if (mode !== "
|
|
9250
|
+
if (mode !== "mfu") {
|
|
9228
9251
|
throw new Error(
|
|
9229
9252
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9230
9253
|
);
|
|
@@ -9261,7 +9284,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9261
9284
|
);
|
|
9262
9285
|
}
|
|
9263
9286
|
const mmtpMode = ot.mmtpMode;
|
|
9264
|
-
if (packaging === "mmtp" && mmtpMode !== "
|
|
9287
|
+
if (packaging === "mmtp" && mmtpMode !== "mfu") {
|
|
9265
9288
|
throw new Error(
|
|
9266
9289
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9267
9290
|
);
|
|
@@ -9562,8 +9585,8 @@ function u32(v) {
|
|
|
9562
9585
|
}
|
|
9563
9586
|
var KEYFRAME_FLAGS = 33554432;
|
|
9564
9587
|
var DELTA_FLAGS = 16842752;
|
|
9565
|
-
var
|
|
9566
|
-
var MAX_TRACK_ID =
|
|
9588
|
+
var UINT32_MAX2 = 4294967295;
|
|
9589
|
+
var MAX_TRACK_ID = UINT32_MAX2 - 1;
|
|
9567
9590
|
var INT32_MIN = -2147483648;
|
|
9568
9591
|
var INT32_MAX = 2147483647;
|
|
9569
9592
|
function assertTrackId(trackId, label) {
|
|
@@ -9572,8 +9595,8 @@ function assertTrackId(trackId, label) {
|
|
|
9572
9595
|
}
|
|
9573
9596
|
}
|
|
9574
9597
|
function assertTimescale(timescale, label) {
|
|
9575
|
-
if (!Number.isInteger(timescale) || timescale <= 0 || timescale >
|
|
9576
|
-
throw new RangeError(`${label} must be an integer in 1..${
|
|
9598
|
+
if (!Number.isInteger(timescale) || timescale <= 0 || timescale > UINT32_MAX2) {
|
|
9599
|
+
throw new RangeError(`${label} must be an integer in 1..${UINT32_MAX2}, got ${timescale}`);
|
|
9577
9600
|
}
|
|
9578
9601
|
}
|
|
9579
9602
|
function assertCompositionTimeOffsets(samples) {
|
|
@@ -12406,16 +12429,6 @@ var DeliveryGapEstimator = class {
|
|
|
12406
12429
|
|
|
12407
12430
|
// src/iso-block-locator.ts
|
|
12408
12431
|
var IsoBlockLocator = class _IsoBlockLocator {
|
|
12409
|
-
/** Known blocks and spans, in serial order of their start. */
|
|
12410
|
-
#blocks = [];
|
|
12411
|
-
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
12412
|
-
#held = /* @__PURE__ */ new Map();
|
|
12413
|
-
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
12414
|
-
#coverageEnd;
|
|
12415
|
-
#kMax;
|
|
12416
|
-
#retentionBlocks;
|
|
12417
|
-
#heldEvicted = 0;
|
|
12418
|
-
#newest;
|
|
12419
12432
|
/**
|
|
12420
12433
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
12421
12434
|
* @param retentionBlocks how many blocks behind the newest position the
|
|
@@ -12423,12 +12436,35 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12423
12436
|
* no locator exists without retention.
|
|
12424
12437
|
*/
|
|
12425
12438
|
constructor(kMax, retentionBlocks) {
|
|
12439
|
+
/** Known blocks and spans, in serial order of their start. */
|
|
12440
|
+
this.#blocks = [];
|
|
12441
|
+
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
12442
|
+
this.#held = /* @__PURE__ */ new Map();
|
|
12443
|
+
this.#heldEvicted = 0;
|
|
12444
|
+
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
12445
|
+
this.#holes = [];
|
|
12446
|
+
/**
|
|
12447
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
12448
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
12449
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
12450
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
12451
|
+
*/
|
|
12452
|
+
this.deferIncompleteGaps = false;
|
|
12426
12453
|
if (!Number.isSafeInteger(kMax) || kMax <= 0) {
|
|
12427
12454
|
throw new Error(`[IsoBlockLocator] maximum K must be a positive integer (got ${kMax})`);
|
|
12428
12455
|
}
|
|
12429
12456
|
this.#kMax = kMax;
|
|
12430
12457
|
this.#retentionBlocks = _IsoBlockLocator.#checkedRetention(retentionBlocks);
|
|
12431
12458
|
}
|
|
12459
|
+
#blocks;
|
|
12460
|
+
#held;
|
|
12461
|
+
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
12462
|
+
#coverageEnd;
|
|
12463
|
+
#kMax;
|
|
12464
|
+
#retentionBlocks;
|
|
12465
|
+
#heldEvicted;
|
|
12466
|
+
#newest;
|
|
12467
|
+
#holes;
|
|
12432
12468
|
static #checkedRetention(retentionBlocks) {
|
|
12433
12469
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
12434
12470
|
throw new Error(
|
|
@@ -12491,6 +12527,14 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12491
12527
|
}
|
|
12492
12528
|
return null;
|
|
12493
12529
|
}
|
|
12530
|
+
/** Number of pending holes. */
|
|
12531
|
+
get holeCount() {
|
|
12532
|
+
return this.#holes.length;
|
|
12533
|
+
}
|
|
12534
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
12535
|
+
blockEndingAt(end) {
|
|
12536
|
+
return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end);
|
|
12537
|
+
}
|
|
12494
12538
|
/** The known block or span starting exactly at `start`. */
|
|
12495
12539
|
blockAt(start) {
|
|
12496
12540
|
return this.#blocks.find((block) => block.start === start);
|
|
@@ -12513,6 +12557,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12513
12557
|
coversBetween(a, b) {
|
|
12514
12558
|
if (this.#coverageEnd === void 0) return false;
|
|
12515
12559
|
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true;
|
|
12560
|
+
const first = a + 1 >>> 0;
|
|
12561
|
+
const count = serial32Distance(a, b) - 1;
|
|
12562
|
+
if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false;
|
|
12516
12563
|
return serial32Precedes(b - 1 >>> 0, this.#coverageEnd);
|
|
12517
12564
|
}
|
|
12518
12565
|
/**
|
|
@@ -12542,6 +12589,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12542
12589
|
* known block (a different length, or an overlap with another block or a
|
|
12543
12590
|
* span) fails closed: the repair symbol is dropped and no block changes.
|
|
12544
12591
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
12592
|
+
* A block so far past `newest` that stating it would retire the position
|
|
12593
|
+
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
12594
|
+
* this is slightly conservative (retirement measures that block from its
|
|
12595
|
+
* last SS_ID), dropping up to one block-length of repairs past the horizon
|
|
12596
|
+
* until a source moves `newest`. Placing it would turn everything
|
|
12597
|
+
* between into a repair-less span and leave every real repair behind it
|
|
12598
|
+
* `stale`. Sources move `newest` (`hold`, `observe`), so after a real outage
|
|
12599
|
+
* the first source back brings the next repair inside the horizon; until one
|
|
12600
|
+
* arrives, a stream's repairs alone cannot pass it.
|
|
12545
12601
|
*/
|
|
12546
12602
|
placeRepair(start, length) {
|
|
12547
12603
|
if (!Number.isSafeInteger(length) || length <= 0 || length > this.#kMax) {
|
|
@@ -12560,6 +12616,22 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12560
12616
|
}
|
|
12561
12617
|
return { status: "placed", block: known, placed: [] };
|
|
12562
12618
|
}
|
|
12619
|
+
const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start));
|
|
12620
|
+
if (pending !== void 0) {
|
|
12621
|
+
if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
|
|
12622
|
+
return { status: "overlap", reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` };
|
|
12623
|
+
}
|
|
12624
|
+
this.#holes.splice(this.#holes.indexOf(pending), 1);
|
|
12625
|
+
const before = serial32Distance(pending.start, start);
|
|
12626
|
+
const afterStart = isoBlockEnd(start, length);
|
|
12627
|
+
const after = pending.length - before - length;
|
|
12628
|
+
if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false });
|
|
12629
|
+
if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false });
|
|
12630
|
+
const block2 = { start, length, span: false };
|
|
12631
|
+
const placed2 = this.#claim(block2);
|
|
12632
|
+
this.#blocks.push(block2);
|
|
12633
|
+
return { status: "placed", block: block2, placed: placed2 };
|
|
12634
|
+
}
|
|
12563
12635
|
for (const block2 of this.#blocks) {
|
|
12564
12636
|
if (isoBlockContains(block2.start, block2.length, start) || isoBlockContains(start, length, block2.start)) {
|
|
12565
12637
|
return {
|
|
@@ -12568,7 +12640,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12568
12640
|
};
|
|
12569
12641
|
}
|
|
12570
12642
|
}
|
|
12643
|
+
if (this.#newest !== void 0 && isoBlocksBehindLowerBound(this.#newest, start, this.#kMax) > this.#retentionBlocks) {
|
|
12644
|
+
return { status: "ahead", reason: `repair block ${start}+${length} is past the retention horizon ahead of ${this.#newest}` };
|
|
12645
|
+
}
|
|
12571
12646
|
let span;
|
|
12647
|
+
let hole;
|
|
12572
12648
|
if (this.#coverageEnd === void 0) {
|
|
12573
12649
|
for (const ssId of this.#held.keys()) {
|
|
12574
12650
|
if (serial32Precedes(ssId, start)) this.#held.delete(ssId);
|
|
@@ -12577,21 +12653,51 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12577
12653
|
} else if (serial32Precedes(start, this.#coverageEnd)) {
|
|
12578
12654
|
return { status: "stale", reason: `repair block ${start}+${length} precedes known coverage` };
|
|
12579
12655
|
} else if (start !== this.#coverageEnd) {
|
|
12580
|
-
const
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
span:
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12656
|
+
const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) };
|
|
12657
|
+
const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : void 0;
|
|
12658
|
+
if (lostSsId !== void 0) {
|
|
12659
|
+
const holeBlock = { ...gap, span: false };
|
|
12660
|
+
this.#holes.push(holeBlock);
|
|
12661
|
+
hole = { block: holeBlock, lostSsId };
|
|
12662
|
+
} else {
|
|
12663
|
+
const spanBlock = { ...gap, span: true };
|
|
12664
|
+
span = { block: spanBlock, placed: this.#claim(spanBlock) };
|
|
12665
|
+
this.#blocks.push(spanBlock);
|
|
12666
|
+
}
|
|
12587
12667
|
}
|
|
12588
12668
|
const block = { start, length, span: false };
|
|
12589
12669
|
const placed = this.#claim(block);
|
|
12590
12670
|
this.#blocks.push(block);
|
|
12591
12671
|
this.#coverageEnd = isoBlockEnd(start, length);
|
|
12592
12672
|
this.retireBehind(start);
|
|
12673
|
+
if (hole !== void 0) return { status: "placed", block, placed, hole };
|
|
12593
12674
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
12594
12675
|
}
|
|
12676
|
+
/**
|
|
12677
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
12678
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
12679
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
12680
|
+
*/
|
|
12681
|
+
closeHolesWithin(start, length) {
|
|
12682
|
+
const closed = [];
|
|
12683
|
+
for (const hole of [...this.#holes]) {
|
|
12684
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
12685
|
+
this.#holes.splice(this.#holes.indexOf(hole), 1);
|
|
12686
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
12687
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
12688
|
+
this.#blocks.push(spanBlock);
|
|
12689
|
+
}
|
|
12690
|
+
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
12691
|
+
}
|
|
12692
|
+
/** The highest SS_ID in the range no source is held for, or undefined when all are. */
|
|
12693
|
+
#highestMissing(start, length) {
|
|
12694
|
+
const steps = Math.min(length, this.#held.size + 1);
|
|
12695
|
+
for (let i = 1; i <= steps; i++) {
|
|
12696
|
+
const ssId = serial32Add(start, length - i);
|
|
12697
|
+
if (!this.#held.has(ssId)) return ssId;
|
|
12698
|
+
}
|
|
12699
|
+
return void 0;
|
|
12700
|
+
}
|
|
12595
12701
|
/**
|
|
12596
12702
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
12597
12703
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -12610,6 +12716,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12610
12716
|
this.#blocks.splice(i, 1);
|
|
12611
12717
|
}
|
|
12612
12718
|
}
|
|
12719
|
+
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
12720
|
+
const hole = this.#holes[i];
|
|
12721
|
+
const last = serial32Add(hole.start, hole.length - 1);
|
|
12722
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
|
|
12723
|
+
}
|
|
12613
12724
|
for (const ssId of [...this.#held.keys()]) {
|
|
12614
12725
|
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
|
|
12615
12726
|
}
|
|
@@ -12618,6 +12729,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12618
12729
|
/** Forget everything (publisher restart, track reset). */
|
|
12619
12730
|
reset() {
|
|
12620
12731
|
this.#blocks.length = 0;
|
|
12732
|
+
this.#holes.length = 0;
|
|
12621
12733
|
this.#held.clear();
|
|
12622
12734
|
this.#coverageEnd = void 0;
|
|
12623
12735
|
this.#newest = void 0;
|
|
@@ -12633,6 +12745,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12633
12745
|
return placed;
|
|
12634
12746
|
}
|
|
12635
12747
|
};
|
|
12748
|
+
function isoRangesOverlap(aStart, aLength, bStart, bLength) {
|
|
12749
|
+
return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength;
|
|
12750
|
+
}
|
|
12636
12751
|
|
|
12637
12752
|
// src/fec-state.ts
|
|
12638
12753
|
var MIN_INTERLEAVE_DEPTH_MS = 1;
|
|
@@ -12655,8 +12770,8 @@ function isPositiveSafeInteger2(value) {
|
|
|
12655
12770
|
}
|
|
12656
12771
|
function catalogDeclaresFec(fec) {
|
|
12657
12772
|
const block = recordOf2(fec);
|
|
12658
|
-
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
12659
|
-
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
12773
|
+
if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"])) return false;
|
|
12774
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block) && !catalogFecDeclaresUnconfigurableInstance(block);
|
|
12660
12775
|
}
|
|
12661
12776
|
function requireBoolean(value, field) {
|
|
12662
12777
|
if (typeof value !== "boolean") {
|
|
@@ -13143,6 +13258,7 @@ function decideGap(input) {
|
|
|
13143
13258
|
}
|
|
13144
13259
|
|
|
13145
13260
|
// src/fec-manager.ts
|
|
13261
|
+
var RS_MAX_BLOCK_SYMBOLS = 255;
|
|
13146
13262
|
var WORKER_ERROR_LOG_CAP = 5;
|
|
13147
13263
|
var WORKER_ERROR_KIND_CAP = 32;
|
|
13148
13264
|
var WORKER_ERROR_OVERFLOW_KIND = "other";
|
|
@@ -13257,6 +13373,11 @@ var FECManager = class _FECManager {
|
|
|
13257
13373
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
13258
13374
|
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
13259
13375
|
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
13376
|
+
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
13377
|
+
this.#heldLayerStates = /* @__PURE__ */ new Map();
|
|
13378
|
+
/** Streams whose FEC failed closed at runtime (fec-01 6.3.9). */
|
|
13379
|
+
this.#fecFailClosed = /* @__PURE__ */ new Map();
|
|
13380
|
+
this.#onFecFailClosed = null;
|
|
13260
13381
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
13261
13382
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
13262
13383
|
// which would falsely start new timeouts without this guard.
|
|
@@ -13377,12 +13498,17 @@ var FECManager = class _FECManager {
|
|
|
13377
13498
|
// per stream. Not only throws: the ordinary out-of-range case is detected by
|
|
13378
13499
|
// arithmetic and never throws at all.
|
|
13379
13500
|
this.#orderedHorizonWarnedFor = /* @__PURE__ */ new Set();
|
|
13380
|
-
// Newest block start (SS_Start)
|
|
13381
|
-
//
|
|
13501
|
+
// Newest block start (SS_Start) any symbol carried per stream and when: the
|
|
13502
|
+
// frontier isoSpanResolution reads.
|
|
13382
13503
|
this.#highestSbn = /* @__PURE__ */ new Map();
|
|
13504
|
+
// The same from source symbols alone: the frontier a source is judged
|
|
13505
|
+
// against for a discontinuity. Repairs ride their own group, which can run
|
|
13506
|
+
// blocks ahead of the media they protect.
|
|
13507
|
+
this.#sourceFrontiers = /* @__PURE__ */ new Map();
|
|
13383
13508
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
13384
13509
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
13385
13510
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
13511
|
+
this.#deferIsoGaps = false;
|
|
13386
13512
|
this.#isoRepairRefusedCount = 0;
|
|
13387
13513
|
this.#isoSourceOversizeCount = 0;
|
|
13388
13514
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -13397,8 +13523,8 @@ var FECManager = class _FECManager {
|
|
|
13397
13523
|
// rate-limited like the other per-symbol warns here. Cumulative.
|
|
13398
13524
|
this.#isoDecoderUnplacedRetireFailed = 0;
|
|
13399
13525
|
// The latest source symbol per stream that carried its MMTP
|
|
13400
|
-
// packet_sequence_number: the anchor that bounds how
|
|
13401
|
-
// producer can have
|
|
13526
|
+
// packet_sequence_number, by its own SS_ID: the anchor that bounds how far
|
|
13527
|
+
// the producer's SS_IDs can have moved before or after another source symbol.
|
|
13402
13528
|
this.#sourceAnchors = /* @__PURE__ */ new Map();
|
|
13403
13529
|
// Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
|
|
13404
13530
|
this.#packetEpochs = /* @__PURE__ */ new Map();
|
|
@@ -13457,6 +13583,14 @@ var FECManager = class _FECManager {
|
|
|
13457
13583
|
this.onBlockReclassified = null;
|
|
13458
13584
|
/** A video stream's classifier mode was established or changed. */
|
|
13459
13585
|
this.onClassifierMode = null;
|
|
13586
|
+
/**
|
|
13587
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
13588
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
13589
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
13590
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
13591
|
+
* for it, which it must be.
|
|
13592
|
+
*/
|
|
13593
|
+
this.#onUndelimitedLoss = null;
|
|
13460
13594
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
13461
13595
|
this.onBlockVanished = null;
|
|
13462
13596
|
/** A block reached a terminal state (completed, recovered, or failed). */
|
|
@@ -13498,6 +13632,9 @@ var FECManager = class _FECManager {
|
|
|
13498
13632
|
#ssbLengthConflictCount;
|
|
13499
13633
|
#blockRepairRsIds;
|
|
13500
13634
|
#blockRsbLengths;
|
|
13635
|
+
#heldLayerStates;
|
|
13636
|
+
#fecFailClosed;
|
|
13637
|
+
#onFecFailClosed;
|
|
13501
13638
|
#completedBlocks;
|
|
13502
13639
|
#terminalExpiryMs;
|
|
13503
13640
|
#terminalQueues;
|
|
@@ -13536,7 +13673,9 @@ var FECManager = class _FECManager {
|
|
|
13536
13673
|
#materializedBlocks;
|
|
13537
13674
|
#orderedHorizonWarnedFor;
|
|
13538
13675
|
#highestSbn;
|
|
13676
|
+
#sourceFrontiers;
|
|
13539
13677
|
#isoLocators;
|
|
13678
|
+
#deferIsoGaps;
|
|
13540
13679
|
#isoRepairRefusedCount;
|
|
13541
13680
|
#isoSourceOversizeCount;
|
|
13542
13681
|
#isoHeldEvictedCount;
|
|
@@ -13550,6 +13689,7 @@ var FECManager = class _FECManager {
|
|
|
13550
13689
|
#workerErrorCounts;
|
|
13551
13690
|
#decoderUnavailableEvents;
|
|
13552
13691
|
#repairSymbolSizeMismatchCount;
|
|
13692
|
+
#onUndelimitedLoss;
|
|
13553
13693
|
#encodeTrackName(catalogTrackName) {
|
|
13554
13694
|
let encoded = this.#encodedTrackNames.get(catalogTrackName);
|
|
13555
13695
|
if (encoded === void 0) {
|
|
@@ -14126,8 +14266,8 @@ var FECManager = class _FECManager {
|
|
|
14126
14266
|
// Deliberately one block tighter than deriveFecRetentionBlocks over the same
|
|
14127
14267
|
// inputs (that function's `+ 1`). Different question: the retention horizon
|
|
14128
14268
|
// asks how long the decoder still ACCEPTS symbols for a block, this asks how
|
|
14129
|
-
// many blocks a stream can
|
|
14130
|
-
//
|
|
14269
|
+
// many blocks a stream can jump ahead of its frontier before a source symbol
|
|
14270
|
+
// there is a discontinuity rather than loss (see #noteSbnSeen).
|
|
14131
14271
|
// The extra block of retention is slack for a block still being fed; a block
|
|
14132
14272
|
// nothing has been heard from does not get it. Not the units defect — but it
|
|
14133
14273
|
// is the next place the two can drift, so change both or neither.
|
|
@@ -14137,55 +14277,72 @@ var FECManager = class _FECManager {
|
|
|
14137
14277
|
}
|
|
14138
14278
|
/**
|
|
14139
14279
|
* Record that a symbol for block `sbn` (the block's SS_Start) arrived and
|
|
14140
|
-
* advance the stream's
|
|
14280
|
+
* advance the stream's frontiers, the newest block start seen.
|
|
14141
14281
|
*
|
|
14142
|
-
* A SOURCE symbol
|
|
14143
|
-
*
|
|
14144
|
-
*
|
|
14282
|
+
* A SOURCE symbol is judged against the newest source block alone: repairs
|
|
14283
|
+
* ride their own group, which can run blocks ahead of the media. One whose
|
|
14284
|
+
* block goes back further than the blocks this manager retains, or that
|
|
14285
|
+
* cannot have been sent before the source it lies behind, or that jumps
|
|
14286
|
+
* further than the stream could have produced since its last symbol, is a
|
|
14287
|
+
* source discontinuity, not loss. A repair symbol can only advance the
|
|
14145
14288
|
* frontier: a D-28 fetch legitimately answers for an old block, so it never
|
|
14146
14289
|
* signals a discontinuity.
|
|
14147
14290
|
*
|
|
14148
14291
|
* The producer closes a block at its Dth media-unit boundary OR when K
|
|
14149
14292
|
* source symbols filled it, so one interleave span can start several blocks
|
|
14150
|
-
* (every large keyframe does). What bounds a
|
|
14151
|
-
*
|
|
14152
|
-
*
|
|
14153
|
-
*
|
|
14154
|
-
* packet_sequence_number
|
|
14155
|
-
*
|
|
14156
|
-
*
|
|
14293
|
+
* (every large keyframe does). What bounds a jump is therefore packet
|
|
14294
|
+
* evidence, not a block rate: SS_ID advances by one per FEC source packet
|
|
14295
|
+
* (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
|
|
14296
|
+
* packet of the packet_id, so with both source symbols'
|
|
14297
|
+
* packet_sequence_number their SS_IDs (`ssId`, not their block starts,
|
|
14298
|
+
* which a repair-less span can put far behind) can move at most the packets
|
|
14299
|
+
* sent between them, in either direction, plus K of slack for sources lost
|
|
14300
|
+
* before a hop that renumbers packets. Without it, only the D-close rate is
|
|
14301
|
+
* known.
|
|
14157
14302
|
*
|
|
14158
14303
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
14159
14304
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
14160
14305
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
14161
14306
|
*/
|
|
14162
|
-
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber) {
|
|
14307
|
+
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
|
|
14163
14308
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
14164
14309
|
const now = performance.now();
|
|
14165
|
-
const previous = this.#highestSbn.get(streamKey);
|
|
14310
|
+
const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
|
|
14166
14311
|
const anchor = this.#sourceAnchors.get(streamKey);
|
|
14167
14312
|
const psn = symbol === "source" && packetSequenceNumber !== void 0 && Number.isSafeInteger(packetSequenceNumber) && packetSequenceNumber >= 0 && packetSequenceNumber <= 4294967295 ? packetSequenceNumber : void 0;
|
|
14168
14313
|
const anchorHere = () => {
|
|
14169
|
-
if (psn !== void 0 && (anchor === void 0 || !
|
|
14170
|
-
this.#sourceAnchors.set(streamKey, {
|
|
14314
|
+
if (psn !== void 0 && (anchor === void 0 || !serial32Precedes(ssId, anchor.ssId))) {
|
|
14315
|
+
this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14171
14316
|
}
|
|
14172
14317
|
};
|
|
14318
|
+
const advance = () => {
|
|
14319
|
+
const highest = this.#highestSbn.get(streamKey);
|
|
14320
|
+
if (highest === void 0 || this.#blockPrecedes(highest.sbn, sbn)) {
|
|
14321
|
+
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14322
|
+
}
|
|
14323
|
+
if (symbol === "source") this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14324
|
+
anchorHere();
|
|
14325
|
+
};
|
|
14173
14326
|
const discontinuity = () => {
|
|
14174
14327
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
14175
14328
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14329
|
+
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14176
14330
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
14177
|
-
else this.#sourceAnchors.set(streamKey, {
|
|
14331
|
+
else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14178
14332
|
this.onSourceDiscontinuity?.(packetId, catalogTrackName);
|
|
14179
14333
|
};
|
|
14180
14334
|
if (previous === void 0) {
|
|
14181
|
-
|
|
14182
|
-
anchorHere();
|
|
14335
|
+
advance();
|
|
14183
14336
|
return;
|
|
14184
14337
|
}
|
|
14185
14338
|
const config = this.#trackConfig(packetId);
|
|
14186
14339
|
const window2 = this.#liveWindowBlocks(config);
|
|
14340
|
+
const sentInOrder = (from, to) => {
|
|
14341
|
+
const sent = to.psn - from.psn >>> 0;
|
|
14342
|
+
return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
|
|
14343
|
+
};
|
|
14187
14344
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
14188
|
-
if (symbol === "source" && window2 !== null && this.#blocksBehind(sbn, previous.sbn, packetId) >
|
|
14345
|
+
if (symbol === "source" && window2 !== null && this.#blockPrecedes(sbn, previous.sbn) && (this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) || psn !== void 0 && anchor !== void 0 && serial32Precedes(ssId, anchor.ssId) && psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))) {
|
|
14189
14346
|
discontinuity();
|
|
14190
14347
|
return;
|
|
14191
14348
|
}
|
|
@@ -14195,9 +14352,8 @@ var FECManager = class _FECManager {
|
|
|
14195
14352
|
const missing = this.#blocksBehind(previous.sbn, sbn, packetId) - 1;
|
|
14196
14353
|
let plausible = true;
|
|
14197
14354
|
if (window2 !== null) {
|
|
14198
|
-
if (psn !== void 0 && anchor !== void 0 &&
|
|
14199
|
-
|
|
14200
|
-
plausible = sent <= 2147483647 && serial32Distance(anchor.sbn, sbn) <= sent + config.k;
|
|
14355
|
+
if (psn !== void 0 && anchor !== void 0 && serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
|
|
14356
|
+
plausible = sentInOrder(anchor, { ssId, psn });
|
|
14201
14357
|
} else {
|
|
14202
14358
|
plausible = missing <= window2 + Math.ceil((now - previous.atMs) / config.interleaveDepthMs);
|
|
14203
14359
|
}
|
|
@@ -14207,8 +14363,7 @@ var FECManager = class _FECManager {
|
|
|
14207
14363
|
discontinuity();
|
|
14208
14364
|
return;
|
|
14209
14365
|
}
|
|
14210
|
-
|
|
14211
|
-
anchorHere();
|
|
14366
|
+
advance();
|
|
14212
14367
|
}
|
|
14213
14368
|
/*
|
|
14214
14369
|
* Block order for one stream (BLO-35597 iso:5). A block is keyed by its
|
|
@@ -14525,8 +14680,10 @@ var FECManager = class _FECManager {
|
|
|
14525
14680
|
);
|
|
14526
14681
|
}
|
|
14527
14682
|
const hasCatalogTiming = _FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs });
|
|
14683
|
+
const algorithm = config.algorithm ?? previous.algorithm;
|
|
14528
14684
|
const next = {
|
|
14529
14685
|
blockProfile,
|
|
14686
|
+
...algorithm === void 0 ? {} : { algorithm },
|
|
14530
14687
|
k,
|
|
14531
14688
|
symbolSize: config.symbolSize != null && config.symbolSize > 0 ? config.symbolSize : previousTrack?.symbolSize ?? 0,
|
|
14532
14689
|
interleaveDepthMs: ownInterleaveDepthMs,
|
|
@@ -14534,8 +14691,19 @@ var FECManager = class _FECManager {
|
|
|
14534
14691
|
timeoutMs: config.timeoutMs ?? (timingChanged ? 0 : previous.timeoutMs ?? 0),
|
|
14535
14692
|
...(config.trackKind ?? previous.trackKind) === void 0 ? {} : { trackKind: config.trackKind ?? previous.trackKind },
|
|
14536
14693
|
...(config.codec ?? previous.codec) === void 0 ? {} : { codec: config.codec ?? previous.codec },
|
|
14537
|
-
...(config.geometry ?? previous.geometry) === void 0 ? {} : { geometry: config.geometry ?? previous.geometry }
|
|
14694
|
+
...(config.geometry ?? previous.geometry) === void 0 ? {} : { geometry: config.geometry ?? previous.geometry },
|
|
14695
|
+
...(config.repairLayers ?? previous.repairLayers) === void 0 ? {} : { repairLayers: config.repairLayers ?? previous.repairLayers },
|
|
14696
|
+
...(config.heldLayers ?? previous.heldLayers) === void 0 ? {} : { heldLayers: config.heldLayers ?? previous.heldLayers }
|
|
14538
14697
|
};
|
|
14698
|
+
if (
|
|
14699
|
+
// By content: a catalog refresh rebuilds equal arrays, and forgetting
|
|
14700
|
+
// the anchors on one would fail open.
|
|
14701
|
+
JSON.stringify(next.repairLayers) !== JSON.stringify(previous.repairLayers) || JSON.stringify(next.heldLayers) !== JSON.stringify(previous.heldLayers)
|
|
14702
|
+
) {
|
|
14703
|
+
for (const key of [...this.#heldLayerStates.keys()]) {
|
|
14704
|
+
if (this.#belongsToPacket(key, packetId)) this.#heldLayerStates.delete(key);
|
|
14705
|
+
}
|
|
14706
|
+
}
|
|
14539
14707
|
if (!hasCatalogTiming) {
|
|
14540
14708
|
next.timeoutMs = config.timeoutMs !== void 0 && config.timeoutMs > 0 ? config.timeoutMs : previousTrack !== void 0 && previousTrack.interleaveDepthMs === 0 ? previousTrack.timeoutMs : LOCAL_FEC_TIMEOUT_MS;
|
|
14541
14709
|
} else {
|
|
@@ -14770,6 +14938,8 @@ var FECManager = class _FECManager {
|
|
|
14770
14938
|
resetMap(this.#blockAuthoredLengths);
|
|
14771
14939
|
resetMap(this.#blockRepairRsIds);
|
|
14772
14940
|
resetMap(this.#blockRsbLengths);
|
|
14941
|
+
resetMap(this.#heldLayerStates);
|
|
14942
|
+
resetMap(this.#fecFailClosed);
|
|
14773
14943
|
resetMap(this.#blockPathCounts);
|
|
14774
14944
|
resetMap(this.#blockAnchorsMs);
|
|
14775
14945
|
resetMap(this.#blockCatalogTrackNames);
|
|
@@ -14792,6 +14962,7 @@ var FECManager = class _FECManager {
|
|
|
14792
14962
|
resetSet(this.#materializedBlocks);
|
|
14793
14963
|
resetMap(this.#resolvedBlockClasses);
|
|
14794
14964
|
resetMap(this.#highestSbn);
|
|
14965
|
+
resetMap(this.#sourceFrontiers);
|
|
14795
14966
|
resetMap(this.#isoLocators);
|
|
14796
14967
|
resetMap(this.#sourceAnchors);
|
|
14797
14968
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -14897,6 +15068,7 @@ var FECManager = class _FECManager {
|
|
|
14897
15068
|
dropMap(this.#orderedPendingBlocks);
|
|
14898
15069
|
dropMap(this.#resolvedBlockClasses);
|
|
14899
15070
|
dropMap(this.#highestSbn);
|
|
15071
|
+
dropMap(this.#sourceFrontiers);
|
|
14900
15072
|
dropMap(this.#isoLocators);
|
|
14901
15073
|
dropMap(this.#sourceAnchors);
|
|
14902
15074
|
dropMap(this.#classifiers);
|
|
@@ -14989,7 +15161,13 @@ var FECManager = class _FECManager {
|
|
|
14989
15161
|
if (isSourceSymbol && esi === 0) {
|
|
14990
15162
|
this.#startupPartialBlocks.delete(blockKey);
|
|
14991
15163
|
this.#startupAlignedPackets.add(streamKey);
|
|
14992
|
-
} else if (
|
|
15164
|
+
} else if (
|
|
15165
|
+
// A ready multicast repair opens a block the join has not seen yet, never
|
|
15166
|
+
// a join partial: its sources were refused, so its repairs alone open a
|
|
15167
|
+
// block that cannot decode and fails at its deadline, once per packet ID
|
|
15168
|
+
// per join (BLO-48308).
|
|
15169
|
+
isStartupPartial || !this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair
|
|
15170
|
+
) {
|
|
14993
15171
|
this.#markStartupPartial(blockKey);
|
|
14994
15172
|
return false;
|
|
14995
15173
|
}
|
|
@@ -15271,6 +15449,7 @@ var FECManager = class _FECManager {
|
|
|
15271
15449
|
let locator = this.#isoLocators.get(streamKey);
|
|
15272
15450
|
if (!locator) {
|
|
15273
15451
|
locator = new IsoBlockLocator(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId));
|
|
15452
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
15274
15453
|
this.#isoLocators.set(streamKey, locator);
|
|
15275
15454
|
}
|
|
15276
15455
|
return locator;
|
|
@@ -15314,6 +15493,10 @@ var FECManager = class _FECManager {
|
|
|
15314
15493
|
}
|
|
15315
15494
|
return blocks;
|
|
15316
15495
|
}
|
|
15496
|
+
/** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
|
|
15497
|
+
isoRetentionBlocksForPacket(packetId) {
|
|
15498
|
+
return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : void 0;
|
|
15499
|
+
}
|
|
15317
15500
|
/** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
|
|
15318
15501
|
isoSourceFits(packetId, packetLength) {
|
|
15319
15502
|
const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize;
|
|
@@ -15363,15 +15546,61 @@ var FECManager = class _FECManager {
|
|
|
15363
15546
|
}
|
|
15364
15547
|
return placement;
|
|
15365
15548
|
}
|
|
15366
|
-
if (placement.span !== void 0)
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15549
|
+
if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
|
|
15550
|
+
if (placement.hole !== void 0) {
|
|
15551
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName);
|
|
15552
|
+
const hole = placement.hole.block;
|
|
15553
|
+
const previous = locator.blockEndingAt(hole.start);
|
|
15554
|
+
const loss = {
|
|
15555
|
+
packetId,
|
|
15556
|
+
catalogTrackName,
|
|
15557
|
+
holeStart: hole.start,
|
|
15558
|
+
holeLength: hole.length,
|
|
15559
|
+
lostSsId: placement.hole.lostSsId,
|
|
15560
|
+
kMax: this.#trackConfig(packetId).k,
|
|
15561
|
+
...previous === void 0 ? {} : { previousBlockStart: previous.start }
|
|
15562
|
+
};
|
|
15563
|
+
this.#onUndelimitedLoss(loss);
|
|
15372
15564
|
}
|
|
15373
15565
|
return placement;
|
|
15374
15566
|
}
|
|
15567
|
+
/**
|
|
15568
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
15569
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
15570
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
15571
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
15572
|
+
* nobody to close it.
|
|
15573
|
+
*/
|
|
15574
|
+
setUndelimitedLossHandler(handler) {
|
|
15575
|
+
this.#onUndelimitedLoss = handler;
|
|
15576
|
+
this.#deferIsoGaps = handler !== null;
|
|
15577
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
15578
|
+
}
|
|
15579
|
+
/**
|
|
15580
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
15581
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
15582
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
15583
|
+
*/
|
|
15584
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
15585
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
15586
|
+
if (locator === void 0) return [];
|
|
15587
|
+
const spans = locator.closeHolesWithin(start, length);
|
|
15588
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName);
|
|
15589
|
+
return spans;
|
|
15590
|
+
}
|
|
15591
|
+
/**
|
|
15592
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
15593
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
15594
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
15595
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
15596
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
15597
|
+
* block.
|
|
15598
|
+
*/
|
|
15599
|
+
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
15600
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
15601
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length);
|
|
15602
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
15603
|
+
}
|
|
15375
15604
|
/**
|
|
15376
15605
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
15377
15606
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -15888,6 +16117,154 @@ var FECManager = class _FECManager {
|
|
|
15888
16117
|
}
|
|
15889
16118
|
return recovered;
|
|
15890
16119
|
}
|
|
16120
|
+
/**
|
|
16121
|
+
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
16122
|
+
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
16123
|
+
* block state unchanged. The router calls this before the repair places a
|
|
16124
|
+
* block or takes any other part in block bookkeeping. A RaptorQ track admits
|
|
16125
|
+
* every header that parsed (its RS_ID < RSB_length check is in the parser).
|
|
16126
|
+
*/
|
|
16127
|
+
admitRepairBlockLength(packetId, ssbLength, rsbLength, rsId) {
|
|
16128
|
+
if (rsId >= rsbLength) return false;
|
|
16129
|
+
if (this.#trackConfigs.get(packetId)?.algorithm !== "reed-solomon") return true;
|
|
16130
|
+
return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS;
|
|
16131
|
+
}
|
|
16132
|
+
/**
|
|
16133
|
+
* Whether a repair symbol of `byteLength` bytes is a valid member of a
|
|
16134
|
+
* `packetId` block: every repair symbol is exactly the track's T. A symbol of
|
|
16135
|
+
* any other size is counted on `repairSymbolSizeMismatches`, warned (rate
|
|
16136
|
+
* limited) and refused. The router calls this before the symbol takes any
|
|
16137
|
+
* other part in block state (placement, first-arrival dedup, completed-block
|
|
16138
|
+
* accounting), so a malformed repair is counted whatever its arrival order:
|
|
16139
|
+
* judged after dedup, one landing on an already-complete block, or behind a
|
|
16140
|
+
* valid copy from the other transport, was swallowed as a duplicate and never
|
|
16141
|
+
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
16142
|
+
* nothing here; its repair is dropped upstream as unreadable.
|
|
16143
|
+
*/
|
|
16144
|
+
admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, byteLength) {
|
|
16145
|
+
if (!this.#hasBlockProfile(packetId)) return false;
|
|
16146
|
+
const symbolSize = this.#trackConfig(packetId).symbolSize;
|
|
16147
|
+
if (symbolSize > 0 && byteLength !== symbolSize) {
|
|
16148
|
+
this.#repairSymbolSizeMismatchCount++;
|
|
16149
|
+
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
16150
|
+
console.warn(
|
|
16151
|
+
`[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
|
|
16152
|
+
);
|
|
16153
|
+
}
|
|
16154
|
+
return false;
|
|
16155
|
+
}
|
|
16156
|
+
return true;
|
|
16157
|
+
}
|
|
16158
|
+
/**
|
|
16159
|
+
* fec-01 6.3.9 receiver check, run on a repair packet after the 4.5 discard
|
|
16160
|
+
* and the size check, before it places a block. For each held layer i with
|
|
16161
|
+
* total B_i = O_i + P_i: the anchor is the earliest block, in SS_Start
|
|
16162
|
+
* serial order, whose repair carried RSB_length >= B_i. The source track
|
|
16163
|
+
* fails closed on (a) a packet on layer i's own repair track (i > 0) below
|
|
16164
|
+
* B_i, or (b) any packet of the instance at or after the anchor below B_i.
|
|
16165
|
+
* Blocks before the anchor (pre-append) stay valid at the previous total. A
|
|
16166
|
+
* packet on a repair track the catalog does not list is discarded and
|
|
16167
|
+
* anchors nothing. `repairTrackName` is the subscribed repair track, never
|
|
16168
|
+
* inferred from RS_ID; without it only (b) runs. Returns false when the
|
|
16169
|
+
* repair must be dropped, including every repair once the track failed.
|
|
16170
|
+
*/
|
|
16171
|
+
admitRepairLayerTotal(packetId, catalogTrackName, repairTrackName, ssStart, rsbLength) {
|
|
16172
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
16173
|
+
if (this.#fecFailClosed.has(streamKey)) return false;
|
|
16174
|
+
const config = this.#trackConfigs.get(packetId);
|
|
16175
|
+
const layers = config?.repairLayers;
|
|
16176
|
+
if (layers === void 0 || layers.length === 0) return true;
|
|
16177
|
+
if (repairTrackName !== void 0 && !layers.some((l) => l.repairTrackName === repairTrackName)) {
|
|
16178
|
+
return false;
|
|
16179
|
+
}
|
|
16180
|
+
let states = this.#heldLayerStates.get(streamKey);
|
|
16181
|
+
if (states === void 0) {
|
|
16182
|
+
const held = new Set(config.heldLayers ?? [0]);
|
|
16183
|
+
states = layers.filter((l) => held.has(l.layer)).map((l) => ({ layer: l.layer, repairTrackName: l.repairTrackName, total: l.rsIdOffset + l.repairSymbols }));
|
|
16184
|
+
this.#heldLayerStates.set(streamKey, states);
|
|
16185
|
+
}
|
|
16186
|
+
const horizon = this.#layerAnchorHorizon(packetId);
|
|
16187
|
+
const frontier = this.#sourceFrontiers.get(streamKey)?.sbn;
|
|
16188
|
+
const farAhead = frontier !== void 0 && serial32Precedes(frontier, ssStart) && serial32Distance(frontier, ssStart) > horizon;
|
|
16189
|
+
for (const state of states) {
|
|
16190
|
+
let code;
|
|
16191
|
+
if (farAhead) {
|
|
16192
|
+
if (rsbLength < state.total) {
|
|
16193
|
+
if (state.layer > 0 && repairTrackName === state.repairTrackName) code = "below_own_track_total";
|
|
16194
|
+
else if (state.anchor !== void 0 || state.settled) code = "below_anchored_total";
|
|
16195
|
+
}
|
|
16196
|
+
} else {
|
|
16197
|
+
if (state.newest === void 0 || serial32Precedes(state.newest, ssStart)) state.newest = ssStart;
|
|
16198
|
+
const stale = (s) => serial32Distance(s, state.newest) > horizon;
|
|
16199
|
+
if (state.latestBelow !== void 0 && stale(state.latestBelow)) {
|
|
16200
|
+
delete state.latestBelow;
|
|
16201
|
+
delete state.latestBelowRsb;
|
|
16202
|
+
}
|
|
16203
|
+
if (state.anchor !== void 0 && stale(state.anchor)) state.settled = true;
|
|
16204
|
+
if (rsbLength < state.total) {
|
|
16205
|
+
if (state.layer > 0 && repairTrackName === state.repairTrackName) code = "below_own_track_total";
|
|
16206
|
+
else if (stale(ssStart)) continue;
|
|
16207
|
+
else if (state.settled || state.anchor !== void 0 && !serial32Precedes(ssStart, state.anchor)) code = "below_anchored_total";
|
|
16208
|
+
else if (state.latestBelow === void 0 || serial32Precedes(state.latestBelow, ssStart)) {
|
|
16209
|
+
state.latestBelow = ssStart;
|
|
16210
|
+
state.latestBelowRsb = rsbLength;
|
|
16211
|
+
}
|
|
16212
|
+
} else if (!state.settled && !stale(ssStart)) {
|
|
16213
|
+
if (state.anchor === void 0 || serial32Precedes(ssStart, state.anchor)) state.anchor = ssStart;
|
|
16214
|
+
if (state.latestBelow !== void 0 && !serial32Precedes(state.latestBelow, state.anchor)) {
|
|
16215
|
+
code = "below_anchored_total";
|
|
16216
|
+
ssStart = state.latestBelow;
|
|
16217
|
+
rsbLength = state.latestBelowRsb;
|
|
16218
|
+
}
|
|
16219
|
+
}
|
|
16220
|
+
}
|
|
16221
|
+
if (code !== void 0) {
|
|
16222
|
+
const reason = {
|
|
16223
|
+
code,
|
|
16224
|
+
layer: state.layer,
|
|
16225
|
+
total: state.total,
|
|
16226
|
+
rsbLength,
|
|
16227
|
+
ssStart,
|
|
16228
|
+
...state.anchor === void 0 ? {} : { anchor: state.anchor }
|
|
16229
|
+
};
|
|
16230
|
+
this.#fecFailClosed.set(streamKey, reason);
|
|
16231
|
+
this.#onFecFailClosed?.({ ...reason, packetId, catalogTrackName });
|
|
16232
|
+
console.warn(
|
|
16233
|
+
`[FECManager] FEC failed closed (fec-01 6.3.9) packetId=${packetId} track=${catalogTrackName ?? "-"}: ${JSON.stringify(reason)}`
|
|
16234
|
+
);
|
|
16235
|
+
return false;
|
|
16236
|
+
}
|
|
16237
|
+
}
|
|
16238
|
+
return true;
|
|
16239
|
+
}
|
|
16240
|
+
/**
|
|
16241
|
+
* How far (in SS_Start symbols) behind the newest block a 6.3.9 anchor or
|
|
16242
|
+
* below-total block can still matter: the iso locator's retention in blocks
|
|
16243
|
+
* times K, capped at 2^30 so compared serials stay inside one half-window.
|
|
16244
|
+
*/
|
|
16245
|
+
#layerAnchorHorizon(packetId) {
|
|
16246
|
+
const cap = 1073741824;
|
|
16247
|
+
let blocks;
|
|
16248
|
+
try {
|
|
16249
|
+
blocks = this.isoRetentionBlocksForPacket(packetId);
|
|
16250
|
+
} catch {
|
|
16251
|
+
blocks = void 0;
|
|
16252
|
+
}
|
|
16253
|
+
const k = this.#trackConfigs.get(packetId)?.k ?? 0;
|
|
16254
|
+
return blocks === void 0 || k <= 0 ? cap : Math.min(cap, blocks * k);
|
|
16255
|
+
}
|
|
16256
|
+
/**
|
|
16257
|
+
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), once,
|
|
16258
|
+
* when it does; null stops reporting. The player wiring forwards it to
|
|
16259
|
+
* CmcdProducer.updateFecFailClosed.
|
|
16260
|
+
*/
|
|
16261
|
+
setFecFailClosedHandler(handler) {
|
|
16262
|
+
this.#onFecFailClosed = handler;
|
|
16263
|
+
}
|
|
16264
|
+
/** The runtime fail-closed reason of a stream's FEC (fec-01 6.3.9), if any. */
|
|
16265
|
+
fecFailClosedReason(packetId, catalogTrackName) {
|
|
16266
|
+
return this.#fecFailClosed.get(this.#streamKey(packetId, catalogTrackName));
|
|
16267
|
+
}
|
|
15891
16268
|
/**
|
|
15892
16269
|
* Feed a repair symbol to the WASM FEC decoder.
|
|
15893
16270
|
*
|
|
@@ -15899,16 +16276,7 @@ var FECManager = class _FECManager {
|
|
|
15899
16276
|
this.#fecStats.repairPackets++;
|
|
15900
16277
|
this.#statsForPacket(packetId).repairPackets++;
|
|
15901
16278
|
if (!this.#hasBlockProfile(packetId)) return null;
|
|
15902
|
-
|
|
15903
|
-
if (symbolSize > 0 && repairData.byteLength !== symbolSize) {
|
|
15904
|
-
this.#repairSymbolSizeMismatchCount++;
|
|
15905
|
-
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
15906
|
-
console.warn(
|
|
15907
|
-
`[FECManager] Dropping repair symbol with invalid size: got ${repairData.byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
|
|
15908
|
-
);
|
|
15909
|
-
}
|
|
15910
|
-
return null;
|
|
15911
|
-
}
|
|
16279
|
+
if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null;
|
|
15912
16280
|
const fecData = repairData;
|
|
15913
16281
|
const k = this.#trackConfig(packetId).k;
|
|
15914
16282
|
const block = this.#isoLocatorFor(packetId, catalogTrackName).blockAt(ssStart);
|
|
@@ -16061,7 +16429,14 @@ var FECManager = class _FECManager {
|
|
|
16061
16429
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
16062
16430
|
const k = trackConfig.k;
|
|
16063
16431
|
if (this.#completedBlocks.has(key)) return;
|
|
16064
|
-
this.#noteSbnSeen(
|
|
16432
|
+
this.#noteSbnSeen(
|
|
16433
|
+
sbn,
|
|
16434
|
+
packetId,
|
|
16435
|
+
catalogTrackName,
|
|
16436
|
+
"source",
|
|
16437
|
+
evidence.packetSequenceNumber,
|
|
16438
|
+
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
|
|
16439
|
+
);
|
|
16065
16440
|
const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
|
|
16066
16441
|
if (Number.isInteger(esi) && esi >= authoredLength) {
|
|
16067
16442
|
this.#failBlock(sbn, packetId, catalogTrackName);
|
|
@@ -16288,6 +16663,8 @@ var FECManager = class _FECManager {
|
|
|
16288
16663
|
this.#blockAuthoredLengths.clear();
|
|
16289
16664
|
this.#blockRepairRsIds.clear();
|
|
16290
16665
|
this.#blockRsbLengths.clear();
|
|
16666
|
+
this.#heldLayerStates.clear();
|
|
16667
|
+
this.#fecFailClosed.clear();
|
|
16291
16668
|
this.#completedBlocks.clear();
|
|
16292
16669
|
this.#cleanlyCompletedBlocks.clear();
|
|
16293
16670
|
this.#repairRequestedBlocks.clear();
|
|
@@ -16312,6 +16689,7 @@ var FECManager = class _FECManager {
|
|
|
16312
16689
|
this.#repairedBlocks.clear();
|
|
16313
16690
|
this.#materializedBlocks.clear();
|
|
16314
16691
|
this.#highestSbn.clear();
|
|
16692
|
+
this.#sourceFrontiers.clear();
|
|
16315
16693
|
this.#isoLocators.clear();
|
|
16316
16694
|
this.#sourceAnchors.clear();
|
|
16317
16695
|
this.#trackConfigs.clear();
|
|
@@ -17401,6 +17779,7 @@ function isFmp4Box(data) {
|
|
|
17401
17779
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
17402
17780
|
return FMPU_BOX_TYPES.has(type);
|
|
17403
17781
|
}
|
|
17782
|
+
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
17404
17783
|
var MmtpContainerParser = class _MmtpContainerParser {
|
|
17405
17784
|
constructor(config) {
|
|
17406
17785
|
this.#tracks = /* @__PURE__ */ new Map();
|
|
@@ -17459,6 +17838,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17459
17838
|
* reordering into the parser. */
|
|
17460
17839
|
this.#reliableMoqStartupGate = /* @__PURE__ */ new Map();
|
|
17461
17840
|
this.#disposed = false;
|
|
17841
|
+
this.#replayingAwaitingTiming = false;
|
|
17462
17842
|
this.#fedObjects = 0;
|
|
17463
17843
|
this.#reassemblerFragmentsFed = 0;
|
|
17464
17844
|
this.#reassemblerDataUnitsReturned = 0;
|
|
@@ -17551,6 +17931,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17551
17931
|
#reorderStats;
|
|
17552
17932
|
#reliableMoqStartupGate;
|
|
17553
17933
|
#disposed;
|
|
17934
|
+
#replayingAwaitingTiming;
|
|
17554
17935
|
#fedObjects;
|
|
17555
17936
|
#reassemblerFragmentsFed;
|
|
17556
17937
|
#reassemblerDataUnitsReturned;
|
|
@@ -17800,7 +18181,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17800
18181
|
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
17801
18182
|
*/
|
|
17802
18183
|
#drop(reason) {
|
|
17803
|
-
this.#
|
|
18184
|
+
if (this.#replayingAwaitingTiming) this.#countDeferredOutcome(reason);
|
|
18185
|
+
else this.#countOutcome(`drop:${reason}`);
|
|
17804
18186
|
return null;
|
|
17805
18187
|
}
|
|
17806
18188
|
get reorderDiagnostics() {
|
|
@@ -17823,6 +18205,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17823
18205
|
for (const combiner of this.#sampleCombiners.values()) {
|
|
17824
18206
|
combiner.cleanupTimeouts(timeoutMs);
|
|
17825
18207
|
}
|
|
18208
|
+
const now = Date.now();
|
|
18209
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
18210
|
+
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
18211
|
+
awaitingTiming.shift();
|
|
18212
|
+
}
|
|
18213
|
+
}
|
|
17826
18214
|
}
|
|
17827
18215
|
/**
|
|
17828
18216
|
* Phase 1 of two-phase parsing. Returns structured header info for FEC feeding.
|
|
@@ -17903,7 +18291,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17903
18291
|
byteLength: packet.byteLength
|
|
17904
18292
|
};
|
|
17905
18293
|
}
|
|
17906
|
-
if (info.fecPayloadId !== null && this.#sourceSymbolCb) {
|
|
18294
|
+
if (info.fecPayloadId !== null && this.#sourceSymbolCb && !this.#replayingAwaitingTiming) {
|
|
17907
18295
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
17908
18296
|
try {
|
|
17909
18297
|
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
@@ -17951,6 +18339,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17951
18339
|
}
|
|
17952
18340
|
return this.#drop("fragment-timing-refused");
|
|
17953
18341
|
}
|
|
18342
|
+
this.#replayAwaitingTiming(streamKey, resolver2);
|
|
17954
18343
|
return {
|
|
17955
18344
|
kind: "fragment",
|
|
17956
18345
|
packet: info,
|
|
@@ -17974,7 +18363,18 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17974
18363
|
mfuDuHeader.movieFragmentSequenceNumber,
|
|
17975
18364
|
mfuDuHeader.sampleNumber
|
|
17976
18365
|
);
|
|
17977
|
-
if (!headTiming)
|
|
18366
|
+
if (!headTiming) {
|
|
18367
|
+
this.#awaitTiming(streamKey, {
|
|
18368
|
+
packet,
|
|
18369
|
+
options,
|
|
18370
|
+
parsed,
|
|
18371
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
18372
|
+
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
18373
|
+
sampleNumber: mfuDuHeader.sampleNumber,
|
|
18374
|
+
arrivedAt: Date.now()
|
|
18375
|
+
});
|
|
18376
|
+
return this.#drop("mfu-sample-timing-missing");
|
|
18377
|
+
}
|
|
17978
18378
|
const offset = mfuDuHeader.offset;
|
|
17979
18379
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
17980
18380
|
return this.#drop("mfu-offset-out-of-range");
|
|
@@ -18050,16 +18450,17 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18050
18450
|
const sampleNumber = assembled.sampleNumber;
|
|
18051
18451
|
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
18052
18452
|
return this.#drop("assembled-identity-missing");
|
|
18053
|
-
|
|
18453
|
+
const assembledTiming = resolver.sampleTiming(
|
|
18054
18454
|
assembled.mpuSequenceNumber,
|
|
18055
18455
|
movieFragmentSequenceNumber,
|
|
18056
18456
|
sampleNumber
|
|
18057
|
-
)
|
|
18457
|
+
);
|
|
18458
|
+
if (!assembledTiming) return this.#drop("assembled-timing-missing");
|
|
18058
18459
|
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
18059
18460
|
return this.#drop("assembled-mpu-mismatch");
|
|
18060
18461
|
let combined;
|
|
18061
18462
|
try {
|
|
18062
|
-
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled);
|
|
18463
|
+
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled, assembledTiming.size);
|
|
18063
18464
|
} catch (error) {
|
|
18064
18465
|
if (!(error instanceof SampleCombineError)) throw error;
|
|
18065
18466
|
console.warn(
|
|
@@ -18368,9 +18769,37 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18368
18769
|
if (existing) return existing.resolver;
|
|
18369
18770
|
if (!create) return null;
|
|
18370
18771
|
const resolver = new IsoBmffTimingResolver(this.#maxPendingTimingSamples);
|
|
18371
|
-
this.#timingStreams.set(streamKey, { packetId, resolver });
|
|
18772
|
+
this.#timingStreams.set(streamKey, { packetId, resolver, awaitingTiming: [] });
|
|
18372
18773
|
return resolver;
|
|
18373
18774
|
}
|
|
18775
|
+
#awaitTiming(streamKey, head) {
|
|
18776
|
+
const awaitingTiming = this.#timingStreams.get(streamKey)?.awaitingTiming;
|
|
18777
|
+
if (!awaitingTiming) return;
|
|
18778
|
+
awaitingTiming.push(head);
|
|
18779
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) awaitingTiming.shift();
|
|
18780
|
+
}
|
|
18781
|
+
/**
|
|
18782
|
+
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
18783
|
+
* FT=1 can be an FEC recovery landing after its sample's FI=1, and neither
|
|
18784
|
+
* FEC path routes a source symbol that already arrived a second time.
|
|
18785
|
+
*/
|
|
18786
|
+
#replayAwaitingTiming(streamKey, resolver) {
|
|
18787
|
+
const state = this.#timingStreams.get(streamKey);
|
|
18788
|
+
if (!state || state.awaitingTiming.length === 0) return;
|
|
18789
|
+
const ready = state.awaitingTiming.filter((head) => resolver.sampleTiming(
|
|
18790
|
+
head.mpuSequenceNumber,
|
|
18791
|
+
head.movieFragmentSequenceNumber,
|
|
18792
|
+
head.sampleNumber
|
|
18793
|
+
));
|
|
18794
|
+
if (ready.length === 0) return;
|
|
18795
|
+
state.awaitingTiming = state.awaitingTiming.filter((head) => !ready.includes(head));
|
|
18796
|
+
this.#replayingAwaitingTiming = true;
|
|
18797
|
+
try {
|
|
18798
|
+
for (const head of ready) this.#feed(head.packet, head.options, head.parsed);
|
|
18799
|
+
} finally {
|
|
18800
|
+
this.#replayingAwaitingTiming = false;
|
|
18801
|
+
}
|
|
18802
|
+
}
|
|
18374
18803
|
#dropTimingStream(streamKey) {
|
|
18375
18804
|
const state = this.#timingStreams.get(streamKey);
|
|
18376
18805
|
if (!state) return;
|
|
@@ -18975,6 +19404,18 @@ var MmtpRouter = class {
|
|
|
18975
19404
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
18976
19405
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
18977
19406
|
#latestVideoSeqByStream = /* @__PURE__ */ new Map();
|
|
19407
|
+
/**
|
|
19408
|
+
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
19409
|
+
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
19410
|
+
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
19411
|
+
*/
|
|
19412
|
+
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
19413
|
+
/**
|
|
19414
|
+
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
19415
|
+
* not parsed, typically because its overlap copy was parsed first
|
|
19416
|
+
* (BLO-49179). The next video keyframe emitted on the stream consumes it.
|
|
19417
|
+
*/
|
|
19418
|
+
#multicastRapTwinByStream = /* @__PURE__ */ new Set();
|
|
18978
19419
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18979
19420
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18980
19421
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -19049,11 +19490,14 @@ var MmtpRouter = class {
|
|
|
19049
19490
|
*/
|
|
19050
19491
|
#onPublisherRestart;
|
|
19051
19492
|
#publisherRestarts = 0;
|
|
19493
|
+
#restampedRecoveredSeqs = 0;
|
|
19052
19494
|
/** Inits delivered with no onTrackInit handler for their packetId (MOQT-01). */
|
|
19053
19495
|
#unmappedInitDeliveries = 0;
|
|
19054
19496
|
// FEC Payload IDs left unread because their (owner) packetId had no
|
|
19055
19497
|
// configured fec.blockProfile (see #noteUnreadableFecPayloadId).
|
|
19056
19498
|
#fecPayloadIdsWithoutProfile = 0;
|
|
19499
|
+
// Repair packets discarded by the fec-01 4.5 block-length rule.
|
|
19500
|
+
#repairBlockLengthDiscards = 0;
|
|
19057
19501
|
/** The staged in-place stream switch, if any (stageStreamSwitch). */
|
|
19058
19502
|
#staged = null;
|
|
19059
19503
|
#disposed = false;
|
|
@@ -19107,6 +19551,12 @@ var MmtpRouter = class {
|
|
|
19107
19551
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName }
|
|
19108
19552
|
};
|
|
19109
19553
|
if (meta.source) frameMeta.source = meta.source;
|
|
19554
|
+
if (isVideo && frameMeta.keyframe) {
|
|
19555
|
+
const twinSeen = this.#multicastRapTwinByStream.delete(
|
|
19556
|
+
this.#mediaStreamKey(packetId, frameMeta.catalogTrackName)
|
|
19557
|
+
);
|
|
19558
|
+
if (twinSeen && frameMeta.source === "moq") frameMeta.source = "multicast";
|
|
19559
|
+
}
|
|
19110
19560
|
if (meta.deliveryProvenance !== void 0)
|
|
19111
19561
|
frameMeta.deliveryProvenance = meta.deliveryProvenance;
|
|
19112
19562
|
if (meta.recovered) frameMeta.recovered = true;
|
|
@@ -19269,6 +19719,14 @@ var MmtpRouter = class {
|
|
|
19269
19719
|
get publisherRestartCount() {
|
|
19270
19720
|
return this.#publisherRestarts;
|
|
19271
19721
|
}
|
|
19722
|
+
/**
|
|
19723
|
+
* FEC-recovered source symbols whose reconstructed header named a
|
|
19724
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to:
|
|
19725
|
+
* a hop re-stamped the sequence after the sender protected the packet.
|
|
19726
|
+
*/
|
|
19727
|
+
get restampedRecoveredSequenceCount() {
|
|
19728
|
+
return this.#restampedRecoveredSeqs;
|
|
19729
|
+
}
|
|
19272
19730
|
/**
|
|
19273
19731
|
* Packets whose Source or Repair FEC Payload ID was left unread because
|
|
19274
19732
|
* their (owner) packetId had no configured `fec.blockProfile`: FEC not
|
|
@@ -19280,6 +19738,14 @@ var MmtpRouter = class {
|
|
|
19280
19738
|
get fecPayloadIdsWithoutProfile() {
|
|
19281
19739
|
return this.#fecPayloadIdsWithoutProfile;
|
|
19282
19740
|
}
|
|
19741
|
+
/**
|
|
19742
|
+
* Repair packets discarded at admission by the fec-01 4.5 rule (RS_ID not
|
|
19743
|
+
* below RSB_length, or a reed-solomon SSB_length + RSB_length above 255),
|
|
19744
|
+
* before they touched any block state.
|
|
19745
|
+
*/
|
|
19746
|
+
get repairBlockLengthDiscards() {
|
|
19747
|
+
return this.#repairBlockLengthDiscards;
|
|
19748
|
+
}
|
|
19283
19749
|
get reassembler() {
|
|
19284
19750
|
return this.#parser.reassembler;
|
|
19285
19751
|
}
|
|
@@ -19658,13 +20124,13 @@ var MmtpRouter = class {
|
|
|
19658
20124
|
* Feed a repair packet from MoQ (reliable QUIC) — parses MMTP repair
|
|
19659
20125
|
* header and delegates to FECManager for FEC recovery.
|
|
19660
20126
|
*/
|
|
19661
|
-
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName) {
|
|
20127
|
+
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName) {
|
|
19662
20128
|
if (this.#disposed) return;
|
|
19663
20129
|
this.#withDeferredFecPokes(() => {
|
|
19664
|
-
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName);
|
|
20130
|
+
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName);
|
|
19665
20131
|
});
|
|
19666
20132
|
}
|
|
19667
|
-
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName) {
|
|
20133
|
+
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName) {
|
|
19668
20134
|
let header;
|
|
19669
20135
|
try {
|
|
19670
20136
|
header = parseMMTPHeader(packet);
|
|
@@ -19695,7 +20161,7 @@ var MmtpRouter = class {
|
|
|
19695
20161
|
this.#noteUnreadableFecPayloadId(ownerPacketId, "repair");
|
|
19696
20162
|
return;
|
|
19697
20163
|
}
|
|
19698
|
-
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed, "moq");
|
|
20164
|
+
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed, "moq", repairTrackName);
|
|
19699
20165
|
}
|
|
19700
20166
|
}
|
|
19701
20167
|
// ── Packet FEC geometry and block profile ───────────────────────
|
|
@@ -19777,13 +20243,25 @@ var MmtpRouter = class {
|
|
|
19777
20243
|
* the repair, the order they had on the wire, so a loss-free block completes
|
|
19778
20244
|
* clean on its repair. A repair contradicting a known block is dropped.
|
|
19779
20245
|
*/
|
|
19780
|
-
#handleIsoRepair(ownerPacketId, catalogTrackName, repair, source) {
|
|
20246
|
+
#handleIsoRepair(ownerPacketId, catalogTrackName, repair, source, repairTrackName) {
|
|
19781
20247
|
const fec = this.#fecManager;
|
|
19782
20248
|
if (!fec?.placeIsoRepair) {
|
|
19783
20249
|
throw new Error(
|
|
19784
20250
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`
|
|
19785
20251
|
);
|
|
19786
20252
|
}
|
|
20253
|
+
if (fec.admitRepairBlockLength && !fec.admitRepairBlockLength(ownerPacketId, repair.ssbLength, repair.rsbLength, repair.rsId)) {
|
|
20254
|
+
this.#repairBlockLengthDiscards++;
|
|
20255
|
+
return;
|
|
20256
|
+
}
|
|
20257
|
+
if (fec.admitRepairSymbolSize && !fec.admitRepairSymbolSize(
|
|
20258
|
+
ownerPacketId,
|
|
20259
|
+
repair.ssStart,
|
|
20260
|
+
repair.ssbLength,
|
|
20261
|
+
repair.rsId,
|
|
20262
|
+
repair.symbolData.byteLength
|
|
20263
|
+
)) return;
|
|
20264
|
+
if (fec.admitRepairLayerTotal && !fec.admitRepairLayerTotal(ownerPacketId, catalogTrackName, repairTrackName, repair.ssStart, repair.rsbLength)) return;
|
|
19787
20265
|
const placement = fec.placeIsoRepair(ownerPacketId, catalogTrackName, repair.ssStart, repair.ssbLength);
|
|
19788
20266
|
if (placement.status !== "placed") return;
|
|
19789
20267
|
const blockStart = placement.block.start;
|
|
@@ -19818,6 +20296,17 @@ var MmtpRouter = class {
|
|
|
19818
20296
|
this.#routeRecoveredBlock(blockStart, recovered, ownerPacketId, catalogTrackName);
|
|
19819
20297
|
}
|
|
19820
20298
|
}
|
|
20299
|
+
/**
|
|
20300
|
+
* The range repair FETCH for an undelimited hole ended (draft-ramadan-moq-fec
|
|
20301
|
+
* §7.5): what no repair stated becomes repair-less spans, whose held sources
|
|
20302
|
+
* are fed exactly as a span a repair closed.
|
|
20303
|
+
*/
|
|
20304
|
+
closeIsoHoles(ownerPacketId, catalogTrackName, start, length) {
|
|
20305
|
+
const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
|
|
20306
|
+
for (const span of spans) {
|
|
20307
|
+
this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
|
|
20308
|
+
}
|
|
20309
|
+
}
|
|
19821
20310
|
/**
|
|
19822
20311
|
* Feed iso-ssbg1-v1 sources a repair just placed, in SS_ID order, exactly as
|
|
19823
20312
|
* a first-arrival source is fed once its block is known: transport
|
|
@@ -19913,6 +20402,8 @@ var MmtpRouter = class {
|
|
|
19913
20402
|
this.#trackSynced.delete(streamKey);
|
|
19914
20403
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
19915
20404
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
20405
|
+
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
20406
|
+
this.#multicastRapTwinByStream.delete(streamKey);
|
|
19916
20407
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
19917
20408
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
19918
20409
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -20683,6 +21174,12 @@ var MmtpRouter = class {
|
|
|
20683
21174
|
} else if (fecUnreadable && info.fecPayloadId) {
|
|
20684
21175
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
20685
21176
|
}
|
|
21177
|
+
if (fecPayloadId && !overlapCopy) {
|
|
21178
|
+
this.#ssIdSeqOffsetByStream.set(
|
|
21179
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
21180
|
+
fecPayloadId.ssId - info.sequenceNumber >>> 0
|
|
21181
|
+
);
|
|
21182
|
+
}
|
|
20686
21183
|
if (!this.#fecManager || !info.fecPayloadId || parseSourceSymbol) {
|
|
20687
21184
|
if (this.#fecManager && info.fecPayloadId) {
|
|
20688
21185
|
duplicates.parsedSymbols.add(info.fecPayloadId.ssId);
|
|
@@ -20705,6 +21202,10 @@ var MmtpRouter = class {
|
|
|
20705
21202
|
// An FEC source frame is anchored by its own SS_ID (C.5.2).
|
|
20706
21203
|
...fecSource && fecPayloadId ? { fecSbn: fecPayloadId.ssId } : {}
|
|
20707
21204
|
}, parsed);
|
|
21205
|
+
} else if (source === "multicast" && info.rapFlag) {
|
|
21206
|
+
this.#multicastRapTwinByStream.add(
|
|
21207
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName)
|
|
21208
|
+
);
|
|
20708
21209
|
}
|
|
20709
21210
|
if (this.#classifyPacketId(info.packetId) === null) return;
|
|
20710
21211
|
if (this.#fecManager && fecPayloadId && coords && sourceSymbolAccepted && sourceSymbolTrackable) {
|
|
@@ -21259,6 +21760,20 @@ var MmtpRouter = class {
|
|
|
21259
21760
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
21260
21761
|
if (ownerPacketId == null) return;
|
|
21261
21762
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
21763
|
+
const ssIdSeqOffset = this.#ssIdSeqOffsetByStream.get(
|
|
21764
|
+
this.#mediaStreamKey(ownerPacketId, catalogTrackName)
|
|
21765
|
+
);
|
|
21766
|
+
if (ssIdSeqOffset !== void 0) {
|
|
21767
|
+
result = {
|
|
21768
|
+
...result,
|
|
21769
|
+
symbols: result.symbols.map((sym) => {
|
|
21770
|
+
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
21771
|
+
if (wire === sym.packetSequenceNumber) return sym;
|
|
21772
|
+
this.#restampedRecoveredSeqs++;
|
|
21773
|
+
return { ...sym, packetSequenceNumber: wire };
|
|
21774
|
+
})
|
|
21775
|
+
};
|
|
21776
|
+
}
|
|
21262
21777
|
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
21263
21778
|
const deliveryProvenance = this.#fecManager?.blockDeliveryProvenance?.(
|
|
21264
21779
|
blockId,
|
|
@@ -21999,48 +22514,6 @@ function createWasmMmtpContainerParser(config) {
|
|
|
21999
22514
|
});
|
|
22000
22515
|
}
|
|
22001
22516
|
|
|
22002
|
-
// src/fec-codec.ts
|
|
22003
|
-
var NoneCodec = class {
|
|
22004
|
-
constructor() {
|
|
22005
|
-
this.algorithm = "none";
|
|
22006
|
-
}
|
|
22007
|
-
addSymbol(_blockId, _symbolId, data, _isRepair) {
|
|
22008
|
-
return data;
|
|
22009
|
-
}
|
|
22010
|
-
configure(_params) {
|
|
22011
|
-
}
|
|
22012
|
-
cleanup(_now) {
|
|
22013
|
-
return new Uint8Array(0);
|
|
22014
|
-
}
|
|
22015
|
-
};
|
|
22016
|
-
function createFecCodec(algorithm) {
|
|
22017
|
-
switch (algorithm) {
|
|
22018
|
-
case "none":
|
|
22019
|
-
return new NoneCodec();
|
|
22020
|
-
case "reed-solomon":
|
|
22021
|
-
return new ReedSolomonCodec();
|
|
22022
|
-
case "raptorq":
|
|
22023
|
-
console.warn("[FEC] RaptorQ requested via createFecCodec \u2014 use FECManager.setFecDecoder() for WASM RaptorQ. Falling back to NoneCodec.");
|
|
22024
|
-
return new NoneCodec();
|
|
22025
|
-
default:
|
|
22026
|
-
console.warn(`[FEC] Unknown algorithm "${algorithm}", falling back to NoneCodec`);
|
|
22027
|
-
return new NoneCodec();
|
|
22028
|
-
}
|
|
22029
|
-
}
|
|
22030
|
-
var ReedSolomonCodec = class {
|
|
22031
|
-
constructor() {
|
|
22032
|
-
this.algorithm = "reed-solomon";
|
|
22033
|
-
}
|
|
22034
|
-
addSymbol(_blockId, _symbolId, _data, _isRepair) {
|
|
22035
|
-
return null;
|
|
22036
|
-
}
|
|
22037
|
-
configure(_params) {
|
|
22038
|
-
}
|
|
22039
|
-
cleanup(_now) {
|
|
22040
|
-
return new Uint8Array(0);
|
|
22041
|
-
}
|
|
22042
|
-
};
|
|
22043
|
-
|
|
22044
22517
|
// src/multicast-transport.ts
|
|
22045
22518
|
var JOIN_SUCCEEDED = Object.freeze({ ok: true });
|
|
22046
22519
|
function providerErrorOf(error) {
|
|
@@ -22084,7 +22557,7 @@ function sameIds(a, b) {
|
|
|
22084
22557
|
for (const id of a) if (!b.has(id)) return false;
|
|
22085
22558
|
return true;
|
|
22086
22559
|
}
|
|
22087
|
-
var MulticastTransport = class
|
|
22560
|
+
var MulticastTransport = class {
|
|
22088
22561
|
#onPacket;
|
|
22089
22562
|
#subscription = null;
|
|
22090
22563
|
#packetListener = null;
|
|
@@ -22156,8 +22629,11 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22156
22629
|
// droppedPacketIds.
|
|
22157
22630
|
#unadvertisedPacketIds = /* @__PURE__ */ new Set();
|
|
22158
22631
|
#joinGeneration = 0;
|
|
22159
|
-
|
|
22632
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
22633
|
+
#gateway;
|
|
22634
|
+
constructor(onPacket, options = {}) {
|
|
22160
22635
|
this.#onPacket = onPacket;
|
|
22636
|
+
this.#gateway = options.gateway;
|
|
22161
22637
|
}
|
|
22162
22638
|
static isAvailable() {
|
|
22163
22639
|
return hasMulticastGateway();
|
|
@@ -22167,7 +22643,8 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22167
22643
|
this.#releaseSubscription();
|
|
22168
22644
|
this.#dataPlaneLive = false;
|
|
22169
22645
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
22170
|
-
|
|
22646
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
22647
|
+
if (typeof gateway?.subscribe !== "function") {
|
|
22171
22648
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
22172
22649
|
return this.#declined(generation, "unavailable");
|
|
22173
22650
|
}
|
|
@@ -22184,11 +22661,13 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22184
22661
|
mode: config.mode,
|
|
22185
22662
|
amtRelay: config.amtRelay,
|
|
22186
22663
|
amtRelayPort: config.amtRelayPort,
|
|
22664
|
+
amtDiscovery: config.amtDiscovery,
|
|
22187
22665
|
packetIds: config.packetIds,
|
|
22188
|
-
tracks: config.tracks
|
|
22666
|
+
tracks: config.tracks,
|
|
22667
|
+
atsc3: config.atsc3
|
|
22189
22668
|
});
|
|
22190
22669
|
failure = "provider-rejected";
|
|
22191
|
-
const subscription = await
|
|
22670
|
+
const subscription = await gateway.subscribe(subscribeConfig);
|
|
22192
22671
|
failure = "invalid-subscription";
|
|
22193
22672
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription);
|
|
22194
22673
|
if (this.#disposed || generation !== this.#joinGeneration) {
|
|
@@ -22790,6 +23269,25 @@ function catalogAmtNetworkSource(networkSource) {
|
|
|
22790
23269
|
}
|
|
22791
23270
|
return void 0;
|
|
22792
23271
|
}
|
|
23272
|
+
function intIn(value, min, max) {
|
|
23273
|
+
return Number.isInteger(value) && value >= min && value <= max;
|
|
23274
|
+
}
|
|
23275
|
+
function catalogAtsc3NetworkSource(networkSource) {
|
|
23276
|
+
const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
|
|
23277
|
+
for (const raw of entries) {
|
|
23278
|
+
if (!raw || typeof raw !== "object") continue;
|
|
23279
|
+
const ns = raw;
|
|
23280
|
+
if (ns.type !== "atsc3" || !intIn(ns.frequency, 1, Number.MAX_SAFE_INTEGER)) continue;
|
|
23281
|
+
const slsUri = typeof ns.slsUri === "string" ? ns.slsUri.trim() : "";
|
|
23282
|
+
return {
|
|
23283
|
+
frequency: ns.frequency,
|
|
23284
|
+
...intIn(ns.plpId, 0, 63) ? { plpId: ns.plpId } : {},
|
|
23285
|
+
...intIn(ns.serviceId, 0, 65535) ? { serviceId: ns.serviceId } : {},
|
|
23286
|
+
...slsUri ? { slsUri } : {}
|
|
23287
|
+
};
|
|
23288
|
+
}
|
|
23289
|
+
return void 0;
|
|
23290
|
+
}
|
|
22793
23291
|
|
|
22794
23292
|
// src/catalog-fec-params.ts
|
|
22795
23293
|
var MAX_SAFE_TICKS_PER_HZ = Number.MAX_SAFE_INTEGER / 1e3;
|
|
@@ -23005,6 +23503,13 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
23005
23503
|
function catalogFecUnavailable(fec, fecPath) {
|
|
23006
23504
|
if (catalogFecAvailable(fec)) return void 0;
|
|
23007
23505
|
const block = recordOf3(fec);
|
|
23506
|
+
if (fecAlgorithmUnimplemented(block["algorithm"])) {
|
|
23507
|
+
return Object.freeze({
|
|
23508
|
+
code: "track_fec_algorithm_unimplemented",
|
|
23509
|
+
path: `${fecPath}.algorithm`,
|
|
23510
|
+
message: `algorithm ${JSON.stringify(block["algorithm"])} is not implemented: the track plays without FEC`
|
|
23511
|
+
});
|
|
23512
|
+
}
|
|
23008
23513
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
23009
23514
|
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
23010
23515
|
if (reason === void 0) {
|
|
@@ -23024,7 +23529,7 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
23024
23529
|
throwRepairContractError(
|
|
23025
23530
|
"track_fec",
|
|
23026
23531
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
23027
|
-
"must be a positive integer"
|
|
23532
|
+
kValid && Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0 ? `iso-ssbg1-v1 symbolSize must be at least ${ISO_SSBG1_MIN_SYMBOL_SIZE}` : "must be a positive integer"
|
|
23028
23533
|
);
|
|
23029
23534
|
}
|
|
23030
23535
|
const fecUnavailable = catalogFecUnavailable(fec, fecPath);
|
|
@@ -23033,6 +23538,7 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
23033
23538
|
const fecBlockProfile = readFecBlockProfile(fec.blockProfile, `${fecPath}.blockProfile`, true, throwRepairContractError);
|
|
23034
23539
|
return {
|
|
23035
23540
|
fecK: fec.sourceSymbols ?? 0,
|
|
23541
|
+
fecAlgorithm: fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq",
|
|
23036
23542
|
fecBlockProfile,
|
|
23037
23543
|
fecRepairCount: fec.repairSymbols ?? 0,
|
|
23038
23544
|
// The wire RSB_length: every base layer's packets carry the base total (§7.1).
|
|
@@ -23129,8 +23635,10 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
23129
23635
|
repairsSkippedRttUnmeasured: 0,
|
|
23130
23636
|
repairsSkippedRttExceedsBudget: 0,
|
|
23131
23637
|
repairsSkippedPresentationDelayUnavailable: 0,
|
|
23638
|
+
repairsSkippedRangeNoAnchor: 0,
|
|
23132
23639
|
lastRepairSkip: null,
|
|
23133
23640
|
keyframeRepairFetchesSent: 0,
|
|
23641
|
+
rangeRepairFetchesSent: 0,
|
|
23134
23642
|
keyframeBudgetHolds: 0,
|
|
23135
23643
|
keyframeBudgetHoldMs: 0,
|
|
23136
23644
|
deltaBlocksFailed: 0,
|
|
@@ -23209,6 +23717,12 @@ var REPAIR_PRIORITY_REASONS = /* @__PURE__ */ new Set([
|
|
|
23209
23717
|
"repair-priority-absent",
|
|
23210
23718
|
"repair-priority-invalid"
|
|
23211
23719
|
]);
|
|
23720
|
+
var REPAIR_SKIP_REASONS = /* @__PURE__ */ new Set([
|
|
23721
|
+
"rtt-unmeasured",
|
|
23722
|
+
"rtt-exceeds-budget",
|
|
23723
|
+
"presentation-delay-unavailable"
|
|
23724
|
+
]);
|
|
23725
|
+
var REPAIR_DEADLINE_BOUNDS = /* @__PURE__ */ new Set(["wait", "presentation", "keyframe", "retention"]);
|
|
23212
23726
|
var GAP_REASONS = {
|
|
23213
23727
|
"rap-lost": "stall",
|
|
23214
23728
|
"rap-unknown": "stall",
|
|
@@ -23231,6 +23745,9 @@ function isSymbolCounts(value) {
|
|
|
23231
23745
|
function isNullableNonNegative(value) {
|
|
23232
23746
|
return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
23233
23747
|
}
|
|
23748
|
+
function isFiniteNumber(value) {
|
|
23749
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
23750
|
+
}
|
|
23234
23751
|
function isRepairLifecycleEvent(value) {
|
|
23235
23752
|
if (!isRecord(value) || value["version"] !== 2) return false;
|
|
23236
23753
|
const block = value["block"];
|
|
@@ -23248,6 +23765,20 @@ function isRepairLifecycleEvent(value) {
|
|
|
23248
23765
|
case "repair-preempted":
|
|
23249
23766
|
case "repair-deferred":
|
|
23250
23767
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
23768
|
+
case "repair-sent":
|
|
23769
|
+
return hasExactKeys(value, [
|
|
23770
|
+
"version",
|
|
23771
|
+
"type",
|
|
23772
|
+
"block",
|
|
23773
|
+
"priority",
|
|
23774
|
+
"rttMs",
|
|
23775
|
+
"budgetMs",
|
|
23776
|
+
"delayMs",
|
|
23777
|
+
"blockAgeMs",
|
|
23778
|
+
"bound"
|
|
23779
|
+
]) && isRepairBlockIdentity(block) && (value["priority"] === 0 || value["priority"] === 1 || value["priority"] === 2) && isFiniteNumber(value["rttMs"]) && value["rttMs"] > 0 && isFiniteNumber(value["budgetMs"]) && value["budgetMs"] > value["rttMs"] && isNullableNonNegative(value["delayMs"]) && isNullableNonNegative(value["blockAgeMs"]) && value["delayMs"] === null === (value["blockAgeMs"] === null) && REPAIR_DEADLINE_BOUNDS.has(value["bound"]);
|
|
23780
|
+
case "repair-skipped":
|
|
23781
|
+
return hasExactKeys(value, ["version", "type", "block", "reason", "rttMs", "budgetMs"]) && isRepairBlockIdentity(block) && REPAIR_SKIP_REASONS.has(value["reason"]) && isNullableNonNegative(value["rttMs"]) && isFiniteNumber(value["budgetMs"]);
|
|
23251
23782
|
case "repair-priority": {
|
|
23252
23783
|
const blockClass = value["blockClass"];
|
|
23253
23784
|
const action = value["action"];
|
|
@@ -23427,6 +23958,9 @@ var MulticastManager = class {
|
|
|
23427
23958
|
#router;
|
|
23428
23959
|
#hostMfuTimeoutMs;
|
|
23429
23960
|
#transport;
|
|
23961
|
+
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
23962
|
+
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
23963
|
+
#repairReleases = /* @__PURE__ */ new Map();
|
|
23430
23964
|
#reportedFecDiagnosticsFailure = false;
|
|
23431
23965
|
// ── Stream-global FEC timing reduction ──
|
|
23432
23966
|
//
|
|
@@ -23690,7 +24224,9 @@ var MulticastManager = class {
|
|
|
23690
24224
|
catalogTrackName
|
|
23691
24225
|
);
|
|
23692
24226
|
this.#configureTrackMapper(packetId, config);
|
|
23693
|
-
this.#router.
|
|
24227
|
+
if (this.#router.trackKindFor(packetId) !== trackType) {
|
|
24228
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
24229
|
+
}
|
|
23694
24230
|
}
|
|
23695
24231
|
/**
|
|
23696
24232
|
* Stop routing a stream's symbols to its Worker decoder. Returns false when
|
|
@@ -23771,6 +24307,14 @@ var MulticastManager = class {
|
|
|
23771
24307
|
);
|
|
23772
24308
|
}
|
|
23773
24309
|
}
|
|
24310
|
+
for (const [packetId, c] of this.#trackFecTiming) {
|
|
24311
|
+
if (c.deliveryWindowMs === void 0) continue;
|
|
24312
|
+
mfuTimeoutMs = Math.max(
|
|
24313
|
+
mfuTimeoutMs ?? 0,
|
|
24314
|
+
this.#fec.terminalRetentionMsForPacket(packetId) ?? 0,
|
|
24315
|
+
this.#hostMfuTimeoutMs ?? 0
|
|
24316
|
+
);
|
|
24317
|
+
}
|
|
23774
24318
|
const failbackWindowMs = deliveryWindowMs === void 0 ? minimumFailbackWindowMs : Math.max(deliveryWindowMs, minimumFailbackWindowMs ?? 0);
|
|
23775
24319
|
this.#transport.setFailbackWindowMs(failbackWindowMs ?? null);
|
|
23776
24320
|
this.#router.setMfuTimeoutMs(mfuTimeoutMs ?? this.#hostMfuTimeoutMs);
|
|
@@ -23954,6 +24498,7 @@ var MulticastManager = class {
|
|
|
23954
24498
|
setMfuTimeoutMs(ms) {
|
|
23955
24499
|
this.#router.setMfuTimeoutMs(ms);
|
|
23956
24500
|
this.#hostMfuTimeoutMs = this.#router.reassembler.timeoutMs;
|
|
24501
|
+
if (this.#trackFecTiming.size > 0) this.#applyStreamGlobalFecTiming();
|
|
23957
24502
|
}
|
|
23958
24503
|
setTrackCodec(packetId, codec) {
|
|
23959
24504
|
this.#router.setTrackCodec(packetId, codec);
|
|
@@ -24074,11 +24619,80 @@ var MulticastManager = class {
|
|
|
24074
24619
|
// through whatever the relay looks like, since dropping it would be the
|
|
24075
24620
|
// worse behaviour.
|
|
24076
24621
|
amtRelayPort: config.amtRelayPort ?? config.relayPort ?? (amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24622
|
+
amtDiscovery: config.amtDiscovery,
|
|
24077
24623
|
packetIds: config.packetIds,
|
|
24078
24624
|
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId }))
|
|
24079
24625
|
};
|
|
24080
24626
|
return ingress === void 0 ? this.#transport.join(transportConfig) : this.#transport.join(transportConfig, ingress);
|
|
24081
24627
|
}
|
|
24628
|
+
/**
|
|
24629
|
+
* Join the selected rung's dedicated repair groups beside the media join
|
|
24630
|
+
* (pim #3898): one subscription per endpoint, through `provider` when given
|
|
24631
|
+
* (a `window.multicast`-shaped gateway or a subscribe callback), otherwise a
|
|
24632
|
+
* new MulticastTransport on `window.multicast`. Returns the call that
|
|
24633
|
+
* releases every one of them; dispose() releases them too.
|
|
24634
|
+
*
|
|
24635
|
+
* Packets go straight to the router with the endpoint's ingress, never
|
|
24636
|
+
* through feedPacket(): repair arriving on its own group is not media
|
|
24637
|
+
* liveness, so it must not hold off the media leg's failback watchdog. The
|
|
24638
|
+
* repair roles and owners are registered here; in-band owners stay the
|
|
24639
|
+
* caller's. Joining is best effort: a group that fails to join is logged
|
|
24640
|
+
* and leaves the media join as it was.
|
|
24641
|
+
*/
|
|
24642
|
+
joinRepairEndpoints(endpoints, provider) {
|
|
24643
|
+
const releases = [];
|
|
24644
|
+
let released = false;
|
|
24645
|
+
const safely = (each) => {
|
|
24646
|
+
try {
|
|
24647
|
+
each();
|
|
24648
|
+
} catch (error) {
|
|
24649
|
+
console.warn("[MulticastManager] repair group release failed", error);
|
|
24650
|
+
}
|
|
24651
|
+
};
|
|
24652
|
+
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners);
|
|
24653
|
+
this.#applyRepairOwners(repairOwners);
|
|
24654
|
+
for (const endpoint of endpoints) {
|
|
24655
|
+
const ingress = {
|
|
24656
|
+
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId })))
|
|
24657
|
+
};
|
|
24658
|
+
const onPacket = (packet) => {
|
|
24659
|
+
if (!released) this.#router.feedPacket(packet, "multicast", void 0, ingress);
|
|
24660
|
+
};
|
|
24661
|
+
const fail = (error) => console.warn(`[MulticastManager] repair group ${endpoint.group}:${endpoint.port} not joined`, error);
|
|
24662
|
+
if (typeof provider === "function") {
|
|
24663
|
+
Promise.resolve().then(() => provider(endpoint, onPacket)).then((release2) => released ? safely(release2) : releases.push(release2), fail);
|
|
24664
|
+
continue;
|
|
24665
|
+
}
|
|
24666
|
+
const transport = new MulticastTransport((packet) => onPacket(packet), { gateway: provider });
|
|
24667
|
+
releases.push(() => transport.dispose());
|
|
24668
|
+
void transport.join({
|
|
24669
|
+
sourceAddress: endpoint.source,
|
|
24670
|
+
groupAddress: endpoint.group,
|
|
24671
|
+
port: endpoint.port,
|
|
24672
|
+
mode: endpoint.mode,
|
|
24673
|
+
amtRelay: endpoint.amtRelay,
|
|
24674
|
+
amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24675
|
+
packetIds: endpoint.packetIds,
|
|
24676
|
+
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId }))
|
|
24677
|
+
}).then((joined) => {
|
|
24678
|
+
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
24679
|
+
});
|
|
24680
|
+
}
|
|
24681
|
+
const release = () => {
|
|
24682
|
+
if (released) return;
|
|
24683
|
+
released = true;
|
|
24684
|
+
this.#repairReleases.delete(release);
|
|
24685
|
+
for (const each of releases.splice(0)) safely(each);
|
|
24686
|
+
};
|
|
24687
|
+
this.#repairReleases.set(release, repairOwners);
|
|
24688
|
+
return release;
|
|
24689
|
+
}
|
|
24690
|
+
#applyRepairOwners(owners) {
|
|
24691
|
+
for (const { packetId, ownerPacketId } of owners) {
|
|
24692
|
+
this.#router.setPacketIdRole(packetId, "repair");
|
|
24693
|
+
this.#router.setRepairPacketIdOwner(packetId, ownerPacketId);
|
|
24694
|
+
}
|
|
24695
|
+
}
|
|
24082
24696
|
// ---------------------------------------------------------------------------
|
|
24083
24697
|
// In-place rendition switch
|
|
24084
24698
|
// ---------------------------------------------------------------------------
|
|
@@ -24354,7 +24968,7 @@ var MulticastManager = class {
|
|
|
24354
24968
|
*
|
|
24355
24969
|
* D-04: Validates completeness via validateSwitchingSet — throws if incomplete.
|
|
24356
24970
|
* D-07: Applies per-track FEC configs (base+delta get decoders; repair does not).
|
|
24357
|
-
* D-17: Builds altGroup → track-name index for getSwitchingSet().
|
|
24971
|
+
* D-17: Builds altGroup → track-name index for getSwitchingSet() (repair legs excluded).
|
|
24358
24972
|
* D-26: Registers packetId → TrackRole on MmtpRouter for block-complete fanout.
|
|
24359
24973
|
*
|
|
24360
24974
|
* FEC availability is per track (draft-ramadan-moq-fec §5.1). A media track
|
|
@@ -24405,11 +25019,9 @@ var MulticastManager = class {
|
|
|
24405
25019
|
}
|
|
24406
25020
|
}
|
|
24407
25021
|
const repairOwnerGroup = /* @__PURE__ */ new Map();
|
|
24408
|
-
const repairOwnerAltGroup = /* @__PURE__ */ new Map();
|
|
24409
25022
|
for (const track of catalog.tracks) {
|
|
24410
25023
|
for (const repairName of repairNamesBySource.get(track.name) ?? []) {
|
|
24411
25024
|
repairOwnerGroup.set(repairName, altGroupKey(track));
|
|
24412
|
-
repairOwnerAltGroup.set(repairName, track.altGroup);
|
|
24413
25025
|
}
|
|
24414
25026
|
}
|
|
24415
25027
|
const groupKeyFor = (track) => repairOwnerGroup.get(track.name) ?? altGroupKey(track);
|
|
@@ -24440,11 +25052,7 @@ var MulticastManager = class {
|
|
|
24440
25052
|
for (const [groupKey, roles] of resolvedRolesByGroup) {
|
|
24441
25053
|
if (!(hasSwitchingSetByGroup.get(groupKey) ?? false)) continue;
|
|
24442
25054
|
const presentRoles = new Set(roles.filter((r) => r !== "single"));
|
|
24443
|
-
const required = [
|
|
24444
|
-
"base",
|
|
24445
|
-
"delta",
|
|
24446
|
-
"repair"
|
|
24447
|
-
];
|
|
25055
|
+
const required = ["base", "repair"];
|
|
24448
25056
|
const missing = required.filter((r) => !presentRoles.has(r));
|
|
24449
25057
|
if (missing.length > 0) {
|
|
24450
25058
|
throw new Error(
|
|
@@ -24491,6 +25099,7 @@ var MulticastManager = class {
|
|
|
24491
25099
|
this.#switchingSets.clear();
|
|
24492
25100
|
this.#repairPacketIds.clear();
|
|
24493
25101
|
this.#router.clearRepairPacketIdOwners();
|
|
25102
|
+
for (const owners of this.#repairReleases.values()) this.#applyRepairOwners(owners);
|
|
24494
25103
|
const fecPacketIds = new Set([...fecDecoders.keys()].map((i) => catalog.tracks[i].packetId));
|
|
24495
25104
|
for (const [packetId, catalogTrackName] of this.#multiTrackFecTracks) {
|
|
24496
25105
|
if (fecPacketIds.has(packetId)) continue;
|
|
@@ -24511,11 +25120,10 @@ var MulticastManager = class {
|
|
|
24511
25120
|
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
24512
25121
|
const track = catalog.tracks[i];
|
|
24513
25122
|
const role = resolvedRoles[i];
|
|
24514
|
-
|
|
24515
|
-
|
|
24516
|
-
const existing = this.#switchingSets.get(altGroup) ?? [];
|
|
25123
|
+
if (role !== "repair" && track.altGroup !== void 0) {
|
|
25124
|
+
const existing = this.#switchingSets.get(track.altGroup) ?? [];
|
|
24517
25125
|
existing.push(track.name);
|
|
24518
|
-
this.#switchingSets.set(altGroup, existing);
|
|
25126
|
+
this.#switchingSets.set(track.altGroup, existing);
|
|
24519
25127
|
}
|
|
24520
25128
|
if (track.packetId !== void 0) {
|
|
24521
25129
|
this.#router.setPacketIdRole(track.packetId, role);
|
|
@@ -24590,7 +25198,7 @@ var MulticastManager = class {
|
|
|
24590
25198
|
#multiTrackFecTracks = /* @__PURE__ */ new Map();
|
|
24591
25199
|
/**
|
|
24592
25200
|
* Return the track names belonging to the given altGroup switching set.
|
|
24593
|
-
* D-17:
|
|
25201
|
+
* D-17: tracks with equal altGroup form one switching set; repair legs are in none.
|
|
24594
25202
|
*
|
|
24595
25203
|
* @param altGroup - The altGroup number to look up.
|
|
24596
25204
|
* @returns Array of track names in that switching set (empty if none).
|
|
@@ -24618,6 +25226,26 @@ var MulticastManager = class {
|
|
|
24618
25226
|
this.requestRepairForBlock(sbn, packetId, catalogTrackName, blockClass);
|
|
24619
25227
|
};
|
|
24620
25228
|
}
|
|
25229
|
+
/**
|
|
25230
|
+
* Register the range repair scheduler (draft-ramadan-moq-fec §7.5): from now
|
|
25231
|
+
* on an iso-ssbg1-v1 gap missing a source and every repair is kept as a
|
|
25232
|
+
* pending hole and reported here, and `closeIsoHoles` must be called for it
|
|
25233
|
+
* once its range FETCH ends (or none is sent).
|
|
25234
|
+
*/
|
|
25235
|
+
onUndelimitedLoss(cb) {
|
|
25236
|
+
this.#fec.setUndelimitedLossHandler(cb);
|
|
25237
|
+
}
|
|
25238
|
+
/**
|
|
25239
|
+
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), e.g.
|
|
25240
|
+
* to CmcdProducer.updateFecFailClosed.
|
|
25241
|
+
*/
|
|
25242
|
+
onFecFailClosed(cb) {
|
|
25243
|
+
this.#fec.setFecFailClosedHandler(cb);
|
|
25244
|
+
}
|
|
25245
|
+
/** End a pending hole's range repair: feed what no repair stated as spans. */
|
|
25246
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
25247
|
+
this.#router.closeIsoHoles(packetId, catalogTrackName, start, length);
|
|
25248
|
+
}
|
|
24621
25249
|
/**
|
|
24622
25250
|
* Record a repair request whose SUBSCRIBER_PRIORITY the catalog could not
|
|
24623
25251
|
* supply (draft-ramadan-moq-fec §11.4.5): sent without the parameter, or
|
|
@@ -24639,6 +25267,7 @@ var MulticastManager = class {
|
|
|
24639
25267
|
stats.repairsSkipped++;
|
|
24640
25268
|
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
24641
25269
|
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
25270
|
+
else if (reason === "range-no-anchor") stats.repairsSkippedRangeNoAnchor++;
|
|
24642
25271
|
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
24643
25272
|
stats.lastRepairSkip = {
|
|
24644
25273
|
reason,
|
|
@@ -24670,8 +25299,20 @@ var MulticastManager = class {
|
|
|
24670
25299
|
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24671
25300
|
}
|
|
24672
25301
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24673
|
-
noteRepairFetchSent(priority,
|
|
25302
|
+
noteRepairFetchSent(priority, sbn, packetId, catalogTrackName, measurement) {
|
|
24674
25303
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
25304
|
+
if (measurement.range) this.#statsFor(packetId, catalogTrackName).rangeRepairFetchesSent++;
|
|
25305
|
+
this.#emitRepairLifecycle({
|
|
25306
|
+
version: 2,
|
|
25307
|
+
type: "repair-sent",
|
|
25308
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
25309
|
+
priority,
|
|
25310
|
+
rttMs: measurement.rttMs,
|
|
25311
|
+
budgetMs: measurement.budgetMs,
|
|
25312
|
+
delayMs: measurement.delayMs,
|
|
25313
|
+
blockAgeMs: measurement.blockAgeMs,
|
|
25314
|
+
bound: measurement.bound
|
|
25315
|
+
});
|
|
24675
25316
|
}
|
|
24676
25317
|
/**
|
|
24677
25318
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
@@ -24822,6 +25463,7 @@ var MulticastManager = class {
|
|
|
24822
25463
|
this.#trackResetObservers.clear();
|
|
24823
25464
|
this.#repairLifecycleObservers.clear();
|
|
24824
25465
|
this.#transport.dispose();
|
|
25466
|
+
for (const release of [...this.#repairReleases.keys()]) release();
|
|
24825
25467
|
this.#router.dispose();
|
|
24826
25468
|
this.#fec.dispose();
|
|
24827
25469
|
}
|
|
@@ -24897,7 +25539,7 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24897
25539
|
trackType: opts.trackType,
|
|
24898
25540
|
framerate: opts.framerate,
|
|
24899
25541
|
sampleRate: opts.sampleRate,
|
|
24900
|
-
algorithm: "
|
|
25542
|
+
algorithm: opts.fecAlgorithm ?? "raptorq",
|
|
24901
25543
|
blockProfile,
|
|
24902
25544
|
k: opts.fecK,
|
|
24903
25545
|
// P as this receiver joined it, not the catalog total: the worker snapshot
|
|
@@ -24911,10 +25553,10 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24911
25553
|
repairTrack: opts.repairTrackName,
|
|
24912
25554
|
relayBlockSigEnabled: false
|
|
24913
25555
|
};
|
|
24914
|
-
client.configure(fecTrackConfig, rqWasm);
|
|
24915
25556
|
try {
|
|
24916
25557
|
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
24917
25558
|
blockProfile,
|
|
25559
|
+
algorithm: opts.fecAlgorithm ?? "raptorq",
|
|
24918
25560
|
k: opts.fecK,
|
|
24919
25561
|
symbolSize: opts.fecSymbolSize,
|
|
24920
25562
|
interleaveDepthMs: opts.fecInterleaveMs,
|
|
@@ -24922,7 +25564,9 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24922
25564
|
// the local cleanup budget, but it must not use a guessed fps for timing
|
|
24923
25565
|
// or classification.
|
|
24924
25566
|
...hasCatalogTiming ? { fps: 1e3 / opts.mediaUnitDurationMs } : {},
|
|
24925
|
-
timeoutMs: deliveryWindowMs
|
|
25567
|
+
timeoutMs: deliveryWindowMs,
|
|
25568
|
+
...opts.fecRepairLayers ? { repairLayers: opts.fecRepairLayers } : {},
|
|
25569
|
+
...opts.heldRepairLayers ? { heldLayers: opts.heldRepairLayers } : {}
|
|
24926
25570
|
}, opts.trackName);
|
|
24927
25571
|
} catch (e) {
|
|
24928
25572
|
try {
|
|
@@ -24931,6 +25575,14 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24931
25575
|
}
|
|
24932
25576
|
throw e;
|
|
24933
25577
|
}
|
|
25578
|
+
fecTrackConfig.interleaveDepth = Math.min(
|
|
25579
|
+
MAX_FEC_RETENTION_BLOCKS,
|
|
25580
|
+
Math.max(
|
|
25581
|
+
interleaveDepthBlocks,
|
|
25582
|
+
opts.multicastManager.fecManager.isoRetentionBlocksForPacket(opts.packetId) ?? 0
|
|
25583
|
+
)
|
|
25584
|
+
);
|
|
25585
|
+
client.configure(fecTrackConfig, rqWasm);
|
|
24934
25586
|
let disposed = false;
|
|
24935
25587
|
return {
|
|
24936
25588
|
client,
|
|
@@ -25580,7 +26232,7 @@ function asSeconds(n) {
|
|
|
25580
26232
|
}
|
|
25581
26233
|
return n;
|
|
25582
26234
|
}
|
|
25583
|
-
function groupIdForTicks(ticks, groupDurationTicks) {
|
|
26235
|
+
function groupIdForTicks(ticks, groupDurationTicks, presentationAnchorTicks = 0) {
|
|
25584
26236
|
if (!Number.isInteger(ticks)) {
|
|
25585
26237
|
throw new Error(
|
|
25586
26238
|
`[align] groupIdForTicks: ticks must be an integer, got ${ticks}`
|
|
@@ -25591,8 +26243,23 @@ function groupIdForTicks(ticks, groupDurationTicks) {
|
|
|
25591
26243
|
`[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`
|
|
25592
26244
|
);
|
|
25593
26245
|
}
|
|
25594
|
-
if (
|
|
25595
|
-
|
|
26246
|
+
if (!Number.isInteger(presentationAnchorTicks)) {
|
|
26247
|
+
throw new Error(
|
|
26248
|
+
`[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`
|
|
26249
|
+
);
|
|
26250
|
+
}
|
|
26251
|
+
const relativeTicks = ticks - presentationAnchorTicks;
|
|
26252
|
+
if (!Number.isSafeInteger(relativeTicks)) {
|
|
26253
|
+
throw new Error(
|
|
26254
|
+
`[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`
|
|
26255
|
+
);
|
|
26256
|
+
}
|
|
26257
|
+
if (relativeTicks < 0) {
|
|
26258
|
+
throw new Error(
|
|
26259
|
+
`[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
26260
|
+
);
|
|
26261
|
+
}
|
|
26262
|
+
return Math.floor(relativeTicks / groupDurationTicks);
|
|
25596
26263
|
}
|
|
25597
26264
|
function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
25598
26265
|
if (!Number.isFinite(mediaTimeSec)) {
|
|
@@ -25605,7 +26272,11 @@ function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
|
25605
26272
|
`[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`
|
|
25606
26273
|
);
|
|
25607
26274
|
}
|
|
25608
|
-
if (mediaTimeSec < 0)
|
|
26275
|
+
if (mediaTimeSec < 0) {
|
|
26276
|
+
throw new Error(
|
|
26277
|
+
`[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
26278
|
+
);
|
|
26279
|
+
}
|
|
25609
26280
|
const TS = 1e9;
|
|
25610
26281
|
const ticks = Math.round(mediaTimeSec * TS);
|
|
25611
26282
|
const durTicks = Math.round(groupDurationSec * TS);
|
|
@@ -26446,6 +27117,7 @@ var CmcdProducer = class {
|
|
|
26446
27117
|
#deltaFailRate = null;
|
|
26447
27118
|
#switchMiscount = 0;
|
|
26448
27119
|
#manifestStats = null;
|
|
27120
|
+
#fecFailClosed = null;
|
|
26449
27121
|
constructor(options) {
|
|
26450
27122
|
this.#onCmcdParams = options.onCmcdParams;
|
|
26451
27123
|
this.#onCmcdPost = options.onCmcdPost;
|
|
@@ -26487,6 +27159,15 @@ var CmcdProducer = class {
|
|
|
26487
27159
|
incrementSwitchMiscount() {
|
|
26488
27160
|
this.#switchMiscount += 1;
|
|
26489
27161
|
}
|
|
27162
|
+
/**
|
|
27163
|
+
* Record that FEC failed closed at runtime (fec-01 6.3.9). Every later
|
|
27164
|
+
* snapshot carries `x-bc-fec-fail-closed` (the reason code) and
|
|
27165
|
+
* `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a
|
|
27166
|
+
* stream playing without FEC is told apart from one with no loss.
|
|
27167
|
+
*/
|
|
27168
|
+
updateFecFailClosed(reason) {
|
|
27169
|
+
this.#fecFailClosed = reason;
|
|
27170
|
+
}
|
|
26490
27171
|
updateManifestVerification(stats) {
|
|
26491
27172
|
this.#manifestStats = stats;
|
|
26492
27173
|
}
|
|
@@ -26524,6 +27205,10 @@ var CmcdProducer = class {
|
|
|
26524
27205
|
if (this.#playMode !== null) {
|
|
26525
27206
|
params["x-bc-play-mode"] = this.#playMode;
|
|
26526
27207
|
}
|
|
27208
|
+
if (this.#fecFailClosed) {
|
|
27209
|
+
params["x-bc-fec-fail-closed"] = this.#fecFailClosed.code;
|
|
27210
|
+
params["x-bc-fec-fail-layer"] = this.#fecFailClosed.layer;
|
|
27211
|
+
}
|
|
26527
27212
|
if (this.#playMode !== null && this.#playMode !== "single-track" && this.#deltaFailRate !== null) {
|
|
26528
27213
|
params["x-bc-delta-fail-rate"] = parseFloat(this.#deltaFailRate.toFixed(4));
|
|
26529
27214
|
}
|
|
@@ -26576,6 +27261,346 @@ var CmcdProducer = class {
|
|
|
26576
27261
|
}
|
|
26577
27262
|
};
|
|
26578
27263
|
|
|
27264
|
+
// src/mmtp-fec-session.ts
|
|
27265
|
+
var PATH_BITS = { moq: 1, multicast: 2 };
|
|
27266
|
+
var MIXED_PATHS = PATH_BITS.moq | PATH_BITS.multicast;
|
|
27267
|
+
var MmtpFecSession = class {
|
|
27268
|
+
#decoder;
|
|
27269
|
+
/** Blocks a repair has defined and that are not settled yet, by SS_Start. */
|
|
27270
|
+
#blocks = /* @__PURE__ */ new Map();
|
|
27271
|
+
/** SS_Starts of settled blocks, so a later repair for one is refused. */
|
|
27272
|
+
#settled = /* @__PURE__ */ new Set();
|
|
27273
|
+
/**
|
|
27274
|
+
* SS_IDs whose packet the parser has, with the PATH_BITS of the path it was
|
|
27275
|
+
* received on, or 0 for one the session recovered.
|
|
27276
|
+
*/
|
|
27277
|
+
#have = /* @__PURE__ */ new Map();
|
|
27278
|
+
#newest;
|
|
27279
|
+
/** The newest SS_ID when the remembered SS_IDs were last pruned. */
|
|
27280
|
+
#prunedAt;
|
|
27281
|
+
#repairPacketId;
|
|
27282
|
+
#stats = {
|
|
27283
|
+
sourceSymbols: 0,
|
|
27284
|
+
repairSymbols: 0,
|
|
27285
|
+
blocksClean: 0,
|
|
27286
|
+
blocksRecovered: 0,
|
|
27287
|
+
blocksFailed: 0,
|
|
27288
|
+
blocksReleased: 0,
|
|
27289
|
+
packetsRecovered: 0,
|
|
27290
|
+
packetsLost: 0,
|
|
27291
|
+
dropped: {},
|
|
27292
|
+
sourceSymbolsByPath: { moq: 0, multicast: 0 },
|
|
27293
|
+
repairSymbolsByPath: { moq: 0, multicast: 0 },
|
|
27294
|
+
mixedPath: { clean: 0, recovered: 0, failed: 0, released: 0 }
|
|
27295
|
+
};
|
|
27296
|
+
/**
|
|
27297
|
+
* @throws when the catalog block lacks or misstates a field the session
|
|
27298
|
+
* needs: the block profile, K, T, `interleaveDepthMs` or
|
|
27299
|
+
* `reorderToleranceMs`. None is defaulted.
|
|
27300
|
+
*/
|
|
27301
|
+
constructor(config) {
|
|
27302
|
+
const fec = config?.fec;
|
|
27303
|
+
if (!fec || typeof fec !== "object") {
|
|
27304
|
+
throw new Error("MmtpFecSession: the catalog fec block is required");
|
|
27305
|
+
}
|
|
27306
|
+
this.blockProfile = parseFecBlockProfile(fec.blockProfile, "fec.blockProfile");
|
|
27307
|
+
if (fec.algorithm !== void 0 && fec.algorithm !== "raptorq" && fec.algorithm !== "reed-solomon") {
|
|
27308
|
+
throw new Error(`MmtpFecSession: fec.algorithm ${JSON.stringify(fec.algorithm)} is not implemented`);
|
|
27309
|
+
}
|
|
27310
|
+
this.algorithm = fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq";
|
|
27311
|
+
this.sourceSymbols = requirePositiveInteger(fec.sourceSymbols, "fec.sourceSymbols");
|
|
27312
|
+
this.symbolSize = requirePositiveInteger(fec.symbolSize, "fec.symbolSize");
|
|
27313
|
+
const interleaveDepthMs = requireNumber(fec.interleaveDepthMs, "fec.interleaveDepthMs");
|
|
27314
|
+
const reorderToleranceMs = requireNumber(fec.reorderToleranceMs, "fec.reorderToleranceMs");
|
|
27315
|
+
this.retentionBlocks = deriveFecRetentionBlocks(
|
|
27316
|
+
fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs),
|
|
27317
|
+
interleaveDepthMs
|
|
27318
|
+
);
|
|
27319
|
+
if (typeof config.Decoder !== "function") {
|
|
27320
|
+
throw new Error("MmtpFecSession: a decoder constructor (wasm_bindgen.MmtFecDecoder) is required");
|
|
27321
|
+
}
|
|
27322
|
+
const decoder = new config.Decoder(this.retentionBlocks, this.blockProfile, this.algorithm);
|
|
27323
|
+
try {
|
|
27324
|
+
decoder.configure_params(this.sourceSymbols, this.symbolSize);
|
|
27325
|
+
} catch (error) {
|
|
27326
|
+
decoder.free();
|
|
27327
|
+
throw error;
|
|
27328
|
+
}
|
|
27329
|
+
this.#decoder = decoder;
|
|
27330
|
+
}
|
|
27331
|
+
/** True once release() ran. */
|
|
27332
|
+
get released() {
|
|
27333
|
+
return this.#decoder === null;
|
|
27334
|
+
}
|
|
27335
|
+
get stats() {
|
|
27336
|
+
return {
|
|
27337
|
+
...this.#stats,
|
|
27338
|
+
dropped: { ...this.#stats.dropped },
|
|
27339
|
+
sourceSymbolsByPath: { ...this.#stats.sourceSymbolsByPath },
|
|
27340
|
+
repairSymbolsByPath: { ...this.#stats.repairSymbolsByPath },
|
|
27341
|
+
mixedPath: { ...this.#stats.mixedPath }
|
|
27342
|
+
};
|
|
27343
|
+
}
|
|
27344
|
+
/**
|
|
27345
|
+
* Feeds one received source packet: the MMTP packet without its four-byte
|
|
27346
|
+
* Source FEC Payload ID, under the SS_ID that ID stated. This is what
|
|
27347
|
+
* MmtpContainerParser's onSourceSymbol() hands over. `path` is where it
|
|
27348
|
+
* was received; a caller that only subscribes over MoQT can leave it out.
|
|
27349
|
+
*
|
|
27350
|
+
* @returns the protected packets of this packet's block that it recovered,
|
|
27351
|
+
* in SS_ID order, for the caller to feed to its parser with
|
|
27352
|
+
* `{skipFecPayloadId: true, recovered: true}`. Usually empty.
|
|
27353
|
+
*/
|
|
27354
|
+
addSource(ssId, packet, path = "moq") {
|
|
27355
|
+
const decoder = this.#decoder;
|
|
27356
|
+
if (!decoder) return this.#drop("source:released");
|
|
27357
|
+
const pathBit = PATH_BITS[path];
|
|
27358
|
+
if (!pathBit) return this.#drop("source:unknown-path");
|
|
27359
|
+
if (!Number.isInteger(ssId) || ssId < 0 || ssId > 4294967295) return this.#drop("source:bad-ss-id");
|
|
27360
|
+
if (!ssbg1FitsSymbol(packet.byteLength, this.symbolSize)) return this.#drop("source:exceeds-symbol");
|
|
27361
|
+
if (this.#have.has(ssId)) return this.#drop("source:duplicate");
|
|
27362
|
+
this.#have.set(ssId, pathBit);
|
|
27363
|
+
this.#stats.sourceSymbols++;
|
|
27364
|
+
this.#stats.sourceSymbolsByPath[path]++;
|
|
27365
|
+
this.#noteNewest(ssId);
|
|
27366
|
+
const start = this.#blockStartOf(ssId);
|
|
27367
|
+
const block = start === void 0 ? void 0 : this.#blocks.get(start);
|
|
27368
|
+
if (block) {
|
|
27369
|
+
block.received++;
|
|
27370
|
+
block.paths |= pathBit;
|
|
27371
|
+
}
|
|
27372
|
+
let output;
|
|
27373
|
+
try {
|
|
27374
|
+
output = decoder.add_source(ssId, packet, 0);
|
|
27375
|
+
} catch {
|
|
27376
|
+
this.#drop("source:decoder-refused");
|
|
27377
|
+
output = void 0;
|
|
27378
|
+
}
|
|
27379
|
+
const recovered = [];
|
|
27380
|
+
if (start !== void 0 && block) {
|
|
27381
|
+
if (output) {
|
|
27382
|
+
recovered.push(...this.#settleDecoded(start, block, output));
|
|
27383
|
+
} else if (block.received >= block.ssbLength) {
|
|
27384
|
+
this.#settleClean(start);
|
|
27385
|
+
}
|
|
27386
|
+
}
|
|
27387
|
+
this.#retireBehindHorizon();
|
|
27388
|
+
return recovered;
|
|
27389
|
+
}
|
|
27390
|
+
/**
|
|
27391
|
+
* Feeds one object of the repair track: a whole MMTP repair packet (ISO/IEC
|
|
27392
|
+
* 23008-1 C.5.3). A repair track carries one repair flow, so the first
|
|
27393
|
+
* repair packet fixes its packet ID and a packet of any other is refused.
|
|
27394
|
+
* `path` is where it was received, as for addSource().
|
|
27395
|
+
*
|
|
27396
|
+
* @returns the protected packets this repair symbol recovered, as for
|
|
27397
|
+
* addSource().
|
|
27398
|
+
*/
|
|
27399
|
+
addRepair(packet, path = "moq") {
|
|
27400
|
+
const decoder = this.#decoder;
|
|
27401
|
+
if (!decoder) return this.#drop("repair:released");
|
|
27402
|
+
const pathBit = PATH_BITS[path];
|
|
27403
|
+
if (!pathBit) return this.#drop("repair:unknown-path");
|
|
27404
|
+
let header;
|
|
27405
|
+
try {
|
|
27406
|
+
header = parseMMTPHeader(packet);
|
|
27407
|
+
} catch {
|
|
27408
|
+
return this.#drop("repair:malformed");
|
|
27409
|
+
}
|
|
27410
|
+
const frame = parseMoqRepairFrameWithHeader(packet, header);
|
|
27411
|
+
if (!frame) return this.#drop("repair:malformed");
|
|
27412
|
+
if (this.#repairPacketId === void 0) {
|
|
27413
|
+
this.#repairPacketId = frame.packetId;
|
|
27414
|
+
} else if (frame.packetId !== this.#repairPacketId) {
|
|
27415
|
+
return this.#drop("repair:foreign-packet-id");
|
|
27416
|
+
}
|
|
27417
|
+
if (frame.symbolData.byteLength !== this.symbolSize) return this.#drop("repair:symbol-size");
|
|
27418
|
+
if (frame.ssbLength > this.sourceSymbols) return this.#drop("repair:ssb-length");
|
|
27419
|
+
if (this.algorithm === "reed-solomon" && frame.ssbLength + frame.rsbLength > 255) {
|
|
27420
|
+
return this.#drop("repair:rs-block-length");
|
|
27421
|
+
}
|
|
27422
|
+
const start = frame.ssStart;
|
|
27423
|
+
let block = this.#blocks.get(start);
|
|
27424
|
+
if (block && block.ssbLength !== frame.ssbLength) return this.#drop("repair:conflicting-ssb-length");
|
|
27425
|
+
if (block?.rsIds.has(frame.rsId)) return this.#drop("repair:duplicate");
|
|
27426
|
+
if (!block) {
|
|
27427
|
+
if (this.#settled.has(start)) return this.#drop("repair:block-settled");
|
|
27428
|
+
if (this.#behindHorizon(start)) return this.#drop("repair:behind-horizon");
|
|
27429
|
+
block = { ssbLength: frame.ssbLength, received: 0, paths: 0, rsIds: /* @__PURE__ */ new Set() };
|
|
27430
|
+
this.#countHeld(start, block);
|
|
27431
|
+
this.#blocks.set(start, block);
|
|
27432
|
+
}
|
|
27433
|
+
this.#noteNewest(serial32Add(start, frame.ssbLength - 1));
|
|
27434
|
+
if (block.received >= block.ssbLength) {
|
|
27435
|
+
this.#settleClean(start);
|
|
27436
|
+
this.#retireBehindHorizon();
|
|
27437
|
+
return [];
|
|
27438
|
+
}
|
|
27439
|
+
let output;
|
|
27440
|
+
try {
|
|
27441
|
+
output = decoder.add_repair(start, frame.ssbLength, frame.rsId, frame.symbolData, 0);
|
|
27442
|
+
} catch {
|
|
27443
|
+
return this.#drop("repair:decoder-refused");
|
|
27444
|
+
}
|
|
27445
|
+
block.rsIds.add(frame.rsId);
|
|
27446
|
+
this.#stats.repairSymbols++;
|
|
27447
|
+
this.#stats.repairSymbolsByPath[path]++;
|
|
27448
|
+
block.paths |= pathBit;
|
|
27449
|
+
const recovered = output ? this.#settleDecoded(start, block, output) : [];
|
|
27450
|
+
this.#retireBehindHorizon();
|
|
27451
|
+
return recovered;
|
|
27452
|
+
}
|
|
27453
|
+
/**
|
|
27454
|
+
* Frees the decoder and every block. Blocks still unsettled are counted as
|
|
27455
|
+
* released, not failed: nothing proved them unrecoverable. Idempotent;
|
|
27456
|
+
* returns whether this call released anything.
|
|
27457
|
+
*/
|
|
27458
|
+
release() {
|
|
27459
|
+
const decoder = this.#decoder;
|
|
27460
|
+
if (!decoder) return false;
|
|
27461
|
+
this.#decoder = null;
|
|
27462
|
+
this.#stats.blocksReleased += this.#blocks.size;
|
|
27463
|
+
for (const block of this.#blocks.values()) this.#noteMixed(block, "released");
|
|
27464
|
+
this.#blocks.clear();
|
|
27465
|
+
this.#settled.clear();
|
|
27466
|
+
this.#have.clear();
|
|
27467
|
+
decoder.free();
|
|
27468
|
+
return true;
|
|
27469
|
+
}
|
|
27470
|
+
#drop(reason) {
|
|
27471
|
+
this.#stats.dropped[reason] = (this.#stats.dropped[reason] ?? 0) + 1;
|
|
27472
|
+
return [];
|
|
27473
|
+
}
|
|
27474
|
+
#noteNewest(ssId) {
|
|
27475
|
+
if (this.#newest === void 0 || serial32Precedes(this.#newest, ssId)) this.#newest = ssId;
|
|
27476
|
+
}
|
|
27477
|
+
#blockStartOf(ssId) {
|
|
27478
|
+
for (const [start, block] of this.#blocks) {
|
|
27479
|
+
if (isoBlockContains(start, block.ssbLength, ssId)) return start;
|
|
27480
|
+
}
|
|
27481
|
+
return void 0;
|
|
27482
|
+
}
|
|
27483
|
+
/** Counts the sources of a new block the parser already has, and their paths. */
|
|
27484
|
+
#countHeld(start, block) {
|
|
27485
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
27486
|
+
const pathBit = this.#have.get(serial32Add(start, i));
|
|
27487
|
+
if (pathBit === void 0) continue;
|
|
27488
|
+
block.received++;
|
|
27489
|
+
block.paths |= pathBit;
|
|
27490
|
+
}
|
|
27491
|
+
}
|
|
27492
|
+
#noteMixed(block, outcome) {
|
|
27493
|
+
if ((block.paths & MIXED_PATHS) === MIXED_PATHS) this.#stats.mixedPath[outcome]++;
|
|
27494
|
+
}
|
|
27495
|
+
/** The decoder's own rule: more than its retention behind, counted from below. */
|
|
27496
|
+
#behindHorizon(start) {
|
|
27497
|
+
const newest = this.#newest;
|
|
27498
|
+
if (newest === void 0) return false;
|
|
27499
|
+
return isoBlocksBehindLowerBound(start, newest, this.sourceSymbols) > this.retentionBlocks;
|
|
27500
|
+
}
|
|
27501
|
+
#settle(start) {
|
|
27502
|
+
this.#blocks.delete(start);
|
|
27503
|
+
this.#settled.add(start);
|
|
27504
|
+
}
|
|
27505
|
+
#settleClean(start) {
|
|
27506
|
+
const block = this.#blocks.get(start);
|
|
27507
|
+
if (!block) return;
|
|
27508
|
+
this.#settle(start);
|
|
27509
|
+
this.#stats.blocksClean++;
|
|
27510
|
+
this.#noteMixed(block, "clean");
|
|
27511
|
+
try {
|
|
27512
|
+
this.#decoder?.cleanup_blocks_detailed(Uint32Array.of(start));
|
|
27513
|
+
} catch {
|
|
27514
|
+
}
|
|
27515
|
+
}
|
|
27516
|
+
/**
|
|
27517
|
+
* The decoder returns a completed block as its K' ssbg_mode1 symbols,
|
|
27518
|
+
* concatenated: split by T, trim by each symbol's length field, and hand
|
|
27519
|
+
* back the packets the parser does not have yet.
|
|
27520
|
+
*/
|
|
27521
|
+
#settleDecoded(start, block, output) {
|
|
27522
|
+
this.#settle(start);
|
|
27523
|
+
if (output.byteLength !== block.ssbLength * this.symbolSize) {
|
|
27524
|
+
this.#stats.blocksFailed++;
|
|
27525
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
27526
|
+
this.#noteMixed(block, "failed");
|
|
27527
|
+
this.#drop("block:decoded-length");
|
|
27528
|
+
return [];
|
|
27529
|
+
}
|
|
27530
|
+
const recovered = [];
|
|
27531
|
+
let refused = 0;
|
|
27532
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
27533
|
+
const ssId = serial32Add(start, i);
|
|
27534
|
+
if (this.#have.has(ssId)) continue;
|
|
27535
|
+
const symbol = output.subarray(i * this.symbolSize, (i + 1) * this.symbolSize);
|
|
27536
|
+
const packet = trimSsbg1SourceSymbol(symbol);
|
|
27537
|
+
if (!packet) {
|
|
27538
|
+
refused++;
|
|
27539
|
+
continue;
|
|
27540
|
+
}
|
|
27541
|
+
this.#have.set(ssId, 0);
|
|
27542
|
+
recovered.push(packet.slice());
|
|
27543
|
+
}
|
|
27544
|
+
if (refused > 0) {
|
|
27545
|
+
this.#stats.blocksFailed++;
|
|
27546
|
+
this.#stats.packetsLost += refused;
|
|
27547
|
+
this.#noteMixed(block, "failed");
|
|
27548
|
+
this.#drop("block:bad-ssbg1-symbol");
|
|
27549
|
+
} else if (recovered.length === 0) {
|
|
27550
|
+
this.#stats.blocksClean++;
|
|
27551
|
+
this.#noteMixed(block, "clean");
|
|
27552
|
+
} else {
|
|
27553
|
+
this.#stats.blocksRecovered++;
|
|
27554
|
+
this.#noteMixed(block, "recovered");
|
|
27555
|
+
}
|
|
27556
|
+
this.#stats.packetsRecovered += recovered.length;
|
|
27557
|
+
return recovered;
|
|
27558
|
+
}
|
|
27559
|
+
/**
|
|
27560
|
+
* Retires every block, and every SS_ID the session remembers, that the
|
|
27561
|
+
* newest SS_ID has moved past the retention. An unsettled block retired
|
|
27562
|
+
* here is a failure: more of its sources were lost than its repair could
|
|
27563
|
+
* restore, or its repair never arrived.
|
|
27564
|
+
*/
|
|
27565
|
+
#retireBehindHorizon() {
|
|
27566
|
+
const decoder = this.#decoder;
|
|
27567
|
+
const newest = this.#newest;
|
|
27568
|
+
if (!decoder || newest === void 0) return;
|
|
27569
|
+
try {
|
|
27570
|
+
decoder.cleanup_by_ss_start(newest);
|
|
27571
|
+
} catch {
|
|
27572
|
+
}
|
|
27573
|
+
for (const [start, block] of this.#blocks) {
|
|
27574
|
+
if (!this.#behindHorizon(start)) continue;
|
|
27575
|
+
this.#settle(start);
|
|
27576
|
+
this.#stats.blocksFailed++;
|
|
27577
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
27578
|
+
this.#noteMixed(block, "failed");
|
|
27579
|
+
}
|
|
27580
|
+
const prunedAt = this.#prunedAt;
|
|
27581
|
+
if (prunedAt !== void 0 && serial32Distance(prunedAt, newest) < this.sourceSymbols) return;
|
|
27582
|
+
this.#prunedAt = newest;
|
|
27583
|
+
for (const ssId of this.#have.keys()) {
|
|
27584
|
+
if (this.#behindHorizon(ssId)) this.#have.delete(ssId);
|
|
27585
|
+
}
|
|
27586
|
+
for (const start of this.#settled) {
|
|
27587
|
+
if (this.#behindHorizon(start)) this.#settled.delete(start);
|
|
27588
|
+
}
|
|
27589
|
+
}
|
|
27590
|
+
};
|
|
27591
|
+
function requirePositiveInteger(value, path) {
|
|
27592
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
27593
|
+
throw new Error(`MmtpFecSession: ${path} must be a positive integer (got ${String(value)})`);
|
|
27594
|
+
}
|
|
27595
|
+
return value;
|
|
27596
|
+
}
|
|
27597
|
+
function requireNumber(value, path) {
|
|
27598
|
+
if (typeof value !== "number") {
|
|
27599
|
+
throw new Error(`MmtpFecSession: ${path} is required (got ${String(value)}); it is never defaulted`);
|
|
27600
|
+
}
|
|
27601
|
+
return value;
|
|
27602
|
+
}
|
|
27603
|
+
|
|
26579
27604
|
// src/repair-fetch.ts
|
|
26580
27605
|
var MOQT_PRIORITY_MAX = 255;
|
|
26581
27606
|
var SOURCE_MEDIA_PRIORITY_MAX = REPAIR_PRIORITY_MIN - 1;
|
|
@@ -26610,6 +27635,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26610
27635
|
if (typeof opts.presentationDelayMs !== "function") {
|
|
26611
27636
|
throw new Error("[RepairFetch] presentationDelayMs is required: a repair FETCH is due by the block's presentation deadline");
|
|
26612
27637
|
}
|
|
27638
|
+
if (opts.rangeTransport !== void 0 && (typeof opts.repairEpochReference !== "function" || !mc.onUndelimitedLoss || !mc.closeIsoHoles)) {
|
|
27639
|
+
throw new Error("[RepairFetch] rangeTransport needs repairEpochReference and a host that reports undelimited losses");
|
|
27640
|
+
}
|
|
26613
27641
|
const entries = /* @__PURE__ */ new Map();
|
|
26614
27642
|
const warnedNoTarget = /* @__PURE__ */ new Set();
|
|
26615
27643
|
let disposed = false;
|
|
@@ -26623,7 +27651,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
26623
27651
|
const note = (type, entry) => {
|
|
26624
27652
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26625
27653
|
};
|
|
27654
|
+
const clearEntry = (entry) => {
|
|
27655
|
+
if (entry.range) mc.closeIsoHoles(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength);
|
|
27656
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
27657
|
+
};
|
|
26626
27658
|
const releaseHold = (entry) => {
|
|
27659
|
+
if (entry.range) return;
|
|
26627
27660
|
if (entry.catalogTrackName === void 0) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId);
|
|
26628
27661
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26629
27662
|
};
|
|
@@ -26656,10 +27689,10 @@ function wireRepairFetch(mc, opts) {
|
|
|
26656
27689
|
const admit = (entry, now) => {
|
|
26657
27690
|
const budgetMs = entry.deadlineAt - now;
|
|
26658
27691
|
const rttMs = readRtt();
|
|
26659
|
-
if (rttMs !== null && rttMs < budgetMs) return
|
|
27692
|
+
if (rttMs !== null && rttMs < budgetMs) return rttMs;
|
|
26660
27693
|
retire(entry);
|
|
26661
27694
|
releaseHold(entry);
|
|
26662
|
-
|
|
27695
|
+
clearEntry(entry);
|
|
26663
27696
|
mc.noteRepairSkipped(
|
|
26664
27697
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
26665
27698
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
@@ -26667,10 +27700,11 @@ function wireRepairFetch(mc, opts) {
|
|
|
26667
27700
|
entry.packetId,
|
|
26668
27701
|
entry.catalogTrackName
|
|
26669
27702
|
);
|
|
26670
|
-
return
|
|
27703
|
+
return null;
|
|
26671
27704
|
};
|
|
26672
27705
|
const retire = (entry) => {
|
|
26673
27706
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
27707
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
26674
27708
|
};
|
|
26675
27709
|
const urgentOutstanding = () => {
|
|
26676
27710
|
for (const entry of entries.values()) {
|
|
@@ -26699,17 +27733,28 @@ function wireRepairFetch(mc, opts) {
|
|
|
26699
27733
|
return derived.kind === "omit" ? { subscriberPriority: void 0 } : null;
|
|
26700
27734
|
};
|
|
26701
27735
|
const start = (entry, counted = true) => {
|
|
26702
|
-
|
|
27736
|
+
const now = performance.now();
|
|
27737
|
+
const rttMs = admit(entry, now);
|
|
27738
|
+
if (rttMs === null) return;
|
|
26703
27739
|
if (counted) entry.attempts++;
|
|
26704
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
27740
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
27741
|
+
rttMs,
|
|
27742
|
+
budgetMs: entry.deadlineAt - now,
|
|
27743
|
+
delayMs: entry.delayMs,
|
|
27744
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
27745
|
+
bound: entry.bound,
|
|
27746
|
+
...entry.range ? { range: true } : {}
|
|
27747
|
+
});
|
|
26705
27748
|
const run = { controller: new AbortController(), stopped: null };
|
|
26706
27749
|
entry.running = run;
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
27750
|
+
if (!entry.range) {
|
|
27751
|
+
mc.fecManager.holdBlockForRepair(
|
|
27752
|
+
entry.sbn,
|
|
27753
|
+
entry.packetId,
|
|
27754
|
+
entry.catalogTrackName,
|
|
27755
|
+
entry.deadlineAt
|
|
27756
|
+
);
|
|
27757
|
+
}
|
|
26713
27758
|
void execute(entry, run);
|
|
26714
27759
|
};
|
|
26715
27760
|
const dispatch = () => {
|
|
@@ -26721,14 +27766,14 @@ function wireRepairFetch(mc, opts) {
|
|
|
26721
27766
|
if (entry.deadlineAt <= now) {
|
|
26722
27767
|
stop(entry, "expired");
|
|
26723
27768
|
retire(entry);
|
|
26724
|
-
|
|
27769
|
+
clearEntry(entry);
|
|
26725
27770
|
}
|
|
26726
27771
|
continue;
|
|
26727
27772
|
}
|
|
26728
27773
|
if (entry.deadlineAt <= now) {
|
|
26729
27774
|
retire(entry);
|
|
26730
27775
|
if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
26731
|
-
|
|
27776
|
+
clearEntry(entry);
|
|
26732
27777
|
continue;
|
|
26733
27778
|
}
|
|
26734
27779
|
queued.push(entry);
|
|
@@ -26765,9 +27810,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26765
27810
|
entry.running = null;
|
|
26766
27811
|
if (error === void 0) {
|
|
26767
27812
|
retire(entry);
|
|
26768
|
-
if (fed === 0 || !decodable(entry)) {
|
|
27813
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
26769
27814
|
releaseHold(entry);
|
|
26770
|
-
|
|
27815
|
+
clearEntry(entry);
|
|
26771
27816
|
}
|
|
26772
27817
|
dispatch();
|
|
26773
27818
|
return;
|
|
@@ -26779,7 +27824,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26779
27824
|
}
|
|
26780
27825
|
retire(entry);
|
|
26781
27826
|
if (fed === 0) releaseHold(entry);
|
|
26782
|
-
|
|
27827
|
+
clearEntry(entry);
|
|
26783
27828
|
console.warn(
|
|
26784
27829
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
26785
27830
|
error
|
|
@@ -26795,15 +27840,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
26795
27840
|
};
|
|
26796
27841
|
const execute = async (entry, run) => {
|
|
26797
27842
|
let fed = 0;
|
|
27843
|
+
const common = {
|
|
27844
|
+
repairTrack: entry.repairTrack,
|
|
27845
|
+
blockProfile: entry.blockProfile,
|
|
27846
|
+
packetId: entry.packetId,
|
|
27847
|
+
signal: run.controller.signal,
|
|
27848
|
+
subscriberPriority: entry.subscriberPriority
|
|
27849
|
+
};
|
|
26798
27850
|
try {
|
|
26799
|
-
|
|
26800
|
-
|
|
26801
|
-
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
})) {
|
|
27851
|
+
const packets = entry.range ? opts.rangeTransport({
|
|
27852
|
+
...common,
|
|
27853
|
+
startGroup: entry.range.startGroup,
|
|
27854
|
+
endGroup: entry.range.endGroup,
|
|
27855
|
+
lostSsId: entry.range.lostSsId
|
|
27856
|
+
}) : opts.transport({ ...common, sbn: entry.sbn });
|
|
27857
|
+
for await (const packet of packets) {
|
|
26807
27858
|
if (run.stopped !== null || entry.running !== run) break;
|
|
26808
27859
|
fed++;
|
|
26809
27860
|
if (entry.catalogTrackName === void 0) {
|
|
@@ -26822,6 +27873,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26822
27873
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue;
|
|
26823
27874
|
retire(entry);
|
|
26824
27875
|
stop(entry, "reset");
|
|
27876
|
+
if (entry.range) clearEntry(entry);
|
|
26825
27877
|
}
|
|
26826
27878
|
warnedNoTarget.delete(noTargetKey(packetId, catalogTrackName));
|
|
26827
27879
|
dispatch();
|
|
@@ -26848,6 +27900,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26848
27900
|
);
|
|
26849
27901
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26850
27902
|
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
27903
|
+
entry2.anchorAt = promotedDeadline.anchorAt;
|
|
27904
|
+
entry2.delayMs = promotedDeadline.delayMs;
|
|
27905
|
+
entry2.bound = promotedDeadline.bound;
|
|
26851
27906
|
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26852
27907
|
}
|
|
26853
27908
|
if (entry2.running) {
|
|
@@ -26873,7 +27928,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26873
27928
|
if (waitMs === void 0) return null;
|
|
26874
27929
|
const waitDeadlineAt = now + waitMs;
|
|
26875
27930
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
26876
|
-
if (anchor === void 0)
|
|
27931
|
+
if (anchor === void 0) {
|
|
27932
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: "wait" };
|
|
27933
|
+
}
|
|
26877
27934
|
let delayMs;
|
|
26878
27935
|
try {
|
|
26879
27936
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -26884,12 +27941,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
26884
27941
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
26885
27942
|
if (retentionMs === void 0) return null;
|
|
26886
27943
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
26887
|
-
const
|
|
26888
|
-
|
|
27944
|
+
const at = (delay, delayBound) => {
|
|
27945
|
+
const presentAt = Math.min(anchor + delay, ceilingAt);
|
|
27946
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: "wait" };
|
|
27947
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : "retention" };
|
|
27948
|
+
};
|
|
27949
|
+
const base = at(delayMs, "presentation");
|
|
26889
27950
|
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
26890
|
-
if (budgetMs === null || budgetMs <= delayMs) return {
|
|
26891
|
-
const extended =
|
|
26892
|
-
return {
|
|
27951
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs };
|
|
27952
|
+
const extended = at(budgetMs, "keyframe");
|
|
27953
|
+
return {
|
|
27954
|
+
...extended,
|
|
27955
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
27956
|
+
anchorAt: anchor,
|
|
27957
|
+
delayMs: budgetMs
|
|
27958
|
+
};
|
|
26893
27959
|
};
|
|
26894
27960
|
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
26895
27961
|
try {
|
|
@@ -26966,6 +28032,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26966
28032
|
priority,
|
|
26967
28033
|
subscriberPriority: wire.subscriberPriority,
|
|
26968
28034
|
deadlineAt: deadline.deadlineAt,
|
|
28035
|
+
anchorAt: deadline.anchorAt,
|
|
28036
|
+
delayMs: deadline.delayMs,
|
|
28037
|
+
bound: deadline.bound,
|
|
26969
28038
|
order: enqueueOrder++,
|
|
26970
28039
|
attempts: 0,
|
|
26971
28040
|
running: null
|
|
@@ -26975,14 +28044,92 @@ function wireRepairFetch(mc, opts) {
|
|
|
26975
28044
|
if (entry.priority < 2) preemptDeltas();
|
|
26976
28045
|
dispatch();
|
|
26977
28046
|
});
|
|
28047
|
+
const rangeFor = (loss, repairTrack) => {
|
|
28048
|
+
let reference;
|
|
28049
|
+
try {
|
|
28050
|
+
reference = opts.repairEpochReference(repairTrack);
|
|
28051
|
+
} catch {
|
|
28052
|
+
return null;
|
|
28053
|
+
}
|
|
28054
|
+
if (reference === void 0) return null;
|
|
28055
|
+
try {
|
|
28056
|
+
const anchor = loss.previousBlockStart === void 0 ? { reference } : { previousBlockStart: extendSsId(reference, loss.previousBlockStart) };
|
|
28057
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor);
|
|
28058
|
+
} catch (error) {
|
|
28059
|
+
if (error instanceof RangeError) return null;
|
|
28060
|
+
throw error;
|
|
28061
|
+
}
|
|
28062
|
+
};
|
|
28063
|
+
if (opts.rangeTransport !== void 0) {
|
|
28064
|
+
mc.onUndelimitedLoss((loss) => {
|
|
28065
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss;
|
|
28066
|
+
const close = () => mc.closeIsoHoles(packetId, catalogTrackName, holeStart, holeLength);
|
|
28067
|
+
if (disposed) return close();
|
|
28068
|
+
const blockProfile = blockProfileOf(packetId);
|
|
28069
|
+
const target = opts.resolveTarget(packetId, catalogTrackName);
|
|
28070
|
+
if (!target) return close();
|
|
28071
|
+
const priority = repairPriorityForClass("unknown");
|
|
28072
|
+
const range = rangeFor(loss, target.repairTrack);
|
|
28073
|
+
if (range === null) {
|
|
28074
|
+
close();
|
|
28075
|
+
mc.noteRepairSkipped("range-no-anchor", { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName);
|
|
28076
|
+
return;
|
|
28077
|
+
}
|
|
28078
|
+
const identity = {
|
|
28079
|
+
target,
|
|
28080
|
+
sbn: holeStart,
|
|
28081
|
+
packetId,
|
|
28082
|
+
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
28083
|
+
};
|
|
28084
|
+
const wire = wirePriority(identity, "unknown");
|
|
28085
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), "unknown");
|
|
28086
|
+
if (deadline === null) {
|
|
28087
|
+
close();
|
|
28088
|
+
mc.noteRepairSkipped(
|
|
28089
|
+
"presentation-delay-unavailable",
|
|
28090
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
28091
|
+
holeStart,
|
|
28092
|
+
packetId,
|
|
28093
|
+
catalogTrackName
|
|
28094
|
+
);
|
|
28095
|
+
return;
|
|
28096
|
+
}
|
|
28097
|
+
const entry = {
|
|
28098
|
+
key: JSON.stringify(["range", packetId, catalogTrackName ?? null, holeStart]),
|
|
28099
|
+
...identity,
|
|
28100
|
+
repairTrack: target.repairTrack,
|
|
28101
|
+
blockProfile,
|
|
28102
|
+
priority,
|
|
28103
|
+
subscriberPriority: wire.subscriberPriority,
|
|
28104
|
+
deadlineAt: deadline.deadlineAt,
|
|
28105
|
+
anchorAt: deadline.anchorAt,
|
|
28106
|
+
delayMs: deadline.delayMs,
|
|
28107
|
+
bound: deadline.bound,
|
|
28108
|
+
order: enqueueOrder++,
|
|
28109
|
+
attempts: 0,
|
|
28110
|
+
running: null,
|
|
28111
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength }
|
|
28112
|
+
};
|
|
28113
|
+
const previous = entries.get(entry.key);
|
|
28114
|
+
if (previous) {
|
|
28115
|
+
retire(previous);
|
|
28116
|
+
stop(previous, "reset");
|
|
28117
|
+
}
|
|
28118
|
+
entries.set(entry.key, entry);
|
|
28119
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1);
|
|
28120
|
+
preemptDeltas();
|
|
28121
|
+
dispatch();
|
|
28122
|
+
});
|
|
28123
|
+
}
|
|
26978
28124
|
return () => {
|
|
26979
28125
|
disposed = true;
|
|
26980
28126
|
removeResetObserver();
|
|
26981
28127
|
removeLifecycleObserver();
|
|
26982
28128
|
for (const entry of [...entries.values()]) {
|
|
26983
|
-
|
|
28129
|
+
clearEntry(entry);
|
|
26984
28130
|
if (entry.running) releaseHold(entry);
|
|
26985
28131
|
stop(entry, "disposed");
|
|
28132
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
26986
28133
|
}
|
|
26987
28134
|
entries.clear();
|
|
26988
28135
|
};
|
|
@@ -27021,20 +28168,19 @@ export {
|
|
|
27021
28168
|
MfuReassemblyError,
|
|
27022
28169
|
MmtpContainerParser,
|
|
27023
28170
|
MmtpDecodePipeline,
|
|
28171
|
+
MmtpFecSession,
|
|
27024
28172
|
MmtpRouter,
|
|
27025
28173
|
MmtpToCmaf,
|
|
27026
28174
|
MulticastContainerContractError,
|
|
27027
28175
|
MulticastInputError,
|
|
27028
28176
|
MulticastManager,
|
|
27029
28177
|
MulticastTransport,
|
|
27030
|
-
NoneCodec,
|
|
27031
28178
|
REPAIR_LIFECYCLE_EVENT_TYPE,
|
|
27032
28179
|
REPAIR_LIFECYCLE_LOG_PREFIX,
|
|
27033
28180
|
REPAIR_PRIORITY_MAX,
|
|
27034
28181
|
REPAIR_PRIORITY_MIN,
|
|
27035
28182
|
REPAIR_TRACK_GEOMETRY_KEYS,
|
|
27036
28183
|
REPAIR_TRACK_ONLY_KEYS,
|
|
27037
|
-
ReedSolomonCodec,
|
|
27038
28184
|
RepairContractError,
|
|
27039
28185
|
SOURCE_MEDIA_PRIORITY_MAX,
|
|
27040
28186
|
SampleCombineError,
|
|
@@ -27055,6 +28201,7 @@ export {
|
|
|
27055
28201
|
buildHevcVideoInitSegment,
|
|
27056
28202
|
buildVideoInitSegment,
|
|
27057
28203
|
catalogAmtNetworkSource,
|
|
28204
|
+
catalogAtsc3NetworkSource,
|
|
27058
28205
|
catalogDeclaresFec,
|
|
27059
28206
|
catalogFecAvailable,
|
|
27060
28207
|
catalogFecDeclaresUnconfigurableInstance,
|
|
@@ -27071,7 +28218,6 @@ export {
|
|
|
27071
28218
|
computeFecDeliveryWindowMediaUnits,
|
|
27072
28219
|
computeFecDeliveryWindowMs,
|
|
27073
28220
|
computeFecLossWindowMs,
|
|
27074
|
-
createFecCodec,
|
|
27075
28221
|
createFragment,
|
|
27076
28222
|
createWasmMmtpContainerParser,
|
|
27077
28223
|
datagramMfuReassembly,
|
|
@@ -27099,6 +28245,7 @@ export {
|
|
|
27099
28245
|
extractHevcCodecDescription,
|
|
27100
28246
|
extractHevcParameterSets,
|
|
27101
28247
|
extractSpsPpsFromAvcC,
|
|
28248
|
+
fecAlgorithmUnimplemented,
|
|
27102
28249
|
findAnnexBStartCode,
|
|
27103
28250
|
forwardRepairLifecycleEvents,
|
|
27104
28251
|
frameSamplesFromInit,
|