@blockcast/mmt-container 0.4.0-main.b58c869b8e09 → 0.4.0-main.bbd83cb48eff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/browser-runtime.js +174 -50
- package/dist/browser-runtime.js.map +2 -2
- package/dist/carp-catalog.d.ts +5 -3
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +15 -5
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/fec-manager.d.ts +15 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +96 -39
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +10 -2
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +14 -4
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-router.d.ts +14 -4
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +43 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +152 -45
- package/dist/multicast-manager.js.map +2 -2
- package/dist/no-modules.js +14 -4
- package/dist/no-modules.js.map +2 -2
- package/package.json +5 -5
- package/src/carp-catalog.ts +33 -10
- package/src/fec-manager.ts +111 -49
- package/src/fec-worker-setup.ts +16 -1
- package/src/mmtp-router.ts +76 -5
- package/src/multicast-manager.ts +23 -6
- package/test-vectors/catalog/README.md +5 -1
- package/test-vectors/catalog-validation.json +95 -0
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ if (hdr.packetType === 0x00) { // MPU
|
|
|
135
135
|
|
|
136
136
|
### MFU reassembler (`./mfu`)
|
|
137
137
|
|
|
138
|
-
Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback.
|
|
138
|
+
Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback. The router feeds a recovered packet under the wire u32 sequence its SS_ID maps to through the stream's received FEC sources, since a hop may re-stamp the sequence after protection.
|
|
139
139
|
|
|
140
140
|
```ts
|
|
141
141
|
interface MFUReassemblerOptions {
|
|
@@ -278,7 +278,7 @@ This is **project-specific**, not in any IETF draft yet. The container's switchi
|
|
|
278
278
|
| `video/repair` | `repair` | FEC repair-symbol leg, cross-CDN federated |
|
|
279
279
|
| `video` (no slash) | `single` | Legacy single-track stream (D-04) |
|
|
280
280
|
|
|
281
|
-
Empty names, unknown suffixes, trailing slashes, and any non-ASCII / control characters all throw at parse time (T-14-01 fuzz hardening at `carp-catalog.ts:49-57`). Multi-track switching sets must include
|
|
281
|
+
Empty names, unknown suffixes, trailing slashes, and any non-ASCII / control characters all throw at parse time (T-14-01 fuzz hardening at `carp-catalog.ts:49-57`). Multi-track switching sets must include `base` and `repair` or `validateSwitchingSet` reports the missing roles; `delta` is optional, since base is self-decodable and a base-only set plays in base-only mode (BLO-49199).
|
|
282
282
|
|
|
283
283
|
```ts
|
|
284
284
|
import { parseTrackRole, validateSwitchingSet } from "@blockcast/mmt-container/carp-catalog"
|
|
@@ -289,6 +289,8 @@ parseTrackRole("video/foo") // throws "unknown role suffix"
|
|
|
289
289
|
|
|
290
290
|
validateSwitchingSet(["v/base", "v/delta", "v/repair"]) // { ok: true }
|
|
291
291
|
validateSwitchingSet(["v/base", "v/delta"]) // { ok: false, missing: ["repair"] }
|
|
292
|
+
validateSwitchingSet(["v/base", "v/repair"]) // { ok: true } — base-only
|
|
293
|
+
validateSwitchingSet(["v/delta", "v/repair"]) // { ok: false, missing: ["base"] }
|
|
292
294
|
```
|
|
293
295
|
|
|
294
296
|
### FEC manager (`./fec-manager`)
|
package/dist/browser-runtime.js
CHANGED
|
@@ -6860,11 +6860,21 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6860
6860
|
const timescale = BigInt(track["timescale"]);
|
|
6861
6861
|
const durationTicks = track["groupDurationTicks"];
|
|
6862
6862
|
const ticks = durationTicks !== void 0 ? BigInt(durationTicks) : BigInt(track["groupDurationMs"]) * timescale / 1000n;
|
|
6863
|
-
const
|
|
6864
|
-
|
|
6865
|
-
|
|
6863
|
+
const framerate = track["framerate"];
|
|
6864
|
+
const intraOnly = positiveNumber2(framerate) && Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
|
|
6865
|
+
const members = switchingSets.get(altGroup) ?? [];
|
|
6866
|
+
members.push({ index, name: track["name"], ticks, timescale, intraOnly });
|
|
6867
|
+
switchingSets.set(altGroup, members);
|
|
6868
|
+
}
|
|
6869
|
+
for (const [altGroup, members] of switchingSets) {
|
|
6870
|
+
const anchor = members.find((member) => !member.intraOnly) ?? members[0];
|
|
6871
|
+
for (const member of members) {
|
|
6872
|
+
if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
|
|
6873
|
+
const nests = member.intraOnly && !anchor.intraOnly && anchor.ticks * member.timescale % (member.ticks * anchor.timescale) === 0n;
|
|
6874
|
+
if (!nests) {
|
|
6875
|
+
catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
|
|
6876
|
+
}
|
|
6866
6877
|
}
|
|
6867
|
-
if (!anchor) switchingSets.set(altGroup, { name: track["name"], ticks, timescale });
|
|
6868
6878
|
}
|
|
6869
6879
|
const multicast = catalog["multicast"];
|
|
6870
6880
|
if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
|
|
@@ -13255,9 +13265,13 @@ var FECManager = class _FECManager {
|
|
|
13255
13265
|
// per stream. Not only throws: the ordinary out-of-range case is detected by
|
|
13256
13266
|
// arithmetic and never throws at all.
|
|
13257
13267
|
this.#orderedHorizonWarnedFor = /* @__PURE__ */ new Set();
|
|
13258
|
-
// Newest block start (SS_Start)
|
|
13259
|
-
//
|
|
13268
|
+
// Newest block start (SS_Start) any symbol carried per stream and when: the
|
|
13269
|
+
// frontier isoSpanResolution reads.
|
|
13260
13270
|
this.#highestSbn = /* @__PURE__ */ new Map();
|
|
13271
|
+
// The same from source symbols alone: the frontier a source is judged
|
|
13272
|
+
// against for a discontinuity. Repairs ride their own group, which can run
|
|
13273
|
+
// blocks ahead of the media they protect.
|
|
13274
|
+
this.#sourceFrontiers = /* @__PURE__ */ new Map();
|
|
13261
13275
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
13262
13276
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
13263
13277
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
@@ -13275,8 +13289,8 @@ var FECManager = class _FECManager {
|
|
|
13275
13289
|
// rate-limited like the other per-symbol warns here. Cumulative.
|
|
13276
13290
|
this.#isoDecoderUnplacedRetireFailed = 0;
|
|
13277
13291
|
// The latest source symbol per stream that carried its MMTP
|
|
13278
|
-
// packet_sequence_number: the anchor that bounds how
|
|
13279
|
-
// producer can have
|
|
13292
|
+
// packet_sequence_number, by its own SS_ID: the anchor that bounds how far
|
|
13293
|
+
// the producer's SS_IDs can have moved before or after another source symbol.
|
|
13280
13294
|
this.#sourceAnchors = /* @__PURE__ */ new Map();
|
|
13281
13295
|
// Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
|
|
13282
13296
|
this.#packetEpochs = /* @__PURE__ */ new Map();
|
|
@@ -13414,6 +13428,7 @@ var FECManager = class _FECManager {
|
|
|
13414
13428
|
#materializedBlocks;
|
|
13415
13429
|
#orderedHorizonWarnedFor;
|
|
13416
13430
|
#highestSbn;
|
|
13431
|
+
#sourceFrontiers;
|
|
13417
13432
|
#isoLocators;
|
|
13418
13433
|
#isoRepairRefusedCount;
|
|
13419
13434
|
#isoSourceOversizeCount;
|
|
@@ -14004,8 +14019,8 @@ var FECManager = class _FECManager {
|
|
|
14004
14019
|
// Deliberately one block tighter than deriveFecRetentionBlocks over the same
|
|
14005
14020
|
// inputs (that function's `+ 1`). Different question: the retention horizon
|
|
14006
14021
|
// asks how long the decoder still ACCEPTS symbols for a block, this asks how
|
|
14007
|
-
// many blocks a stream can
|
|
14008
|
-
//
|
|
14022
|
+
// many blocks a stream can jump ahead of its frontier before a source symbol
|
|
14023
|
+
// there is a discontinuity rather than loss (see #noteSbnSeen).
|
|
14009
14024
|
// The extra block of retention is slack for a block still being fed; a block
|
|
14010
14025
|
// nothing has been heard from does not get it. Not the units defect — but it
|
|
14011
14026
|
// is the next place the two can drift, so change both or neither.
|
|
@@ -14015,55 +14030,72 @@ var FECManager = class _FECManager {
|
|
|
14015
14030
|
}
|
|
14016
14031
|
/**
|
|
14017
14032
|
* Record that a symbol for block `sbn` (the block's SS_Start) arrived and
|
|
14018
|
-
* advance the stream's
|
|
14033
|
+
* advance the stream's frontiers, the newest block start seen.
|
|
14019
14034
|
*
|
|
14020
|
-
* A SOURCE symbol
|
|
14021
|
-
*
|
|
14022
|
-
*
|
|
14035
|
+
* A SOURCE symbol is judged against the newest source block alone: repairs
|
|
14036
|
+
* ride their own group, which can run blocks ahead of the media. One whose
|
|
14037
|
+
* block goes back further than the blocks this manager retains, or that
|
|
14038
|
+
* cannot have been sent before the source it lies behind, or that jumps
|
|
14039
|
+
* further than the stream could have produced since its last symbol, is a
|
|
14040
|
+
* source discontinuity, not loss. A repair symbol can only advance the
|
|
14023
14041
|
* frontier: a D-28 fetch legitimately answers for an old block, so it never
|
|
14024
14042
|
* signals a discontinuity.
|
|
14025
14043
|
*
|
|
14026
14044
|
* The producer closes a block at its Dth media-unit boundary OR when K
|
|
14027
14045
|
* source symbols filled it, so one interleave span can start several blocks
|
|
14028
|
-
* (every large keyframe does). What bounds a
|
|
14029
|
-
*
|
|
14030
|
-
*
|
|
14031
|
-
*
|
|
14032
|
-
* packet_sequence_number
|
|
14033
|
-
*
|
|
14034
|
-
*
|
|
14046
|
+
* (every large keyframe does). What bounds a jump is therefore packet
|
|
14047
|
+
* evidence, not a block rate: SS_ID advances by one per FEC source packet
|
|
14048
|
+
* (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
|
|
14049
|
+
* packet of the packet_id, so with both source symbols'
|
|
14050
|
+
* packet_sequence_number their SS_IDs (`ssId`, not their block starts,
|
|
14051
|
+
* which a repair-less span can put far behind) can move at most the packets
|
|
14052
|
+
* sent between them, in either direction, plus K of slack for sources lost
|
|
14053
|
+
* before a hop that renumbers packets. Without it, only the D-close rate is
|
|
14054
|
+
* known.
|
|
14035
14055
|
*
|
|
14036
14056
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
14037
14057
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
14038
14058
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
14039
14059
|
*/
|
|
14040
|
-
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber) {
|
|
14060
|
+
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
|
|
14041
14061
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
14042
14062
|
const now = performance.now();
|
|
14043
|
-
const previous = this.#highestSbn.get(streamKey);
|
|
14063
|
+
const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
|
|
14044
14064
|
const anchor = this.#sourceAnchors.get(streamKey);
|
|
14045
14065
|
const psn = symbol === "source" && packetSequenceNumber !== void 0 && Number.isSafeInteger(packetSequenceNumber) && packetSequenceNumber >= 0 && packetSequenceNumber <= 4294967295 ? packetSequenceNumber : void 0;
|
|
14046
14066
|
const anchorHere = () => {
|
|
14047
|
-
if (psn !== void 0 && (anchor === void 0 || !
|
|
14048
|
-
this.#sourceAnchors.set(streamKey, {
|
|
14067
|
+
if (psn !== void 0 && (anchor === void 0 || !serial32Precedes(ssId, anchor.ssId))) {
|
|
14068
|
+
this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14049
14069
|
}
|
|
14050
14070
|
};
|
|
14071
|
+
const advance = () => {
|
|
14072
|
+
const highest = this.#highestSbn.get(streamKey);
|
|
14073
|
+
if (highest === void 0 || this.#blockPrecedes(highest.sbn, sbn)) {
|
|
14074
|
+
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14075
|
+
}
|
|
14076
|
+
if (symbol === "source") this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14077
|
+
anchorHere();
|
|
14078
|
+
};
|
|
14051
14079
|
const discontinuity = () => {
|
|
14052
14080
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
14053
14081
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14082
|
+
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14054
14083
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
14055
|
-
else this.#sourceAnchors.set(streamKey, {
|
|
14084
|
+
else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
|
|
14056
14085
|
this.onSourceDiscontinuity?.(packetId, catalogTrackName);
|
|
14057
14086
|
};
|
|
14058
14087
|
if (previous === void 0) {
|
|
14059
|
-
|
|
14060
|
-
anchorHere();
|
|
14088
|
+
advance();
|
|
14061
14089
|
return;
|
|
14062
14090
|
}
|
|
14063
14091
|
const config = this.#trackConfig(packetId);
|
|
14064
14092
|
const window2 = this.#liveWindowBlocks(config);
|
|
14093
|
+
const sentInOrder = (from, to) => {
|
|
14094
|
+
const sent = to.psn - from.psn >>> 0;
|
|
14095
|
+
return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
|
|
14096
|
+
};
|
|
14065
14097
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
14066
|
-
if (symbol === "source" && window2 !== null && this.#blocksBehind(sbn, previous.sbn, packetId) >
|
|
14098
|
+
if (symbol === "source" && window2 !== null && this.#blockPrecedes(sbn, previous.sbn) && (this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) || psn !== void 0 && anchor !== void 0 && serial32Precedes(ssId, anchor.ssId) && psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))) {
|
|
14067
14099
|
discontinuity();
|
|
14068
14100
|
return;
|
|
14069
14101
|
}
|
|
@@ -14073,9 +14105,8 @@ var FECManager = class _FECManager {
|
|
|
14073
14105
|
const missing = this.#blocksBehind(previous.sbn, sbn, packetId) - 1;
|
|
14074
14106
|
let plausible = true;
|
|
14075
14107
|
if (window2 !== null) {
|
|
14076
|
-
if (psn !== void 0 && anchor !== void 0 &&
|
|
14077
|
-
|
|
14078
|
-
plausible = sent <= 2147483647 && serial32Distance(anchor.sbn, sbn) <= sent + config.k;
|
|
14108
|
+
if (psn !== void 0 && anchor !== void 0 && serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
|
|
14109
|
+
plausible = sentInOrder(anchor, { ssId, psn });
|
|
14079
14110
|
} else {
|
|
14080
14111
|
plausible = missing <= window2 + Math.ceil((now - previous.atMs) / config.interleaveDepthMs);
|
|
14081
14112
|
}
|
|
@@ -14085,8 +14116,7 @@ var FECManager = class _FECManager {
|
|
|
14085
14116
|
discontinuity();
|
|
14086
14117
|
return;
|
|
14087
14118
|
}
|
|
14088
|
-
|
|
14089
|
-
anchorHere();
|
|
14119
|
+
advance();
|
|
14090
14120
|
}
|
|
14091
14121
|
/*
|
|
14092
14122
|
* Block order for one stream (BLO-35597 iso:5). A block is keyed by its
|
|
@@ -14670,6 +14700,7 @@ var FECManager = class _FECManager {
|
|
|
14670
14700
|
resetSet(this.#materializedBlocks);
|
|
14671
14701
|
resetMap(this.#resolvedBlockClasses);
|
|
14672
14702
|
resetMap(this.#highestSbn);
|
|
14703
|
+
resetMap(this.#sourceFrontiers);
|
|
14673
14704
|
resetMap(this.#isoLocators);
|
|
14674
14705
|
resetMap(this.#sourceAnchors);
|
|
14675
14706
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -14775,6 +14806,7 @@ var FECManager = class _FECManager {
|
|
|
14775
14806
|
dropMap(this.#orderedPendingBlocks);
|
|
14776
14807
|
dropMap(this.#resolvedBlockClasses);
|
|
14777
14808
|
dropMap(this.#highestSbn);
|
|
14809
|
+
dropMap(this.#sourceFrontiers);
|
|
14778
14810
|
dropMap(this.#isoLocators);
|
|
14779
14811
|
dropMap(this.#sourceAnchors);
|
|
14780
14812
|
dropMap(this.#classifiers);
|
|
@@ -14867,7 +14899,13 @@ var FECManager = class _FECManager {
|
|
|
14867
14899
|
if (isSourceSymbol && esi === 0) {
|
|
14868
14900
|
this.#startupPartialBlocks.delete(blockKey);
|
|
14869
14901
|
this.#startupAlignedPackets.add(streamKey);
|
|
14870
|
-
} else if (
|
|
14902
|
+
} else if (
|
|
14903
|
+
// A ready multicast repair opens a block the join has not seen yet, never
|
|
14904
|
+
// a join partial: its sources were refused, so its repairs alone open a
|
|
14905
|
+
// block that cannot decode and fails at its deadline, once per packet ID
|
|
14906
|
+
// per join (BLO-48308).
|
|
14907
|
+
isStartupPartial || !this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair
|
|
14908
|
+
) {
|
|
14871
14909
|
this.#markStartupPartial(blockKey);
|
|
14872
14910
|
return false;
|
|
14873
14911
|
}
|
|
@@ -15192,6 +15230,10 @@ var FECManager = class _FECManager {
|
|
|
15192
15230
|
}
|
|
15193
15231
|
return blocks;
|
|
15194
15232
|
}
|
|
15233
|
+
/** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
|
|
15234
|
+
isoRetentionBlocksForPacket(packetId) {
|
|
15235
|
+
return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : void 0;
|
|
15236
|
+
}
|
|
15195
15237
|
/** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
|
|
15196
15238
|
isoSourceFits(packetId, packetLength) {
|
|
15197
15239
|
const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize;
|
|
@@ -15773,20 +15815,37 @@ var FECManager = class _FECManager {
|
|
|
15773
15815
|
* Caller is responsible for routing recovered data and updating
|
|
15774
15816
|
* block completion state via `markBlockCompleted()`.
|
|
15775
15817
|
*/
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15818
|
+
/**
|
|
15819
|
+
* Whether a repair symbol of `byteLength` bytes is a valid member of a
|
|
15820
|
+
* `packetId` block: every repair symbol is exactly the track's T. A symbol of
|
|
15821
|
+
* any other size is counted on `repairSymbolSizeMismatches`, warned (rate
|
|
15822
|
+
* limited) and refused. The router calls this before the symbol takes any
|
|
15823
|
+
* other part in block state (placement, first-arrival dedup, completed-block
|
|
15824
|
+
* accounting), so a malformed repair is counted whatever its arrival order:
|
|
15825
|
+
* judged after dedup, one landing on an already-complete block, or behind a
|
|
15826
|
+
* valid copy from the other transport, was swallowed as a duplicate and never
|
|
15827
|
+
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
15828
|
+
* nothing here; its repair is dropped upstream as unreadable.
|
|
15829
|
+
*/
|
|
15830
|
+
admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, byteLength) {
|
|
15831
|
+
if (!this.#hasBlockProfile(packetId)) return false;
|
|
15780
15832
|
const symbolSize = this.#trackConfig(packetId).symbolSize;
|
|
15781
|
-
if (symbolSize > 0 &&
|
|
15833
|
+
if (symbolSize > 0 && byteLength !== symbolSize) {
|
|
15782
15834
|
this.#repairSymbolSizeMismatchCount++;
|
|
15783
15835
|
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
15784
15836
|
console.warn(
|
|
15785
|
-
`[FECManager] Dropping repair symbol with invalid size: got ${
|
|
15837
|
+
`[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
|
|
15786
15838
|
);
|
|
15787
15839
|
}
|
|
15788
|
-
return
|
|
15840
|
+
return false;
|
|
15789
15841
|
}
|
|
15842
|
+
return true;
|
|
15843
|
+
}
|
|
15844
|
+
feedRepairSymbol(packetId, ssStart, ssbLength, rsId, repairData, catalogTrackName) {
|
|
15845
|
+
this.#fecStats.repairPackets++;
|
|
15846
|
+
this.#statsForPacket(packetId).repairPackets++;
|
|
15847
|
+
if (!this.#hasBlockProfile(packetId)) return null;
|
|
15848
|
+
if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null;
|
|
15790
15849
|
const fecData = repairData;
|
|
15791
15850
|
const k = this.#trackConfig(packetId).k;
|
|
15792
15851
|
const block = this.#isoLocatorFor(packetId, catalogTrackName).blockAt(ssStart);
|
|
@@ -15939,7 +15998,14 @@ var FECManager = class _FECManager {
|
|
|
15939
15998
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15940
15999
|
const k = trackConfig.k;
|
|
15941
16000
|
if (this.#completedBlocks.has(key)) return;
|
|
15942
|
-
this.#noteSbnSeen(
|
|
16001
|
+
this.#noteSbnSeen(
|
|
16002
|
+
sbn,
|
|
16003
|
+
packetId,
|
|
16004
|
+
catalogTrackName,
|
|
16005
|
+
"source",
|
|
16006
|
+
evidence.packetSequenceNumber,
|
|
16007
|
+
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
|
|
16008
|
+
);
|
|
15943
16009
|
const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
|
|
15944
16010
|
if (Number.isInteger(esi) && esi >= authoredLength) {
|
|
15945
16011
|
this.#failBlock(sbn, packetId, catalogTrackName);
|
|
@@ -16190,6 +16256,7 @@ var FECManager = class _FECManager {
|
|
|
16190
16256
|
this.#repairedBlocks.clear();
|
|
16191
16257
|
this.#materializedBlocks.clear();
|
|
16192
16258
|
this.#highestSbn.clear();
|
|
16259
|
+
this.#sourceFrontiers.clear();
|
|
16193
16260
|
this.#isoLocators.clear();
|
|
16194
16261
|
this.#sourceAnchors.clear();
|
|
16195
16262
|
this.#trackConfigs.clear();
|
|
@@ -18904,6 +18971,12 @@ var MmtpRouter = class {
|
|
|
18904
18971
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
18905
18972
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
18906
18973
|
#latestVideoSeqByStream = /* @__PURE__ */ new Map();
|
|
18974
|
+
/**
|
|
18975
|
+
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
18976
|
+
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
18977
|
+
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
18978
|
+
*/
|
|
18979
|
+
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
18907
18980
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18908
18981
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18909
18982
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -18978,6 +19051,7 @@ var MmtpRouter = class {
|
|
|
18978
19051
|
*/
|
|
18979
19052
|
#onPublisherRestart;
|
|
18980
19053
|
#publisherRestarts = 0;
|
|
19054
|
+
#restampedRecoveredSeqs = 0;
|
|
18981
19055
|
/** Inits delivered with no onTrackInit handler for their packetId (MOQT-01). */
|
|
18982
19056
|
#unmappedInitDeliveries = 0;
|
|
18983
19057
|
// FEC Payload IDs left unread because their (owner) packetId had no
|
|
@@ -19198,6 +19272,14 @@ var MmtpRouter = class {
|
|
|
19198
19272
|
get publisherRestartCount() {
|
|
19199
19273
|
return this.#publisherRestarts;
|
|
19200
19274
|
}
|
|
19275
|
+
/**
|
|
19276
|
+
* FEC-recovered source symbols whose reconstructed header named a
|
|
19277
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to:
|
|
19278
|
+
* a hop re-stamped the sequence after the sender protected the packet.
|
|
19279
|
+
*/
|
|
19280
|
+
get restampedRecoveredSequenceCount() {
|
|
19281
|
+
return this.#restampedRecoveredSeqs;
|
|
19282
|
+
}
|
|
19201
19283
|
/**
|
|
19202
19284
|
* Packets whose Source or Repair FEC Payload ID was left unread because
|
|
19203
19285
|
* their (owner) packetId had no configured `fec.blockProfile`: FEC not
|
|
@@ -19713,6 +19795,13 @@ var MmtpRouter = class {
|
|
|
19713
19795
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`
|
|
19714
19796
|
);
|
|
19715
19797
|
}
|
|
19798
|
+
if (fec.admitRepairSymbolSize && !fec.admitRepairSymbolSize(
|
|
19799
|
+
ownerPacketId,
|
|
19800
|
+
repair.ssStart,
|
|
19801
|
+
repair.ssbLength,
|
|
19802
|
+
repair.rsId,
|
|
19803
|
+
repair.symbolData.byteLength
|
|
19804
|
+
)) return;
|
|
19716
19805
|
const placement = fec.placeIsoRepair(ownerPacketId, catalogTrackName, repair.ssStart, repair.ssbLength);
|
|
19717
19806
|
if (placement.status !== "placed") return;
|
|
19718
19807
|
const blockStart = placement.block.start;
|
|
@@ -19842,6 +19931,7 @@ var MmtpRouter = class {
|
|
|
19842
19931
|
this.#trackSynced.delete(streamKey);
|
|
19843
19932
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
19844
19933
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
19934
|
+
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
19845
19935
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
19846
19936
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
19847
19937
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -20612,6 +20702,12 @@ var MmtpRouter = class {
|
|
|
20612
20702
|
} else if (fecUnreadable && info.fecPayloadId) {
|
|
20613
20703
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
20614
20704
|
}
|
|
20705
|
+
if (fecPayloadId && !overlapCopy) {
|
|
20706
|
+
this.#ssIdSeqOffsetByStream.set(
|
|
20707
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
20708
|
+
fecPayloadId.ssId - info.sequenceNumber >>> 0
|
|
20709
|
+
);
|
|
20710
|
+
}
|
|
20615
20711
|
if (!this.#fecManager || !info.fecPayloadId || parseSourceSymbol) {
|
|
20616
20712
|
if (this.#fecManager && info.fecPayloadId) {
|
|
20617
20713
|
duplicates.parsedSymbols.add(info.fecPayloadId.ssId);
|
|
@@ -21188,6 +21284,20 @@ var MmtpRouter = class {
|
|
|
21188
21284
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
21189
21285
|
if (ownerPacketId == null) return;
|
|
21190
21286
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
21287
|
+
const ssIdSeqOffset = this.#ssIdSeqOffsetByStream.get(
|
|
21288
|
+
this.#mediaStreamKey(ownerPacketId, catalogTrackName)
|
|
21289
|
+
);
|
|
21290
|
+
if (ssIdSeqOffset !== void 0) {
|
|
21291
|
+
result = {
|
|
21292
|
+
...result,
|
|
21293
|
+
symbols: result.symbols.map((sym) => {
|
|
21294
|
+
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
21295
|
+
if (wire === sym.packetSequenceNumber) return sym;
|
|
21296
|
+
this.#restampedRecoveredSeqs++;
|
|
21297
|
+
return { ...sym, packetSequenceNumber: wire };
|
|
21298
|
+
})
|
|
21299
|
+
};
|
|
21300
|
+
}
|
|
21191
21301
|
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
21192
21302
|
const deliveryProvenance = this.#fecManager?.blockDeliveryProvenance?.(
|
|
21193
21303
|
blockId,
|
|
@@ -23627,7 +23737,9 @@ var MulticastManager = class {
|
|
|
23627
23737
|
catalogTrackName
|
|
23628
23738
|
);
|
|
23629
23739
|
this.#configureTrackMapper(packetId, config);
|
|
23630
|
-
this.#router.
|
|
23740
|
+
if (this.#router.trackKindFor(packetId) !== trackType) {
|
|
23741
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
23742
|
+
}
|
|
23631
23743
|
}
|
|
23632
23744
|
/**
|
|
23633
23745
|
* Stop routing a stream's symbols to its Worker decoder. Returns false when
|
|
@@ -23708,6 +23820,14 @@ var MulticastManager = class {
|
|
|
23708
23820
|
);
|
|
23709
23821
|
}
|
|
23710
23822
|
}
|
|
23823
|
+
for (const [packetId, c] of this.#trackFecTiming) {
|
|
23824
|
+
if (c.deliveryWindowMs === void 0) continue;
|
|
23825
|
+
mfuTimeoutMs = Math.max(
|
|
23826
|
+
mfuTimeoutMs ?? 0,
|
|
23827
|
+
this.#fec.terminalRetentionMsForPacket(packetId) ?? 0,
|
|
23828
|
+
this.#hostMfuTimeoutMs ?? 0
|
|
23829
|
+
);
|
|
23830
|
+
}
|
|
23711
23831
|
const failbackWindowMs = deliveryWindowMs === void 0 ? minimumFailbackWindowMs : Math.max(deliveryWindowMs, minimumFailbackWindowMs ?? 0);
|
|
23712
23832
|
this.#transport.setFailbackWindowMs(failbackWindowMs ?? null);
|
|
23713
23833
|
this.#router.setMfuTimeoutMs(mfuTimeoutMs ?? this.#hostMfuTimeoutMs);
|
|
@@ -23891,6 +24011,7 @@ var MulticastManager = class {
|
|
|
23891
24011
|
setMfuTimeoutMs(ms) {
|
|
23892
24012
|
this.#router.setMfuTimeoutMs(ms);
|
|
23893
24013
|
this.#hostMfuTimeoutMs = this.#router.reassembler.timeoutMs;
|
|
24014
|
+
if (this.#trackFecTiming.size > 0) this.#applyStreamGlobalFecTiming();
|
|
23894
24015
|
}
|
|
23895
24016
|
setTrackCodec(packetId, codec) {
|
|
23896
24017
|
this.#router.setTrackCodec(packetId, codec);
|
|
@@ -24446,11 +24567,7 @@ var MulticastManager = class {
|
|
|
24446
24567
|
for (const [groupKey, roles] of resolvedRolesByGroup) {
|
|
24447
24568
|
if (!(hasSwitchingSetByGroup.get(groupKey) ?? false)) continue;
|
|
24448
24569
|
const presentRoles = new Set(roles.filter((r) => r !== "single"));
|
|
24449
|
-
const required = [
|
|
24450
|
-
"base",
|
|
24451
|
-
"delta",
|
|
24452
|
-
"repair"
|
|
24453
|
-
];
|
|
24570
|
+
const required = ["base", "repair"];
|
|
24454
24571
|
const missing = required.filter((r) => !presentRoles.has(r));
|
|
24455
24572
|
if (missing.length > 0) {
|
|
24456
24573
|
throw new Error(
|
|
@@ -24919,7 +25036,6 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24919
25036
|
repairTrack: opts.repairTrackName,
|
|
24920
25037
|
relayBlockSigEnabled: false
|
|
24921
25038
|
};
|
|
24922
|
-
client.configure(fecTrackConfig, rqWasm);
|
|
24923
25039
|
try {
|
|
24924
25040
|
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
24925
25041
|
blockProfile,
|
|
@@ -24939,6 +25055,14 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
24939
25055
|
}
|
|
24940
25056
|
throw e;
|
|
24941
25057
|
}
|
|
25058
|
+
fecTrackConfig.interleaveDepth = Math.min(
|
|
25059
|
+
MAX_FEC_RETENTION_BLOCKS,
|
|
25060
|
+
Math.max(
|
|
25061
|
+
interleaveDepthBlocks,
|
|
25062
|
+
opts.multicastManager.fecManager.isoRetentionBlocksForPacket(opts.packetId) ?? 0
|
|
25063
|
+
)
|
|
25064
|
+
);
|
|
25065
|
+
client.configure(fecTrackConfig, rqWasm);
|
|
24942
25066
|
let disposed = false;
|
|
24943
25067
|
return {
|
|
24944
25068
|
client,
|