@blockcast/mmt-container 0.1.0-main.30d2c7ed30b2 → 0.1.0-main.47cd40b694a0
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 +314 -85
- package/dist/browser-runtime.js.map +2 -2
- package/dist/carp-catalog.d.ts +2 -5
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.d.ts +35 -0
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +69 -1
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/fec-manager.d.ts +46 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +129 -34
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +6 -2
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +45 -36
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +2 -2
- package/dist/media-router.d.ts +12 -0
- package/dist/media-router.d.ts.map +1 -1
- package/dist/media-router.js +5 -19
- package/dist/media-router.js.map +2 -2
- package/dist/mfu-reassembler.d.ts +60 -1
- package/dist/mfu-reassembler.d.ts.map +1 -1
- package/dist/mfu-reassembler.js +59 -20
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.js +58 -20
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +58 -20
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-decode-pipeline.js +58 -20
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.js +58 -20
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +30 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +248 -74
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +58 -20
- package/dist/no-modules.js.map +2 -2
- package/dist/track-session.d.ts +7 -11
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +10 -20
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +58 -20
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +7 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +14 -5
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +15 -5
- package/package.json +6 -6
- package/src/carp-catalog.ts +2 -5
- package/src/catalog-fec-params.ts +59 -0
- package/src/fec-manager.ts +168 -18
- package/src/fec-worker-setup.ts +37 -11
- package/src/index.ts +7 -0
- package/src/media-router.ts +13 -6
- package/src/mfu-reassembler.ts +155 -24
- package/src/multicast-manager.ts +106 -22
- package/src/track-session.ts +20 -62
package/dist/browser-runtime.js
CHANGED
|
@@ -126,7 +126,7 @@ var init_fec_worker_client = __esm({
|
|
|
126
126
|
*/
|
|
127
127
|
feedSource(ssId, data, ts, alta) {
|
|
128
128
|
if (__privateGet(this, _disposed5))
|
|
129
|
-
|
|
129
|
+
throw new Error("[FecWorkerClient] feedSource on a disposed client");
|
|
130
130
|
const cmd = alta ? {
|
|
131
131
|
type: "feedSource",
|
|
132
132
|
ssId,
|
|
@@ -149,7 +149,7 @@ var init_fec_worker_client = __esm({
|
|
|
149
149
|
*/
|
|
150
150
|
feedRepair(ssStart, ssbLength, rsId, data, ts) {
|
|
151
151
|
if (__privateGet(this, _disposed5))
|
|
152
|
-
|
|
152
|
+
throw new Error("[FecWorkerClient] feedRepair on a disposed client");
|
|
153
153
|
__privateGet(this, _worker).postMessage({
|
|
154
154
|
type: "feedRepair",
|
|
155
155
|
ssStart,
|
|
@@ -164,7 +164,7 @@ var init_fec_worker_client = __esm({
|
|
|
164
164
|
*/
|
|
165
165
|
relayBlockSig(sbn, sig, hash) {
|
|
166
166
|
if (__privateGet(this, _disposed5))
|
|
167
|
-
|
|
167
|
+
throw new Error("[FecWorkerClient] relayBlockSig on a disposed client");
|
|
168
168
|
__privateGet(this, _worker).postMessage({ type: "relayBlockSig", sbn, sig, hash }, [sig, hash]);
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -175,7 +175,7 @@ var init_fec_worker_client = __esm({
|
|
|
175
175
|
*/
|
|
176
176
|
cleanup(currentSbn) {
|
|
177
177
|
if (__privateGet(this, _disposed5))
|
|
178
|
-
|
|
178
|
+
throw new Error("[FecWorkerClient] cleanup on a disposed client");
|
|
179
179
|
if (!Number.isInteger(currentSbn) || currentSbn < 0 || currentSbn > 4294967295) {
|
|
180
180
|
throw new Error("[FecWorkerClient] cleanup: SBN must be a uint32");
|
|
181
181
|
}
|
|
@@ -188,7 +188,7 @@ var init_fec_worker_client = __esm({
|
|
|
188
188
|
/** Reset this track's decoder epoch while preserving Worker configuration. */
|
|
189
189
|
reset() {
|
|
190
190
|
if (__privateGet(this, _disposed5))
|
|
191
|
-
|
|
191
|
+
throw new Error("[FecWorkerClient] reset on a disposed client");
|
|
192
192
|
__privateWrapper(this, _pendingResets)._++;
|
|
193
193
|
__privateSet(this, _cleanupInFlight, null);
|
|
194
194
|
__privateGet(this, _queuedCleanupSbns).clear();
|
|
@@ -218,6 +218,15 @@ var init_fec_worker_client = __esm({
|
|
|
218
218
|
onError(cb) {
|
|
219
219
|
__privateSet(this, _onError, cb);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* True once dispose() ran. A disposed client cannot decode, fill, or
|
|
223
|
+
* acknowledge anything, so routing symbols to it discards them; every
|
|
224
|
+
* command method (feedSource, feedRepair, relayBlockSig, cleanup, reset)
|
|
225
|
+
* throws rather than pretend otherwise. Callers check this first.
|
|
226
|
+
*/
|
|
227
|
+
get disposed() {
|
|
228
|
+
return __privateGet(this, _disposed5);
|
|
229
|
+
}
|
|
221
230
|
/**
|
|
222
231
|
* Dispose the Worker. Sends dispose command then terminates.
|
|
223
232
|
* Idempotent — safe to call multiple times.
|
|
@@ -1020,6 +1029,9 @@ function checkedSampleEnd(offset, byteLength) {
|
|
|
1020
1029
|
return Number.isSafeInteger(end) && end <= 4294967295 ? end : null;
|
|
1021
1030
|
}
|
|
1022
1031
|
var COMPLETED_ADDRESS_WINDOW_MULTIPLE = 2;
|
|
1032
|
+
function parkedRunHoldsASlot(hasOpenRun, fragmentCount) {
|
|
1033
|
+
return !hasOpenRun && fragmentCount > 0;
|
|
1034
|
+
}
|
|
1023
1035
|
var _buffers, _timeouts, _activeDataUnits, _pendingContinuations, _emitted, _emittedOrder, _completed, _completedOrder, _timeoutMs, _maxBuffered, _nextAdmissionSeq, _MFUReassembler_instances, addAssociatedFragment_fn, parkContinuation_fn, drainPendingContinuations_fn, incompleteRunCount_fn, evictLeastRecentlyAdmitted_fn, releaseSlot_fn, reject_fn, associateDataUnit_fn, tryReassemble_fn, assemble_fn, setTimeout_fn, clearPendingTimeout_fn, armHeadlessPendingTimeout_fn, deletePendingRun_fn, onPendingTimeout_fn, clearTimeout_fn, markEmitted_fn, markCompleted_fn, orderValue_fn, removeActiveDataUnitForBuffer_fn, openRunAt_fn, onTimeout_fn, pendingDebugSamples_fn;
|
|
1024
1036
|
var MFUReassembler = class {
|
|
1025
1037
|
constructor(options) {
|
|
@@ -1255,12 +1267,28 @@ var MFUReassembler = class {
|
|
|
1255
1267
|
this.stats.outOfOrderFragments = 0;
|
|
1256
1268
|
}
|
|
1257
1269
|
/**
|
|
1258
|
-
* Get number of pending MFUs
|
|
1270
|
+
* Get number of pending MFUs: engine buffers plus every headless parked data
|
|
1271
|
+
* unit that holds a slot.
|
|
1272
|
+
*
|
|
1273
|
+
* This is not one of the four charging sites, but it shares their second term,
|
|
1274
|
+
* so it takes the same rule. Rust's public `buffered_count()` is
|
|
1275
|
+
* `inner.buffered_count() + unopened_parked_run_count()`, and that count is
|
|
1276
|
+
* `parked_run_holds_a_slot` — so filtering here on the open run alone would
|
|
1277
|
+
* report a phantom slot for an empty published queue in TypeScript and not in
|
|
1278
|
+
* Rust, out of a *host-observable* counter (`getStatus().bufferedMFUs`). Same
|
|
1279
|
+
* state, two numbers, decided by which engine the host loaded: the divergence
|
|
1280
|
+
* class this file exists to close, so the public counters have to agree too.
|
|
1281
|
+
*
|
|
1282
|
+
* Distinct from `#incompleteRunCount`, which sums `#activeDataUnits` rather
|
|
1283
|
+
* than `#buffers`. Those are different quantities by design and are not being
|
|
1284
|
+
* merged; only the parked term they share is required to agree.
|
|
1259
1285
|
*/
|
|
1260
1286
|
get pendingCount() {
|
|
1261
1287
|
let count = __privateGet(this, _buffers).size;
|
|
1262
|
-
for (const address of __privateGet(this, _pendingContinuations)
|
|
1263
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address)
|
|
1288
|
+
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1289
|
+
if (parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1290
|
+
count++;
|
|
1291
|
+
}
|
|
1264
1292
|
}
|
|
1265
1293
|
return count;
|
|
1266
1294
|
}
|
|
@@ -1323,24 +1351,28 @@ addAssociatedFragment_fn = function(fragment, runKey, address, startedAt) {
|
|
|
1323
1351
|
};
|
|
1324
1352
|
parkContinuation_fn = function(address, fragment) {
|
|
1325
1353
|
let pending = __privateGet(this, _pendingContinuations).get(address);
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
if (
|
|
1330
|
-
|
|
1331
|
-
__privateMethod(this, _MFUReassembler_instances, reject_fn).call(this, "active-data-unit-limit", "active MFU data-unit limit reached");
|
|
1332
|
-
}
|
|
1354
|
+
const open = __privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address);
|
|
1355
|
+
const alreadyCharged = open !== void 0 || parkedRunHoldsASlot(open !== void 0, pending?.fragments.size ?? 0);
|
|
1356
|
+
if (!alreadyCharged && __privateMethod(this, _MFUReassembler_instances, incompleteRunCount_fn).call(this) >= __privateGet(this, _maxBuffered)) {
|
|
1357
|
+
if (!__privateMethod(this, _MFUReassembler_instances, evictLeastRecentlyAdmitted_fn).call(this)) {
|
|
1358
|
+
__privateMethod(this, _MFUReassembler_instances, reject_fn).call(this, "active-data-unit-limit", "active MFU data-unit limit reached");
|
|
1333
1359
|
}
|
|
1334
|
-
|
|
1360
|
+
}
|
|
1361
|
+
if (pending === void 0) {
|
|
1335
1362
|
pending = {
|
|
1336
1363
|
fragments: /* @__PURE__ */ new Map(),
|
|
1337
|
-
startedAt,
|
|
1338
|
-
admissionSeq: open
|
|
1364
|
+
startedAt: Date.now(),
|
|
1365
|
+
admissionSeq: open !== void 0 ? open[1].admissionSeq : __privateWrapper(this, _nextAdmissionSeq)._++
|
|
1339
1366
|
};
|
|
1340
|
-
if (
|
|
1367
|
+
if (open === void 0 && __privateGet(this, _timeoutMs) !== null) {
|
|
1341
1368
|
pending.timeoutId = setTimeout(() => __privateMethod(this, _MFUReassembler_instances, onPendingTimeout_fn).call(this, address), __privateGet(this, _timeoutMs));
|
|
1342
1369
|
}
|
|
1343
1370
|
__privateGet(this, _pendingContinuations).set(address, pending);
|
|
1371
|
+
} else if (!alreadyCharged) {
|
|
1372
|
+
pending.admissionSeq = __privateWrapper(this, _nextAdmissionSeq)._++;
|
|
1373
|
+
pending.startedAt = Date.now();
|
|
1374
|
+
__privateMethod(this, _MFUReassembler_instances, clearPendingTimeout_fn).call(this, address);
|
|
1375
|
+
__privateMethod(this, _MFUReassembler_instances, armHeadlessPendingTimeout_fn).call(this, address);
|
|
1344
1376
|
}
|
|
1345
1377
|
if (pending.fragments.has(fragment.fragmentCounter)) {
|
|
1346
1378
|
__privateMethod(this, _MFUReassembler_instances, reject_fn).call(this, "fragment-counter-mismatch", "duplicate queued continuation counter would replace retained media");
|
|
@@ -1368,12 +1400,16 @@ drainPendingContinuations_fn = function(address, runKey) {
|
|
|
1368
1400
|
}
|
|
1369
1401
|
}
|
|
1370
1402
|
};
|
|
1371
|
-
/** Every open run plus every headless parked data unit
|
|
1372
|
-
* This is the quantity maxBuffered bounds.
|
|
1403
|
+
/** Every open run plus every headless parked data unit that holds a slot,
|
|
1404
|
+
* one slot each. This is the quantity maxBuffered bounds. Membership is
|
|
1405
|
+
* `parkedRunHoldsASlot`, the same rule #evictLeastRecentlyAdmitted offers as
|
|
1406
|
+
* candidates, so nothing can be counted here that eviction cannot reclaim. */
|
|
1373
1407
|
incompleteRunCount_fn = function() {
|
|
1374
1408
|
let count = __privateGet(this, _activeDataUnits).size;
|
|
1375
|
-
for (const address of __privateGet(this, _pendingContinuations)
|
|
1376
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address)
|
|
1409
|
+
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1410
|
+
if (parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1411
|
+
count++;
|
|
1412
|
+
}
|
|
1377
1413
|
}
|
|
1378
1414
|
return count;
|
|
1379
1415
|
};
|
|
@@ -1388,6 +1424,12 @@ incompleteRunCount_fn = function() {
|
|
|
1388
1424
|
* Returns false only if no slot is charged, which cannot happen at the bound
|
|
1389
1425
|
* (`maxBuffered` is a positive integer); admission then falls back to the
|
|
1390
1426
|
* fail-closed `active-data-unit-limit` reject, which stays a stable host code.
|
|
1427
|
+
* That holds because the candidate set here is built from the same
|
|
1428
|
+
* `parkedRunHoldsASlot` rule `#incompleteRunCount` counts by, so reaching the
|
|
1429
|
+
* bound implies at least one candidate. Filtering one and not the other would
|
|
1430
|
+
* make the claim false: a queue counted but not offered charges a slot no
|
|
1431
|
+
* eviction can reclaim, and the receiver refuses every later data unit
|
|
1432
|
+
* permanently.
|
|
1391
1433
|
*/
|
|
1392
1434
|
evictLeastRecentlyAdmitted_fn = function() {
|
|
1393
1435
|
let victimAddress;
|
|
@@ -1399,7 +1441,9 @@ evictLeastRecentlyAdmitted_fn = function() {
|
|
|
1399
1441
|
}
|
|
1400
1442
|
}
|
|
1401
1443
|
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1402
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0)
|
|
1444
|
+
if (!parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1445
|
+
continue;
|
|
1446
|
+
}
|
|
1403
1447
|
if (pending.admissionSeq < victimSeq) {
|
|
1404
1448
|
victimSeq = pending.admissionSeq;
|
|
1405
1449
|
victimAddress = address;
|
|
@@ -1434,7 +1478,10 @@ associateDataUnit_fn = function(fragment, runKey, address) {
|
|
|
1434
1478
|
const fi = fragment.fragmentationIndicator;
|
|
1435
1479
|
if (fi === 1) {
|
|
1436
1480
|
const parked = __privateGet(this, _pendingContinuations).get(address);
|
|
1437
|
-
const inheritsParkedSlot = (
|
|
1481
|
+
const inheritsParkedSlot = parkedRunHoldsASlot(
|
|
1482
|
+
__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0,
|
|
1483
|
+
parked?.fragments.size ?? 0
|
|
1484
|
+
);
|
|
1438
1485
|
const sampleIdentity = hasSampleIdentity(fragment);
|
|
1439
1486
|
const hasSampleFields = hasAnySampleIdentityField(fragment);
|
|
1440
1487
|
const hasItemIdentity = fragment.itemId !== void 0;
|
|
@@ -8501,6 +8548,15 @@ function deriveFecInterleaveDepth(interleaveDepthMs, mediaUnitDurationMs) {
|
|
|
8501
8548
|
}
|
|
8502
8549
|
return Math.max(1, Math.floor(interleaveDepthMs / mediaUnitDurationMs + 0.5));
|
|
8503
8550
|
}
|
|
8551
|
+
function fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs) {
|
|
8552
|
+
if (!Number.isFinite(interleaveDepthMs) || !(interleaveDepthMs > 0)) {
|
|
8553
|
+
throw new Error(`[FEC] interleaveDepthMs must be a finite value > 0 (got ${interleaveDepthMs}ms). Fix encoder config.`);
|
|
8554
|
+
}
|
|
8555
|
+
if (!(reorderToleranceMs >= 0) || !Number.isFinite(reorderToleranceMs)) {
|
|
8556
|
+
throw new Error(`[FEC] reorderToleranceMs must be a finite value >= 0 (got ${reorderToleranceMs}ms). It is a catalog value (fec.reorderToleranceMs), not a local default.`);
|
|
8557
|
+
}
|
|
8558
|
+
return Math.ceil(interleaveDepthMs + reorderToleranceMs);
|
|
8559
|
+
}
|
|
8504
8560
|
function parseRepairPacket(packet) {
|
|
8505
8561
|
const parsed = parseMoqRepairFrame(packet);
|
|
8506
8562
|
if (!parsed)
|
|
@@ -8602,32 +8658,18 @@ function computeFecLossWindowMs(fecInterleaveMs, fecK, jitterBufferMs) {
|
|
|
8602
8658
|
function computeFecDeliveryWindowMs(config) {
|
|
8603
8659
|
const fecInterleaveMs = config.interleaveDepthMs;
|
|
8604
8660
|
const fecK = config.sourceSymbols;
|
|
8605
|
-
if (fecInterleaveMs <= 0) {
|
|
8661
|
+
if (!Number.isFinite(fecInterleaveMs) || fecInterleaveMs <= 0) {
|
|
8606
8662
|
throw new Error(
|
|
8607
8663
|
`[TrackSession] fecInterleaveMs=${fecInterleaveMs}. Derive a positive FEC interleave window from the stream catalog.`
|
|
8608
8664
|
);
|
|
8609
8665
|
}
|
|
8610
|
-
if (fecK <= 0) {
|
|
8666
|
+
if (!Number.isFinite(fecK) || fecK <= 0) {
|
|
8611
8667
|
throw new Error(
|
|
8612
8668
|
`[TrackSession] fecK=${fecK}. Derive a positive FEC source-symbol count from the stream catalog.`
|
|
8613
8669
|
);
|
|
8614
8670
|
}
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
const mediaUnitMs = 1e3 / config.mediaUnitsPerSecond;
|
|
8618
|
-
const interleaveUnits = deriveFecInterleaveDepth(fecInterleaveMs, mediaUnitMs);
|
|
8619
|
-
const deliverySymbols = fecK + Math.max(0, config.repairSymbols ?? 0);
|
|
8620
|
-
spansMs.push(deliverySymbols * interleaveUnits * mediaUnitMs);
|
|
8621
|
-
}
|
|
8622
|
-
if (config.symbolSize && config.symbolSize > 0 && config.bandwidthBps && config.bandwidthBps > 0) {
|
|
8623
|
-
const repairSymbols = Math.max(0, config.repairSymbols ?? 0);
|
|
8624
|
-
spansMs.push(
|
|
8625
|
-
(fecK + repairSymbols) * config.symbolSize * 8 * 1e3 / config.bandwidthBps
|
|
8626
|
-
);
|
|
8627
|
-
}
|
|
8628
|
-
const coreMs = Math.max(...spansMs);
|
|
8629
|
-
const marginMs = config.jitterBufferMs !== void 0 && config.jitterBufferMs >= 0 ? config.jitterBufferMs : fecInterleaveMs;
|
|
8630
|
-
return Math.ceil(coreMs) + Math.ceil(marginMs);
|
|
8671
|
+
if (config.jitterBufferMs === void 0) return Math.ceil(fecInterleaveMs);
|
|
8672
|
+
return fecBlockBudgetMs(fecInterleaveMs, config.jitterBufferMs);
|
|
8631
8673
|
}
|
|
8632
8674
|
function computeFecDeliveryWindowMediaUnits(config, timestampTimescale) {
|
|
8633
8675
|
if (!Number.isFinite(timestampTimescale) || timestampTimescale <= 0) {
|
|
@@ -8786,7 +8828,11 @@ var TrackSession = class {
|
|
|
8786
8828
|
if (__privateGet(this, _state) !== "multicast" && __privateGet(this, _state) !== "amt") return;
|
|
8787
8829
|
__privateSet(this, _previousPrimary, __privateGet(this, _state));
|
|
8788
8830
|
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "failing");
|
|
8789
|
-
const hysteresisMs = computeFecLossWindowMs(
|
|
8831
|
+
const hysteresisMs = computeFecLossWindowMs(
|
|
8832
|
+
this.config.fecInterleaveMs,
|
|
8833
|
+
this.config.fecK,
|
|
8834
|
+
this.config.fecReorderToleranceMs
|
|
8835
|
+
);
|
|
8790
8836
|
__privateSet(this, _hysteresisTimer, setTimeout(() => {
|
|
8791
8837
|
this.hysteresisExpired();
|
|
8792
8838
|
}, hysteresisMs));
|
|
@@ -9111,7 +9157,7 @@ function newFecCounters() {
|
|
|
9111
9157
|
greenFillFrames: 0
|
|
9112
9158
|
};
|
|
9113
9159
|
}
|
|
9114
|
-
var _fecDecoders, _workerClients, _syncDecoderBlockOwners, _decoderBlockOwners, _fecK, _fecSymbolSize, _fecTimeoutMs, _trackConfigs, _fecStats, _fecTrackStats, _fecWorkerStats, _fecStatsObservers, _activeBlocks, _activeBlockDeadlinesMs, _activeBlockTimeoutOwners, _lifecycleTrace, _pendingWorkerCleanups, _pendingWorkerCleanupClients, _blockSourceCounts, _blockSourceEsis, _blockRepairRsIds, _completedBlocks, _seenSymbols, _blockPathCounts, _blockCatalogTrackNames, _startupAlignedPackets, _startupPartialBlocks, _startupRequireRepairReady, _startupRepairReadyPackets, _startupRepairBoundaryCounts, _startupRepairFailOpenPackets, _cleanlyCompletedBlocks, _repairRequestedBlocks, _repairDeadlines, _workerRecoveredBlocks, _fpsDetected, _fecFps, _fecInterleaveDepthMs, _workerErrorCounts, _repairSymbolSizeMismatchCount, _FECManager_instances, streamKey_fn, belongsToPacket_fn, belongsToStream_fn, packetIdsForStreamKeys_fn, blockKey_fn, parseBlockKey_fn, decoderForPacket_fn, workerForPacket_fn, claimDecoderBlock_fn, decoderBlockCatalogTrackName_fn, resetDecoderBlockOwners_fn, discardFecDecoderClient_fn, assertExclusiveDecoderClient_fn, statsForPacket_fn, markPathBlockComplete_fn, clearRepairDeadline_fn, requestRepair_fn, traceLifecycle_fn, defaultTrackConfig_fn, resolveTrackConfig_fn, computeTimeout_fn, repairDeadlineMs_fn, repairGraceMs_fn, armBlockTimeout_fn, upsertTrackConfig_fn, normalizeSymbolData_fn, blockKeysFor_fn, observeBlockCatalogTrackName_fn, markStartupPartial_fn, routeSyncCleanup_fn, failBlock_fn;
|
|
9160
|
+
var _fecDecoders, _workerClients, _syncDecoderBlockOwners, _decoderBlockOwners, _fecK, _fecSymbolSize, _fecTimeoutMs, _trackConfigs, _fecStats, _fecTrackStats, _fecWorkerStats, _fecStatsObservers, _activeBlocks, _activeBlockDeadlinesMs, _activeBlockTimeoutOwners, _lifecycleTrace, _pendingWorkerCleanups, _pendingWorkerCleanupClients, _blockSourceCounts, _blockSourceEsis, _blockRepairRsIds, _completedBlocks, _seenSymbols, _blockPathCounts, _blockCatalogTrackNames, _startupAlignedPackets, _startupPartialBlocks, _startupRequireRepairReady, _startupRepairReadyPackets, _startupRepairBoundaryCounts, _startupRepairFailOpenPackets, _cleanlyCompletedBlocks, _repairRequestedBlocks, _repairDeadlines, _workerRecoveredBlocks, _fpsDetected, _fecFps, _fecInterleaveDepthMs, _workerErrorCounts, _decoderUnavailableEvents, _repairSymbolSizeMismatchCount, _FECManager_instances, streamKey_fn, belongsToPacket_fn, belongsToStream_fn, packetIdsForStreamKeys_fn, parseStreamKey_fn, blockKey_fn, parseBlockKey_fn, decoderForPacket_fn, workerForPacket_fn, routableWorkerForPacket_fn, claimDecoderBlock_fn, decoderBlockCatalogTrackName_fn, resetDecoderBlockOwners_fn, discardFecDecoderClient_fn, assertExclusiveDecoderClient_fn, statsForPacket_fn, markPathBlockComplete_fn, clearRepairDeadline_fn, requestRepair_fn, traceLifecycle_fn, defaultTrackConfig_fn, resolveTrackConfig_fn, computeTimeout_fn, repairDeadlineMs_fn, repairGraceMs_fn, armBlockTimeout_fn, upsertTrackConfig_fn, normalizeSymbolData_fn, blockKeysFor_fn, observeBlockCatalogTrackName_fn, markStartupPartial_fn, retireWorker_fn, releaseWorkerClient_fn, settleOwedCleanup_fn, evictDisposedWorker_fn, routeSyncCleanup_fn, failBlock_fn;
|
|
9115
9161
|
var FECManager = class {
|
|
9116
9162
|
constructor() {
|
|
9117
9163
|
__privateAdd(this, _FECManager_instances);
|
|
@@ -9215,6 +9261,7 @@ var FECManager = class {
|
|
|
9215
9261
|
// validation harness — which caps headless warnings at 500 — fails even
|
|
9216
9262
|
// though the errors are duplicates of a single underlying event.
|
|
9217
9263
|
__privateAdd(this, _workerErrorCounts, /* @__PURE__ */ new Map());
|
|
9264
|
+
__privateAdd(this, _decoderUnavailableEvents, 0);
|
|
9218
9265
|
__privateAdd(this, _repairSymbolSizeMismatchCount, 0);
|
|
9219
9266
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
9220
9267
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
@@ -9223,6 +9270,17 @@ var FECManager = class {
|
|
|
9223
9270
|
this.onBlockStarted = null;
|
|
9224
9271
|
this.onBlockComplete = null;
|
|
9225
9272
|
this.onBlockFailed = null;
|
|
9273
|
+
/**
|
|
9274
|
+
* Fired once per stream when its Worker decoder stops being routable.
|
|
9275
|
+
* `reason` is 'cleared' when clearFecWorker() removed it and 'disposed' when
|
|
9276
|
+
* a symbol or reset found the registered client already disposed and
|
|
9277
|
+
* evicted it. `fallbackDecoder` is 'sync' when a synchronous WASM decoder
|
|
9278
|
+
* registered for the same stream keeps decoding its symbols, and 'none'
|
|
9279
|
+
* when nothing does. Only 'none' leaves the stream unprotected: the host
|
|
9280
|
+
* must then register a decoder again or leave the stream, because counting
|
|
9281
|
+
* its symbols as handled would hide the loss.
|
|
9282
|
+
*/
|
|
9283
|
+
this.onDecoderUnavailable = null;
|
|
9226
9284
|
// D-28 on-demand repair callbacks. When onRepairNeeded is registered, each
|
|
9227
9285
|
// block arms a one-shot repair deadline after the derived K-symbol source
|
|
9228
9286
|
// horizon; a block still short of K when it fires requests a per-SBN MoQ
|
|
@@ -9256,6 +9314,7 @@ var FECManager = class {
|
|
|
9256
9314
|
startupRepairReadyPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairReadyPackets)),
|
|
9257
9315
|
startupRepairFailOpenPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairFailOpenPackets)),
|
|
9258
9316
|
pendingWorkerCleanups: __privateGet(this, _pendingWorkerCleanups).size,
|
|
9317
|
+
decoderUnavailableEvents: __privateGet(this, _decoderUnavailableEvents),
|
|
9259
9318
|
repairTrackedBlocks: __privateGet(this, _blockRepairRsIds).size,
|
|
9260
9319
|
lifecycleTrace: __privateGet(this, _lifecycleTrace).map((entry) => ({ ...entry }))
|
|
9261
9320
|
};
|
|
@@ -9390,8 +9449,12 @@ var FECManager = class {
|
|
|
9390
9449
|
__privateMethod(this, _FECManager_instances, discardFecDecoderClient_fn).call(this, client);
|
|
9391
9450
|
}
|
|
9392
9451
|
}
|
|
9393
|
-
for (const [key, client] of __privateGet(this, _workerClients)) {
|
|
9452
|
+
for (const [key, client] of [...__privateGet(this, _workerClients)]) {
|
|
9394
9453
|
if (!__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) continue;
|
|
9454
|
+
if (client.disposed === true) {
|
|
9455
|
+
__privateMethod(this, _FECManager_instances, evictDisposedWorker_fn).call(this, client);
|
|
9456
|
+
continue;
|
|
9457
|
+
}
|
|
9395
9458
|
client.reset();
|
|
9396
9459
|
clients.add(client);
|
|
9397
9460
|
}
|
|
@@ -9611,6 +9674,12 @@ var FECManager = class {
|
|
|
9611
9674
|
}
|
|
9612
9675
|
const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
|
|
9613
9676
|
__privateMethod(this, _FECManager_instances, assertExclusiveDecoderClient_fn).call(this, streamKey, client, __privateGet(this, _workerClients), "worker");
|
|
9677
|
+
const incumbent = __privateGet(this, _workerClients).get(streamKey);
|
|
9678
|
+
if (incumbent !== void 0 && incumbent !== client) {
|
|
9679
|
+
throw new Error(
|
|
9680
|
+
`[FECManager] stream ${streamKey} already routes to a Worker; call clearFecWorker before registering another`
|
|
9681
|
+
);
|
|
9682
|
+
}
|
|
9614
9683
|
if (config) __privateMethod(this, _FECManager_instances, upsertTrackConfig_fn).call(this, packetId, config);
|
|
9615
9684
|
const workerK = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).k;
|
|
9616
9685
|
__privateGet(this, _workerClients).set(streamKey, client);
|
|
@@ -9697,14 +9766,7 @@ var FECManager = class {
|
|
|
9697
9766
|
const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
|
|
9698
9767
|
return block.packetId === packetId && block.sbn === sbn && __privateGet(this, _pendingWorkerCleanupClients).get(key) === client;
|
|
9699
9768
|
});
|
|
9700
|
-
for (const key of cleanupKeys)
|
|
9701
|
-
__privateGet(this, _pendingWorkerCleanups).delete(key);
|
|
9702
|
-
__privateGet(this, _pendingWorkerCleanupClients).delete(key);
|
|
9703
|
-
if (__privateGet(this, _completedBlocks).has(key)) continue;
|
|
9704
|
-
const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
|
|
9705
|
-
__privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "cleanup-ack", sbn, packetId, block.catalogTrackName);
|
|
9706
|
-
__privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, block.catalogTrackName);
|
|
9707
|
-
}
|
|
9769
|
+
for (const key of cleanupKeys) __privateMethod(this, _FECManager_instances, settleOwedCleanup_fn).call(this, key, "cleanup-ack");
|
|
9708
9770
|
});
|
|
9709
9771
|
client.onError((msg, code) => {
|
|
9710
9772
|
const requestedKind = code ?? msg;
|
|
@@ -9720,6 +9782,25 @@ var FECManager = class {
|
|
|
9720
9782
|
}
|
|
9721
9783
|
});
|
|
9722
9784
|
}
|
|
9785
|
+
/**
|
|
9786
|
+
* Remove a stream's Worker decoder from routing.
|
|
9787
|
+
*
|
|
9788
|
+
* Returns false when no Worker is registered under that exact stream key.
|
|
9789
|
+
* On success every cleanup acknowledgement still owed by the client is
|
|
9790
|
+
* resolved by failing its block now (a Worker that is going away cannot
|
|
9791
|
+
* post it), the client's block ownership is released, and
|
|
9792
|
+
* onDecoderUnavailable fires once with reason 'cleared' and the decoder
|
|
9793
|
+
* that remains for the stream ('sync' or 'none'). Call this before
|
|
9794
|
+
* disposing the client; a client disposed while still registered is
|
|
9795
|
+
* evicted on its next symbol or reset with reason 'disposed'.
|
|
9796
|
+
*/
|
|
9797
|
+
clearFecWorker(packetId, catalogTrackName) {
|
|
9798
|
+
const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
|
|
9799
|
+
const client = __privateGet(this, _workerClients).get(streamKey);
|
|
9800
|
+
if (!client) return false;
|
|
9801
|
+
__privateMethod(this, _FECManager_instances, retireWorker_fn).call(this, streamKey, client, "cleared");
|
|
9802
|
+
return true;
|
|
9803
|
+
}
|
|
9723
9804
|
/** Called by player when framerate is known (from decoder output). Refines FEC block timeout. */
|
|
9724
9805
|
setFramerate(fps) {
|
|
9725
9806
|
if (__privateGet(this, _fpsDetected) || fps <= 0) return;
|
|
@@ -9770,7 +9851,7 @@ var FECManager = class {
|
|
|
9770
9851
|
const sbn = Math.floor(ssId / this.kForPacket(packetId));
|
|
9771
9852
|
const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
|
|
9772
9853
|
const syncBlockOwner = __privateGet(this, _syncDecoderBlockOwners).get(blockKey);
|
|
9773
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
9854
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
9774
9855
|
if (workerClient && !syncBlockOwner) {
|
|
9775
9856
|
if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
|
|
9776
9857
|
const buf = fecData.buffer.slice(
|
|
@@ -9847,7 +9928,7 @@ var FECManager = class {
|
|
|
9847
9928
|
if (__privateGet(this, _repairRequestedBlocks).has(blockKey)) {
|
|
9848
9929
|
__privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "repair-arrived", sbn, packetId, catalogTrackName, rsId);
|
|
9849
9930
|
}
|
|
9850
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
9931
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
9851
9932
|
if (workerClient && !syncBlockOwner) {
|
|
9852
9933
|
if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
|
|
9853
9934
|
const buf = fecData.buffer.slice(
|
|
@@ -10132,6 +10213,7 @@ _fpsDetected = new WeakMap();
|
|
|
10132
10213
|
_fecFps = new WeakMap();
|
|
10133
10214
|
_fecInterleaveDepthMs = new WeakMap();
|
|
10134
10215
|
_workerErrorCounts = new WeakMap();
|
|
10216
|
+
_decoderUnavailableEvents = new WeakMap();
|
|
10135
10217
|
_repairSymbolSizeMismatchCount = new WeakMap();
|
|
10136
10218
|
_FECManager_instances = new WeakSet();
|
|
10137
10219
|
streamKey_fn = function(packetId, catalogTrackName) {
|
|
@@ -10151,6 +10233,14 @@ belongsToStream_fn = function(key, packetId, catalogTrackName) {
|
|
|
10151
10233
|
packetIdsForStreamKeys_fn = function(keys) {
|
|
10152
10234
|
return [...new Set([...keys].map((key) => Number(key.split(":", 1)[0])))];
|
|
10153
10235
|
};
|
|
10236
|
+
parseStreamKey_fn = function(key) {
|
|
10237
|
+
const separator = key.indexOf(":");
|
|
10238
|
+
if (separator < 0) return { packetId: Number(key) || 0 };
|
|
10239
|
+
return {
|
|
10240
|
+
packetId: Number(key.slice(0, separator)) || 0,
|
|
10241
|
+
catalogTrackName: decodeURIComponent(key.slice(separator + 1))
|
|
10242
|
+
};
|
|
10243
|
+
};
|
|
10154
10244
|
blockKey_fn = function(sbn, packetId, catalogTrackName) {
|
|
10155
10245
|
const base = `${packetId}:${sbn}`;
|
|
10156
10246
|
return catalogTrackName === void 0 ? base : `${base}:${encodeURIComponent(catalogTrackName)}`;
|
|
@@ -10170,6 +10260,18 @@ decoderForPacket_fn = function(packetId, catalogTrackName) {
|
|
|
10170
10260
|
workerForPacket_fn = function(packetId, catalogTrackName) {
|
|
10171
10261
|
return __privateGet(this, _workerClients).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName)) ?? __privateGet(this, _workerClients).get(__privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId));
|
|
10172
10262
|
};
|
|
10263
|
+
/**
|
|
10264
|
+
* The stream's Worker client for routing, or undefined after evicting a
|
|
10265
|
+
* registered client that was already disposed. A disposed client throws on
|
|
10266
|
+
* every command, so it leaves routing here before a symbol reaches it and
|
|
10267
|
+
* the stream reports its decoder unavailable instead.
|
|
10268
|
+
*/
|
|
10269
|
+
routableWorkerForPacket_fn = function(packetId, catalogTrackName) {
|
|
10270
|
+
const client = __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
10271
|
+
if (client === void 0 || client.disposed !== true) return client;
|
|
10272
|
+
__privateMethod(this, _FECManager_instances, evictDisposedWorker_fn).call(this, client);
|
|
10273
|
+
return void 0;
|
|
10274
|
+
};
|
|
10173
10275
|
claimDecoderBlock_fn = function(client, sbn, catalogTrackName) {
|
|
10174
10276
|
let blocks = __privateGet(this, _decoderBlockOwners).get(client);
|
|
10175
10277
|
if (!blocks) {
|
|
@@ -10337,7 +10439,7 @@ armBlockTimeout_fn = function(sbn, packetId, catalogTrackName, delayMs) {
|
|
|
10337
10439
|
__privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, catalogTrackName);
|
|
10338
10440
|
return;
|
|
10339
10441
|
}
|
|
10340
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
10442
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
10341
10443
|
if (workerClient) {
|
|
10342
10444
|
__privateGet(this, _pendingWorkerCleanups).add(key);
|
|
10343
10445
|
__privateGet(this, _pendingWorkerCleanupClients).set(key, workerClient);
|
|
@@ -10420,6 +10522,59 @@ markStartupPartial_fn = function(blockKey) {
|
|
|
10420
10522
|
));
|
|
10421
10523
|
}
|
|
10422
10524
|
};
|
|
10525
|
+
/**
|
|
10526
|
+
* Take a Worker client out of routing under one stream key, fail the blocks
|
|
10527
|
+
* whose completion it still owed, and report the stream's decoder
|
|
10528
|
+
* unavailable together with whatever still decodes the stream.
|
|
10529
|
+
*/
|
|
10530
|
+
retireWorker_fn = function(streamKey, client, reason) {
|
|
10531
|
+
__privateGet(this, _workerClients).delete(streamKey);
|
|
10532
|
+
__privateMethod(this, _FECManager_instances, releaseWorkerClient_fn).call(this, client);
|
|
10533
|
+
__privateWrapper(this, _decoderUnavailableEvents)._++;
|
|
10534
|
+
const stream = __privateMethod(this, _FECManager_instances, parseStreamKey_fn).call(this, streamKey);
|
|
10535
|
+
const fallbackDecoder = __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, stream.packetId, stream.catalogTrackName) ? "sync" : "none";
|
|
10536
|
+
this.onDecoderUnavailable?.({
|
|
10537
|
+
packetId: stream.packetId,
|
|
10538
|
+
...stream.catalogTrackName === void 0 ? {} : { catalogTrackName: stream.catalogTrackName },
|
|
10539
|
+
reason,
|
|
10540
|
+
fallbackDecoder
|
|
10541
|
+
});
|
|
10542
|
+
};
|
|
10543
|
+
/**
|
|
10544
|
+
* Fail every block whose Worker cleanup acknowledgement is owed by `client`
|
|
10545
|
+
* and drop its block ownership, so no block waits on a message the Worker
|
|
10546
|
+
* will never post.
|
|
10547
|
+
*/
|
|
10548
|
+
releaseWorkerClient_fn = function(client) {
|
|
10549
|
+
const owed = [...__privateGet(this, _pendingWorkerCleanupClients)].filter(([, owner]) => owner === client).map(([key]) => key);
|
|
10550
|
+
for (const key of owed) __privateMethod(this, _FECManager_instances, settleOwedCleanup_fn).call(this, key, "decoder-unavailable");
|
|
10551
|
+
__privateGet(this, _decoderBlockOwners).delete(client);
|
|
10552
|
+
};
|
|
10553
|
+
/**
|
|
10554
|
+
* Resolve one owed Worker cleanup: drop the pending entry and fail the block
|
|
10555
|
+
* unless it already completed. Shared by the cleanup acknowledgement and by
|
|
10556
|
+
* Worker retirement, so the two paths cannot drift in their bookkeeping.
|
|
10557
|
+
*/
|
|
10558
|
+
settleOwedCleanup_fn = function(key, event) {
|
|
10559
|
+
__privateGet(this, _pendingWorkerCleanups).delete(key);
|
|
10560
|
+
__privateGet(this, _pendingWorkerCleanupClients).delete(key);
|
|
10561
|
+
if (__privateGet(this, _completedBlocks).has(key)) return;
|
|
10562
|
+
const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
|
|
10563
|
+
__privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, event, block.sbn, block.packetId, block.catalogTrackName);
|
|
10564
|
+
__privateMethod(this, _FECManager_instances, failBlock_fn).call(this, block.sbn, block.packetId, false, block.catalogTrackName);
|
|
10565
|
+
};
|
|
10566
|
+
/** Evict a disposed client under every stream key that still maps to it. */
|
|
10567
|
+
evictDisposedWorker_fn = function(client) {
|
|
10568
|
+
for (const [key, registered] of [...__privateGet(this, _workerClients)]) {
|
|
10569
|
+
if (registered !== client) continue;
|
|
10570
|
+
const stream = __privateMethod(this, _FECManager_instances, parseStreamKey_fn).call(this, key);
|
|
10571
|
+
const track = stream.catalogTrackName === void 0 ? "" : ` track=${stream.catalogTrackName}`;
|
|
10572
|
+
console.warn(
|
|
10573
|
+
`[FECManager] packetId=${stream.packetId}${track} Worker decoder was disposed while still registered; evicting it`
|
|
10574
|
+
);
|
|
10575
|
+
__privateMethod(this, _FECManager_instances, retireWorker_fn).call(this, key, client, "disposed");
|
|
10576
|
+
}
|
|
10577
|
+
};
|
|
10423
10578
|
routeSyncCleanup_fn = function(decoder, sbn, packetId) {
|
|
10424
10579
|
let framed;
|
|
10425
10580
|
try {
|
|
@@ -14603,12 +14758,22 @@ function createDefaultRepairLifecycleEvent(detail, options) {
|
|
|
14603
14758
|
function isRecord(value) {
|
|
14604
14759
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14605
14760
|
}
|
|
14606
|
-
function
|
|
14761
|
+
function isRepairStreamIdentity(value) {
|
|
14607
14762
|
if (!isRecord(value)) return false;
|
|
14608
14763
|
const packetId = value["packetId"];
|
|
14609
14764
|
const catalogTrackName = value["catalogTrackName"];
|
|
14765
|
+
return Number.isSafeInteger(packetId) && packetId >= 0 && (catalogTrackName === null || typeof catalogTrackName === "string" && catalogTrackName.length > 0);
|
|
14766
|
+
}
|
|
14767
|
+
function isRepairBlockIdentity(value) {
|
|
14768
|
+
if (!isRecord(value)) return false;
|
|
14610
14769
|
const sbn = value["sbn"];
|
|
14611
|
-
return
|
|
14770
|
+
return isRepairStreamIdentity(value) && Number.isSafeInteger(sbn) && sbn >= 0;
|
|
14771
|
+
}
|
|
14772
|
+
function isDecoderUnavailableReason(value) {
|
|
14773
|
+
return value === "cleared" || value === "disposed";
|
|
14774
|
+
}
|
|
14775
|
+
function isFecFallbackDecoder(value) {
|
|
14776
|
+
return value === "sync" || value === "none";
|
|
14612
14777
|
}
|
|
14613
14778
|
function isRepairLifecycleEvent(value) {
|
|
14614
14779
|
if (!isRecord(value)) return false;
|
|
@@ -14616,7 +14781,11 @@ function isRepairLifecycleEvent(value) {
|
|
|
14616
14781
|
const type = value["type"];
|
|
14617
14782
|
const block = value["block"];
|
|
14618
14783
|
const symbols = value["symbols"];
|
|
14619
|
-
if (version !== 1
|
|
14784
|
+
if (version !== 1) return false;
|
|
14785
|
+
if (type === "decoder-unavailable") {
|
|
14786
|
+
return isRepairStreamIdentity(value["stream"]) && isDecoderUnavailableReason(value["reason"]) && isFecFallbackDecoder(value["fallbackDecoder"]) && block === void 0 && symbols === void 0;
|
|
14787
|
+
}
|
|
14788
|
+
if (type !== "requested" && type !== "recovered" && type !== "failed" || !isRepairBlockIdentity(block) || value["stream"] !== void 0 || value["reason"] !== void 0 || value["fallbackDecoder"] !== void 0) {
|
|
14620
14789
|
return false;
|
|
14621
14790
|
}
|
|
14622
14791
|
if (type === "requested") return symbols === void 0;
|
|
@@ -14635,22 +14804,25 @@ function forwardRepairLifecycleEvents(source, target, options = {}) {
|
|
|
14635
14804
|
target.dispatchEvent(forwardedEvent);
|
|
14636
14805
|
});
|
|
14637
14806
|
}
|
|
14638
|
-
function
|
|
14807
|
+
function repairStreamIdentity(packetId, catalogTrackName) {
|
|
14639
14808
|
if (!Number.isSafeInteger(packetId) || packetId < 0) {
|
|
14640
14809
|
throw new TypeError("packetId must be a non-negative safe integer");
|
|
14641
14810
|
}
|
|
14642
|
-
if (!Number.isSafeInteger(sbn) || sbn < 0) {
|
|
14643
|
-
throw new TypeError("sbn must be a non-negative safe integer");
|
|
14644
|
-
}
|
|
14645
14811
|
if (catalogTrackName !== void 0 && (typeof catalogTrackName !== "string" || catalogTrackName.length === 0)) {
|
|
14646
14812
|
throw new TypeError("catalogTrackName must be a non-empty string when provided");
|
|
14647
14813
|
}
|
|
14648
14814
|
return {
|
|
14649
14815
|
packetId,
|
|
14650
|
-
catalogTrackName: catalogTrackName ?? null
|
|
14651
|
-
sbn
|
|
14816
|
+
catalogTrackName: catalogTrackName ?? null
|
|
14652
14817
|
};
|
|
14653
14818
|
}
|
|
14819
|
+
function repairBlockIdentity(packetId, sbn, catalogTrackName) {
|
|
14820
|
+
const stream = repairStreamIdentity(packetId, catalogTrackName);
|
|
14821
|
+
if (!Number.isSafeInteger(sbn) || sbn < 0) {
|
|
14822
|
+
throw new TypeError("sbn must be a non-negative safe integer");
|
|
14823
|
+
}
|
|
14824
|
+
return { ...stream, sbn };
|
|
14825
|
+
}
|
|
14654
14826
|
function assertPositiveGeometry(label, value) {
|
|
14655
14827
|
if (value === void 0) return;
|
|
14656
14828
|
if (!Number.isFinite(value) || value <= 0) {
|
|
@@ -14820,6 +14992,15 @@ var MulticastManager = class {
|
|
|
14820
14992
|
}
|
|
14821
14993
|
});
|
|
14822
14994
|
};
|
|
14995
|
+
__privateGet(this, _fec).onDecoderUnavailable = (event) => {
|
|
14996
|
+
__privateMethod(this, _MulticastManager_instances, emitRepairLifecycle_fn).call(this, {
|
|
14997
|
+
version: 1,
|
|
14998
|
+
type: "decoder-unavailable",
|
|
14999
|
+
stream: repairStreamIdentity(event.packetId, event.catalogTrackName),
|
|
15000
|
+
reason: event.reason,
|
|
15001
|
+
fallbackDecoder: event.fallbackDecoder
|
|
15002
|
+
});
|
|
15003
|
+
};
|
|
14823
15004
|
}
|
|
14824
15005
|
// ---------------------------------------------------------------------------
|
|
14825
15006
|
// Decomposed component accessors (for new code)
|
|
@@ -14874,6 +15055,17 @@ var MulticastManager = class {
|
|
|
14874
15055
|
__privateMethod(this, _MulticastManager_instances, configureTrackMapper_fn).call(this, packetId, config);
|
|
14875
15056
|
__privateGet(this, _router).setPacketIdType(packetId, trackType);
|
|
14876
15057
|
}
|
|
15058
|
+
/**
|
|
15059
|
+
* Stop routing a stream's symbols to its Worker decoder. Returns false when
|
|
15060
|
+
* none is registered; on success one `decoder-unavailable` repair lifecycle
|
|
15061
|
+
* event with reason 'cleared' reaches every observer, carrying whether a
|
|
15062
|
+
* synchronous WASM decoder still serves the stream. The packet mapping and
|
|
15063
|
+
* track type are untouched: the track still exists, it just has no Worker
|
|
15064
|
+
* decoder. Call this before disposing the client.
|
|
15065
|
+
*/
|
|
15066
|
+
clearFecWorker(packetId, catalogTrackName) {
|
|
15067
|
+
return __privateGet(this, _fec).clearFecWorker(packetId, catalogTrackName);
|
|
15068
|
+
}
|
|
14877
15069
|
/** Register callback for Worker-level FecTrackStats updates. */
|
|
14878
15070
|
setOnFecStatsUpdate(cb) {
|
|
14879
15071
|
__privateGet(this, _fec).onFecStatsUpdate = cb;
|
|
@@ -14919,8 +15111,9 @@ var MulticastManager = class {
|
|
|
14919
15111
|
repairSymbols: config.fecRepairSymbols,
|
|
14920
15112
|
symbolSize: config.fecSymbolSize,
|
|
14921
15113
|
mediaUnitsPerSecond: config.fps,
|
|
14922
|
-
bandwidthBps: config.bandwidth
|
|
14923
|
-
|
|
15114
|
+
bandwidthBps: config.bandwidth,
|
|
15115
|
+
jitterBufferMs: config.fecReorderToleranceMs
|
|
15116
|
+
}) : void 0;
|
|
14924
15117
|
const fecConfig = {
|
|
14925
15118
|
k: config.fecK,
|
|
14926
15119
|
symbolSize: config.fecSymbolSize,
|
|
@@ -14957,8 +15150,9 @@ var MulticastManager = class {
|
|
|
14957
15150
|
repairSymbols: config.fecRepairSymbols,
|
|
14958
15151
|
symbolSize: config.fecSymbolSize,
|
|
14959
15152
|
mediaUnitsPerSecond: config.fps,
|
|
14960
|
-
bandwidthBps: config.bandwidth
|
|
14961
|
-
|
|
15153
|
+
bandwidthBps: config.bandwidth,
|
|
15154
|
+
jitterBufferMs: config.fecReorderToleranceMs
|
|
15155
|
+
}) : void 0;
|
|
14962
15156
|
__privateGet(this, _fec).configure({
|
|
14963
15157
|
k: config.fecK,
|
|
14964
15158
|
symbolSize: config.fecSymbolSize,
|
|
@@ -15475,11 +15669,13 @@ applyStreamGlobalFecTiming_fn = function() {
|
|
|
15475
15669
|
};
|
|
15476
15670
|
_onTrackTypeDiscovered = new WeakMap();
|
|
15477
15671
|
emitRepairLifecycle_fn = function(event) {
|
|
15478
|
-
const immutableEvent = Object.freeze(
|
|
15479
|
-
...event,
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15672
|
+
const immutableEvent = Object.freeze(
|
|
15673
|
+
event.type === "decoder-unavailable" ? { ...event, stream: Object.freeze({ ...event.stream }) } : {
|
|
15674
|
+
...event,
|
|
15675
|
+
block: Object.freeze({ ...event.block }),
|
|
15676
|
+
...event.type === "requested" ? {} : { symbols: Object.freeze({ ...event.symbols }) }
|
|
15677
|
+
}
|
|
15678
|
+
);
|
|
15483
15679
|
console.info(
|
|
15484
15680
|
`${REPAIR_LIFECYCLE_LOG_PREFIX}${JSON.stringify(immutableEvent)}`
|
|
15485
15681
|
);
|
|
@@ -15503,7 +15699,8 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15503
15699
|
sourceSymbols: opts.fecK,
|
|
15504
15700
|
repairSymbols: opts.fecRepairCount,
|
|
15505
15701
|
symbolSize: opts.fecSymbolSize,
|
|
15506
|
-
mediaUnitsPerSecond: 1e3 / opts.mediaUnitDurationMs
|
|
15702
|
+
mediaUnitsPerSecond: 1e3 / opts.mediaUnitDurationMs,
|
|
15703
|
+
jitterBufferMs: opts.fecReorderToleranceMs
|
|
15507
15704
|
});
|
|
15508
15705
|
const origin = typeof location !== "undefined" && location.origin ? location.origin : "http://localhost";
|
|
15509
15706
|
const workerUrl = new URL(opts.assetUrls.fecWorker, origin);
|
|
@@ -15549,15 +15746,23 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15549
15746
|
relayBlockSigEnabled: false
|
|
15550
15747
|
};
|
|
15551
15748
|
client.configure(fecTrackConfig, rqWasm, altaKeyBuffer, altaWasmModule);
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15749
|
+
try {
|
|
15750
|
+
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
15751
|
+
k: opts.fecK,
|
|
15752
|
+
symbolSize: opts.fecSymbolSize,
|
|
15753
|
+
interleaveDepthMs: opts.fecInterleaveMs,
|
|
15754
|
+
// FEC timing is expressed in media units. For audio this is the access-unit
|
|
15755
|
+
// cadence (for example 1024/48kHz), not a video-only framerate field.
|
|
15756
|
+
fps: 1e3 / opts.mediaUnitDurationMs,
|
|
15757
|
+
timeoutMs: deliveryWindowMs
|
|
15758
|
+
}, opts.trackName);
|
|
15759
|
+
} catch (e) {
|
|
15760
|
+
try {
|
|
15761
|
+
client.dispose();
|
|
15762
|
+
} catch {
|
|
15763
|
+
}
|
|
15764
|
+
throw e;
|
|
15765
|
+
}
|
|
15561
15766
|
let disposed = false;
|
|
15562
15767
|
return {
|
|
15563
15768
|
client,
|
|
@@ -15565,6 +15770,11 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15565
15770
|
dispose: () => {
|
|
15566
15771
|
if (disposed) return;
|
|
15567
15772
|
disposed = true;
|
|
15773
|
+
if (!opts.multicastManager.clearFecWorker(opts.packetId, opts.trackName)) {
|
|
15774
|
+
console.warn(
|
|
15775
|
+
`[fec-worker-setup] packetId=${opts.packetId} track=${opts.trackName} Worker was not registered when disposed`
|
|
15776
|
+
);
|
|
15777
|
+
}
|
|
15568
15778
|
try {
|
|
15569
15779
|
client.dispose();
|
|
15570
15780
|
} catch {
|
|
@@ -17325,6 +17535,23 @@ emit_fn = function(params) {
|
|
|
17325
17535
|
};
|
|
17326
17536
|
|
|
17327
17537
|
// src/catalog-fec-params.ts
|
|
17538
|
+
function timescaleHz(value) {
|
|
17539
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
17540
|
+
}
|
|
17541
|
+
function catalogGroupDurationMs(rendition) {
|
|
17542
|
+
if (!rendition) return void 0;
|
|
17543
|
+
const ticks = numericField(rendition.groupDurationTicks);
|
|
17544
|
+
const ms = numericField(rendition.groupDurationMs);
|
|
17545
|
+
const timescale = timescaleHz(rendition.container?.kind === "mmtp" ? rendition.container.timescale : void 0) ?? timescaleHz(rendition.timescale);
|
|
17546
|
+
if (ticks !== void 0 && Number.isSafeInteger(ticks) && timescale !== void 0) {
|
|
17547
|
+
return resolveGroupDurationMs({ groupDurationTicks: ticks }, timescale);
|
|
17548
|
+
}
|
|
17549
|
+
return ms;
|
|
17550
|
+
}
|
|
17551
|
+
function resolveCatalogTrackGroupDurationMs(catalog, track) {
|
|
17552
|
+
const renditions = track.type === "audio" ? catalog?.audio?.renditions : catalog?.video?.renditions;
|
|
17553
|
+
return catalogGroupDurationMs(renditions?.[track.name]);
|
|
17554
|
+
}
|
|
17328
17555
|
var NO_FEC = {
|
|
17329
17556
|
fecK: 0,
|
|
17330
17557
|
fecRepairCount: 0,
|
|
@@ -17571,6 +17798,7 @@ export {
|
|
|
17571
17798
|
buildVideoInitSegment,
|
|
17572
17799
|
catalogAmtNetworkSource,
|
|
17573
17800
|
catalogFecInterleaveMs,
|
|
17801
|
+
catalogGroupDurationMs,
|
|
17574
17802
|
classifyH264Keyframe,
|
|
17575
17803
|
classifyPacket,
|
|
17576
17804
|
codecStringFromAvcC,
|
|
@@ -17641,6 +17869,7 @@ export {
|
|
|
17641
17869
|
reliableMoqMfuReassembly,
|
|
17642
17870
|
removeEmulationPrevention,
|
|
17643
17871
|
resolveCatalogTrackFec,
|
|
17872
|
+
resolveCatalogTrackGroupDurationMs,
|
|
17644
17873
|
resolveGlobalMmtWasmBindings,
|
|
17645
17874
|
resolveGroupDurationMs,
|
|
17646
17875
|
resolveGroupDurationTicks,
|