@blockcast/mmt-container 0.4.0-main.cc36a672eb06 → 0.4.0-main.d5ca55d82e33
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 +1 -1
- package/dist/browser-runtime.js +234 -55
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.js +3 -0
- 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 +26 -1
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.js +3 -0
- 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.js +3 -0
- 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.js +24 -13
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +37 -22
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +24 -13
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +18 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +30 -13
- 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 +161 -29
- 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 +35 -5
- 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 +37 -22
- 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/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 +24 -13
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/catalog-fec-params.ts +38 -17
- package/src/fec-state.ts +4 -9
- package/src/index.ts +5 -0
- package/src/mmtp-router.ts +26 -1
- package/src/multicast-manager.ts +120 -1
- package/src/multicast-transport.ts +14 -3
package/README.md
CHANGED
|
@@ -265,7 +265,7 @@ per-commit `0.1.0-main.<sha>` prerelease from `stamp-prerelease.mjs`), and a
|
|
|
265
265
|
> Superseded by BLO-40665. Every package is now bumped in lockstep by a `v*`
|
|
266
266
|
> tag and the sibling ranges move with it, so the objection above no longer
|
|
267
267
|
> applies -- it was an argument against bumping *one* package. The set is at
|
|
268
|
-
> `0.
|
|
268
|
+
> `0.4.0`; see `RELEASES.md`.
|
|
269
269
|
|
|
270
270
|
#### Track-role convention (Phase 14)
|
|
271
271
|
|
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;
|
|
@@ -6926,6 +6999,9 @@ var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
|
6926
6999
|
"iso-ssbg1-v1"
|
|
6927
7000
|
]);
|
|
6928
7001
|
|
|
7002
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
7003
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
7004
|
+
|
|
6929
7005
|
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
6930
7006
|
var DRIADDiscovery = class {
|
|
6931
7007
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -7507,7 +7583,8 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7507
7583
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
7508
7584
|
};
|
|
7509
7585
|
const relay = input.amtRelay?.trim();
|
|
7510
|
-
const
|
|
7586
|
+
const driad = !relay && input.amtDiscovery === "driad";
|
|
7587
|
+
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
7511
7588
|
if (!wantsAmt) {
|
|
7512
7589
|
const native = {
|
|
7513
7590
|
...base,
|
|
@@ -7517,6 +7594,20 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
7517
7594
|
return native;
|
|
7518
7595
|
}
|
|
7519
7596
|
const relayPort = input.amtRelayPort;
|
|
7597
|
+
if (driad) {
|
|
7598
|
+
if (!base.source)
|
|
7599
|
+
throw new TypeError("AMT DRIAD discovery requires a source address");
|
|
7600
|
+
if (relayPort !== void 0 && !isPositivePort(relayPort)) {
|
|
7601
|
+
throw new TypeError("AMT DRIAD discovery requires a valid relay port when one is given");
|
|
7602
|
+
}
|
|
7603
|
+
return {
|
|
7604
|
+
...base,
|
|
7605
|
+
source: base.source,
|
|
7606
|
+
origin: "amt",
|
|
7607
|
+
discovery: "driad",
|
|
7608
|
+
...relayPort !== void 0 ? { relayPort } : {}
|
|
7609
|
+
};
|
|
7610
|
+
}
|
|
7520
7611
|
if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
|
|
7521
7612
|
throw new TypeError("AMT requires a resolved relay and a valid relay port");
|
|
7522
7613
|
}
|
|
@@ -8128,6 +8219,10 @@ var TransportManager = class {
|
|
|
8128
8219
|
pollMulticastTierSwitch() {
|
|
8129
8220
|
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
|
|
8130
8221
|
}
|
|
8222
|
+
/** Abandon the in-flight tier join, e.g. because the host could not join the target. */
|
|
8223
|
+
cancelMulticastTierJoin() {
|
|
8224
|
+
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
|
|
8225
|
+
}
|
|
8131
8226
|
/**
|
|
8132
8227
|
* Set packet callback
|
|
8133
8228
|
*/
|
|
@@ -12575,22 +12670,16 @@ var INACTIVE = Object.freeze({
|
|
|
12575
12670
|
"reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
|
|
12576
12671
|
"no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
|
|
12577
12672
|
});
|
|
12578
|
-
function
|
|
12673
|
+
function recordOf2(value) {
|
|
12579
12674
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12580
12675
|
}
|
|
12581
|
-
function
|
|
12676
|
+
function isPositiveSafeInteger2(value) {
|
|
12582
12677
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
12583
12678
|
}
|
|
12584
12679
|
function catalogDeclaresFec(fec) {
|
|
12585
|
-
const block =
|
|
12680
|
+
const block = recordOf2(fec);
|
|
12586
12681
|
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
12587
|
-
return
|
|
12588
|
-
}
|
|
12589
|
-
function isoBlockSpanUsable(fec) {
|
|
12590
|
-
const block = recordOf(fec);
|
|
12591
|
-
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
|
|
12592
|
-
const ms = block["interleaveDepthMs"];
|
|
12593
|
-
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
12682
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
12594
12683
|
}
|
|
12595
12684
|
function requireBoolean(value, field) {
|
|
12596
12685
|
if (typeof value !== "boolean") {
|
|
@@ -12606,7 +12695,7 @@ function resolveFecState(evidence) {
|
|
|
12606
12695
|
if (typeof transportPolicy !== "string" || !TRANSPORT_POLICIES.has(transportPolicy)) {
|
|
12607
12696
|
throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`);
|
|
12608
12697
|
}
|
|
12609
|
-
if (stats !== null && stats !== void 0 &&
|
|
12698
|
+
if (stats !== null && stats !== void 0 && recordOf2(stats) === void 0) {
|
|
12610
12699
|
throw new TypeError("resolveFecState: stats must be a plain object, null or undefined");
|
|
12611
12700
|
}
|
|
12612
12701
|
if (!catalogFec) return INACTIVE["no-catalog-fec"];
|
|
@@ -20627,6 +20716,8 @@ var MmtpRouter = class {
|
|
|
20627
20716
|
catalogTrackName
|
|
20628
20717
|
);
|
|
20629
20718
|
this.#routeTrackPacket(packet, info.packetId, info.sequenceNumber, {
|
|
20719
|
+
mmtpTimestamp: parsed.header.timestamp,
|
|
20720
|
+
rap: info.rapFlag,
|
|
20630
20721
|
recovered: false,
|
|
20631
20722
|
skipFecPayloadId: false,
|
|
20632
20723
|
catalogTrackName
|
|
@@ -20814,6 +20905,8 @@ var MmtpRouter = class {
|
|
|
20814
20905
|
callback(packet, {
|
|
20815
20906
|
packetId,
|
|
20816
20907
|
packetSequenceNumber,
|
|
20908
|
+
mmtpTimestamp: meta.mmtpTimestamp,
|
|
20909
|
+
rap: meta.rap,
|
|
20817
20910
|
recovered: meta.recovered,
|
|
20818
20911
|
skipFecPayloadId: meta.skipFecPayloadId,
|
|
20819
20912
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName },
|
|
@@ -21197,6 +21290,8 @@ var MmtpRouter = class {
|
|
|
21197
21290
|
) ?? "unknown";
|
|
21198
21291
|
for (const sym of result.symbols) {
|
|
21199
21292
|
this.#routeTrackPacket(sym.rawSymbol, ownerPacketId, sym.packetSequenceNumber, {
|
|
21293
|
+
mmtpTimestamp: sym.fragment.timestamp,
|
|
21294
|
+
rap: sym.fragment.rapFlag,
|
|
21200
21295
|
recovered: true,
|
|
21201
21296
|
skipFecPayloadId: true,
|
|
21202
21297
|
catalogTrackName,
|
|
@@ -22012,7 +22107,7 @@ function sameIds(a, b) {
|
|
|
22012
22107
|
for (const id of a) if (!b.has(id)) return false;
|
|
22013
22108
|
return true;
|
|
22014
22109
|
}
|
|
22015
|
-
var MulticastTransport = class
|
|
22110
|
+
var MulticastTransport = class {
|
|
22016
22111
|
#onPacket;
|
|
22017
22112
|
#subscription = null;
|
|
22018
22113
|
#packetListener = null;
|
|
@@ -22084,8 +22179,11 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22084
22179
|
// droppedPacketIds.
|
|
22085
22180
|
#unadvertisedPacketIds = /* @__PURE__ */ new Set();
|
|
22086
22181
|
#joinGeneration = 0;
|
|
22087
|
-
|
|
22182
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
22183
|
+
#gateway;
|
|
22184
|
+
constructor(onPacket, options = {}) {
|
|
22088
22185
|
this.#onPacket = onPacket;
|
|
22186
|
+
this.#gateway = options.gateway;
|
|
22089
22187
|
}
|
|
22090
22188
|
static isAvailable() {
|
|
22091
22189
|
return hasMulticastGateway();
|
|
@@ -22095,7 +22193,8 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22095
22193
|
this.#releaseSubscription();
|
|
22096
22194
|
this.#dataPlaneLive = false;
|
|
22097
22195
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
22098
|
-
|
|
22196
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
22197
|
+
if (typeof gateway?.subscribe !== "function") {
|
|
22099
22198
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
22100
22199
|
return this.#declined(generation, "unavailable");
|
|
22101
22200
|
}
|
|
@@ -22112,11 +22211,12 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
22112
22211
|
mode: config.mode,
|
|
22113
22212
|
amtRelay: config.amtRelay,
|
|
22114
22213
|
amtRelayPort: config.amtRelayPort,
|
|
22214
|
+
amtDiscovery: config.amtDiscovery,
|
|
22115
22215
|
packetIds: config.packetIds,
|
|
22116
22216
|
tracks: config.tracks
|
|
22117
22217
|
});
|
|
22118
22218
|
failure = "provider-rejected";
|
|
22119
|
-
const subscription = await
|
|
22219
|
+
const subscription = await gateway.subscribe(subscribeConfig);
|
|
22120
22220
|
failure = "invalid-subscription";
|
|
22121
22221
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription);
|
|
22122
22222
|
if (this.#disposed || generation !== this.#joinGeneration) {
|
|
@@ -22772,28 +22872,28 @@ function joinedRepairSymbolCount(params, joinedRepairTrackNames) {
|
|
|
22772
22872
|
}
|
|
22773
22873
|
return total;
|
|
22774
22874
|
}
|
|
22775
|
-
function
|
|
22875
|
+
function recordOf3(value) {
|
|
22776
22876
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22777
22877
|
}
|
|
22778
22878
|
function msfTracks(catalog) {
|
|
22779
22879
|
const raw = catalog.tracks;
|
|
22780
22880
|
if (!Array.isArray(raw)) return void 0;
|
|
22781
|
-
return { tracks: raw.map((t) =>
|
|
22881
|
+
return { tracks: raw.map((t) => recordOf3(t) ?? {}) };
|
|
22782
22882
|
}
|
|
22783
22883
|
function resolveRepairLayers(catalog, source) {
|
|
22784
22884
|
if (!catalog) return void 0;
|
|
22785
22885
|
const sourceName = typeof source === "string" ? source : source.name;
|
|
22786
22886
|
const hang = catalog;
|
|
22787
22887
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "audio" ? ["audio"] : source.type === "video" ? ["video"] : ["video", "audio"];
|
|
22788
|
-
const
|
|
22789
|
-
if (
|
|
22790
|
-
const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22791
|
-
const rendition =
|
|
22888
|
+
const located = locateCatalogFecSource(catalog, sourceName, roles);
|
|
22889
|
+
if (located?.dialect === "hang") {
|
|
22890
|
+
const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22891
|
+
const rendition = located.entry;
|
|
22792
22892
|
rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
|
|
22793
|
-
const repairRenditions =
|
|
22893
|
+
const repairRenditions = recordOf3(hang.repair?.renditions) ?? {};
|
|
22794
22894
|
const descriptors2 = Object.entries(repairRenditions).map(([name, entry]) => {
|
|
22795
22895
|
const path = `$.repair.renditions[${JSON.stringify(name)}]`;
|
|
22796
|
-
const fields =
|
|
22896
|
+
const fields = recordOf3(entry);
|
|
22797
22897
|
if (fields === void 0) {
|
|
22798
22898
|
throwRepairContractError("track_repair_layer", path, "a repair rendition must be an object");
|
|
22799
22899
|
}
|
|
@@ -22801,14 +22901,14 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22801
22901
|
return describeRepairTrack(name, path, fields);
|
|
22802
22902
|
});
|
|
22803
22903
|
const fecOfRendition = (entry) => {
|
|
22804
|
-
const fec2 =
|
|
22904
|
+
const fec2 = recordOf3(recordOf3(entry)?.["fec"]);
|
|
22805
22905
|
return fec2 !== void 0 && fec2["algorithm"] !== "none" ? fec2 : void 0;
|
|
22806
22906
|
};
|
|
22807
22907
|
const mediaRenditions = [
|
|
22808
|
-
...Object.values(
|
|
22809
|
-
...Object.values(
|
|
22908
|
+
...Object.values(recordOf3(hang.video?.renditions) ?? {}),
|
|
22909
|
+
...Object.values(recordOf3(hang.audio?.renditions) ?? {})
|
|
22810
22910
|
];
|
|
22811
|
-
const reachability2 = repairReachability(mediaRenditions.map((entry) =>
|
|
22911
|
+
const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf3(entry)?.["fec"]));
|
|
22812
22912
|
for (const d of descriptors2) {
|
|
22813
22913
|
validateRepairTrackFields(d, throwRepairContractError);
|
|
22814
22914
|
assertRepairTrackReachable(d, reachability2, throwRepairContractError);
|
|
@@ -22824,20 +22924,20 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22824
22924
|
}
|
|
22825
22925
|
}
|
|
22826
22926
|
const layers2 = assembleRepairLayers(
|
|
22827
|
-
geometryOf(sourceName, `${renditionPath}.fec`,
|
|
22927
|
+
geometryOf(sourceName, `${renditionPath}.fec`, recordOf3(rendition["fec"])),
|
|
22828
22928
|
descriptors2,
|
|
22829
22929
|
throwRepairContractError
|
|
22830
22930
|
);
|
|
22831
22931
|
return catalogFecUnavailable(rendition["fec"], `${renditionPath}.fec`) === void 0 ? layers2 : void 0;
|
|
22832
22932
|
}
|
|
22833
22933
|
const msf = msfTracks(catalog);
|
|
22834
|
-
|
|
22835
|
-
|
|
22934
|
+
if (!msf || located?.dialect !== "msf") return void 0;
|
|
22935
|
+
const msfIndex = located.index;
|
|
22836
22936
|
const track = msf.tracks[msfIndex];
|
|
22837
|
-
const fec =
|
|
22937
|
+
const fec = recordOf3(track["fec"]);
|
|
22838
22938
|
const packagingOf = (t) => t["packaging"];
|
|
22839
22939
|
const fecOfTrack = (t) => {
|
|
22840
|
-
const trackFec =
|
|
22940
|
+
const trackFec = recordOf3(t?.["fec"]);
|
|
22841
22941
|
return trackFec !== void 0 && trackFec["algorithm"] !== "none" ? trackFec : void 0;
|
|
22842
22942
|
};
|
|
22843
22943
|
const descriptors = [];
|
|
@@ -22887,8 +22987,8 @@ function catalogRepairTarget(catalog, source) {
|
|
|
22887
22987
|
const entry = msf?.tracks.find((t) => t["name"] === sourceName);
|
|
22888
22988
|
const hang = catalog;
|
|
22889
22989
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "video" ? ["video"] : source.type === "audio" ? ["audio"] : ["video", "audio"];
|
|
22890
|
-
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) =>
|
|
22891
|
-
const fec = rendition === void 0 ?
|
|
22990
|
+
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) => recordOf3(r) !== void 0);
|
|
22991
|
+
const fec = rendition === void 0 ? recordOf3(entry?.["fec"]) : recordOf3(rendition.fec);
|
|
22892
22992
|
if (!fec || !(catalogFecInterleaveMs(fec) ?? 0)) return null;
|
|
22893
22993
|
const sourcePriority = entry === void 0 ? null : moqtPriority2(entry["priority"]);
|
|
22894
22994
|
return { repairTrack: layerZero.repairTrackName, sourcePriority, repairPriority: layerZero.priority };
|
|
@@ -22931,10 +23031,14 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
22931
23031
|
});
|
|
22932
23032
|
}
|
|
22933
23033
|
function catalogFecUnavailable(fec, fecPath) {
|
|
22934
|
-
|
|
22935
|
-
|
|
23034
|
+
if (catalogFecAvailable(fec)) return void 0;
|
|
23035
|
+
const block = recordOf3(fec);
|
|
22936
23036
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
22937
|
-
|
|
23037
|
+
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
23038
|
+
if (reason === void 0) {
|
|
23039
|
+
throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
|
|
23040
|
+
}
|
|
23041
|
+
return reason;
|
|
22938
23042
|
}
|
|
22939
23043
|
function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
22940
23044
|
const mediaRate = sampleRate === void 0 ? { fps } : { fps, sampleRate };
|
|
@@ -22943,10 +23047,8 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
22943
23047
|
const repair = resolveRepairLayers(catalog, track);
|
|
22944
23048
|
const fecPath = `$.${track.type}.renditions[${JSON.stringify(track.name)}].fec`;
|
|
22945
23049
|
if (!catalogDeclaresFec(fec)) {
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
|
|
22949
|
-
if (declaresFecInstance && !(kValid && tValid)) {
|
|
23050
|
+
if (catalogFecDeclaresUnconfigurableInstance(fec)) {
|
|
23051
|
+
const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
|
|
22950
23052
|
throwRepairContractError(
|
|
22951
23053
|
"track_fec",
|
|
22952
23054
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
@@ -23353,6 +23455,9 @@ var MulticastManager = class {
|
|
|
23353
23455
|
#router;
|
|
23354
23456
|
#hostMfuTimeoutMs;
|
|
23355
23457
|
#transport;
|
|
23458
|
+
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
23459
|
+
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
23460
|
+
#repairReleases = /* @__PURE__ */ new Map();
|
|
23356
23461
|
#reportedFecDiagnosticsFailure = false;
|
|
23357
23462
|
// ── Stream-global FEC timing reduction ──
|
|
23358
23463
|
//
|
|
@@ -24000,11 +24105,80 @@ var MulticastManager = class {
|
|
|
24000
24105
|
// through whatever the relay looks like, since dropping it would be the
|
|
24001
24106
|
// worse behaviour.
|
|
24002
24107
|
amtRelayPort: config.amtRelayPort ?? config.relayPort ?? (amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24108
|
+
amtDiscovery: config.amtDiscovery,
|
|
24003
24109
|
packetIds: config.packetIds,
|
|
24004
24110
|
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId }))
|
|
24005
24111
|
};
|
|
24006
24112
|
return ingress === void 0 ? this.#transport.join(transportConfig) : this.#transport.join(transportConfig, ingress);
|
|
24007
24113
|
}
|
|
24114
|
+
/**
|
|
24115
|
+
* Join the selected rung's dedicated repair groups beside the media join
|
|
24116
|
+
* (pim #3898): one subscription per endpoint, through `provider` when given
|
|
24117
|
+
* (a `window.multicast`-shaped gateway or a subscribe callback), otherwise a
|
|
24118
|
+
* new MulticastTransport on `window.multicast`. Returns the call that
|
|
24119
|
+
* releases every one of them; dispose() releases them too.
|
|
24120
|
+
*
|
|
24121
|
+
* Packets go straight to the router with the endpoint's ingress, never
|
|
24122
|
+
* through feedPacket(): repair arriving on its own group is not media
|
|
24123
|
+
* liveness, so it must not hold off the media leg's failback watchdog. The
|
|
24124
|
+
* repair roles and owners are registered here; in-band owners stay the
|
|
24125
|
+
* caller's. Joining is best effort: a group that fails to join is logged
|
|
24126
|
+
* and leaves the media join as it was.
|
|
24127
|
+
*/
|
|
24128
|
+
joinRepairEndpoints(endpoints, provider) {
|
|
24129
|
+
const releases = [];
|
|
24130
|
+
let released = false;
|
|
24131
|
+
const safely = (each) => {
|
|
24132
|
+
try {
|
|
24133
|
+
each();
|
|
24134
|
+
} catch (error) {
|
|
24135
|
+
console.warn("[MulticastManager] repair group release failed", error);
|
|
24136
|
+
}
|
|
24137
|
+
};
|
|
24138
|
+
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners);
|
|
24139
|
+
this.#applyRepairOwners(repairOwners);
|
|
24140
|
+
for (const endpoint of endpoints) {
|
|
24141
|
+
const ingress = {
|
|
24142
|
+
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId })))
|
|
24143
|
+
};
|
|
24144
|
+
const onPacket = (packet) => {
|
|
24145
|
+
if (!released) this.#router.feedPacket(packet, "multicast", void 0, ingress);
|
|
24146
|
+
};
|
|
24147
|
+
const fail = (error) => console.warn(`[MulticastManager] repair group ${endpoint.group}:${endpoint.port} not joined`, error);
|
|
24148
|
+
if (typeof provider === "function") {
|
|
24149
|
+
Promise.resolve().then(() => provider(endpoint, onPacket)).then((release2) => released ? safely(release2) : releases.push(release2), fail);
|
|
24150
|
+
continue;
|
|
24151
|
+
}
|
|
24152
|
+
const transport = new MulticastTransport((packet) => onPacket(packet), { gateway: provider });
|
|
24153
|
+
releases.push(() => transport.dispose());
|
|
24154
|
+
void transport.join({
|
|
24155
|
+
sourceAddress: endpoint.source,
|
|
24156
|
+
groupAddress: endpoint.group,
|
|
24157
|
+
port: endpoint.port,
|
|
24158
|
+
mode: endpoint.mode,
|
|
24159
|
+
amtRelay: endpoint.amtRelay,
|
|
24160
|
+
amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : void 0),
|
|
24161
|
+
packetIds: endpoint.packetIds,
|
|
24162
|
+
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId }))
|
|
24163
|
+
}).then((joined) => {
|
|
24164
|
+
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
24165
|
+
});
|
|
24166
|
+
}
|
|
24167
|
+
const release = () => {
|
|
24168
|
+
if (released) return;
|
|
24169
|
+
released = true;
|
|
24170
|
+
this.#repairReleases.delete(release);
|
|
24171
|
+
for (const each of releases.splice(0)) safely(each);
|
|
24172
|
+
};
|
|
24173
|
+
this.#repairReleases.set(release, repairOwners);
|
|
24174
|
+
return release;
|
|
24175
|
+
}
|
|
24176
|
+
#applyRepairOwners(owners) {
|
|
24177
|
+
for (const { packetId, ownerPacketId } of owners) {
|
|
24178
|
+
this.#router.setPacketIdRole(packetId, "repair");
|
|
24179
|
+
this.#router.setRepairPacketIdOwner(packetId, ownerPacketId);
|
|
24180
|
+
}
|
|
24181
|
+
}
|
|
24008
24182
|
// ---------------------------------------------------------------------------
|
|
24009
24183
|
// In-place rendition switch
|
|
24010
24184
|
// ---------------------------------------------------------------------------
|
|
@@ -24417,6 +24591,7 @@ var MulticastManager = class {
|
|
|
24417
24591
|
this.#switchingSets.clear();
|
|
24418
24592
|
this.#repairPacketIds.clear();
|
|
24419
24593
|
this.#router.clearRepairPacketIdOwners();
|
|
24594
|
+
for (const owners of this.#repairReleases.values()) this.#applyRepairOwners(owners);
|
|
24420
24595
|
const fecPacketIds = new Set([...fecDecoders.keys()].map((i) => catalog.tracks[i].packetId));
|
|
24421
24596
|
for (const [packetId, catalogTrackName] of this.#multiTrackFecTracks) {
|
|
24422
24597
|
if (fecPacketIds.has(packetId)) continue;
|
|
@@ -24748,6 +24923,7 @@ var MulticastManager = class {
|
|
|
24748
24923
|
this.#trackResetObservers.clear();
|
|
24749
24924
|
this.#repairLifecycleObservers.clear();
|
|
24750
24925
|
this.#transport.dispose();
|
|
24926
|
+
for (const release of [...this.#repairReleases.keys()]) release();
|
|
24751
24927
|
this.#router.dispose();
|
|
24752
24928
|
this.#fec.dispose();
|
|
24753
24929
|
}
|
|
@@ -26982,6 +27158,8 @@ export {
|
|
|
26982
27158
|
buildVideoInitSegment,
|
|
26983
27159
|
catalogAmtNetworkSource,
|
|
26984
27160
|
catalogDeclaresFec,
|
|
27161
|
+
catalogFecAvailable,
|
|
27162
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
26985
27163
|
catalogFecInterleaveMs,
|
|
26986
27164
|
catalogFecMediaUnitsPerSecond,
|
|
26987
27165
|
catalogFecUnavailable,
|
|
@@ -27056,6 +27234,7 @@ export {
|
|
|
27056
27234
|
isTrackTimingConfig,
|
|
27057
27235
|
joinedRepairSymbolCount,
|
|
27058
27236
|
keyframeIntervalMediaTicks,
|
|
27237
|
+
locateCatalogFecSource,
|
|
27059
27238
|
mergeOverrideIntoCmsfTracks,
|
|
27060
27239
|
mergeOverrideIntoHangRenditions,
|
|
27061
27240
|
mfuReassemblyTimeoutMs,
|