@blockcast/mmt-container 0.1.0-main.3b596a80146b → 0.1.0-main.3ca5d1ea196c
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 +1015 -177
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +7 -7
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +336 -12
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.d.ts +105 -0
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +495 -4
- package/dist/catalog-fec-params.js.map +4 -4
- 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 +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +2 -2
- 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 +95 -1
- package/dist/mfu-reassembler.d.ts.map +1 -1
- package/dist/mfu-reassembler.js +92 -28
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.js +91 -28
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +427 -40
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.d.ts +34 -0
- package/dist/mmtp-decode-pipeline.d.ts.map +1 -1
- package/dist/mmtp-decode-pipeline.js +152 -52
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.js +91 -28
- 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 +281 -82
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +427 -40
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-layers.d.ts +141 -0
- package/dist/repair-layers.d.ts.map +1 -0
- package/dist/repair-layers.js +303 -0
- package/dist/repair-layers.js.map +7 -0
- package/dist/track-session.d.ts +64 -24
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +138 -65
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +91 -28
- 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/schemas/catalog.schema.json +82 -5
- package/src/carp-catalog.ts +80 -11
- package/src/catalog-fec-params.ts +342 -2
- package/src/fec-manager.ts +168 -18
- package/src/fec-worker-setup.ts +37 -11
- package/src/index.ts +38 -0
- package/src/media-router.ts +1 -6
- package/src/mfu-reassembler.ts +233 -31
- package/src/mmtp-decode-pipeline.ts +93 -24
- package/src/multicast-manager.ts +106 -22
- package/src/repair-layers.ts +490 -0
- package/src/track-session.ts +201 -119
- package/test-vectors/catalog/README.md +16 -1
- package/test-vectors/catalog/negative/fec-enhancement-repair-removed.json +27 -0
- package/test-vectors/catalog/negative/fec-repair-layer-geometry.json +32 -0
- package/test-vectors/catalog/negative/fec-repair-layer-missing-symbols.json +30 -0
- package/test-vectors/catalog/negative/fec-repair-multiple-depends.json +31 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-with-layer.json +33 -0
- package/test-vectors/catalog/negative/fec-repair-priority-out-of-band.json +23 -0
- package/test-vectors/catalog/negative/fec-repair-source-symbols-without-scope.json +32 -0
- package/test-vectors/catalog/negative/media-track-repair-layer.json +16 -0
- package/test-vectors/catalog/negative/raptorq-source-symbols-over-max.json +23 -0
- package/test-vectors/catalog/negative/repair-track-legacy-shape.json +2 -1
- package/test-vectors/catalog/positive/fec-layered-repair.json +104 -0
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,7 +1029,10 @@ function checkedSampleEnd(offset, byteLength) {
|
|
|
1020
1029
|
return Number.isSafeInteger(end) && end <= 4294967295 ? end : null;
|
|
1021
1030
|
}
|
|
1022
1031
|
var COMPLETED_ADDRESS_WINDOW_MULTIPLE = 2;
|
|
1023
|
-
|
|
1032
|
+
function parkedRunHoldsASlot(hasOpenRun, fragmentCount) {
|
|
1033
|
+
return !hasOpenRun && fragmentCount > 0;
|
|
1034
|
+
}
|
|
1035
|
+
var _buffers, _timeouts, _activeDataUnits, _pendingContinuations, _emitted, _emittedOrder, _completed, _completedOrder, _timeoutMs, _maxBuffered, _nextAdmissionSeq, _MFUReassembler_instances, addAssociatedFragment_fn, parkContinuation_fn, drainPendingContinuations_fn, unopenedParkedRunCount_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) {
|
|
1026
1038
|
__privateAdd(this, _MFUReassembler_instances);
|
|
@@ -1089,7 +1101,7 @@ var MFUReassembler = class {
|
|
|
1089
1101
|
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1090
1102
|
if (pending.timeoutId !== void 0) clearTimeout(pending.timeoutId);
|
|
1091
1103
|
delete pending.timeoutId;
|
|
1092
|
-
if (ms !== null && __privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address)
|
|
1104
|
+
if (ms !== null && parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1093
1105
|
pending.timeoutId = setTimeout(() => __privateMethod(this, _MFUReassembler_instances, onPendingTimeout_fn).call(this, address), Math.max(0, pending.startedAt + ms - now));
|
|
1094
1106
|
}
|
|
1095
1107
|
}
|
|
@@ -1255,14 +1267,26 @@ 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 — by delegating to `#unopenedParkedRunCount`, the
|
|
1275
|
+
* one site that applies it. Rust's public `buffered_count()` is
|
|
1276
|
+
* `inner.buffered_count() + unopened_parked_run_count()`, and that count is
|
|
1277
|
+
* `parked_run_holds_a_slot` — so filtering here on the open run alone would
|
|
1278
|
+
* report a phantom slot for an empty published queue in TypeScript and not in
|
|
1279
|
+
* Rust, out of a *host-observable* counter (`getStatus().bufferedMFUs`). Same
|
|
1280
|
+
* state, two numbers, decided by which engine the host loaded: the divergence
|
|
1281
|
+
* class this file exists to close, so the public counters have to agree too.
|
|
1282
|
+
*
|
|
1283
|
+
* Distinct from `#incompleteRunCount`, which sums `#activeDataUnits` rather
|
|
1284
|
+
* than `#buffers`. Those are different quantities by design and are not being
|
|
1285
|
+
* merged; only the parked term they share is required to agree, which is what
|
|
1286
|
+
* routing both through one method makes structural rather than conventional.
|
|
1259
1287
|
*/
|
|
1260
1288
|
get pendingCount() {
|
|
1261
|
-
|
|
1262
|
-
for (const address of __privateGet(this, _pendingContinuations).keys()) {
|
|
1263
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) === void 0) count++;
|
|
1264
|
-
}
|
|
1265
|
-
return count;
|
|
1289
|
+
return __privateGet(this, _buffers).size + __privateMethod(this, _MFUReassembler_instances, unopenedParkedRunCount_fn).call(this);
|
|
1266
1290
|
}
|
|
1267
1291
|
/**
|
|
1268
1292
|
* Get current buffer status
|
|
@@ -1323,29 +1347,35 @@ addAssociatedFragment_fn = function(fragment, runKey, address, startedAt) {
|
|
|
1323
1347
|
};
|
|
1324
1348
|
parkContinuation_fn = function(address, fragment) {
|
|
1325
1349
|
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
|
-
}
|
|
1350
|
+
const open = __privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address);
|
|
1351
|
+
const alreadyCharged = open !== void 0 || parkedRunHoldsASlot(open !== void 0, pending?.fragments.size ?? 0);
|
|
1352
|
+
if (!alreadyCharged && __privateMethod(this, _MFUReassembler_instances, incompleteRunCount_fn).call(this) >= __privateGet(this, _maxBuffered)) {
|
|
1353
|
+
if (!__privateMethod(this, _MFUReassembler_instances, evictLeastRecentlyAdmitted_fn).call(this)) {
|
|
1354
|
+
__privateMethod(this, _MFUReassembler_instances, reject_fn).call(this, "active-data-unit-limit", "active MFU data-unit limit reached");
|
|
1333
1355
|
}
|
|
1334
|
-
|
|
1356
|
+
}
|
|
1357
|
+
let reAnchored = false;
|
|
1358
|
+
if (pending === void 0) {
|
|
1335
1359
|
pending = {
|
|
1336
1360
|
fragments: /* @__PURE__ */ new Map(),
|
|
1337
|
-
startedAt,
|
|
1338
|
-
admissionSeq: open
|
|
1361
|
+
startedAt: Date.now(),
|
|
1362
|
+
admissionSeq: open !== void 0 ? open[1].admissionSeq : __privateWrapper(this, _nextAdmissionSeq)._++
|
|
1339
1363
|
};
|
|
1340
|
-
if (
|
|
1364
|
+
if (open === void 0 && __privateGet(this, _timeoutMs) !== null) {
|
|
1341
1365
|
pending.timeoutId = setTimeout(() => __privateMethod(this, _MFUReassembler_instances, onPendingTimeout_fn).call(this, address), __privateGet(this, _timeoutMs));
|
|
1342
1366
|
}
|
|
1343
1367
|
__privateGet(this, _pendingContinuations).set(address, pending);
|
|
1368
|
+
} else if (!alreadyCharged) {
|
|
1369
|
+
pending.admissionSeq = __privateWrapper(this, _nextAdmissionSeq)._++;
|
|
1370
|
+
pending.startedAt = Date.now();
|
|
1371
|
+
__privateMethod(this, _MFUReassembler_instances, clearPendingTimeout_fn).call(this, address);
|
|
1372
|
+
reAnchored = true;
|
|
1344
1373
|
}
|
|
1345
1374
|
if (pending.fragments.has(fragment.fragmentCounter)) {
|
|
1346
1375
|
__privateMethod(this, _MFUReassembler_instances, reject_fn).call(this, "fragment-counter-mismatch", "duplicate queued continuation counter would replace retained media");
|
|
1347
1376
|
}
|
|
1348
1377
|
pending.fragments.set(fragment.fragmentCounter, fragment);
|
|
1378
|
+
if (reAnchored) __privateMethod(this, _MFUReassembler_instances, armHeadlessPendingTimeout_fn).call(this, address);
|
|
1349
1379
|
};
|
|
1350
1380
|
drainPendingContinuations_fn = function(address, runKey) {
|
|
1351
1381
|
while (true) {
|
|
@@ -1368,15 +1398,35 @@ drainPendingContinuations_fn = function(address, runKey) {
|
|
|
1368
1398
|
}
|
|
1369
1399
|
}
|
|
1370
1400
|
};
|
|
1371
|
-
/**
|
|
1372
|
-
*
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1401
|
+
/** Parked data units that hold a `maxBuffered` slot of their own. Membership
|
|
1402
|
+
* is `parkedRunHoldsASlot`, the same rule #evictLeastRecentlyAdmitted offers
|
|
1403
|
+
* as candidates, so nothing can be counted here that eviction cannot reclaim.
|
|
1404
|
+
*
|
|
1405
|
+
* One site, two callers — `#incompleteRunCount` and `pendingCount` — mirroring
|
|
1406
|
+
* Rust's `unopened_parked_run_count`, which `incomplete_run_count` and
|
|
1407
|
+
* `buffered_count` both delegate to. Both callers used to inline this loop
|
|
1408
|
+
* verbatim, so converging the *rule* moved one copy and left the other as the
|
|
1409
|
+
* divergence (Ally's review of #400). The rule can no longer drift now that
|
|
1410
|
+
* every site routes through `parkedRunHoldsASlot`; keeping the loop itself at
|
|
1411
|
+
* one site is what stops the scaffolding drifting the next time this question
|
|
1412
|
+
* grows an argument. */
|
|
1413
|
+
unopenedParkedRunCount_fn = function() {
|
|
1414
|
+
let count = 0;
|
|
1415
|
+
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1416
|
+
if (parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1417
|
+
count++;
|
|
1418
|
+
}
|
|
1377
1419
|
}
|
|
1378
1420
|
return count;
|
|
1379
1421
|
};
|
|
1422
|
+
/** Every open run plus every headless parked data unit that holds a slot,
|
|
1423
|
+
* one slot each. This is the quantity maxBuffered bounds. The parked term is
|
|
1424
|
+
* `#unopenedParkedRunCount`, whose membership is `parkedRunHoldsASlot` — the
|
|
1425
|
+
* same rule #evictLeastRecentlyAdmitted offers as candidates, so nothing can
|
|
1426
|
+
* be counted here that eviction cannot reclaim. */
|
|
1427
|
+
incompleteRunCount_fn = function() {
|
|
1428
|
+
return __privateGet(this, _activeDataUnits).size + __privateMethod(this, _MFUReassembler_instances, unopenedParkedRunCount_fn).call(this);
|
|
1429
|
+
};
|
|
1380
1430
|
/**
|
|
1381
1431
|
* Drop the incomplete data unit admitted longest ago so a newly arriving one
|
|
1382
1432
|
* can take its slot. Selection is by monotonic admission ordinal, never by
|
|
@@ -1388,6 +1438,12 @@ incompleteRunCount_fn = function() {
|
|
|
1388
1438
|
* Returns false only if no slot is charged, which cannot happen at the bound
|
|
1389
1439
|
* (`maxBuffered` is a positive integer); admission then falls back to the
|
|
1390
1440
|
* fail-closed `active-data-unit-limit` reject, which stays a stable host code.
|
|
1441
|
+
* That holds because the candidate set here is built from the same
|
|
1442
|
+
* `parkedRunHoldsASlot` rule `#incompleteRunCount` counts by, so reaching the
|
|
1443
|
+
* bound implies at least one candidate. Filtering one and not the other would
|
|
1444
|
+
* make the claim false: a queue counted but not offered charges a slot no
|
|
1445
|
+
* eviction can reclaim, and the receiver refuses every later data unit
|
|
1446
|
+
* permanently.
|
|
1391
1447
|
*/
|
|
1392
1448
|
evictLeastRecentlyAdmitted_fn = function() {
|
|
1393
1449
|
let victimAddress;
|
|
@@ -1399,7 +1455,9 @@ evictLeastRecentlyAdmitted_fn = function() {
|
|
|
1399
1455
|
}
|
|
1400
1456
|
}
|
|
1401
1457
|
for (const [address, pending] of __privateGet(this, _pendingContinuations)) {
|
|
1402
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0)
|
|
1458
|
+
if (!parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1459
|
+
continue;
|
|
1460
|
+
}
|
|
1403
1461
|
if (pending.admissionSeq < victimSeq) {
|
|
1404
1462
|
victimSeq = pending.admissionSeq;
|
|
1405
1463
|
victimAddress = address;
|
|
@@ -1434,7 +1492,10 @@ associateDataUnit_fn = function(fragment, runKey, address) {
|
|
|
1434
1492
|
const fi = fragment.fragmentationIndicator;
|
|
1435
1493
|
if (fi === 1) {
|
|
1436
1494
|
const parked = __privateGet(this, _pendingContinuations).get(address);
|
|
1437
|
-
const inheritsParkedSlot = (
|
|
1495
|
+
const inheritsParkedSlot = parkedRunHoldsASlot(
|
|
1496
|
+
__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0,
|
|
1497
|
+
parked?.fragments.size ?? 0
|
|
1498
|
+
);
|
|
1438
1499
|
const sampleIdentity = hasSampleIdentity(fragment);
|
|
1439
1500
|
const hasSampleFields = hasAnySampleIdentityField(fragment);
|
|
1440
1501
|
const hasItemIdentity = fragment.itemId !== void 0;
|
|
@@ -1605,11 +1666,18 @@ clearPendingTimeout_fn = function(address) {
|
|
|
1605
1666
|
/**
|
|
1606
1667
|
* A queue whose run closed without completing is headless again and expires
|
|
1607
1668
|
* from its own first arrival, exactly as it would had the head never come.
|
|
1669
|
+
*
|
|
1670
|
+
* An empty queue is not armed: it holds no data unit that could fail to
|
|
1671
|
+
* complete, so there is nothing for a deadline to expire. Both arming sites
|
|
1672
|
+
* take that test through `parkedRunHoldsASlot` rather than filtering on the
|
|
1673
|
+
* open run alone, which is how this engine reaches Rust's answer — its
|
|
1674
|
+
* `next_timeout_at` derives candidate deadlines from the queue's live
|
|
1675
|
+
* entries, so an empty queue yields none (BLO-32420).
|
|
1608
1676
|
*/
|
|
1609
1677
|
armHeadlessPendingTimeout_fn = function(address) {
|
|
1610
1678
|
const pending = __privateGet(this, _pendingContinuations).get(address);
|
|
1611
1679
|
if (pending === void 0 || pending.timeoutId !== void 0 || __privateGet(this, _timeoutMs) === null) return;
|
|
1612
|
-
if (__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0) return;
|
|
1680
|
+
if (!parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) return;
|
|
1613
1681
|
pending.timeoutId = setTimeout(
|
|
1614
1682
|
() => __privateMethod(this, _MFUReassembler_instances, onPendingTimeout_fn).call(this, address),
|
|
1615
1683
|
Math.max(0, pending.startedAt + __privateGet(this, _timeoutMs) - Date.now())
|
|
@@ -1622,6 +1690,10 @@ deletePendingRun_fn = function(address) {
|
|
|
1622
1690
|
onPendingTimeout_fn = function(address) {
|
|
1623
1691
|
const pending = __privateGet(this, _pendingContinuations).get(address);
|
|
1624
1692
|
if (pending === void 0) return;
|
|
1693
|
+
if (!parkedRunHoldsASlot(__privateMethod(this, _MFUReassembler_instances, openRunAt_fn).call(this, address) !== void 0, pending.fragments.size)) {
|
|
1694
|
+
__privateMethod(this, _MFUReassembler_instances, clearPendingTimeout_fn).call(this, address);
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1625
1697
|
this.stats.timedOutMFUs++;
|
|
1626
1698
|
console.warn(
|
|
1627
1699
|
`[MfuReassembler] timeout: run=${address} fragments=${pending.fragments.size} (continuations awaiting first fragment, discarded)`
|
|
@@ -5735,6 +5807,289 @@ function resolveMulticastAuthCatalog(catalog, playerMode) {
|
|
|
5735
5807
|
};
|
|
5736
5808
|
}
|
|
5737
5809
|
|
|
5810
|
+
// src/repair-layers.ts
|
|
5811
|
+
var REPAIR_PRIORITY_MIN = 192;
|
|
5812
|
+
var REPAIR_PRIORITY_MAX = 255;
|
|
5813
|
+
var DEFAULT_REPAIR_PRIORITY = 240;
|
|
5814
|
+
var MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
|
|
5815
|
+
var MAX_REPAIR_SYMBOLS = 16777215;
|
|
5816
|
+
var MAX_ENCODING_SYMBOL_ID = 16777215;
|
|
5817
|
+
var RepairContractError = class extends Error {
|
|
5818
|
+
constructor(code, path, message) {
|
|
5819
|
+
super(`[repair-layers:${code}] ${path}: ${message}`);
|
|
5820
|
+
this.code = code;
|
|
5821
|
+
this.path = path;
|
|
5822
|
+
this.name = "RepairContractError";
|
|
5823
|
+
}
|
|
5824
|
+
};
|
|
5825
|
+
var throwRepairContractError = (code, path, message) => {
|
|
5826
|
+
throw new RepairContractError(code, path, message);
|
|
5827
|
+
};
|
|
5828
|
+
var REPAIR_FIELDS = ["depends", "repairLayer", "repairSymbols", "priority", "scope", "sourceSymbols"];
|
|
5829
|
+
var REPAIR_TRACK_GEOMETRY_KEYS = [
|
|
5830
|
+
"mmtpMode",
|
|
5831
|
+
"timescale",
|
|
5832
|
+
"groupDurationMs",
|
|
5833
|
+
"groupDurationTicks",
|
|
5834
|
+
"keyframeIntervalMs",
|
|
5835
|
+
"keyframeIntervalTicks",
|
|
5836
|
+
"fec",
|
|
5837
|
+
"symbolSize",
|
|
5838
|
+
"interleaveDepthMs"
|
|
5839
|
+
];
|
|
5840
|
+
var REPAIR_TRACK_ONLY_KEYS = ["repairLayer", "repairSymbols", "sourceSymbols", "scope"];
|
|
5841
|
+
function rejectRepairTrackGeometry(path, fields, fail) {
|
|
5842
|
+
for (const key of REPAIR_TRACK_GEOMETRY_KEYS) {
|
|
5843
|
+
if (fields[key] !== void 0) {
|
|
5844
|
+
fail(
|
|
5845
|
+
"track_repair_geometry",
|
|
5846
|
+
`${path}.${key}`,
|
|
5847
|
+
"a repair track carries no block geometry; it is shared with the source track's fec object"
|
|
5848
|
+
);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
}
|
|
5852
|
+
function repairReachability(fecObjects) {
|
|
5853
|
+
let declaresFecSource = false;
|
|
5854
|
+
const layerZeroNames = /* @__PURE__ */ new Set();
|
|
5855
|
+
for (const candidate of fecObjects) {
|
|
5856
|
+
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate)) continue;
|
|
5857
|
+
const fec = candidate;
|
|
5858
|
+
if (fec["algorithm"] === "none") continue;
|
|
5859
|
+
declaresFecSource = true;
|
|
5860
|
+
const repairTrack = fec["repairTrack"];
|
|
5861
|
+
if (typeof repairTrack === "string" && repairTrack.length > 0) layerZeroNames.add(repairTrack);
|
|
5862
|
+
}
|
|
5863
|
+
return { declaresFecSource, layerZeroNames };
|
|
5864
|
+
}
|
|
5865
|
+
function assertRepairTrackReachable(descriptor, reachability, fail) {
|
|
5866
|
+
if (dependsTarget(descriptor) !== void 0) return;
|
|
5867
|
+
if (reachability.declaresFecSource && !reachability.layerZeroNames.has(descriptor.name)) {
|
|
5868
|
+
fail(
|
|
5869
|
+
"track_repair_depends",
|
|
5870
|
+
`${descriptor.path}.depends`,
|
|
5871
|
+
"no source names this repair track in fec.repairTrack and it declares no depends"
|
|
5872
|
+
);
|
|
5873
|
+
}
|
|
5874
|
+
}
|
|
5875
|
+
function rejectRepairFieldsOnMediaTrack(path, fields, fail) {
|
|
5876
|
+
for (const key of REPAIR_TRACK_ONLY_KEYS) {
|
|
5877
|
+
if (fields[key] !== void 0) {
|
|
5878
|
+
fail("track_repair_layer", `${path}.${key}`, `${key} is a repair track field`);
|
|
5879
|
+
}
|
|
5880
|
+
}
|
|
5881
|
+
}
|
|
5882
|
+
function describeRepairTrack(name, path, fields) {
|
|
5883
|
+
const descriptor = { name, path };
|
|
5884
|
+
for (const field of REPAIR_FIELDS) {
|
|
5885
|
+
if (field in fields) descriptor[field] = fields[field];
|
|
5886
|
+
}
|
|
5887
|
+
return descriptor;
|
|
5888
|
+
}
|
|
5889
|
+
function isSafeInteger(value) {
|
|
5890
|
+
return typeof value === "number" && Number.isSafeInteger(value);
|
|
5891
|
+
}
|
|
5892
|
+
function positiveInteger(value) {
|
|
5893
|
+
return isSafeInteger(value) && value > 0;
|
|
5894
|
+
}
|
|
5895
|
+
function dependsTarget(descriptor) {
|
|
5896
|
+
const depends = descriptor.depends;
|
|
5897
|
+
return Array.isArray(depends) && depends.length === 1 && typeof depends[0] === "string" && depends[0].length > 0 ? depends[0] : void 0;
|
|
5898
|
+
}
|
|
5899
|
+
function validateRepairTrackFields(descriptor, fail) {
|
|
5900
|
+
const { path } = descriptor;
|
|
5901
|
+
if (descriptor.depends !== void 0 && dependsTarget(descriptor) === void 0) {
|
|
5902
|
+
fail("track_repair_depends", `${path}.depends`, "must name exactly one source track");
|
|
5903
|
+
}
|
|
5904
|
+
if (descriptor.repairLayer !== void 0 && (!isSafeInteger(descriptor.repairLayer) || descriptor.repairLayer < 0)) {
|
|
5905
|
+
fail("track_repair_layer", `${path}.repairLayer`, "must be a non-negative integer");
|
|
5906
|
+
}
|
|
5907
|
+
if (descriptor.repairSymbols !== void 0 && (!positiveInteger(descriptor.repairSymbols) || descriptor.repairSymbols > MAX_REPAIR_SYMBOLS)) {
|
|
5908
|
+
fail("track_repair_layer", `${path}.repairSymbols`, `must be a positive integer at most ${MAX_REPAIR_SYMBOLS}`);
|
|
5909
|
+
}
|
|
5910
|
+
if (descriptor.priority !== void 0 && (!isSafeInteger(descriptor.priority) || descriptor.priority < REPAIR_PRIORITY_MIN || descriptor.priority > REPAIR_PRIORITY_MAX)) {
|
|
5911
|
+
fail(
|
|
5912
|
+
"track_repair_priority",
|
|
5913
|
+
`${path}.priority`,
|
|
5914
|
+
`must be an integer from ${REPAIR_PRIORITY_MIN} to ${REPAIR_PRIORITY_MAX} (MoQT scale, lower first)`
|
|
5915
|
+
);
|
|
5916
|
+
}
|
|
5917
|
+
if (descriptor.scope !== void 0) {
|
|
5918
|
+
if (descriptor.scope !== "keyframe") {
|
|
5919
|
+
fail("track_repair_overlay", `${path}.scope`, 'must be "keyframe"');
|
|
5920
|
+
}
|
|
5921
|
+
if (descriptor.repairLayer !== void 0) {
|
|
5922
|
+
fail("track_repair_overlay", `${path}.repairLayer`, "an overlay is a separate FEC instance and carries no repairLayer");
|
|
5923
|
+
}
|
|
5924
|
+
for (const field of ["depends", "sourceSymbols", "repairSymbols", "priority"]) {
|
|
5925
|
+
if (descriptor[field] === void 0) {
|
|
5926
|
+
fail("track_repair_overlay", `${path}.${field}`, `an overlay must declare ${field}`);
|
|
5927
|
+
}
|
|
5928
|
+
}
|
|
5929
|
+
}
|
|
5930
|
+
if (descriptor.sourceSymbols !== void 0) {
|
|
5931
|
+
if (descriptor.scope === void 0) {
|
|
5932
|
+
fail("track_repair_overlay", `${path}.sourceSymbols`, "only an overlay (scope: keyframe) declares its own sourceSymbols");
|
|
5933
|
+
}
|
|
5934
|
+
if (!positiveInteger(descriptor.sourceSymbols) || descriptor.sourceSymbols > MAX_RAPTORQ_SOURCE_SYMBOLS) {
|
|
5935
|
+
fail(
|
|
5936
|
+
"track_fec_bounds",
|
|
5937
|
+
`${path}.sourceSymbols`,
|
|
5938
|
+
`must be a positive integer at most ${MAX_RAPTORQ_SOURCE_SYMBOLS} (RFC 6330 source block limit)`
|
|
5939
|
+
);
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
if (isSafeInteger(descriptor.repairLayer) && descriptor.repairLayer >= 1) {
|
|
5943
|
+
for (const field of ["depends", "repairSymbols", "priority"]) {
|
|
5944
|
+
if (descriptor[field] === void 0) {
|
|
5945
|
+
fail("track_repair_layer", `${path}.${field}`, `repair layer ${descriptor.repairLayer} must declare ${field}`);
|
|
5946
|
+
}
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
function assembleRepairLayers(source, descriptors, fail = throwRepairContractError, options = {}) {
|
|
5951
|
+
const layerZeroName = typeof source.repairTrack === "string" && source.repairTrack.length > 0 ? source.repairTrack : void 0;
|
|
5952
|
+
const layerZero = layerZeroName === void 0 ? void 0 : descriptors.find((d) => d.name === layerZeroName);
|
|
5953
|
+
if (layerZeroName !== void 0 && layerZero === void 0 && options.layerZeroMustBeDeclared) {
|
|
5954
|
+
fail("track_repair_track", `${source.path}.repairTrack`, `unknown FEC repair track ${JSON.stringify(layerZeroName)}`);
|
|
5955
|
+
}
|
|
5956
|
+
const dependents = descriptors.filter((d) => d.name !== layerZeroName && dependsTarget(d) === source.name);
|
|
5957
|
+
const k = positiveInteger(source.sourceSymbols) ? source.sourceSymbols : 0;
|
|
5958
|
+
if (source.algorithm === "raptorq" && k > MAX_RAPTORQ_SOURCE_SYMBOLS) {
|
|
5959
|
+
fail(
|
|
5960
|
+
"track_fec_bounds",
|
|
5961
|
+
`${source.path}.sourceSymbols`,
|
|
5962
|
+
`must be at most ${MAX_RAPTORQ_SOURCE_SYMBOLS} (RFC 6330 source block limit)`
|
|
5963
|
+
);
|
|
5964
|
+
}
|
|
5965
|
+
if (layerZeroName === void 0) {
|
|
5966
|
+
if (dependents.length === 0) return void 0;
|
|
5967
|
+
fail(
|
|
5968
|
+
"track_repair_layer",
|
|
5969
|
+
`${dependents[0].path}.depends`,
|
|
5970
|
+
`repair layers of ${JSON.stringify(source.name)} require a layer 0 (fec.repairTrack) on the source`
|
|
5971
|
+
);
|
|
5972
|
+
}
|
|
5973
|
+
const layered = dependents.length > 0;
|
|
5974
|
+
let layerZeroSymbols = 0;
|
|
5975
|
+
if (positiveInteger(source.repairSymbols)) {
|
|
5976
|
+
layerZeroSymbols = source.repairSymbols;
|
|
5977
|
+
} else if (layered) {
|
|
5978
|
+
fail("track_fec", `${source.path}.repairSymbols`, "layered or overlay repair needs a positive integer repairSymbols on layer 0");
|
|
5979
|
+
}
|
|
5980
|
+
if (layered && !positiveInteger(source.sourceSymbols)) {
|
|
5981
|
+
fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
|
|
5982
|
+
}
|
|
5983
|
+
if (layered && source.algorithm !== "raptorq") {
|
|
5984
|
+
fail(
|
|
5985
|
+
"track_fec",
|
|
5986
|
+
`${source.path}.algorithm`,
|
|
5987
|
+
"repair layers and overlays are defined only for raptorq: a block code fixes its codeword length, so symbols of a larger P are not symbols of the code a receiver holding fewer layers decodes"
|
|
5988
|
+
);
|
|
5989
|
+
}
|
|
5990
|
+
let layerZeroPriority = DEFAULT_REPAIR_PRIORITY;
|
|
5991
|
+
if (layerZero !== void 0) {
|
|
5992
|
+
if (layerZero.depends !== void 0 && dependsTarget(layerZero) !== source.name) {
|
|
5993
|
+
fail(
|
|
5994
|
+
"track_repair_depends",
|
|
5995
|
+
`${layerZero.path}.depends`,
|
|
5996
|
+
`layer 0 of ${JSON.stringify(source.name)} must depend on that source`
|
|
5997
|
+
);
|
|
5998
|
+
}
|
|
5999
|
+
if (layerZero.repairLayer !== void 0 && layerZero.repairLayer !== 0) {
|
|
6000
|
+
fail("track_repair_layer", `${layerZero.path}.repairLayer`, "the track named by fec.repairTrack is layer 0");
|
|
6001
|
+
}
|
|
6002
|
+
if (layerZero.scope !== void 0) {
|
|
6003
|
+
fail("track_repair_overlay", `${layerZero.path}.scope`, "the track named by fec.repairTrack is base layer 0, not an overlay");
|
|
6004
|
+
}
|
|
6005
|
+
if (layerZero.repairSymbols !== void 0 && layerZero.repairSymbols !== layerZeroSymbols) {
|
|
6006
|
+
fail(
|
|
6007
|
+
"track_repair_layer",
|
|
6008
|
+
`${layerZero.path}.repairSymbols`,
|
|
6009
|
+
`must agree with the source's fec.repairSymbols (${layerZeroSymbols})`
|
|
6010
|
+
);
|
|
6011
|
+
}
|
|
6012
|
+
if (typeof layerZero.priority === "number") layerZeroPriority = layerZero.priority;
|
|
6013
|
+
}
|
|
6014
|
+
const baseLayers = [
|
|
6015
|
+
{ layer: 0, repairTrackName: layerZeroName, repairSymbols: layerZeroSymbols, rsIdOffset: 0, priority: layerZeroPriority }
|
|
6016
|
+
];
|
|
6017
|
+
const overlays = [];
|
|
6018
|
+
for (const d of dependents) {
|
|
6019
|
+
if (d.scope === void 0 && d.repairLayer === void 0) {
|
|
6020
|
+
fail(
|
|
6021
|
+
"track_repair_layer",
|
|
6022
|
+
`${d.path}.repairLayer`,
|
|
6023
|
+
`a repair track that depends on ${JSON.stringify(source.name)} must declare repairLayer (1..n) or scope: "keyframe"`
|
|
6024
|
+
);
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
6027
|
+
const layerTracks = dependents.filter((d) => d.scope === void 0).sort((a, b) => a.repairLayer - b.repairLayer);
|
|
6028
|
+
for (const d of dependents) {
|
|
6029
|
+
if (d.scope !== "keyframe") continue;
|
|
6030
|
+
if (overlays.length === 1) {
|
|
6031
|
+
fail(
|
|
6032
|
+
"track_repair_overlay",
|
|
6033
|
+
`${d.path}.scope`,
|
|
6034
|
+
`${JSON.stringify(source.name)} already has keyframe overlay ${JSON.stringify(overlays[0].repairTrackName)}: a RAP packet carries exactly two Source FEC Payload IDs (base, then overlay), so one overlay per source`
|
|
6035
|
+
);
|
|
6036
|
+
}
|
|
6037
|
+
const sourceSymbols = d.sourceSymbols;
|
|
6038
|
+
const repairSymbols = d.repairSymbols;
|
|
6039
|
+
if (sourceSymbols + repairSymbols - 1 > MAX_ENCODING_SYMBOL_ID) {
|
|
6040
|
+
fail(
|
|
6041
|
+
"track_fec_bounds",
|
|
6042
|
+
`${d.path}.repairSymbols`,
|
|
6043
|
+
`overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
6044
|
+
);
|
|
6045
|
+
}
|
|
6046
|
+
overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority });
|
|
6047
|
+
}
|
|
6048
|
+
let offset = layerZeroSymbols;
|
|
6049
|
+
let previousPriority = layerZeroPriority;
|
|
6050
|
+
layerTracks.forEach((d, i) => {
|
|
6051
|
+
const expected = i + 1;
|
|
6052
|
+
if (d.repairLayer === 0) {
|
|
6053
|
+
fail("track_repair_layer", `${d.path}.repairLayer`, `layer 0 of ${JSON.stringify(source.name)} is ${JSON.stringify(layerZeroName)}, named by fec.repairTrack`);
|
|
6054
|
+
}
|
|
6055
|
+
if (d.repairLayer !== expected) {
|
|
6056
|
+
fail(
|
|
6057
|
+
"track_repair_layer",
|
|
6058
|
+
`${d.path}.repairLayer`,
|
|
6059
|
+
i > 0 && d.repairLayer === layerTracks[i - 1].repairLayer ? `repair layer ${d.repairLayer} is declared twice for ${JSON.stringify(source.name)}` : `repair layers must be contiguous from 1: expected ${expected}, found ${d.repairLayer}`
|
|
6060
|
+
);
|
|
6061
|
+
}
|
|
6062
|
+
const priority = d.priority;
|
|
6063
|
+
if (priority < previousPriority) {
|
|
6064
|
+
fail(
|
|
6065
|
+
"track_repair_priority",
|
|
6066
|
+
`${d.path}.priority`,
|
|
6067
|
+
`must be at least ${previousPriority}, the priority of layer ${expected - 1}: priority is monotonic non-decreasing with layer index`
|
|
6068
|
+
);
|
|
6069
|
+
}
|
|
6070
|
+
previousPriority = priority;
|
|
6071
|
+
const repairSymbols = d.repairSymbols;
|
|
6072
|
+
baseLayers.push({ layer: expected, repairTrackName: d.name, repairSymbols, rsIdOffset: offset, priority });
|
|
6073
|
+
offset += repairSymbols;
|
|
6074
|
+
});
|
|
6075
|
+
const totalBaseRepairSymbols = offset;
|
|
6076
|
+
if (totalBaseRepairSymbols > MAX_REPAIR_SYMBOLS) {
|
|
6077
|
+
fail(
|
|
6078
|
+
"track_fec_bounds",
|
|
6079
|
+
`${layerTracks.length === 0 ? source.path : layerTracks[layerTracks.length - 1].path}.repairSymbols`,
|
|
6080
|
+
`total repair symbols across base layers exceeds the 24-bit RS_ID space (${MAX_REPAIR_SYMBOLS})`
|
|
6081
|
+
);
|
|
6082
|
+
}
|
|
6083
|
+
if (k + totalBaseRepairSymbols - 1 > MAX_ENCODING_SYMBOL_ID) {
|
|
6084
|
+
fail(
|
|
6085
|
+
"track_fec_bounds",
|
|
6086
|
+
`${source.path}.sourceSymbols`,
|
|
6087
|
+
`sourceSymbols + total base repair symbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
6088
|
+
);
|
|
6089
|
+
}
|
|
6090
|
+
return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
|
|
6091
|
+
}
|
|
6092
|
+
|
|
5738
6093
|
// src/carp-catalog.ts
|
|
5739
6094
|
var VALID_ROLE_SUFFIXES = /* @__PURE__ */ new Set(["base", "delta", "repair"]);
|
|
5740
6095
|
function parseTrackRole(trackName) {
|
|
@@ -5861,7 +6216,7 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
5861
6216
|
const tracks = catalog["tracks"];
|
|
5862
6217
|
const trackRecords = [];
|
|
5863
6218
|
const effective = (track, field) => track[field] ?? common[field];
|
|
5864
|
-
const
|
|
6219
|
+
const positiveInteger2 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
5865
6220
|
const positiveNumber = (input) => typeof input === "number" && Number.isFinite(input) && input > 0;
|
|
5866
6221
|
for (let index = 0; index < tracks.length; index++) {
|
|
5867
6222
|
const raw = tracks[index];
|
|
@@ -5897,21 +6252,27 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
5897
6252
|
const groupDurationTicks = effective(track, "groupDurationTicks");
|
|
5898
6253
|
const keyframeIntervalMs = effective(track, "keyframeIntervalMs");
|
|
5899
6254
|
const keyframeIntervalTicks = effective(track, "keyframeIntervalTicks");
|
|
5900
|
-
if (groupDurationMs !== void 0 && !
|
|
6255
|
+
if (groupDurationMs !== void 0 && !positiveInteger2(groupDurationMs)) {
|
|
5901
6256
|
catalogError("track_group_duration_ms", `${path}.groupDurationMs`, "must be a positive integer");
|
|
5902
6257
|
}
|
|
5903
|
-
if (groupDurationTicks !== void 0 && !
|
|
6258
|
+
if (groupDurationTicks !== void 0 && !positiveInteger2(groupDurationTicks)) {
|
|
5904
6259
|
catalogError("track_group_duration_ticks", `${path}.groupDurationTicks`, "must be a positive integer");
|
|
5905
6260
|
}
|
|
5906
|
-
if (keyframeIntervalMs !== void 0 && !positiveNumber(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !
|
|
6261
|
+
if (keyframeIntervalMs !== void 0 && !positiveNumber(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger2(keyframeIntervalTicks)) {
|
|
5907
6262
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
5908
6263
|
}
|
|
6264
|
+
if (packaging === "fec-repair") {
|
|
6265
|
+
rejectRepairTrackGeometry(path, track, catalogError);
|
|
6266
|
+
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
6267
|
+
} else {
|
|
6268
|
+
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
6269
|
+
}
|
|
5909
6270
|
if (packaging === "mmtp") {
|
|
5910
6271
|
const mmtpMode = effective(track, "mmtpMode");
|
|
5911
6272
|
if (mmtpMode !== "mpu" && mmtpMode !== "mfu") {
|
|
5912
6273
|
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
5913
6274
|
}
|
|
5914
|
-
if (!
|
|
6275
|
+
if (!positiveInteger2(timescale)) {
|
|
5915
6276
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
5916
6277
|
}
|
|
5917
6278
|
if (groupDurationMs === void 0 && groupDurationTicks === void 0) {
|
|
@@ -5938,12 +6299,19 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
5938
6299
|
if ("interleaveDepth" in config || "interleaveMs" in config) {
|
|
5939
6300
|
catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
|
|
5940
6301
|
}
|
|
5941
|
-
if (
|
|
6302
|
+
if ("enhancementRepair" in config) {
|
|
6303
|
+
catalogError(
|
|
6304
|
+
"track_fec",
|
|
6305
|
+
`${path}.fec.enhancementRepair`,
|
|
6306
|
+
"repair layers are self-describing fec-repair tracks (depends, repairLayer); fec.enhancementRepair is not supported"
|
|
6307
|
+
);
|
|
6308
|
+
}
|
|
6309
|
+
if (config["interleaveDepthMs"] !== void 0 && !positiveInteger2(config["interleaveDepthMs"])) {
|
|
5942
6310
|
catalogError("track_fec", `${path}.fec.interleaveDepthMs`, "must be a positive integer");
|
|
5943
6311
|
}
|
|
5944
6312
|
if (algorithm !== "none") {
|
|
5945
6313
|
for (const field of ["sourceSymbols", "repairSymbols", "symbolSize"]) {
|
|
5946
|
-
if (!
|
|
6314
|
+
if (!positiveInteger2(config[field])) {
|
|
5947
6315
|
catalogError("track_fec", `${path}.fec.${field}`, "must be a positive integer");
|
|
5948
6316
|
}
|
|
5949
6317
|
}
|
|
@@ -5953,15 +6321,43 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
5953
6321
|
}
|
|
5954
6322
|
}
|
|
5955
6323
|
}
|
|
6324
|
+
const repairDescriptors = trackRecords.flatMap(
|
|
6325
|
+
(track, index) => effective(track, "packaging") === "fec-repair" ? [describeRepairTrack(track["name"], `$.tracks[${index}]`, track)] : []
|
|
6326
|
+
);
|
|
6327
|
+
const reachability = repairReachability(
|
|
6328
|
+
trackRecords.filter((track) => effective(track, "packaging") !== "fec-repair").map((track) => track["fec"])
|
|
6329
|
+
);
|
|
6330
|
+
for (const descriptor of repairDescriptors) {
|
|
6331
|
+
assertRepairTrackReachable(descriptor, reachability, catalogError);
|
|
6332
|
+
const target = dependsTarget(descriptor);
|
|
6333
|
+
if (target === void 0) continue;
|
|
6334
|
+
const source = trackRecords.find((candidate) => candidate["name"] === target);
|
|
6335
|
+
const sourceFec = source?.["fec"];
|
|
6336
|
+
if (!source || effective(source, "packaging") !== "mmtp" || !sourceFec || sourceFec["algorithm"] === "none") {
|
|
6337
|
+
catalogError(
|
|
6338
|
+
"track_repair_depends",
|
|
6339
|
+
`${descriptor.path}.depends`,
|
|
6340
|
+
`${JSON.stringify(target)} is not an mmtp track with FEC`
|
|
6341
|
+
);
|
|
6342
|
+
}
|
|
6343
|
+
}
|
|
5956
6344
|
for (let index = 0; index < trackRecords.length; index++) {
|
|
5957
6345
|
const track = trackRecords[index];
|
|
5958
6346
|
const fec = track["fec"];
|
|
5959
6347
|
if (!fec || fec["algorithm"] === "none") continue;
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
6348
|
+
assembleRepairLayers(
|
|
6349
|
+
{
|
|
6350
|
+
name: track["name"],
|
|
6351
|
+
path: `$.tracks[${index}].fec`,
|
|
6352
|
+
algorithm: fec["algorithm"],
|
|
6353
|
+
sourceSymbols: fec["sourceSymbols"],
|
|
6354
|
+
repairSymbols: fec["repairSymbols"],
|
|
6355
|
+
repairTrack: fec["repairTrack"]
|
|
6356
|
+
},
|
|
6357
|
+
repairDescriptors,
|
|
6358
|
+
catalogError,
|
|
6359
|
+
{ layerZeroMustBeDeclared: true }
|
|
6360
|
+
);
|
|
5965
6361
|
}
|
|
5966
6362
|
const switchingSets = /* @__PURE__ */ new Map();
|
|
5967
6363
|
for (let index = 0; index < trackRecords.length; index++) {
|
|
@@ -8501,6 +8897,15 @@ function deriveFecInterleaveDepth(interleaveDepthMs, mediaUnitDurationMs) {
|
|
|
8501
8897
|
}
|
|
8502
8898
|
return Math.max(1, Math.floor(interleaveDepthMs / mediaUnitDurationMs + 0.5));
|
|
8503
8899
|
}
|
|
8900
|
+
function fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs) {
|
|
8901
|
+
if (!Number.isFinite(interleaveDepthMs) || !(interleaveDepthMs > 0)) {
|
|
8902
|
+
throw new Error(`[FEC] interleaveDepthMs must be a finite value > 0 (got ${interleaveDepthMs}ms). Fix encoder config.`);
|
|
8903
|
+
}
|
|
8904
|
+
if (!(reorderToleranceMs >= 0) || !Number.isFinite(reorderToleranceMs)) {
|
|
8905
|
+
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.`);
|
|
8906
|
+
}
|
|
8907
|
+
return Math.ceil(interleaveDepthMs + reorderToleranceMs);
|
|
8908
|
+
}
|
|
8504
8909
|
function parseRepairPacket(packet) {
|
|
8505
8910
|
const parsed = parseMoqRepairFrame(packet);
|
|
8506
8911
|
if (!parsed)
|
|
@@ -8602,32 +9007,18 @@ function computeFecLossWindowMs(fecInterleaveMs, fecK, jitterBufferMs) {
|
|
|
8602
9007
|
function computeFecDeliveryWindowMs(config) {
|
|
8603
9008
|
const fecInterleaveMs = config.interleaveDepthMs;
|
|
8604
9009
|
const fecK = config.sourceSymbols;
|
|
8605
|
-
if (fecInterleaveMs <= 0) {
|
|
9010
|
+
if (!Number.isFinite(fecInterleaveMs) || fecInterleaveMs <= 0) {
|
|
8606
9011
|
throw new Error(
|
|
8607
9012
|
`[TrackSession] fecInterleaveMs=${fecInterleaveMs}. Derive a positive FEC interleave window from the stream catalog.`
|
|
8608
9013
|
);
|
|
8609
9014
|
}
|
|
8610
|
-
if (fecK <= 0) {
|
|
9015
|
+
if (!Number.isFinite(fecK) || fecK <= 0) {
|
|
8611
9016
|
throw new Error(
|
|
8612
9017
|
`[TrackSession] fecK=${fecK}. Derive a positive FEC source-symbol count from the stream catalog.`
|
|
8613
9018
|
);
|
|
8614
9019
|
}
|
|
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);
|
|
9020
|
+
if (config.jitterBufferMs === void 0) return Math.ceil(fecInterleaveMs);
|
|
9021
|
+
return fecBlockBudgetMs(fecInterleaveMs, config.jitterBufferMs);
|
|
8631
9022
|
}
|
|
8632
9023
|
function computeFecDeliveryWindowMediaUnits(config, timestampTimescale) {
|
|
8633
9024
|
if (!Number.isFinite(timestampTimescale) || timestampTimescale <= 0) {
|
|
@@ -8643,7 +9034,7 @@ function computeFecDeliveryWindowMediaUnits(config, timestampTimescale) {
|
|
|
8643
9034
|
}
|
|
8644
9035
|
return deliveryWindow;
|
|
8645
9036
|
}
|
|
8646
|
-
var _state, _subscription, _hysteresisTimer, _joinDeadlineTimer, _previousPrimary, _manager, _suppressFired, _TrackSession_instances, transition_fn, clearHysteresis_fn, armJoinDeadline_fn, clearJoinDeadline_fn, suppress_fn, unsuppress_fn;
|
|
9037
|
+
var _state, _subscription, _hysteresisTimer, _joinDeadlineTimer, _previousPrimary, _manager, _suppressFired, _fecArmed, _TrackSession_instances, transition_fn, clearHysteresis_fn, armJoinDeadline_fn, clearJoinDeadline_fn, armFec_fn, disarmFec_fn, suppress_fn, unsuppress_fn;
|
|
8647
9038
|
var TrackSession = class {
|
|
8648
9039
|
constructor(config, manager) {
|
|
8649
9040
|
__privateAdd(this, _TrackSession_instances);
|
|
@@ -8660,6 +9051,12 @@ var TrackSession = class {
|
|
|
8660
9051
|
// from `failing` (exactly where a starving track sits) was re-subscribed to
|
|
8661
9052
|
// unicast with the host's media still muted: MoQ playing into a dead sink.
|
|
8662
9053
|
__privateAdd(this, _suppressFired, false);
|
|
9054
|
+
// Single FEC authority flag: set by the fec-setup edges (joinStarted,
|
|
9055
|
+
// enterUnicastFallback), cleared by the fec-teardown edge in #transition.
|
|
9056
|
+
// Setup and teardown are paired by construction, so a takeover timeout that
|
|
9057
|
+
// parks the session in `unicast` keeps the decoder the still-joined
|
|
9058
|
+
// transport is feeding, and the later unsubscribe still tears it down.
|
|
9059
|
+
__privateAdd(this, _fecArmed, false);
|
|
8663
9060
|
this.config = config;
|
|
8664
9061
|
__privateSet(this, _manager, manager);
|
|
8665
9062
|
}
|
|
@@ -8734,7 +9131,7 @@ var TrackSession = class {
|
|
|
8734
9131
|
joinStarted() {
|
|
8735
9132
|
if (__privateGet(this, _state) !== "unicast") return;
|
|
8736
9133
|
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "joining");
|
|
8737
|
-
|
|
9134
|
+
__privateMethod(this, _TrackSession_instances, armFec_fn).call(this);
|
|
8738
9135
|
}
|
|
8739
9136
|
/**
|
|
8740
9137
|
* any non-fallback state → unicast-fallback. Used when the SSM bridge is
|
|
@@ -8755,7 +9152,7 @@ var TrackSession = class {
|
|
|
8755
9152
|
__privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
|
|
8756
9153
|
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast-fallback");
|
|
8757
9154
|
__privateMethod(this, _TrackSession_instances, suppress_fn).call(this);
|
|
8758
|
-
|
|
9155
|
+
__privateMethod(this, _TrackSession_instances, armFec_fn).call(this);
|
|
8759
9156
|
}
|
|
8760
9157
|
/**
|
|
8761
9158
|
* unicast-fallback → unicast. Called when the SSM bridge appears mid-session
|
|
@@ -8786,7 +9183,11 @@ var TrackSession = class {
|
|
|
8786
9183
|
if (__privateGet(this, _state) !== "multicast" && __privateGet(this, _state) !== "amt") return;
|
|
8787
9184
|
__privateSet(this, _previousPrimary, __privateGet(this, _state));
|
|
8788
9185
|
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "failing");
|
|
8789
|
-
const hysteresisMs = computeFecLossWindowMs(
|
|
9186
|
+
const hysteresisMs = computeFecLossWindowMs(
|
|
9187
|
+
this.config.fecInterleaveMs,
|
|
9188
|
+
this.config.fecK,
|
|
9189
|
+
this.config.fecReorderToleranceMs
|
|
9190
|
+
);
|
|
8790
9191
|
__privateSet(this, _hysteresisTimer, setTimeout(() => {
|
|
8791
9192
|
this.hysteresisExpired();
|
|
8792
9193
|
}, hysteresisMs));
|
|
@@ -8810,23 +9211,19 @@ var TrackSession = class {
|
|
|
8810
9211
|
const prefs = this.config.preferredTransports;
|
|
8811
9212
|
const currentIdx = current ? prefs.indexOf(current) : -1;
|
|
8812
9213
|
const nextMode = prefs[currentIdx + 1];
|
|
8813
|
-
if (nextMode) {
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
__privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
|
|
8817
|
-
if (this.config.trackType === "audio") {
|
|
8818
|
-
__privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
|
|
8819
|
-
}
|
|
8820
|
-
} else {
|
|
8821
|
-
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "joining");
|
|
8822
|
-
__privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
|
|
8823
|
-
}
|
|
8824
|
-
} else {
|
|
8825
|
-
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
|
|
9214
|
+
if (nextMode !== void 0 && nextMode !== "moq") {
|
|
9215
|
+
__privateSet(this, _previousPrimary, nextMode);
|
|
9216
|
+
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "joining");
|
|
8826
9217
|
__privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
9218
|
+
return;
|
|
9219
|
+
}
|
|
9220
|
+
const from = __privateGet(this, _state);
|
|
9221
|
+
__privateSet(this, _previousPrimary, null);
|
|
9222
|
+
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
|
|
9223
|
+
__privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
|
|
9224
|
+
__privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
|
|
9225
|
+
if (from !== "unicast" && this.config.trackType === "audio") {
|
|
9226
|
+
__privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
|
|
8830
9227
|
}
|
|
8831
9228
|
}
|
|
8832
9229
|
/** Hysteresis expired → failback to next transport (Claim 9g). */
|
|
@@ -8850,11 +9247,20 @@ var TrackSession = class {
|
|
|
8850
9247
|
get isUnicastFallback() {
|
|
8851
9248
|
return __privateGet(this, _state) === "unicast-fallback";
|
|
8852
9249
|
}
|
|
9250
|
+
/**
|
|
9251
|
+
* True while this track owns a FEC decoder (fec-setup fired, fec-teardown
|
|
9252
|
+
* not yet). Stays true across a takeover timeout that parked the session in
|
|
9253
|
+
* `unicast`; SessionManager.failbackAll uses it to release such sessions.
|
|
9254
|
+
*/
|
|
9255
|
+
get isFecArmed() {
|
|
9256
|
+
return __privateGet(this, _fecArmed);
|
|
9257
|
+
}
|
|
8853
9258
|
dispose() {
|
|
8854
9259
|
__privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
|
|
8855
9260
|
__privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
|
|
8856
9261
|
__privateSet(this, _state, "idle");
|
|
8857
9262
|
__privateSet(this, _subscription, null);
|
|
9263
|
+
__privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
|
|
8858
9264
|
}
|
|
8859
9265
|
};
|
|
8860
9266
|
_state = new WeakMap();
|
|
@@ -8864,20 +9270,20 @@ _joinDeadlineTimer = new WeakMap();
|
|
|
8864
9270
|
_previousPrimary = new WeakMap();
|
|
8865
9271
|
_manager = new WeakMap();
|
|
8866
9272
|
_suppressFired = new WeakMap();
|
|
9273
|
+
_fecArmed = new WeakMap();
|
|
8867
9274
|
_TrackSession_instances = new WeakSet();
|
|
8868
9275
|
// -----------------------------------------------------------------------
|
|
8869
9276
|
// Internal
|
|
8870
9277
|
// -----------------------------------------------------------------------
|
|
8871
|
-
transition_fn = function(to) {
|
|
9278
|
+
transition_fn = function(to, opts) {
|
|
8872
9279
|
const from = __privateGet(this, _state);
|
|
8873
9280
|
if (from === to) return;
|
|
9281
|
+
const joinDeadlineMs = to === "joining" ? __privateGet(this, _manager).takeoverDeadlineMs : void 0;
|
|
8874
9282
|
__privateSet(this, _state, to);
|
|
8875
9283
|
if (from === "joining") __privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
|
|
8876
|
-
if (
|
|
9284
|
+
if (joinDeadlineMs !== void 0) __privateMethod(this, _TrackSession_instances, armJoinDeadline_fn).call(this, joinDeadlineMs);
|
|
8877
9285
|
const fecActive = (s) => s === "joining" || s === "multicast" || s === "amt" || s === "failing" || s === "unicast-fallback";
|
|
8878
|
-
if (fecActive(
|
|
8879
|
-
__privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-teardown" }, this.config);
|
|
8880
|
-
}
|
|
9286
|
+
if (!fecActive(to) && !opts?.retainFec) __privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
|
|
8881
9287
|
__privateGet(this, _manager).callbacks?.onStateChange?.(this.config.trackName, from, to);
|
|
8882
9288
|
};
|
|
8883
9289
|
clearHysteresis_fn = function() {
|
|
@@ -8886,14 +9292,13 @@ clearHysteresis_fn = function() {
|
|
|
8886
9292
|
__privateSet(this, _hysteresisTimer, null);
|
|
8887
9293
|
}
|
|
8888
9294
|
};
|
|
8889
|
-
armJoinDeadline_fn = function() {
|
|
9295
|
+
armJoinDeadline_fn = function(deadlineMs) {
|
|
8890
9296
|
__privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
|
|
8891
|
-
|
|
8892
|
-
if (deadlineMs <= 0) return;
|
|
9297
|
+
if (deadlineMs === 0) return;
|
|
8893
9298
|
__privateSet(this, _joinDeadlineTimer, setTimeout(() => {
|
|
8894
9299
|
__privateSet(this, _joinDeadlineTimer, null);
|
|
8895
9300
|
if (__privateGet(this, _state) !== "joining") return;
|
|
8896
|
-
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
|
|
9301
|
+
__privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast", { retainFec: true });
|
|
8897
9302
|
__privateGet(this, _manager).callbacks?.onTakeoverTimeout?.(this.config.trackName);
|
|
8898
9303
|
}, deadlineMs));
|
|
8899
9304
|
};
|
|
@@ -8903,6 +9308,18 @@ clearJoinDeadline_fn = function() {
|
|
|
8903
9308
|
__privateSet(this, _joinDeadlineTimer, null);
|
|
8904
9309
|
}
|
|
8905
9310
|
};
|
|
9311
|
+
/** Fire fec-setup exactly once per FEC epoch. */
|
|
9312
|
+
armFec_fn = function() {
|
|
9313
|
+
if (__privateGet(this, _fecArmed)) return;
|
|
9314
|
+
__privateSet(this, _fecArmed, true);
|
|
9315
|
+
__privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-setup" }, this.config);
|
|
9316
|
+
};
|
|
9317
|
+
/** Fire fec-teardown for an armed decoder; no-op when none is armed. */
|
|
9318
|
+
disarmFec_fn = function() {
|
|
9319
|
+
if (!__privateGet(this, _fecArmed)) return;
|
|
9320
|
+
__privateSet(this, _fecArmed, false);
|
|
9321
|
+
__privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-teardown" }, this.config);
|
|
9322
|
+
};
|
|
8906
9323
|
/** Fire onSuppress(true) exactly once per suppression epoch. */
|
|
8907
9324
|
suppress_fn = function() {
|
|
8908
9325
|
if (__privateGet(this, _suppressFired)) return;
|
|
@@ -8915,18 +9332,14 @@ unsuppress_fn = function() {
|
|
|
8915
9332
|
__privateSet(this, _suppressFired, false);
|
|
8916
9333
|
__privateGet(this, _manager).callbacks?.onSuppress?.(this.config.trackName, false);
|
|
8917
9334
|
};
|
|
9335
|
+
var MAX_TAKEOVER_DEADLINE_MS = 2147483647;
|
|
9336
|
+
var _takeoverDeadlineMs, _SessionManager_instances, requireTakeoverDeadlineMs_fn;
|
|
8918
9337
|
var SessionManager = class {
|
|
8919
9338
|
constructor(poolOptions) {
|
|
9339
|
+
__privateAdd(this, _SessionManager_instances);
|
|
8920
9340
|
this.sessions = /* @__PURE__ */ new Map();
|
|
8921
9341
|
this.callbacks = null;
|
|
8922
|
-
|
|
8923
|
-
* Takeover deadline (BLO-9413/D9): max time a session may sit in `joining`
|
|
8924
|
-
* without a RAP before returning to `unicast` and firing onTakeoverTimeout.
|
|
8925
|
-
* MoQ is never suppressed during `joining`, so expiry is a silent abandon —
|
|
8926
|
-
* playback never glitches. Hosts tune per stream (e.g. GOP length); 0
|
|
8927
|
-
* disables.
|
|
8928
|
-
*/
|
|
8929
|
-
this.takeoverDeadlineMs = 5e3;
|
|
9342
|
+
__privateAdd(this, _takeoverDeadlineMs);
|
|
8930
9343
|
this.pool = new TransportPool(poolOptions);
|
|
8931
9344
|
this.pool.onSubscriptionFailed((sub) => {
|
|
8932
9345
|
for (const trackName of sub.consumers) {
|
|
@@ -8935,18 +9348,56 @@ var SessionManager = class {
|
|
|
8935
9348
|
}
|
|
8936
9349
|
});
|
|
8937
9350
|
}
|
|
9351
|
+
/**
|
|
9352
|
+
* Takeover deadline (BLO-9413/D9): the time a session may sit in `joining`
|
|
9353
|
+
* without a RAP before returning to `unicast` and firing onTakeoverTimeout.
|
|
9354
|
+
* MoQ is never suppressed during `joining`, so expiry abandons the takeover
|
|
9355
|
+
* without a playback glitch. The host derives it from the catalog (RAP
|
|
9356
|
+
* cadence from groupDurationTicks/timescale plus the signaled FEC delivery
|
|
9357
|
+
* window or reorder tolerance) and sets it before addTrack(). There is no
|
|
9358
|
+
* default: an unset value fails addTrack() closed, and reading the getter
|
|
9359
|
+
* before assignment throws the same way, so no host ever holds a
|
|
9360
|
+
* `number | undefined` it could coalesce back into a default.
|
|
9361
|
+
* `hasTakeoverDeadline` answers whether one was admitted. A declared 0
|
|
9362
|
+
* disables the deadline. The value is an integer number of milliseconds:
|
|
9363
|
+
* setTimeout truncates fractions, so a host that divides ticks by a
|
|
9364
|
+
* timescale must round before assigning.
|
|
9365
|
+
*
|
|
9366
|
+
* Assignment validates, so the diagnostic lands at the host's own call site.
|
|
9367
|
+
* That is what bounds the blast radius: `joining` is entered from
|
|
9368
|
+
* joinStarted(), from the transportFailed() failover branch -- itself
|
|
9369
|
+
* reachable from a setTimeout via hysteresisExpired(), where no caller could
|
|
9370
|
+
* catch a throw -- and from the activateMulticast()/activateAmt()/pool-failure
|
|
9371
|
+
* loops, where a throw on one session would abandon its siblings mid-loop
|
|
9372
|
+
* (the split-brain those loops exist to prevent). Refusing a bad value at
|
|
9373
|
+
* assignment means no host mutation can make an already-admitted session
|
|
9374
|
+
* throw out of a transport edge.
|
|
9375
|
+
*/
|
|
9376
|
+
get takeoverDeadlineMs() {
|
|
9377
|
+
return __privateMethod(this, _SessionManager_instances, requireTakeoverDeadlineMs_fn).call(this);
|
|
9378
|
+
}
|
|
9379
|
+
set takeoverDeadlineMs(value) {
|
|
9380
|
+
if (!Number.isInteger(value) || value < 0 || value > MAX_TAKEOVER_DEADLINE_MS) {
|
|
9381
|
+
throw new Error(
|
|
9382
|
+
`[SessionManager] takeoverDeadlineMs must be an integer from 0 to ${MAX_TAKEOVER_DEADLINE_MS} (0 disables it, larger values overflow setTimeout); got ${String(value)}`
|
|
9383
|
+
);
|
|
9384
|
+
}
|
|
9385
|
+
__privateSet(this, _takeoverDeadlineMs, value);
|
|
9386
|
+
}
|
|
9387
|
+
/** True once the host has admitted a deadline; a declared 0 counts. */
|
|
9388
|
+
get hasTakeoverDeadline() {
|
|
9389
|
+
return __privateGet(this, _takeoverDeadlineMs) !== void 0;
|
|
9390
|
+
}
|
|
8938
9391
|
/** Narrow to MMTP callbacks (onTrackEvent). Safe — optional chaining handles PIM-only consumers. */
|
|
8939
9392
|
get mmtp() {
|
|
8940
9393
|
return this.callbacks;
|
|
8941
9394
|
}
|
|
8942
|
-
// -----------------------------------------------------------------------
|
|
8943
|
-
// Track management
|
|
8944
|
-
// -----------------------------------------------------------------------
|
|
8945
9395
|
/** Add a track session from catalog config. */
|
|
8946
9396
|
addTrack(config) {
|
|
8947
9397
|
if (this.sessions.has(config.trackName)) {
|
|
8948
9398
|
throw new Error(`[SessionManager] Track "${config.trackName}" already exists`);
|
|
8949
9399
|
}
|
|
9400
|
+
__privateMethod(this, _SessionManager_instances, requireTakeoverDeadlineMs_fn).call(this);
|
|
8950
9401
|
const session = new TrackSession(config, this);
|
|
8951
9402
|
this.sessions.set(config.trackName, session);
|
|
8952
9403
|
return session;
|
|
@@ -8970,8 +9421,9 @@ var SessionManager = class {
|
|
|
8970
9421
|
* Prevents split-brain between video and audio.
|
|
8971
9422
|
*
|
|
8972
9423
|
* A takeover deadline can return a track from `joining` to `unicast` while
|
|
8973
|
-
* the multicast socket keeps delivering packets
|
|
8974
|
-
* later,
|
|
9424
|
+
* the multicast socket keeps delivering packets and the track keeps its FEC
|
|
9425
|
+
* decoder armed. If a valid RAP arrives later, that late-RAP edge suppresses
|
|
9426
|
+
* unicast and promotes multicast without a second fec-setup.
|
|
8975
9427
|
*/
|
|
8976
9428
|
activateMulticast() {
|
|
8977
9429
|
for (const [, session] of this.sessions) {
|
|
@@ -9003,13 +9455,17 @@ var SessionManager = class {
|
|
|
9003
9455
|
* and they must drain uninterrupted across transport-state events.
|
|
9004
9456
|
*
|
|
9005
9457
|
* Coherence invariant (BLO-9413): after this returns, every non-fallback
|
|
9006
|
-
* session is `unicast` (or `idle`)
|
|
9007
|
-
* any outstanding suppression regardless of the state
|
|
9008
|
-
* (`failing` included; see TrackSession.#suppressFired)
|
|
9458
|
+
* session is `unicast` (or `idle`), unsuppressed, and without a FEC decoder.
|
|
9459
|
+
* unsubscribe() unwinds any outstanding suppression regardless of the state
|
|
9460
|
+
* it tears down from (`failing` included; see TrackSession.#suppressFired),
|
|
9461
|
+
* and a session that a takeover timeout parked in `unicast` with its decoder
|
|
9462
|
+
* still armed is cycled too, because this transport edge is what releases
|
|
9463
|
+
* that decoder (unsubscribe fires fec-teardown).
|
|
9009
9464
|
*/
|
|
9010
9465
|
failbackAll() {
|
|
9011
9466
|
for (const [, session] of this.sessions) {
|
|
9012
|
-
|
|
9467
|
+
const parkedWithFec = session.state === "unicast" && session.isFecArmed;
|
|
9468
|
+
if (parkedWithFec || session.state !== "idle" && session.state !== "unicast" && session.state !== "unicast-fallback") {
|
|
9013
9469
|
session.unsubscribe();
|
|
9014
9470
|
session.subscribe();
|
|
9015
9471
|
}
|
|
@@ -9093,6 +9549,27 @@ var SessionManager = class {
|
|
|
9093
9549
|
this.callbacks = null;
|
|
9094
9550
|
}
|
|
9095
9551
|
};
|
|
9552
|
+
_takeoverDeadlineMs = new WeakMap();
|
|
9553
|
+
_SessionManager_instances = new WeakSet();
|
|
9554
|
+
// -----------------------------------------------------------------------
|
|
9555
|
+
// Track management
|
|
9556
|
+
// -----------------------------------------------------------------------
|
|
9557
|
+
/**
|
|
9558
|
+
* The admitted takeover deadline. Throws only when the host never set one,
|
|
9559
|
+
* every other invalid value being refused by the setter, and returns a
|
|
9560
|
+
* declared 0 as 0. The getter and addTrack() both route through it, so a
|
|
9561
|
+
* session cannot exist without an admitted deadline, which is what makes
|
|
9562
|
+
* the #transition() read unable to throw on an already-admitted session.
|
|
9563
|
+
*/
|
|
9564
|
+
requireTakeoverDeadlineMs_fn = function() {
|
|
9565
|
+
const value = __privateGet(this, _takeoverDeadlineMs);
|
|
9566
|
+
if (value === void 0) {
|
|
9567
|
+
throw new Error(
|
|
9568
|
+
"[SessionManager] takeoverDeadlineMs is unset; set a catalog-derived takeover deadline (0 disables it) before adding tracks"
|
|
9569
|
+
);
|
|
9570
|
+
}
|
|
9571
|
+
return value;
|
|
9572
|
+
};
|
|
9096
9573
|
|
|
9097
9574
|
// src/fec-manager.ts
|
|
9098
9575
|
var MIN_INTERLEAVE_DEPTH_MS = 33;
|
|
@@ -9111,7 +9588,7 @@ function newFecCounters() {
|
|
|
9111
9588
|
greenFillFrames: 0
|
|
9112
9589
|
};
|
|
9113
9590
|
}
|
|
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;
|
|
9591
|
+
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
9592
|
var FECManager = class {
|
|
9116
9593
|
constructor() {
|
|
9117
9594
|
__privateAdd(this, _FECManager_instances);
|
|
@@ -9215,6 +9692,7 @@ var FECManager = class {
|
|
|
9215
9692
|
// validation harness — which caps headless warnings at 500 — fails even
|
|
9216
9693
|
// though the errors are duplicates of a single underlying event.
|
|
9217
9694
|
__privateAdd(this, _workerErrorCounts, /* @__PURE__ */ new Map());
|
|
9695
|
+
__privateAdd(this, _decoderUnavailableEvents, 0);
|
|
9218
9696
|
__privateAdd(this, _repairSymbolSizeMismatchCount, 0);
|
|
9219
9697
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
9220
9698
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
@@ -9223,6 +9701,17 @@ var FECManager = class {
|
|
|
9223
9701
|
this.onBlockStarted = null;
|
|
9224
9702
|
this.onBlockComplete = null;
|
|
9225
9703
|
this.onBlockFailed = null;
|
|
9704
|
+
/**
|
|
9705
|
+
* Fired once per stream when its Worker decoder stops being routable.
|
|
9706
|
+
* `reason` is 'cleared' when clearFecWorker() removed it and 'disposed' when
|
|
9707
|
+
* a symbol or reset found the registered client already disposed and
|
|
9708
|
+
* evicted it. `fallbackDecoder` is 'sync' when a synchronous WASM decoder
|
|
9709
|
+
* registered for the same stream keeps decoding its symbols, and 'none'
|
|
9710
|
+
* when nothing does. Only 'none' leaves the stream unprotected: the host
|
|
9711
|
+
* must then register a decoder again or leave the stream, because counting
|
|
9712
|
+
* its symbols as handled would hide the loss.
|
|
9713
|
+
*/
|
|
9714
|
+
this.onDecoderUnavailable = null;
|
|
9226
9715
|
// D-28 on-demand repair callbacks. When onRepairNeeded is registered, each
|
|
9227
9716
|
// block arms a one-shot repair deadline after the derived K-symbol source
|
|
9228
9717
|
// horizon; a block still short of K when it fires requests a per-SBN MoQ
|
|
@@ -9256,6 +9745,7 @@ var FECManager = class {
|
|
|
9256
9745
|
startupRepairReadyPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairReadyPackets)),
|
|
9257
9746
|
startupRepairFailOpenPackets: __privateMethod(this, _FECManager_instances, packetIdsForStreamKeys_fn).call(this, __privateGet(this, _startupRepairFailOpenPackets)),
|
|
9258
9747
|
pendingWorkerCleanups: __privateGet(this, _pendingWorkerCleanups).size,
|
|
9748
|
+
decoderUnavailableEvents: __privateGet(this, _decoderUnavailableEvents),
|
|
9259
9749
|
repairTrackedBlocks: __privateGet(this, _blockRepairRsIds).size,
|
|
9260
9750
|
lifecycleTrace: __privateGet(this, _lifecycleTrace).map((entry) => ({ ...entry }))
|
|
9261
9751
|
};
|
|
@@ -9390,8 +9880,12 @@ var FECManager = class {
|
|
|
9390
9880
|
__privateMethod(this, _FECManager_instances, discardFecDecoderClient_fn).call(this, client);
|
|
9391
9881
|
}
|
|
9392
9882
|
}
|
|
9393
|
-
for (const [key, client] of __privateGet(this, _workerClients)) {
|
|
9883
|
+
for (const [key, client] of [...__privateGet(this, _workerClients)]) {
|
|
9394
9884
|
if (!__privateMethod(this, _FECManager_instances, belongsToStream_fn).call(this, key, packetId, catalogTrackName)) continue;
|
|
9885
|
+
if (client.disposed === true) {
|
|
9886
|
+
__privateMethod(this, _FECManager_instances, evictDisposedWorker_fn).call(this, client);
|
|
9887
|
+
continue;
|
|
9888
|
+
}
|
|
9395
9889
|
client.reset();
|
|
9396
9890
|
clients.add(client);
|
|
9397
9891
|
}
|
|
@@ -9611,6 +10105,12 @@ var FECManager = class {
|
|
|
9611
10105
|
}
|
|
9612
10106
|
const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
|
|
9613
10107
|
__privateMethod(this, _FECManager_instances, assertExclusiveDecoderClient_fn).call(this, streamKey, client, __privateGet(this, _workerClients), "worker");
|
|
10108
|
+
const incumbent = __privateGet(this, _workerClients).get(streamKey);
|
|
10109
|
+
if (incumbent !== void 0 && incumbent !== client) {
|
|
10110
|
+
throw new Error(
|
|
10111
|
+
`[FECManager] stream ${streamKey} already routes to a Worker; call clearFecWorker before registering another`
|
|
10112
|
+
);
|
|
10113
|
+
}
|
|
9614
10114
|
if (config) __privateMethod(this, _FECManager_instances, upsertTrackConfig_fn).call(this, packetId, config);
|
|
9615
10115
|
const workerK = __privateMethod(this, _FECManager_instances, resolveTrackConfig_fn).call(this, packetId).k;
|
|
9616
10116
|
__privateGet(this, _workerClients).set(streamKey, client);
|
|
@@ -9697,14 +10197,7 @@ var FECManager = class {
|
|
|
9697
10197
|
const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
|
|
9698
10198
|
return block.packetId === packetId && block.sbn === sbn && __privateGet(this, _pendingWorkerCleanupClients).get(key) === client;
|
|
9699
10199
|
});
|
|
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
|
-
}
|
|
10200
|
+
for (const key of cleanupKeys) __privateMethod(this, _FECManager_instances, settleOwedCleanup_fn).call(this, key, "cleanup-ack");
|
|
9708
10201
|
});
|
|
9709
10202
|
client.onError((msg, code) => {
|
|
9710
10203
|
const requestedKind = code ?? msg;
|
|
@@ -9720,6 +10213,25 @@ var FECManager = class {
|
|
|
9720
10213
|
}
|
|
9721
10214
|
});
|
|
9722
10215
|
}
|
|
10216
|
+
/**
|
|
10217
|
+
* Remove a stream's Worker decoder from routing.
|
|
10218
|
+
*
|
|
10219
|
+
* Returns false when no Worker is registered under that exact stream key.
|
|
10220
|
+
* On success every cleanup acknowledgement still owed by the client is
|
|
10221
|
+
* resolved by failing its block now (a Worker that is going away cannot
|
|
10222
|
+
* post it), the client's block ownership is released, and
|
|
10223
|
+
* onDecoderUnavailable fires once with reason 'cleared' and the decoder
|
|
10224
|
+
* that remains for the stream ('sync' or 'none'). Call this before
|
|
10225
|
+
* disposing the client; a client disposed while still registered is
|
|
10226
|
+
* evicted on its next symbol or reset with reason 'disposed'.
|
|
10227
|
+
*/
|
|
10228
|
+
clearFecWorker(packetId, catalogTrackName) {
|
|
10229
|
+
const streamKey = __privateMethod(this, _FECManager_instances, streamKey_fn).call(this, packetId, catalogTrackName);
|
|
10230
|
+
const client = __privateGet(this, _workerClients).get(streamKey);
|
|
10231
|
+
if (!client) return false;
|
|
10232
|
+
__privateMethod(this, _FECManager_instances, retireWorker_fn).call(this, streamKey, client, "cleared");
|
|
10233
|
+
return true;
|
|
10234
|
+
}
|
|
9723
10235
|
/** Called by player when framerate is known (from decoder output). Refines FEC block timeout. */
|
|
9724
10236
|
setFramerate(fps) {
|
|
9725
10237
|
if (__privateGet(this, _fpsDetected) || fps <= 0) return;
|
|
@@ -9770,7 +10282,7 @@ var FECManager = class {
|
|
|
9770
10282
|
const sbn = Math.floor(ssId / this.kForPacket(packetId));
|
|
9771
10283
|
const blockKey = __privateMethod(this, _FECManager_instances, blockKey_fn).call(this, sbn, packetId, catalogTrackName);
|
|
9772
10284
|
const syncBlockOwner = __privateGet(this, _syncDecoderBlockOwners).get(blockKey);
|
|
9773
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
10285
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
9774
10286
|
if (workerClient && !syncBlockOwner) {
|
|
9775
10287
|
if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
|
|
9776
10288
|
const buf = fecData.buffer.slice(
|
|
@@ -9847,7 +10359,7 @@ var FECManager = class {
|
|
|
9847
10359
|
if (__privateGet(this, _repairRequestedBlocks).has(blockKey)) {
|
|
9848
10360
|
__privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, "repair-arrived", sbn, packetId, catalogTrackName, rsId);
|
|
9849
10361
|
}
|
|
9850
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
10362
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
9851
10363
|
if (workerClient && !syncBlockOwner) {
|
|
9852
10364
|
if (!__privateMethod(this, _FECManager_instances, claimDecoderBlock_fn).call(this, workerClient, sbn, catalogTrackName)) return null;
|
|
9853
10365
|
const buf = fecData.buffer.slice(
|
|
@@ -10132,6 +10644,7 @@ _fpsDetected = new WeakMap();
|
|
|
10132
10644
|
_fecFps = new WeakMap();
|
|
10133
10645
|
_fecInterleaveDepthMs = new WeakMap();
|
|
10134
10646
|
_workerErrorCounts = new WeakMap();
|
|
10647
|
+
_decoderUnavailableEvents = new WeakMap();
|
|
10135
10648
|
_repairSymbolSizeMismatchCount = new WeakMap();
|
|
10136
10649
|
_FECManager_instances = new WeakSet();
|
|
10137
10650
|
streamKey_fn = function(packetId, catalogTrackName) {
|
|
@@ -10151,6 +10664,14 @@ belongsToStream_fn = function(key, packetId, catalogTrackName) {
|
|
|
10151
10664
|
packetIdsForStreamKeys_fn = function(keys) {
|
|
10152
10665
|
return [...new Set([...keys].map((key) => Number(key.split(":", 1)[0])))];
|
|
10153
10666
|
};
|
|
10667
|
+
parseStreamKey_fn = function(key) {
|
|
10668
|
+
const separator = key.indexOf(":");
|
|
10669
|
+
if (separator < 0) return { packetId: Number(key) || 0 };
|
|
10670
|
+
return {
|
|
10671
|
+
packetId: Number(key.slice(0, separator)) || 0,
|
|
10672
|
+
catalogTrackName: decodeURIComponent(key.slice(separator + 1))
|
|
10673
|
+
};
|
|
10674
|
+
};
|
|
10154
10675
|
blockKey_fn = function(sbn, packetId, catalogTrackName) {
|
|
10155
10676
|
const base = `${packetId}:${sbn}`;
|
|
10156
10677
|
return catalogTrackName === void 0 ? base : `${base}:${encodeURIComponent(catalogTrackName)}`;
|
|
@@ -10170,6 +10691,18 @@ decoderForPacket_fn = function(packetId, catalogTrackName) {
|
|
|
10170
10691
|
workerForPacket_fn = function(packetId, catalogTrackName) {
|
|
10171
10692
|
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
10693
|
};
|
|
10694
|
+
/**
|
|
10695
|
+
* The stream's Worker client for routing, or undefined after evicting a
|
|
10696
|
+
* registered client that was already disposed. A disposed client throws on
|
|
10697
|
+
* every command, so it leaves routing here before a symbol reaches it and
|
|
10698
|
+
* the stream reports its decoder unavailable instead.
|
|
10699
|
+
*/
|
|
10700
|
+
routableWorkerForPacket_fn = function(packetId, catalogTrackName) {
|
|
10701
|
+
const client = __privateMethod(this, _FECManager_instances, workerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
10702
|
+
if (client === void 0 || client.disposed !== true) return client;
|
|
10703
|
+
__privateMethod(this, _FECManager_instances, evictDisposedWorker_fn).call(this, client);
|
|
10704
|
+
return void 0;
|
|
10705
|
+
};
|
|
10173
10706
|
claimDecoderBlock_fn = function(client, sbn, catalogTrackName) {
|
|
10174
10707
|
let blocks = __privateGet(this, _decoderBlockOwners).get(client);
|
|
10175
10708
|
if (!blocks) {
|
|
@@ -10337,7 +10870,7 @@ armBlockTimeout_fn = function(sbn, packetId, catalogTrackName, delayMs) {
|
|
|
10337
10870
|
__privateMethod(this, _FECManager_instances, failBlock_fn).call(this, sbn, packetId, false, catalogTrackName);
|
|
10338
10871
|
return;
|
|
10339
10872
|
}
|
|
10340
|
-
const workerClient = __privateMethod(this, _FECManager_instances,
|
|
10873
|
+
const workerClient = __privateMethod(this, _FECManager_instances, routableWorkerForPacket_fn).call(this, packetId, catalogTrackName);
|
|
10341
10874
|
if (workerClient) {
|
|
10342
10875
|
__privateGet(this, _pendingWorkerCleanups).add(key);
|
|
10343
10876
|
__privateGet(this, _pendingWorkerCleanupClients).set(key, workerClient);
|
|
@@ -10420,6 +10953,59 @@ markStartupPartial_fn = function(blockKey) {
|
|
|
10420
10953
|
));
|
|
10421
10954
|
}
|
|
10422
10955
|
};
|
|
10956
|
+
/**
|
|
10957
|
+
* Take a Worker client out of routing under one stream key, fail the blocks
|
|
10958
|
+
* whose completion it still owed, and report the stream's decoder
|
|
10959
|
+
* unavailable together with whatever still decodes the stream.
|
|
10960
|
+
*/
|
|
10961
|
+
retireWorker_fn = function(streamKey, client, reason) {
|
|
10962
|
+
__privateGet(this, _workerClients).delete(streamKey);
|
|
10963
|
+
__privateMethod(this, _FECManager_instances, releaseWorkerClient_fn).call(this, client);
|
|
10964
|
+
__privateWrapper(this, _decoderUnavailableEvents)._++;
|
|
10965
|
+
const stream = __privateMethod(this, _FECManager_instances, parseStreamKey_fn).call(this, streamKey);
|
|
10966
|
+
const fallbackDecoder = __privateMethod(this, _FECManager_instances, decoderForPacket_fn).call(this, stream.packetId, stream.catalogTrackName) ? "sync" : "none";
|
|
10967
|
+
this.onDecoderUnavailable?.({
|
|
10968
|
+
packetId: stream.packetId,
|
|
10969
|
+
...stream.catalogTrackName === void 0 ? {} : { catalogTrackName: stream.catalogTrackName },
|
|
10970
|
+
reason,
|
|
10971
|
+
fallbackDecoder
|
|
10972
|
+
});
|
|
10973
|
+
};
|
|
10974
|
+
/**
|
|
10975
|
+
* Fail every block whose Worker cleanup acknowledgement is owed by `client`
|
|
10976
|
+
* and drop its block ownership, so no block waits on a message the Worker
|
|
10977
|
+
* will never post.
|
|
10978
|
+
*/
|
|
10979
|
+
releaseWorkerClient_fn = function(client) {
|
|
10980
|
+
const owed = [...__privateGet(this, _pendingWorkerCleanupClients)].filter(([, owner]) => owner === client).map(([key]) => key);
|
|
10981
|
+
for (const key of owed) __privateMethod(this, _FECManager_instances, settleOwedCleanup_fn).call(this, key, "decoder-unavailable");
|
|
10982
|
+
__privateGet(this, _decoderBlockOwners).delete(client);
|
|
10983
|
+
};
|
|
10984
|
+
/**
|
|
10985
|
+
* Resolve one owed Worker cleanup: drop the pending entry and fail the block
|
|
10986
|
+
* unless it already completed. Shared by the cleanup acknowledgement and by
|
|
10987
|
+
* Worker retirement, so the two paths cannot drift in their bookkeeping.
|
|
10988
|
+
*/
|
|
10989
|
+
settleOwedCleanup_fn = function(key, event) {
|
|
10990
|
+
__privateGet(this, _pendingWorkerCleanups).delete(key);
|
|
10991
|
+
__privateGet(this, _pendingWorkerCleanupClients).delete(key);
|
|
10992
|
+
if (__privateGet(this, _completedBlocks).has(key)) return;
|
|
10993
|
+
const block = __privateMethod(this, _FECManager_instances, parseBlockKey_fn).call(this, key);
|
|
10994
|
+
__privateMethod(this, _FECManager_instances, traceLifecycle_fn).call(this, event, block.sbn, block.packetId, block.catalogTrackName);
|
|
10995
|
+
__privateMethod(this, _FECManager_instances, failBlock_fn).call(this, block.sbn, block.packetId, false, block.catalogTrackName);
|
|
10996
|
+
};
|
|
10997
|
+
/** Evict a disposed client under every stream key that still maps to it. */
|
|
10998
|
+
evictDisposedWorker_fn = function(client) {
|
|
10999
|
+
for (const [key, registered] of [...__privateGet(this, _workerClients)]) {
|
|
11000
|
+
if (registered !== client) continue;
|
|
11001
|
+
const stream = __privateMethod(this, _FECManager_instances, parseStreamKey_fn).call(this, key);
|
|
11002
|
+
const track = stream.catalogTrackName === void 0 ? "" : ` track=${stream.catalogTrackName}`;
|
|
11003
|
+
console.warn(
|
|
11004
|
+
`[FECManager] packetId=${stream.packetId}${track} Worker decoder was disposed while still registered; evicting it`
|
|
11005
|
+
);
|
|
11006
|
+
__privateMethod(this, _FECManager_instances, retireWorker_fn).call(this, key, client, "disposed");
|
|
11007
|
+
}
|
|
11008
|
+
};
|
|
10423
11009
|
routeSyncCleanup_fn = function(decoder, sbn, packetId) {
|
|
10424
11010
|
let framed;
|
|
10425
11011
|
try {
|
|
@@ -12038,7 +12624,7 @@ buildFrameMeta_fn = function(assembled, packetId, seq, timing, recovered = false
|
|
|
12038
12624
|
}
|
|
12039
12625
|
return meta;
|
|
12040
12626
|
};
|
|
12041
|
-
sequencerFor_fn = function(packetId,
|
|
12627
|
+
sequencerFor_fn = function(packetId, _trackType2, catalogTrackName) {
|
|
12042
12628
|
const windowSize = __privateGet(this, _reassemblyPolicy) ? mmtpFrameReorderWindowFrames(__privateGet(this, _reassemblyPolicy), __privateGet(this, _reorderWindow)) : __privateGet(this, _reorderWindow);
|
|
12043
12629
|
if (windowSize <= 0) return null;
|
|
12044
12630
|
const streamKey = __privateMethod(this, _MmtpContainerParser_instances, streamKey_fn2).call(this, packetId, catalogTrackName);
|
|
@@ -14603,12 +15189,22 @@ function createDefaultRepairLifecycleEvent(detail, options) {
|
|
|
14603
15189
|
function isRecord(value) {
|
|
14604
15190
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14605
15191
|
}
|
|
14606
|
-
function
|
|
15192
|
+
function isRepairStreamIdentity(value) {
|
|
14607
15193
|
if (!isRecord(value)) return false;
|
|
14608
15194
|
const packetId = value["packetId"];
|
|
14609
15195
|
const catalogTrackName = value["catalogTrackName"];
|
|
15196
|
+
return Number.isSafeInteger(packetId) && packetId >= 0 && (catalogTrackName === null || typeof catalogTrackName === "string" && catalogTrackName.length > 0);
|
|
15197
|
+
}
|
|
15198
|
+
function isRepairBlockIdentity(value) {
|
|
15199
|
+
if (!isRecord(value)) return false;
|
|
14610
15200
|
const sbn = value["sbn"];
|
|
14611
|
-
return
|
|
15201
|
+
return isRepairStreamIdentity(value) && Number.isSafeInteger(sbn) && sbn >= 0;
|
|
15202
|
+
}
|
|
15203
|
+
function isDecoderUnavailableReason(value) {
|
|
15204
|
+
return value === "cleared" || value === "disposed";
|
|
15205
|
+
}
|
|
15206
|
+
function isFecFallbackDecoder(value) {
|
|
15207
|
+
return value === "sync" || value === "none";
|
|
14612
15208
|
}
|
|
14613
15209
|
function isRepairLifecycleEvent(value) {
|
|
14614
15210
|
if (!isRecord(value)) return false;
|
|
@@ -14616,7 +15212,11 @@ function isRepairLifecycleEvent(value) {
|
|
|
14616
15212
|
const type = value["type"];
|
|
14617
15213
|
const block = value["block"];
|
|
14618
15214
|
const symbols = value["symbols"];
|
|
14619
|
-
if (version !== 1
|
|
15215
|
+
if (version !== 1) return false;
|
|
15216
|
+
if (type === "decoder-unavailable") {
|
|
15217
|
+
return isRepairStreamIdentity(value["stream"]) && isDecoderUnavailableReason(value["reason"]) && isFecFallbackDecoder(value["fallbackDecoder"]) && block === void 0 && symbols === void 0;
|
|
15218
|
+
}
|
|
15219
|
+
if (type !== "requested" && type !== "recovered" && type !== "failed" || !isRepairBlockIdentity(block) || value["stream"] !== void 0 || value["reason"] !== void 0 || value["fallbackDecoder"] !== void 0) {
|
|
14620
15220
|
return false;
|
|
14621
15221
|
}
|
|
14622
15222
|
if (type === "requested") return symbols === void 0;
|
|
@@ -14635,22 +15235,25 @@ function forwardRepairLifecycleEvents(source, target, options = {}) {
|
|
|
14635
15235
|
target.dispatchEvent(forwardedEvent);
|
|
14636
15236
|
});
|
|
14637
15237
|
}
|
|
14638
|
-
function
|
|
15238
|
+
function repairStreamIdentity(packetId, catalogTrackName) {
|
|
14639
15239
|
if (!Number.isSafeInteger(packetId) || packetId < 0) {
|
|
14640
15240
|
throw new TypeError("packetId must be a non-negative safe integer");
|
|
14641
15241
|
}
|
|
14642
|
-
if (!Number.isSafeInteger(sbn) || sbn < 0) {
|
|
14643
|
-
throw new TypeError("sbn must be a non-negative safe integer");
|
|
14644
|
-
}
|
|
14645
15242
|
if (catalogTrackName !== void 0 && (typeof catalogTrackName !== "string" || catalogTrackName.length === 0)) {
|
|
14646
15243
|
throw new TypeError("catalogTrackName must be a non-empty string when provided");
|
|
14647
15244
|
}
|
|
14648
15245
|
return {
|
|
14649
15246
|
packetId,
|
|
14650
|
-
catalogTrackName: catalogTrackName ?? null
|
|
14651
|
-
sbn
|
|
15247
|
+
catalogTrackName: catalogTrackName ?? null
|
|
14652
15248
|
};
|
|
14653
15249
|
}
|
|
15250
|
+
function repairBlockIdentity(packetId, sbn, catalogTrackName) {
|
|
15251
|
+
const stream = repairStreamIdentity(packetId, catalogTrackName);
|
|
15252
|
+
if (!Number.isSafeInteger(sbn) || sbn < 0) {
|
|
15253
|
+
throw new TypeError("sbn must be a non-negative safe integer");
|
|
15254
|
+
}
|
|
15255
|
+
return { ...stream, sbn };
|
|
15256
|
+
}
|
|
14654
15257
|
function assertPositiveGeometry(label, value) {
|
|
14655
15258
|
if (value === void 0) return;
|
|
14656
15259
|
if (!Number.isFinite(value) || value <= 0) {
|
|
@@ -14820,6 +15423,15 @@ var MulticastManager = class {
|
|
|
14820
15423
|
}
|
|
14821
15424
|
});
|
|
14822
15425
|
};
|
|
15426
|
+
__privateGet(this, _fec).onDecoderUnavailable = (event) => {
|
|
15427
|
+
__privateMethod(this, _MulticastManager_instances, emitRepairLifecycle_fn).call(this, {
|
|
15428
|
+
version: 1,
|
|
15429
|
+
type: "decoder-unavailable",
|
|
15430
|
+
stream: repairStreamIdentity(event.packetId, event.catalogTrackName),
|
|
15431
|
+
reason: event.reason,
|
|
15432
|
+
fallbackDecoder: event.fallbackDecoder
|
|
15433
|
+
});
|
|
15434
|
+
};
|
|
14823
15435
|
}
|
|
14824
15436
|
// ---------------------------------------------------------------------------
|
|
14825
15437
|
// Decomposed component accessors (for new code)
|
|
@@ -14874,6 +15486,17 @@ var MulticastManager = class {
|
|
|
14874
15486
|
__privateMethod(this, _MulticastManager_instances, configureTrackMapper_fn).call(this, packetId, config);
|
|
14875
15487
|
__privateGet(this, _router).setPacketIdType(packetId, trackType);
|
|
14876
15488
|
}
|
|
15489
|
+
/**
|
|
15490
|
+
* Stop routing a stream's symbols to its Worker decoder. Returns false when
|
|
15491
|
+
* none is registered; on success one `decoder-unavailable` repair lifecycle
|
|
15492
|
+
* event with reason 'cleared' reaches every observer, carrying whether a
|
|
15493
|
+
* synchronous WASM decoder still serves the stream. The packet mapping and
|
|
15494
|
+
* track type are untouched: the track still exists, it just has no Worker
|
|
15495
|
+
* decoder. Call this before disposing the client.
|
|
15496
|
+
*/
|
|
15497
|
+
clearFecWorker(packetId, catalogTrackName) {
|
|
15498
|
+
return __privateGet(this, _fec).clearFecWorker(packetId, catalogTrackName);
|
|
15499
|
+
}
|
|
14877
15500
|
/** Register callback for Worker-level FecTrackStats updates. */
|
|
14878
15501
|
setOnFecStatsUpdate(cb) {
|
|
14879
15502
|
__privateGet(this, _fec).onFecStatsUpdate = cb;
|
|
@@ -14919,8 +15542,9 @@ var MulticastManager = class {
|
|
|
14919
15542
|
repairSymbols: config.fecRepairSymbols,
|
|
14920
15543
|
symbolSize: config.fecSymbolSize,
|
|
14921
15544
|
mediaUnitsPerSecond: config.fps,
|
|
14922
|
-
bandwidthBps: config.bandwidth
|
|
14923
|
-
|
|
15545
|
+
bandwidthBps: config.bandwidth,
|
|
15546
|
+
jitterBufferMs: config.fecReorderToleranceMs
|
|
15547
|
+
}) : void 0;
|
|
14924
15548
|
const fecConfig = {
|
|
14925
15549
|
k: config.fecK,
|
|
14926
15550
|
symbolSize: config.fecSymbolSize,
|
|
@@ -14957,8 +15581,9 @@ var MulticastManager = class {
|
|
|
14957
15581
|
repairSymbols: config.fecRepairSymbols,
|
|
14958
15582
|
symbolSize: config.fecSymbolSize,
|
|
14959
15583
|
mediaUnitsPerSecond: config.fps,
|
|
14960
|
-
bandwidthBps: config.bandwidth
|
|
14961
|
-
|
|
15584
|
+
bandwidthBps: config.bandwidth,
|
|
15585
|
+
jitterBufferMs: config.fecReorderToleranceMs
|
|
15586
|
+
}) : void 0;
|
|
14962
15587
|
__privateGet(this, _fec).configure({
|
|
14963
15588
|
k: config.fecK,
|
|
14964
15589
|
symbolSize: config.fecSymbolSize,
|
|
@@ -15475,11 +16100,13 @@ applyStreamGlobalFecTiming_fn = function() {
|
|
|
15475
16100
|
};
|
|
15476
16101
|
_onTrackTypeDiscovered = new WeakMap();
|
|
15477
16102
|
emitRepairLifecycle_fn = function(event) {
|
|
15478
|
-
const immutableEvent = Object.freeze(
|
|
15479
|
-
...event,
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
16103
|
+
const immutableEvent = Object.freeze(
|
|
16104
|
+
event.type === "decoder-unavailable" ? { ...event, stream: Object.freeze({ ...event.stream }) } : {
|
|
16105
|
+
...event,
|
|
16106
|
+
block: Object.freeze({ ...event.block }),
|
|
16107
|
+
...event.type === "requested" ? {} : { symbols: Object.freeze({ ...event.symbols }) }
|
|
16108
|
+
}
|
|
16109
|
+
);
|
|
15483
16110
|
console.info(
|
|
15484
16111
|
`${REPAIR_LIFECYCLE_LOG_PREFIX}${JSON.stringify(immutableEvent)}`
|
|
15485
16112
|
);
|
|
@@ -15503,7 +16130,8 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15503
16130
|
sourceSymbols: opts.fecK,
|
|
15504
16131
|
repairSymbols: opts.fecRepairCount,
|
|
15505
16132
|
symbolSize: opts.fecSymbolSize,
|
|
15506
|
-
mediaUnitsPerSecond: 1e3 / opts.mediaUnitDurationMs
|
|
16133
|
+
mediaUnitsPerSecond: 1e3 / opts.mediaUnitDurationMs,
|
|
16134
|
+
jitterBufferMs: opts.fecReorderToleranceMs
|
|
15507
16135
|
});
|
|
15508
16136
|
const origin = typeof location !== "undefined" && location.origin ? location.origin : "http://localhost";
|
|
15509
16137
|
const workerUrl = new URL(opts.assetUrls.fecWorker, origin);
|
|
@@ -15549,15 +16177,23 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15549
16177
|
relayBlockSigEnabled: false
|
|
15550
16178
|
};
|
|
15551
16179
|
client.configure(fecTrackConfig, rqWasm, altaKeyBuffer, altaWasmModule);
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
16180
|
+
try {
|
|
16181
|
+
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
16182
|
+
k: opts.fecK,
|
|
16183
|
+
symbolSize: opts.fecSymbolSize,
|
|
16184
|
+
interleaveDepthMs: opts.fecInterleaveMs,
|
|
16185
|
+
// FEC timing is expressed in media units. For audio this is the access-unit
|
|
16186
|
+
// cadence (for example 1024/48kHz), not a video-only framerate field.
|
|
16187
|
+
fps: 1e3 / opts.mediaUnitDurationMs,
|
|
16188
|
+
timeoutMs: deliveryWindowMs
|
|
16189
|
+
}, opts.trackName);
|
|
16190
|
+
} catch (e) {
|
|
16191
|
+
try {
|
|
16192
|
+
client.dispose();
|
|
16193
|
+
} catch {
|
|
16194
|
+
}
|
|
16195
|
+
throw e;
|
|
16196
|
+
}
|
|
15561
16197
|
let disposed = false;
|
|
15562
16198
|
return {
|
|
15563
16199
|
client,
|
|
@@ -15565,6 +16201,11 @@ async function setupFecWorkerForTrack(opts) {
|
|
|
15565
16201
|
dispose: () => {
|
|
15566
16202
|
if (disposed) return;
|
|
15567
16203
|
disposed = true;
|
|
16204
|
+
if (!opts.multicastManager.clearFecWorker(opts.packetId, opts.trackName)) {
|
|
16205
|
+
console.warn(
|
|
16206
|
+
`[fec-worker-setup] packetId=${opts.packetId} track=${opts.trackName} Worker was not registered when disposed`
|
|
16207
|
+
);
|
|
16208
|
+
}
|
|
15568
16209
|
try {
|
|
15569
16210
|
client.dispose();
|
|
15570
16211
|
} catch {
|
|
@@ -16448,7 +17089,7 @@ _readIndex = new WeakMap();
|
|
|
16448
17089
|
_stalled = new WeakMap();
|
|
16449
17090
|
|
|
16450
17091
|
// src/mmtp-decode-pipeline.ts
|
|
16451
|
-
var _parser2, _fecClient, _frameCb2, _initCb2, _needsKeyframe, _codec, _gateDropped, _gateEmitted, _fedObjects, _warnedNoParser, _feedOutcomes, _MmtpDecodePipeline_instances, gatedEmit_fn;
|
|
17092
|
+
var _parser2, _fecClient, _frameCb2, _initCb2, _needsKeyframe, _codec, _trackType, _gateDropped, _gateEmitted, _fedObjects, _warnedNoParser, _feedOutcomes, _MmtpDecodePipeline_instances, tag_fn, gatedEmit_fn;
|
|
16452
17093
|
var MmtpDecodePipeline = class {
|
|
16453
17094
|
constructor() {
|
|
16454
17095
|
__privateAdd(this, _MmtpDecodePipeline_instances);
|
|
@@ -16457,7 +17098,11 @@ var MmtpDecodePipeline = class {
|
|
|
16457
17098
|
__privateAdd(this, _frameCb2, null);
|
|
16458
17099
|
__privateAdd(this, _initCb2, null);
|
|
16459
17100
|
__privateAdd(this, _needsKeyframe, false);
|
|
16460
|
-
__privateAdd(this, _codec,
|
|
17101
|
+
__privateAdd(this, _codec, null);
|
|
17102
|
+
/** Set together with #codec at configure(). Also the diagnostic label: a
|
|
17103
|
+
* player builds one pipeline per track, and codec alone does not say which
|
|
17104
|
+
* role a line belongs to at a glance. */
|
|
17105
|
+
__privateAdd(this, _trackType, null);
|
|
16461
17106
|
/** Diagnostic counters. The keyframe gate drops silently, so a parser that
|
|
16462
17107
|
* never marks a frame as a keyframe stalls the whole pipeline with no
|
|
16463
17108
|
* output anywhere: frames are fed, frames are parsed, and nothing is
|
|
@@ -16486,6 +17131,7 @@ var MmtpDecodePipeline = class {
|
|
|
16486
17131
|
__privateSet(this, _warnedNoParser, false);
|
|
16487
17132
|
__privateSet(this, _codec, config.codec);
|
|
16488
17133
|
const trackType = isVideoCodec(config.codec) ? "video" : "audio";
|
|
17134
|
+
__privateSet(this, _trackType, trackType);
|
|
16489
17135
|
const trackInfo = {
|
|
16490
17136
|
type: trackType,
|
|
16491
17137
|
codec: config.codec,
|
|
@@ -16529,6 +17175,24 @@ var MmtpDecodePipeline = class {
|
|
|
16529
17175
|
get reorderStats() {
|
|
16530
17176
|
return __privateGet(this, _parser2)?.reorderStats ?? null;
|
|
16531
17177
|
}
|
|
17178
|
+
/**
|
|
17179
|
+
* Feed tallies for this track. A fresh snapshot per call, not a live view.
|
|
17180
|
+
*
|
|
17181
|
+
* Unlike reorderStats this never returns null: the counters belong to the
|
|
17182
|
+
* pipeline rather than the parser, so they survive dispose(). That is
|
|
17183
|
+
* deliberate — a wedged pipeline is usually read after teardown, which is
|
|
17184
|
+
* exactly when the parser is already gone.
|
|
17185
|
+
*/
|
|
17186
|
+
get feedStats() {
|
|
17187
|
+
return {
|
|
17188
|
+
trackType: __privateGet(this, _trackType),
|
|
17189
|
+
codec: __privateGet(this, _codec),
|
|
17190
|
+
fedObjects: __privateGet(this, _fedObjects),
|
|
17191
|
+
emitted: __privateGet(this, _gateEmitted),
|
|
17192
|
+
gateDropped: __privateGet(this, _gateDropped),
|
|
17193
|
+
outcomes: Object.fromEntries(__privateGet(this, _feedOutcomes))
|
|
17194
|
+
};
|
|
17195
|
+
}
|
|
16532
17196
|
/**
|
|
16533
17197
|
* Feed a raw MoQ object payload (one MMTP packet per MoQ object).
|
|
16534
17198
|
* Optionally feeds source symbols to FEC client before parsing.
|
|
@@ -16537,33 +17201,37 @@ var MmtpDecodePipeline = class {
|
|
|
16537
17201
|
if (!__privateGet(this, _parser2)) {
|
|
16538
17202
|
if (!__privateGet(this, _warnedNoParser)) {
|
|
16539
17203
|
__privateSet(this, _warnedNoParser, true);
|
|
16540
|
-
console.warn(
|
|
17204
|
+
console.warn(`[mmtp-pipeline] feedMoqObject called with NO PARSER configured ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} \u2014 packet dropped`);
|
|
16541
17205
|
}
|
|
16542
17206
|
return;
|
|
16543
17207
|
}
|
|
16544
17208
|
__privateSet(this, _fedObjects, __privateGet(this, _fedObjects) + 1);
|
|
16545
17209
|
if (__privateGet(this, _fedObjects) === 1) {
|
|
16546
|
-
console.log(`[mmtp-pipeline] first object fed
|
|
17210
|
+
console.log(`[mmtp-pipeline] first object fed ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${packet.length}`);
|
|
16547
17211
|
}
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
if (
|
|
16551
|
-
__privateGet(this,
|
|
17212
|
+
let outcomeKind = "threw";
|
|
17213
|
+
try {
|
|
17214
|
+
if (__privateGet(this, _fecClient)?.addSourceSymbol) {
|
|
17215
|
+
const info = __privateGet(this, _parser2).parseHeader(packet);
|
|
17216
|
+
if (info?.fecPayloadId) {
|
|
17217
|
+
__privateGet(this, _fecClient).addSourceSymbol(info.fecPayloadId.ssId, packet);
|
|
17218
|
+
}
|
|
17219
|
+
}
|
|
17220
|
+
const record = __privateGet(this, _parser2).feed(packet);
|
|
17221
|
+
outcomeKind = record?.kind ?? "null(parse-or-extract-failed)";
|
|
17222
|
+
} finally {
|
|
17223
|
+
const seen = (__privateGet(this, _feedOutcomes).get(outcomeKind) ?? 0) + 1;
|
|
17224
|
+
__privateGet(this, _feedOutcomes).set(outcomeKind, seen);
|
|
17225
|
+
if (seen === 1) {
|
|
17226
|
+
console.log(
|
|
17227
|
+
`[mmtp-pipeline] feed outcome FIRST '${outcomeKind}' ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} at object #${__privateGet(this, _fedObjects)} bytes=${packet.length}`
|
|
17228
|
+
);
|
|
16552
17229
|
}
|
|
16553
|
-
}
|
|
16554
|
-
const record = __privateGet(this, _parser2).feed(packet);
|
|
16555
|
-
const kind = record?.kind ?? "null(parse-or-extract-failed)";
|
|
16556
|
-
const seen = (__privateGet(this, _feedOutcomes).get(kind) ?? 0) + 1;
|
|
16557
|
-
__privateGet(this, _feedOutcomes).set(kind, seen);
|
|
16558
|
-
if (seen === 1) {
|
|
16559
|
-
console.log(
|
|
16560
|
-
`[mmtp-pipeline] feed outcome FIRST '${kind}' at object #${__privateGet(this, _fedObjects)} bytes=${packet.length}`
|
|
16561
|
-
);
|
|
16562
17230
|
}
|
|
16563
17231
|
if (__privateGet(this, _fedObjects) % 200 === 0) {
|
|
16564
17232
|
const hist = [...__privateGet(this, _feedOutcomes)].map(([k, v]) => `${k}=${v}`).join(" ");
|
|
16565
17233
|
console.log(
|
|
16566
|
-
`[mmtp-pipeline] feed histogram @${__privateGet(this, _fedObjects)}: ${hist} | emitted=${__privateGet(this, _gateEmitted)} gateDropped=${__privateGet(this, _gateDropped)}`
|
|
17234
|
+
`[mmtp-pipeline] feed histogram ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} @${__privateGet(this, _fedObjects)}: ${hist} | emitted=${__privateGet(this, _gateEmitted)} gateDropped=${__privateGet(this, _gateDropped)}`
|
|
16567
17235
|
);
|
|
16568
17236
|
}
|
|
16569
17237
|
}
|
|
@@ -16583,7 +17251,10 @@ var MmtpDecodePipeline = class {
|
|
|
16583
17251
|
...meta.mmtpTimestamp === void 0 ? {} : { mmtpTimestamp: meta.mmtpTimestamp },
|
|
16584
17252
|
keyframe: meta.keyframe,
|
|
16585
17253
|
packetId: meta.packetId,
|
|
16586
|
-
|
|
17254
|
+
// Same derivation as configure(), read from the field it set rather than
|
|
17255
|
+
// recomputed. Pre-configure the parser is null and routeFrame below is a
|
|
17256
|
+
// no-op, so the fallback is unreachable in practice.
|
|
17257
|
+
trackType: __privateGet(this, _trackType) ?? "audio",
|
|
16587
17258
|
packetSequenceNumber: meta.packetSequenceNumber
|
|
16588
17259
|
};
|
|
16589
17260
|
if (meta.sourceDiscontinuity) frameMeta.sourceDiscontinuity = true;
|
|
@@ -16609,7 +17280,7 @@ var MmtpDecodePipeline = class {
|
|
|
16609
17280
|
const droppedFrames = (__privateGet(this, _parser2)?.reorderStats.droppedOnLiveDispose ?? droppedBefore) - droppedBefore;
|
|
16610
17281
|
if (droppedFrames > 0) {
|
|
16611
17282
|
console.warn(
|
|
16612
|
-
`[MmtpDecodePipeline] live dispose dropped ${droppedFrames} buffered frame(s); finite inputs must use dispose({ flush: true })`
|
|
17283
|
+
`[MmtpDecodePipeline] live dispose ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} dropped ${droppedFrames} buffered frame(s); finite inputs must use dispose({ flush: true })`
|
|
16613
17284
|
);
|
|
16614
17285
|
}
|
|
16615
17286
|
__privateSet(this, _parser2, null);
|
|
@@ -16624,12 +17295,19 @@ _frameCb2 = new WeakMap();
|
|
|
16624
17295
|
_initCb2 = new WeakMap();
|
|
16625
17296
|
_needsKeyframe = new WeakMap();
|
|
16626
17297
|
_codec = new WeakMap();
|
|
17298
|
+
_trackType = new WeakMap();
|
|
16627
17299
|
_gateDropped = new WeakMap();
|
|
16628
17300
|
_gateEmitted = new WeakMap();
|
|
16629
17301
|
_fedObjects = new WeakMap();
|
|
16630
17302
|
_warnedNoParser = new WeakMap();
|
|
16631
17303
|
_feedOutcomes = new WeakMap();
|
|
16632
17304
|
_MmtpDecodePipeline_instances = new WeakSet();
|
|
17305
|
+
/** Identity prefix for diagnostics: one pipeline per track means two
|
|
17306
|
+
* instances write to the same console, and unlabelled lines interleave into
|
|
17307
|
+
* a single unreadable stream. */
|
|
17308
|
+
tag_fn = function() {
|
|
17309
|
+
return `track=${__privateGet(this, _trackType) ?? "unconfigured"} codec=${__privateGet(this, _codec) ?? "none"}`;
|
|
17310
|
+
};
|
|
16633
17311
|
gatedEmit_fn = function(data, meta) {
|
|
16634
17312
|
var _a;
|
|
16635
17313
|
let sourceDiscontinuity = false;
|
|
@@ -16638,7 +17316,7 @@ gatedEmit_fn = function(data, meta) {
|
|
|
16638
17316
|
__privateSet(this, _gateDropped, __privateGet(this, _gateDropped) + 1);
|
|
16639
17317
|
if (__privateGet(this, _gateDropped) <= 3 || __privateGet(this, _gateDropped) % 200 === 0) {
|
|
16640
17318
|
console.warn(
|
|
16641
|
-
`[mmtp-pipeline] keyframe gate DROP #${__privateGet(this, _gateDropped)}
|
|
17319
|
+
`[mmtp-pipeline] keyframe gate DROP #${__privateGet(this, _gateDropped)} ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${data.length} fed=${__privateGet(this, _fedObjects)} emitted=${__privateGet(this, _gateEmitted)}`
|
|
16642
17320
|
);
|
|
16643
17321
|
}
|
|
16644
17322
|
return;
|
|
@@ -16646,12 +17324,12 @@ gatedEmit_fn = function(data, meta) {
|
|
|
16646
17324
|
__privateSet(this, _needsKeyframe, false);
|
|
16647
17325
|
sourceDiscontinuity = true;
|
|
16648
17326
|
console.log(
|
|
16649
|
-
`[mmtp-pipeline] keyframe gate OPENED
|
|
17327
|
+
`[mmtp-pipeline] keyframe gate OPENED ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} after ${__privateGet(this, _gateDropped)} drops, fed=${__privateGet(this, _fedObjects)}`
|
|
16650
17328
|
);
|
|
16651
17329
|
}
|
|
16652
17330
|
__privateSet(this, _gateEmitted, __privateGet(this, _gateEmitted) + 1);
|
|
16653
17331
|
if (__privateGet(this, _gateEmitted) === 1) {
|
|
16654
|
-
console.log(`[mmtp-pipeline] first frame emitted
|
|
17332
|
+
console.log(`[mmtp-pipeline] first frame emitted ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${data.length}`);
|
|
16655
17333
|
}
|
|
16656
17334
|
const outMeta = sourceDiscontinuity ? { ...meta, sourceDiscontinuity: true } : meta;
|
|
16657
17335
|
(_a = __privateGet(this, _frameCb2)) == null ? void 0 : _a.call(this, data, outMeta);
|
|
@@ -17325,12 +18003,140 @@ emit_fn = function(params) {
|
|
|
17325
18003
|
};
|
|
17326
18004
|
|
|
17327
18005
|
// src/catalog-fec-params.ts
|
|
18006
|
+
var MAX_SAFE_TICKS_PER_HZ = Number.MAX_SAFE_INTEGER / 1e3;
|
|
18007
|
+
function timescaleHz(value) {
|
|
18008
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
18009
|
+
}
|
|
18010
|
+
function catalogGroupDurationMs(rendition) {
|
|
18011
|
+
if (!rendition) return void 0;
|
|
18012
|
+
const ticks = numericField(rendition.groupDurationTicks);
|
|
18013
|
+
const ms = numericField(rendition.groupDurationMs);
|
|
18014
|
+
const timescale = timescaleHz(rendition.container?.kind === "mmtp" ? rendition.container.timescale : void 0) ?? timescaleHz(rendition.timescale);
|
|
18015
|
+
if (ticks !== void 0 && timescale !== void 0 && Number.isSafeInteger(ticks) && ticks <= timescale * MAX_SAFE_TICKS_PER_HZ) {
|
|
18016
|
+
return resolveGroupDurationMs({ groupDurationTicks: ticks }, timescale);
|
|
18017
|
+
}
|
|
18018
|
+
return ms;
|
|
18019
|
+
}
|
|
18020
|
+
function resolveCatalogTrackGroupDurationMs(catalog, track) {
|
|
18021
|
+
const renditions = track.type === "audio" ? catalog?.audio?.renditions : catalog?.video?.renditions;
|
|
18022
|
+
return catalogGroupDurationMs(renditions?.[track.name]);
|
|
18023
|
+
}
|
|
17328
18024
|
var NO_FEC = {
|
|
17329
18025
|
fecK: 0,
|
|
17330
18026
|
fecRepairCount: 0,
|
|
18027
|
+
fecTotalRepairCount: 0,
|
|
17331
18028
|
fecSymbolSize: 0,
|
|
17332
18029
|
fecInterleaveMs: 0
|
|
17333
18030
|
};
|
|
18031
|
+
function recordOf(value) {
|
|
18032
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
18033
|
+
}
|
|
18034
|
+
function msfTracks(catalog) {
|
|
18035
|
+
const raw = catalog.tracks;
|
|
18036
|
+
if (!Array.isArray(raw)) return void 0;
|
|
18037
|
+
const common = recordOf(catalog.commonTrackFields) ?? {};
|
|
18038
|
+
return { tracks: raw.map((t) => recordOf(t) ?? {}), common };
|
|
18039
|
+
}
|
|
18040
|
+
function resolveRepairLayers(catalog, source) {
|
|
18041
|
+
if (!catalog) return void 0;
|
|
18042
|
+
const sourceName = typeof source === "string" ? source : source.name;
|
|
18043
|
+
const hang = catalog;
|
|
18044
|
+
const roles = typeof source === "string" ? ["video", "audio"] : source.type === "audio" ? ["audio"] : source.type === "video" ? ["video"] : ["video", "audio"];
|
|
18045
|
+
const role = roles.find((r) => recordOf(hang[r]?.renditions?.[sourceName]) !== void 0);
|
|
18046
|
+
if (role !== void 0) {
|
|
18047
|
+
const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
18048
|
+
const rendition = recordOf(hang[role].renditions[sourceName]);
|
|
18049
|
+
rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
|
|
18050
|
+
const repairRenditions = recordOf(hang.repair?.renditions) ?? {};
|
|
18051
|
+
const descriptors2 = Object.entries(repairRenditions).map(([name, entry]) => {
|
|
18052
|
+
const path = `$.repair.renditions[${JSON.stringify(name)}]`;
|
|
18053
|
+
const fields = recordOf(entry);
|
|
18054
|
+
if (fields === void 0) {
|
|
18055
|
+
throwRepairContractError("track_repair_layer", path, "a repair rendition must be an object");
|
|
18056
|
+
}
|
|
18057
|
+
rejectRepairTrackGeometry(path, fields, throwRepairContractError);
|
|
18058
|
+
return describeRepairTrack(name, path, fields);
|
|
18059
|
+
});
|
|
18060
|
+
const fecOfRendition = (entry) => {
|
|
18061
|
+
const fec2 = recordOf(recordOf(entry)?.["fec"]);
|
|
18062
|
+
return fec2 !== void 0 && fec2["algorithm"] !== "none" ? fec2 : void 0;
|
|
18063
|
+
};
|
|
18064
|
+
const mediaRenditions = [
|
|
18065
|
+
...Object.values(recordOf(hang.video?.renditions) ?? {}),
|
|
18066
|
+
...Object.values(recordOf(hang.audio?.renditions) ?? {})
|
|
18067
|
+
];
|
|
18068
|
+
const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf(entry)?.["fec"]));
|
|
18069
|
+
for (const d of descriptors2) {
|
|
18070
|
+
validateRepairTrackFields(d, throwRepairContractError);
|
|
18071
|
+
assertRepairTrackReachable(d, reachability2, throwRepairContractError);
|
|
18072
|
+
const target = dependsTarget(d);
|
|
18073
|
+
if (target === void 0) continue;
|
|
18074
|
+
const targetFec = fecOfRendition(hang.video?.renditions?.[target]) ?? fecOfRendition(hang.audio?.renditions?.[target]);
|
|
18075
|
+
if (targetFec === void 0) {
|
|
18076
|
+
throwRepairContractError(
|
|
18077
|
+
"track_repair_depends",
|
|
18078
|
+
`${d.path}.depends`,
|
|
18079
|
+
`${JSON.stringify(target)} is not a video or audio rendition with FEC`
|
|
18080
|
+
);
|
|
18081
|
+
}
|
|
18082
|
+
}
|
|
18083
|
+
return assembleRepairLayers(
|
|
18084
|
+
geometryOf(sourceName, `${renditionPath}.fec`, recordOf(rendition["fec"])),
|
|
18085
|
+
descriptors2,
|
|
18086
|
+
throwRepairContractError
|
|
18087
|
+
);
|
|
18088
|
+
}
|
|
18089
|
+
const msf = msfTracks(catalog);
|
|
18090
|
+
const msfIndex = msf ? msf.tracks.findIndex((t) => t["name"] === sourceName) : -1;
|
|
18091
|
+
if (!msf || msfIndex < 0) return void 0;
|
|
18092
|
+
const track = msf.tracks[msfIndex];
|
|
18093
|
+
const fec = recordOf(track["fec"]);
|
|
18094
|
+
const packagingOf = (t) => t["packaging"] ?? msf.common["packaging"];
|
|
18095
|
+
const fecOfTrack = (t) => {
|
|
18096
|
+
const trackFec = recordOf(t?.["fec"]);
|
|
18097
|
+
return trackFec !== void 0 && trackFec["algorithm"] !== "none" ? trackFec : void 0;
|
|
18098
|
+
};
|
|
18099
|
+
const descriptors = [];
|
|
18100
|
+
const mediaTracks = [];
|
|
18101
|
+
msf.tracks.forEach((t, i) => {
|
|
18102
|
+
const path = `$.tracks[${i}]`;
|
|
18103
|
+
if (packagingOf(t) === "fec-repair") {
|
|
18104
|
+
rejectRepairTrackGeometry(path, t, throwRepairContractError);
|
|
18105
|
+
if (typeof t["name"] === "string") descriptors.push(describeRepairTrack(t["name"], path, t));
|
|
18106
|
+
return;
|
|
18107
|
+
}
|
|
18108
|
+
rejectRepairFieldsOnMediaTrack(path, t, throwRepairContractError);
|
|
18109
|
+
mediaTracks.push(t);
|
|
18110
|
+
});
|
|
18111
|
+
const reachability = repairReachability(mediaTracks.map((t) => t["fec"]));
|
|
18112
|
+
for (const d of descriptors) {
|
|
18113
|
+
validateRepairTrackFields(d, throwRepairContractError);
|
|
18114
|
+
assertRepairTrackReachable(d, reachability, throwRepairContractError);
|
|
18115
|
+
const target = dependsTarget(d);
|
|
18116
|
+
if (target === void 0) continue;
|
|
18117
|
+
const targetTrack = msf.tracks.find((t) => t["name"] === target);
|
|
18118
|
+
if (targetTrack === void 0 || packagingOf(targetTrack) !== "mmtp" || fecOfTrack(targetTrack) === void 0) {
|
|
18119
|
+
throwRepairContractError(
|
|
18120
|
+
"track_repair_depends",
|
|
18121
|
+
`${d.path}.depends`,
|
|
18122
|
+
`${JSON.stringify(target)} is not an mmtp track with FEC`
|
|
18123
|
+
);
|
|
18124
|
+
}
|
|
18125
|
+
}
|
|
18126
|
+
return assembleRepairLayers(geometryOf(sourceName, `$.tracks[${msfIndex}].fec`, fec), descriptors, throwRepairContractError, {
|
|
18127
|
+
layerZeroMustBeDeclared: true
|
|
18128
|
+
});
|
|
18129
|
+
}
|
|
18130
|
+
function geometryOf(name, path, fec) {
|
|
18131
|
+
return {
|
|
18132
|
+
name,
|
|
18133
|
+
path,
|
|
18134
|
+
algorithm: fec?.["algorithm"],
|
|
18135
|
+
sourceSymbols: fec?.["sourceSymbols"],
|
|
18136
|
+
repairSymbols: fec?.["repairSymbols"],
|
|
18137
|
+
repairTrack: fec?.["repairTrack"]
|
|
18138
|
+
};
|
|
18139
|
+
}
|
|
17334
18140
|
function numericField(value) {
|
|
17335
18141
|
const n = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;
|
|
17336
18142
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
@@ -17339,13 +18145,16 @@ function nonNegativeField(value) {
|
|
|
17339
18145
|
const n = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;
|
|
17340
18146
|
return Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
17341
18147
|
}
|
|
17342
|
-
function fecParams(rendition, fps, sampleRate) {
|
|
18148
|
+
function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
17343
18149
|
const mediaRate = sampleRate === void 0 ? { fps } : { fps, sampleRate };
|
|
17344
18150
|
const fec = rendition?.fec;
|
|
17345
18151
|
if (!fec) return { ...NO_FEC, ...mediaRate };
|
|
18152
|
+
const repair = track ? resolveRepairLayers(catalog, track) : void 0;
|
|
17346
18153
|
return {
|
|
17347
18154
|
fecK: fec.sourceSymbols ?? 0,
|
|
17348
18155
|
fecRepairCount: fec.repairSymbols ?? 0,
|
|
18156
|
+
// The wire RSB_length: every base layer's packets carry the base total (§7.1).
|
|
18157
|
+
fecTotalRepairCount: repair?.totalBaseRepairSymbols ?? fec.repairSymbols ?? 0,
|
|
17349
18158
|
fecSymbolSize: fec.symbolSize ?? 0,
|
|
17350
18159
|
// interleaveDepthMs is the FEC block span in MILLISECONDS (§5.1) — the
|
|
17351
18160
|
// only interleave key the catalog carries post-BLO-14526. Receivers
|
|
@@ -17357,6 +18166,8 @@ function fecParams(rendition, fps, sampleRate) {
|
|
|
17357
18166
|
// so it cannot be reused here — a declared 0 is a legitimate value.
|
|
17358
18167
|
fecReorderToleranceMs: nonNegativeField(fec.reorderToleranceMs),
|
|
17359
18168
|
repairTrackName: fec.repairTrack,
|
|
18169
|
+
repairLayers: repair?.baseLayers,
|
|
18170
|
+
repairOverlays: repair?.overlays,
|
|
17360
18171
|
...mediaRate
|
|
17361
18172
|
};
|
|
17362
18173
|
}
|
|
@@ -17370,8 +18181,14 @@ function resolveCatalogTrackFec(catalog, tracks) {
|
|
|
17370
18181
|
const catalogFps = numericField(video?.framerate);
|
|
17371
18182
|
const sampleRate = numericField(audio?.sampleRate ?? audio?.samplerate);
|
|
17372
18183
|
const audioFps = sampleRate ? sampleRate / 1024 : void 0;
|
|
17373
|
-
const videoParams = fecParams(video, catalogFps);
|
|
17374
|
-
const audioParams = fecParams(
|
|
18184
|
+
const videoParams = fecParams(catalog, videoTrackName ? { name: videoTrackName, type: "video" } : void 0, video, catalogFps);
|
|
18185
|
+
const audioParams = fecParams(
|
|
18186
|
+
catalog,
|
|
18187
|
+
audioTrackName ? { name: audioTrackName, type: "audio" } : void 0,
|
|
18188
|
+
audio,
|
|
18189
|
+
audioFps,
|
|
18190
|
+
sampleRate
|
|
18191
|
+
);
|
|
17375
18192
|
return {
|
|
17376
18193
|
videoTrackName,
|
|
17377
18194
|
audioTrackName,
|
|
@@ -17534,6 +18351,7 @@ export {
|
|
|
17534
18351
|
CmafGroupBatcher,
|
|
17535
18352
|
CmcdProducer,
|
|
17536
18353
|
CmsfCatalogValidationError,
|
|
18354
|
+
DEFAULT_REPAIR_PRIORITY,
|
|
17537
18355
|
FECManager,
|
|
17538
18356
|
FEC_ESI_MAX,
|
|
17539
18357
|
FEC_SBN_MAX,
|
|
@@ -17541,6 +18359,10 @@ export {
|
|
|
17541
18359
|
FecStarvationDetector,
|
|
17542
18360
|
KEYFRAME_LOST_TIMEOUT_SLACK,
|
|
17543
18361
|
LOCHeaderExtensionId,
|
|
18362
|
+
MAX_ENCODING_SYMBOL_ID,
|
|
18363
|
+
MAX_RAPTORQ_SOURCE_SYMBOLS,
|
|
18364
|
+
MAX_REPAIR_SYMBOLS,
|
|
18365
|
+
MAX_TAKEOVER_DEADLINE_MS,
|
|
17544
18366
|
MFUReassembler,
|
|
17545
18367
|
MediaRouter,
|
|
17546
18368
|
MfuReassemblyError,
|
|
@@ -17555,7 +18377,12 @@ export {
|
|
|
17555
18377
|
NoneCodec,
|
|
17556
18378
|
REPAIR_LIFECYCLE_EVENT_TYPE,
|
|
17557
18379
|
REPAIR_LIFECYCLE_LOG_PREFIX,
|
|
18380
|
+
REPAIR_PRIORITY_MAX,
|
|
18381
|
+
REPAIR_PRIORITY_MIN,
|
|
18382
|
+
REPAIR_TRACK_GEOMETRY_KEYS,
|
|
18383
|
+
REPAIR_TRACK_ONLY_KEYS,
|
|
17558
18384
|
ReedSolomonCodec,
|
|
18385
|
+
RepairContractError,
|
|
17559
18386
|
SampleCombineError,
|
|
17560
18387
|
SampleCombiner,
|
|
17561
18388
|
SessionManager,
|
|
@@ -17566,11 +18393,14 @@ export {
|
|
|
17566
18393
|
WasmMfuReassembler,
|
|
17567
18394
|
annexBToAvcc,
|
|
17568
18395
|
asSeconds,
|
|
18396
|
+
assembleRepairLayers,
|
|
18397
|
+
assertRepairTrackReachable,
|
|
17569
18398
|
avccToAnnexB,
|
|
17570
18399
|
buildAudioInitSegment,
|
|
17571
18400
|
buildVideoInitSegment,
|
|
17572
18401
|
catalogAmtNetworkSource,
|
|
17573
18402
|
catalogFecInterleaveMs,
|
|
18403
|
+
catalogGroupDurationMs,
|
|
17574
18404
|
classifyH264Keyframe,
|
|
17575
18405
|
classifyPacket,
|
|
17576
18406
|
codecStringFromAvcC,
|
|
@@ -17585,6 +18415,8 @@ export {
|
|
|
17585
18415
|
decodeLocHeader,
|
|
17586
18416
|
decodeLocTimestamp,
|
|
17587
18417
|
decodeTimestamp,
|
|
18418
|
+
dependsTarget,
|
|
18419
|
+
describeRepairTrack,
|
|
17588
18420
|
detectH264Keyframe,
|
|
17589
18421
|
driftCheck,
|
|
17590
18422
|
encodeDataSegment,
|
|
@@ -17638,12 +18470,17 @@ export {
|
|
|
17638
18470
|
parseAacSampleRate,
|
|
17639
18471
|
parseOpusFrameSamples,
|
|
17640
18472
|
processMMTPWithReassembly,
|
|
18473
|
+
rejectRepairFieldsOnMediaTrack,
|
|
18474
|
+
rejectRepairTrackGeometry,
|
|
17641
18475
|
reliableMoqMfuReassembly,
|
|
17642
18476
|
removeEmulationPrevention,
|
|
18477
|
+
repairReachability,
|
|
17643
18478
|
resolveCatalogTrackFec,
|
|
18479
|
+
resolveCatalogTrackGroupDurationMs,
|
|
17644
18480
|
resolveGlobalMmtWasmBindings,
|
|
17645
18481
|
resolveGroupDurationMs,
|
|
17646
18482
|
resolveGroupDurationTicks,
|
|
18483
|
+
resolveRepairLayers,
|
|
17647
18484
|
secondsFromTicks,
|
|
17648
18485
|
setupFecWorkerForTrack,
|
|
17649
18486
|
setupTrackPipeline,
|
|
@@ -17653,6 +18490,7 @@ export {
|
|
|
17653
18490
|
unwrapMulticastPacket,
|
|
17654
18491
|
validateCmsfMmtpCatalog,
|
|
17655
18492
|
validateMulticastContainerContract,
|
|
18493
|
+
validateRepairTrackFields,
|
|
17656
18494
|
validateSwitchingSetTiming,
|
|
17657
18495
|
wireRepairFetch,
|
|
17658
18496
|
wrapAdtsFrame
|