@blockcast/mmt-container 0.4.0-main.d60c84364d2a → 0.4.0-main.ef132674b2a1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser-runtime.js +85 -53
- package/dist/browser-runtime.js.map +3 -3
- package/dist/mmtp-router.d.ts +9 -5
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +70 -37
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.d.ts +6 -2
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +85 -53
- package/dist/multicast-manager.js.map +3 -3
- package/package.json +5 -5
- package/src/mmtp-router.ts +101 -48
- package/src/multicast-manager.ts +15 -16
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ if (hdr.packetType === 0x00) { // MPU
|
|
|
135
135
|
|
|
136
136
|
### MFU reassembler (`./mfu`)
|
|
137
137
|
|
|
138
|
-
Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback. The router feeds a recovered packet under the
|
|
138
|
+
Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback. The router feeds a recovered packet under the u32 sequence from its reconstructed header unless a received source of the same FEC block shows a hop re-stamped it after protection; then under the wire sequence that source states (`restampedRecoveredSequenceCount` counts those).
|
|
139
139
|
|
|
140
140
|
```ts
|
|
141
141
|
interface MFUReassemblerOptions {
|
package/dist/browser-runtime.js
CHANGED
|
@@ -18847,6 +18847,7 @@ var NO_BLOCK_SPAN_HORIZON = Object.freeze({
|
|
|
18847
18847
|
});
|
|
18848
18848
|
var DIRECT_RECOVERED_VIDEO_QUEUE_LIMIT = 512;
|
|
18849
18849
|
var DIRECT_RECOVERED_AUDIO_QUEUE_LIMIT = 512;
|
|
18850
|
+
var WIRE_SEQ_RECORD_LIMIT = 512;
|
|
18850
18851
|
function sourceSymbolEvidence(packet, header, rapFlag, packetSequenceNumber) {
|
|
18851
18852
|
const identity = MmtpContainerParser.sourcePacketIdentity(packet, header);
|
|
18852
18853
|
return {
|
|
@@ -18904,12 +18905,6 @@ var MmtpRouter = class {
|
|
|
18904
18905
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
18905
18906
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
18906
18907
|
#latestVideoSeqByStream = /* @__PURE__ */ new Map();
|
|
18907
|
-
/**
|
|
18908
|
-
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
18909
|
-
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
18910
|
-
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
18911
|
-
*/
|
|
18912
|
-
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
18913
18908
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18914
18909
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18915
18910
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -19206,9 +19201,10 @@ var MmtpRouter = class {
|
|
|
19206
19201
|
return this.#publisherRestarts;
|
|
19207
19202
|
}
|
|
19208
19203
|
/**
|
|
19209
|
-
* FEC-recovered source symbols
|
|
19210
|
-
*
|
|
19211
|
-
* a hop re-stamped the sequence after the sender protected
|
|
19204
|
+
* FEC-recovered source symbols fed under the wire packet_sequence_number a
|
|
19205
|
+
* received source of their block states, because their reconstructed header
|
|
19206
|
+
* named another: a hop re-stamped the sequence after the sender protected
|
|
19207
|
+
* the packet. 0 on a stream no hop re-stamped.
|
|
19212
19208
|
*/
|
|
19213
19209
|
get restampedRecoveredSequenceCount() {
|
|
19214
19210
|
return this.#restampedRecoveredSeqs;
|
|
@@ -19818,11 +19814,14 @@ var MmtpRouter = class {
|
|
|
19818
19814
|
this.#withDeferredFecPokes(() => this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName));
|
|
19819
19815
|
}
|
|
19820
19816
|
/** Route a single recovered source symbol through the parser + dedup pipeline.
|
|
19821
|
-
* Worker-backed decoders emit one padded source symbol per frame event.
|
|
19822
|
-
|
|
19817
|
+
* Worker-backed decoders emit one padded source symbol per frame event.
|
|
19818
|
+
* `esi` (default 0) and the block's `ssbLength` place the symbol in block
|
|
19819
|
+
* `blockId`, whose received sources can decide the packet_sequence_number
|
|
19820
|
+
* it is fed under: pass both. */
|
|
19821
|
+
routeRecoveredSymbol(blockId, data, packetId, esi = 0, catalogTrackName, ssbLength) {
|
|
19823
19822
|
const blockProfile = this.#blockProfileFor(packetId);
|
|
19824
19823
|
const result = processFecSymbol(data, { ownerPacketId: packetId, index: esi, blockProfile });
|
|
19825
|
-
this.#routeVerifiedFecSymbols(blockId, result, packetId, catalogTrackName);
|
|
19824
|
+
this.#routeVerifiedFecSymbols(blockId, { ...result, ssbLength }, packetId, catalogTrackName);
|
|
19826
19825
|
}
|
|
19827
19826
|
// ── Keyframe timer cancellation ─────────────────────────────────
|
|
19828
19827
|
/** Cancel the active keyframe loss timer.
|
|
@@ -19845,8 +19844,8 @@ var MmtpRouter = class {
|
|
|
19845
19844
|
if (this.#disposed) return;
|
|
19846
19845
|
const staged = this.#staged;
|
|
19847
19846
|
if (staged !== null) {
|
|
19848
|
-
const
|
|
19849
|
-
if (isStream(
|
|
19847
|
+
const stream2 = { packetId, catalogTrackName };
|
|
19848
|
+
if (isStream(stream2, staged.to)) {
|
|
19850
19849
|
staged.droppedIncomingFrames += staged.held?.length ?? 0;
|
|
19851
19850
|
staged.held = null;
|
|
19852
19851
|
staged.heldInit = void 0;
|
|
@@ -19857,7 +19856,6 @@ var MmtpRouter = class {
|
|
|
19857
19856
|
this.#trackSynced.delete(streamKey);
|
|
19858
19857
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
19859
19858
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
19860
|
-
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
19861
19859
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
19862
19860
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
19863
19861
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -19866,7 +19864,10 @@ var MmtpRouter = class {
|
|
|
19866
19864
|
this.#pendingDirectRecoveredAudioByStream.delete(streamKey);
|
|
19867
19865
|
this.#manifestRecoveryQueues.delete(streamKey);
|
|
19868
19866
|
this.#deliveredVideoHighWaterByStream.delete(streamKey);
|
|
19869
|
-
this.#stream(packetId, catalogTrackName)
|
|
19867
|
+
const stream = this.#stream(packetId, catalogTrackName);
|
|
19868
|
+
stream.duplicates.clear();
|
|
19869
|
+
stream.wireSeqBySsId.clear();
|
|
19870
|
+
stream.untagged = false;
|
|
19870
19871
|
const assemblersToReset = /* @__PURE__ */ new Set();
|
|
19871
19872
|
const exactAssembler = this.#mseAssemblers.get(streamKey);
|
|
19872
19873
|
if (exactAssembler) assemblersToReset.add(exactAssembler);
|
|
@@ -20629,10 +20630,11 @@ var MmtpRouter = class {
|
|
|
20629
20630
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
20630
20631
|
}
|
|
20631
20632
|
if (fecPayloadId && !overlapCopy) {
|
|
20632
|
-
this.#
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20633
|
+
const wireSeqs = this.#stream(info.packetId, catalogTrackName).wireSeqBySsId;
|
|
20634
|
+
wireSeqs.set(fecPayloadId.ssId, info.sequenceNumber);
|
|
20635
|
+
if (wireSeqs.size > WIRE_SEQ_RECORD_LIMIT) wireSeqs.delete(wireSeqs.keys().next().value);
|
|
20636
|
+
} else if (!info.fecPayloadId && !overlapCopy) {
|
|
20637
|
+
this.#stream(info.packetId, catalogTrackName).untagged = true;
|
|
20636
20638
|
}
|
|
20637
20639
|
if (!this.#fecManager || !info.fecPayloadId || parseSourceSymbol) {
|
|
20638
20640
|
if (this.#fecManager && info.fecPayloadId) {
|
|
@@ -20866,7 +20868,9 @@ var MmtpRouter = class {
|
|
|
20866
20868
|
if (stream === void 0) {
|
|
20867
20869
|
stream = {
|
|
20868
20870
|
key: JSON.stringify([packetId, catalogTrackName ?? null]),
|
|
20869
|
-
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId))
|
|
20871
|
+
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId)),
|
|
20872
|
+
wireSeqBySsId: /* @__PURE__ */ new Map(),
|
|
20873
|
+
untagged: false
|
|
20870
20874
|
};
|
|
20871
20875
|
byName.set(catalogTrackName, stream);
|
|
20872
20876
|
}
|
|
@@ -21109,7 +21113,12 @@ var MmtpRouter = class {
|
|
|
21109
21113
|
ownerPacketId,
|
|
21110
21114
|
blockProfile
|
|
21111
21115
|
});
|
|
21112
|
-
this.#routeVerifiedFecSymbols(
|
|
21116
|
+
this.#routeVerifiedFecSymbols(
|
|
21117
|
+
blockId,
|
|
21118
|
+
{ ...result, ssbLength: recovered.length / symbolSize },
|
|
21119
|
+
ownerPacketId,
|
|
21120
|
+
catalogTrackName
|
|
21121
|
+
);
|
|
21113
21122
|
}
|
|
21114
21123
|
#routeVerifiedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
21115
21124
|
if (!this.#manifestVerifier || ownerPacketId == null) {
|
|
@@ -21207,24 +21216,48 @@ var MmtpRouter = class {
|
|
|
21207
21216
|
};
|
|
21208
21217
|
admitNext(0);
|
|
21209
21218
|
}
|
|
21219
|
+
/**
|
|
21220
|
+
* A recovered symbol under the packet_sequence_number it had on the wire.
|
|
21221
|
+
* Its reconstructed header names the sequence the sender protected. A hop
|
|
21222
|
+
* that re-stamps packet_sequence_number after protection (cast's
|
|
21223
|
+
* publisher-rotation bridge) leaves the decode mixing every received
|
|
21224
|
+
* source's re-stamped bytes into it, and the reassembler and the source
|
|
21225
|
+
* dedup address the fragment by that number. While every packet of the
|
|
21226
|
+
* stream is an FEC source, a received source of the symbol's own block (at
|
|
21227
|
+
* or below it first; above it only within the block's `ssbLength`) states
|
|
21228
|
+
* the wire sequence exactly: its own plus the SS_ID distance. A block's
|
|
21229
|
+
* sources come from one publisher, so a rotation between blocks does not
|
|
21230
|
+
* disturb it. On a stream that carried an untagged packet (FEC_type 0, MPU
|
|
21231
|
+
* metadata for one) the unprotected packets between two sources shift that
|
|
21232
|
+
* statement by their count, so the decoded sequence stands there.
|
|
21233
|
+
*/
|
|
21234
|
+
#withWireSequence(sym, blockId, ssbLength, stream) {
|
|
21235
|
+
if (stream.untagged) return sym;
|
|
21236
|
+
let wire;
|
|
21237
|
+
for (let esi = sym.index; wire === void 0 && esi >= 0; esi--) {
|
|
21238
|
+
const seq = stream.wireSeqBySsId.get(this.#fecAnchorForRecovered(blockId, esi));
|
|
21239
|
+
if (seq !== void 0) wire = seq + sym.index - esi >>> 0;
|
|
21240
|
+
}
|
|
21241
|
+
for (let esi = sym.index + 1; wire === void 0 && esi < (ssbLength ?? 0); esi++) {
|
|
21242
|
+
const seq = stream.wireSeqBySsId.get(this.#fecAnchorForRecovered(blockId, esi));
|
|
21243
|
+
if (seq !== void 0) wire = seq + sym.index - esi >>> 0;
|
|
21244
|
+
}
|
|
21245
|
+
if (wire === void 0 || wire === sym.packetSequenceNumber) return sym;
|
|
21246
|
+
this.#restampedRecoveredSeqs++;
|
|
21247
|
+
const rawSymbol = sym.rawSymbol.slice();
|
|
21248
|
+
new DataView(rawSymbol.buffer).setUint32(8, wire);
|
|
21249
|
+
return { ...sym, packetSequenceNumber: wire, rawSymbol };
|
|
21250
|
+
}
|
|
21210
21251
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
21211
21252
|
if (ownerPacketId == null) return;
|
|
21212
21253
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
21213
|
-
const
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
result
|
|
21218
|
-
|
|
21219
|
-
|
|
21220
|
-
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
21221
|
-
if (wire === sym.packetSequenceNumber) return sym;
|
|
21222
|
-
this.#restampedRecoveredSeqs++;
|
|
21223
|
-
return { ...sym, packetSequenceNumber: wire };
|
|
21224
|
-
})
|
|
21225
|
-
};
|
|
21226
|
-
}
|
|
21227
|
-
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
21254
|
+
const stream = this.#stream(ownerPacketId, catalogTrackName);
|
|
21255
|
+
const { ssbLength } = result;
|
|
21256
|
+
result = {
|
|
21257
|
+
...result,
|
|
21258
|
+
symbols: result.symbols.map((sym) => this.#withWireSequence(sym, blockId, ssbLength, stream))
|
|
21259
|
+
};
|
|
21260
|
+
stream.duplicates.advance(blockId);
|
|
21228
21261
|
const deliveryProvenance = this.#fecManager?.blockDeliveryProvenance?.(
|
|
21229
21262
|
blockId,
|
|
21230
21263
|
ownerPacketId,
|
|
@@ -23505,19 +23538,14 @@ var MulticastManager = class {
|
|
|
23505
23538
|
this.#fec.setMulticastSymbolDelivery(delivery);
|
|
23506
23539
|
});
|
|
23507
23540
|
this.#fec.onBlockRecovered = (sbn, packetId, data, meta, recoveredTrackName) => {
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
this.#
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
packetId,
|
|
23517
|
-
meta.esi,
|
|
23518
|
-
catalogTrackName
|
|
23519
|
-
);
|
|
23520
|
-
}
|
|
23541
|
+
this.#router.routeRecoveredSymbol(
|
|
23542
|
+
sbn,
|
|
23543
|
+
new Uint8Array(data),
|
|
23544
|
+
packetId,
|
|
23545
|
+
meta.esi,
|
|
23546
|
+
recoveredTrackName ?? this.#fec.catalogTrackNameForBlock(sbn, packetId),
|
|
23547
|
+
meta.ssbLength
|
|
23548
|
+
);
|
|
23521
23549
|
};
|
|
23522
23550
|
this.#fec.onRepairResolved = (sbn, packetId, _outcome, catalogTrackName) => {
|
|
23523
23551
|
this.clearRepairForBlock(sbn, packetId, catalogTrackName);
|
|
@@ -24384,9 +24412,13 @@ var MulticastManager = class {
|
|
|
24384
24412
|
routeRecoveredBlock(blockId, data, packetId, catalogTrackName) {
|
|
24385
24413
|
this.#router.routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
24386
24414
|
}
|
|
24387
|
-
/**
|
|
24388
|
-
|
|
24389
|
-
|
|
24415
|
+
/**
|
|
24416
|
+
* Route one Worker-recovered source symbol through the MMTP parser + dedup
|
|
24417
|
+
* pipeline. Pass its ESI and its block's SSB_length: see
|
|
24418
|
+
* MmtpRouter.routeRecoveredSymbol.
|
|
24419
|
+
*/
|
|
24420
|
+
routeRecoveredSymbol(blockId, data, packetId, esi = 0, catalogTrackName, ssbLength) {
|
|
24421
|
+
this.#router.routeRecoveredSymbol(blockId, data, packetId, esi, catalogTrackName, ssbLength);
|
|
24390
24422
|
}
|
|
24391
24423
|
// ---------------------------------------------------------------------------
|
|
24392
24424
|
// Phase 14: multi-track catalog ingest (D-04, D-06, D-07, D-17, D-26, D-28)
|