@blockcast/mmt-fec 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/block-processor.d.ts +19 -20
- package/dist/block-processor.d.ts.map +1 -1
- package/dist/block-processor.js +27 -93
- package/dist/block-processor.js.map +1 -1
- package/dist/fec-block-mapper.d.ts +16 -72
- package/dist/fec-block-mapper.d.ts.map +1 -1
- package/dist/fec-block-mapper.js +17 -96
- package/dist/fec-block-mapper.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/oti.d.ts +17 -8
- package/dist/oti.d.ts.map +1 -1
- package/dist/oti.js +9 -1
- package/dist/oti.js.map +1 -1
- package/dist/repair-group.d.ts +86 -0
- package/dist/repair-group.d.ts.map +1 -1
- package/dist/repair-group.js +135 -0
- package/dist/repair-group.js.map +1 -1
- package/package.json +5 -6
- package/src/block-processor.ts +31 -110
- package/src/fec-block-mapper.ts +23 -108
- package/src/index.ts +6 -1
- package/src/oti.ts +20 -9
- package/src/repair-group.ts +176 -0
- package/test-vectors/repair-epoch.json +119 -0
- package/node_modules/@blockcast/mmt-alta-parse/README.md +0 -181
- package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +0 -57
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +0 -115
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +0 -1
- package/node_modules/@blockcast/mmt-alta-parse/package.json +0 -50
- package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +0 -136
- package/node_modules/@blockcast/mmt-base/README.md +0 -134
- package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts +0 -55
- package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js +0 -128
- package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts +0 -7
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/index.js +0 -7
- package/node_modules/@blockcast/mmt-base/dist/index.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +0 -292
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +0 -612
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts +0 -18
- package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/net-constants.js +0 -18
- package/node_modules/@blockcast/mmt-base/dist/net-constants.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts +0 -47
- package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/ntp-short.js +0 -54
- package/node_modules/@blockcast/mmt-base/dist/ntp-short.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts +0 -57
- package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/serial-number.js +0 -98
- package/node_modules/@blockcast/mmt-base/dist/serial-number.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts +0 -312
- package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts.map +0 -1
- package/node_modules/@blockcast/mmt-base/dist/signalling.js +0 -637
- package/node_modules/@blockcast/mmt-base/dist/signalling.js.map +0 -1
- package/node_modules/@blockcast/mmt-base/package.json +0 -49
- package/node_modules/@blockcast/mmt-base/src/fec-block-profile.ts +0 -145
- package/node_modules/@blockcast/mmt-base/src/index.ts +0 -6
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +0 -892
- package/node_modules/@blockcast/mmt-base/src/net-constants.ts +0 -17
- package/node_modules/@blockcast/mmt-base/src/ntp-short.ts +0 -67
- package/node_modules/@blockcast/mmt-base/src/serial-number.ts +0 -107
- package/node_modules/@blockcast/mmt-base/src/signalling.ts +0 -862
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ const blocks = new FecBlockManager({ k: K, timeoutMs })
|
|
|
29
29
|
if (recoveredBlock) {
|
|
30
30
|
// K source symbols concatenated. Split them back into MFU fragments under
|
|
31
31
|
// the catalog fec.blockProfile (required; there is no default profile or T).
|
|
32
|
-
const { symbols } = processFecBlock(recoveredBlock, { blockProfile: "
|
|
32
|
+
const { symbols } = processFecBlock(recoveredBlock, { blockProfile: "iso-ssbg1-v1", k: K, symbolSize: T })
|
|
33
33
|
for (const s of symbols) reassembler.addFragment(s.fragment)
|
|
34
34
|
}
|
|
35
35
|
```
|
|
@@ -48,7 +48,7 @@ Mirrors `package.json#exports`. Each subpath is a tree-shakeable entry point.
|
|
|
48
48
|
| `./cmaf-recovery` | `src/cmaf-recovery.ts` | `CmafFecRecovery` — stateful recovery for CMAF chunks + LOC frames |
|
|
49
49
|
| `./loc` | `src/loc-symbols.ts` | `splitFrameToSymbol`, `recoverFrameFromSymbol` — LOC 1:1 frame ↔ symbol |
|
|
50
50
|
|
|
51
|
-
The aggregator entry also re-exports OTI helpers (`buildOTI`, `buildOTIFromCatalog`, `parseOTI`, `computeFecTimeout`, `parseRepairPacket`) the block-geometry mappers (`FecBlockMapper`, `NullBlockMapper`, `
|
|
51
|
+
The aggregator entry also re-exports OTI helpers (`buildOTI`, `buildOTIFromCatalog`, `parseOTI`, `computeFecTimeout`, `parseRepairPacket`) the block-geometry mappers (`FecBlockMapper`, `NullBlockMapper`, `createMapper`, `recoveredPacketMediaGroup`), and the `iso-ssbg1-v1` MoQ repair group helpers (`extSsStart`, `extendSsId`, `repairFetchRange`, `repairGroupIdMatches`). Canonical MMTP Source FEC Payload ID parsing lives in `@blockcast/mmt-base`; canonical LOC FEC source information lives in `@blockcast/mmt-container`.
|
|
52
52
|
|
|
53
53
|
## Architecture
|
|
54
54
|
|
|
@@ -104,7 +104,7 @@ container or worker.
|
|
|
104
104
|
|
|
105
105
|
The WASM decoder hands back `K * symbolSize` bytes (K source symbols concatenated). `processFecBlock` (`src/block-processor.ts:68`) walks each symbol, parses its MMTP header, extracts the MFU payload via `@blockcast/mmt-base`'s `extractMFUPayload`, and emits a `ParsedFecSymbol[]` sorted with wrapping 32-bit MMTP serial-number arithmetic (source-symbol index breaks duplicate ties) — undoing FEC interleaving so the reassembler sees `FI=1` before `FI=2/3` for the same MPU, including across `0xffff_ffff → 0`.
|
|
106
106
|
|
|
107
|
-
Both `processFecBlock` and `processFecSymbol` require the stream's catalog `fec.blockProfile`, and `processFecBlock` requires the symbol size T; neither is defaulted
|
|
107
|
+
Both `processFecBlock` and `processFecSymbol` require the stream's catalog `fec.blockProfile`, and `processFecBlock` requires the symbol size T; neither is defaulted, and the only profile is `iso-ssbg1-v1` (the retired `k-padded-v1` token throws like any unknown one). A recovered symbol is the ISO/IEC 23008-1 C.3.3 ssbg_mode1 `u16 length || packet || 00h padding`: the length field alone delimits the packet, and a length past the symbol or non-zero padding is counted as `bad_ssbg1_length`. The processor never infers packet boundaries from MFU contents, padding scans or alternate length conventions.
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
110
|
interface ParsedFecSymbol {
|
|
@@ -176,7 +176,7 @@ parseRepairPacket(mmtpPacket) // ISO 23008-1 §C.5.3 repair FEC PID
|
|
|
176
176
|
|
|
177
177
|
`computeFecTimeout` derives the block-recovery deadline from the catalog interleave value — see `src/oti.ts:121`. The catalog's `interleaveDepthMs` IS the full FEC block span (§5.1), so the timeout is `interleaveDepthMs * safetyFactor`, independent of K; the safety factor is the only tunable. **Do not** hardcode `setTimeout` values upstream.
|
|
178
178
|
|
|
179
|
-
`./` (root) exposes the catalog block geometry via `FecBlockMapper` (`k`, `d`, `interleaveDepthMs`, `gopDurationMs`, `pacingThresholdMs`, and the required `blockProfile`). It does not map MoQ groups to FEC blocks: a recovered packet's media group comes from its own header (`mediaGroupOf` / `recoveredPacketMediaGroup`), and `fromSsId`
|
|
179
|
+
`./` (root) exposes the catalog block geometry via `FecBlockMapper` (`k`, `d`, `interleaveDepthMs`, `gopDurationMs`, `pacingThresholdMs`, and the required `blockProfile`). It does not map MoQ groups to FEC blocks: a recovered packet's media group comes from its own header (`mediaGroupOf` / `recoveredPacketMediaGroup`), and `fromSsId` throws for every stream with an FEC instance, whose `iso-ssbg1-v1` blocks are located by `(SS_Start, SSB_length)` range membership. `NullBlockMapper` (no FEC, no profile) keeps its identity `derive` and `fromSsId`; `createMapper({ mode: 'object' })` throws, since per-group object FEC numbers SS_IDs on the retired `k-padded-v1` stride. Under `iso-ssbg1-v1` the MoQ repair group id is the 62-bit wrap-epoch-extended SS_Start (`extSsStart`); a receiver that lost SS_ID x in a block it has not delimited FETCHes `repairFetchRange(x, K, { previousBlockStart })`, or `repairFetchRange(x, K, { reference })` from its wrap-epoch reference when no delimited block ends before x (draft-ramadan-moq-fec §7.5), and discards a repair object whose Group ID fails `repairGroupIdMatches`.
|
|
180
180
|
|
|
181
181
|
## WASM module loading
|
|
182
182
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FEC Block Processor
|
|
3
3
|
*
|
|
4
|
-
* Splits decoded FEC blocks (
|
|
4
|
+
* Splits decoded FEC blocks (SSB_length symbols concatenated by the WASM decoder)
|
|
5
5
|
* into individual MFU fragments ready for reassembly and decoding.
|
|
6
6
|
*
|
|
7
7
|
* Extracted from moqtail.html's inline processFecBlock() for reuse across
|
|
@@ -49,9 +49,9 @@ export interface ProcessFecBlockResult {
|
|
|
49
49
|
/** Options for {@link processFecSymbol}. */
|
|
50
50
|
export interface ProcessFecSymbolOptions {
|
|
51
51
|
/**
|
|
52
|
-
* The stream's catalog `fec.blockProfile`. Required, never defaulted:
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* The stream's catalog `fec.blockProfile`. Required, never defaulted:
|
|
53
|
+
* the profile fixes how a packet is laid into a symbol, and the only one
|
|
54
|
+
* implemented is `iso-ssbg1-v1`.
|
|
55
55
|
*/
|
|
56
56
|
blockProfile: FecBlockProfile;
|
|
57
57
|
/** Symbol index within the block, used only for diagnostics. */
|
|
@@ -66,9 +66,9 @@ export interface ProcessFecBlockOptions {
|
|
|
66
66
|
/** Symbol size T in bytes (catalog `fec.symbolSize`). Required: there is no default T. */
|
|
67
67
|
symbolSize: number;
|
|
68
68
|
/**
|
|
69
|
-
* Source symbols in the decoded block: K
|
|
70
|
-
*
|
|
71
|
-
*
|
|
69
|
+
* Source symbols in the decoded block: its SSB_length (K'). When omitted
|
|
70
|
+
* the block must be a whole number of T-byte symbols and K' is that
|
|
71
|
+
* number; a partial symbol throws.
|
|
72
72
|
*/
|
|
73
73
|
k?: number;
|
|
74
74
|
/** Keep only symbols for this packetId. */
|
|
@@ -77,30 +77,29 @@ export interface ProcessFecBlockOptions {
|
|
|
77
77
|
/**
|
|
78
78
|
* Parse one recovered FEC source symbol into an MFU fragment.
|
|
79
79
|
*
|
|
80
|
-
* The symbol is
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
80
|
+
* The symbol is the `iso-ssbg1-v1` ssbg_mode1 `u16 length || packet || zero
|
|
81
|
+
* padding` (ISO/IEC 23008-1 C.3.3): the length field alone delimits the
|
|
82
|
+
* protected packet, which is then parsed as an MMTP MPU packet. Failures are
|
|
83
|
+
* counted by reason (`bad_ssbg1_length` is the length/padding refusal), never
|
|
84
|
+
* thrown.
|
|
85
85
|
*
|
|
86
|
-
* @throws when `options.blockProfile` is absent or not
|
|
86
|
+
* @throws when `options.blockProfile` is absent or not `iso-ssbg1-v1`.
|
|
87
87
|
*/
|
|
88
88
|
export declare function processFecSymbol(symbolData: Uint8Array, options: ProcessFecSymbolOptions): ProcessFecBlockResult;
|
|
89
89
|
/**
|
|
90
90
|
* Process a decoded FEC block into individual MFU fragments.
|
|
91
91
|
*
|
|
92
92
|
* The WASM RaptorQ decoder returns every source symbol of the block
|
|
93
|
-
* concatenated (
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* structured results sorted for reassembly.
|
|
93
|
+
* concatenated (SSB_length x T bytes). This function splits them apart,
|
|
94
|
+
* recovers each protected packet from its ssbg_mode1 length field (see
|
|
95
|
+
* {@link processFecSymbol}), extracts the MFU payload via shared
|
|
96
|
+
* extractMFUPayload, and returns structured results sorted for reassembly.
|
|
98
97
|
*
|
|
99
98
|
* @param blockData - Concatenated source symbols from the WASM decoder
|
|
100
99
|
* @param options - Block profile and symbol size T are required; see {@link ProcessFecBlockOptions}
|
|
101
100
|
* @throws when the block profile or symbol size is absent or invalid, when an
|
|
102
|
-
* omitted `k` cannot be read exactly from the block length, or when
|
|
103
|
-
*
|
|
101
|
+
* omitted `k` cannot be read exactly from the block length, or when the
|
|
102
|
+
* block is not exactly `k` symbols long.
|
|
104
103
|
*/
|
|
105
104
|
export declare function processFecBlock(blockData: Uint8Array, options: ProcessFecBlockOptions): ProcessFecBlockResult;
|
|
106
105
|
//# sourceMappingURL=block-processor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-processor.d.ts","sourceRoot":"","sources":["../src/block-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"block-processor.d.ts","sourceRoot":"","sources":["../src/block-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAON,KAAK,eAAe,EAEpB,MAAM,qBAAqB,CAAC;AAE7B,sDAAsD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F;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AA0ID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,uBAAuB,GAC9B,qBAAqB,CAyBvB;AA2CD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC9B,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAgCvB"}
|
package/dist/block-processor.js
CHANGED
|
@@ -1,59 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FEC Block Processor
|
|
3
3
|
*
|
|
4
|
-
* Splits decoded FEC blocks (
|
|
4
|
+
* Splits decoded FEC blocks (SSB_length symbols concatenated by the WASM decoder)
|
|
5
5
|
* into individual MFU fragments ready for reassembly and decoding.
|
|
6
6
|
*
|
|
7
7
|
* Extracted from moqtail.html's inline processFecBlock() for reuse across
|
|
8
8
|
* both moq-lib and moqtail players. Pure function — no side effects.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
function hasUniformPaddingFrom(data, start) {
|
|
12
|
-
if (start >= data.length)
|
|
13
|
-
return false;
|
|
14
|
-
const pad = data[start];
|
|
15
|
-
if (pad !== 0x00 && pad !== 0xee)
|
|
16
|
-
return false;
|
|
17
|
-
for (let i = start + 1; i < data.length; i++) {
|
|
18
|
-
if (data[i] !== pad)
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
function maybeExtendAltaTrailer(symbolData, packetEnd) {
|
|
24
|
-
if (packetEnd + MMTP_EXT_TRAILER_HEADER_SIZE > symbolData.length)
|
|
25
|
-
return packetEnd;
|
|
26
|
-
const view = new DataView(symbolData.buffer, symbolData.byteOffset + packetEnd, symbolData.byteLength - packetEnd);
|
|
27
|
-
const extType = view.getUint16(0, false);
|
|
28
|
-
if (extType !== MMTP_EXT_TYPE_ALTA_AUTH)
|
|
29
|
-
return packetEnd;
|
|
30
|
-
const extLen = view.getUint16(2, false);
|
|
31
|
-
const trailerEnd = packetEnd + MMTP_EXT_TRAILER_HEADER_SIZE + extLen;
|
|
32
|
-
return trailerEnd <= symbolData.length ? trailerEnd : packetEnd;
|
|
33
|
-
}
|
|
34
|
-
function trimDecodedSourceSymbol(symbolData) {
|
|
35
|
-
if (symbolData.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
36
|
-
return null;
|
|
37
|
-
const headerLength = parseMMTPHeader(symbolData).headerLength;
|
|
38
|
-
if (symbolData.length < headerLength + MPU_HEADER_SIZE)
|
|
39
|
-
return null;
|
|
40
|
-
const payload = symbolData.subarray(headerLength);
|
|
41
|
-
const mpu = parseMPUHeader(payload);
|
|
42
|
-
const trailingMpuHeaderSize = MPU_HEADER_SIZE - 2;
|
|
43
|
-
if (mpu.payloadLength < trailingMpuHeaderSize)
|
|
44
|
-
return null;
|
|
45
|
-
// Recovered source symbols are fixed-width and may be padded, but their wire
|
|
46
|
-
// boundary is still the ISO length-after-field coordinate. ALTA may extend the
|
|
47
|
-
// packet from exactly that point; no MFU-content or alternate-length guessing.
|
|
48
|
-
const declaredEnd = headerLength + 2 + mpu.payloadLength;
|
|
49
|
-
if (declaredEnd > symbolData.length)
|
|
50
|
-
return null;
|
|
51
|
-
const packetEnd = maybeExtendAltaTrailer(symbolData, declaredEnd);
|
|
52
|
-
if (packetEnd < symbolData.length && !hasUniformPaddingFrom(symbolData, packetEnd)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return symbolData.subarray(0, packetEnd);
|
|
56
|
-
}
|
|
10
|
+
import { MMTP_HEADER_SIZE, SSBG1_LENGTH_FIELD_BYTES, extractMFUPayload, parseFecBlockProfile, parseMMTPHeader, trimSsbg1SourceSymbol, } from "@blockcast/mmt-base";
|
|
57
11
|
function emptyProcessResult() {
|
|
58
12
|
return {
|
|
59
13
|
symbols: [],
|
|
@@ -77,8 +31,8 @@ function resultFromSymbols(parsed, failedCount, failReasons, ownerPacketId) {
|
|
|
77
31
|
// Reassembler needs FI=1 before FI=2/3 for the same mpuSequenceNumber.
|
|
78
32
|
parsed.sort(comparePacketSequence);
|
|
79
33
|
// When ownerPacketId is set, only keep symbols matching the track that owns
|
|
80
|
-
// this FEC block. Other packetIds
|
|
81
|
-
//
|
|
34
|
+
// this FEC block. Other packetIds are garbage and must be rejected to
|
|
35
|
+
// prevent decoder crashes.
|
|
82
36
|
const symbols = ownerPacketId != null
|
|
83
37
|
? parsed.filter((s) => s.packetId === ownerPacketId)
|
|
84
38
|
: parsed;
|
|
@@ -87,9 +41,8 @@ function resultFromSymbols(parsed, failedCount, failReasons, ownerPacketId) {
|
|
|
87
41
|
/**
|
|
88
42
|
* Gate one candidate MMTP packet on its fixed header: long enough, version 0,
|
|
89
43
|
* parseable, and an MPU packet. Returns the parsed header, or null after
|
|
90
|
-
* counting why it was refused.
|
|
91
|
-
*
|
|
92
|
-
* length-delimited packet under iso-ssbg1-v1).
|
|
44
|
+
* counting why it was refused. It sees the length-delimited protected packet,
|
|
45
|
+
* never the padded symbol.
|
|
93
46
|
*/
|
|
94
47
|
function gateMpuHeader(data, bump) {
|
|
95
48
|
if (data.length < MMTP_HEADER_SIZE) {
|
|
@@ -118,7 +71,7 @@ function parseProtectedPacket(packetData, hdr, index, bump) {
|
|
|
118
71
|
// packet (fecType=1 per draft-ramadan-moq-mmt-00 §3.1), but the 4-byte
|
|
119
72
|
// Source FEC Payload ID (ISO 23008-1 §C.5.2) is never part of the protected
|
|
120
73
|
// packet (C.4.2). Tell extractMFUPayload to skip FEC PID subtraction so it
|
|
121
|
-
// does not truncate video data; any
|
|
74
|
+
// does not truncate video data; any legacy authenticator trailer must then consume the
|
|
122
75
|
// exact suffix after the declared payload.
|
|
123
76
|
const extraction = extractMFUPayload(packetData, { skipFecId: true });
|
|
124
77
|
if (!extraction) {
|
|
@@ -147,22 +100,6 @@ function parseProtectedPacket(packetData, hdr, index, bump) {
|
|
|
147
100
|
rawSymbol: packetData,
|
|
148
101
|
};
|
|
149
102
|
}
|
|
150
|
-
/**
|
|
151
|
-
* k-padded-v1: the symbol is the protected packet zero-padded to T with no
|
|
152
|
-
* length field, so the packet ends at its ISO-declared MPU boundary (plus an
|
|
153
|
-
* ALTA trailer starting exactly there) and the rest must be uniform padding.
|
|
154
|
-
*/
|
|
155
|
-
function parseKPaddedSymbol(symbolData, index, bump) {
|
|
156
|
-
const hdr = gateMpuHeader(symbolData, bump);
|
|
157
|
-
if (!hdr)
|
|
158
|
-
return null;
|
|
159
|
-
const packetData = trimDecodedSourceSymbol(symbolData);
|
|
160
|
-
if (!packetData) {
|
|
161
|
-
bump("bad_length");
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
return parseProtectedPacket(packetData, hdr, index, bump);
|
|
165
|
-
}
|
|
166
103
|
/**
|
|
167
104
|
* iso-ssbg1-v1 (ISO/IEC 23008-1 C.3.3 ssbg_mode1): the symbol is
|
|
168
105
|
* `u16be(length) || protected packet || 00h padding`. The length field alone
|
|
@@ -183,16 +120,16 @@ function parseSsbg1Symbol(symbolData, index, bump) {
|
|
|
183
120
|
/**
|
|
184
121
|
* Parse one recovered FEC source symbol into an MFU fragment.
|
|
185
122
|
*
|
|
186
|
-
* The symbol is
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
123
|
+
* The symbol is the `iso-ssbg1-v1` ssbg_mode1 `u16 length || packet || zero
|
|
124
|
+
* padding` (ISO/IEC 23008-1 C.3.3): the length field alone delimits the
|
|
125
|
+
* protected packet, which is then parsed as an MMTP MPU packet. Failures are
|
|
126
|
+
* counted by reason (`bad_ssbg1_length` is the length/padding refusal), never
|
|
127
|
+
* thrown.
|
|
191
128
|
*
|
|
192
|
-
* @throws when `options.blockProfile` is absent or not
|
|
129
|
+
* @throws when `options.blockProfile` is absent or not `iso-ssbg1-v1`.
|
|
193
130
|
*/
|
|
194
131
|
export function processFecSymbol(symbolData, options) {
|
|
195
|
-
|
|
132
|
+
parseFecBlockProfile(options?.blockProfile, "processFecSymbol options.blockProfile");
|
|
196
133
|
const failReasons = {};
|
|
197
134
|
let failedCount = 0;
|
|
198
135
|
const bump = (reason) => {
|
|
@@ -204,9 +141,7 @@ export function processFecSymbol(symbolData, options) {
|
|
|
204
141
|
const index = options.index ?? 0;
|
|
205
142
|
let parsed;
|
|
206
143
|
try {
|
|
207
|
-
parsed =
|
|
208
|
-
? parseSsbg1Symbol(symbolData, index, bump)
|
|
209
|
-
: parseKPaddedSymbol(symbolData, index, bump);
|
|
144
|
+
parsed = parseSsbg1Symbol(symbolData, index, bump);
|
|
210
145
|
}
|
|
211
146
|
catch {
|
|
212
147
|
bump("exception");
|
|
@@ -214,19 +149,19 @@ export function processFecSymbol(symbolData, options) {
|
|
|
214
149
|
}
|
|
215
150
|
return resultFromSymbols(parsed ? [parsed] : [], failedCount, failReasons, options.ownerPacketId);
|
|
216
151
|
}
|
|
217
|
-
function requireSymbolSize(symbolSize
|
|
152
|
+
function requireSymbolSize(symbolSize) {
|
|
218
153
|
if (symbolSize === undefined) {
|
|
219
154
|
throw new Error("processFecBlock options.symbolSize is required: name the catalog fec.symbolSize (T)");
|
|
220
155
|
}
|
|
221
156
|
if (typeof symbolSize !== "number" || !Number.isSafeInteger(symbolSize) || symbolSize <= 0) {
|
|
222
157
|
throw new Error(`processFecBlock options.symbolSize must be a positive integer (got ${String(symbolSize)})`);
|
|
223
158
|
}
|
|
224
|
-
if (
|
|
159
|
+
if (symbolSize <= SSBG1_LENGTH_FIELD_BYTES) {
|
|
225
160
|
throw new Error(`processFecBlock options.symbolSize must exceed the ${SSBG1_LENGTH_FIELD_BYTES}-byte ssbg_mode1 length field (got ${symbolSize})`);
|
|
226
161
|
}
|
|
227
162
|
return symbolSize;
|
|
228
163
|
}
|
|
229
|
-
function requireSourceSymbolCount(k, blockLength, symbolSize
|
|
164
|
+
function requireSourceSymbolCount(k, blockLength, symbolSize) {
|
|
230
165
|
if (k === undefined) {
|
|
231
166
|
if (blockLength % symbolSize !== 0) {
|
|
232
167
|
throw new Error(`processFecBlock: ${blockLength} bytes is not a whole number of ${symbolSize}-byte symbols; pass options.k`);
|
|
@@ -238,7 +173,7 @@ function requireSourceSymbolCount(k, blockLength, symbolSize, blockProfile) {
|
|
|
238
173
|
}
|
|
239
174
|
// An iso-ssbg1-v1 block is exactly K' = SSB_length symbols of T bytes
|
|
240
175
|
// (C.5.3); any other length is not the block the repair symbols described.
|
|
241
|
-
if (
|
|
176
|
+
if (blockLength !== k * symbolSize) {
|
|
242
177
|
throw new Error(`processFecBlock: an iso-ssbg1-v1 block of ${k} symbols of ${symbolSize} bytes is ${k * symbolSize} bytes (got ${blockLength})`);
|
|
243
178
|
}
|
|
244
179
|
return k;
|
|
@@ -247,24 +182,23 @@ function requireSourceSymbolCount(k, blockLength, symbolSize, blockProfile) {
|
|
|
247
182
|
* Process a decoded FEC block into individual MFU fragments.
|
|
248
183
|
*
|
|
249
184
|
* The WASM RaptorQ decoder returns every source symbol of the block
|
|
250
|
-
* concatenated (
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* structured results sorted for reassembly.
|
|
185
|
+
* concatenated (SSB_length x T bytes). This function splits them apart,
|
|
186
|
+
* recovers each protected packet from its ssbg_mode1 length field (see
|
|
187
|
+
* {@link processFecSymbol}), extracts the MFU payload via shared
|
|
188
|
+
* extractMFUPayload, and returns structured results sorted for reassembly.
|
|
255
189
|
*
|
|
256
190
|
* @param blockData - Concatenated source symbols from the WASM decoder
|
|
257
191
|
* @param options - Block profile and symbol size T are required; see {@link ProcessFecBlockOptions}
|
|
258
192
|
* @throws when the block profile or symbol size is absent or invalid, when an
|
|
259
|
-
* omitted `k` cannot be read exactly from the block length, or when
|
|
260
|
-
*
|
|
193
|
+
* omitted `k` cannot be read exactly from the block length, or when the
|
|
194
|
+
* block is not exactly `k` symbols long.
|
|
261
195
|
*/
|
|
262
196
|
export function processFecBlock(blockData, options) {
|
|
263
197
|
const blockProfile = parseFecBlockProfile(options?.blockProfile, "processFecBlock options.blockProfile");
|
|
264
|
-
const symbolSize = requireSymbolSize(options.symbolSize
|
|
198
|
+
const symbolSize = requireSymbolSize(options.symbolSize);
|
|
265
199
|
if (!blockData || blockData.length === 0)
|
|
266
200
|
return emptyProcessResult();
|
|
267
|
-
const k = requireSourceSymbolCount(options.k, blockData.length, symbolSize
|
|
201
|
+
const k = requireSourceSymbolCount(options.k, blockData.length, symbolSize);
|
|
268
202
|
const failReasons = {};
|
|
269
203
|
let failedCount = 0;
|
|
270
204
|
const parsed = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-processor.js","sourceRoot":"","sources":["../src/block-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"block-processor.js","sourceRoot":"","sources":["../src/block-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GAGrB,MAAM,qBAAqB,CAAC;AAwE7B,SAAS,kBAAkB;IAC1B,OAAO;QACN,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgB,EAAE,QAAiB;IACjE,OAAO,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,qBAAqB,CAAC,CAAkB,EAAE,CAAkB;IACpE,6EAA6E;IAC7E,6EAA6E;IAC7E,6EAA6E;IAC7E,gEAAgE;IAChE,MAAM,WAAW,GAAG,CAAC,CAAC,CA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KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAClE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;QAC1D,CAAC;QACD,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -8,17 +8,10 @@
|
|
|
8
8
|
* It deliberately does NOT map MoQ media groups to FEC blocks. A recovered
|
|
9
9
|
* packet's media group is read from its own MMTP/MPU header
|
|
10
10
|
* ({@link recoveredPacketMediaGroup}), never from SBN arithmetic, and a source
|
|
11
|
-
* symbol's block comes from the wire:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - `iso-ssbg1-v1`: a block is the SS_ID range `[SS_Start, SS_Start +
|
|
16
|
-
* SSB_length)` its Repair FEC Payload ID states (ISO/IEC 23008-1 C.5.3), so
|
|
17
|
-
* SS_ID alone locates nothing and `fromSsId` throws.
|
|
18
|
-
*
|
|
19
|
-
* Object FEC (draft-ramadan-moq-fec §9.1) is the one exception: there each MoQ
|
|
20
|
-
* group IS its own FEC block, so {@link ObjectBlockMapper} keeps its identity
|
|
21
|
-
* `derive`.
|
|
11
|
+
* symbol's block comes from the wire: under `iso-ssbg1-v1` a block is the SS_ID
|
|
12
|
+
* range `[SS_Start, SS_Start + SSB_length)` its Repair FEC Payload ID states
|
|
13
|
+
* (ISO/IEC 23008-1 C.5.3), so SS_ID alone locates nothing and `fromSsId`
|
|
14
|
+
* throws for every stream with an FEC instance.
|
|
22
15
|
*/
|
|
23
16
|
import { type FecBlockProfile } from "@blockcast/mmt-base";
|
|
24
17
|
/** Configuration from catalog FEC parameters. */
|
|
@@ -27,10 +20,7 @@ export interface FecBlockConfig {
|
|
|
27
20
|
interleaveDepthMs: number;
|
|
28
21
|
/** GOP/frame duration (milliseconds). Measured from actual MMTP timestamps. */
|
|
29
22
|
gopDurationMs: number;
|
|
30
|
-
/**
|
|
31
|
-
* K from catalog fec.sourceSymbols: the source symbols per block under
|
|
32
|
-
* `k-padded-v1`, the maximum SSB_length under `iso-ssbg1-v1`.
|
|
33
|
-
*/
|
|
23
|
+
/** K from catalog fec.sourceSymbols: the maximum SSB_length of a block. */
|
|
34
24
|
k: number;
|
|
35
25
|
/**
|
|
36
26
|
* The catalog `fec.blockProfile`. Required and validated with
|
|
@@ -38,7 +28,7 @@ export interface FecBlockConfig {
|
|
|
38
28
|
*/
|
|
39
29
|
blockProfile: FecBlockProfile;
|
|
40
30
|
}
|
|
41
|
-
/** FEC coordinates of one MoQ object, for the
|
|
31
|
+
/** FEC coordinates of one MoQ object, for the mapper whose groups are blocks. */
|
|
42
32
|
export interface FecCoordinates {
|
|
43
33
|
/** Source Block Number */
|
|
44
34
|
sbn: number;
|
|
@@ -76,7 +66,7 @@ interface NoFecInstanceConfig {
|
|
|
76
66
|
export declare class FecBlockMapper {
|
|
77
67
|
/** Media units (GOPs/frames) per FEC block, recovered with positive round-half-up semantics. */
|
|
78
68
|
readonly d: number;
|
|
79
|
-
/** K:
|
|
69
|
+
/** K: the maximum SSB_length of a block (catalog `fec.sourceSymbols`). */
|
|
80
70
|
readonly k: number;
|
|
81
71
|
/** Block time span (ms) — used as pacing threshold */
|
|
82
72
|
readonly interleaveDepthMs: number;
|
|
@@ -94,14 +84,13 @@ export declare class FecBlockMapper {
|
|
|
94
84
|
*/
|
|
95
85
|
constructor(config: FecBlockConfig | NoFecInstanceConfig);
|
|
96
86
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
87
|
+
* SS_ID → (SBN, ESI). Only {@link NullBlockMapper} answers: a stream with an
|
|
88
|
+
* FEC instance is `iso-ssbg1-v1`, whose blocks are located by
|
|
89
|
+
* `(SS_Start, SSB_length)` range membership and never from SS_ID alone.
|
|
100
90
|
*
|
|
101
|
-
* @throws
|
|
102
|
-
* `(SS_Start, SSB_length)` range membership and never from SS_ID alone
|
|
91
|
+
* @throws for every stream with an FEC instance
|
|
103
92
|
*/
|
|
104
|
-
fromSsId(
|
|
93
|
+
fromSsId(_ssId: number): {
|
|
105
94
|
sbn: number;
|
|
106
95
|
esi: number;
|
|
107
96
|
};
|
|
@@ -137,53 +126,6 @@ export declare class NullBlockMapper extends FecBlockMapper {
|
|
|
137
126
|
/** No FEC: nothing to wait for, so pacing never sleeps. */
|
|
138
127
|
get pacingThresholdMs(): number;
|
|
139
128
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Object-level FEC (§9.1): each MoQ group (frame) is its own FEC block.
|
|
142
|
-
* K_actual = ceil(frame_bytes / symbolSize) — varies per block.
|
|
143
|
-
*
|
|
144
|
-
* SBN = group_id, ESI = object_id.
|
|
145
|
-
* SS_ID = Group_ID * sourceSymbols + Object_ID (§9.1.2).
|
|
146
|
-
*
|
|
147
|
-
* That SS_ID is the K-stride numbering of `k-padded-v1`; `iso-ssbg1-v1`
|
|
148
|
-
* numbers SS_IDs consecutively per source packet (ISO/IEC 23008-1 C.5.2), so
|
|
149
|
-
* §9.1 object FEC is defined only under `k-padded-v1` and the constructor
|
|
150
|
-
* refuses any other profile.
|
|
151
|
-
*
|
|
152
|
-
* The stride of that numbering is the catalog `sourceSymbols`, never a
|
|
153
|
-
* block's own K: a short block (K_actual < sourceSymbols) still starts at
|
|
154
|
-
* `Group_ID * sourceSymbols` (its repair's SS_Start) and leaves the rest of
|
|
155
|
-
* its stride unused, which is exactly `k-padded-v1` with `SSB_length =
|
|
156
|
-
* K_actual`. So the SS_ID locator is the inherited
|
|
157
|
-
* {@link FecBlockMapper.fromSsId} over `k = sourceSymbols`, the exact inverse
|
|
158
|
-
* of {@link ObjectBlockMapper.derive}; it needs no per-block K and infers
|
|
159
|
-
* nothing.
|
|
160
|
-
*
|
|
161
|
-
* This mapper does NOT carry per-block K. Each block discovers its own K from:
|
|
162
|
-
* 1. Clean reception: counting source objects per group
|
|
163
|
-
* 2. Repair packets: SSB_length in the Repair FEC Payload ID (ISO 23008-1 C.5.3)
|
|
164
|
-
*
|
|
165
|
-
* Callers MUST pass per-block K to FecBlockManager.addSourcePacket/addRepairPacket.
|
|
166
|
-
* Created once per stream, GC'd on stream close (Effect cleanup).
|
|
167
|
-
*/
|
|
168
|
-
export declare class ObjectBlockMapper extends FecBlockMapper {
|
|
169
|
-
/** Catalog sourceSymbols (max K) — used ONLY for SS_ID encoding (§9.1.2).
|
|
170
|
-
* Actual per-block K varies: K_actual = ceil(frame_bytes / symbolSize). */
|
|
171
|
-
readonly sourceSymbolsMax: number;
|
|
172
|
-
/**
|
|
173
|
-
* @param gopDurationMs - GOP/frame duration (ms)
|
|
174
|
-
* @param sourceSymbolsMax - Catalog `fec.sourceSymbols`
|
|
175
|
-
* @param blockProfile - Catalog `fec.blockProfile`; must be `k-padded-v1`
|
|
176
|
-
*/
|
|
177
|
-
constructor(gopDurationMs: number, sourceSymbolsMax: number, blockProfile: FecBlockProfile);
|
|
178
|
-
/**
|
|
179
|
-
* SBN = group_id, ESI = object_id. SS_ID per §9.1.2. Its inverse is the
|
|
180
|
-
* inherited `fromSsId` (SBN = floor(SS_ID / sourceSymbols), ESI = SS_ID mod
|
|
181
|
-
* sourceSymbols).
|
|
182
|
-
*/
|
|
183
|
-
derive(groupId: number, objectId: number): FecCoordinates;
|
|
184
|
-
/** One frame of latency: each frame is its own block. */
|
|
185
|
-
get pacingThresholdMs(): number;
|
|
186
|
-
}
|
|
187
129
|
/**
|
|
188
130
|
* Create a FecBlockMapper from catalog FEC config + measured GOP duration.
|
|
189
131
|
*
|
|
@@ -191,8 +133,10 @@ export declare class ObjectBlockMapper extends FecBlockMapper {
|
|
|
191
133
|
* {@link NullBlockMapper}; `fec.blockProfile` is not read, since a stream
|
|
192
134
|
* without FEC names none.
|
|
193
135
|
* - Otherwise `fec.blockProfile` is required (validated with
|
|
194
|
-
* `parseFecBlockProfile`, throwing
|
|
195
|
-
*
|
|
136
|
+
* `parseFecBlockProfile`, throwing unless it is `iso-ssbg1-v1`) and the
|
|
137
|
+
* result is a {@link FecBlockMapper}. `mode: 'object'` (per-group object
|
|
138
|
+
* FEC, SS_ID = Group_ID * K + Object_ID) throws: that numbering is the
|
|
139
|
+
* retired `k-padded-v1` stride, which `iso-ssbg1-v1` does not define.
|
|
196
140
|
*/
|
|
197
141
|
export declare function createMapper(fecConfig: {
|
|
198
142
|
interleaveDepthMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fec-block-mapper.d.ts","sourceRoot":"","sources":["../src/fec-block-mapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fec-block-mapper.d.ts","sourceRoot":"","sources":["../src/fec-block-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAA;AAG5B,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,iBAAiB,EAAE,MAAM,CAAA;IACzB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,CAAA;IACrB,2EAA2E;IAC3E,CAAC,EAAE,MAAM,CAAA;IACT;;;OAGG;IACH,YAAY,EAAE,eAAe,CAAA;CAC9B;AAED,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAA;IACX,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAQpE;AAED;;;;;GAKG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