@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbd83cb48eff
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 +5 -3
- package/dist/browser-runtime.js +532 -333
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +5 -3
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +18 -5
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +5 -2
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +100 -36
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.js +3 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/delivery-catalog.js +84 -220
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +15 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +99 -39
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +3 -2
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +16 -9
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +13 -2
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js +3 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +24 -13
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +96 -22
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +124 -36
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +96 -22
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +14 -4
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +139 -22
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-input.js +3 -0
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +49 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +437 -302
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +93 -224
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +24 -13
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +123 -35
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.js +3 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.js +3 -0
- package/dist/repair-layers.js.map +3 -3
- 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.js +3 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +24 -13
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +96 -22
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/carp-catalog.ts +33 -10
- package/src/catalog-fec-params.ts +38 -17
- package/src/fec-manager.ts +111 -49
- package/src/fec-state.ts +4 -9
- package/src/fec-worker-setup.ts +16 -1
- package/src/index.ts +5 -0
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-router.ts +76 -5
- package/src/multicast-manager.ts +143 -7
- package/src/multicast-transport.ts +14 -3
- package/src/sample-combiner.ts +15 -2
- package/test-vectors/catalog/README.md +5 -1
- package/test-vectors/catalog-validation.json +95 -0
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);
|
|
@@ -949,6 +957,71 @@ function isoBlocksBehindLowerBound(a, b, kMax) {
|
|
|
949
957
|
return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
|
|
950
958
|
}
|
|
951
959
|
|
|
960
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
961
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
962
|
+
function recordOf(value) {
|
|
963
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
964
|
+
}
|
|
965
|
+
function locateCatalogFecSource(catalog, source, roles = ALL_ROLES) {
|
|
966
|
+
const root = recordOf(catalog);
|
|
967
|
+
if (root === void 0)
|
|
968
|
+
return void 0;
|
|
969
|
+
for (const role of roles) {
|
|
970
|
+
const renditions = recordOf(recordOf(root[role])?.["renditions"]);
|
|
971
|
+
if (renditions === void 0 || !Object.hasOwn(renditions, source))
|
|
972
|
+
continue;
|
|
973
|
+
const entry2 = recordOf(renditions[source]);
|
|
974
|
+
if (entry2 === void 0)
|
|
975
|
+
continue;
|
|
976
|
+
return Object.freeze({
|
|
977
|
+
dialect: "hang",
|
|
978
|
+
role,
|
|
979
|
+
entry: entry2,
|
|
980
|
+
fec: entry2["fec"],
|
|
981
|
+
fecPath: `$.${role}.renditions[${JSON.stringify(source)}].fec`
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
const tracks = root["tracks"];
|
|
985
|
+
if (!Array.isArray(tracks))
|
|
986
|
+
return void 0;
|
|
987
|
+
const index = tracks.findIndex((track) => recordOf(track)?.["name"] === source);
|
|
988
|
+
if (index < 0)
|
|
989
|
+
return void 0;
|
|
990
|
+
const entry = recordOf(tracks[index]) ?? {};
|
|
991
|
+
return Object.freeze({
|
|
992
|
+
dialect: "msf",
|
|
993
|
+
index,
|
|
994
|
+
entry,
|
|
995
|
+
fec: entry["fec"],
|
|
996
|
+
fecPath: `$.tracks[${index}].fec`
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
function isoBlockSpanUsable(fec) {
|
|
1000
|
+
const block = recordOf(fec);
|
|
1001
|
+
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
|
|
1002
|
+
return true;
|
|
1003
|
+
const ms = block["interleaveDepthMs"];
|
|
1004
|
+
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
1005
|
+
}
|
|
1006
|
+
function catalogFecAvailable(fec) {
|
|
1007
|
+
const block = recordOf(fec);
|
|
1008
|
+
if (block === void 0)
|
|
1009
|
+
return true;
|
|
1010
|
+
const declaresFecInstance = block["algorithm"] !== "none";
|
|
1011
|
+
const profile = block["blockProfile"];
|
|
1012
|
+
const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
|
|
1013
|
+
return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
|
|
1014
|
+
}
|
|
1015
|
+
function isPositiveSafeInteger(value) {
|
|
1016
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1017
|
+
}
|
|
1018
|
+
function catalogFecDeclaresUnconfigurableInstance(fec) {
|
|
1019
|
+
const block = recordOf(fec);
|
|
1020
|
+
if (block === void 0 || block["algorithm"] === "none")
|
|
1021
|
+
return false;
|
|
1022
|
+
return !(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"]));
|
|
1023
|
+
}
|
|
1024
|
+
|
|
952
1025
|
// src/mfu-reassembler.ts
|
|
953
1026
|
function fragmentProvenance(fragment) {
|
|
954
1027
|
if (fragment.deliveryProvenance !== void 0) return fragment.deliveryProvenance;
|
|
@@ -3821,8 +3894,14 @@ var SampleCombiner = class {
|
|
|
3821
3894
|
/**
|
|
3822
3895
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
3823
3896
|
* constituent data unit has arrived and totals the authored size.
|
|
3897
|
+
*
|
|
3898
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
3899
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
3900
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
3901
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
3902
|
+
* fragments, or one decoded before its source copy arrived.
|
|
3824
3903
|
*/
|
|
3825
|
-
addMfu(mfu) {
|
|
3904
|
+
addMfu(mfu, sampleSize) {
|
|
3826
3905
|
if (mfu.movieFragmentSequenceNumber === void 0 || mfu.sampleNumber === void 0) {
|
|
3827
3906
|
this.#stats.passthroughSamples++;
|
|
3828
3907
|
return fromPassthrough(mfu);
|
|
@@ -3838,7 +3917,7 @@ var SampleCombiner = class {
|
|
|
3838
3917
|
return null;
|
|
3839
3918
|
}
|
|
3840
3919
|
const dataLen = mfu.data.byteLength;
|
|
3841
|
-
const authoredSize = this.#authoredSizes.get(key);
|
|
3920
|
+
const authoredSize = this.#authoredSizes.get(key) ?? sampleSize;
|
|
3842
3921
|
if (offset === 0 && !this.#pending.has(key)) {
|
|
3843
3922
|
const passesThrough = authoredSize === void 0 ? !this.#requireAuthoredSize : dataLen === authoredSize;
|
|
3844
3923
|
if (passesThrough) {
|
|
@@ -4132,6 +4211,12 @@ if (void 0) {
|
|
|
4132
4211
|
const out = c.addMfu(mfu(1, 9, 17, 5, [6, 7, 8, 9, 10], 1001n, false));
|
|
4133
4212
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
4134
4213
|
});
|
|
4214
|
+
test("a size handed with the data unit completes a sample no head registered", () => {
|
|
4215
|
+
const c = combiner({ requireAuthoredSize: true });
|
|
4216
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5);
|
|
4217
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
|
|
4218
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull();
|
|
4219
|
+
});
|
|
4135
4220
|
test("duplicate offset is rejected", () => {
|
|
4136
4221
|
const c = combiner();
|
|
4137
4222
|
c.registerAuthoredSize(void 0, 1, 9, 17, 10);
|
|
@@ -6775,11 +6860,21 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6775
6860
|
const timescale = BigInt(track["timescale"]);
|
|
6776
6861
|
const durationTicks = track["groupDurationTicks"];
|
|
6777
6862
|
const ticks = durationTicks !== void 0 ? BigInt(durationTicks) : BigInt(track["groupDurationMs"]) * timescale / 1000n;
|
|
6778
|
-
const
|
|
6779
|
-
|
|
6780
|
-
|
|
6863
|
+
const framerate = track["framerate"];
|
|
6864
|
+
const intraOnly = positiveNumber2(framerate) && Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
|
|
6865
|
+
const members = switchingSets.get(altGroup) ?? [];
|
|
6866
|
+
members.push({ index, name: track["name"], ticks, timescale, intraOnly });
|
|
6867
|
+
switchingSets.set(altGroup, members);
|
|
6868
|
+
}
|
|
6869
|
+
for (const [altGroup, members] of switchingSets) {
|
|
6870
|
+
const anchor = members.find((member) => !member.intraOnly) ?? members[0];
|
|
6871
|
+
for (const member of members) {
|
|
6872
|
+
if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
|
|
6873
|
+
const nests = member.intraOnly && !anchor.intraOnly && anchor.ticks * member.timescale % (member.ticks * anchor.timescale) === 0n;
|
|
6874
|
+
if (!nests) {
|
|
6875
|
+
catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
|
|
6876
|
+
}
|
|
6781
6877
|
}
|
|
6782
|
-
if (!anchor) switchingSets.set(altGroup, { name: track["name"], ticks, timescale });
|
|
6783
6878
|
}
|
|
6784
6879
|
const multicast = catalog["multicast"];
|
|
6785
6880
|
if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
|
|
@@ -6890,178 +6985,6 @@ var MoqFecAlgorithm;
|
|
|
6890
6985
|
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
6891
6986
|
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
6892
6987
|
|
|
6893
|
-
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
6894
|
-
var MPU_HEADER_SIZE2 = 8;
|
|
6895
|
-
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
6896
|
-
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
6897
|
-
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
6898
|
-
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
6899
|
-
|
|
6900
|
-
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
6901
|
-
var DEFAULT_AMT_RELAY_PORT2 = 2268;
|
|
6902
|
-
|
|
6903
|
-
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
6904
|
-
var NTP_SHORT_BITS2 = 32;
|
|
6905
|
-
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
6906
|
-
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
6907
|
-
function isNtpShort(value) {
|
|
6908
|
-
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
6909
|
-
}
|
|
6910
|
-
function compareNtpShort(a, b) {
|
|
6911
|
-
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
6912
|
-
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
6913
|
-
}
|
|
6914
|
-
if (a === b)
|
|
6915
|
-
return "equal";
|
|
6916
|
-
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
6917
|
-
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
6918
|
-
return "after";
|
|
6919
|
-
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
6920
|
-
return "before";
|
|
6921
|
-
return "unordered";
|
|
6922
|
-
}
|
|
6923
|
-
|
|
6924
|
-
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
6925
|
-
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
6926
|
-
"iso-ssbg1-v1"
|
|
6927
|
-
]);
|
|
6928
|
-
|
|
6929
|
-
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
6930
|
-
var DRIADDiscovery = class {
|
|
6931
|
-
cache = /* @__PURE__ */ new Map();
|
|
6932
|
-
cacheExpiry = 3e5;
|
|
6933
|
-
// 5 minutes
|
|
6934
|
-
/**
|
|
6935
|
-
* Discover AMT relays for a multicast source address (RFC 8777)
|
|
6936
|
-
*
|
|
6937
|
-
* @param source - The multicast source IP address (NOT the group!)
|
|
6938
|
-
* @returns Array of discovered AMT relays that can tunnel traffic from this source
|
|
6939
|
-
*/
|
|
6940
|
-
async discoverRelays(source) {
|
|
6941
|
-
const cached = this.cache.get(source);
|
|
6942
|
-
if (cached) {
|
|
6943
|
-
return cached;
|
|
6944
|
-
}
|
|
6945
|
-
try {
|
|
6946
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
6947
|
-
const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
|
|
6948
|
-
console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
|
|
6949
|
-
const relays = await this.queryDRIADProxy(source);
|
|
6950
|
-
if (relays.length > 0) {
|
|
6951
|
-
this.cache.set(source, relays);
|
|
6952
|
-
setTimeout(() => this.cache.delete(source), this.cacheExpiry);
|
|
6953
|
-
}
|
|
6954
|
-
return relays;
|
|
6955
|
-
} catch (error) {
|
|
6956
|
-
console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
|
|
6957
|
-
return [];
|
|
6958
|
-
}
|
|
6959
|
-
}
|
|
6960
|
-
/**
|
|
6961
|
-
* Query DRIAD proxy service (browser-compatible)
|
|
6962
|
-
*/
|
|
6963
|
-
async queryDRIADProxy(source) {
|
|
6964
|
-
const proxyEndpoints = [
|
|
6965
|
-
"https://driad.amt.net/api/v1/relays",
|
|
6966
|
-
"https://multicast-gateway.cloudflare.com/driad"
|
|
6967
|
-
];
|
|
6968
|
-
for (const endpoint of proxyEndpoints) {
|
|
6969
|
-
try {
|
|
6970
|
-
const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
|
|
6971
|
-
method: "GET",
|
|
6972
|
-
headers: { Accept: "application/json" },
|
|
6973
|
-
signal: AbortSignal.timeout(5e3)
|
|
6974
|
-
});
|
|
6975
|
-
if (response.ok) {
|
|
6976
|
-
const data = await response.json();
|
|
6977
|
-
return data.relays || [];
|
|
6978
|
-
}
|
|
6979
|
-
} catch {
|
|
6980
|
-
}
|
|
6981
|
-
}
|
|
6982
|
-
const dohRelay = await this.queryDNSOverHTTPS(source);
|
|
6983
|
-
if (dohRelay) {
|
|
6984
|
-
return [dohRelay];
|
|
6985
|
-
}
|
|
6986
|
-
return [];
|
|
6987
|
-
}
|
|
6988
|
-
/**
|
|
6989
|
-
* Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
|
|
6990
|
-
*/
|
|
6991
|
-
async queryDNSOverHTTPS(source) {
|
|
6992
|
-
try {
|
|
6993
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
6994
|
-
const queryName = `${reversedSource}.amt.in-addr.arpa`;
|
|
6995
|
-
const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
|
|
6996
|
-
const response = await fetch(dohUrl, {
|
|
6997
|
-
headers: { Accept: "application/dns-json" },
|
|
6998
|
-
signal: AbortSignal.timeout(3e3)
|
|
6999
|
-
});
|
|
7000
|
-
if (!response.ok) {
|
|
7001
|
-
return null;
|
|
7002
|
-
}
|
|
7003
|
-
const result = await response.json();
|
|
7004
|
-
if (result.Answer && result.Answer.length > 0) {
|
|
7005
|
-
return {
|
|
7006
|
-
host: result.Answer[0].data,
|
|
7007
|
-
port: DEFAULT_AMT_RELAY_PORT2,
|
|
7008
|
-
priority: 10,
|
|
7009
|
-
weight: 100,
|
|
7010
|
-
asn: 0
|
|
7011
|
-
};
|
|
7012
|
-
}
|
|
7013
|
-
return null;
|
|
7014
|
-
} catch (error) {
|
|
7015
|
-
console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
|
|
7016
|
-
return null;
|
|
7017
|
-
}
|
|
7018
|
-
}
|
|
7019
|
-
/**
|
|
7020
|
-
* Select best relay based on RTT measurements
|
|
7021
|
-
*/
|
|
7022
|
-
async selectBestRelay(relays) {
|
|
7023
|
-
if (relays.length === 0)
|
|
7024
|
-
return null;
|
|
7025
|
-
const measured = await Promise.all(relays.map(async (relay) => {
|
|
7026
|
-
const rtt = await this.measureRTT(relay.host, relay.port);
|
|
7027
|
-
return { ...relay, rtt };
|
|
7028
|
-
}));
|
|
7029
|
-
measured.sort((a, b) => {
|
|
7030
|
-
if (a.priority !== b.priority)
|
|
7031
|
-
return a.priority - b.priority;
|
|
7032
|
-
return (a.rtt || Infinity) - (b.rtt || Infinity);
|
|
7033
|
-
});
|
|
7034
|
-
console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
|
|
7035
|
-
return measured[0];
|
|
7036
|
-
}
|
|
7037
|
-
async measureRTT(host, _port) {
|
|
7038
|
-
const start = performance.now();
|
|
7039
|
-
try {
|
|
7040
|
-
await fetch(`https://${host}/health`, {
|
|
7041
|
-
method: "HEAD",
|
|
7042
|
-
signal: AbortSignal.timeout(2e3),
|
|
7043
|
-
mode: "no-cors"
|
|
7044
|
-
});
|
|
7045
|
-
return performance.now() - start;
|
|
7046
|
-
} catch {
|
|
7047
|
-
return Infinity;
|
|
7048
|
-
}
|
|
7049
|
-
}
|
|
7050
|
-
/**
|
|
7051
|
-
* Clear the relay cache
|
|
7052
|
-
*/
|
|
7053
|
-
clearCache() {
|
|
7054
|
-
this.cache.clear();
|
|
7055
|
-
}
|
|
7056
|
-
/**
|
|
7057
|
-
* Get cached relays for a source address
|
|
7058
|
-
*/
|
|
7059
|
-
getCached(source) {
|
|
7060
|
-
return this.cache.get(source);
|
|
7061
|
-
}
|
|
7062
|
-
};
|
|
7063
|
-
var driadDiscovery = new DRIADDiscovery();
|
|
7064
|
-
|
|
7065
6988
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
7066
6989
|
function endpointKey(endpoint) {
|
|
7067
6990
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -7269,6 +7192,45 @@ var AdaptiveBitrateController = class {
|
|
|
7269
7192
|
}
|
|
7270
7193
|
};
|
|
7271
7194
|
|
|
7195
|
+
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
7196
|
+
var MPU_HEADER_SIZE2 = 8;
|
|
7197
|
+
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
7198
|
+
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
7199
|
+
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
7200
|
+
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
7201
|
+
|
|
7202
|
+
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
7203
|
+
var DEFAULT_AMT_RELAY_PORT2 = 2268;
|
|
7204
|
+
|
|
7205
|
+
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
7206
|
+
var NTP_SHORT_BITS2 = 32;
|
|
7207
|
+
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
7208
|
+
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
7209
|
+
function isNtpShort(value) {
|
|
7210
|
+
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
7211
|
+
}
|
|
7212
|
+
function compareNtpShort(a, b) {
|
|
7213
|
+
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
7214
|
+
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
7215
|
+
}
|
|
7216
|
+
if (a === b)
|
|
7217
|
+
return "equal";
|
|
7218
|
+
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
7219
|
+
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
7220
|
+
return "after";
|
|
7221
|
+
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
7222
|
+
return "before";
|
|
7223
|
+
return "unordered";
|
|
7224
|
+
}
|
|
7225
|
+
|
|
7226
|
+
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
7227
|
+
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
7228
|
+
"iso-ssbg1-v1"
|
|
7229
|
+
]);
|
|
7230
|
+
|
|
7231
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
7232
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
7233
|
+
|
|
7272
7234
|
// node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
|
|
7273
7235
|
var DEFAULT_DWELL_MS = 3e3;
|
|
7274
7236
|
var DEFAULT_JOIN_DEADLINE_MS = 5e3;
|
|
@@ -7507,7 +7469,8 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7507
7469
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
7508
7470
|
};
|
|
7509
7471
|
const relay = input.amtRelay?.trim();
|
|
7510
|
-
const
|
|
7472
|
+
const driad = !relay && input.amtDiscovery === "driad";
|
|
7473
|
+
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
7511
7474
|
if (!wantsAmt) {
|
|
7512
7475
|
const native = {
|
|
7513
7476
|
...base,
|
|
@@ -7517,6 +7480,20 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7517
7480
|
return native;
|
|
7518
7481
|
}
|
|
7519
7482
|
const relayPort = input.amtRelayPort;
|
|
7483
|
+
if (driad) {
|
|
7484
|
+
if (!base.source)
|
|
7485
|
+
throw new TypeError("AMT DRIAD discovery requires a source address");
|
|
7486
|
+
if (relayPort !== void 0 && !isPositivePort(relayPort)) {
|
|
7487
|
+
throw new TypeError("AMT DRIAD discovery requires a valid relay port when one is given");
|
|
7488
|
+
}
|
|
7489
|
+
return {
|
|
7490
|
+
...base,
|
|
7491
|
+
source: base.source,
|
|
7492
|
+
origin: "amt",
|
|
7493
|
+
discovery: "driad",
|
|
7494
|
+
...relayPort !== void 0 ? { relayPort } : {}
|
|
7495
|
+
};
|
|
7496
|
+
}
|
|
7520
7497
|
if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
|
|
7521
7498
|
throw new TypeError("AMT requires a resolved relay and a valid relay port");
|
|
7522
7499
|
}
|
|
@@ -7560,7 +7537,8 @@ function normalizeMulticastEndpoint(endpoint) {
|
|
|
7560
7537
|
port: endpoint.port,
|
|
7561
7538
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
7562
7539
|
...amtRelay ? { amtRelay } : {},
|
|
7563
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
7540
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
7541
|
+
...endpoint.amtDiscovery === "driad" ? { amtDiscovery: "driad" } : {}
|
|
7564
7542
|
};
|
|
7565
7543
|
}
|
|
7566
7544
|
function multicastEndpointKey(endpoint) {
|
|
@@ -7573,7 +7551,9 @@ function multicastEndpointKey(endpoint) {
|
|
|
7573
7551
|
normalized.port,
|
|
7574
7552
|
normalized.mode ?? "auto",
|
|
7575
7553
|
normalized.amtRelay ?? "",
|
|
7576
|
-
normalized.amtRelayPort ?? ""
|
|
7554
|
+
normalized.amtRelayPort ?? "",
|
|
7555
|
+
// A DRIAD join is a different gateway subscription from a native one.
|
|
7556
|
+
...normalized.amtDiscovery ? [normalized.amtDiscovery] : []
|
|
7577
7557
|
]);
|
|
7578
7558
|
}
|
|
7579
7559
|
function isMulticastTrackPacketId(value) {
|
|
@@ -7613,7 +7593,8 @@ var MulticastSubscriptionPool = class {
|
|
|
7613
7593
|
port: config.port,
|
|
7614
7594
|
mode: config.mode,
|
|
7615
7595
|
amtRelay: config.amtRelay,
|
|
7616
|
-
amtRelayPort: config.amtRelayPort
|
|
7596
|
+
amtRelayPort: config.amtRelayPort,
|
|
7597
|
+
amtDiscovery: config.amtDiscovery
|
|
7617
7598
|
});
|
|
7618
7599
|
if (!endpoint)
|
|
7619
7600
|
throw new Error("Invalid multicast endpoint");
|
|
@@ -7679,7 +7660,8 @@ var MulticastSubscriptionPool = class {
|
|
|
7679
7660
|
port: endpoint.port,
|
|
7680
7661
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
7681
7662
|
...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
|
|
7682
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
7663
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
7664
|
+
...endpoint.amtDiscovery ? { amtDiscovery: endpoint.amtDiscovery } : {}
|
|
7683
7665
|
}));
|
|
7684
7666
|
const consumers = /* @__PURE__ */ new Map();
|
|
7685
7667
|
let entry;
|
|
@@ -7759,7 +7741,6 @@ var TransportManager = class {
|
|
|
7759
7741
|
};
|
|
7760
7742
|
capabilities = null;
|
|
7761
7743
|
subscription = null;
|
|
7762
|
-
driad = new DRIADDiscovery();
|
|
7763
7744
|
/** Built by `connect()` from the caller's ladder; there is no built-in one. */
|
|
7764
7745
|
abr = null;
|
|
7765
7746
|
multicastOrchestrator = null;
|
|
@@ -7809,8 +7790,8 @@ var TransportManager = class {
|
|
|
7809
7790
|
nativeIGMP: hasGatewayBytes,
|
|
7810
7791
|
directSockets: typeof win?.UDPSocket !== "undefined",
|
|
7811
7792
|
amt: false,
|
|
7812
|
-
driad:
|
|
7813
|
-
//
|
|
7793
|
+
driad: hasGatewayBytes,
|
|
7794
|
+
// the gateway runs RFC 8777 discovery
|
|
7814
7795
|
fecDecode: false
|
|
7815
7796
|
};
|
|
7816
7797
|
console.log("[Transport] Capabilities:", this.capabilities);
|
|
@@ -7821,7 +7802,7 @@ var TransportManager = class {
|
|
|
7821
7802
|
*
|
|
7822
7803
|
* Promotion hierarchy:
|
|
7823
7804
|
* 1. window.multicast gateway bytes
|
|
7824
|
-
* 2. AMT
|
|
7805
|
+
* 2. AMT: a configured relay via the AMT proxy, else gateway DRIAD discovery
|
|
7825
7806
|
* 3. MOQ WebTransport (final fallback)
|
|
7826
7807
|
*
|
|
7827
7808
|
* The ABR ladder (`abrLadder`) and initial rendition (`initialQuality`)
|
|
@@ -7915,7 +7896,7 @@ var TransportManager = class {
|
|
|
7915
7896
|
/**
|
|
7916
7897
|
* Connect via the lowercase window.multicast bytes gateway.
|
|
7917
7898
|
*/
|
|
7918
|
-
async connectWindowMulticast(config, generation) {
|
|
7899
|
+
async connectWindowMulticast(config, generation, mode = "multicast") {
|
|
7919
7900
|
try {
|
|
7920
7901
|
const gateway = this.getWindowMulticastGateway();
|
|
7921
7902
|
if (typeof gateway?.subscribe !== "function")
|
|
@@ -7950,7 +7931,7 @@ var TransportManager = class {
|
|
|
7950
7931
|
}
|
|
7951
7932
|
};
|
|
7952
7933
|
this.state = {
|
|
7953
|
-
mode
|
|
7934
|
+
mode,
|
|
7954
7935
|
connected: true,
|
|
7955
7936
|
group: config.group,
|
|
7956
7937
|
source: config.source,
|
|
@@ -7968,29 +7949,19 @@ var TransportManager = class {
|
|
|
7968
7949
|
}
|
|
7969
7950
|
}
|
|
7970
7951
|
/**
|
|
7971
|
-
* Connect via AMT proxy
|
|
7952
|
+
* Connect via AMT: a configured relay goes through the AMT proxy; with no
|
|
7953
|
+
* relay, the window.multicast gateway discovers one per RFC 8777 (DRIAD).
|
|
7972
7954
|
*/
|
|
7973
7955
|
async connectAmt(config, generation) {
|
|
7974
7956
|
try {
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
const relays = await this.driad.discoverRelays(config.source);
|
|
7979
|
-
if (generation !== this.connectionGeneration)
|
|
7980
|
-
return false;
|
|
7981
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
7982
|
-
if (generation !== this.connectionGeneration)
|
|
7983
|
-
return false;
|
|
7984
|
-
if (bestRelay) {
|
|
7985
|
-
amtRelay = bestRelay.host;
|
|
7986
|
-
this.state.amtRelay = amtRelay;
|
|
7987
|
-
}
|
|
7988
|
-
}
|
|
7989
|
-
if (!amtRelay) {
|
|
7957
|
+
if (config.amtRelay)
|
|
7958
|
+
return await this.connectAmtProxy(config, config.amtRelay, generation);
|
|
7959
|
+
if (config.driadEnabled === false || !config.source || config.mode === "native") {
|
|
7990
7960
|
console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
|
|
7991
7961
|
return false;
|
|
7992
7962
|
}
|
|
7993
|
-
|
|
7963
|
+
console.log(`[Transport] Asking the gateway for a DRIAD relay for source ${config.source}...`);
|
|
7964
|
+
return await this.connectWindowMulticast({ ...config, amtDiscovery: "driad" }, generation, "amt");
|
|
7994
7965
|
} catch (error) {
|
|
7995
7966
|
console.warn("[Transport] AMT connection failed:", error);
|
|
7996
7967
|
return false;
|
|
@@ -8221,7 +8192,6 @@ var AMTGatewayManager = class {
|
|
|
8221
8192
|
subscriptions = /* @__PURE__ */ new Map();
|
|
8222
8193
|
messageHandler;
|
|
8223
8194
|
pendingPackets = /* @__PURE__ */ new Map();
|
|
8224
|
-
driad = new DRIADDiscovery();
|
|
8225
8195
|
constructor() {
|
|
8226
8196
|
this.messageHandler = (event) => {
|
|
8227
8197
|
const data = event.data;
|
|
@@ -8252,26 +8222,12 @@ var AMTGatewayManager = class {
|
|
|
8252
8222
|
return keyStr;
|
|
8253
8223
|
}
|
|
8254
8224
|
try {
|
|
8255
|
-
|
|
8256
|
-
let discoveryMethod;
|
|
8225
|
+
const relayAddress = config.relayAddress;
|
|
8257
8226
|
const relayPort = config.relayPort || DEFAULT_AMT_RELAY_PORT2;
|
|
8258
|
-
if (
|
|
8259
|
-
|
|
8260
|
-
discoveryMethod = "manual";
|
|
8261
|
-
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
8262
|
-
} else if (key.source) {
|
|
8263
|
-
console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
|
|
8264
|
-
const relays = await this.driad.discoverRelays(key.source);
|
|
8265
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
8266
|
-
if (!bestRelay) {
|
|
8267
|
-
throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
|
|
8268
|
-
}
|
|
8269
|
-
relayAddress = bestRelay.host;
|
|
8270
|
-
discoveryMethod = "driad";
|
|
8271
|
-
console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
|
|
8272
|
-
} else {
|
|
8273
|
-
throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
|
|
8227
|
+
if (!relayAddress) {
|
|
8228
|
+
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".`);
|
|
8274
8229
|
}
|
|
8230
|
+
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
8275
8231
|
const subscriptionId = keyStr;
|
|
8276
8232
|
this.pendingPackets.set(subscriptionId, []);
|
|
8277
8233
|
const subscription = {
|
|
@@ -8282,7 +8238,7 @@ var AMTGatewayManager = class {
|
|
|
8282
8238
|
relay: {
|
|
8283
8239
|
address: relayAddress,
|
|
8284
8240
|
port: relayPort,
|
|
8285
|
-
discoveryMethod,
|
|
8241
|
+
discoveryMethod: "manual",
|
|
8286
8242
|
discoveredAt: Date.now()
|
|
8287
8243
|
}
|
|
8288
8244
|
};
|
|
@@ -12579,22 +12535,16 @@ var INACTIVE = Object.freeze({
|
|
|
12579
12535
|
"reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
|
|
12580
12536
|
"no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
|
|
12581
12537
|
});
|
|
12582
|
-
function
|
|
12538
|
+
function recordOf2(value) {
|
|
12583
12539
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12584
12540
|
}
|
|
12585
|
-
function
|
|
12541
|
+
function isPositiveSafeInteger2(value) {
|
|
12586
12542
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
12587
12543
|
}
|
|
12588
12544
|
function catalogDeclaresFec(fec) {
|
|
12589
|
-
const block =
|
|
12545
|
+
const block = recordOf2(fec);
|
|
12590
12546
|
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
12591
|
-
return
|
|
12592
|
-
}
|
|
12593
|
-
function isoBlockSpanUsable(fec) {
|
|
12594
|
-
const block = recordOf(fec);
|
|
12595
|
-
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
|
|
12596
|
-
const ms = block["interleaveDepthMs"];
|
|
12597
|
-
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
12547
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
12598
12548
|
}
|
|
12599
12549
|
function requireBoolean(value, field) {
|
|
12600
12550
|
if (typeof value !== "boolean") {
|
|
@@ -12610,7 +12560,7 @@ function resolveFecState(evidence) {
|
|
|
12610
12560
|
if (typeof transportPolicy !== "string" || !TRANSPORT_POLICIES.has(transportPolicy)) {
|
|
12611
12561
|
throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`);
|
|
12612
12562
|
}
|
|
12613
|
-
if (stats !== null && stats !== void 0 &&
|
|
12563
|
+
if (stats !== null && stats !== void 0 && recordOf2(stats) === void 0) {
|
|
12614
12564
|
throw new TypeError("resolveFecState: stats must be a plain object, null or undefined");
|
|
12615
12565
|
}
|
|
12616
12566
|
if (!catalogFec) return INACTIVE["no-catalog-fec"];
|
|
@@ -13315,9 +13265,13 @@ var FECManager = class _FECManager {
|
|
|
13315
13265
|
// per stream. Not only throws: the ordinary out-of-range case is detected by
|
|
13316
13266
|
// arithmetic and never throws at all.
|
|
13317
13267
|
this.#orderedHorizonWarnedFor = /* @__PURE__ */ new Set();
|
|
13318
|
-
// Newest block start (SS_Start)
|
|
13319
|
-
//
|
|
13268
|
+
// Newest block start (SS_Start) any symbol carried per stream and when: the
|
|
13269
|
+
// frontier isoSpanResolution reads.
|
|
13320
13270
|
this.#highestSbn = /* @__PURE__ */ new Map();
|
|
13271
|
+
// The same from source symbols alone: the frontier a source is judged
|
|
13272
|
+
// against for a discontinuity. Repairs ride their own group, which can run
|
|
13273
|
+
// blocks ahead of the media they protect.
|
|
13274
|
+
this.#sourceFrontiers = /* @__PURE__ */ new Map();
|
|
13321
13275
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
13322
13276
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
13323
13277
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
@@ -13335,8 +13289,8 @@ var FECManager = class _FECManager {
|
|
|
13335
13289
|
// rate-limited like the other per-symbol warns here. Cumulative.
|
|
13336
13290
|
this.#isoDecoderUnplacedRetireFailed = 0;
|
|
13337
13291
|
// The latest source symbol per stream that carried its MMTP
|
|
13338
|
-
// packet_sequence_number: the anchor that bounds how
|
|
13339
|
-
// producer can have
|
|
13292
|
+
// packet_sequence_number, by its own SS_ID: the anchor that bounds how far
|
|
13293
|
+
// the producer's SS_IDs can have moved before or after another source symbol.
|
|
13340
13294
|
this.#sourceAnchors = /* @__PURE__ */ new Map();
|
|
13341
13295
|
// Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
|
|
13342
13296
|
this.#packetEpochs = /* @__PURE__ */ new Map();
|
|
@@ -13474,6 +13428,7 @@ var FECManager = class _FECManager {
|
|
|
13474
13428
|
#materializedBlocks;
|
|
13475
13429
|
#orderedHorizonWarnedFor;
|
|
13476
13430
|
#highestSbn;
|
|
13431
|
+
#sourceFrontiers;
|
|
13477
13432
|
#isoLocators;
|
|
13478
13433
|
#isoRepairRefusedCount;
|
|
13479
13434
|
#isoSourceOversizeCount;
|
|
@@ -14064,8 +14019,8 @@ var FECManager = class _FECManager {
|
|
|
14064
14019
|
// Deliberately one block tighter than deriveFecRetentionBlocks over the same
|
|
14065
14020
|
// inputs (that function's `+ 1`). Different question: the retention horizon
|
|
14066
14021
|
// asks how long the decoder still ACCEPTS symbols for a block, this asks how
|
|
14067
|
-
// many blocks a stream can
|
|
14068
|
-
//
|
|
14022
|
+
// many blocks a stream can jump ahead of its frontier before a source symbol
|
|
14023
|
+
// there is a discontinuity rather than loss (see #noteSbnSeen).
|
|
14069
14024
|
// The extra block of retention is slack for a block still being fed; a block
|
|
14070
14025
|
// nothing has been heard from does not get it. Not the units defect — but it
|
|
14071
14026
|
// is the next place the two can drift, so change both or neither.
|
|
@@ -14075,55 +14030,72 @@ var FECManager = class _FECManager {
|
|
|
14075
14030
|
}
|
|
14076
14031
|
/**
|
|
14077
14032
|
* Record that a symbol for block `sbn` (the block's SS_Start) arrived and
|
|
14078
|
-
* advance the stream's
|
|
14033
|
+
* advance the stream's frontiers, the newest block start seen.
|
|
14079
14034
|
*
|
|
14080
|
-
* A SOURCE symbol
|
|
14081
|
-
*
|
|
14082
|
-
*
|
|
14035
|
+
* A SOURCE symbol is judged against the newest source block alone: repairs
|
|
14036
|
+
* ride their own group, which can run blocks ahead of the media. One whose
|
|
14037
|
+
* block goes back further than the blocks this manager retains, or that
|
|
14038
|
+
* cannot have been sent before the source it lies behind, or that jumps
|
|
14039
|
+
* further than the stream could have produced since its last symbol, is a
|
|
14040
|
+
* source discontinuity, not loss. A repair symbol can only advance the
|
|
14083
14041
|
* frontier: a D-28 fetch legitimately answers for an old block, so it never
|
|
14084
14042
|
* signals a discontinuity.
|
|
14085
14043
|
*
|
|
14086
14044
|
* The producer closes a block at its Dth media-unit boundary OR when K
|
|
14087
14045
|
* source symbols filled it, so one interleave span can start several blocks
|
|
14088
|
-
* (every large keyframe does). What bounds a
|
|
14089
|
-
*
|
|
14090
|
-
*
|
|
14091
|
-
*
|
|
14092
|
-
* packet_sequence_number
|
|
14093
|
-
*
|
|
14094
|
-
*
|
|
14046
|
+
* (every large keyframe does). What bounds a jump is therefore packet
|
|
14047
|
+
* evidence, not a block rate: SS_ID advances by one per FEC source packet
|
|
14048
|
+
* (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
|
|
14049
|
+
* packet of the packet_id, so with both source symbols'
|
|
14050
|
+
* packet_sequence_number their SS_IDs (`ssId`, not their block starts,
|
|
14051
|
+
* which a repair-less span can put far behind) can move at most the packets
|
|
14052
|
+
* sent between them, in either direction, plus K of slack for sources lost
|
|
14053
|
+
* before a hop that renumbers packets. Without it, only the D-close rate is
|
|
14054
|
+
* known.
|
|
14095
14055
|
*
|
|
14096
14056
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
14097
14057
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
14098
14058
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
14099
14059
|
*/
|
|
14100
|
-
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber) {
|
|
14060
|
+
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
|
|
14101
14061
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
14102
14062
|
const now = performance.now();
|
|
14103
|
-
const previous = this.#highestSbn.get(streamKey);
|
|
14063
|
+
const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
|
|
14104
14064
|
const anchor = this.#sourceAnchors.get(streamKey);
|
|
14105
14065
|
const psn = symbol === "source" && packetSequenceNumber !== void 0 && Number.isSafeInteger(packetSequenceNumber) && packetSequenceNumber >= 0 && packetSequenceNumber <= 4294967295 ? packetSequenceNumber : void 0;
|
|
14106
14066
|
const anchorHere = () => {
|
|
14107
|
-
if (psn !== void 0 && (anchor === void 0 || !
|
|
14108
|
-
this.#sourceAnchors.set(streamKey, {
|
|
14067
|
+
if (psn !== void 0 && (anchor === void 0 || !serial32Precedes(ssId, anchor.ssId))) {
|
|
14068
|
+
this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14109
14069
|
}
|
|
14110
14070
|
};
|
|
14071
|
+
const advance = () => {
|
|
14072
|
+
const highest = this.#highestSbn.get(streamKey);
|
|
14073
|
+
if (highest === void 0 || this.#blockPrecedes(highest.sbn, sbn)) {
|
|
14074
|
+
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14075
|
+
}
|
|
14076
|
+
if (symbol === "source") this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14077
|
+
anchorHere();
|
|
14078
|
+
};
|
|
14111
14079
|
const discontinuity = () => {
|
|
14112
14080
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
14113
14081
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14082
|
+
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14114
14083
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
14115
|
-
else this.#sourceAnchors.set(streamKey, {
|
|
14084
|
+
else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14116
14085
|
this.onSourceDiscontinuity?.(packetId, catalogTrackName);
|
|
14117
14086
|
};
|
|
14118
14087
|
if (previous === void 0) {
|
|
14119
|
-
|
|
14120
|
-
anchorHere();
|
|
14088
|
+
advance();
|
|
14121
14089
|
return;
|
|
14122
14090
|
}
|
|
14123
14091
|
const config = this.#trackConfig(packetId);
|
|
14124
14092
|
const window2 = this.#liveWindowBlocks(config);
|
|
14093
|
+
const sentInOrder = (from, to) => {
|
|
14094
|
+
const sent = to.psn - from.psn >>> 0;
|
|
14095
|
+
return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
|
|
14096
|
+
};
|
|
14125
14097
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
14126
|
-
if (symbol === "source" && window2 !== null && this.#blocksBehind(sbn, previous.sbn, packetId) >
|
|
14098
|
+
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))) {
|
|
14127
14099
|
discontinuity();
|
|
14128
14100
|
return;
|
|
14129
14101
|
}
|
|
@@ -14133,9 +14105,8 @@ var FECManager = class _FECManager {
|
|
|
14133
14105
|
const missing = this.#blocksBehind(previous.sbn, sbn, packetId) - 1;
|
|
14134
14106
|
let plausible = true;
|
|
14135
14107
|
if (window2 !== null) {
|
|
14136
|
-
if (psn !== void 0 && anchor !== void 0 &&
|
|
14137
|
-
|
|
14138
|
-
plausible = sent <= 2147483647 && serial32Distance(anchor.sbn, sbn) <= sent + config.k;
|
|
14108
|
+
if (psn !== void 0 && anchor !== void 0 && serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
|
|
14109
|
+
plausible = sentInOrder(anchor, { ssId, psn });
|
|
14139
14110
|
} else {
|
|
14140
14111
|
plausible = missing <= window2 + Math.ceil((now - previous.atMs) / config.interleaveDepthMs);
|
|
14141
14112
|
}
|
|
@@ -14145,8 +14116,7 @@ var FECManager = class _FECManager {
|
|
|
14145
14116
|
discontinuity();
|
|
14146
14117
|
return;
|
|
14147
14118
|
}
|
|
14148
|
-
|
|
14149
|
-
anchorHere();
|
|
14119
|
+
advance();
|
|
14150
14120
|
}
|
|
14151
14121
|
/*
|
|
14152
14122
|
* Block order for one stream (BLO-35597 iso:5). A block is keyed by its
|
|
@@ -14730,6 +14700,7 @@ var FECManager = class _FECManager {
|
|
|
14730
14700
|
resetSet(this.#materializedBlocks);
|
|
14731
14701
|
resetMap(this.#resolvedBlockClasses);
|
|
14732
14702
|
resetMap(this.#highestSbn);
|
|
14703
|
+
resetMap(this.#sourceFrontiers);
|
|
14733
14704
|
resetMap(this.#isoLocators);
|
|
14734
14705
|
resetMap(this.#sourceAnchors);
|
|
14735
14706
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -14835,6 +14806,7 @@ var FECManager = class _FECManager {
|
|
|
14835
14806
|
dropMap(this.#orderedPendingBlocks);
|
|
14836
14807
|
dropMap(this.#resolvedBlockClasses);
|
|
14837
14808
|
dropMap(this.#highestSbn);
|
|
14809
|
+
dropMap(this.#sourceFrontiers);
|
|
14838
14810
|
dropMap(this.#isoLocators);
|
|
14839
14811
|
dropMap(this.#sourceAnchors);
|
|
14840
14812
|
dropMap(this.#classifiers);
|
|
@@ -14927,7 +14899,13 @@ var FECManager = class _FECManager {
|
|
|
14927
14899
|
if (isSourceSymbol && esi === 0) {
|
|
14928
14900
|
this.#startupPartialBlocks.delete(blockKey);
|
|
14929
14901
|
this.#startupAlignedPackets.add(streamKey);
|
|
14930
|
-
} else if (
|
|
14902
|
+
} else if (
|
|
14903
|
+
// A ready multicast repair opens a block the join has not seen yet, never
|
|
14904
|
+
// a join partial: its sources were refused, so its repairs alone open a
|
|
14905
|
+
// block that cannot decode and fails at its deadline, once per packet ID
|
|
14906
|
+
// per join (BLO-48308).
|
|
14907
|
+
isStartupPartial || !this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair
|
|
14908
|
+
) {
|
|
14931
14909
|
this.#markStartupPartial(blockKey);
|
|
14932
14910
|
return false;
|
|
14933
14911
|
}
|
|
@@ -15252,6 +15230,10 @@ var FECManager = class _FECManager {
|
|
|
15252
15230
|
}
|
|
15253
15231
|
return blocks;
|
|
15254
15232
|
}
|
|
15233
|
+
/** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
|
|
15234
|
+
isoRetentionBlocksForPacket(packetId) {
|
|
15235
|
+
return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : void 0;
|
|
15236
|
+
}
|
|
15255
15237
|
/** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
|
|
15256
15238
|
isoSourceFits(packetId, packetLength) {
|
|
15257
15239
|
const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize;
|
|
@@ -15833,20 +15815,37 @@ var FECManager = class _FECManager {
|
|
|
15833
15815
|
* Caller is responsible for routing recovered data and updating
|
|
15834
15816
|
* block completion state via `markBlockCompleted()`.
|
|
15835
15817
|
*/
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15818
|
+
/**
|
|
15819
|
+
* Whether a repair symbol of `byteLength` bytes is a valid member of a
|
|
15820
|
+
* `packetId` block: every repair symbol is exactly the track's T. A symbol of
|
|
15821
|
+
* any other size is counted on `repairSymbolSizeMismatches`, warned (rate
|
|
15822
|
+
* limited) and refused. The router calls this before the symbol takes any
|
|
15823
|
+
* other part in block state (placement, first-arrival dedup, completed-block
|
|
15824
|
+
* accounting), so a malformed repair is counted whatever its arrival order:
|
|
15825
|
+
* judged after dedup, one landing on an already-complete block, or behind a
|
|
15826
|
+
* valid copy from the other transport, was swallowed as a duplicate and never
|
|
15827
|
+
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
15828
|
+
* nothing here; its repair is dropped upstream as unreadable.
|
|
15829
|
+
*/
|
|
15830
|
+
admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, byteLength) {
|
|
15831
|
+
if (!this.#hasBlockProfile(packetId)) return false;
|
|
15840
15832
|
const symbolSize = this.#trackConfig(packetId).symbolSize;
|
|
15841
|
-
if (symbolSize > 0 &&
|
|
15833
|
+
if (symbolSize > 0 && byteLength !== symbolSize) {
|
|
15842
15834
|
this.#repairSymbolSizeMismatchCount++;
|
|
15843
15835
|
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
15844
15836
|
console.warn(
|
|
15845
|
-
`[FECManager] Dropping repair symbol with invalid size: got ${
|
|
15837
|
+
`[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
|
|
15846
15838
|
);
|
|
15847
15839
|
}
|
|
15848
|
-
return
|
|
15840
|
+
return false;
|
|
15849
15841
|
}
|
|
15842
|
+
return true;
|
|
15843
|
+
}
|
|
15844
|
+
feedRepairSymbol(packetId, ssStart, ssbLength, rsId, repairData, catalogTrackName) {
|
|
15845
|
+
this.#fecStats.repairPackets++;
|
|
15846
|
+
this.#statsForPacket(packetId).repairPackets++;
|
|
15847
|
+
if (!this.#hasBlockProfile(packetId)) return null;
|
|
15848
|
+
if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null;
|
|
15850
15849
|
const fecData = repairData;
|
|
15851
15850
|
const k = this.#trackConfig(packetId).k;
|
|
15852
15851
|
const block = this.#isoLocatorFor(packetId, catalogTrackName).blockAt(ssStart);
|
|
@@ -15999,7 +15998,14 @@ var FECManager = class _FECManager {
|
|
|
15999
15998
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
16000
15999
|
const k = trackConfig.k;
|
|
16001
16000
|
if (this.#completedBlocks.has(key)) return;
|
|
16002
|
-
this.#noteSbnSeen(
|
|
16001
|
+
this.#noteSbnSeen(
|
|
16002
|
+
sbn,
|
|
16003
|
+
packetId,
|
|
16004
|
+
catalogTrackName,
|
|
16005
|
+
"source",
|
|
16006
|
+
evidence.packetSequenceNumber,
|
|
16007
|
+
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
|
|
16008
|
+
);
|
|
16003
16009
|
const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
|
|
16004
16010
|
if (Number.isInteger(esi) && esi >= authoredLength) {
|
|
16005
16011
|
this.#failBlock(sbn, packetId, catalogTrackName);
|
|
@@ -16250,6 +16256,7 @@ var FECManager = class _FECManager {
|
|
|
16250
16256
|
this.#repairedBlocks.clear();
|
|
16251
16257
|
this.#materializedBlocks.clear();
|
|
16252
16258
|
this.#highestSbn.clear();
|
|
16259
|
+
this.#sourceFrontiers.clear();
|
|
16253
16260
|
this.#isoLocators.clear();
|
|
16254
16261
|
this.#sourceAnchors.clear();
|
|
16255
16262
|
this.#trackConfigs.clear();
|
|
@@ -17339,6 +17346,7 @@ function isFmp4Box(data) {
|
|
|
17339
17346
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
17340
17347
|
return FMPU_BOX_TYPES.has(type);
|
|
17341
17348
|
}
|
|
17349
|
+
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
17342
17350
|
var MmtpContainerParser = class _MmtpContainerParser {
|
|
17343
17351
|
constructor(config) {
|
|
17344
17352
|
this.#tracks = /* @__PURE__ */ new Map();
|
|
@@ -17397,6 +17405,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17397
17405
|
* reordering into the parser. */
|
|
17398
17406
|
this.#reliableMoqStartupGate = /* @__PURE__ */ new Map();
|
|
17399
17407
|
this.#disposed = false;
|
|
17408
|
+
this.#replayingAwaitingTiming = false;
|
|
17400
17409
|
this.#fedObjects = 0;
|
|
17401
17410
|
this.#reassemblerFragmentsFed = 0;
|
|
17402
17411
|
this.#reassemblerDataUnitsReturned = 0;
|
|
@@ -17489,6 +17498,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17489
17498
|
#reorderStats;
|
|
17490
17499
|
#reliableMoqStartupGate;
|
|
17491
17500
|
#disposed;
|
|
17501
|
+
#replayingAwaitingTiming;
|
|
17492
17502
|
#fedObjects;
|
|
17493
17503
|
#reassemblerFragmentsFed;
|
|
17494
17504
|
#reassemblerDataUnitsReturned;
|
|
@@ -17738,7 +17748,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17738
17748
|
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
17739
17749
|
*/
|
|
17740
17750
|
#drop(reason) {
|
|
17741
|
-
this.#
|
|
17751
|
+
if (this.#replayingAwaitingTiming) this.#countDeferredOutcome(reason);
|
|
17752
|
+
else this.#countOutcome(`drop:${reason}`);
|
|
17742
17753
|
return null;
|
|
17743
17754
|
}
|
|
17744
17755
|
get reorderDiagnostics() {
|
|
@@ -17761,6 +17772,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17761
17772
|
for (const combiner of this.#sampleCombiners.values()) {
|
|
17762
17773
|
combiner.cleanupTimeouts(timeoutMs);
|
|
17763
17774
|
}
|
|
17775
|
+
const now = Date.now();
|
|
17776
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
17777
|
+
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
17778
|
+
awaitingTiming.shift();
|
|
17779
|
+
}
|
|
17780
|
+
}
|
|
17764
17781
|
}
|
|
17765
17782
|
/**
|
|
17766
17783
|
* Phase 1 of two-phase parsing. Returns structured header info for FEC feeding.
|
|
@@ -17841,7 +17858,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17841
17858
|
byteLength: packet.byteLength
|
|
17842
17859
|
};
|
|
17843
17860
|
}
|
|
17844
|
-
if (info.fecPayloadId !== null && this.#sourceSymbolCb) {
|
|
17861
|
+
if (info.fecPayloadId !== null && this.#sourceSymbolCb && !this.#replayingAwaitingTiming) {
|
|
17845
17862
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
17846
17863
|
try {
|
|
17847
17864
|
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
@@ -17889,6 +17906,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17889
17906
|
}
|
|
17890
17907
|
return this.#drop("fragment-timing-refused");
|
|
17891
17908
|
}
|
|
17909
|
+
this.#replayAwaitingTiming(streamKey, resolver2);
|
|
17892
17910
|
return {
|
|
17893
17911
|
kind: "fragment",
|
|
17894
17912
|
packet: info,
|
|
@@ -17912,7 +17930,18 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17912
17930
|
mfuDuHeader.movieFragmentSequenceNumber,
|
|
17913
17931
|
mfuDuHeader.sampleNumber
|
|
17914
17932
|
);
|
|
17915
|
-
if (!headTiming)
|
|
17933
|
+
if (!headTiming) {
|
|
17934
|
+
this.#awaitTiming(streamKey, {
|
|
17935
|
+
packet,
|
|
17936
|
+
options,
|
|
17937
|
+
parsed,
|
|
17938
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
17939
|
+
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
17940
|
+
sampleNumber: mfuDuHeader.sampleNumber,
|
|
17941
|
+
arrivedAt: Date.now()
|
|
17942
|
+
});
|
|
17943
|
+
return this.#drop("mfu-sample-timing-missing");
|
|
17944
|
+
}
|
|
17916
17945
|
const offset = mfuDuHeader.offset;
|
|
17917
17946
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
17918
17947
|
return this.#drop("mfu-offset-out-of-range");
|
|
@@ -17988,16 +18017,17 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17988
18017
|
const sampleNumber = assembled.sampleNumber;
|
|
17989
18018
|
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
17990
18019
|
return this.#drop("assembled-identity-missing");
|
|
17991
|
-
|
|
18020
|
+
const assembledTiming = resolver.sampleTiming(
|
|
17992
18021
|
assembled.mpuSequenceNumber,
|
|
17993
18022
|
movieFragmentSequenceNumber,
|
|
17994
18023
|
sampleNumber
|
|
17995
|
-
)
|
|
18024
|
+
);
|
|
18025
|
+
if (!assembledTiming) return this.#drop("assembled-timing-missing");
|
|
17996
18026
|
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
17997
18027
|
return this.#drop("assembled-mpu-mismatch");
|
|
17998
18028
|
let combined;
|
|
17999
18029
|
try {
|
|
18000
|
-
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled);
|
|
18030
|
+
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled, assembledTiming.size);
|
|
18001
18031
|
} catch (error) {
|
|
18002
18032
|
if (!(error instanceof SampleCombineError)) throw error;
|
|
18003
18033
|
console.warn(
|
|
@@ -18306,9 +18336,37 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18306
18336
|
if (existing) return existing.resolver;
|
|
18307
18337
|
if (!create) return null;
|
|
18308
18338
|
const resolver = new IsoBmffTimingResolver(this.#maxPendingTimingSamples);
|
|
18309
|
-
this.#timingStreams.set(streamKey, { packetId, resolver });
|
|
18339
|
+
this.#timingStreams.set(streamKey, { packetId, resolver, awaitingTiming: [] });
|
|
18310
18340
|
return resolver;
|
|
18311
18341
|
}
|
|
18342
|
+
#awaitTiming(streamKey, head) {
|
|
18343
|
+
const awaitingTiming = this.#timingStreams.get(streamKey)?.awaitingTiming;
|
|
18344
|
+
if (!awaitingTiming) return;
|
|
18345
|
+
awaitingTiming.push(head);
|
|
18346
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) awaitingTiming.shift();
|
|
18347
|
+
}
|
|
18348
|
+
/**
|
|
18349
|
+
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
18350
|
+
* FT=1 can be an FEC recovery landing after its sample's FI=1, and neither
|
|
18351
|
+
* FEC path routes a source symbol that already arrived a second time.
|
|
18352
|
+
*/
|
|
18353
|
+
#replayAwaitingTiming(streamKey, resolver) {
|
|
18354
|
+
const state = this.#timingStreams.get(streamKey);
|
|
18355
|
+
if (!state || state.awaitingTiming.length === 0) return;
|
|
18356
|
+
const ready = state.awaitingTiming.filter((head) => resolver.sampleTiming(
|
|
18357
|
+
head.mpuSequenceNumber,
|
|
18358
|
+
head.movieFragmentSequenceNumber,
|
|
18359
|
+
head.sampleNumber
|
|
18360
|
+
));
|
|
18361
|
+
if (ready.length === 0) return;
|
|
18362
|
+
state.awaitingTiming = state.awaitingTiming.filter((head) => !ready.includes(head));
|
|
18363
|
+
this.#replayingAwaitingTiming = true;
|
|
18364
|
+
try {
|
|
18365
|
+
for (const head of ready) this.#feed(head.packet, head.options, head.parsed);
|
|
18366
|
+
} finally {
|
|
18367
|
+
this.#replayingAwaitingTiming = false;
|
|
18368
|
+
}
|
|
18369
|
+
}
|
|
18312
18370
|
#dropTimingStream(streamKey) {
|
|
18313
18371
|
const state = this.#timingStreams.get(streamKey);
|
|
18314
18372
|
if (!state) return;
|
|
@@ -18913,6 +18971,12 @@ var MmtpRouter = class {
|
|
|
18913
18971
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
18914
18972
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
18915
18973
|
#latestVideoSeqByStream = /* @__PURE__ */ new Map();
|
|
18974
|
+
/**
|
|
18975
|
+
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
18976
|
+
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
18977
|
+
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
18978
|
+
*/
|
|
18979
|
+
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
18916
18980
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18917
18981
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18918
18982
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -18987,6 +19051,7 @@ var MmtpRouter = class {
|
|
|
18987
19051
|
*/
|
|
18988
19052
|
#onPublisherRestart;
|
|
18989
19053
|
#publisherRestarts = 0;
|
|
19054
|
+
#restampedRecoveredSeqs = 0;
|
|
18990
19055
|
/** Inits delivered with no onTrackInit handler for their packetId (MOQT-01). */
|
|
18991
19056
|
#unmappedInitDeliveries = 0;
|
|
18992
19057
|
// FEC Payload IDs left unread because their (owner) packetId had no
|
|
@@ -19207,6 +19272,14 @@ var MmtpRouter = class {
|
|
|
19207
19272
|
get publisherRestartCount() {
|
|
19208
19273
|
return this.#publisherRestarts;
|
|
19209
19274
|
}
|
|
19275
|
+
/**
|
|
19276
|
+
* FEC-recovered source symbols whose reconstructed header named a
|
|
19277
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to:
|
|
19278
|
+
* a hop re-stamped the sequence after the sender protected the packet.
|
|
19279
|
+
*/
|
|
19280
|
+
get restampedRecoveredSequenceCount() {
|
|
19281
|
+
return this.#restampedRecoveredSeqs;
|
|
19282
|
+
}
|
|
19210
19283
|
/**
|
|
19211
19284
|
* Packets whose Source or Repair FEC Payload ID was left unread because
|
|
19212
19285
|
* their (owner) packetId had no configured `fec.blockProfile`: FEC not
|
|
@@ -19722,6 +19795,13 @@ var MmtpRouter = class {
|
|
|
19722
19795
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`
|
|
19723
19796
|
);
|
|
19724
19797
|
}
|
|
19798
|
+
if (fec.admitRepairSymbolSize && !fec.admitRepairSymbolSize(
|
|
19799
|
+
ownerPacketId,
|
|
19800
|
+
repair.ssStart,
|
|
19801
|
+
repair.ssbLength,
|
|
19802
|
+
repair.rsId,
|
|
19803
|
+
repair.symbolData.byteLength
|
|
19804
|
+
)) return;
|
|
19725
19805
|
const placement = fec.placeIsoRepair(ownerPacketId, catalogTrackName, repair.ssStart, repair.ssbLength);
|
|
19726
19806
|
if (placement.status !== "placed") return;
|
|
19727
19807
|
const blockStart = placement.block.start;
|
|
@@ -19851,6 +19931,7 @@ var MmtpRouter = class {
|
|
|
19851
19931
|
this.#trackSynced.delete(streamKey);
|
|
19852
19932
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
19853
19933
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
19934
|
+
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
19854
19935
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
19855
19936
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
19856
19937
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -20621,6 +20702,12 @@ var MmtpRouter = class {
|
|
|
20621
20702
|
} else if (fecUnreadable && info.fecPayloadId) {
|
|
20622
20703
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
20623
20704
|
}
|
|
20705
|
+
if (fecPayloadId && !overlapCopy) {
|
|
20706
|
+
this.#ssIdSeqOffsetByStream.set(
|
|
20707
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
20708
|
+
fecPayloadId.ssId - info.sequenceNumber >>> 0
|
|
20709
|
+
);
|
|
20710
|
+
}
|
|
20624
20711
|
if (!this.#fecManager || !info.fecPayloadId || parseSourceSymbol) {
|
|
20625
20712
|
if (this.#fecManager && info.fecPayloadId) {
|
|
20626
20713
|
duplicates.parsedSymbols.add(info.fecPayloadId.ssId);
|
|
@@ -21197,6 +21284,20 @@ var MmtpRouter = class {
|
|
|
21197
21284
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
21198
21285
|
if (ownerPacketId == null) return;
|
|
21199
21286
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
21287
|
+
const ssIdSeqOffset = this.#ssIdSeqOffsetByStream.get(
|
|
21288
|
+
this.#mediaStreamKey(ownerPacketId, catalogTrackName)
|
|
21289
|
+
);
|
|
21290
|
+
if (ssIdSeqOffset !== void 0) {
|
|
21291
|
+
result = {
|
|
21292
|
+
...result,
|
|
21293
|
+
symbols: result.symbols.map((sym) => {
|
|
21294
|
+
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
21295
|
+
if (wire === sym.packetSequenceNumber) return sym;
|
|
21296
|
+
this.#restampedRecoveredSeqs++;
|
|
21297
|
+
return { ...sym, packetSequenceNumber: wire };
|
|
21298
|
+
})
|
|
21299
|
+
};
|
|
21300
|
+
}
|
|
21200
21301
|
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
21201
21302
|
const deliveryProvenance = this.#fecManager?.blockDeliveryProvenance?.(
|
|
21202
21303
|
blockId,
|
|
@@ -22022,7 +22123,7 @@ function sameIds(a, b) {
|
|
|
22022
22123
|
for (const id of a) if (!b.has(id)) return false;
|
|
22023
22124
|
return true;
|
|
22024
22125
|
}
|
|
22025
|
-
var MulticastTransport = class
|
|
22126
|
+
var MulticastTransport = class {
|
|
22026
22127
|
#onPacket;
|
|
22027
22128
|
#subscription = null;
|
|
22028
22129
|
#packetListener = null;
|
|
@@ -22094,8 +22195,11 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22094
22195
|
// droppedPacketIds.
|
|
22095
22196
|
#unadvertisedPacketIds = /* @__PURE__ */ new Set();
|
|
22096
22197
|
#joinGeneration = 0;
|
|
22097
|
-
|
|
22198
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
22199
|
+
#gateway;
|
|
22200
|
+
constructor(onPacket, options = {}) {
|
|
22098
22201
|
this.#onPacket = onPacket;
|
|
22202
|
+
this.#gateway = options.gateway;
|
|
22099
22203
|
}
|
|
22100
22204
|
static isAvailable() {
|
|
22101
22205
|
return hasMulticastGateway();
|
|
@@ -22105,7 +22209,8 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22105
22209
|
this.#releaseSubscription();
|
|
22106
22210
|
this.#dataPlaneLive = false;
|
|
22107
22211
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
22108
|
-
|
|
22212
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
22213
|
+
if (typeof gateway?.subscribe !== "function") {
|
|
22109
22214
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
22110
22215
|
return this.#declined(generation, "unavailable");
|
|
22111
22216
|
}
|
|
@@ -22122,11 +22227,12 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22122
22227
|
mode: config.mode,
|
|
22123
22228
|
amtRelay: config.amtRelay,
|
|
22124
22229
|
amtRelayPort: config.amtRelayPort,
|
|
22230
|
+
amtDiscovery: config.amtDiscovery,
|
|
22125
22231
|
packetIds: config.packetIds,
|
|
22126
22232
|
tracks: config.tracks
|
|
22127
22233
|
});
|
|
22128
22234
|
failure = "provider-rejected";
|
|
22129
|
-
const subscription = await
|
|
22235
|
+
const subscription = await gateway.subscribe(subscribeConfig);
|
|
22130
22236
|
failure = "invalid-subscription";
|
|
22131
22237
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription);
|
|
22132
22238
|
if (this.#disposed || generation !== this.#joinGeneration) {
|
|
@@ -22782,28 +22888,28 @@ function joinedRepairSymbolCount(params, joinedRepairTrackNames) {
|
|
|
22782
22888
|
}
|
|
22783
22889
|
return total;
|
|
22784
22890
|
}
|
|
22785
|
-
function
|
|
22891
|
+
function recordOf3(value) {
|
|
22786
22892
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22787
22893
|
}
|
|
22788
22894
|
function msfTracks(catalog) {
|
|
22789
22895
|
const raw = catalog.tracks;
|
|
22790
22896
|
if (!Array.isArray(raw)) return void 0;
|
|
22791
|
-
return { tracks: raw.map((t) =>
|
|
22897
|
+
return { tracks: raw.map((t) => recordOf3(t) ?? {}) };
|
|
22792
22898
|
}
|
|
22793
22899
|
function resolveRepairLayers(catalog, source) {
|
|
22794
22900
|
if (!catalog) return void 0;
|
|
22795
22901
|
const sourceName = typeof source === "string" ? source : source.name;
|
|
22796
22902
|
const hang = catalog;
|
|
22797
22903
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "audio" ? ["audio"] : source.type === "video" ? ["video"] : ["video", "audio"];
|
|
22798
|
-
const
|
|
22799
|
-
if (
|
|
22800
|
-
const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22801
|
-
const rendition =
|
|
22904
|
+
const located = locateCatalogFecSource(catalog, sourceName, roles);
|
|
22905
|
+
if (located?.dialect === "hang") {
|
|
22906
|
+
const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22907
|
+
const rendition = located.entry;
|
|
22802
22908
|
rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
|
|
22803
|
-
const repairRenditions =
|
|
22909
|
+
const repairRenditions = recordOf3(hang.repair?.renditions) ?? {};
|
|
22804
22910
|
const descriptors2 = Object.entries(repairRenditions).map(([name, entry]) => {
|
|
22805
22911
|
const path = `$.repair.renditions[${JSON.stringify(name)}]`;
|
|
22806
|
-
const fields =
|
|
22912
|
+
const fields = recordOf3(entry);
|
|
22807
22913
|
if (fields === void 0) {
|
|
22808
22914
|
throwRepairContractError("track_repair_layer", path, "a repair rendition must be an object");
|
|
22809
22915
|
}
|
|
@@ -22811,14 +22917,14 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22811
22917
|
return describeRepairTrack(name, path, fields);
|
|
22812
22918
|
});
|
|
22813
22919
|
const fecOfRendition = (entry) => {
|
|
22814
|
-
const fec2 =
|
|
22920
|
+
const fec2 = recordOf3(recordOf3(entry)?.["fec"]);
|
|
22815
22921
|
return fec2 !== void 0 && fec2["algorithm"] !== "none" ? fec2 : void 0;
|
|
22816
22922
|
};
|
|
22817
22923
|
const mediaRenditions = [
|
|
22818
|
-
...Object.values(
|
|
22819
|
-
...Object.values(
|
|
22924
|
+
...Object.values(recordOf3(hang.video?.renditions) ?? {}),
|
|
22925
|
+
...Object.values(recordOf3(hang.audio?.renditions) ?? {})
|
|
22820
22926
|
];
|
|
22821
|
-
const reachability2 = repairReachability(mediaRenditions.map((entry) =>
|
|
22927
|
+
const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf3(entry)?.["fec"]));
|
|
22822
22928
|
for (const d of descriptors2) {
|
|
22823
22929
|
validateRepairTrackFields(d, throwRepairContractError);
|
|
22824
22930
|
assertRepairTrackReachable(d, reachability2, throwRepairContractError);
|
|
@@ -22834,20 +22940,20 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22834
22940
|
}
|
|
22835
22941
|
}
|
|
22836
22942
|
const layers2 = assembleRepairLayers(
|
|
22837
|
-
geometryOf(sourceName, `${renditionPath}.fec`,
|
|
22943
|
+
geometryOf(sourceName, `${renditionPath}.fec`, recordOf3(rendition["fec"])),
|
|
22838
22944
|
descriptors2,
|
|
22839
22945
|
throwRepairContractError
|
|
22840
22946
|
);
|
|
22841
22947
|
return catalogFecUnavailable(rendition["fec"], `${renditionPath}.fec`) === void 0 ? layers2 : void 0;
|
|
22842
22948
|
}
|
|
22843
22949
|
const msf = msfTracks(catalog);
|
|
22844
|
-
|
|
22845
|
-
|
|
22950
|
+
if (!msf || located?.dialect !== "msf") return void 0;
|
|
22951
|
+
const msfIndex = located.index;
|
|
22846
22952
|
const track = msf.tracks[msfIndex];
|
|
22847
|
-
const fec =
|
|
22953
|
+
const fec = recordOf3(track["fec"]);
|
|
22848
22954
|
const packagingOf = (t) => t["packaging"];
|
|
22849
22955
|
const fecOfTrack = (t) => {
|
|
22850
|
-
const trackFec =
|
|
22956
|
+
const trackFec = recordOf3(t?.["fec"]);
|
|
22851
22957
|
return trackFec !== void 0 && trackFec["algorithm"] !== "none" ? trackFec : void 0;
|
|
22852
22958
|
};
|
|
22853
22959
|
const descriptors = [];
|
|
@@ -22897,8 +23003,8 @@ function catalogRepairTarget(catalog, source) {
|
|
|
22897
23003
|
const entry = msf?.tracks.find((t) => t["name"] === sourceName);
|
|
22898
23004
|
const hang = catalog;
|
|
22899
23005
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "video" ? ["video"] : source.type === "audio" ? ["audio"] : ["video", "audio"];
|
|
22900
|
-
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) =>
|
|
22901
|
-
const fec = rendition === void 0 ?
|
|
23006
|
+
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) => recordOf3(r) !== void 0);
|
|
23007
|
+
const fec = rendition === void 0 ? recordOf3(entry?.["fec"]) : recordOf3(rendition.fec);
|
|
22902
23008
|
if (!fec || !(catalogFecInterleaveMs(fec) ?? 0)) return null;
|
|
22903
23009
|
const sourcePriority = entry === void 0 ? null : moqtPriority2(entry["priority"]);
|
|
22904
23010
|
return { repairTrack: layerZero.repairTrackName, sourcePriority, repairPriority: layerZero.priority };
|
|
@@ -22941,10 +23047,14 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
22941
23047
|
});
|
|
22942
23048
|
}
|
|
22943
23049
|
function catalogFecUnavailable(fec, fecPath) {
|
|
22944
|
-
|
|
22945
|
-
|
|
23050
|
+
if (catalogFecAvailable(fec)) return void 0;
|
|
23051
|
+
const block = recordOf3(fec);
|
|
22946
23052
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
22947
|
-
|
|
23053
|
+
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
23054
|
+
if (reason === void 0) {
|
|
23055
|
+
throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
|
|
23056
|
+
}
|
|
23057
|
+
return reason;
|
|
22948
23058
|
}
|
|
22949
23059
|
function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
22950
23060
|
const mediaRate = sampleRate === void 0 ? { fps } : { fps, sampleRate };
|
|
@@ -22953,10 +23063,8 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
22953
23063
|
const repair = resolveRepairLayers(catalog, track);
|
|
22954
23064
|
const fecPath = `$.${track.type}.renditions[${JSON.stringify(track.name)}].fec`;
|
|
22955
23065
|
if (!catalogDeclaresFec(fec)) {
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
|
|
22959
|
-
if (declaresFecInstance && !(kValid && tValid)) {
|
|
23066
|
+
if (catalogFecDeclaresUnconfigurableInstance(fec)) {
|
|
23067
|
+
const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
|
|
22960
23068
|
throwRepairContractError(
|
|
22961
23069
|
"track_fec",
|
|
22962
23070
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
@@ -23363,6 +23471,9 @@ var MulticastManager = class {
|
|
|
23363
23471
|
#router;
|
|
23364
23472
|
#hostMfuTimeoutMs;
|
|
23365
23473
|
#transport;
|
|
23474
|
+
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
23475
|
+
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
23476
|
+
#repairReleases = /* @__PURE__ */ new Map();
|
|
23366
23477
|
#reportedFecDiagnosticsFailure = false;
|
|
23367
23478
|
// ── Stream-global FEC timing reduction ──
|
|
23368
23479
|
//
|
|
@@ -23626,7 +23737,9 @@ var MulticastManager = class {
|
|
|
23626
23737
|
catalogTrackName
|
|
23627
23738
|
);
|
|
23628
23739
|
this.#configureTrackMapper(packetId, config);
|
|
23629
|
-
this.#router.
|
|
23740
|
+
if (this.#router.trackKindFor(packetId) !== trackType) {
|
|
23741
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
23742
|
+
}
|
|
23630
23743
|
}
|
|
23631
23744
|
/**
|
|
23632
23745
|
* Stop routing a stream's symbols to its Worker decoder. Returns false when
|
|
@@ -23707,6 +23820,14 @@ var MulticastManager = class {
|
|
|
23707
23820
|
);
|
|
23708
23821
|
}
|
|
23709
23822
|
}
|
|
23823
|
+
for (const [packetId, c] of this.#trackFecTiming) {
|
|
23824
|
+
if (c.deliveryWindowMs === void 0) continue;
|
|
23825
|
+
mfuTimeoutMs = Math.max(
|
|
23826
|
+
mfuTimeoutMs ?? 0,
|
|
23827
|
+
this.#fec.terminalRetentionMsForPacket(packetId) ?? 0,
|
|
23828
|
+
this.#hostMfuTimeoutMs ?? 0
|
|
23829
|
+
);
|
|
23830
|
+
}
|
|
23710
23831
|
const failbackWindowMs = deliveryWindowMs === void 0 ? minimumFailbackWindowMs : Math.max(deliveryWindowMs, minimumFailbackWindowMs ?? 0);
|
|
23711
23832
|
this.#transport.setFailbackWindowMs(failbackWindowMs ?? null);
|
|
23712
23833
|
this.#router.setMfuTimeoutMs(mfuTimeoutMs ?? this.#hostMfuTimeoutMs);
|
|
@@ -23890,6 +24011,7 @@ var MulticastManager = class {
|
|
|
23890
24011
|
setMfuTimeoutMs(ms) {
|
|
23891
24012
|
this.#router.setMfuTimeoutMs(ms);
|
|
23892
24013
|
this.#hostMfuTimeoutMs = this.#router.reassembler.timeoutMs;
|
|
24014
|
+
if (this.#trackFecTiming.size > 0) this.#applyStreamGlobalFecTiming();
|
|
23893
24015
|
}
|
|
23894
24016
|
setTrackCodec(packetId, codec) {
|
|
23895
24017
|
this.#router.setTrackCodec(packetId, codec);
|
|
@@ -24010,11 +24132,80 @@ var MulticastManager = class {
|
|
|
24010
24132
|
// through whatever the relay looks like, since dropping it would be the
|
|
24011
24133
|
// worse behaviour.
|
|
24012
24134
|
amtRelayPort: config.amtRelayPort ?? config.relayPort ?? (amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24135
|
+
amtDiscovery: config.amtDiscovery,
|
|
24013
24136
|
packetIds: config.packetIds,
|
|
24014
24137
|
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId }))
|
|
24015
24138
|
};
|
|
24016
24139
|
return ingress === void 0 ? this.#transport.join(transportConfig) : this.#transport.join(transportConfig, ingress);
|
|
24017
24140
|
}
|
|
24141
|
+
/**
|
|
24142
|
+
* Join the selected rung's dedicated repair groups beside the media join
|
|
24143
|
+
* (pim #3898): one subscription per endpoint, through `provider` when given
|
|
24144
|
+
* (a `window.multicast`-shaped gateway or a subscribe callback), otherwise a
|
|
24145
|
+
* new MulticastTransport on `window.multicast`. Returns the call that
|
|
24146
|
+
* releases every one of them; dispose() releases them too.
|
|
24147
|
+
*
|
|
24148
|
+
* Packets go straight to the router with the endpoint's ingress, never
|
|
24149
|
+
* through feedPacket(): repair arriving on its own group is not media
|
|
24150
|
+
* liveness, so it must not hold off the media leg's failback watchdog. The
|
|
24151
|
+
* repair roles and owners are registered here; in-band owners stay the
|
|
24152
|
+
* caller's. Joining is best effort: a group that fails to join is logged
|
|
24153
|
+
* and leaves the media join as it was.
|
|
24154
|
+
*/
|
|
24155
|
+
joinRepairEndpoints(endpoints, provider) {
|
|
24156
|
+
const releases = [];
|
|
24157
|
+
let released = false;
|
|
24158
|
+
const safely = (each) => {
|
|
24159
|
+
try {
|
|
24160
|
+
each();
|
|
24161
|
+
} catch (error) {
|
|
24162
|
+
console.warn("[MulticastManager] repair group release failed", error);
|
|
24163
|
+
}
|
|
24164
|
+
};
|
|
24165
|
+
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners);
|
|
24166
|
+
this.#applyRepairOwners(repairOwners);
|
|
24167
|
+
for (const endpoint of endpoints) {
|
|
24168
|
+
const ingress = {
|
|
24169
|
+
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId })))
|
|
24170
|
+
};
|
|
24171
|
+
const onPacket = (packet) => {
|
|
24172
|
+
if (!released) this.#router.feedPacket(packet, "multicast", void 0, ingress);
|
|
24173
|
+
};
|
|
24174
|
+
const fail = (error) => console.warn(`[MulticastManager] repair group ${endpoint.group}:${endpoint.port} not joined`, error);
|
|
24175
|
+
if (typeof provider === "function") {
|
|
24176
|
+
Promise.resolve().then(() => provider(endpoint, onPacket)).then((release2) => released ? safely(release2) : releases.push(release2), fail);
|
|
24177
|
+
continue;
|
|
24178
|
+
}
|
|
24179
|
+
const transport = new MulticastTransport((packet) => onPacket(packet), { gateway: provider });
|
|
24180
|
+
releases.push(() => transport.dispose());
|
|
24181
|
+
void transport.join({
|
|
24182
|
+
sourceAddress: endpoint.source,
|
|
24183
|
+
groupAddress: endpoint.group,
|
|
24184
|
+
port: endpoint.port,
|
|
24185
|
+
mode: endpoint.mode,
|
|
24186
|
+
amtRelay: endpoint.amtRelay,
|
|
24187
|
+
amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24188
|
+
packetIds: endpoint.packetIds,
|
|
24189
|
+
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId }))
|
|
24190
|
+
}).then((joined) => {
|
|
24191
|
+
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
24192
|
+
});
|
|
24193
|
+
}
|
|
24194
|
+
const release = () => {
|
|
24195
|
+
if (released) return;
|
|
24196
|
+
released = true;
|
|
24197
|
+
this.#repairReleases.delete(release);
|
|
24198
|
+
for (const each of releases.splice(0)) safely(each);
|
|
24199
|
+
};
|
|
24200
|
+
this.#repairReleases.set(release, repairOwners);
|
|
24201
|
+
return release;
|
|
24202
|
+
}
|
|
24203
|
+
#applyRepairOwners(owners) {
|
|
24204
|
+
for (const { packetId, ownerPacketId } of owners) {
|
|
24205
|
+
this.#router.setPacketIdRole(packetId, "repair");
|
|
24206
|
+
this.#router.setRepairPacketIdOwner(packetId, ownerPacketId);
|
|
24207
|
+
}
|
|
24208
|
+
}
|
|
24018
24209
|
// ---------------------------------------------------------------------------
|
|
24019
24210
|
// In-place rendition switch
|
|
24020
24211
|
// ---------------------------------------------------------------------------
|
|
@@ -24376,11 +24567,7 @@ var MulticastManager = class {
|
|
|
24376
24567
|
for (const [groupKey, roles] of resolvedRolesByGroup) {
|
|
24377
24568
|
if (!(hasSwitchingSetByGroup.get(groupKey) ?? false)) continue;
|
|
24378
24569
|
const presentRoles = new Set(roles.filter((r) => r !== "single"));
|
|
24379
|
-
const required = [
|
|
24380
|
-
"base",
|
|
24381
|
-
"delta",
|
|
24382
|
-
"repair"
|
|
24383
|
-
];
|
|
24570
|
+
const required = ["base", "repair"];
|
|
24384
24571
|
const missing = required.filter((r) => !presentRoles.has(r));
|
|
24385
24572
|
if (missing.length > 0) {
|
|
24386
24573
|
throw new Error(
|
|
@@ -24427,6 +24614,7 @@ var MulticastManager = class {
|
|
|
24427
24614
|
this.#switchingSets.clear();
|
|
24428
24615
|
this.#repairPacketIds.clear();
|
|
24429
24616
|
this.#router.clearRepairPacketIdOwners();
|
|
24617
|
+
for (const owners of this.#repairReleases.values()) this.#applyRepairOwners(owners);
|
|
24430
24618
|
const fecPacketIds = new Set([...fecDecoders.keys()].map((i) => catalog.tracks[i].packetId));
|
|
24431
24619
|
for (const [packetId, catalogTrackName] of this.#multiTrackFecTracks) {
|
|
24432
24620
|
if (fecPacketIds.has(packetId)) continue;
|
|
@@ -24758,6 +24946,7 @@ var MulticastManager = class {
|
|
|
24758
24946
|
this.#trackResetObservers.clear();
|
|
24759
24947
|
this.#repairLifecycleObservers.clear();
|
|
24760
24948
|
this.#transport.dispose();
|
|
24949
|
+
for (const release of [...this.#repairReleases.keys()]) release();
|
|
24761
24950
|
this.#router.dispose();
|
|
24762
24951
|
this.#fec.dispose();
|
|
24763
24952
|
}
|
|
@@ -24847,7 +25036,6 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24847
25036
|
repairTrack: opts.repairTrackName,
|
|
24848
25037
|
relayBlockSigEnabled: false
|
|
24849
25038
|
};
|
|
24850
|
-
client.configure(fecTrackConfig, rqWasm);
|
|
24851
25039
|
try {
|
|
24852
25040
|
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
24853
25041
|
blockProfile,
|
|
@@ -24867,6 +25055,14 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24867
25055
|
}
|
|
24868
25056
|
throw e;
|
|
24869
25057
|
}
|
|
25058
|
+
fecTrackConfig.interleaveDepth = Math.min(
|
|
25059
|
+
MAX_FEC_RETENTION_BLOCKS,
|
|
25060
|
+
Math.max(
|
|
25061
|
+
interleaveDepthBlocks,
|
|
25062
|
+
opts.multicastManager.fecManager.isoRetentionBlocksForPacket(opts.packetId) ?? 0
|
|
25063
|
+
)
|
|
25064
|
+
);
|
|
25065
|
+
client.configure(fecTrackConfig, rqWasm);
|
|
24870
25066
|
let disposed = false;
|
|
24871
25067
|
return {
|
|
24872
25068
|
client,
|
|
@@ -26992,6 +27188,8 @@ export {
|
|
|
26992
27188
|
buildVideoInitSegment,
|
|
26993
27189
|
catalogAmtNetworkSource,
|
|
26994
27190
|
catalogDeclaresFec,
|
|
27191
|
+
catalogFecAvailable,
|
|
27192
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
26995
27193
|
catalogFecInterleaveMs,
|
|
26996
27194
|
catalogFecMediaUnitsPerSecond,
|
|
26997
27195
|
catalogFecUnavailable,
|
|
@@ -27066,6 +27264,7 @@ export {
|
|
|
27066
27264
|
isTrackTimingConfig,
|
|
27067
27265
|
joinedRepairSymbolCount,
|
|
27068
27266
|
keyframeIntervalMediaTicks,
|
|
27267
|
+
locateCatalogFecSource,
|
|
27069
27268
|
mergeOverrideIntoCmsfTracks,
|
|
27070
27269
|
mergeOverrideIntoHangRenditions,
|
|
27071
27270
|
mfuReassemblyTimeoutMs,
|