@blockcast/mmt-container 0.4.0-main.71d61b2a53f2 → 0.4.0-main.cc36a672eb06
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 +257 -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/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 +14 -3
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +98 -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 +173 -15
- package/dist/multicast-manager.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 +43 -17
- 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
|
}
|
|
@@ -13185,6 +13188,9 @@ var FECManager = class _FECManager {
|
|
|
13185
13188
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
13186
13189
|
this.#ssbLengthConflictCount = 0;
|
|
13187
13190
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
13191
|
+
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
13192
|
+
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
13193
|
+
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
13188
13194
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
13189
13195
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
13190
13196
|
// which would falsely start new timeouts without this guard.
|
|
@@ -13425,6 +13431,7 @@ var FECManager = class _FECManager {
|
|
|
13425
13431
|
#blockAuthoredLengths;
|
|
13426
13432
|
#ssbLengthConflictCount;
|
|
13427
13433
|
#blockRepairRsIds;
|
|
13434
|
+
#blockRsbLengths;
|
|
13428
13435
|
#completedBlocks;
|
|
13429
13436
|
#terminalExpiryMs;
|
|
13430
13437
|
#terminalQueues;
|
|
@@ -14696,6 +14703,7 @@ var FECManager = class _FECManager {
|
|
|
14696
14703
|
resetMap(this.#blockSourceEsis);
|
|
14697
14704
|
resetMap(this.#blockAuthoredLengths);
|
|
14698
14705
|
resetMap(this.#blockRepairRsIds);
|
|
14706
|
+
resetMap(this.#blockRsbLengths);
|
|
14699
14707
|
resetMap(this.#blockPathCounts);
|
|
14700
14708
|
resetMap(this.#blockAnchorsMs);
|
|
14701
14709
|
resetMap(this.#blockCatalogTrackNames);
|
|
@@ -14813,6 +14821,7 @@ var FECManager = class _FECManager {
|
|
|
14813
14821
|
dropMap(this.#blockSourceEsis);
|
|
14814
14822
|
dropMap(this.#blockAuthoredLengths);
|
|
14815
14823
|
dropMap(this.#blockRepairRsIds);
|
|
14824
|
+
dropMap(this.#blockRsbLengths);
|
|
14816
14825
|
dropMap(this.#blockPathCounts);
|
|
14817
14826
|
dropMap(this.#blockAnchorsMs);
|
|
14818
14827
|
dropMap(this.#blockCatalogTrackNames);
|
|
@@ -15067,6 +15076,31 @@ var FECManager = class _FECManager {
|
|
|
15067
15076
|
windowMs: this.#deliveryGaps.windowMs
|
|
15068
15077
|
};
|
|
15069
15078
|
}
|
|
15079
|
+
/**
|
|
15080
|
+
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
15081
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it).
|
|
15082
|
+
* Undefined for a block that is not open.
|
|
15083
|
+
*/
|
|
15084
|
+
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
15085
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15086
|
+
if (!this.#activeBlocks.has(key)) return void 0;
|
|
15087
|
+
return {
|
|
15088
|
+
sources: this.#blockSourceCounts.get(key) ?? 0,
|
|
15089
|
+
repairs: this.#blockRepairRsIds.get(key)?.size ?? 0,
|
|
15090
|
+
authoredLength: this.#blockAuthoredLengths.get(key),
|
|
15091
|
+
repairGroupLength: this.#blockRsbLengths.get(key)
|
|
15092
|
+
};
|
|
15093
|
+
}
|
|
15094
|
+
/**
|
|
15095
|
+
* Record a block's RSB_length from one of its repair symbols (the router
|
|
15096
|
+
* parses it from the Repair FEC Payload ID). The largest stated value wins.
|
|
15097
|
+
*/
|
|
15098
|
+
noteRepairGroupLength(sbn, packetId, rsbLength, catalogTrackName) {
|
|
15099
|
+
if (!Number.isSafeInteger(rsbLength) || rsbLength <= 0) return;
|
|
15100
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15101
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
15102
|
+
if ((this.#blockRsbLengths.get(key) ?? 0) < rsbLength) this.#blockRsbLengths.set(key, rsbLength);
|
|
15103
|
+
}
|
|
15070
15104
|
/**
|
|
15071
15105
|
* Receiver-local time of a block's first accepted symbol, or undefined for
|
|
15072
15106
|
* a block no symbol reached (one materialized because a later SBN arrived).
|
|
@@ -16006,6 +16040,7 @@ var FECManager = class _FECManager {
|
|
|
16006
16040
|
this.#blockSourceEsis.delete(key);
|
|
16007
16041
|
this.#blockAuthoredLengths.delete(key);
|
|
16008
16042
|
this.#blockRepairRsIds.delete(key);
|
|
16043
|
+
this.#blockRsbLengths.delete(key);
|
|
16009
16044
|
this.#markTerminal(key, sbn, packetId, true);
|
|
16010
16045
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
16011
16046
|
if (catalogTrackName === void 0) {
|
|
@@ -16057,6 +16092,7 @@ var FECManager = class _FECManager {
|
|
|
16057
16092
|
this.#blockSourceEsis.delete(key);
|
|
16058
16093
|
this.#blockAuthoredLengths.delete(key);
|
|
16059
16094
|
this.#blockRepairRsIds.delete(key);
|
|
16095
|
+
this.#blockRsbLengths.delete(key);
|
|
16060
16096
|
this.#syncDecoderBlockOwners.delete(key);
|
|
16061
16097
|
this.#markTerminal(key, sbn, packetId, false);
|
|
16062
16098
|
this.#failedBlocks.add(key);
|
|
@@ -16094,6 +16130,7 @@ var FECManager = class _FECManager {
|
|
|
16094
16130
|
this.#blockSourceEsis.delete(key);
|
|
16095
16131
|
this.#blockAuthoredLengths.delete(key);
|
|
16096
16132
|
this.#blockRepairRsIds.delete(key);
|
|
16133
|
+
this.#blockRsbLengths.delete(key);
|
|
16097
16134
|
this.#clearBlockTimer(key);
|
|
16098
16135
|
this.onBlockResolved?.(block.sbn, block.packetId, block.catalogTrackName);
|
|
16099
16136
|
}
|
|
@@ -16184,6 +16221,7 @@ var FECManager = class _FECManager {
|
|
|
16184
16221
|
this.#blockSourceEsis.clear();
|
|
16185
16222
|
this.#blockAuthoredLengths.clear();
|
|
16186
16223
|
this.#blockRepairRsIds.clear();
|
|
16224
|
+
this.#blockRsbLengths.clear();
|
|
16187
16225
|
this.#completedBlocks.clear();
|
|
16188
16226
|
this.#cleanlyCompletedBlocks.clear();
|
|
16189
16227
|
this.#repairRequestedBlocks.clear();
|
|
@@ -17055,6 +17093,42 @@ var FecReleaseSequencer = class {
|
|
|
17055
17093
|
for (const stream of this.#streams.values()) total += stream.buf.length;
|
|
17056
17094
|
return total;
|
|
17057
17095
|
}
|
|
17096
|
+
#deferDepth = 0;
|
|
17097
|
+
#deferredStreams = /* @__PURE__ */ new Set();
|
|
17098
|
+
/**
|
|
17099
|
+
* Run `work` with the drains its pushes would run deferred to its end. A
|
|
17100
|
+
* recovered FEC block is routed one frame at a time, and its block is
|
|
17101
|
+
* already resolved when the first frame is pushed: draining on that push
|
|
17102
|
+
* would release past the gap before the block's other recovered frames
|
|
17103
|
+
* arrive (deciding a conceal or stall for media that is about to land),
|
|
17104
|
+
* and those frames would then be dropped as stale. Nests.
|
|
17105
|
+
*/
|
|
17106
|
+
defer(work) {
|
|
17107
|
+
this.#deferDepth++;
|
|
17108
|
+
let threw = true;
|
|
17109
|
+
try {
|
|
17110
|
+
work();
|
|
17111
|
+
threw = false;
|
|
17112
|
+
} finally {
|
|
17113
|
+
this.#deferDepth--;
|
|
17114
|
+
if (this.#deferDepth === 0 && this.#deferredStreams.size > 0) {
|
|
17115
|
+
const streams = [...this.#deferredStreams];
|
|
17116
|
+
this.#deferredStreams.clear();
|
|
17117
|
+
if (!threw) {
|
|
17118
|
+
for (const stream of streams) this.#drain(stream);
|
|
17119
|
+
} else {
|
|
17120
|
+
try {
|
|
17121
|
+
for (const stream of streams) this.#drain(stream);
|
|
17122
|
+
} catch {
|
|
17123
|
+
}
|
|
17124
|
+
}
|
|
17125
|
+
}
|
|
17126
|
+
}
|
|
17127
|
+
}
|
|
17128
|
+
#drainUnlessDeferred(stream) {
|
|
17129
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
17130
|
+
else this.#drain(stream);
|
|
17131
|
+
}
|
|
17058
17132
|
push(streamKey, data, meta, seq) {
|
|
17059
17133
|
const frame = { data, meta: { ...meta }, seq, arrivedAtMs: performance.now() };
|
|
17060
17134
|
const stream = this.#streamFor(streamKey, meta);
|
|
@@ -17076,7 +17150,7 @@ var FecReleaseSequencer = class {
|
|
|
17076
17150
|
return;
|
|
17077
17151
|
}
|
|
17078
17152
|
this.#release(stream, frame, void 0);
|
|
17079
|
-
this.#
|
|
17153
|
+
this.#drainUnlessDeferred(stream);
|
|
17080
17154
|
return;
|
|
17081
17155
|
}
|
|
17082
17156
|
let lo = 0;
|
|
@@ -17087,7 +17161,23 @@ var FecReleaseSequencer = class {
|
|
|
17087
17161
|
else hi = mid;
|
|
17088
17162
|
}
|
|
17089
17163
|
stream.buf.splice(lo, 0, frame);
|
|
17090
|
-
this.#
|
|
17164
|
+
this.#drainUnlessDeferred(stream);
|
|
17165
|
+
}
|
|
17166
|
+
/**
|
|
17167
|
+
* Arrival time of the earliest frame a stream of `packetId` holds behind a
|
|
17168
|
+
* gap (the gate forces it out `holdLimitMs` after that), or undefined when
|
|
17169
|
+
* none is held. Without `catalogTrackName`, every stream of the packetId.
|
|
17170
|
+
*/
|
|
17171
|
+
earliestHeldArrivalMs(packetId, catalogTrackName) {
|
|
17172
|
+
let earliest;
|
|
17173
|
+
for (const stream of this.#streams.values()) {
|
|
17174
|
+
if (stream.packetId !== packetId) continue;
|
|
17175
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
17176
|
+
for (const frame of stream.buf) {
|
|
17177
|
+
if (earliest === void 0 || frame.arrivedAtMs < earliest) earliest = frame.arrivedAtMs;
|
|
17178
|
+
}
|
|
17179
|
+
}
|
|
17180
|
+
return earliest;
|
|
17091
17181
|
}
|
|
17092
17182
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
17093
17183
|
poke(streamKey) {
|
|
@@ -17523,6 +17613,22 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
17523
17613
|
}
|
|
17524
17614
|
) : null;
|
|
17525
17615
|
}
|
|
17616
|
+
/**
|
|
17617
|
+
* Run `work` with the FEC release gate's drains deferred to its end, so
|
|
17618
|
+
* every frame it pushes is in place before any held gap is decided (see
|
|
17619
|
+
* FecReleaseSequencer.defer).
|
|
17620
|
+
*/
|
|
17621
|
+
deferFecRelease(work) {
|
|
17622
|
+
if (!this.#fecSequencer) {
|
|
17623
|
+
work();
|
|
17624
|
+
return;
|
|
17625
|
+
}
|
|
17626
|
+
this.#fecSequencer.defer(work);
|
|
17627
|
+
}
|
|
17628
|
+
/** See FecReleaseSequencer.earliestHeldArrivalMs. */
|
|
17629
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
17630
|
+
return this.#fecSequencer?.earliestHeldArrivalMs(packetId, catalogTrackName);
|
|
17631
|
+
}
|
|
17526
17632
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
17527
17633
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
17528
17634
|
if (!this.#fecSequencer) return;
|
|
@@ -18860,6 +18966,8 @@ var MmtpRouter = class {
|
|
|
18860
18966
|
// ── Keyframe loss detection state ───────────────────────────────
|
|
18861
18967
|
/** 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
18968
|
#keyframeLostTimeoutMs;
|
|
18969
|
+
/** packetIds already warned for running without Phase 13 (non-FEC video only). */
|
|
18970
|
+
#warnedNoKeyframeLostTimeout = /* @__PURE__ */ new Set();
|
|
18863
18971
|
/** Why the last reader evaluation left the timer unarmed; null while arming. Dedups the warning. */
|
|
18864
18972
|
#keyframeLostUnarmedReason = null;
|
|
18865
18973
|
/** Active keyframe loss timer handle. Single timer per video track — cleared on each rapFlag and on dispose(). */
|
|
@@ -19189,15 +19297,14 @@ var MmtpRouter = class {
|
|
|
19189
19297
|
}
|
|
19190
19298
|
/** Register MMTP packetId → track type mapping.
|
|
19191
19299
|
* Call BEFORE packets arrive to ensure correct routing from the first packet.
|
|
19192
|
-
*
|
|
19193
|
-
*
|
|
19194
|
-
*
|
|
19300
|
+
* Without keyframeLostTimeoutMs a track WITHOUT FEC has no Phase 13
|
|
19301
|
+
* keyframe repair (video still routes/decodes normally); that is warned at
|
|
19302
|
+
* its first keyframe, once the FEC configuration is known (see
|
|
19303
|
+
* #noteEmittedKeyframe). Nothing is warned here: an FEC track never uses
|
|
19304
|
+
* the timer, and at registration the FEC configuration may not be applied
|
|
19305
|
+
* yet. framerate is OPTIONAL per draft-ietf-moq-catalogformat-01 §3.2.23,
|
|
19306
|
+
* so we can't require the timeout. */
|
|
19195
19307
|
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
19308
|
if (trackType === "video") this.#videoPacketIds.add(packetId);
|
|
19202
19309
|
else this.#audioPacketIds.add(packetId);
|
|
19203
19310
|
const codec = this.#trackCodecs.get(packetId) ?? "";
|
|
@@ -19628,6 +19735,7 @@ var MmtpRouter = class {
|
|
|
19628
19735
|
catalogTrackName
|
|
19629
19736
|
)) return;
|
|
19630
19737
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
19738
|
+
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
19631
19739
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
19632
19740
|
const recovered = fec.feedRepairSymbol(
|
|
19633
19741
|
ownerPacketId,
|
|
@@ -19697,7 +19805,7 @@ var MmtpRouter = class {
|
|
|
19697
19805
|
* Sync WASM decoders return the block's K' = SSB_length fixed-width
|
|
19698
19806
|
* ssbg_mode1 source symbols concatenated. */
|
|
19699
19807
|
routeRecoveredBlock(blockId, data, packetId, catalogTrackName) {
|
|
19700
|
-
this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
19808
|
+
this.#withDeferredFecPokes(() => this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName));
|
|
19701
19809
|
}
|
|
19702
19810
|
/** Route a single recovered source symbol through the parser + dedup pipeline.
|
|
19703
19811
|
* Worker-backed decoders emit one padded source symbol per frame event. */
|
|
@@ -20111,8 +20219,16 @@ var MmtpRouter = class {
|
|
|
20111
20219
|
#noteEmittedKeyframe(packetId, keyframe) {
|
|
20112
20220
|
if (!keyframe) return;
|
|
20113
20221
|
if (!this.#videoPacketIds.has(packetId)) return;
|
|
20114
|
-
if (this.#keyframeLostTimeoutMs === null) return;
|
|
20115
20222
|
if (this.#isFecTrack(packetId)) return;
|
|
20223
|
+
if (this.#keyframeLostTimeoutMs === null) {
|
|
20224
|
+
if (!this.#warnedNoKeyframeLostTimeout.has(packetId)) {
|
|
20225
|
+
this.#warnedNoKeyframeLostTimeout.add(packetId);
|
|
20226
|
+
console.warn(
|
|
20227
|
+
`[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.`
|
|
20228
|
+
);
|
|
20229
|
+
}
|
|
20230
|
+
return;
|
|
20231
|
+
}
|
|
20116
20232
|
this.#lastKeyframeGroupId++;
|
|
20117
20233
|
this.#armKeyframeLostTimer();
|
|
20118
20234
|
}
|
|
@@ -20124,7 +20240,7 @@ var MmtpRouter = class {
|
|
|
20124
20240
|
#withDeferredFecPokes(work) {
|
|
20125
20241
|
this.#fecPokeDepth++;
|
|
20126
20242
|
try {
|
|
20127
|
-
work
|
|
20243
|
+
this.#parser.deferFecRelease(work);
|
|
20128
20244
|
} finally {
|
|
20129
20245
|
this.#fecPokeDepth--;
|
|
20130
20246
|
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
@@ -20136,6 +20252,13 @@ var MmtpRouter = class {
|
|
|
20136
20252
|
}
|
|
20137
20253
|
}
|
|
20138
20254
|
}
|
|
20255
|
+
/**
|
|
20256
|
+
* Arrival time of the earliest frame the FEC release gate holds for this
|
|
20257
|
+
* stream (see FecReleaseSequencer.earliestHeldArrivalMs), or undefined.
|
|
20258
|
+
*/
|
|
20259
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
20260
|
+
return this.#parser.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
20261
|
+
}
|
|
20139
20262
|
#requestFecPoke(packetId, catalogTrackName) {
|
|
20140
20263
|
if (this.#disposed) return;
|
|
20141
20264
|
if (this.#fecPokeDepth > 0) {
|
|
@@ -22929,6 +23052,13 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
22929
23052
|
deltaRepairsPreempted: 0,
|
|
22930
23053
|
deltaRepairsDeferred: 0,
|
|
22931
23054
|
repairsSkipped: 0,
|
|
23055
|
+
repairsSkippedRttUnmeasured: 0,
|
|
23056
|
+
repairsSkippedRttExceedsBudget: 0,
|
|
23057
|
+
repairsSkippedPresentationDelayUnavailable: 0,
|
|
23058
|
+
lastRepairSkip: null,
|
|
23059
|
+
keyframeRepairFetchesSent: 0,
|
|
23060
|
+
keyframeBudgetHolds: 0,
|
|
23061
|
+
keyframeBudgetHoldMs: 0,
|
|
22932
23062
|
deltaBlocksFailed: 0,
|
|
22933
23063
|
audioBlocksRecoveredInband: 0,
|
|
22934
23064
|
audioBlocksRecoveredQuic: 0,
|
|
@@ -24431,7 +24561,17 @@ var MulticastManager = class {
|
|
|
24431
24561
|
}
|
|
24432
24562
|
/** Record a repair request the scheduler sent no FETCH for. */
|
|
24433
24563
|
noteRepairSkipped(reason, measurement, sbn, packetId, catalogTrackName) {
|
|
24434
|
-
this.#statsFor(packetId, catalogTrackName)
|
|
24564
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24565
|
+
stats.repairsSkipped++;
|
|
24566
|
+
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
24567
|
+
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
24568
|
+
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
24569
|
+
stats.lastRepairSkip = {
|
|
24570
|
+
reason,
|
|
24571
|
+
rttMs: measurement.rttMs,
|
|
24572
|
+
budgetMs: measurement.budgetMs,
|
|
24573
|
+
priority: measurement.priority ?? null
|
|
24574
|
+
};
|
|
24435
24575
|
this.#emitRepairLifecycle({
|
|
24436
24576
|
version: 2,
|
|
24437
24577
|
type: "repair-skipped",
|
|
@@ -24441,6 +24581,24 @@ var MulticastManager = class {
|
|
|
24441
24581
|
budgetMs: measurement.budgetMs
|
|
24442
24582
|
});
|
|
24443
24583
|
}
|
|
24584
|
+
/**
|
|
24585
|
+
* Arrival time of the earliest frame the in-order release gate holds for
|
|
24586
|
+
* the stream: the gate releases it as a discontinuity once
|
|
24587
|
+
* `terminalRetentionMsForPacket` has passed since then.
|
|
24588
|
+
*/
|
|
24589
|
+
earliestGatedFrameAtMs(packetId, catalogTrackName) {
|
|
24590
|
+
return this.#router.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
24591
|
+
}
|
|
24592
|
+
/** Record a keyframe late-repair budget the scheduler granted a block. */
|
|
24593
|
+
noteKeyframeBudgetGranted(extensionMs, _sbn, packetId, catalogTrackName) {
|
|
24594
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
24595
|
+
stats.keyframeBudgetHolds++;
|
|
24596
|
+
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24597
|
+
}
|
|
24598
|
+
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24599
|
+
noteRepairFetchSent(priority, _sbn, packetId, catalogTrackName) {
|
|
24600
|
+
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
24601
|
+
}
|
|
24444
24602
|
/**
|
|
24445
24603
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
24446
24604
|
* keyframe/audio work, or never dispatched before its block resolved.
|
|
@@ -24468,7 +24626,10 @@ var MulticastManager = class {
|
|
|
24468
24626
|
const out = {};
|
|
24469
24627
|
for (const [key, stats] of this.#blockPolicyStats) {
|
|
24470
24628
|
if (stats.epoch !== this.#fec.epochFor(stats.packetId)) continue;
|
|
24471
|
-
out[key] = {
|
|
24629
|
+
out[key] = {
|
|
24630
|
+
...stats,
|
|
24631
|
+
lastRepairSkip: stats.lastRepairSkip === null ? null : { ...stats.lastRepairSkip }
|
|
24632
|
+
};
|
|
24472
24633
|
}
|
|
24473
24634
|
return out;
|
|
24474
24635
|
}
|
|
@@ -26359,6 +26520,10 @@ function repairFetchSubscriberPriority(blockClass, target) {
|
|
|
26359
26520
|
if (!isMoqtPriority(repair)) return { kind: "decline", reason: "repair-priority-invalid" };
|
|
26360
26521
|
return { kind: "carry", subscriberPriority: Math.max(repair, REPAIR_PRIORITY_MIN) };
|
|
26361
26522
|
}
|
|
26523
|
+
function keyframeBudgetEligible(blockClass, classifierMode) {
|
|
26524
|
+
if (blockClass === "keyframe") return true;
|
|
26525
|
+
return blockClass === "unknown" && classifierMode === "classifying";
|
|
26526
|
+
}
|
|
26362
26527
|
function wireRepairFetch(mc, opts) {
|
|
26363
26528
|
if (!Number.isSafeInteger(opts.attemptLimit) || opts.attemptLimit < 1) {
|
|
26364
26529
|
throw new Error(
|
|
@@ -26396,6 +26561,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
26396
26561
|
run.controller.abort();
|
|
26397
26562
|
if (reason === "preempted") releaseHold(entry);
|
|
26398
26563
|
};
|
|
26564
|
+
const readKeyframeBudget = (packetId, catalogTrackName) => {
|
|
26565
|
+
const reader = opts.keyframeRepairBudgetMs;
|
|
26566
|
+
if (reader === void 0) return null;
|
|
26567
|
+
try {
|
|
26568
|
+
const budgetMs = reader(packetId, catalogTrackName);
|
|
26569
|
+
return Number.isFinite(budgetMs) && budgetMs > 0 ? budgetMs : null;
|
|
26570
|
+
} catch {
|
|
26571
|
+
return null;
|
|
26572
|
+
}
|
|
26573
|
+
};
|
|
26399
26574
|
const readRtt = () => {
|
|
26400
26575
|
try {
|
|
26401
26576
|
const rtt = opts.reliableRttMs();
|
|
@@ -26413,7 +26588,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26413
26588
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26414
26589
|
mc.noteRepairSkipped(
|
|
26415
26590
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
26416
|
-
{ rttMs, budgetMs },
|
|
26591
|
+
{ rttMs, budgetMs, priority: entry.priority },
|
|
26417
26592
|
entry.sbn,
|
|
26418
26593
|
entry.packetId,
|
|
26419
26594
|
entry.catalogTrackName
|
|
@@ -26452,6 +26627,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26452
26627
|
const start = (entry, counted = true) => {
|
|
26453
26628
|
if (!admit(entry, performance.now())) return;
|
|
26454
26629
|
if (counted) entry.attempts++;
|
|
26630
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26455
26631
|
const run = { controller: new AbortController(), stopped: null };
|
|
26456
26632
|
entry.running = run;
|
|
26457
26633
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -26489,6 +26665,25 @@ function wireRepairFetch(mc, opts) {
|
|
|
26489
26665
|
if (urgentOutstanding()) return;
|
|
26490
26666
|
queued.filter((entry) => entry.priority === 2).sort((a, b) => a.deadlineAt - b.deadlineAt || a.order - b.order).forEach((entry) => start(entry));
|
|
26491
26667
|
};
|
|
26668
|
+
const symbolCounts = (sbn, packetId, catalogTrackName) => {
|
|
26669
|
+
try {
|
|
26670
|
+
return mc.fecManager.blockSymbolCounts?.(sbn, packetId, catalogTrackName);
|
|
26671
|
+
} catch {
|
|
26672
|
+
return void 0;
|
|
26673
|
+
}
|
|
26674
|
+
};
|
|
26675
|
+
const decodable = (entry) => {
|
|
26676
|
+
const counts = symbolCounts(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26677
|
+
if (counts === void 0 || counts.authoredLength === void 0) return true;
|
|
26678
|
+
return counts.sources + counts.repairs >= counts.authoredLength;
|
|
26679
|
+
};
|
|
26680
|
+
const groupCanComplete = (sbn, packetId, catalogTrackName) => {
|
|
26681
|
+
const counts = symbolCounts(sbn, packetId, catalogTrackName);
|
|
26682
|
+
if (counts === void 0 || counts.authoredLength === void 0 || counts.repairGroupLength === void 0) {
|
|
26683
|
+
return true;
|
|
26684
|
+
}
|
|
26685
|
+
return counts.sources + counts.repairGroupLength >= counts.authoredLength;
|
|
26686
|
+
};
|
|
26492
26687
|
const finish = (entry, run, fed, error) => {
|
|
26493
26688
|
if (run.stopped !== null || entry.running !== run || entries.get(entry.key) !== entry) {
|
|
26494
26689
|
return;
|
|
@@ -26496,7 +26691,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26496
26691
|
entry.running = null;
|
|
26497
26692
|
if (error === void 0) {
|
|
26498
26693
|
retire(entry);
|
|
26499
|
-
if (fed === 0) {
|
|
26694
|
+
if (fed === 0 || !decodable(entry)) {
|
|
26500
26695
|
releaseHold(entry);
|
|
26501
26696
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26502
26697
|
}
|
|
@@ -26570,6 +26765,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
26570
26765
|
if (wire === null) return;
|
|
26571
26766
|
entry2.priority = promoted;
|
|
26572
26767
|
entry2.subscriberPriority = wire.subscriberPriority;
|
|
26768
|
+
const promotedDeadline = presentationDeadlineAt(
|
|
26769
|
+
entry2.sbn,
|
|
26770
|
+
entry2.packetId,
|
|
26771
|
+
entry2.catalogTrackName,
|
|
26772
|
+
performance.now(),
|
|
26773
|
+
event.to
|
|
26774
|
+
);
|
|
26775
|
+
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26776
|
+
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
26777
|
+
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26778
|
+
}
|
|
26573
26779
|
if (entry2.running) {
|
|
26574
26780
|
stop(entry2, "reprioritized");
|
|
26575
26781
|
start(entry2, false);
|
|
@@ -26588,12 +26794,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
26588
26794
|
else if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
26589
26795
|
dispatch();
|
|
26590
26796
|
});
|
|
26591
|
-
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now) => {
|
|
26797
|
+
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now, blockClass) => {
|
|
26592
26798
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName);
|
|
26593
26799
|
if (waitMs === void 0) return null;
|
|
26594
26800
|
const waitDeadlineAt = now + waitMs;
|
|
26595
26801
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
26596
|
-
if (anchor === void 0) return waitDeadlineAt;
|
|
26802
|
+
if (anchor === void 0) return { deadlineAt: waitDeadlineAt, extensionMs: 0 };
|
|
26597
26803
|
let delayMs;
|
|
26598
26804
|
try {
|
|
26599
26805
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -26603,8 +26809,31 @@ function wireRepairFetch(mc, opts) {
|
|
|
26603
26809
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) return null;
|
|
26604
26810
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
26605
26811
|
if (retentionMs === void 0) return null;
|
|
26606
|
-
const ceilingAt = anchor + retentionMs;
|
|
26607
|
-
|
|
26812
|
+
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
26813
|
+
const deadlineAt = (delay) => Math.max(waitDeadlineAt, Math.min(anchor + delay, ceilingAt));
|
|
26814
|
+
const base = deadlineAt(delayMs);
|
|
26815
|
+
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
26816
|
+
if (budgetMs === null || budgetMs <= delayMs) return { deadlineAt: base, extensionMs: 0 };
|
|
26817
|
+
const extended = deadlineAt(budgetMs);
|
|
26818
|
+
return { deadlineAt: extended, extensionMs: extended - base };
|
|
26819
|
+
};
|
|
26820
|
+
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
26821
|
+
try {
|
|
26822
|
+
const at = mc.earliestGatedFrameAtMs?.(packetId, catalogTrackName);
|
|
26823
|
+
return at !== void 0 && Number.isFinite(at) ? at : void 0;
|
|
26824
|
+
} catch {
|
|
26825
|
+
return void 0;
|
|
26826
|
+
}
|
|
26827
|
+
};
|
|
26828
|
+
const classifierMode = (packetId, catalogTrackName) => {
|
|
26829
|
+
try {
|
|
26830
|
+
return mc.fecManager.classifierModeFor?.(packetId, catalogTrackName).mode;
|
|
26831
|
+
} catch {
|
|
26832
|
+
return void 0;
|
|
26833
|
+
}
|
|
26834
|
+
};
|
|
26835
|
+
const noteBudget = (entry, extensionMs) => {
|
|
26836
|
+
if (extensionMs > 0) mc.noteKeyframeBudgetGranted?.(extensionMs, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
26608
26837
|
};
|
|
26609
26838
|
mc.onRepairSubscribe((sbn, packetId, catalogTrackName, blockClass) => {
|
|
26610
26839
|
if (disposed) {
|
|
@@ -26642,12 +26871,13 @@ function wireRepairFetch(mc, opts) {
|
|
|
26642
26871
|
return;
|
|
26643
26872
|
}
|
|
26644
26873
|
const now = performance.now();
|
|
26645
|
-
const
|
|
26646
|
-
|
|
26874
|
+
const priority = repairPriorityForClass(blockClass);
|
|
26875
|
+
const deadline = presentationDeadlineAt(sbn, packetId, catalogTrackName, now, blockClass);
|
|
26876
|
+
if (deadline === null) {
|
|
26647
26877
|
clearRepair(sbn, packetId, catalogTrackName);
|
|
26648
26878
|
mc.noteRepairSkipped(
|
|
26649
26879
|
"presentation-delay-unavailable",
|
|
26650
|
-
{ rttMs: readRtt(), budgetMs: 0 },
|
|
26880
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
26651
26881
|
sbn,
|
|
26652
26882
|
packetId,
|
|
26653
26883
|
catalogTrackName
|
|
@@ -26659,14 +26889,15 @@ function wireRepairFetch(mc, opts) {
|
|
|
26659
26889
|
...identity,
|
|
26660
26890
|
repairTrack: target.repairTrack,
|
|
26661
26891
|
blockProfile,
|
|
26662
|
-
priority
|
|
26892
|
+
priority,
|
|
26663
26893
|
subscriberPriority: wire.subscriberPriority,
|
|
26664
|
-
deadlineAt,
|
|
26894
|
+
deadlineAt: deadline.deadlineAt,
|
|
26665
26895
|
order: enqueueOrder++,
|
|
26666
26896
|
attempts: 0,
|
|
26667
26897
|
running: null
|
|
26668
26898
|
};
|
|
26669
26899
|
entries.set(key, entry);
|
|
26900
|
+
noteBudget(entry, deadline.extensionMs);
|
|
26670
26901
|
if (entry.priority < 2) preemptDeltas();
|
|
26671
26902
|
dispatch();
|
|
26672
26903
|
});
|