@blockcast/mmt-container 0.4.0-main.f750d2a511b3 → 0.4.1-main.30f0611c24e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser-runtime.js +144 -67
- package/dist/browser-runtime.js.map +3 -3
- package/dist/fec-manager.d.ts +2 -15
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +105 -62
- package/dist/fec-manager.js.map +3 -3
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/iso-block-locator.d.ts +10 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +12 -0
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +119 -6
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-fec-session.d.ts +36 -3
- package/dist/mmtp-fec-session.d.ts.map +1 -1
- package/dist/mmtp-fec-session.js +114 -5
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/multicast-manager.js +105 -62
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +114 -5
- package/dist/no-modules.js.map +3 -3
- package/package.json +5 -5
- package/src/fec-manager.ts +23 -107
- package/src/held-layer-admission.ts +161 -0
- package/src/iso-block-locator.ts +13 -1
- package/src/mmtp-fec-session.ts +76 -3
package/README.md
CHANGED
|
@@ -270,7 +270,7 @@ per-commit `0.1.0-main.<sha>` prerelease from `stamp-prerelease.mjs`), and a
|
|
|
270
270
|
> Superseded by BLO-40665. Every package is now bumped in lockstep by a `v*`
|
|
271
271
|
> tag and the sibling ranges move with it, so the objection above no longer
|
|
272
272
|
> applies -- it was an argument against bumping *one* package. The set is at
|
|
273
|
-
> `0.4.
|
|
273
|
+
> `0.4.1`; see `RELEASES.md`.
|
|
274
274
|
|
|
275
275
|
#### Track-role convention (Phase 14)
|
|
276
276
|
|
package/dist/browser-runtime.js
CHANGED
|
@@ -12589,6 +12589,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12589
12589
|
* known block (a different length, or an overlap with another block or a
|
|
12590
12590
|
* span) fails closed: the repair symbol is dropped and no block changes.
|
|
12591
12591
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
12592
|
+
* A block so far past `newest` that stating it would retire the position
|
|
12593
|
+
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
12594
|
+
* this is slightly conservative (retirement measures that block from its
|
|
12595
|
+
* last SS_ID), dropping up to one block-length of repairs past the horizon
|
|
12596
|
+
* until a source moves `newest`. Placing it would turn everything
|
|
12597
|
+
* between into a repair-less span and leave every real repair behind it
|
|
12598
|
+
* `stale`. Sources move `newest` (`hold`, `observe`), so after a real outage
|
|
12599
|
+
* the first source back brings the next repair inside the horizon; until one
|
|
12600
|
+
* arrives, a stream's repairs alone cannot pass it.
|
|
12592
12601
|
*/
|
|
12593
12602
|
placeRepair(start, length) {
|
|
12594
12603
|
if (!Number.isSafeInteger(length) || length <= 0 || length > this.#kMax) {
|
|
@@ -12631,6 +12640,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12631
12640
|
};
|
|
12632
12641
|
}
|
|
12633
12642
|
}
|
|
12643
|
+
if (this.#newest !== void 0 && isoBlocksBehindLowerBound(this.#newest, start, this.#kMax) > this.#retentionBlocks) {
|
|
12644
|
+
return { status: "ahead", reason: `repair block ${start}+${length} is past the retention horizon ahead of ${this.#newest}` };
|
|
12645
|
+
}
|
|
12634
12646
|
let span;
|
|
12635
12647
|
let hole;
|
|
12636
12648
|
if (this.#coverageEnd === void 0) {
|
|
@@ -13245,6 +13257,79 @@ function decideGap(input) {
|
|
|
13245
13257
|
});
|
|
13246
13258
|
}
|
|
13247
13259
|
|
|
13260
|
+
// src/held-layer-admission.ts
|
|
13261
|
+
var HORIZON_CAP = 1073741824;
|
|
13262
|
+
function heldLayerAnchorHorizon(retentionBlocks, k) {
|
|
13263
|
+
return retentionBlocks === void 0 || k <= 0 ? HORIZON_CAP : Math.min(HORIZON_CAP, retentionBlocks * k);
|
|
13264
|
+
}
|
|
13265
|
+
var HeldLayerAdmission = class {
|
|
13266
|
+
#layerNames;
|
|
13267
|
+
#states;
|
|
13268
|
+
constructor(layers, heldLayers = [0]) {
|
|
13269
|
+
const held = new Set(heldLayers);
|
|
13270
|
+
this.#layerNames = new Set(layers.map((l) => l.repairTrackName));
|
|
13271
|
+
this.#states = layers.filter((l) => held.has(l.layer)).map((l) => ({ layer: l.layer, repairTrackName: l.repairTrackName, total: l.rsIdOffset + l.repairSymbols }));
|
|
13272
|
+
}
|
|
13273
|
+
/**
|
|
13274
|
+
* Judges one repair packet, after the 4.5 discards and the size check and
|
|
13275
|
+
* before it places a block. `repairTrackName` is the subscribed repair
|
|
13276
|
+
* track, never inferred from RS_ID; without it only (b) runs. A packet on a
|
|
13277
|
+
* repair track the catalog does not list is `'discard'` and anchors nothing.
|
|
13278
|
+
* `sourceFrontier` is the newest source SS_ID, if any: a repair more than
|
|
13279
|
+
* `horizon` past it is judged without moving the anchored state.
|
|
13280
|
+
*
|
|
13281
|
+
* @returns undefined to admit, `'discard'`, or the fail-closed reason.
|
|
13282
|
+
*/
|
|
13283
|
+
admit(repairTrackName, ssStart, rsbLength, horizon, sourceFrontier) {
|
|
13284
|
+
if (repairTrackName !== void 0 && !this.#layerNames.has(repairTrackName)) return "discard";
|
|
13285
|
+
const farAhead = sourceFrontier !== void 0 && serial32Precedes(sourceFrontier, ssStart) && serial32Distance(sourceFrontier, ssStart) > horizon;
|
|
13286
|
+
for (const state of this.#states) {
|
|
13287
|
+
let code;
|
|
13288
|
+
if (farAhead) {
|
|
13289
|
+
if (rsbLength < state.total) {
|
|
13290
|
+
if (state.layer > 0 && repairTrackName === state.repairTrackName) code = "below_own_track_total";
|
|
13291
|
+
else if (state.anchor !== void 0 || state.settled) code = "below_anchored_total";
|
|
13292
|
+
}
|
|
13293
|
+
} else {
|
|
13294
|
+
if (state.newest === void 0 || serial32Precedes(state.newest, ssStart)) state.newest = ssStart;
|
|
13295
|
+
const stale = (s) => serial32Distance(s, state.newest) > horizon;
|
|
13296
|
+
if (state.latestBelow !== void 0 && stale(state.latestBelow)) {
|
|
13297
|
+
delete state.latestBelow;
|
|
13298
|
+
delete state.latestBelowRsb;
|
|
13299
|
+
}
|
|
13300
|
+
if (state.anchor !== void 0 && stale(state.anchor)) state.settled = true;
|
|
13301
|
+
if (rsbLength < state.total) {
|
|
13302
|
+
if (state.layer > 0 && repairTrackName === state.repairTrackName) code = "below_own_track_total";
|
|
13303
|
+
else if (stale(ssStart)) continue;
|
|
13304
|
+
else if (state.settled || state.anchor !== void 0 && !serial32Precedes(ssStart, state.anchor)) code = "below_anchored_total";
|
|
13305
|
+
else if (state.latestBelow === void 0 || serial32Precedes(state.latestBelow, ssStart)) {
|
|
13306
|
+
state.latestBelow = ssStart;
|
|
13307
|
+
state.latestBelowRsb = rsbLength;
|
|
13308
|
+
}
|
|
13309
|
+
} else if (!state.settled && !stale(ssStart)) {
|
|
13310
|
+
if (state.anchor === void 0 || serial32Precedes(ssStart, state.anchor)) state.anchor = ssStart;
|
|
13311
|
+
if (state.latestBelow !== void 0 && !serial32Precedes(state.latestBelow, state.anchor)) {
|
|
13312
|
+
code = "below_anchored_total";
|
|
13313
|
+
ssStart = state.latestBelow;
|
|
13314
|
+
rsbLength = state.latestBelowRsb;
|
|
13315
|
+
}
|
|
13316
|
+
}
|
|
13317
|
+
}
|
|
13318
|
+
if (code !== void 0) {
|
|
13319
|
+
return {
|
|
13320
|
+
code,
|
|
13321
|
+
layer: state.layer,
|
|
13322
|
+
total: state.total,
|
|
13323
|
+
rsbLength,
|
|
13324
|
+
ssStart,
|
|
13325
|
+
...state.anchor === void 0 ? {} : { anchor: state.anchor }
|
|
13326
|
+
};
|
|
13327
|
+
}
|
|
13328
|
+
}
|
|
13329
|
+
return void 0;
|
|
13330
|
+
}
|
|
13331
|
+
};
|
|
13332
|
+
|
|
13248
13333
|
// src/fec-manager.ts
|
|
13249
13334
|
var RS_MAX_BLOCK_SYMBOLS = 255;
|
|
13250
13335
|
var WORKER_ERROR_LOG_CAP = 5;
|
|
@@ -16162,66 +16247,26 @@ var FECManager = class _FECManager {
|
|
|
16162
16247
|
const config = this.#trackConfigs.get(packetId);
|
|
16163
16248
|
const layers = config?.repairLayers;
|
|
16164
16249
|
if (layers === void 0 || layers.length === 0) return true;
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
if (states === void 0) {
|
|
16170
|
-
const held = new Set(config.heldLayers ?? [0]);
|
|
16171
|
-
states = layers.filter((l) => held.has(l.layer)).map((l) => ({ layer: l.layer, repairTrackName: l.repairTrackName, total: l.rsIdOffset + l.repairSymbols }));
|
|
16172
|
-
this.#heldLayerStates.set(streamKey, states);
|
|
16250
|
+
let admission = this.#heldLayerStates.get(streamKey);
|
|
16251
|
+
if (admission === void 0) {
|
|
16252
|
+
admission = new HeldLayerAdmission(layers, config.heldLayers);
|
|
16253
|
+
this.#heldLayerStates.set(streamKey, admission);
|
|
16173
16254
|
}
|
|
16174
|
-
const
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
delete state.latestBelowRsb;
|
|
16190
|
-
}
|
|
16191
|
-
if (state.anchor !== void 0 && stale(state.anchor)) state.settled = true;
|
|
16192
|
-
if (rsbLength < state.total) {
|
|
16193
|
-
if (state.layer > 0 && repairTrackName === state.repairTrackName) code = "below_own_track_total";
|
|
16194
|
-
else if (stale(ssStart)) continue;
|
|
16195
|
-
else if (state.settled || state.anchor !== void 0 && !serial32Precedes(ssStart, state.anchor)) code = "below_anchored_total";
|
|
16196
|
-
else if (state.latestBelow === void 0 || serial32Precedes(state.latestBelow, ssStart)) {
|
|
16197
|
-
state.latestBelow = ssStart;
|
|
16198
|
-
state.latestBelowRsb = rsbLength;
|
|
16199
|
-
}
|
|
16200
|
-
} else if (!state.settled && !stale(ssStart)) {
|
|
16201
|
-
if (state.anchor === void 0 || serial32Precedes(ssStart, state.anchor)) state.anchor = ssStart;
|
|
16202
|
-
if (state.latestBelow !== void 0 && !serial32Precedes(state.latestBelow, state.anchor)) {
|
|
16203
|
-
code = "below_anchored_total";
|
|
16204
|
-
ssStart = state.latestBelow;
|
|
16205
|
-
rsbLength = state.latestBelowRsb;
|
|
16206
|
-
}
|
|
16207
|
-
}
|
|
16208
|
-
}
|
|
16209
|
-
if (code !== void 0) {
|
|
16210
|
-
const reason = {
|
|
16211
|
-
code,
|
|
16212
|
-
layer: state.layer,
|
|
16213
|
-
total: state.total,
|
|
16214
|
-
rsbLength,
|
|
16215
|
-
ssStart,
|
|
16216
|
-
...state.anchor === void 0 ? {} : { anchor: state.anchor }
|
|
16217
|
-
};
|
|
16218
|
-
this.#fecFailClosed.set(streamKey, reason);
|
|
16219
|
-
this.#onFecFailClosed?.({ ...reason, packetId, catalogTrackName });
|
|
16220
|
-
console.warn(
|
|
16221
|
-
`[FECManager] FEC failed closed (fec-01 6.3.9) packetId=${packetId} track=${catalogTrackName ?? "-"}: ${JSON.stringify(reason)}`
|
|
16222
|
-
);
|
|
16223
|
-
return false;
|
|
16224
|
-
}
|
|
16255
|
+
const verdict = admission.admit(
|
|
16256
|
+
repairTrackName,
|
|
16257
|
+
ssStart,
|
|
16258
|
+
rsbLength,
|
|
16259
|
+
this.#layerAnchorHorizon(packetId),
|
|
16260
|
+
this.#sourceFrontiers.get(streamKey)?.sbn
|
|
16261
|
+
);
|
|
16262
|
+
if (verdict === "discard") return false;
|
|
16263
|
+
if (verdict !== void 0) {
|
|
16264
|
+
this.#fecFailClosed.set(streamKey, verdict);
|
|
16265
|
+
this.#onFecFailClosed?.({ ...verdict, packetId, catalogTrackName });
|
|
16266
|
+
console.warn(
|
|
16267
|
+
`[FECManager] FEC failed closed (fec-01 6.3.9) packetId=${packetId} track=${catalogTrackName ?? "-"}: ${JSON.stringify(verdict)}`
|
|
16268
|
+
);
|
|
16269
|
+
return false;
|
|
16225
16270
|
}
|
|
16226
16271
|
return true;
|
|
16227
16272
|
}
|
|
@@ -16231,15 +16276,13 @@ var FECManager = class _FECManager {
|
|
|
16231
16276
|
* times K, capped at 2^30 so compared serials stay inside one half-window.
|
|
16232
16277
|
*/
|
|
16233
16278
|
#layerAnchorHorizon(packetId) {
|
|
16234
|
-
const cap = 1073741824;
|
|
16235
16279
|
let blocks;
|
|
16236
16280
|
try {
|
|
16237
16281
|
blocks = this.isoRetentionBlocksForPacket(packetId);
|
|
16238
16282
|
} catch {
|
|
16239
16283
|
blocks = void 0;
|
|
16240
16284
|
}
|
|
16241
|
-
|
|
16242
|
-
return blocks === void 0 || k <= 0 ? cap : Math.min(cap, blocks * k);
|
|
16285
|
+
return heldLayerAnchorHorizon(blocks, this.#trackConfigs.get(packetId)?.k ?? 0);
|
|
16243
16286
|
}
|
|
16244
16287
|
/**
|
|
16245
16288
|
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), once,
|
|
@@ -27267,6 +27310,9 @@ var MmtpFecSession = class {
|
|
|
27267
27310
|
/** The newest SS_ID when the remembered SS_IDs were last pruned. */
|
|
27268
27311
|
#prunedAt;
|
|
27269
27312
|
#repairPacketId;
|
|
27313
|
+
#newestSource;
|
|
27314
|
+
#heldLayers;
|
|
27315
|
+
#anchorHorizon;
|
|
27270
27316
|
#stats = {
|
|
27271
27317
|
sourceSymbols: 0,
|
|
27272
27318
|
repairSymbols: 0,
|
|
@@ -27279,11 +27325,12 @@ var MmtpFecSession = class {
|
|
|
27279
27325
|
dropped: {},
|
|
27280
27326
|
sourceSymbolsByPath: { moq: 0, multicast: 0 },
|
|
27281
27327
|
repairSymbolsByPath: { moq: 0, multicast: 0 },
|
|
27282
|
-
mixedPath: { clean: 0, recovered: 0, failed: 0, released: 0 }
|
|
27328
|
+
mixedPath: { clean: 0, recovered: 0, failed: 0, released: 0 },
|
|
27329
|
+
failClosed: null
|
|
27283
27330
|
};
|
|
27284
27331
|
/**
|
|
27285
27332
|
* @throws when the catalog block lacks or misstates a field the session
|
|
27286
|
-
* needs: the block profile, K, T, `interleaveDepthMs` or
|
|
27333
|
+
* needs: the block profile, K, P_0 (`repairSymbols`), T, `interleaveDepthMs` or
|
|
27287
27334
|
* `reorderToleranceMs`. None is defaulted.
|
|
27288
27335
|
*/
|
|
27289
27336
|
constructor(config) {
|
|
@@ -27297,6 +27344,7 @@ var MmtpFecSession = class {
|
|
|
27297
27344
|
}
|
|
27298
27345
|
this.algorithm = fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq";
|
|
27299
27346
|
this.sourceSymbols = requirePositiveInteger(fec.sourceSymbols, "fec.sourceSymbols");
|
|
27347
|
+
this.repairSymbols = requirePositiveInteger(fec.repairSymbols, "fec.repairSymbols");
|
|
27300
27348
|
this.symbolSize = requirePositiveInteger(fec.symbolSize, "fec.symbolSize");
|
|
27301
27349
|
const interleaveDepthMs = requireNumber(fec.interleaveDepthMs, "fec.interleaveDepthMs");
|
|
27302
27350
|
const reorderToleranceMs = requireNumber(fec.reorderToleranceMs, "fec.reorderToleranceMs");
|
|
@@ -27304,6 +27352,18 @@ var MmtpFecSession = class {
|
|
|
27304
27352
|
fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs),
|
|
27305
27353
|
interleaveDepthMs
|
|
27306
27354
|
);
|
|
27355
|
+
this.#heldLayers = new HeldLayerAdmission(
|
|
27356
|
+
config.repairLayers ?? [
|
|
27357
|
+
{
|
|
27358
|
+
layer: 0,
|
|
27359
|
+
repairTrackName: typeof fec.repairTrack === "string" ? fec.repairTrack : "",
|
|
27360
|
+
rsIdOffset: 0,
|
|
27361
|
+
repairSymbols: this.repairSymbols
|
|
27362
|
+
}
|
|
27363
|
+
],
|
|
27364
|
+
config.heldLayers
|
|
27365
|
+
);
|
|
27366
|
+
this.#anchorHorizon = heldLayerAnchorHorizon(this.retentionBlocks, this.sourceSymbols);
|
|
27307
27367
|
if (typeof config.Decoder !== "function") {
|
|
27308
27368
|
throw new Error("MmtpFecSession: a decoder constructor (wasm_bindgen.MmtFecDecoder) is required");
|
|
27309
27369
|
}
|
|
@@ -27326,7 +27386,8 @@ var MmtpFecSession = class {
|
|
|
27326
27386
|
dropped: { ...this.#stats.dropped },
|
|
27327
27387
|
sourceSymbolsByPath: { ...this.#stats.sourceSymbolsByPath },
|
|
27328
27388
|
repairSymbolsByPath: { ...this.#stats.repairSymbolsByPath },
|
|
27329
|
-
mixedPath: { ...this.#stats.mixedPath }
|
|
27389
|
+
mixedPath: { ...this.#stats.mixedPath },
|
|
27390
|
+
failClosed: this.#stats.failClosed && { ...this.#stats.failClosed }
|
|
27330
27391
|
};
|
|
27331
27392
|
}
|
|
27332
27393
|
/**
|
|
@@ -27351,6 +27412,7 @@ var MmtpFecSession = class {
|
|
|
27351
27412
|
this.#stats.sourceSymbols++;
|
|
27352
27413
|
this.#stats.sourceSymbolsByPath[path]++;
|
|
27353
27414
|
this.#noteNewest(ssId);
|
|
27415
|
+
if (this.#newestSource === void 0 || serial32Precedes(this.#newestSource, ssId)) this.#newestSource = ssId;
|
|
27354
27416
|
const start = this.#blockStartOf(ssId);
|
|
27355
27417
|
const block = start === void 0 ? void 0 : this.#blocks.get(start);
|
|
27356
27418
|
if (block) {
|
|
@@ -27379,14 +27441,17 @@ var MmtpFecSession = class {
|
|
|
27379
27441
|
* Feeds one object of the repair track: a whole MMTP repair packet (ISO/IEC
|
|
27380
27442
|
* 23008-1 C.5.3). A repair track carries one repair flow, so the first
|
|
27381
27443
|
* repair packet fixes its packet ID and a packet of any other is refused.
|
|
27382
|
-
* `path` is where it was received, as for addSource().
|
|
27444
|
+
* `path` is where it was received, as for addSource(). `repairTrackName`
|
|
27445
|
+
* is the repair track it was received on, for the 6.3.9 own-track rule; a
|
|
27446
|
+
* track the layers do not list is refused as `repair:unlisted-track`.
|
|
27383
27447
|
*
|
|
27384
27448
|
* @returns the protected packets this repair symbol recovered, as for
|
|
27385
27449
|
* addSource().
|
|
27386
27450
|
*/
|
|
27387
|
-
addRepair(packet, path = "moq") {
|
|
27451
|
+
addRepair(packet, path = "moq", repairTrackName) {
|
|
27388
27452
|
const decoder = this.#decoder;
|
|
27389
27453
|
if (!decoder) return this.#drop("repair:released");
|
|
27454
|
+
if (this.#stats.failClosed) return this.#drop("repair:fail-closed");
|
|
27390
27455
|
const pathBit = PATH_BITS[path];
|
|
27391
27456
|
if (!pathBit) return this.#drop("repair:unknown-path");
|
|
27392
27457
|
let header;
|
|
@@ -27407,6 +27472,18 @@ var MmtpFecSession = class {
|
|
|
27407
27472
|
if (this.algorithm === "reed-solomon" && frame.ssbLength + frame.rsbLength > 255) {
|
|
27408
27473
|
return this.#drop("repair:rs-block-length");
|
|
27409
27474
|
}
|
|
27475
|
+
const verdict = this.#heldLayers.admit(
|
|
27476
|
+
repairTrackName,
|
|
27477
|
+
frame.ssStart,
|
|
27478
|
+
frame.rsbLength,
|
|
27479
|
+
this.#anchorHorizon,
|
|
27480
|
+
this.#newestSource
|
|
27481
|
+
);
|
|
27482
|
+
if (verdict === "discard") return this.#drop("repair:unlisted-track");
|
|
27483
|
+
if (verdict !== void 0) {
|
|
27484
|
+
this.#stats.failClosed = verdict;
|
|
27485
|
+
return this.#drop("repair:fail-closed");
|
|
27486
|
+
}
|
|
27410
27487
|
const start = frame.ssStart;
|
|
27411
27488
|
let block = this.#blocks.get(start);
|
|
27412
27489
|
if (block && block.ssbLength !== frame.ssbLength) return this.#drop("repair:conflicting-ssb-length");
|