@blockcast/mmt-wasm 0.3.0 → 0.4.0-main.2654dbc2ed6d

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/package.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "name": "@blockcast/mmt-wasm",
3
- "version": "0.3.0",
4
- "description": "wasm-bindgen builds of the libmmt Rust core (RaptorQ FEC, MMTP MFU reassembly): `pkg` for ESM bundlers and `pkg-no-modules` as a global script for Closure-compiled pages",
5
- "main": "pkg/mmt_wasm.js",
6
- "types": "pkg/mmt_wasm.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./pkg/mmt_wasm.d.ts",
10
- "import": "./pkg/mmt_wasm.js"
11
- },
12
- "./mmt_wasm_bg.wasm": "./pkg/mmt_wasm_bg.wasm",
13
- "./no-modules": {
14
- "types": "./pkg-no-modules/mmt_wasm.d.ts",
15
- "default": "./pkg-no-modules/mmt_wasm.js"
16
- },
17
- "./no-modules/mmt_wasm_bg.wasm": "./pkg-no-modules/mmt_wasm_bg.wasm",
18
- "./package.json": "./package.json"
19
- },
20
- "files": [
21
- "pkg",
22
- "pkg-no-modules"
23
- ],
24
- "scripts": {
25
- "build": "make -C ../.. mmt-wasm",
26
- "test": "node build-contract.test.mjs"
27
- },
28
- "keywords": [
29
- "mmt",
30
- "mmtp",
31
- "raptorq",
32
- "wasm"
33
- ],
34
- "license": "Apache-2.0",
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/Blockcast/libmmt.git",
38
- "directory": "packages/mmt-wasm"
39
- }
2
+ "name": "@blockcast/mmt-wasm",
3
+ "version": "0.4.0-main.2654dbc2ed6d",
4
+ "description": "wasm-bindgen builds of the libmmt Rust core (RaptorQ FEC, MMTP MFU reassembly): `pkg` for ESM bundlers and `pkg-no-modules` as a global script for Closure-compiled pages",
5
+ "main": "pkg/mmt_wasm.js",
6
+ "types": "pkg/mmt_wasm.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./pkg/mmt_wasm.d.ts",
10
+ "import": "./pkg/mmt_wasm.js"
11
+ },
12
+ "./mmt_wasm_bg.wasm": "./pkg/mmt_wasm_bg.wasm",
13
+ "./no-modules": {
14
+ "types": "./pkg-no-modules/mmt_wasm.d.ts",
15
+ "default": "./pkg-no-modules/mmt_wasm.js"
16
+ },
17
+ "./no-modules/mmt_wasm_bg.wasm": "./pkg-no-modules/mmt_wasm_bg.wasm",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "pkg",
22
+ "pkg-no-modules"
23
+ ],
24
+ "scripts": {
25
+ "build": "make -C ../.. mmt-wasm",
26
+ "test": "node build-contract.test.mjs"
27
+ },
28
+ "keywords": [
29
+ "mmt",
30
+ "mmtp",
31
+ "raptorq",
32
+ "wasm"
33
+ ],
34
+ "license": "Apache-2.0",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/Blockcast/libmmt.git",
38
+ "directory": "packages/mmt-wasm"
39
+ }
40
40
  }
package/pkg/mmt_wasm.d.ts CHANGED
@@ -45,6 +45,12 @@ export class FecStats {
45
45
  * Blocks that expired with fewer than K symbols (delivery issue, not FEC issue)
46
46
  */
47
47
  blocks_delivery_failed: bigint;
48
+ /**
49
+ * `iso-ssbg1-v1` held sources evicted, oldest arrival first, because the
50
+ * unplaced pool was at its `(interleave_depth + 1) * K` cap: no sweep
51
+ * (`cleanup_by_ss_start` / `retire_unplaced`) retired them first.
52
+ */
53
+ unplaced_evicted: bigint;
48
54
  }
49
55
 
