@blockcast/mmt-container 0.4.0-main.71d61b2a53f2 → 0.4.0-main.81e28ca1c5f5
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 +267 -26
- package/dist/browser-runtime.js.map +2 -2
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +3 -0
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.js.map +1 -1
- package/dist/delivery-catalog.js +4 -0
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/fec-manager.d.ts +16 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +35 -0
- package/dist/fec-manager.js.map +2 -2
- 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 +70 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +76 -3
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-decode-pipeline.js +70 -2
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +32 -3
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +104 -13
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +38 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +183 -15
- package/dist/multicast-manager.js.map +2 -2
- package/dist/multicast-transport.js +4 -0
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +73 -2
- package/dist/no-modules.js.map +2 -2
- package/dist/repair-fetch.d.ts +86 -2
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +82 -11
- package/dist/repair-fetch.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +70 -2
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/carp-catalog.ts +5 -0
- package/src/fec-manager.ts +43 -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
|
@@ -6718,6 +6718,9 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6718
6718
|
catalogError("track_fec", `${path}.fec.${field}`, "must be a positive integer");
|
|
6719
6719
|
}
|
|
6720
6720
|
}
|
|
6721
|
+
if (algorithm === "raptorq" && config["symbolSize"] % 8 !== 0) {
|
|
6722
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "RaptorQ symbolSize must be a multiple of 8");
|
|
6723
|
+
}
|
|
6721
6724
|
if (typeof config["repairTrack"] !== "string" || config["repairTrack"].length === 0) {
|
|
6722
6725
|
catalogError("track_fec", `${path}.fec.repairTrack`, "must be a non-empty string");
|
|
6723
6726
|
}
|
|
@@ -8125,6 +8128,10 @@ var TransportManager = class {
|
|
|
8125
8128
|
pollMulticastTierSwitch() {
|
|
8126
8129
|
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
|
|
8127
8130
|
}
|
|
8131
|
+
/** Abandon the in-flight tier join, e.g. because the host could not join the target. */
|
|
8132
|
+
cancelMulticastTierJoin() {
|
|
8133
|
+
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
|
|
8134
|
+
}
|
|
8128
8135
|
/**
|
|
8129
8136
|
* Set packet callback
|
|
8130
8137
|
*/
|
|
@@ -13185,6 +13192,9 @@ var FECManager = class _FECManager {
|
|
|
13185
13192
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
13186
13193
|
this.#ssbLengthConflictCount = 0;
|
|
13187
13194
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
13195
|
+
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
13196
|
+
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
13197
|
+
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
13188
13198
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
13189
13199
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
13190
13200
|
// which would falsely start new timeouts without this guard.
|
|
@@ -13425,6 +13435,7 @@ var FECManager = class _FECManager {
|
|
|
13425
13435
|
#blockAuthoredLengths;
|
|
13426
13436
|
#ssbLengthConflictCount;
|
|
13427
13437
|
#blockRepairRsIds;
|
|
13438
|
+
#blockRsbLengths;
|
|
13428
13439
|
#completedBlocks;
|
|
13429
13440
|
#terminalExpiryMs;
|
|
13430
13441
|
#terminalQueues;
|
|
@@ -14696,6 +14707,7 @@ var FECManager = class _FECManager {
|
|
|
14696
14707
|
resetMap(this.#blockSourceEsis);
|
|
14697
14708
|
resetMap(this.#blockAuthoredLengths);
|
|
14698
14709
|
resetMap(this.#blockRepairRsIds);
|
|
14710
|
+
resetMap(this.#blockRsbLengths);
|
|
14699
14711
|
resetMap(this.#blockPathCounts);
|
|
14700
14712
|
resetMap(this.#blockAnchorsMs);
|
|
14701
14713
|
resetMap(this.#blockCatalogTrackNames);
|
|
@@ -14813,6 +14825,7 @@ var FECManager = class _FECManager {
|
|
|
14813
14825
|
dropMap(this.#blockSourceEsis);
|
|
14814
14826
|
dropMap(this.#blockAuthoredLengths);
|
|
14815
14827
|
dropMap(this.#blockRepairRsIds);
|
|
14828
|
+
dropMap(this.#blockRsbLengths);
|
|
14816
14829
|
dropMap(this.#blockPathCounts);
|
|
14817
14830
|
dropMap(this.#blockAnchorsMs);
|
|
14818
14831
|
dropMap(this.#blockCatalogTrackNames);
|
|
@@ -15067,6 +15080,31 @@ var FECManager = class _FECManager {
|
|
|
15067
15080
|
windowMs: this.#deliveryGaps.windowMs
|
|
15068
15081
|
};
|
|
15069
15082
|
}
|
|
15083
|
+
/**
|
|
15084
|
+
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
15085
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it).
|
|
15086
|
+
* Undefined for a block that is not open.
|
|
15087
|
+
*/
|
|
15088
|
+
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
15089
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15090
|
+
if (!this.#activeBlocks.has(key)) return void 0;
|
|
15091
|
+
return {
|
|
15092
|
+
sources: this.#blockSourceCounts.get(key) ?? 0,
|
|
15093
|
+
repairs: this.#blockRepairRsIds.get(key)?.size ?? 0,
|
|
15094
|
+
authoredLength: this.#blockAuthoredLengths.get(key),
|
|
15095
|
+
repairGroupLength: this.#blockRsbLengths.get(key)
|
|
15096
|
+
};
|
|
15097
|
+
}
|
|
15098
|
+
/**
|
|
15099
|
+
* Record a block's RSB_length from one of its repair symbols (the router
|
|
15100
|
+
* parses it from the Repair FEC Payload ID). The largest stated value wins.
|
|
15101
|
+
*/
|
|
15102
|
+
noteRepairGroupLength(sbn, packetId, rsbLength, catalogTrackName) {
|
|
15103
|
+
if (!Number.isSafeInteger(rsbLength) || rsbLength <= 0) return;
|
|
15104
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15105
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
15106
|
+
if ((this.#blockRsbLengths.get(key) ?? 0) < rsbLength) this.#blockRsbLengths.set(key, rsbLength);
|
|
15107
|
+
}
|
|
15070
15108
|
/**
|
|
15071
15109
|
* Receiver-local time of a block's first accepted symbol, or undefined for
|
|
15072
15110
|
* a block no symbol reached (one materialized because a later SBN arrived).
|
|
@@ -16006,6 +16044,7 @@ var FECManager = class _FECManager {
|
|
|
16006
16044
|
this.#blockSourceEsis.delete(key);
|
|
16007
16045
|
this.#blockAuthoredLengths.delete(key);
|
|
16008
16046
|
this.#blockRepairRsIds.delete(key);
|
|
16047
|
+
this.#blockRsbLengths.delete(key);
|
|
16009
16048
|
this.#markTerminal(key, sbn, packetId, true);
|
|
16010
16049
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
16011
16050
|
if (catalogTrackName === void 0) {
|
|
@@ -16057,6 +16096,7 @@ var FECManager = class _FECManager {
|
|
|
16057
16096
|
this.#blockSourceEsis.delete(key);
|
|
16058
16097
|
this.#blockAuthoredLengths.delete(key);
|
|
16059
16098
|
this.#blockRepairRsIds.delete(key);
|
|
16099
|
+
this.#blockRsbLengths.delete(key);
|
|
16060
16100
|
this.#syncDecoderBlockOwners.delete(key);
|
|
16061
16101
|
this.#markTerminal(key, sbn, packetId, false);
|
|
16062
16102
|
this.#failedBlocks.add(key);
|
|
@@ -16094,6 +16134,7 @@ var FECManager = class _FECManager {
|
|
|
16094
16134
|
this.#blockSourceEsis.delete(key);
|
|
16095
16135
|
this.#blockAuthoredLengths.delete(key);
|
|
16096
16136
|
this.#blockRepairRsIds.delete(key);
|
|
16137
|
+
this.#blockRsbLengths.delete(key);
|
|
16097
16138
|
this.#clearBlockTimer(key);
|
|
16098
16139
|
this.onBlockResolved?.(block.sbn, block.packetId, block.catalogTrackName);
|
|
16099
16140
|
}
|
|
@@ -16184,6 +16225,7 @@ var FECManager = class _FECManager {
|
|
|
16184
16225
|
this.#blockSourceEsis.clear();
|
|
16185
16226
|
this.#blockAuthoredLengths.clear();
|
|
16186
16227
|
this.#blockRepairRsIds.clear();
|
|
16228
|
+
this.#blockRsbLengths.clear();
|
|
16187
16229
|
this.#completedBlocks.clear();
|
|
16188
16230
|
this.#cleanlyCompletedBlocks.clear();
|
|
16189
16231
|
this.#repairRequestedBlocks.clear();
|
|
@@ -17055,6 +17097,42 @@ var FecReleaseSequencer = class {
|
|
|
17055
17097
|
for (const stream of this.#streams.values()) total += stream.buf.length;
|
|
17056
17098
|
return total;
|
|
17057
17099
|
}
|
|
17100
|
+
#deferDepth = 0;
|
|
17101
|
+
#deferredStreams = /* @__PURE__ */ new Set();
|
|
17102
|
+
/**
|
|
17103
|
+
* Run `work` with the drains its pushes would run deferred to its end. A
|
|
17104
|
+
* recovered FEC block is routed one frame at a time, and its block is
|
|
17105
|
+
* already resolved when the first frame is pushed: draining on that push
|
|
17106
|
+
* would release past the gap before the block's other recovered frames
|
|
17107
|
+
* arrive (deciding a conceal or stall for media that is about to land),
|
|
17108
|
+
* and those frames would then be dropped as stale. Nests.
|
|
17109
|
+
*/
|
|
17110
|
+
defer(work) {
|
|
17111
|
+
this.#deferDepth++;
|
|
17112
|
+
let threw = true;
|
|
17113
|
+
try {
|
|
17114
|
+
work();
|
|
17115
|
+
threw = false;
|
|
17116
|
+
} finally {
|
|
17117
|
+
this.#deferDepth--;
|
|
17118
|
+
if (this.#deferDepth === 0 && this.#deferredStreams.size > 0) {
|
|
17119
|
+
const streams = [...this.#deferredStreams];
|
|
17120
|
+
this.#deferredStreams.clear();
|
|
17121
|
+
if (!threw) {
|
|
17122
|
+
for (const stream of streams) this.#drain(stream);
|
|
17123
|
+
} else {
|
|
17124
|
+
try {
|
|
17125
|
+
for (const stream of streams) this.#drain(stream);
|
|
17126
|
+
} catch {
|
|
17127
|
+
}
|
|
17128
|
+
}
|
|
17129
|
+
}
|
|
17130
|
+
}
|
|
17131
|
+
}
|
|
17132
|
+
#drainUnlessDeferred(stream) {
|
|
17133
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
17134
|
+
else this.#drain(stream);
|
|
17135
|
+
}
|
|
17058
17136
|
push(streamKey, data, meta, seq) {
|
|
17059
17137
|
const frame = { data, meta: { ...meta }, seq, arrivedAtMs: performance.now() };
|
|
17060
17138
|
const stream = this.#streamFor(streamKey, meta);
|
|
@@ -17076,7 +17154,7 @@ var FecReleaseSequencer = class {
|
|
|
17076
17154
|
return;
|
|
17077
17155
|
}
|
|
17078
17156
|
this.#release(stream, frame, void 0);
|
|
17079
|
-
this.#
|
|
17157
|
+
this.#drainUnlessDeferred(stream);
|
|
17080
17158
|
return;
|
|
17081
17159
|
}
|
|
17082
17160
|
let lo = 0;
|
|
@@ -17087,7 +17165,23 @@ var FecReleaseSequencer = class {
|
|
|
17087
17165
|
else hi = mid;
|
|
17088
17166
|
}
|
|
17089
17167
|
stream.buf.splice(lo, 0, frame);
|
|
17090
|
-
this.#
|
|
17168
|
+
this.#drainUnlessDeferred(stream);
|
|
17169
|
+
}
|
|
17170
|
+
/**
|
|
17171
|
+
* Arrival time of the earliest frame a stream of `packetId` holds behind a
|
|
17172
|
+
* gap (the gate forces it out `holdLimitMs` after that), or undefined when
|
|
17173
|
+
* none is held. Without `catalogTrackName`, every stream of the packetId.
|
|
17174
|
+
*/
|
|
17175
|
+
earliestHeldArrivalMs(packetId, catalogTrackName) {
|
|
17176
|
+
let earliest;
|
|
17177
|
+
for (const stream of this.#streams.values()) {
|
|
17178
|
+
if (stream.packetId !== packetId) continue;
|
|
17179
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
17180
|
+
for (const frame of stream.buf) {
|
|
17181
|
+
if (earliest === void 0 || frame.arrivedAtMs < earliest) earliest = frame.arrivedAtMs;
|
|
17182
|
+
}
|
|
17183
|
+
}
|
|
17184
|
+
return earliest;
|
|
17091
17185
|
}
|
|
17092
17186
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
17093
17187
|
poke(streamKey) {
|
|
@@ -17523,6 +17617,22 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17523
17617
|
}
|
|
17524
17618
|
) : null;
|
|
17525
17619
|
}
|
|
17620
|
+
/**
|
|
17621
|
+
* Run `work` with the FEC release gate's drains deferred to its end, so
|
|
17622
|
+
* every frame it pushes is in place before any held gap is decided (see
|
|
17623
|
+
* FecReleaseSequencer.defer).
|
|
17624
|
+
*/
|
|
17625
|
+
deferFecRelease(work) {
|
|
17626
|
+
if (!this.#fecSequencer) {
|
|
17627
|
+
work();
|
|
17628
|
+
return;
|
|
17629
|
+
}
|
|
17630
|
+
this.#fecSequencer.defer(work);
|
|
17631
|
+
}
|
|
17632
|
+
/** See FecReleaseSequencer.earliestHeldArrivalMs. */
|
|
17633
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
17634
|
+
return this.#fecSequencer?.earliestHeldArrivalMs(packetId, catalogTrackName);
|
|
17635
|
+
}
|
|
17526
17636
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
17527
17637
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
17528
17638
|
if (!this.#fecSequencer) return;
|
|
@@ -18860,6 +18970,8 @@ var MmtpRouter = class {
|
|
|
18860
18970
|
// ── Keyframe loss detection state ───────────────────────────────
|
|
18861
18971
|
/** 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
18972
|
#keyframeLostTimeoutMs;
|
|
18973
|
+
/** packetIds already warned for running without Phase 13 (non-FEC video only). */
|
|
18974
|
+
#warnedNoKeyframeLostTimeout = /* @__PURE__ */ new Set();
|
|
18863
18975
|
/** Why the last reader evaluation left the timer unarmed; null while arming. Dedups the warning. */
|
|
18864
18976
|
#keyframeLostUnarmedReason = null;
|
|
18865
18977
|
/** Active keyframe loss timer handle. Single timer per video track — cleared on each rapFlag and on dispose(). */
|
|
@@ -19189,15 +19301,14 @@ var MmtpRouter = class {
|
|
|
19189
19301
|
}
|
|
19190
19302
|
/** Register MMTP packetId → track type mapping.
|
|
19191
19303
|
* Call BEFORE packets arrive to ensure correct routing from the first packet.
|
|
19192
|
-
*
|
|
19193
|
-
*
|
|
19194
|
-
*
|
|
19304
|
+
* Without keyframeLostTimeoutMs a track WITHOUT FEC has no Phase 13
|
|
19305
|
+
* keyframe repair (video still routes/decodes normally); that is warned at
|
|
19306
|
+
* its first keyframe, once the FEC configuration is known (see
|
|
19307
|
+
* #noteEmittedKeyframe). Nothing is warned here: an FEC track never uses
|
|
19308
|
+
* the timer, and at registration the FEC configuration may not be applied
|
|
19309
|
+
* yet. framerate is OPTIONAL per draft-ietf-moq-catalogformat-01 §3.2.23,
|
|
19310
|
+
* so we can't require the timeout. */
|
|
19195
19311
|
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
19312
|
if (trackType === "video") this.#videoPacketIds.add(packetId);
|
|
19202
19313
|
else this.#audioPacketIds.add(packetId);
|
|
19203
19314
|
const codec = this.#trackCodecs.get(packetId) ?? "";
|
|
@@ -19628,6 +19739,7 @@ var MmtpRouter = class {
|
|
|
19628
19739
|
catalogTrackName
|
|
19629
19740
|
)) return;
|
|
19630
19741
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
19742
|
+
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
19631
19743
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
19632
19744
|
const recovered = fec.feedRepairSymbol(
|
|
19633
19745
|
ownerPacketId,
|
|
@@ -19697,7 +19809,7 @@ var MmtpRouter = class {
|
|
|
19697
19809
|
* Sync WASM decoders return the block's K' = SSB_length fixed-width
|
|
19698
19810
|
* ssbg_mode1 source symbols concatenated. */
|
|
19699
19811
|
routeRecoveredBlock(blockId, data, packetId, catalogTrackName) {
|
|
19700
|
-
this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
19812
|
+
this.#withDeferredFecPokes(() => this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName));
|
|
19701
19813
|
}
|
|
19702
19814
|
/** Route a single recovered source symbol through the parser + dedup pipeline.
|
|
19703
19815
|
* Worker-backed decoders emit one padded source symbol per frame event. */
|
|
@@ -20111,8 +20223,16 @@ var MmtpRouter = class {
|
|
|
20111
20223
|
#noteEmittedKeyframe(packetId, keyframe) {
|
|
20112
20224
|
if (!keyframe) return;
|
|
20113
20225
|
if (!this.#videoPacketIds.has(packetId)) return;
|
|
20114
|
-
if (this.#keyframeLostTimeoutMs === null) return;
|
|
20115
20226
|
if (this.#isFecTrack(packetId)) return;
|
|
20227
|
+
if (this.#keyframeLostTimeoutMs === null) {
|
|
20228
|
+
if (!this.#warnedNoKeyframeLostTimeout.has(packetId)) {
|
|
20229
|
+
this.#warnedNoKeyframeLostTimeout.add(packetId);
|
|
20230
|
+
console.warn(
|
|
20231
|
+
`[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.`
|
|
20232
|
+
);
|
|
20233
|
+
}
|
|
20234
|
+
return;
|
|
20235
|
+
}
|
|
20116
20236
|
this.#lastKeyframeGroupId++;
|
|
20117
20237
|
this.#armKeyframeLostTimer();
|
|
20118
20238
|
}
|
|
@@ -20124,7 +20244,7 @@ var MmtpRouter = class {
|
|
|
20124
20244
|
#withDeferredFecPokes(work) {
|
|
20125
20245
|
this.#fecPokeDepth++;
|
|
20126
20246
|
try {
|
|
20127
|
-
work
|
|
20247
|
+
this.#parser.deferFecRelease(work);
|
|
20128
20248
|
} finally {
|
|
20129
20249
|
this.#fecPokeDepth--;
|
|
20130
20250
|
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
@@ -20136,6 +20256,13 @@ var MmtpRouter = class {
|
|
|
20136
20256
|
}
|
|
20137
20257
|
}
|
|
20138
20258
|
}
|
|
20259
|
+
/**
|
|
20260
|
+
* Arrival time of the earliest frame the FEC release gate holds for this
|
|
20261
|
+
* stream (see FecReleaseSequencer.earliestHeldArrivalMs), or undefined.
|
|
20262
|
+
*/
|
|
20263
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
20264
|
+
return this.#parser.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
20265
|
+
}
|
|
20139
20266
|
#requestFecPoke(packetId, catalogTrackName) {
|
|
20140
20267
|
if (this.#disposed) return;
|
|
20141
20268
|
if (this.#fecPokeDepth > 0) {
|
|
@@ -20504,6 +20631,8 @@ var MmtpRouter = class {
|
|
|
20504
20631
|
catalogTrackName
|
|
20505
20632
|
);
|
|
20506
20633
|
this.#routeTrackPacket(packet, info.packetId, info.sequenceNumber, {
|
|
20634
|
+
mmtpTimestamp: parsed.header.timestamp,
|
|
20635
|
+
rap: info.rapFlag,
|
|
20507
20636
|
recovered: false,
|
|
20508
20637
|
skipFecPayloadId: false,
|
|
20509
20638
|
catalogTrackName
|
|
@@ -20691,6 +20820,8 @@ var MmtpRouter = class {
|
|
|
20691
20820
|
callback(packet, {
|
|
20692
20821
|
packetId,
|
|
20693
20822
|
packetSequenceNumber,
|
|
20823
|
+
mmtpTimestamp: meta.mmtpTimestamp,
|
|
20824
|
+
rap: meta.rap,
|
|
20694
20825
|
recovered: meta.recovered,
|
|
20695
20826
|
skipFecPayloadId: meta.skipFecPayloadId,
|
|
20696
20827
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName },
|
|
@@ -21074,6 +21205,8 @@ var MmtpRouter = class {
|
|
|
21074
21205
|
) ?? "unknown";
|
|
21075
21206
|
for (const sym of result.symbols) {
|
|
21076
21207
|
this.#routeTrackPacket(sym.rawSymbol, ownerPacketId, sym.packetSequenceNumber, {
|
|
21208
|
+
mmtpTimestamp: sym.fragment.timestamp,
|
|
21209
|
+
rap: sym.fragment.rapFlag,
|
|
21077
21210
|
recovered: true,
|
|
21078
21211
|
skipFecPayloadId: true,
|
|
21079
21212
|
catalogTrackName,
|
|
@@ -22929,6 +23062,13 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
22929
23062
|
deltaRepairsPreempted: 0,
|
|
22930
23063
|
deltaRepairsDeferred: 0,
|
|
22931
23064
|
repairsSkipped: 0,
|
|
23065
|
+
repairsSkippedRttUnmeasured: 0,
|
|
23066
|
+
repairsSkippedRttExceedsBudget: 0,
|
|
23067
|
+
repairsSkippedPresentationDelayUnavailable: 0,
|
|
23068
|
+
lastRepairSkip: null,
|
|
23069
|
+
keyframeRepairFetchesSent: 0,
|
|
23070
|
+
keyframeBudgetHolds: 0,
|
|
23071
|
+
keyframeBudgetHoldMs: 0,
|
|
22932
23072
|
deltaBlocksFailed: 0,
|
|
22933
23073
|
audioBlocksRecoveredInband: 0,
|
|
22934
23074
|
audioBlocksRecoveredQuic: 0,
|
|
@@ -24431,7 +24571,17 @@ var MulticastManager = class {
|
|
|
24431
24571
|
}
|
|
24432
24572
|
/** Record a repair request the scheduler sent no FETCH for. */
|
|
24433
24573
|
noteRepairSkipped(reason, measurement, sbn, packetId, catalogTrackName) {
|
|
24434
|
-
this.#statsFor(packetId, catalogTrackName)
|
|
24574
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24575
|
+
stats.repairsSkipped++;
|
|
24576
|
+
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
24577
|
+
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
24578
|
+
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
24579
|
+
stats.lastRepairSkip = {
|
|
24580
|
+
reason,
|
|
24581
|
+
rttMs: measurement.rttMs,
|
|
24582
|
+
budgetMs: measurement.budgetMs,
|
|
24583
|
+
priority: measurement.priority ?? null
|
|
24584
|
+
};
|
|
24435
24585
|
this.#emitRepairLifecycle({
|
|
24436
24586
|
version: 2,
|
|
24437
24587
|
type: "repair-skipped",
|
|
@@ -24441,6 +24591,24 @@ var MulticastManager = class {
|
|
|
24441
24591
|
budgetMs: measurement.budgetMs
|
|
24442
24592
|
});
|
|
24443
24593
|
}
|
|
24594
|
+
/**
|
|
24595
|
+
* Arrival time of the earliest frame the in-order release gate holds for
|
|
24596
|
+
* the stream: the gate releases it as a discontinuity once
|
|
24597
|
+
* `terminalRetentionMsForPacket` has passed since then.
|
|
24598
|
+
*/
|
|
24599
|
+
earliestGatedFrameAtMs(packetId, catalogTrackName) {
|
|
24600
|
+
return this.#router.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
24601
|
+
}
|
|
24602
|
+
/** Record a keyframe late-repair budget the scheduler granted a block. */
|
|
24603
|
+
noteKeyframeBudgetGranted(extensionMs, _sbn, packetId, catalogTrackName) {
|
|
24604
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24605
|
+
stats.keyframeBudgetHolds++;
|
|
24606
|
+
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24607
|
+
}
|
|
24608
|
+
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24609
|
+
noteRepairFetchSent(priority, _sbn, packetId, catalogTrackName) {
|
|
24610
|
+
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
24611
|
+
}
|
|
24444
24612
|
/**
|
|
24445
24613
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
24446
24614
|
* keyframe/audio work, or never dispatched before its block resolved.
|
|
@@ -24468,7 +24636,10 @@ var MulticastManager = class {
|
|
|
24468
24636
|
const out = {};
|
|
24469
24637
|
for (const [key, stats] of this.#blockPolicyStats) {
|
|
24470
24638
|
if (stats.epoch !== this.#fec.epochFor(stats.packetId)) continue;
|
|
24471
|
-
out[key] = {
|
|
24639
|
+
out[key] = {
|
|
24640
|
+
...stats,
|
|
24641
|
+
lastRepairSkip: stats.lastRepairSkip === null ? null : { ...stats.lastRepairSkip }
|
|
24642
|
+
};
|
|
24472
24643
|
}
|
|
24473
24644
|
return out;
|
|
24474
24645
|
}
|
|
@@ -26359,6 +26530,10 @@ function repairFetchSubscriberPriority(blockClass, target) {
|
|
|
26359
26530
|
if (!isMoqtPriority(repair)) return { kind: "decline", reason: "repair-priority-invalid" };
|
|
26360
26531
|
return { kind: "carry", subscriberPriority: Math.max(repair, REPAIR_PRIORITY_MIN) };
|
|
26361
26532
|
}
|
|
26533
|
+
function keyframeBudgetEligible(blockClass, classifierMode) {
|
|
26534
|
+
if (blockClass === "keyframe") return true;
|
|
26535
|
+
return blockClass === "unknown" && classifierMode === "classifying";
|
|
26536
|
+
}
|
|
26362
26537
|
function wireRepairFetch(mc, opts) {
|
|
26363
26538
|
if (!Number.isSafeInteger(opts.attemptLimit) || opts.attemptLimit < 1) {
|
|
26364
26539
|
throw new Error(
|
|
@@ -26396,6 +26571,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
26396
26571
|
run.controller.abort();
|
|
26397
26572
|
if (reason === "preempted") releaseHold(entry);
|
|
26398
26573
|
};
|
|
26574
|
+
const readKeyframeBudget = (packetId, catalogTrackName) => {
|
|
26575
|
+
const reader = opts.keyframeRepairBudgetMs;
|
|
26576
|
+
if (reader === void 0) return null;
|
|
26577
|
+
try {
|
|
26578
|
+
const budgetMs = reader(packetId, catalogTrackName);
|
|
26579
|
+
return Number.isFinite(budgetMs) && budgetMs > 0 ? budgetMs : null;
|
|
26580
|
+
} catch {
|
|
26581
|
+
return null;
|
|
26582
|
+
}
|
|
26583
|
+
};
|
|
26399
26584
|
const readRtt = () => {
|
|
26400
26585
|
try {
|
|
26401
26586
|
const rtt = opts.reliableRttMs();
|
|
@@ -26413,7 +26598,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26413
26598
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26414
26599
|
mc.noteRepairSkipped(
|
|
26415
26600
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
26416
|
-
{ rttMs, budgetMs },
|
|
26601
|
+
{ rttMs, budgetMs, priority: entry.priority },
|
|
26417
26602
|
entry.sbn,
|
|
26418
26603
|
entry.packetId,
|
|
26419
26604
|
entry.catalogTrackName
|
|
@@ -26452,6 +26637,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26452
26637
|
const start = (entry, counted = true) => {
|
|
26453
26638
|
if (!admit(entry, performance.now())) return;
|
|
26454
26639
|
if (counted) entry.attempts++;
|
|
26640
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26455
26641
|
const run = { controller: new AbortController(), stopped: null };
|
|
26456
26642
|
entry.running = run;
|
|
26457
26643
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -26489,6 +26675,25 @@ function wireRepairFetch(mc, opts) {
|
|
|
26489
26675
|
if (urgentOutstanding()) return;
|
|
26490
26676
|
queued.filter((entry) => entry.priority === 2).sort((a, b) => a.deadlineAt - b.deadlineAt || a.order - b.order).forEach((entry) => start(entry));
|
|
26491
26677
|
};
|
|
26678
|
+
const symbolCounts = (sbn, packetId, catalogTrackName) => {
|
|
26679
|
+
try {
|
|
26680
|
+
return mc.fecManager.blockSymbolCounts?.(sbn, packetId, catalogTrackName);
|
|
26681
|
+
} catch {
|
|
26682
|
+
return void 0;
|
|
26683
|
+
}
|
|
26684
|
+
};
|
|
26685
|
+
const decodable = (entry) => {
|
|
26686
|
+
const counts = symbolCounts(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26687
|
+
if (counts === void 0 || counts.authoredLength === void 0) return true;
|
|
26688
|
+
return counts.sources + counts.repairs >= counts.authoredLength;
|
|
26689
|
+
};
|
|
26690
|
+
const groupCanComplete = (sbn, packetId, catalogTrackName) => {
|
|
26691
|
+
const counts = symbolCounts(sbn, packetId, catalogTrackName);
|
|
26692
|
+
if (counts === void 0 || counts.authoredLength === void 0 || counts.repairGroupLength === void 0) {
|
|
26693
|
+
return true;
|
|
26694
|
+
}
|
|
26695
|
+
return counts.sources + counts.repairGroupLength >= counts.authoredLength;
|
|
26696
|
+
};
|
|
26492
26697
|
const finish = (entry, run, fed, error) => {
|
|
26493
26698
|
if (run.stopped !== null || entry.running !== run || entries.get(entry.key) !== entry) {
|
|
26494
26699
|
return;
|
|
@@ -26496,7 +26701,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26496
26701
|
entry.running = null;
|
|
26497
26702
|
if (error === void 0) {
|
|
26498
26703
|
retire(entry);
|
|
26499
|
-
if (fed === 0) {
|
|
26704
|
+
if (fed === 0 || !decodable(entry)) {
|
|
26500
26705
|
releaseHold(entry);
|
|
26501
26706
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26502
26707
|
}
|
|
@@ -26570,6 +26775,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
26570
26775
|
if (wire === null) return;
|
|
26571
26776
|
entry2.priority = promoted;
|
|
26572
26777
|
entry2.subscriberPriority = wire.subscriberPriority;
|
|
26778
|
+
const promotedDeadline = presentationDeadlineAt(
|
|
26779
|
+
entry2.sbn,
|
|
26780
|
+
entry2.packetId,
|
|
26781
|
+
entry2.catalogTrackName,
|
|
26782
|
+
performance.now(),
|
|
26783
|
+
event.to
|
|
26784
|
+
);
|
|
26785
|
+
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26786
|
+
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
26787
|
+
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26788
|
+
}
|
|
26573
26789
|
if (entry2.running) {
|
|
26574
26790
|
stop(entry2, "reprioritized");
|
|
26575
26791
|
start(entry2, false);
|
|
@@ -26588,12 +26804,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
26588
26804
|
else if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
26589
26805
|
dispatch();
|
|
26590
26806
|
});
|
|
26591
|
-
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now) => {
|
|
26807
|
+
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now, blockClass) => {
|
|
26592
26808
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName);
|
|
26593
26809
|
if (waitMs === void 0) return null;
|
|
26594
26810
|
const waitDeadlineAt = now + waitMs;
|
|
26595
26811
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
26596
|
-
if (anchor === void 0) return waitDeadlineAt;
|
|
26812
|
+
if (anchor === void 0) return { deadlineAt: waitDeadlineAt, extensionMs: 0 };
|
|
26597
26813
|
let delayMs;
|
|
26598
26814
|
try {
|
|
26599
26815
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -26603,8 +26819,31 @@ function wireRepairFetch(mc, opts) {
|
|
|
26603
26819
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) return null;
|
|
26604
26820
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
26605
26821
|
if (retentionMs === void 0) return null;
|
|
26606
|
-
const ceilingAt = anchor + retentionMs;
|
|
26607
|
-
|
|
26822
|
+
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
26823
|
+
const deadlineAt = (delay) => Math.max(waitDeadlineAt, Math.min(anchor + delay, ceilingAt));
|
|
26824
|
+
const base = deadlineAt(delayMs);
|
|
26825
|
+
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
26826
|
+
if (budgetMs === null || budgetMs <= delayMs) return { deadlineAt: base, extensionMs: 0 };
|
|
26827
|
+
const extended = deadlineAt(budgetMs);
|
|
26828
|
+
return { deadlineAt: extended, extensionMs: extended - base };
|
|
26829
|
+
};
|
|
26830
|
+
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
26831
|
+
try {
|
|
26832
|
+
const at = mc.earliestGatedFrameAtMs?.(packetId, catalogTrackName);
|
|
26833
|
+
return at !== void 0 && Number.isFinite(at) ? at : void 0;
|
|
26834
|
+
} catch {
|
|
26835
|
+
return void 0;
|
|
26836
|
+
}
|
|
26837
|
+
};
|
|
26838
|
+
const classifierMode = (packetId, catalogTrackName) => {
|
|
26839
|
+
try {
|
|
26840
|
+
return mc.fecManager.classifierModeFor?.(packetId, catalogTrackName).mode;
|
|
26841
|
+
} catch {
|
|
26842
|
+
return void 0;
|
|
26843
|
+
}
|
|
26844
|
+
};
|
|
26845
|
+
const noteBudget = (entry, extensionMs) => {
|
|
26846
|
+
if (extensionMs > 0) mc.noteKeyframeBudgetGranted?.(extensionMs, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26608
26847
|
};
|
|
26609
26848
|
mc.onRepairSubscribe((sbn, packetId, catalogTrackName, blockClass) => {
|
|
26610
26849
|
if (disposed) {
|
|
@@ -26642,12 +26881,13 @@ function wireRepairFetch(mc, opts) {
|
|
|
26642
26881
|
return;
|
|
26643
26882
|
}
|
|
26644
26883
|
const now = performance.now();
|
|
26645
|
-
const
|
|
26646
|
-
|
|
26884
|
+
const priority = repairPriorityForClass(blockClass);
|
|
26885
|
+
const deadline = presentationDeadlineAt(sbn, packetId, catalogTrackName, now, blockClass);
|
|
26886
|
+
if (deadline === null) {
|
|
26647
26887
|
clearRepair(sbn, packetId, catalogTrackName);
|
|
26648
26888
|
mc.noteRepairSkipped(
|
|
26649
26889
|
"presentation-delay-unavailable",
|
|
26650
|
-
{ rttMs: readRtt(), budgetMs: 0 },
|
|
26890
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
26651
26891
|
sbn,
|
|
26652
26892
|
packetId,
|
|
26653
26893
|
catalogTrackName
|
|
@@ -26659,14 +26899,15 @@ function wireRepairFetch(mc, opts) {
|
|
|
26659
26899
|
...identity,
|
|
26660
26900
|
repairTrack: target.repairTrack,
|
|
26661
26901
|
blockProfile,
|
|
26662
|
-
priority
|
|
26902
|
+
priority,
|
|
26663
26903
|
subscriberPriority: wire.subscriberPriority,
|
|
26664
|
-
deadlineAt,
|
|
26904
|
+
deadlineAt: deadline.deadlineAt,
|
|
26665
26905
|
order: enqueueOrder++,
|
|
26666
26906
|
attempts: 0,
|
|
26667
26907
|
running: null
|
|
26668
26908
|
};
|
|
26669
26909
|
entries.set(key, entry);
|
|
26910
|
+
noteBudget(entry, deadline.extensionMs);
|
|
26670
26911
|
if (entry.priority < 2) preemptDeltas();
|
|
26671
26912
|
dispatch();
|
|
26672
26913
|
});
|