@blockcast/mmt-container 0.4.0-main.71d61b2a53f2 → 0.4.0-main.726ce14f2b17
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/dist/browser-runtime.js +371 -63
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +6 -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 +10 -0
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +16 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +38 -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 +3 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +8 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +73 -2
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +92 -12
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +73 -2
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +32 -3
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +107 -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 +38 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +214 -26
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +10 -0
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +3 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +89 -11
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +86 -2
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +85 -11
- 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 +3 -0
- 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 +73 -2
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/carp-catalog.ts +5 -0
- package/src/catalog-fec-params.ts +38 -17
- package/src/fec-manager.ts +43 -0
- package/src/fec-state.ts +4 -9
- package/src/index.ts +5 -0
- package/src/mmtp-container-parser.ts +79 -2
- package/src/mmtp-router.ts +69 -18
- package/src/multicast-manager.ts +81 -3
- package/src/repair-fetch.ts +228 -17
- package/test-vectors/catalog/README.md +7 -1
- package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +1 -0
- package/test-vectors/catalog/section-codes.json +33 -0
package/dist/browser-runtime.js
CHANGED
|
@@ -949,6 +949,71 @@ function isoBlocksBehindLowerBound(a, b, kMax) {
|
|
|
949
949
|
return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
|
|
950
950
|
}
|
|
951
951
|
|
|
952
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
953
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
954
|
+
function recordOf(value) {
|
|
955
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
956
|
+
}
|
|
957
|
+
function locateCatalogFecSource(catalog, source, roles = ALL_ROLES) {
|
|
958
|
+
const root = recordOf(catalog);
|
|
959
|
+
if (root === void 0)
|
|
960
|
+
return void 0;
|
|
961
|
+
for (const role of roles) {
|
|
962
|
+
const renditions = recordOf(recordOf(root[role])?.["renditions"]);
|
|
963
|
+
if (renditions === void 0 || !Object.hasOwn(renditions, source))
|
|
964
|
+
continue;
|
|
965
|
+
const entry2 = recordOf(renditions[source]);
|
|
966
|
+
if (entry2 === void 0)
|
|
967
|
+
continue;
|
|
968
|
+
return Object.freeze({
|
|
969
|
+
dialect: "hang",
|
|
970
|
+
role,
|
|
971
|
+
entry: entry2,
|
|
972
|
+
fec: entry2["fec"],
|
|
973
|
+
fecPath: `$.${role}.renditions[${JSON.stringify(source)}].fec`
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
const tracks = root["tracks"];
|
|
977
|
+
if (!Array.isArray(tracks))
|
|
978
|
+
return void 0;
|
|
979
|
+
const index = tracks.findIndex((track) => recordOf(track)?.["name"] === source);
|
|
980
|
+
if (index < 0)
|
|
981
|
+
return void 0;
|
|
982
|
+
const entry = recordOf(tracks[index]) ?? {};
|
|
983
|
+
return Object.freeze({
|
|
984
|
+
dialect: "msf",
|
|
985
|
+
index,
|
|
986
|
+
entry,
|
|
987
|
+
fec: entry["fec"],
|
|
988
|
+
fecPath: `$.tracks[${index}].fec`
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
function isoBlockSpanUsable(fec) {
|
|
992
|
+
const block = recordOf(fec);
|
|
993
|
+
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
|
|
994
|
+
return true;
|
|
995
|
+
const ms = block["interleaveDepthMs"];
|
|
996
|
+
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
997
|
+
}
|
|
998
|
+
function catalogFecAvailable(fec) {
|
|
999
|
+
const block = recordOf(fec);
|
|
1000
|
+
if (block === void 0)
|
|
1001
|
+
return true;
|
|
1002
|
+
const declaresFecInstance = block["algorithm"] !== "none";
|
|
1003
|
+
const profile = block["blockProfile"];
|
|
1004
|
+
const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
|
|
1005
|
+
return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
|
|
1006
|
+
}
|
|
1007
|
+
function isPositiveSafeInteger(value) {
|
|
1008
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1009
|
+
}
|
|
1010
|
+
function catalogFecDeclaresUnconfigurableInstance(fec) {
|
|
1011
|
+
const block = recordOf(fec);
|
|
1012
|
+
if (block === void 0 || block["algorithm"] === "none")
|
|
1013
|
+
return false;
|
|
1014
|
+
return !(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"]));
|
|
1015
|
+
}
|
|
1016
|
+
|
|
952
1017
|
// src/mfu-reassembler.ts
|
|
953
1018
|
function fragmentProvenance(fragment) {
|
|
954
1019
|
if (fragment.deliveryProvenance !== void 0) return fragment.deliveryProvenance;
|
|
@@ -6718,6 +6783,9 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6718
6783
|
catalogError("track_fec", `${path}.fec.${field}`, "must be a positive integer");
|
|
6719
6784
|
}
|
|
6720
6785
|
}
|
|
6786
|
+
if (algorithm === "raptorq" && config["symbolSize"] % 8 !== 0) {
|
|
6787
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "RaptorQ symbolSize must be a multiple of 8");
|
|
6788
|
+
}
|
|
6721
6789
|
if (typeof config["repairTrack"] !== "string" || config["repairTrack"].length === 0) {
|
|
6722
6790
|
catalogError("track_fec", `${path}.fec.repairTrack`, "must be a non-empty string");
|
|
6723
6791
|
}
|
|
@@ -6923,6 +6991,9 @@ var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
|
6923
6991
|
"iso-ssbg1-v1"
|
|
6924
6992
|
]);
|
|
6925
6993
|
|
|
6994
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
6995
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
6996
|
+
|
|
6926
6997
|
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
6927
6998
|
var DRIADDiscovery = class {
|
|
6928
6999
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -8125,6 +8196,10 @@ var TransportManager = class {
|
|
|
8125
8196
|
pollMulticastTierSwitch() {
|
|
8126
8197
|
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
|
|
8127
8198
|
}
|
|
8199
|
+
/** Abandon the in-flight tier join, e.g. because the host could not join the target. */
|
|
8200
|
+
cancelMulticastTierJoin() {
|
|
8201
|
+
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
|
|
8202
|
+
}
|
|
8128
8203
|
/**
|
|
8129
8204
|
* Set packet callback
|
|
8130
8205
|
*/
|
|
@@ -12572,22 +12647,16 @@ var INACTIVE = Object.freeze({
|
|
|
12572
12647
|
"reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
|
|
12573
12648
|
"no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
|
|
12574
12649
|
});
|
|
12575
|
-
function
|
|
12650
|
+
function recordOf2(value) {
|
|
12576
12651
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12577
12652
|
}
|
|
12578
|
-
function
|
|
12653
|
+
function isPositiveSafeInteger2(value) {
|
|
12579
12654
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
12580
12655
|
}
|
|
12581
12656
|
function catalogDeclaresFec(fec) {
|
|
12582
|
-
const block =
|
|
12657
|
+
const block = recordOf2(fec);
|
|
12583
12658
|
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
12584
|
-
return
|
|
12585
|
-
}
|
|
12586
|
-
function isoBlockSpanUsable(fec) {
|
|
12587
|
-
const block = recordOf(fec);
|
|
12588
|
-
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
|
|
12589
|
-
const ms = block["interleaveDepthMs"];
|
|
12590
|
-
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
12659
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
12591
12660
|
}
|
|
12592
12661
|
function requireBoolean(value, field) {
|
|
12593
12662
|
if (typeof value !== "boolean") {
|
|
@@ -12603,7 +12672,7 @@ function resolveFecState(evidence) {
|
|
|
12603
12672
|
if (typeof transportPolicy !== "string" || !TRANSPORT_POLICIES.has(transportPolicy)) {
|
|
12604
12673
|
throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`);
|
|
12605
12674
|
}
|
|
12606
|
-
if (stats !== null && stats !== void 0 &&
|
|
12675
|
+
if (stats !== null && stats !== void 0 && recordOf2(stats) === void 0) {
|
|
12607
12676
|
throw new TypeError("resolveFecState: stats must be a plain object, null or undefined");
|
|
12608
12677
|
}
|
|
12609
12678
|
if (!catalogFec) return INACTIVE["no-catalog-fec"];
|
|
@@ -13185,6 +13254,9 @@ var FECManager = class _FECManager {
|
|
|
13185
13254
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
13186
13255
|
this.#ssbLengthConflictCount = 0;
|
|
13187
13256
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
13257
|
+
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
13258
|
+
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
13259
|
+
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
13188
13260
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
13189
13261
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
13190
13262
|
// which would falsely start new timeouts without this guard.
|
|
@@ -13425,6 +13497,7 @@ var FECManager = class _FECManager {
|
|
|
13425
13497
|
#blockAuthoredLengths;
|
|
13426
13498
|
#ssbLengthConflictCount;
|
|
13427
13499
|
#blockRepairRsIds;
|
|
13500
|
+
#blockRsbLengths;
|
|
13428
13501
|
#completedBlocks;
|
|
13429
13502
|
#terminalExpiryMs;
|
|
13430
13503
|
#terminalQueues;
|
|
@@ -14696,6 +14769,7 @@ var FECManager = class _FECManager {
|
|
|
14696
14769
|
resetMap(this.#blockSourceEsis);
|
|
14697
14770
|
resetMap(this.#blockAuthoredLengths);
|
|
14698
14771
|
resetMap(this.#blockRepairRsIds);
|
|
14772
|
+
resetMap(this.#blockRsbLengths);
|
|
14699
14773
|
resetMap(this.#blockPathCounts);
|
|
14700
14774
|
resetMap(this.#blockAnchorsMs);
|
|
14701
14775
|
resetMap(this.#blockCatalogTrackNames);
|
|
@@ -14813,6 +14887,7 @@ var FECManager = class _FECManager {
|
|
|
14813
14887
|
dropMap(this.#blockSourceEsis);
|
|
14814
14888
|
dropMap(this.#blockAuthoredLengths);
|
|
14815
14889
|
dropMap(this.#blockRepairRsIds);
|
|
14890
|
+
dropMap(this.#blockRsbLengths);
|
|
14816
14891
|
dropMap(this.#blockPathCounts);
|
|
14817
14892
|
dropMap(this.#blockAnchorsMs);
|
|
14818
14893
|
dropMap(this.#blockCatalogTrackNames);
|
|
@@ -15067,6 +15142,31 @@ var FECManager = class _FECManager {
|
|
|
15067
15142
|
windowMs: this.#deliveryGaps.windowMs
|
|
15068
15143
|
};
|
|
15069
15144
|
}
|
|
15145
|
+
/**
|
|
15146
|
+
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
15147
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it).
|
|
15148
|
+
* Undefined for a block that is not open.
|
|
15149
|
+
*/
|
|
15150
|
+
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
15151
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15152
|
+
if (!this.#activeBlocks.has(key)) return void 0;
|
|
15153
|
+
return {
|
|
15154
|
+
sources: this.#blockSourceCounts.get(key) ?? 0,
|
|
15155
|
+
repairs: this.#blockRepairRsIds.get(key)?.size ?? 0,
|
|
15156
|
+
authoredLength: this.#blockAuthoredLengths.get(key),
|
|
15157
|
+
repairGroupLength: this.#blockRsbLengths.get(key)
|
|
15158
|
+
};
|
|
15159
|
+
}
|
|
15160
|
+
/**
|
|
15161
|
+
* Record a block's RSB_length from one of its repair symbols (the router
|
|
15162
|
+
* parses it from the Repair FEC Payload ID). The largest stated value wins.
|
|
15163
|
+
*/
|
|
15164
|
+
noteRepairGroupLength(sbn, packetId, rsbLength, catalogTrackName) {
|
|
15165
|
+
if (!Number.isSafeInteger(rsbLength) || rsbLength <= 0) return;
|
|
15166
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15167
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
15168
|
+
if ((this.#blockRsbLengths.get(key) ?? 0) < rsbLength) this.#blockRsbLengths.set(key, rsbLength);
|
|
15169
|
+
}
|
|
15070
15170
|
/**
|
|
15071
15171
|
* Receiver-local time of a block's first accepted symbol, or undefined for
|
|
15072
15172
|
* a block no symbol reached (one materialized because a later SBN arrived).
|
|
@@ -16006,6 +16106,7 @@ var FECManager = class _FECManager {
|
|
|
16006
16106
|
this.#blockSourceEsis.delete(key);
|
|
16007
16107
|
this.#blockAuthoredLengths.delete(key);
|
|
16008
16108
|
this.#blockRepairRsIds.delete(key);
|
|
16109
|
+
this.#blockRsbLengths.delete(key);
|
|
16009
16110
|
this.#markTerminal(key, sbn, packetId, true);
|
|
16010
16111
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
16011
16112
|
if (catalogTrackName === void 0) {
|
|
@@ -16057,6 +16158,7 @@ var FECManager = class _FECManager {
|
|
|
16057
16158
|
this.#blockSourceEsis.delete(key);
|
|
16058
16159
|
this.#blockAuthoredLengths.delete(key);
|
|
16059
16160
|
this.#blockRepairRsIds.delete(key);
|
|
16161
|
+
this.#blockRsbLengths.delete(key);
|
|
16060
16162
|
this.#syncDecoderBlockOwners.delete(key);
|
|
16061
16163
|
this.#markTerminal(key, sbn, packetId, false);
|
|
16062
16164
|
this.#failedBlocks.add(key);
|
|
@@ -16094,6 +16196,7 @@ var FECManager = class _FECManager {
|
|
|
16094
16196
|
this.#blockSourceEsis.delete(key);
|
|
16095
16197
|
this.#blockAuthoredLengths.delete(key);
|
|
16096
16198
|
this.#blockRepairRsIds.delete(key);
|
|
16199
|
+
this.#blockRsbLengths.delete(key);
|
|
16097
16200
|
this.#clearBlockTimer(key);
|
|
16098
16201
|
this.onBlockResolved?.(block.sbn, block.packetId, block.catalogTrackName);
|
|
16099
16202
|
}
|
|
@@ -16184,6 +16287,7 @@ var FECManager = class _FECManager {
|
|
|
16184
16287
|
this.#blockSourceEsis.clear();
|
|
16185
16288
|
this.#blockAuthoredLengths.clear();
|
|
16186
16289
|
this.#blockRepairRsIds.clear();
|
|
16290
|
+
this.#blockRsbLengths.clear();
|
|
16187
16291
|
this.#completedBlocks.clear();
|
|
16188
16292
|
this.#cleanlyCompletedBlocks.clear();
|
|
16189
16293
|
this.#repairRequestedBlocks.clear();
|
|
@@ -17055,6 +17159,42 @@ var FecReleaseSequencer = class {
|
|
|
17055
17159
|
for (const stream of this.#streams.values()) total += stream.buf.length;
|
|
17056
17160
|
return total;
|
|
17057
17161
|
}
|
|
17162
|
+
#deferDepth = 0;
|
|
17163
|
+
#deferredStreams = /* @__PURE__ */ new Set();
|
|
17164
|
+
/**
|
|
17165
|
+
* Run `work` with the drains its pushes would run deferred to its end. A
|
|
17166
|
+
* recovered FEC block is routed one frame at a time, and its block is
|
|
17167
|
+
* already resolved when the first frame is pushed: draining on that push
|
|
17168
|
+
* would release past the gap before the block's other recovered frames
|
|
17169
|
+
* arrive (deciding a conceal or stall for media that is about to land),
|
|
17170
|
+
* and those frames would then be dropped as stale. Nests.
|
|
17171
|
+
*/
|
|
17172
|
+
defer(work) {
|
|
17173
|
+
this.#deferDepth++;
|
|
17174
|
+
let threw = true;
|
|
17175
|
+
try {
|
|
17176
|
+
work();
|
|
17177
|
+
threw = false;
|
|
17178
|
+
} finally {
|
|
17179
|
+
this.#deferDepth--;
|
|
17180
|
+
if (this.#deferDepth === 0 && this.#deferredStreams.size > 0) {
|
|
17181
|
+
const streams = [...this.#deferredStreams];
|
|
17182
|
+
this.#deferredStreams.clear();
|
|
17183
|
+
if (!threw) {
|
|
17184
|
+
for (const stream of streams) this.#drain(stream);
|
|
17185
|
+
} else {
|
|
17186
|
+
try {
|
|
17187
|
+
for (const stream of streams) this.#drain(stream);
|
|
17188
|
+
} catch {
|
|
17189
|
+
}
|
|
17190
|
+
}
|
|
17191
|
+
}
|
|
17192
|
+
}
|
|
17193
|
+
}
|
|
17194
|
+
#drainUnlessDeferred(stream) {
|
|
17195
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
17196
|
+
else this.#drain(stream);
|
|
17197
|
+
}
|
|
17058
17198
|
push(streamKey, data, meta, seq) {
|
|
17059
17199
|
const frame = { data, meta: { ...meta }, seq, arrivedAtMs: performance.now() };
|
|
17060
17200
|
const stream = this.#streamFor(streamKey, meta);
|
|
@@ -17076,7 +17216,7 @@ var FecReleaseSequencer = class {
|
|
|
17076
17216
|
return;
|
|
17077
17217
|
}
|
|
17078
17218
|
this.#release(stream, frame, void 0);
|
|
17079
|
-
this.#
|
|
17219
|
+
this.#drainUnlessDeferred(stream);
|
|
17080
17220
|
return;
|
|
17081
17221
|
}
|
|
17082
17222
|
let lo = 0;
|
|
@@ -17087,7 +17227,23 @@ var FecReleaseSequencer = class {
|
|
|
17087
17227
|
else hi = mid;
|
|
17088
17228
|
}
|
|
17089
17229
|
stream.buf.splice(lo, 0, frame);
|
|
17090
|
-
this.#
|
|
17230
|
+
this.#drainUnlessDeferred(stream);
|
|
17231
|
+
}
|
|
17232
|
+
/**
|
|
17233
|
+
* Arrival time of the earliest frame a stream of `packetId` holds behind a
|
|
17234
|
+
* gap (the gate forces it out `holdLimitMs` after that), or undefined when
|
|
17235
|
+
* none is held. Without `catalogTrackName`, every stream of the packetId.
|
|
17236
|
+
*/
|
|
17237
|
+
earliestHeldArrivalMs(packetId, catalogTrackName) {
|
|
17238
|
+
let earliest;
|
|
17239
|
+
for (const stream of this.#streams.values()) {
|
|
17240
|
+
if (stream.packetId !== packetId) continue;
|
|
17241
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
17242
|
+
for (const frame of stream.buf) {
|
|
17243
|
+
if (earliest === void 0 || frame.arrivedAtMs < earliest) earliest = frame.arrivedAtMs;
|
|
17244
|
+
}
|
|
17245
|
+
}
|
|
17246
|
+
return earliest;
|
|
17091
17247
|
}
|
|
17092
17248
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
17093
17249
|
poke(streamKey) {
|
|
@@ -17523,6 +17679,22 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17523
17679
|
}
|
|
17524
17680
|
) : null;
|
|
17525
17681
|
}
|
|
17682
|
+
/**
|
|
17683
|
+
* Run `work` with the FEC release gate's drains deferred to its end, so
|
|
17684
|
+
* every frame it pushes is in place before any held gap is decided (see
|
|
17685
|
+
* FecReleaseSequencer.defer).
|
|
17686
|
+
*/
|
|
17687
|
+
deferFecRelease(work) {
|
|
17688
|
+
if (!this.#fecSequencer) {
|
|
17689
|
+
work();
|
|
17690
|
+
return;
|
|
17691
|
+
}
|
|
17692
|
+
this.#fecSequencer.defer(work);
|
|
17693
|
+
}
|
|
17694
|
+
/** See FecReleaseSequencer.earliestHeldArrivalMs. */
|
|
17695
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
17696
|
+
return this.#fecSequencer?.earliestHeldArrivalMs(packetId, catalogTrackName);
|
|
17697
|
+
}
|
|
17526
17698
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
17527
17699
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
17528
17700
|
if (!this.#fecSequencer) return;
|
|
@@ -18860,6 +19032,8 @@ var MmtpRouter = class {
|
|
|
18860
19032
|
// ── Keyframe loss detection state ───────────────────────────────
|
|
18861
19033
|
/** Catalog-derived keyframe loss timeout (ms), or a reader evaluated at each arm. null = not configured (warns on video track registration; Phase-13 keyframe repair stays off). */
|
|
18862
19034
|
#keyframeLostTimeoutMs;
|
|
19035
|
+
/** packetIds already warned for running without Phase 13 (non-FEC video only). */
|
|
19036
|
+
#warnedNoKeyframeLostTimeout = /* @__PURE__ */ new Set();
|
|
18863
19037
|
/** Why the last reader evaluation left the timer unarmed; null while arming. Dedups the warning. */
|
|
18864
19038
|
#keyframeLostUnarmedReason = null;
|
|
18865
19039
|
/** Active keyframe loss timer handle. Single timer per video track — cleared on each rapFlag and on dispose(). */
|
|
@@ -19189,15 +19363,14 @@ var MmtpRouter = class {
|
|
|
19189
19363
|
}
|
|
19190
19364
|
/** Register MMTP packetId → track type mapping.
|
|
19191
19365
|
* Call BEFORE packets arrive to ensure correct routing from the first packet.
|
|
19192
|
-
*
|
|
19193
|
-
*
|
|
19194
|
-
*
|
|
19366
|
+
* Without keyframeLostTimeoutMs a track WITHOUT FEC has no Phase 13
|
|
19367
|
+
* keyframe repair (video still routes/decodes normally); that is warned at
|
|
19368
|
+
* its first keyframe, once the FEC configuration is known (see
|
|
19369
|
+
* #noteEmittedKeyframe). Nothing is warned here: an FEC track never uses
|
|
19370
|
+
* the timer, and at registration the FEC configuration may not be applied
|
|
19371
|
+
* yet. framerate is OPTIONAL per draft-ietf-moq-catalogformat-01 §3.2.23,
|
|
19372
|
+
* so we can't require the timeout. */
|
|
19195
19373
|
setPacketIdType(packetId, trackType) {
|
|
19196
|
-
if (trackType === "video" && this.#keyframeLostTimeoutMs === null) {
|
|
19197
|
-
console.warn(
|
|
19198
|
-
"[MmtpRouter] keyframeLostTimeoutMs not configured \u2014 Phase 13 keyframe repair disabled for this track. Set it via setKeyframeLostTimeoutMs() or provide in constructor config to enable: Math.ceil(groupDurationMs * KEYFRAME_LOST_TIMEOUT_SLACK)."
|
|
19199
|
-
);
|
|
19200
|
-
}
|
|
19201
19374
|
if (trackType === "video") this.#videoPacketIds.add(packetId);
|
|
19202
19375
|
else this.#audioPacketIds.add(packetId);
|
|
19203
19376
|
const codec = this.#trackCodecs.get(packetId) ?? "";
|
|
@@ -19628,6 +19801,7 @@ var MmtpRouter = class {
|
|
|
19628
19801
|
catalogTrackName
|
|
19629
19802
|
)) return;
|
|
19630
19803
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
19804
|
+
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
19631
19805
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
19632
19806
|
const recovered = fec.feedRepairSymbol(
|
|
19633
19807
|
ownerPacketId,
|
|
@@ -19697,7 +19871,7 @@ var MmtpRouter = class {
|
|
|
19697
19871
|
* Sync WASM decoders return the block's K' = SSB_length fixed-width
|
|
19698
19872
|
* ssbg_mode1 source symbols concatenated. */
|
|
19699
19873
|
routeRecoveredBlock(blockId, data, packetId, catalogTrackName) {
|
|
19700
|
-
this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
19874
|
+
this.#withDeferredFecPokes(() => this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName));
|
|
19701
19875
|
}
|
|
19702
19876
|
/** Route a single recovered source symbol through the parser + dedup pipeline.
|
|
19703
19877
|
* Worker-backed decoders emit one padded source symbol per frame event. */
|
|
@@ -20111,8 +20285,16 @@ var MmtpRouter = class {
|
|
|
20111
20285
|
#noteEmittedKeyframe(packetId, keyframe) {
|
|
20112
20286
|
if (!keyframe) return;
|
|
20113
20287
|
if (!this.#videoPacketIds.has(packetId)) return;
|
|
20114
|
-
if (this.#keyframeLostTimeoutMs === null) return;
|
|
20115
20288
|
if (this.#isFecTrack(packetId)) return;
|
|
20289
|
+
if (this.#keyframeLostTimeoutMs === null) {
|
|
20290
|
+
if (!this.#warnedNoKeyframeLostTimeout.has(packetId)) {
|
|
20291
|
+
this.#warnedNoKeyframeLostTimeout.add(packetId);
|
|
20292
|
+
console.warn(
|
|
20293
|
+
`[MmtpRouter] keyframeLostTimeoutMs not configured \u2014 Phase 13 keyframe repair disabled for packetId=${packetId}, a video track without FEC. Set it via setKeyframeLostTimeoutMs() or provide in constructor config to enable.`
|
|
20294
|
+
);
|
|
20295
|
+
}
|
|
20296
|
+
return;
|
|
20297
|
+
}
|
|
20116
20298
|
this.#lastKeyframeGroupId++;
|
|
20117
20299
|
this.#armKeyframeLostTimer();
|
|
20118
20300
|
}
|
|
@@ -20124,7 +20306,7 @@ var MmtpRouter = class {
|
|
|
20124
20306
|
#withDeferredFecPokes(work) {
|
|
20125
20307
|
this.#fecPokeDepth++;
|
|
20126
20308
|
try {
|
|
20127
|
-
work
|
|
20309
|
+
this.#parser.deferFecRelease(work);
|
|
20128
20310
|
} finally {
|
|
20129
20311
|
this.#fecPokeDepth--;
|
|
20130
20312
|
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
@@ -20136,6 +20318,13 @@ var MmtpRouter = class {
|
|
|
20136
20318
|
}
|
|
20137
20319
|
}
|
|
20138
20320
|
}
|
|
20321
|
+
/**
|
|
20322
|
+
* Arrival time of the earliest frame the FEC release gate holds for this
|
|
20323
|
+
* stream (see FecReleaseSequencer.earliestHeldArrivalMs), or undefined.
|
|
20324
|
+
*/
|
|
20325
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
20326
|
+
return this.#parser.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
20327
|
+
}
|
|
20139
20328
|
#requestFecPoke(packetId, catalogTrackName) {
|
|
20140
20329
|
if (this.#disposed) return;
|
|
20141
20330
|
if (this.#fecPokeDepth > 0) {
|
|
@@ -20504,6 +20693,8 @@ var MmtpRouter = class {
|
|
|
20504
20693
|
catalogTrackName
|
|
20505
20694
|
);
|
|
20506
20695
|
this.#routeTrackPacket(packet, info.packetId, info.sequenceNumber, {
|
|
20696
|
+
mmtpTimestamp: parsed.header.timestamp,
|
|
20697
|
+
rap: info.rapFlag,
|
|
20507
20698
|
recovered: false,
|
|
20508
20699
|
skipFecPayloadId: false,
|
|
20509
20700
|
catalogTrackName
|
|
@@ -20691,6 +20882,8 @@ var MmtpRouter = class {
|
|
|
20691
20882
|
callback(packet, {
|
|
20692
20883
|
packetId,
|
|
20693
20884
|
packetSequenceNumber,
|
|
20885
|
+
mmtpTimestamp: meta.mmtpTimestamp,
|
|
20886
|
+
rap: meta.rap,
|
|
20694
20887
|
recovered: meta.recovered,
|
|
20695
20888
|
skipFecPayloadId: meta.skipFecPayloadId,
|
|
20696
20889
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName },
|
|
@@ -21074,6 +21267,8 @@ var MmtpRouter = class {
|
|
|
21074
21267
|
) ?? "unknown";
|
|
21075
21268
|
for (const sym of result.symbols) {
|
|
21076
21269
|
this.#routeTrackPacket(sym.rawSymbol, ownerPacketId, sym.packetSequenceNumber, {
|
|
21270
|
+
mmtpTimestamp: sym.fragment.timestamp,
|
|
21271
|
+
rap: sym.fragment.rapFlag,
|
|
21077
21272
|
recovered: true,
|
|
21078
21273
|
skipFecPayloadId: true,
|
|
21079
21274
|
catalogTrackName,
|
|
@@ -22649,28 +22844,28 @@ function joinedRepairSymbolCount(params, joinedRepairTrackNames) {
|
|
|
22649
22844
|
}
|
|
22650
22845
|
return total;
|
|
22651
22846
|
}
|
|
22652
|
-
function
|
|
22847
|
+
function recordOf3(value) {
|
|
22653
22848
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22654
22849
|
}
|
|
22655
22850
|
function msfTracks(catalog) {
|
|
22656
22851
|
const raw = catalog.tracks;
|
|
22657
22852
|
if (!Array.isArray(raw)) return void 0;
|
|
22658
|
-
return { tracks: raw.map((t) =>
|
|
22853
|
+
return { tracks: raw.map((t) => recordOf3(t) ?? {}) };
|
|
22659
22854
|
}
|
|
22660
22855
|
function resolveRepairLayers(catalog, source) {
|
|
22661
22856
|
if (!catalog) return void 0;
|
|
22662
22857
|
const sourceName = typeof source === "string" ? source : source.name;
|
|
22663
22858
|
const hang = catalog;
|
|
22664
22859
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "audio" ? ["audio"] : source.type === "video" ? ["video"] : ["video", "audio"];
|
|
22665
|
-
const
|
|
22666
|
-
if (
|
|
22667
|
-
const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22668
|
-
const rendition =
|
|
22860
|
+
const located = locateCatalogFecSource(catalog, sourceName, roles);
|
|
22861
|
+
if (located?.dialect === "hang") {
|
|
22862
|
+
const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
22863
|
+
const rendition = located.entry;
|
|
22669
22864
|
rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
|
|
22670
|
-
const repairRenditions =
|
|
22865
|
+
const repairRenditions = recordOf3(hang.repair?.renditions) ?? {};
|
|
22671
22866
|
const descriptors2 = Object.entries(repairRenditions).map(([name, entry]) => {
|
|
22672
22867
|
const path = `$.repair.renditions[${JSON.stringify(name)}]`;
|
|
22673
|
-
const fields =
|
|
22868
|
+
const fields = recordOf3(entry);
|
|
22674
22869
|
if (fields === void 0) {
|
|
22675
22870
|
throwRepairContractError("track_repair_layer", path, "a repair rendition must be an object");
|
|
22676
22871
|
}
|
|
@@ -22678,14 +22873,14 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22678
22873
|
return describeRepairTrack(name, path, fields);
|
|
22679
22874
|
});
|
|
22680
22875
|
const fecOfRendition = (entry) => {
|
|
22681
|
-
const fec2 =
|
|
22876
|
+
const fec2 = recordOf3(recordOf3(entry)?.["fec"]);
|
|
22682
22877
|
return fec2 !== void 0 && fec2["algorithm"] !== "none" ? fec2 : void 0;
|
|
22683
22878
|
};
|
|
22684
22879
|
const mediaRenditions = [
|
|
22685
|
-
...Object.values(
|
|
22686
|
-
...Object.values(
|
|
22880
|
+
...Object.values(recordOf3(hang.video?.renditions) ?? {}),
|
|
22881
|
+
...Object.values(recordOf3(hang.audio?.renditions) ?? {})
|
|
22687
22882
|
];
|
|
22688
|
-
const reachability2 = repairReachability(mediaRenditions.map((entry) =>
|
|
22883
|
+
const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf3(entry)?.["fec"]));
|
|
22689
22884
|
for (const d of descriptors2) {
|
|
22690
22885
|
validateRepairTrackFields(d, throwRepairContractError);
|
|
22691
22886
|
assertRepairTrackReachable(d, reachability2, throwRepairContractError);
|
|
@@ -22701,20 +22896,20 @@ function resolveRepairLayers(catalog, source) {
|
|
|
22701
22896
|
}
|
|
22702
22897
|
}
|
|
22703
22898
|
const layers2 = assembleRepairLayers(
|
|
22704
|
-
geometryOf(sourceName, `${renditionPath}.fec`,
|
|
22899
|
+
geometryOf(sourceName, `${renditionPath}.fec`, recordOf3(rendition["fec"])),
|
|
22705
22900
|
descriptors2,
|
|
22706
22901
|
throwRepairContractError
|
|
22707
22902
|
);
|
|
22708
22903
|
return catalogFecUnavailable(rendition["fec"], `${renditionPath}.fec`) === void 0 ? layers2 : void 0;
|
|
22709
22904
|
}
|
|
22710
22905
|
const msf = msfTracks(catalog);
|
|
22711
|
-
|
|
22712
|
-
|
|
22906
|
+
if (!msf || located?.dialect !== "msf") return void 0;
|
|
22907
|
+
const msfIndex = located.index;
|
|
22713
22908
|
const track = msf.tracks[msfIndex];
|
|
22714
|
-
const fec =
|
|
22909
|
+
const fec = recordOf3(track["fec"]);
|
|
22715
22910
|
const packagingOf = (t) => t["packaging"];
|
|
22716
22911
|
const fecOfTrack = (t) => {
|
|
22717
|
-
const trackFec =
|
|
22912
|
+
const trackFec = recordOf3(t?.["fec"]);
|
|
22718
22913
|
return trackFec !== void 0 && trackFec["algorithm"] !== "none" ? trackFec : void 0;
|
|
22719
22914
|
};
|
|
22720
22915
|
const descriptors = [];
|
|
@@ -22764,8 +22959,8 @@ function catalogRepairTarget(catalog, source) {
|
|
|
22764
22959
|
const entry = msf?.tracks.find((t) => t["name"] === sourceName);
|
|
22765
22960
|
const hang = catalog;
|
|
22766
22961
|
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "video" ? ["video"] : source.type === "audio" ? ["audio"] : ["video", "audio"];
|
|
22767
|
-
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) =>
|
|
22768
|
-
const fec = rendition === void 0 ?
|
|
22962
|
+
const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) => recordOf3(r) !== void 0);
|
|
22963
|
+
const fec = rendition === void 0 ? recordOf3(entry?.["fec"]) : recordOf3(rendition.fec);
|
|
22769
22964
|
if (!fec || !(catalogFecInterleaveMs(fec) ?? 0)) return null;
|
|
22770
22965
|
const sourcePriority = entry === void 0 ? null : moqtPriority2(entry["priority"]);
|
|
22771
22966
|
return { repairTrack: layerZero.repairTrackName, sourcePriority, repairPriority: layerZero.priority };
|
|
@@ -22808,10 +23003,14 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
22808
23003
|
});
|
|
22809
23004
|
}
|
|
22810
23005
|
function catalogFecUnavailable(fec, fecPath) {
|
|
22811
|
-
|
|
22812
|
-
|
|
23006
|
+
if (catalogFecAvailable(fec)) return void 0;
|
|
23007
|
+
const block = recordOf3(fec);
|
|
22813
23008
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
22814
|
-
|
|
23009
|
+
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
23010
|
+
if (reason === void 0) {
|
|
23011
|
+
throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
|
|
23012
|
+
}
|
|
23013
|
+
return reason;
|
|
22815
23014
|
}
|
|
22816
23015
|
function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
22817
23016
|
const mediaRate = sampleRate === void 0 ? { fps } : { fps, sampleRate };
|
|
@@ -22820,10 +23019,8 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
22820
23019
|
const repair = resolveRepairLayers(catalog, track);
|
|
22821
23020
|
const fecPath = `$.${track.type}.renditions[${JSON.stringify(track.name)}].fec`;
|
|
22822
23021
|
if (!catalogDeclaresFec(fec)) {
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
|
|
22826
|
-
if (declaresFecInstance && !(kValid && tValid)) {
|
|
23022
|
+
if (catalogFecDeclaresUnconfigurableInstance(fec)) {
|
|
23023
|
+
const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
|
|
22827
23024
|
throwRepairContractError(
|
|
22828
23025
|
"track_fec",
|
|
22829
23026
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
@@ -22929,6 +23126,13 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
22929
23126
|
deltaRepairsPreempted: 0,
|
|
22930
23127
|
deltaRepairsDeferred: 0,
|
|
22931
23128
|
repairsSkipped: 0,
|
|
23129
|
+
repairsSkippedRttUnmeasured: 0,
|
|
23130
|
+
repairsSkippedRttExceedsBudget: 0,
|
|
23131
|
+
repairsSkippedPresentationDelayUnavailable: 0,
|
|
23132
|
+
lastRepairSkip: null,
|
|
23133
|
+
keyframeRepairFetchesSent: 0,
|
|
23134
|
+
keyframeBudgetHolds: 0,
|
|
23135
|
+
keyframeBudgetHoldMs: 0,
|
|
22932
23136
|
deltaBlocksFailed: 0,
|
|
22933
23137
|
audioBlocksRecoveredInband: 0,
|
|
22934
23138
|
audioBlocksRecoveredQuic: 0,
|
|
@@ -24431,7 +24635,17 @@ var MulticastManager = class {
|
|
|
24431
24635
|
}
|
|
24432
24636
|
/** Record a repair request the scheduler sent no FETCH for. */
|
|
24433
24637
|
noteRepairSkipped(reason, measurement, sbn, packetId, catalogTrackName) {
|
|
24434
|
-
this.#statsFor(packetId, catalogTrackName)
|
|
24638
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24639
|
+
stats.repairsSkipped++;
|
|
24640
|
+
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
24641
|
+
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
24642
|
+
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
24643
|
+
stats.lastRepairSkip = {
|
|
24644
|
+
reason,
|
|
24645
|
+
rttMs: measurement.rttMs,
|
|
24646
|
+
budgetMs: measurement.budgetMs,
|
|
24647
|
+
priority: measurement.priority ?? null
|
|
24648
|
+
};
|
|
24435
24649
|
this.#emitRepairLifecycle({
|
|
24436
24650
|
version: 2,
|
|
24437
24651
|
type: "repair-skipped",
|
|
@@ -24441,6 +24655,24 @@ var MulticastManager = class {
|
|
|
24441
24655
|
budgetMs: measurement.budgetMs
|
|
24442
24656
|
});
|
|
24443
24657
|
}
|
|
24658
|
+
/**
|
|
24659
|
+
* Arrival time of the earliest frame the in-order release gate holds for
|
|
24660
|
+
* the stream: the gate releases it as a discontinuity once
|
|
24661
|
+
* `terminalRetentionMsForPacket` has passed since then.
|
|
24662
|
+
*/
|
|
24663
|
+
earliestGatedFrameAtMs(packetId, catalogTrackName) {
|
|
24664
|
+
return this.#router.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
24665
|
+
}
|
|
24666
|
+
/** Record a keyframe late-repair budget the scheduler granted a block. */
|
|
24667
|
+
noteKeyframeBudgetGranted(extensionMs, _sbn, packetId, catalogTrackName) {
|
|
24668
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24669
|
+
stats.keyframeBudgetHolds++;
|
|
24670
|
+
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24671
|
+
}
|
|
24672
|
+
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24673
|
+
noteRepairFetchSent(priority, _sbn, packetId, catalogTrackName) {
|
|
24674
|
+
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
24675
|
+
}
|
|
24444
24676
|
/**
|
|
24445
24677
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
24446
24678
|
* keyframe/audio work, or never dispatched before its block resolved.
|
|
@@ -24468,7 +24700,10 @@ var MulticastManager = class {
|
|
|
24468
24700
|
const out = {};
|
|
24469
24701
|
for (const [key, stats] of this.#blockPolicyStats) {
|
|
24470
24702
|
if (stats.epoch !== this.#fec.epochFor(stats.packetId)) continue;
|
|
24471
|
-
out[key] = {
|
|
24703
|
+
out[key] = {
|
|
24704
|
+
...stats,
|
|
24705
|
+
lastRepairSkip: stats.lastRepairSkip === null ? null : { ...stats.lastRepairSkip }
|
|
24706
|
+
};
|
|
24472
24707
|
}
|
|
24473
24708
|
return out;
|
|
24474
24709
|
}
|
|
@@ -26359,6 +26594,10 @@ function repairFetchSubscriberPriority(blockClass, target) {
|
|
|
26359
26594
|
if (!isMoqtPriority(repair)) return { kind: "decline", reason: "repair-priority-invalid" };
|
|
26360
26595
|
return { kind: "carry", subscriberPriority: Math.max(repair, REPAIR_PRIORITY_MIN) };
|
|
26361
26596
|
}
|
|
26597
|
+
function keyframeBudgetEligible(blockClass, classifierMode) {
|
|
26598
|
+
if (blockClass === "keyframe") return true;
|
|
26599
|
+
return blockClass === "unknown" && classifierMode === "classifying";
|
|
26600
|
+
}
|
|
26362
26601
|
function wireRepairFetch(mc, opts) {
|
|
26363
26602
|
if (!Number.isSafeInteger(opts.attemptLimit) || opts.attemptLimit < 1) {
|
|
26364
26603
|
throw new Error(
|
|
@@ -26396,6 +26635,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
26396
26635
|
run.controller.abort();
|
|
26397
26636
|
if (reason === "preempted") releaseHold(entry);
|
|
26398
26637
|
};
|
|
26638
|
+
const readKeyframeBudget = (packetId, catalogTrackName) => {
|
|
26639
|
+
const reader = opts.keyframeRepairBudgetMs;
|
|
26640
|
+
if (reader === void 0) return null;
|
|
26641
|
+
try {
|
|
26642
|
+
const budgetMs = reader(packetId, catalogTrackName);
|
|
26643
|
+
return Number.isFinite(budgetMs) && budgetMs > 0 ? budgetMs : null;
|
|
26644
|
+
} catch {
|
|
26645
|
+
return null;
|
|
26646
|
+
}
|
|
26647
|
+
};
|
|
26399
26648
|
const readRtt = () => {
|
|
26400
26649
|
try {
|
|
26401
26650
|
const rtt = opts.reliableRttMs();
|
|
@@ -26413,7 +26662,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26413
26662
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26414
26663
|
mc.noteRepairSkipped(
|
|
26415
26664
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
26416
|
-
{ rttMs, budgetMs },
|
|
26665
|
+
{ rttMs, budgetMs, priority: entry.priority },
|
|
26417
26666
|
entry.sbn,
|
|
26418
26667
|
entry.packetId,
|
|
26419
26668
|
entry.catalogTrackName
|
|
@@ -26452,6 +26701,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26452
26701
|
const start = (entry, counted = true) => {
|
|
26453
26702
|
if (!admit(entry, performance.now())) return;
|
|
26454
26703
|
if (counted) entry.attempts++;
|
|
26704
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26455
26705
|
const run = { controller: new AbortController(), stopped: null };
|
|
26456
26706
|
entry.running = run;
|
|
26457
26707
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -26489,6 +26739,25 @@ function wireRepairFetch(mc, opts) {
|
|
|
26489
26739
|
if (urgentOutstanding()) return;
|
|
26490
26740
|
queued.filter((entry) => entry.priority === 2).sort((a, b) => a.deadlineAt - b.deadlineAt || a.order - b.order).forEach((entry) => start(entry));
|
|
26491
26741
|
};
|
|
26742
|
+
const symbolCounts = (sbn, packetId, catalogTrackName) => {
|
|
26743
|
+
try {
|
|
26744
|
+
return mc.fecManager.blockSymbolCounts?.(sbn, packetId, catalogTrackName);
|
|
26745
|
+
} catch {
|
|
26746
|
+
return void 0;
|
|
26747
|
+
}
|
|
26748
|
+
};
|
|
26749
|
+
const decodable = (entry) => {
|
|
26750
|
+
const counts = symbolCounts(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26751
|
+
if (counts === void 0 || counts.authoredLength === void 0) return true;
|
|
26752
|
+
return counts.sources + counts.repairs >= counts.authoredLength;
|
|
26753
|
+
};
|
|
26754
|
+
const groupCanComplete = (sbn, packetId, catalogTrackName) => {
|
|
26755
|
+
const counts = symbolCounts(sbn, packetId, catalogTrackName);
|
|
26756
|
+
if (counts === void 0 || counts.authoredLength === void 0 || counts.repairGroupLength === void 0) {
|
|
26757
|
+
return true;
|
|
26758
|
+
}
|
|
26759
|
+
return counts.sources + counts.repairGroupLength >= counts.authoredLength;
|
|
26760
|
+
};
|
|
26492
26761
|
const finish = (entry, run, fed, error) => {
|
|
26493
26762
|
if (run.stopped !== null || entry.running !== run || entries.get(entry.key) !== entry) {
|
|
26494
26763
|
return;
|
|
@@ -26496,7 +26765,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26496
26765
|
entry.running = null;
|
|
26497
26766
|
if (error === void 0) {
|
|
26498
26767
|
retire(entry);
|
|
26499
|
-
if (fed === 0) {
|
|
26768
|
+
if (fed === 0 || !decodable(entry)) {
|
|
26500
26769
|
releaseHold(entry);
|
|
26501
26770
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26502
26771
|
}
|
|
@@ -26570,6 +26839,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
26570
26839
|
if (wire === null) return;
|
|
26571
26840
|
entry2.priority = promoted;
|
|
26572
26841
|
entry2.subscriberPriority = wire.subscriberPriority;
|
|
26842
|
+
const promotedDeadline = presentationDeadlineAt(
|
|
26843
|
+
entry2.sbn,
|
|
26844
|
+
entry2.packetId,
|
|
26845
|
+
entry2.catalogTrackName,
|
|
26846
|
+
performance.now(),
|
|
26847
|
+
event.to
|
|
26848
|
+
);
|
|
26849
|
+
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26850
|
+
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
26851
|
+
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26852
|
+
}
|
|
26573
26853
|
if (entry2.running) {
|
|
26574
26854
|
stop(entry2, "reprioritized");
|
|
26575
26855
|
start(entry2, false);
|
|
@@ -26588,12 +26868,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
26588
26868
|
else if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
26589
26869
|
dispatch();
|
|
26590
26870
|
});
|
|
26591
|
-
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now) => {
|
|
26871
|
+
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now, blockClass) => {
|
|
26592
26872
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName);
|
|
26593
26873
|
if (waitMs === void 0) return null;
|
|
26594
26874
|
const waitDeadlineAt = now + waitMs;
|
|
26595
26875
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
26596
|
-
if (anchor === void 0) return waitDeadlineAt;
|
|
26876
|
+
if (anchor === void 0) return { deadlineAt: waitDeadlineAt, extensionMs: 0 };
|
|
26597
26877
|
let delayMs;
|
|
26598
26878
|
try {
|
|
26599
26879
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -26603,8 +26883,31 @@ function wireRepairFetch(mc, opts) {
|
|
|
26603
26883
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) return null;
|
|
26604
26884
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
26605
26885
|
if (retentionMs === void 0) return null;
|
|
26606
|
-
const ceilingAt = anchor + retentionMs;
|
|
26607
|
-
|
|
26886
|
+
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
26887
|
+
const deadlineAt = (delay) => Math.max(waitDeadlineAt, Math.min(anchor + delay, ceilingAt));
|
|
26888
|
+
const base = deadlineAt(delayMs);
|
|
26889
|
+
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
26890
|
+
if (budgetMs === null || budgetMs <= delayMs) return { deadlineAt: base, extensionMs: 0 };
|
|
26891
|
+
const extended = deadlineAt(budgetMs);
|
|
26892
|
+
return { deadlineAt: extended, extensionMs: extended - base };
|
|
26893
|
+
};
|
|
26894
|
+
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
26895
|
+
try {
|
|
26896
|
+
const at = mc.earliestGatedFrameAtMs?.(packetId, catalogTrackName);
|
|
26897
|
+
return at !== void 0 && Number.isFinite(at) ? at : void 0;
|
|
26898
|
+
} catch {
|
|
26899
|
+
return void 0;
|
|
26900
|
+
}
|
|
26901
|
+
};
|
|
26902
|
+
const classifierMode = (packetId, catalogTrackName) => {
|
|
26903
|
+
try {
|
|
26904
|
+
return mc.fecManager.classifierModeFor?.(packetId, catalogTrackName).mode;
|
|
26905
|
+
} catch {
|
|
26906
|
+
return void 0;
|
|
26907
|
+
}
|
|
26908
|
+
};
|
|
26909
|
+
const noteBudget = (entry, extensionMs) => {
|
|
26910
|
+
if (extensionMs > 0) mc.noteKeyframeBudgetGranted?.(extensionMs, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26608
26911
|
};
|
|
26609
26912
|
mc.onRepairSubscribe((sbn, packetId, catalogTrackName, blockClass) => {
|
|
26610
26913
|
if (disposed) {
|
|
@@ -26642,12 +26945,13 @@ function wireRepairFetch(mc, opts) {
|
|
|
26642
26945
|
return;
|
|
26643
26946
|
}
|
|
26644
26947
|
const now = performance.now();
|
|
26645
|
-
const
|
|
26646
|
-
|
|
26948
|
+
const priority = repairPriorityForClass(blockClass);
|
|
26949
|
+
const deadline = presentationDeadlineAt(sbn, packetId, catalogTrackName, now, blockClass);
|
|
26950
|
+
if (deadline === null) {
|
|
26647
26951
|
clearRepair(sbn, packetId, catalogTrackName);
|
|
26648
26952
|
mc.noteRepairSkipped(
|
|
26649
26953
|
"presentation-delay-unavailable",
|
|
26650
|
-
{ rttMs: readRtt(), budgetMs: 0 },
|
|
26954
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
26651
26955
|
sbn,
|
|
26652
26956
|
packetId,
|
|
26653
26957
|
catalogTrackName
|
|
@@ -26659,14 +26963,15 @@ function wireRepairFetch(mc, opts) {
|
|
|
26659
26963
|
...identity,
|
|
26660
26964
|
repairTrack: target.repairTrack,
|
|
26661
26965
|
blockProfile,
|
|
26662
|
-
priority
|
|
26966
|
+
priority,
|
|
26663
26967
|
subscriberPriority: wire.subscriberPriority,
|
|
26664
|
-
deadlineAt,
|
|
26968
|
+
deadlineAt: deadline.deadlineAt,
|
|
26665
26969
|
order: enqueueOrder++,
|
|
26666
26970
|
attempts: 0,
|
|
26667
26971
|
running: null
|
|
26668
26972
|
};
|
|
26669
26973
|
entries.set(key, entry);
|
|
26974
|
+
noteBudget(entry, deadline.extensionMs);
|
|
26670
26975
|
if (entry.priority < 2) preemptDeltas();
|
|
26671
26976
|
dispatch();
|
|
26672
26977
|
});
|
|
@@ -26751,6 +27056,8 @@ export {
|
|
|
26751
27056
|
buildVideoInitSegment,
|
|
26752
27057
|
catalogAmtNetworkSource,
|
|
26753
27058
|
catalogDeclaresFec,
|
|
27059
|
+
catalogFecAvailable,
|
|
27060
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
26754
27061
|
catalogFecInterleaveMs,
|
|
26755
27062
|
catalogFecMediaUnitsPerSecond,
|
|
26756
27063
|
catalogFecUnavailable,
|
|
@@ -26825,6 +27132,7 @@ export {
|
|
|
26825
27132
|
isTrackTimingConfig,
|
|
26826
27133
|
joinedRepairSymbolCount,
|
|
26827
27134
|
keyframeIntervalMediaTicks,
|
|
27135
|
+
locateCatalogFecSource,
|
|
26828
27136
|
mergeOverrideIntoCmsfTracks,
|
|
26829
27137
|
mergeOverrideIntoHangRenditions,
|
|
26830
27138
|
mfuReassemblyTimeoutMs,
|