50
56
  export class MfuFragmentJs {
@@ -100,27 +106,15 @@ export class MmtFecDecoder {
100
106
  /**
101
107
  * Add a repair symbol per ISO 23008-1 §C.5.3.
102
108
  *
103
- * Repair carries (SS_Start, SSB_length, RS_ID).
104
- * SS_Start = SS_ID of first source in block = SBN * K.
105
- * SSB_length = the authored source-symbol count in this block (1..=K).
106
- * SBN = SS_Start / configured K.
107
- * Repair ESI = K + RS_ID.
108
- *
109
- * The decoder's configured K is the fixed RaptorQ geometry. A short
110
- * authored block (`SSB_length < K`) is the producer's K-symbol RaptorQ
111
- * block with ESIs `SSB_length..K` zero-filled and never transmitted
112
- * (fec-raptorq `InterleavedEncoder::force_complete`). The block records
113
- * `SSB_length`, completes once that many source symbols arrived, and
114
- * recovers from `SSB_length` received symbols by supplying the known
115
- * padding itself. A conflicting `SSB_length` for one block is rejected
116
- * without changing that block.
117
- *
118
- * Under `iso-ssbg1-v1` the block is `[SS_Start, SS_Start + SSB_length)`
119
- * with `1 <= SSB_length <= K` (K is only the maximum), its RaptorQ geometry
120
- * is K' = SSB_length with no padding, and repair ESI = SSB_length + RS_ID
121
- * (C.5.3). The first repair defines the block and claims every held source
122
- * in range. A conflicting SSB_length, or a range overlapping a different
123
- * known block, is refused without changing any block. Output is the K'*T
109
+ * Repair carries (SS_Start, SSB_length, RS_ID). The block is
110
+ * `[SS_Start, SS_Start + SSB_length)` with `1 <= SSB_length <= K` (the
111
+ * configured K is only the maximum), its RaptorQ geometry is
112
+ * K' = SSB_length with no padding, and repair ESI = SSB_length + RS_ID.
113
+ * The first repair defines the block and claims every held source in
114
+ * range. A conflicting SSB_length, a range overlapping a different known
115
+ * block, or a start more than `interleave_depth` blocks behind the last
116
+ * `cleanup_by_ss_start`'s `current` (`iso_blocks_behind_lower_bound`), is
117
+ * refused without changing any block. Output is the K'*T
124
118
  * concatenated ssbg_mode1 symbols: split by T and trim by the length field.
125
119
  */
126
120
  add_repair(ss_start: number, ssb_length: number, rs_id: number, data: Uint8Array, timestamp: number): Uint8Array | undefined;
@@ -130,13 +124,12 @@ export class MmtFecDecoder {
130
124
  * SS_ID is a flat 32-bit counter. An unconfigured decoder rejects the
131
125
  * packet.
132
126
  *
133
- * - `k-padded-v1`: derives SBN = floor(SS_ID / K), ESI = SS_ID % K and
134
- * zero-pads `data` to T.
135
- * - `iso-ssbg1-v1`: builds the C.3.3 ssbg_mode1 symbol
136
- * `u16be(len) || data || zero padding` (refusing `len + 2 > T`) and
137
- * places it at ESI = serial distance from the start of the known block
138
- * whose `[SS_Start, SS_Start + SSB_length)` contains SS_ID. A source
139
- * whose block no repair has defined yet is held by SS_ID until one does.
127
+ * Builds the C.3.3 ssbg_mode1 symbol `u16be(len) || data || zero padding`
128
+ * (refusing `len + 2 > T`) and places it at ESI = serial distance from the
129
+ * start of the known block whose `[SS_Start, SS_Start + SSB_length)`
130
+ * contains SS_ID. A source whose block no repair has defined yet is held
131
+ * by SS_ID until one does; at most `(interleave_depth + 1) * K` are held, and
132
+ * the oldest arrival is evicted first (`FecStats::unplaced_evicted`).
140
133
  *
141
134
  * # Arguments
142
135
  * * `ss_id` - Source symbol ID (32-bit monotonic counter)
@@ -152,18 +145,6 @@ export class MmtFecDecoder {
152
145
  * Get alignment (Al) parameter from OTI
153
146
  */
154
147
  get_alignment(): number;
155
- /**
156
- * `k-padded-v1` only: cleanup blocks more than `interleave_depth` blocks
157
- * behind `current_sbn`. Refused under `iso-ssbg1-v1`, which has no SBN
158
- * (use `cleanup_by_ss_start`).
159
- *
160
- * Blocks are ordered by RFC 1982 serial comparison of their first SS_ID
161
- * (`sbn * K mod 2^32`, ISO/IEC 23008-1 C.5.2; BLO-35597 iso:5). For a
162
- * stream that has not wrapped SS_ID that is exactly the old
163
- * `sbn < current_sbn - interleave_depth`; after the wrap it still retires
164
- * the pre-wrap blocks instead of keeping them forever.
165
- */
166
- cleanup_by_sbn(current_sbn: number): Uint32Array;
167
148
  /**
168
149
  * Get sub-blocks (N) parameter from OTI
169
150
  */
@@ -177,11 +158,11 @@ export class MmtFecDecoder {
177
158
  */
178
159
  get_symbol_size(): number;
179
160
  /**
180
- * `iso-ssbg1-v1` only: retire the held source symbols that no repair can
181
- * place any more, by the same rule as `cleanup_by_ss_start`, without
182
- * retiring any block. For a caller that retires blocks itself, by their
183
- * deadlines (`cleanup_blocks_detailed`), and needs only this half. Returns
184
- * how many it retired.
161
+ * Retire the held source symbols that no repair can place any more, by
162
+ * the same rule as `cleanup_by_ss_start`, without retiring any block. For
163
+ * a caller that retires blocks itself, by their deadlines
164
+ * (`cleanup_blocks_detailed`), and needs only this half. Returns how many
165
+ * it retired.
185
166
  */
186
167
  retire_unplaced(current: number): number;
187
168
  /**
@@ -201,11 +182,11 @@ export class MmtFecDecoder {
201
182
  */
202
183
  get_source_blocks(): number;
203
184
  /**
204
- * `iso-ssbg1-v1` only: retire every block, and every held source symbol,
205
- * lying more than `interleave_depth` blocks behind SS_ID `current`, the
206
- * newest SS_ID the caller has seen (no block start or held source follows
207
- * it). A block start or held source that `current` has moved at least
208
- * half the SS_ID space past no longer precedes it and is retired too
185
+ * Retire every block, and every held source symbol, lying more than
186
+ * `interleave_depth` blocks behind SS_ID `current`, the newest SS_ID the
187
+ * caller has seen (no block start or held source follows it). A block
188
+ * start or held source that `current` has moved at least half the SS_ID
189
+ * space past no longer precedes it and is retired too
209
190
  * (`iso_past_horizon`).
210
191
  *
211
192
  * Blocks have no SBN under ssbg_mode1, so distance is measured on the
@@ -221,21 +202,21 @@ export class MmtFecDecoder {
221
202
  */
222
203
  get_interleave_depth(): number;
223
204
  /**
224
- * Finalize only the source blocks whose host-owned deadlines fired.
225
- * Keys are SBNs under `k-padded-v1` and SS_Starts under `iso-ssbg1-v1`.
205
+ * Finalize only the source blocks whose host-owned deadlines fired,
206
+ * named by their SS_Starts.
226
207
  *
227
208
  * The JavaScript FEC manager owns per-block repair grace. A timeout for one
228
209
  * block must therefore not run the decoder's global age scan and evict a
229
210
  * peer block that is still waiting for fetched repair.
230
211
  */
231
- cleanup_blocks_detailed(sbns: Uint32Array): void;
212
+ cleanup_blocks_detailed(ss_starts: Uint32Array): void;
232
213
  /**
233
214
  * Create a new FEC decoder
234
215
  *
235
216
  * # Arguments
236
217
  * * `interleave_depth` - Explicit positive number of interleaved blocks.
237
- * * `block_profile` - Catalog `fec.blockProfile`: `"k-padded-v1"` or
238
- * `"iso-ssbg1-v1"`. Required; any other value is refused.
218
+ * * `block_profile` - Catalog `fec.blockProfile`: `"iso-ssbg1-v1"`.
219
+ * Required; any other value is refused.
239
220
  */
240
221
  constructor(interleave_depth: number, block_profile: string);
241
222
  /**
@@ -250,7 +231,8 @@ export class MmtFecDecoder {
250
231
  * Configure FEC from 12-byte OTI
251
232
  *
252
233
  * # Arguments
253
- * * `oti` - 12-byte Object Transmission Information from S-TSID fecOTI
234
+ * * `oti` - 12-byte RFC 6330 Common FEC OTI: decoder geometry per
235
+ * draft-fec-01 Section 4.2 (Z = 1, N = 1, Al = 8)
254
236
  */
255
237
  configure(oti: Uint8Array): void;
256
238
  /**
@@ -270,33 +252,28 @@ export class MmtFecEncoder {
270
252
  * `[SS_Start:4][RSB_length:3][RS_ID:3][SSB_length:3][symbol: T]`.
271
253
  * Callers split on that stride; `entry i` is at `i * (13 + T)`.
272
254
  *
273
- * `k-padded-v1`: `block` is the Source Block Number and `source_block`
274
- * MUST be exactly `K * symbol_size` bytes — the caller pads the final
275
- * (short) block with zeros, mirroring `InterleavedEncoder` and the FFmpeg
276
- * path. `SS_Start = block * K` (wrapping), `SSB_length = K`.
277
- *
278
- * `iso-ssbg1-v1`: `block` is the SS_Start (the block's first SS_ID) and
279
- * `source_block` is the block's K' ssbg_mode1 symbols (`1 <= K' <= K`,
280
- * `len % T == 0`, each a well-formed C.3.3 symbol). RaptorQ runs over K'
281
- * symbols (F = K'*T) and `SSB_length = K'`.
255
+ * `ss_start` is the block's first SS_ID and `source_block` is the
256
+ * block's K' ssbg_mode1 symbols (`1 <= K' <= K`, `len % T == 0`, each a
257
+ * well-formed C.3.3 symbol). RaptorQ runs over K' symbols (F = K'*T) and
258
+ * `SSB_length = K'`.
282
259
  *
283
260
  * # Arguments
284
- * * `block` - SBN (`k-padded-v1`) or SS_Start (`iso-ssbg1-v1`).
261
+ * * `ss_start` - SS_Start: the block's first SS_ID.
285
262
  * * `source_block` - The block's source symbols, as described above.
286
263
  * * `repair_count` - Number of repair symbols (P) to generate.
287
264
  */
288
- encode_repair(block: number, source_block: Uint8Array, repair_count: number): Uint8Array;
265
+ encode_repair(ss_start: number, source_block: Uint8Array, repair_count: number): Uint8Array;
289
266
  /**
290
267
  * Create an encoder for a fixed `(K, symbol_size)` block geometry.
291
268
  *
292
269
  * Builds the OTI as `ObjectTransmissionInformation::new(K*T, T, 1, 1, 8)`
293
- * (single source block, single sub-block, byte alignment) — matching the
294
- * decoder's recovery model in [`FecBlock::try_decode`] — and pre-computes
295
- * the shared `SourceBlockEncodingPlan` so per-block encoding is cheap.
270
+ * (single source block, single sub-block, byte alignment) — the geometry
271
+ * [`MmtFecDecoder::configure`] reads back. K is the maximum SSB_length;
272
+ * each block is encoded over its own K' symbols (see
273
+ * [`MmtFecEncoder::encode_repair`]).
296
274
  *
297
- * `block_profile` is the catalog `fec.blockProfile` (`"k-padded-v1"` or
298
- * `"iso-ssbg1-v1"`); any other value is refused. Under `iso-ssbg1-v1`, K
299
- * is the maximum SSB_length.
275
+ * `block_profile` is the catalog `fec.blockProfile` (`"iso-ssbg1-v1"`);
276
+ * any other value is refused.
300
277
  */
301
278
  constructor(k: number, symbol_size: number, block_profile: string);
302
279
  /**
@@ -808,7 +785,7 @@ export interface InitOutput {
808
785
  readonly __wbg_get_fecstats_bytes_recovered: (a: number) => bigint;
809
786
  readonly __wbg_get_fecstats_repair_packets: (a: number) => bigint;
810
787
  readonly __wbg_get_fecstats_source_packets: (a: number) => bigint;
811
- readonly __wbg_get_reassemblerstatsjs_ambiguous_fallback_fragments: (a: number) => bigint;
788
+ readonly __wbg_get_fecstats_unplaced_evicted: (a: number) => bigint;
812
789
  readonly __wbg_mfufragmentjs_free: (a: number, b: number) => void;
813
790
  readonly __wbg_mmtfecdecoder_free: (a: number, b: number) => void;
814
791
  readonly __wbg_mmtfecencoder_free: (a: number, b: number) => void;
@@ -821,7 +798,6 @@ export interface InitOutput {
821
798
  readonly __wbg_moqfecencoder_free: (a: number, b: number) => void;
822
799
  readonly __wbg_moqfecstatsjs_free: (a: number, b: number) => void;
823
800
  readonly __wbg_reassembledmfujs_free: (a: number, b: number) => void;
824
- readonly __wbg_reassemblerstatsjs_free: (a: number, b: number) => void;
825
801
  readonly __wbg_recoveredset_free: (a: number, b: number) => void;
826
802
  readonly __wbg_samplecombinerstatsjs_free: (a: number, b: number) => void;
827
803
  readonly __wbg_set_fecstats_blocks_complete: (a: number, b: bigint) => void;
@@ -831,7 +807,7 @@ export interface InitOutput {
831
807
  readonly __wbg_set_fecstats_bytes_recovered: (a: number, b: bigint) => void;
832
808
  readonly __wbg_set_fecstats_repair_packets: (a: number, b: bigint) => void;
833
809
  readonly __wbg_set_fecstats_source_packets: (a: number, b: bigint) => void;
834
- readonly __wbg_set_reassemblerstatsjs_ambiguous_fallback_fragments: (a: number, b: bigint) => void;
810
+ readonly __wbg_set_fecstats_unplaced_evicted: (a: number, b: bigint) => void;
835
811
  readonly __wbg_shredfecbuffer_free: (a: number, b: number) => void;
836
812
  readonly __wbg_shredreassembler_free: (a: number, b: number) => void;
837
813
  readonly annexb_access_unit_is_keyframe: (a: number, b: number, c: number, d: number) => [number, number, number];
@@ -862,7 +838,6 @@ export interface InitOutput {
862
838
  readonly mmtfecdecoder_add_repair: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
863
839
  readonly mmtfecdecoder_add_source: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
864
840
  readonly mmtfecdecoder_cleanup_blocks_detailed: (a: number, b: number, c: number) => void;
865
- readonly mmtfecdecoder_cleanup_by_sbn: (a: number, b: number) => [number, number, number, number];
866
841
  readonly mmtfecdecoder_cleanup_by_ss_start: (a: number, b: number) => [number, number, number, number];
867
842
  readonly mmtfecdecoder_configure: (a: number, b: number, c: number) => [number, number];
868
843
  readonly mmtfecdecoder_configure_params: (a: number, b: number, c: number) => [number, number];
@@ -957,7 +932,6 @@ export interface InitOutput {
957
932
  readonly reassembledmfujs_sample_number: (a: number) => number;
958
933
  readonly reassembledmfujs_stream_identity: (a: number) => number;
959
934
  readonly reassembledmfujs_timestamp: (a: number) => number;
960
- readonly recoveredset_fec_set_index: (a: number) => number;
961
935
  readonly recoveredset_payload: (a: number) => [number, number];
962
936
  readonly recoveredset_slot: (a: number) => bigint;
963
937
  readonly shredfecbuffer_add_shred: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
@@ -974,7 +948,9 @@ export interface InitOutput {
974
948
  readonly moqfecstatsjs_blocksComplete: (a: number) => number;
975
949
  readonly moqfecstatsjs_blocksIncomplete: (a: number) => number;
976
950
  readonly moqfecstatsjs_totalSymbolsReceived: (a: number) => number;
951
+ readonly recoveredset_fec_set_index: (a: number) => number;
977
952
  readonly shredreassembler_pending_fec_sets: (a: number) => number;
953
+ readonly __wbg_get_reassemblerstatsjs_ambiguous_fallback_fragments: (a: number) => bigint;
978
954
  readonly __wbg_get_reassemblerstatsjs_duplicate_fragments: (a: number) => bigint;
979
955
  readonly __wbg_get_reassemblerstatsjs_evicted_data_units: (a: number) => bigint;
980
956
  readonly __wbg_get_reassemblerstatsjs_evicted_memory_limit: (a: number) => bigint;
@@ -986,6 +962,8 @@ export interface InitOutput {
986
962
  readonly __wbg_get_samplecombinerstatsjs_evicted_samples: (a: number) => bigint;
987
963
  readonly __wbg_get_samplecombinerstatsjs_passthrough_samples: (a: number) => bigint;
988
964
  readonly __wbg_get_samplecombinerstatsjs_timed_out_samples: (a: number) => bigint;
965
+ readonly __wbg_reassemblerstatsjs_free: (a: number, b: number) => void;
966
+ readonly __wbg_set_reassemblerstatsjs_ambiguous_fallback_fragments: (a: number, b: bigint) => void;
989
967
  readonly __wbg_set_reassemblerstatsjs_duplicate_fragments: (a: number, b: bigint) => void;
990
968
  readonly __wbg_set_reassemblerstatsjs_evicted_data_units: (a: number, b: bigint) => void;
991
969
  readonly __wbg_set_reassemblerstatsjs_evicted_memory_limit: (a: number, b: bigint) => void;