@blockcast/fec-worker 0.3.0 → 0.4.0-main.373719cc7317
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 +15 -20
- package/dist/block-order.d.ts +3 -19
- package/dist/block-order.d.ts.map +1 -1
- package/dist/block-order.js +3 -33
- package/dist/block-order.js.map +1 -1
- package/dist/fec-worker-client.d.ts +6 -16
- package/dist/fec-worker-client.d.ts.map +1 -1
- package/dist/fec-worker-client.js +10 -38
- package/dist/fec-worker-client.js.map +1 -1
- package/dist/fec-worker-types.d.ts +47 -101
- package/dist/fec-worker-types.d.ts.map +1 -1
- package/dist/fec-worker-types.js +2 -2
- package/dist/fec-worker.js +26 -187
- package/dist/fec-worker.js.map +2 -2
- package/package.json +4 -7
- package/src/block-order.ts +3 -37
- package/src/fec-worker-client.ts +8 -40
- package/src/fec-worker-types.ts +47 -101
- package/src/fec-worker.ts +49 -454
package/src/fec-worker-types.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @blockcast/fec-worker — Shared Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* Defines the Worker message protocol (commands/events), FecTrackStats shape
|
|
5
|
-
* consumed by fec-panel (Phase 5) and CmcdProducer (Phase 6), and
|
|
6
|
-
*
|
|
5
|
+
* consumed by fec-panel (Phase 5) and CmcdProducer (Phase 6), and the relay
|
|
6
|
+
* block signature stub.
|
|
7
7
|
*
|
|
8
8
|
* Types here are importable from both main thread and Worker contexts.
|
|
9
9
|
*/
|
|
@@ -12,19 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* FEC block profile (BLO-35597, ISO/IEC 23008-1 Annex C): the catalog
|
|
15
|
-
* `fec.blockProfile` token.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* packet mod 2^32; a block is `[SS_Start, SS_Start + SSB_length)` keyed by
|
|
22
|
-
* SS_Start; `k` is only the maximum SSB_length; repair ESI =
|
|
23
|
-
* SSB_length + RS_ID.
|
|
15
|
+
* `fec.blockProfile` token. Required and never inferred; the only profile is
|
|
16
|
+
* `iso-ssbg1-v1` (C.3.3 ssbg_mode1): SS_ID increments by one per source
|
|
17
|
+
* packet mod 2^32; a block is `[SS_Start, SS_Start + SSB_length)` keyed by
|
|
18
|
+
* SS_Start; `k` is only the maximum SSB_length; repair ESI =
|
|
19
|
+
* SSB_length + RS_ID. The retired `k-padded-v1` token is refused like any
|
|
20
|
+
* unknown one.
|
|
24
21
|
*
|
|
25
22
|
* Mirrors @blockcast/mmt-base `FecBlockProfile`.
|
|
26
23
|
*/
|
|
27
|
-
export type FecBlockProfile = "
|
|
24
|
+
export type FecBlockProfile = "iso-ssbg1-v1";
|
|
28
25
|
|
|
29
26
|
/** Per-track FEC configuration. Matches design spec section 3.2 FecTrackConfig. */
|
|
30
27
|
export interface FecTrackConfig {
|
|
@@ -51,26 +48,31 @@ export interface FecTrackConfig {
|
|
|
51
48
|
repairCount: number;
|
|
52
49
|
/** Bytes per symbol */
|
|
53
50
|
symbolSize: number;
|
|
54
|
-
/** Retained decoder horizon as a BLOCK COUNT
|
|
55
|
-
*
|
|
56
|
-
* `
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* (block-order.ts), the lower bound every ISO receiver layer shares.
|
|
51
|
+
/** Retained decoder horizon as a BLOCK COUNT, not D. `isRetiredSbn`
|
|
52
|
+
* retires blocks more than this many blocks behind the live SS_ID, by
|
|
53
|
+
* `isoBlocksBehind(SS_ID, live SS_ID, k)` (block-order.ts), the lower
|
|
54
|
+
* bound every ISO receiver layer shares, and `MmtFecDecoder::new`
|
|
55
|
+
* documents it as "the number of interleaved blocks".
|
|
60
56
|
* Never assign `deriveFecInterleaveDepth()` here — that returns media units
|
|
61
57
|
* per block, which is a different quantity (BLO-35597). */
|
|
62
58
|
interleaveDepth: number;
|
|
63
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Catalog interleave span in integer milliseconds. A positive value is the complete
|
|
61
|
+
* source-plus-repair span; zero represents an absent/zero catalog span and
|
|
62
|
+
* carries no elapsed-time deadline.
|
|
63
|
+
*/
|
|
64
64
|
interleaveMs: number;
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Positive cleanup budget. For a positive `interleaveMs` this is the
|
|
67
|
+
* catalog span plus its explicit reorder allowance. For zero it is a
|
|
68
|
+
* receiver-local bound only, never an inferred catalog deadline.
|
|
69
|
+
*/
|
|
66
70
|
deliveryWindowMs: number;
|
|
67
71
|
/** FEC encoding mode */
|
|
68
72
|
fecMode: "subframe" | "object";
|
|
69
73
|
/** MoQ repair track name (optional) */
|
|
70
74
|
repairTrack?: string;
|
|
71
75
|
|
|
72
|
-
/** Whether ALTA publisher auth is enabled (AUTH-01) */
|
|
73
|
-
altaEnabled: boolean;
|
|
74
76
|
/** Whether relay block signature verification is enabled (AUTH-01) */
|
|
75
77
|
relayBlockSigEnabled: boolean;
|
|
76
78
|
}
|
|
@@ -79,8 +81,7 @@ export interface FecTrackConfig {
|
|
|
79
81
|
|
|
80
82
|
/** Per-block snapshot for live block visualization and stats. */
|
|
81
83
|
export interface FecBlockSnapshot {
|
|
82
|
-
/** Block key: the
|
|
83
|
-
* SS_Start under `iso-ssbg1-v1`. */
|
|
84
|
+
/** Block key: the block's SS_Start. */
|
|
84
85
|
sbn: number;
|
|
85
86
|
/** Current block state */
|
|
86
87
|
state: "collecting" | "complete" | "recovered" | "failed";
|
|
@@ -103,10 +104,11 @@ export interface FecBlockSnapshot {
|
|
|
103
104
|
lastSymbolTs: number;
|
|
104
105
|
/** Timestamp when block completed (ms), undefined if not yet complete */
|
|
105
106
|
completedTs?: number;
|
|
106
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Cleanup timestamp (ms). It is the catalog completion deadline when
|
|
109
|
+
* `config.interleaveMs > 0`, and a local retention timestamp otherwise.
|
|
110
|
+
*/
|
|
107
111
|
deadlineTs: number;
|
|
108
|
-
/** Count of source symbols with valid ALTA signature (AUTH-02) */
|
|
109
|
-
altaVerified: number;
|
|
110
112
|
/** Relay block signature validity: true/false after verification, null if not yet verified (AUTH-02) */
|
|
111
113
|
relayBlockSigValid: boolean | null;
|
|
112
114
|
}
|
|
@@ -131,45 +133,12 @@ export interface FecTrackStats {
|
|
|
131
133
|
/** Recovery success rate 0-100 */
|
|
132
134
|
recoveryRate: number;
|
|
133
135
|
|
|
134
|
-
/** Packets with valid publisher ALTA signature */
|
|
135
|
-
altaVerified: number;
|
|
136
|
-
/** Packets with MAC / signature / hash-chain mismatch (tamper-confirmed) */
|
|
137
|
-
altaFailed: number;
|
|
138
|
-
/** Packets that couldn't be verified due to missing trailer / not-ready verifier /
|
|
139
|
-
* late-joiner bootstrap gap. Neither tamper nor error — just unverifiable. */
|
|
140
|
-
altaPending: number;
|
|
141
|
-
/** Deferred-queue entries evicted by cap (queue full). Separate counter so
|
|
142
|
-
* cap misconfiguration is distinguishable from natural bootstrap-gap noise. */
|
|
143
|
-
altaPendingEvictedCap: number;
|
|
144
|
-
/** Deferred-queue entries evicted by TTL (retry window expired). */
|
|
145
|
-
altaPendingEvictedTtl: number;
|
|
146
|
-
/** verifyDetached / parse threw an exception (WASM trap, OOM, unmarshal panic).
|
|
147
|
-
* Not counted as altaFailed because the cause isn't crypto — helps ops
|
|
148
|
-
* distinguish infrastructure flake from tamper. */
|
|
149
|
-
altaError: number;
|
|
150
|
-
/** True if ALTA was enabled at configure time but the verifier WASM init
|
|
151
|
-
* failed. Ops alerting should treat this as "ALTA disabled due to error",
|
|
152
|
-
* distinct from "ALTA disabled by config" (altaEnabled flag not present). */
|
|
153
|
-
altaInitFailed: boolean;
|
|
154
|
-
/** Diagnostic: last ≤16 altaFailed events with full context (seq, error
|
|
155
|
-
* string from the verifier, auth+payload lengths, and which code path
|
|
156
|
-
* raised the failure). Bounded so it can't blow memory. Intended for
|
|
157
|
-
* investigation — not a stable API; consumers should treat it as
|
|
158
|
-
* opt-in and defensive (may be undefined). */
|
|
159
|
-
altaFailedDetails?: Array<{
|
|
160
|
-
seq: number;
|
|
161
|
-
error: string;
|
|
162
|
-
authLen: number;
|
|
163
|
-
payloadLen: number;
|
|
164
|
-
path: string;
|
|
165
|
-
}>;
|
|
166
136
|
/** Blocks with valid relay signature */
|
|
167
137
|
relayBlocksVerified: number;
|
|
168
138
|
/** Blocks with invalid relay signature */
|
|
169
139
|
relayBlocksFailed: number;
|
|
170
140
|
|
|
171
|
-
/** Live media position: the newest
|
|
172
|
-
* `k-padded-v1`, the newest accepted SS_ID / SS_Start under `iso-ssbg1-v1`. */
|
|
141
|
+
/** Live media position: the newest accepted SS_ID / SS_Start. */
|
|
173
142
|
liveSbn: number;
|
|
174
143
|
/** Active block snapshots */
|
|
175
144
|
blocks: FecBlockSnapshot[];
|
|
@@ -220,13 +189,14 @@ export interface FecTrackStats {
|
|
|
220
189
|
*/
|
|
221
190
|
sourceDroppedDuplicate?: number;
|
|
222
191
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
192
|
+
* Accepted source symbols whose block never became known (no repair
|
|
193
|
+
* symbol named a range containing them) before their SS_ID fell behind
|
|
194
|
+
* the retained horizon. They were already fed to the decoder and routed
|
|
195
|
+
* directly; this counts the bookkeeping retired with them, i.e. evidence
|
|
196
|
+
* that a block's repair symbols never arrived. The decoder retires its
|
|
197
|
+
* own copies by the same horizon inside `cleanup_by_ss_start`.
|
|
228
198
|
*/
|
|
229
|
-
sourceUnplacedRetired
|
|
199
|
+
sourceUnplacedRetired: number;
|
|
230
200
|
/** Native decoder counters, converted to numbers so browser diagnostics remain JSON-safe. */
|
|
231
201
|
decoder?: {
|
|
232
202
|
sourcePackets: number;
|
|
@@ -262,11 +232,9 @@ export type FecWorkerErrorCode =
|
|
|
262
232
|
|
|
263
233
|
/** Per-frame metadata emitted with frame events from Worker. */
|
|
264
234
|
export interface FrameMeta {
|
|
265
|
-
/** ALTA verification result: true/false after check, null when ALTA not configured (AUTH-04) */
|
|
266
|
-
altaVerified: boolean | null;
|
|
267
235
|
/** Whether this frame was recovered via FEC (not received directly) */
|
|
268
236
|
recovered: boolean;
|
|
269
|
-
/** Block key this frame belongs to:
|
|
237
|
+
/** Block key this frame belongs to: the block's SS_Start */
|
|
270
238
|
sbn: number;
|
|
271
239
|
/** Encoding Symbol ID within the recovered source block (0..ssbLength-1).
|
|
272
240
|
* Under `iso-ssbg1-v1` a recovered frame is the full T-byte ssbg_mode1
|
|
@@ -289,51 +257,29 @@ export type FecWorkerCommand =
|
|
|
289
257
|
type: "configure";
|
|
290
258
|
config: FecTrackConfig;
|
|
291
259
|
wasmModule: WebAssembly.Module;
|
|
292
|
-
/**
|
|
293
|
-
* ALTA public key as PKCS#8 SubjectPublicKeyInfo DER bytes (self-describing).
|
|
294
|
-
* Algorithm (Ed25519 or ECDSA P-256) is auto-detected from the SPKI OID.
|
|
295
|
-
* Ed25519 SPKI is 44 bytes; P-256 uncompressed is 91 bytes.
|
|
296
|
-
*/
|
|
297
|
-
altaPublicKey?: ArrayBuffer;
|
|
298
|
-
/** Pre-compiled ALTA WASM module. Structured-cloneable (NOT transferable) — do not add to transfer list. */
|
|
299
|
-
altaWasmModule?: WebAssembly.Module;
|
|
300
260
|
}
|
|
301
261
|
| {
|
|
302
262
|
type: "feedSource";
|
|
303
263
|
/** Flat 32-bit Source Symbol ID from the MMTP Source FEC Payload ID
|
|
304
|
-
* (ISO 23008-1 §C.5.2).
|
|
305
|
-
*
|
|
306
|
-
* pre-compute
|
|
307
|
-
* packet mod 2^32 and the block comes from a repair's range. */
|
|
264
|
+
* (ISO 23008-1 §C.5.2). SS_IDs are consecutive per source packet mod
|
|
265
|
+
* 2^32 and the block comes from a repair's range — do NOT
|
|
266
|
+
* pre-compute a block. */
|
|
308
267
|
ssId: number;
|
|
309
|
-
/**
|
|
310
|
-
*
|
|
268
|
+
/** The protected packet exactly, unpadded and without its SS_ID (at
|
|
269
|
+
* most T-2 bytes). */
|
|
311
270
|
data: ArrayBuffer;
|
|
312
271
|
ts: number;
|
|
313
|
-
/** Optional ALTA authenticator bytes (detached mode — 08-07 MMTP
|
|
314
|
-
* trailer). Present when the source packet carried a
|
|
315
|
-
* `[0xF0A1][len][auth]` trailer and ALTA is enabled at the worker.
|
|
316
|
-
* When omitted, the worker skips verification and the packet
|
|
317
|
-
* counts as `altaPending`. */
|
|
318
|
-
altaAuth?: ArrayBuffer;
|
|
319
|
-
/** Byte offset within `data` where the signed MMTP payload ends
|
|
320
|
-
* (== where the trailer began on the wire). Required when
|
|
321
|
-
* `altaAuth` is present. Worker constructs
|
|
322
|
-
* `payload = new Uint8Array(data, 0, altaPayloadEnd)` for
|
|
323
|
-
* `verifyDetached(altaAuth, payload)`. */
|
|
324
|
-
altaPayloadEnd?: number;
|
|
325
272
|
}
|
|
326
273
|
| {
|
|
327
274
|
type: "feedRepair";
|
|
328
275
|
/** SS_Start: SS_ID of the first source symbol in the block, from the
|
|
329
|
-
* MMTP Repair FEC Payload ID (ISO 23008-1 §C.5.3)
|
|
330
|
-
*
|
|
276
|
+
* MMTP Repair FEC Payload ID (ISO 23008-1 §C.5.3): any uint32; the
|
|
277
|
+
* block key. */
|
|
331
278
|
ssStart: number;
|
|
332
279
|
/** Authored source-symbol count for this block; 1..configured K. */
|
|
333
280
|
ssbLength: number;
|
|
334
281
|
/** RS_ID: repair symbol index within the block; WASM maps to repair
|
|
335
|
-
* ESI =
|
|
336
|
-
* (`iso-ssbg1-v1`). */
|
|
282
|
+
* ESI = SSB_length + RS_ID. */
|
|
337
283
|
rsId: number;
|
|
338
284
|
data: ArrayBuffer;
|
|
339
285
|
ts: number;
|
|
@@ -358,7 +304,7 @@ export type FecWorkerCommand =
|
|
|
358
304
|
| {
|
|
359
305
|
type: "cleanup";
|
|
360
306
|
/** Every timed-out block covered by this coalesced queue-drain barrier,
|
|
361
|
-
* by block key
|
|
307
|
+
* by block key (SS_Start). */
|
|
362
308
|
sbns: number[];
|
|
363
309
|
}
|
|
364
310
|
| { type: "reset" }
|