@blockcast/mmt-wasm 0.0.0-stage → 0.1.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.
@@ -0,0 +1,3018 @@
1
+ let wasm_bindgen;
2
+ (function() {
3
+ const __exports = {};
4
+ let script_src;
5
+ if (typeof document !== 'undefined' && document.currentScript !== null) {
6
+ script_src = new URL(document.currentScript.src, location.href).toString();
7
+ }
8
+ let wasm = undefined;
9
+
10
+ function addToExternrefTable0(obj) {
11
+ const idx = wasm.__externref_table_alloc();
12
+ wasm.__wbindgen_externrefs.set(idx, obj);
13
+ return idx;
14
+ }
15
+
16
+ function _assertClass(instance, klass) {
17
+ if (!(instance instanceof klass)) {
18
+ throw new Error(`expected instance of ${klass.name}`);
19
+ }
20
+ }
21
+
22
+ function debugString(val) {
23
+ // primitive types
24
+ const type = typeof val;
25
+ if (type == 'number' || type == 'boolean' || val == null) {
26
+ return `${val}`;
27
+ }
28
+ if (type == 'string') {
29
+ return `"${val}"`;
30
+ }
31
+ if (type == 'symbol') {
32
+ const description = val.description;
33
+ if (description == null) {
34
+ return 'Symbol';
35
+ } else {
36
+ return `Symbol(${description})`;
37
+ }
38
+ }
39
+ if (type == 'function') {
40
+ const name = val.name;
41
+ if (typeof name == 'string' && name.length > 0) {
42
+ return `Function(${name})`;
43
+ } else {
44
+ return 'Function';
45
+ }
46
+ }
47
+ // objects
48
+ if (Array.isArray(val)) {
49
+ const length = val.length;
50
+ let debug = '[';
51
+ if (length > 0) {
52
+ debug += debugString(val[0]);
53
+ }
54
+ for(let i = 1; i < length; i++) {
55
+ debug += ', ' + debugString(val[i]);
56
+ }
57
+ debug += ']';
58
+ return debug;
59
+ }
60
+ // Test for built-in
61
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
62
+ let className;
63
+ if (builtInMatches && builtInMatches.length > 1) {
64
+ className = builtInMatches[1];
65
+ } else {
66
+ // Failed to match the standard '[object ClassName]'
67
+ return toString.call(val);
68
+ }
69
+ if (className == 'Object') {
70
+ // we're a user defined class or Object
71
+ // JSON.stringify avoids problems with cycles, and is generally much
72
+ // easier than looping through ownProperties of `val`.
73
+ try {
74
+ return 'Object(' + JSON.stringify(val) + ')';
75
+ } catch (_) {
76
+ return 'Object';
77
+ }
78
+ }
79
+ // errors
80
+ if (val instanceof Error) {
81
+ return `${val.name}: ${val.message}\n${val.stack}`;
82
+ }
83
+ // TODO we could test for more things here, like `Set`s and `Map`s.
84
+ return className;
85
+ }
86
+
87
+ function getArrayU32FromWasm0(ptr, len) {
88
+ ptr = ptr >>> 0;
89
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
90
+ }
91
+
92
+ function getArrayU8FromWasm0(ptr, len) {
93
+ ptr = ptr >>> 0;
94
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
95
+ }
96
+
97
+ let cachedDataViewMemory0 = null;
98
+ function getDataViewMemory0() {
99
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
100
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
101
+ }
102
+ return cachedDataViewMemory0;
103
+ }
104
+
105
+ function getStringFromWasm0(ptr, len) {
106
+ ptr = ptr >>> 0;
107
+ return decodeText(ptr, len);
108
+ }
109
+
110
+ let cachedUint32ArrayMemory0 = null;
111
+ function getUint32ArrayMemory0() {
112
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
113
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
114
+ }
115
+ return cachedUint32ArrayMemory0;
116
+ }
117
+
118
+ let cachedUint8ArrayMemory0 = null;
119
+ function getUint8ArrayMemory0() {
120
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
121
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
122
+ }
123
+ return cachedUint8ArrayMemory0;
124
+ }
125
+
126
+ function handleError(f, args) {
127
+ try {
128
+ return f.apply(this, args);
129
+ } catch (e) {
130
+ const idx = addToExternrefTable0(e);
131
+ wasm.__wbindgen_exn_store(idx);
132
+ }
133
+ }
134
+
135
+ function isLikeNone(x) {
136
+ return x === undefined || x === null;
137
+ }
138
+
139
+ function passArray32ToWasm0(arg, malloc) {
140
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
141
+ getUint32ArrayMemory0().set(arg, ptr / 4);
142
+ WASM_VECTOR_LEN = arg.length;
143
+ return ptr;
144
+ }
145
+
146
+ function passArray8ToWasm0(arg, malloc) {
147
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
148
+ getUint8ArrayMemory0().set(arg, ptr / 1);
149
+ WASM_VECTOR_LEN = arg.length;
150
+ return ptr;
151
+ }
152
+
153
+ function passStringToWasm0(arg, malloc, realloc) {
154
+ if (realloc === undefined) {
155
+ const buf = cachedTextEncoder.encode(arg);
156
+ const ptr = malloc(buf.length, 1) >>> 0;
157
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
158
+ WASM_VECTOR_LEN = buf.length;
159
+ return ptr;
160
+ }
161
+
162
+ let len = arg.length;
163
+ let ptr = malloc(len, 1) >>> 0;
164
+
165
+ const mem = getUint8ArrayMemory0();
166
+
167
+ let offset = 0;
168
+
169
+ for (; offset < len; offset++) {
170
+ const code = arg.charCodeAt(offset);
171
+ if (code > 0x7F) break;
172
+ mem[ptr + offset] = code;
173
+ }
174
+ if (offset !== len) {
175
+ if (offset !== 0) {
176
+ arg = arg.slice(offset);
177
+ }
178
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
179
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
180
+ const ret = cachedTextEncoder.encodeInto(arg, view);
181
+
182
+ offset += ret.written;
183
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
184
+ }
185
+
186
+ WASM_VECTOR_LEN = offset;
187
+ return ptr;
188
+ }
189
+
190
+ function takeFromExternrefTable0(idx) {
191
+ const value = wasm.__wbindgen_externrefs.get(idx);
192
+ wasm.__externref_table_dealloc(idx);
193
+ return value;
194
+ }
195
+
196
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
197
+ cachedTextDecoder.decode();
198
+ function decodeText(ptr, len) {
199
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
200
+ }
201
+
202
+ const cachedTextEncoder = new TextEncoder();
203
+
204
+ if (!('encodeInto' in cachedTextEncoder)) {
205
+ cachedTextEncoder.encodeInto = function (arg, view) {
206
+ const buf = cachedTextEncoder.encode(arg);
207
+ view.set(buf);
208
+ return {
209
+ read: arg.length,
210
+ written: buf.length
211
+ };
212
+ }
213
+ }
214
+
215
+ let WASM_VECTOR_LEN = 0;
216
+
217
+ const CombinedSampleJsFinalization = (typeof FinalizationRegistry === 'undefined')
218
+ ? { register: () => {}, unregister: () => {} }
219
+ : new FinalizationRegistry(ptr => wasm.__wbg_combinedsamplejs_free(ptr >>> 0, 1));
220
+
221
+ const FecStatsFinalization = (typeof FinalizationRegistry === 'undefined')
222
+ ? { register: () => {}, unregister: () => {} }
223
+ : new FinalizationRegistry(ptr => wasm.__wbg_fecstats_free(ptr >>> 0, 1));
224
+
225
+ const MfuFragmentJsFinalization = (typeof FinalizationRegistry === 'undefined')
226
+ ? { register: () => {}, unregister: () => {} }
227
+ : new FinalizationRegistry(ptr => wasm.__wbg_mfufragmentjs_free(ptr >>> 0, 1));
228
+
229
+ const MmtFecDecoderFinalization = (typeof FinalizationRegistry === 'undefined')
230
+ ? { register: () => {}, unregister: () => {} }
231
+ : new FinalizationRegistry(ptr => wasm.__wbg_mmtfecdecoder_free(ptr >>> 0, 1));
232
+
233
+ const MmtFecEncoderFinalization = (typeof FinalizationRegistry === 'undefined')
234
+ ? { register: () => {}, unregister: () => {} }
235
+ : new FinalizationRegistry(ptr => wasm.__wbg_mmtfecencoder_free(ptr >>> 0, 1));
236
+
237
+ const MmtPacketizerFinalization = (typeof FinalizationRegistry === 'undefined')
238
+ ? { register: () => {}, unregister: () => {} }
239
+ : new FinalizationRegistry(ptr => wasm.__wbg_mmtpacketizer_free(ptr >>> 0, 1));
240
+
241
+ const MmtReassemblerFinalization = (typeof FinalizationRegistry === 'undefined')
242
+ ? { register: () => {}, unregister: () => {} }
243
+ : new FinalizationRegistry(ptr => wasm.__wbg_mmtreassembler_free(ptr >>> 0, 1));
244
+
245
+ const MmtSampleCombinerFinalization = (typeof FinalizationRegistry === 'undefined')
246
+ ? { register: () => {}, unregister: () => {} }
247
+ : new FinalizationRegistry(ptr => wasm.__wbg_mmtsamplecombiner_free(ptr >>> 0, 1));
248
+
249
+ const MoqEncodedBlockFinalization = (typeof FinalizationRegistry === 'undefined')
250
+ ? { register: () => {}, unregister: () => {} }
251
+ : new FinalizationRegistry(ptr => wasm.__wbg_moqencodedblock_free(ptr >>> 0, 1));
252
+
253
+ const MoqFecConfigFinalization = (typeof FinalizationRegistry === 'undefined')
254
+ ? { register: () => {}, unregister: () => {} }
255
+ : new FinalizationRegistry(ptr => wasm.__wbg_moqfecconfig_free(ptr >>> 0, 1));
256
+
257
+ const MoqFecDecoderFinalization = (typeof FinalizationRegistry === 'undefined')
258
+ ? { register: () => {}, unregister: () => {} }
259
+ : new FinalizationRegistry(ptr => wasm.__wbg_moqfecdecoder_free(ptr >>> 0, 1));
260
+
261
+ const MoqFecEncoderFinalization = (typeof FinalizationRegistry === 'undefined')
262
+ ? { register: () => {}, unregister: () => {} }
263
+ : new FinalizationRegistry(ptr => wasm.__wbg_moqfecencoder_free(ptr >>> 0, 1));
264
+
265
+ const MoqFecStatsJsFinalization = (typeof FinalizationRegistry === 'undefined')
266
+ ? { register: () => {}, unregister: () => {} }
267
+ : new FinalizationRegistry(ptr => wasm.__wbg_moqfecstatsjs_free(ptr >>> 0, 1));
268
+
269
+ const ReassembledMfuJsFinalization = (typeof FinalizationRegistry === 'undefined')
270
+ ? { register: () => {}, unregister: () => {} }
271
+ : new FinalizationRegistry(ptr => wasm.__wbg_reassembledmfujs_free(ptr >>> 0, 1));
272
+
273
+ const ReassemblerStatsJsFinalization = (typeof FinalizationRegistry === 'undefined')
274
+ ? { register: () => {}, unregister: () => {} }
275
+ : new FinalizationRegistry(ptr => wasm.__wbg_reassemblerstatsjs_free(ptr >>> 0, 1));
276
+
277
+ const RecoveredSetFinalization = (typeof FinalizationRegistry === 'undefined')
278
+ ? { register: () => {}, unregister: () => {} }
279
+ : new FinalizationRegistry(ptr => wasm.__wbg_recoveredset_free(ptr >>> 0, 1));
280
+
281
+ const SampleCombinerStatsJsFinalization = (typeof FinalizationRegistry === 'undefined')
282
+ ? { register: () => {}, unregister: () => {} }
283
+ : new FinalizationRegistry(ptr => wasm.__wbg_samplecombinerstatsjs_free(ptr >>> 0, 1));
284
+
285
+ const ShredFecBufferFinalization = (typeof FinalizationRegistry === 'undefined')
286
+ ? { register: () => {}, unregister: () => {} }
287
+ : new FinalizationRegistry(ptr => wasm.__wbg_shredfecbuffer_free(ptr >>> 0, 1));
288
+
289
+ const ShredReassemblerFinalization = (typeof FinalizationRegistry === 'undefined')
290
+ ? { register: () => {}, unregister: () => {} }
291
+ : new FinalizationRegistry(ptr => wasm.__wbg_shredreassembler_free(ptr >>> 0, 1));
292
+
293
+ /**
294
+ * A sample combined from its constituent subsample data unit(s) (moqcast
295
+ * #37), handed back to JS by [`MmtSampleCombiner::add_mfu`].
296
+ */
297
+ class CombinedSampleJs {
298
+ static __wrap(ptr) {
299
+ ptr = ptr >>> 0;
300
+ const obj = Object.create(CombinedSampleJs.prototype);
301
+ obj.__wbg_ptr = ptr;
302
+ CombinedSampleJsFinalization.register(obj, obj.__wbg_ptr, obj);
303
+ return obj;
304
+ }
305
+ __destroy_into_raw() {
306
+ const ptr = this.__wbg_ptr;
307
+ this.__wbg_ptr = 0;
308
+ CombinedSampleJsFinalization.unregister(this);
309
+ return ptr;
310
+ }
311
+ free() {
312
+ const ptr = this.__destroy_into_raw();
313
+ wasm.__wbg_combinedsamplejs_free(ptr, 0);
314
+ }
315
+ /**
316
+ * @returns {number | undefined}
317
+ */
318
+ get attribution() {
319
+ const ret = wasm.combinedsamplejs_attribution(this.__wbg_ptr);
320
+ return ret === 0xFFFFFF ? undefined : ret;
321
+ }
322
+ /**
323
+ * @returns {number}
324
+ */
325
+ get sample_number() {
326
+ const ret = wasm.combinedsamplejs_sample_number(this.__wbg_ptr);
327
+ return ret >>> 0;
328
+ }
329
+ /**
330
+ * @returns {number | undefined}
331
+ */
332
+ get stream_identity() {
333
+ const ret = wasm.combinedsamplejs_stream_identity(this.__wbg_ptr);
334
+ return ret === 0x100000001 ? undefined : ret;
335
+ }
336
+ /**
337
+ * Number of subsample data units combined (1 for a whole-sample DU or a
338
+ * non-timed passthrough).
339
+ * @returns {number}
340
+ */
341
+ get subsample_count() {
342
+ const ret = wasm.combinedsamplejs_subsample_count(this.__wbg_ptr);
343
+ return ret >>> 0;
344
+ }
345
+ /**
346
+ * @returns {number}
347
+ */
348
+ get mpu_sequence_number() {
349
+ const ret = wasm.combinedsamplejs_mpu_sequence_number(this.__wbg_ptr);
350
+ return ret >>> 0;
351
+ }
352
+ /**
353
+ * @returns {Uint32Array | undefined}
354
+ */
355
+ get packet_sequence_numbers() {
356
+ const ret = wasm.combinedsamplejs_packet_sequence_numbers(this.__wbg_ptr);
357
+ let v1;
358
+ if (ret[0] !== 0) {
359
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
360
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
361
+ }
362
+ return v1;
363
+ }
364
+ /**
365
+ * @returns {number}
366
+ */
367
+ get movie_fragment_sequence_number() {
368
+ const ret = wasm.combinedsamplejs_movie_fragment_sequence_number(this.__wbg_ptr);
369
+ return ret >>> 0;
370
+ }
371
+ /**
372
+ * @returns {Uint32Array | undefined}
373
+ */
374
+ get repaired_packet_sequence_numbers() {
375
+ const ret = wasm.combinedsamplejs_repaired_packet_sequence_numbers(this.__wbg_ptr);
376
+ let v1;
377
+ if (ret[0] !== 0) {
378
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
379
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
380
+ }
381
+ return v1;
382
+ }
383
+ /**
384
+ * Same pattern as [`ReassembledMfuJs::data`].
385
+ * @returns {Uint8Array}
386
+ */
387
+ get data() {
388
+ const ret = wasm.combinedsamplejs_data(this.__wbg_ptr);
389
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
390
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
391
+ return v1;
392
+ }
393
+ /**
394
+ * @returns {number | undefined}
395
+ */
396
+ get priority() {
397
+ const ret = wasm.combinedsamplejs_priority(this.__wbg_ptr);
398
+ return ret === 0xFFFFFF ? undefined : ret;
399
+ }
400
+ /**
401
+ * @returns {boolean}
402
+ */
403
+ get rap_flag() {
404
+ const ret = wasm.combinedsamplejs_rap_flag(this.__wbg_ptr);
405
+ return ret !== 0;
406
+ }
407
+ /**
408
+ * @returns {number}
409
+ */
410
+ get timestamp() {
411
+ const ret = wasm.combinedsamplejs_timestamp(this.__wbg_ptr);
412
+ return ret >>> 0;
413
+ }
414
+ }
415
+ if (Symbol.dispose) CombinedSampleJs.prototype[Symbol.dispose] = CombinedSampleJs.prototype.free;
416
+ __exports.CombinedSampleJs = CombinedSampleJs;
417
+
418
+ /**
419
+ * FEC statistics for monitoring
420
+ */
421
+ class FecStats {
422
+ static __wrap(ptr) {
423
+ ptr = ptr >>> 0;
424
+ const obj = Object.create(FecStats.prototype);
425
+ obj.__wbg_ptr = ptr;
426
+ FecStatsFinalization.register(obj, obj.__wbg_ptr, obj);
427
+ return obj;
428
+ }
429
+ __destroy_into_raw() {
430
+ const ptr = this.__wbg_ptr;
431
+ this.__wbg_ptr = 0;
432
+ FecStatsFinalization.unregister(this);
433
+ return ptr;
434
+ }
435
+ free() {
436
+ const ptr = this.__destroy_into_raw();
437
+ wasm.__wbg_fecstats_free(ptr, 0);
438
+ }
439
+ /**
440
+ * @returns {bigint}
441
+ */
442
+ get source_packets() {
443
+ const ret = wasm.__wbg_get_fecstats_source_packets(this.__wbg_ptr);
444
+ return BigInt.asUintN(64, ret);
445
+ }
446
+ /**
447
+ * @param {bigint} arg0
448
+ */
449
+ set source_packets(arg0) {
450
+ wasm.__wbg_set_fecstats_source_packets(this.__wbg_ptr, arg0);
451
+ }
452
+ /**
453
+ * @returns {bigint}
454
+ */
455
+ get repair_packets() {
456
+ const ret = wasm.__wbg_get_fecstats_repair_packets(this.__wbg_ptr);
457
+ return BigInt.asUintN(64, ret);
458
+ }
459
+ /**
460
+ * @param {bigint} arg0
461
+ */
462
+ set repair_packets(arg0) {
463
+ wasm.__wbg_set_fecstats_repair_packets(this.__wbg_ptr, arg0);
464
+ }
465
+ /**
466
+ * @returns {bigint}
467
+ */
468
+ get blocks_complete() {
469
+ const ret = wasm.__wbg_get_fecstats_blocks_complete(this.__wbg_ptr);
470
+ return BigInt.asUintN(64, ret);
471
+ }
472
+ /**
473
+ * @param {bigint} arg0
474
+ */
475
+ set blocks_complete(arg0) {
476
+ wasm.__wbg_set_fecstats_blocks_complete(this.__wbg_ptr, arg0);
477
+ }
478
+ /**
479
+ * @returns {bigint}
480
+ */
481
+ get blocks_recovered() {
482
+ const ret = wasm.__wbg_get_fecstats_blocks_recovered(this.__wbg_ptr);
483
+ return BigInt.asUintN(64, ret);
484
+ }
485
+ /**
486
+ * @param {bigint} arg0
487
+ */
488
+ set blocks_recovered(arg0) {
489
+ wasm.__wbg_set_fecstats_blocks_recovered(this.__wbg_ptr, arg0);
490
+ }
491
+ /**
492
+ * @returns {bigint}
493
+ */
494
+ get blocks_failed() {
495
+ const ret = wasm.__wbg_get_fecstats_blocks_failed(this.__wbg_ptr);
496
+ return BigInt.asUintN(64, ret);
497
+ }
498
+ /**
499
+ * @param {bigint} arg0
500
+ */
501
+ set blocks_failed(arg0) {
502
+ wasm.__wbg_set_fecstats_blocks_failed(this.__wbg_ptr, arg0);
503
+ }
504
+ /**
505
+ * @returns {bigint}
506
+ */
507
+ get bytes_recovered() {
508
+ const ret = wasm.__wbg_get_fecstats_bytes_recovered(this.__wbg_ptr);
509
+ return BigInt.asUintN(64, ret);
510
+ }
511
+ /**
512
+ * @param {bigint} arg0
513
+ */
514
+ set bytes_recovered(arg0) {
515
+ wasm.__wbg_set_fecstats_bytes_recovered(this.__wbg_ptr, arg0);
516
+ }
517
+ /**
518
+ * Blocks that expired with fewer than K symbols (delivery issue, not FEC issue)
519
+ * @returns {bigint}
520
+ */
521
+ get blocks_delivery_failed() {
522
+ const ret = wasm.__wbg_get_fecstats_blocks_delivery_failed(this.__wbg_ptr);
523
+ return BigInt.asUintN(64, ret);
524
+ }
525
+ /**
526
+ * Blocks that expired with fewer than K symbols (delivery issue, not FEC issue)
527
+ * @param {bigint} arg0
528
+ */
529
+ set blocks_delivery_failed(arg0) {
530
+ wasm.__wbg_set_fecstats_blocks_delivery_failed(this.__wbg_ptr, arg0);
531
+ }
532
+ /**
533
+ * Recovery rate as percentage (0-100)
534
+ * Counts all blocks: complete + recovered + FEC-failed + delivery-failed
535
+ * @returns {number}
536
+ */
537
+ recovery_rate() {
538
+ const ret = wasm.fecstats_recovery_rate(this.__wbg_ptr);
539
+ return ret;
540
+ }
541
+ constructor() {
542
+ const ret = wasm.fecstats_new();
543
+ this.__wbg_ptr = ret >>> 0;
544
+ FecStatsFinalization.register(this, this.__wbg_ptr, this);
545
+ return this;
546
+ }
547
+ }
548
+ if (Symbol.dispose) FecStats.prototype[Symbol.dispose] = FecStats.prototype.free;
549
+ __exports.FecStats = FecStats;
550
+
551
+ /**
552
+ * A timed-MFU fragment fed to [`MmtReassembler::add_fragment`].
553
+ *
554
+ * Typed (decision D-6) rather than a positional arg list or a stringly-typed
555
+ * bag object, so the Closure-ADVANCED externs stay type-checked and the wasm
556
+ * surface cannot silently drift. Built in JS from the parsed MPU/MFU header,
557
+ * then optionally annotated with the timed-MFU DU-header sample identity via
558
+ * [`with_sample_identity`](Self::with_sample_identity) before hand-off.
559
+ */
560
+ class MfuFragmentJs {
561
+ __destroy_into_raw() {
562
+ const ptr = this.__wbg_ptr;
563
+ this.__wbg_ptr = 0;
564
+ MfuFragmentJsFinalization.unregister(this);
565
+ return ptr;
566
+ }
567
+ free() {
568
+ const ptr = this.__destroy_into_raw();
569
+ wasm.__wbg_mfufragmentjs_free(ptr, 0);
570
+ }
571
+ /**
572
+ * Attach the non-timed MFU Item_ID.
573
+ * @param {number} item_id
574
+ */
575
+ set_item_id(item_id) {
576
+ wasm.mfufragmentjs_set_item_id(this.__wbg_ptr, item_id);
577
+ }
578
+ /**
579
+ * Attach timed-MFU DU priority metadata.
580
+ * @param {number} priority
581
+ */
582
+ set_priority(priority) {
583
+ wasm.mfufragmentjs_set_priority(this.__wbg_ptr, priority);
584
+ }
585
+ /**
586
+ * Attach an opaque host attribution tag that follows the accepted frame.
587
+ * @param {number} attribution
588
+ */
589
+ set_attribution(attribution) {
590
+ wasm.mfufragmentjs_set_attribution(this.__wbg_ptr, attribution);
591
+ }
592
+ /**
593
+ * Attach the authored source-header packet sequence and whether FEC
594
+ * reconstructed it. Recovered packets must retain the original u32 value.
595
+ * @param {number} packet_sequence_number
596
+ * @param {boolean} recovered
597
+ */
598
+ set_packet_delivery(packet_sequence_number, recovered) {
599
+ wasm.mfufragmentjs_set_packet_delivery(this.__wbg_ptr, packet_sequence_number, recovered);
600
+ }
601
+ /**
602
+ * Attach an opaque host stream identity used to isolate reassembly state.
603
+ * @param {number} stream_identity
604
+ */
605
+ set_stream_identity(stream_identity) {
606
+ wasm.mfufragmentjs_set_stream_identity(this.__wbg_ptr, stream_identity);
607
+ }
608
+ /**
609
+ * Attach the timed-MFU DU-header sample identity (offset mode / the IFC
610
+ * path): `movie_fragment_sequence`, `sample_number`, byte `offset`.
611
+ *
612
+ * `offset` is this DU's authored base byte position within its sample
613
+ * (moqcast #37): 0 for a whole-sample DU, nonzero for one subsample DU
614
+ * of a partitioned sample. One `SampleIdentity`, so a fragment built
615
+ * through this facade always carries movie + sample + offset together
616
+ * (the core's folded `Option<SampleIdentity>` makes the partial hybrid
617
+ * unrepresentable).
618
+ * @param {number} movie_fragment_sequence
619
+ * @param {number} sample_number
620
+ * @param {number} offset
621
+ */
622
+ with_sample_identity(movie_fragment_sequence, sample_number, offset) {
623
+ wasm.mfufragmentjs_with_sample_identity(this.__wbg_ptr, movie_fragment_sequence, sample_number, offset);
624
+ }
625
+ /**
626
+ * Build a fragment from the MPU/MFU header fields.
627
+ *
628
+ * `data` is the fragment payload AFTER the MPU/MFU (and any DU) header has
629
+ * been stripped by the caller; it is copied once across the wasm boundary
630
+ * into an owned `Bytes`. A fragmented FI=1 start must subsequently receive
631
+ * timed sample identity or a non-timed Item_ID before it is added.
632
+ * @param {number} mpu_sequence_number
633
+ * @param {number} fragmentation_indicator
634
+ * @param {number} fragment_counter
635
+ * @param {Uint8Array} data
636
+ * @param {number} timestamp
637
+ * @param {boolean} rap_flag
638
+ */
639
+ constructor(mpu_sequence_number, fragmentation_indicator, fragment_counter, data, timestamp, rap_flag) {
640
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
641
+ const len0 = WASM_VECTOR_LEN;
642
+ const ret = wasm.mfufragmentjs_new(mpu_sequence_number, fragmentation_indicator, fragment_counter, ptr0, len0, timestamp, rap_flag);
643
+ this.__wbg_ptr = ret >>> 0;
644
+ MfuFragmentJsFinalization.register(this, this.__wbg_ptr, this);
645
+ return this;
646
+ }
647
+ }
648
+ if (Symbol.dispose) MfuFragmentJs.prototype[Symbol.dispose] = MfuFragmentJs.prototype.free;
649
+ __exports.MfuFragmentJs = MfuFragmentJs;
650
+
651
+ /**
652
+ * MMT FEC Decoder with interleaving support
653
+ *
654
+ * Handles RaptorQ FEC decoding for MMT streams with interleaved blocks
655
+ * to protect against burst packet loss.
656
+ *
657
+ * Uses interior mutability (RefCell) so that wasm-bindgen exports use
658
+ * `&self` instead of `&mut self`, preventing "recursive use of an object"
659
+ * panics when source and repair tracks call methods concurrently.
660
+ */
661
+ class MmtFecDecoder {
662
+ __destroy_into_raw() {
663
+ const ptr = this.__wbg_ptr;
664
+ this.__wbg_ptr = 0;
665
+ MmtFecDecoderFinalization.unregister(this);
666
+ return ptr;
667
+ }
668
+ free() {
669
+ const ptr = this.__destroy_into_raw();
670
+ wasm.__wbg_mmtfecdecoder_free(ptr, 0);
671
+ }
672
+ /**
673
+ * Add a repair symbol per ISO 23008-1 §C.5.3.
674
+ *
675
+ * Repair carries (SS_Start, SSB_length, RS_ID).
676
+ * SS_Start = SS_ID of first source in block = SBN * K.
677
+ * SSB_length = the authored source-symbol count in this block (1..=K).
678
+ * SBN = SS_Start / configured K.
679
+ * Repair ESI = K + RS_ID.
680
+ *
681
+ * The decoder's configured K is the fixed RaptorQ geometry. A short
682
+ * authored block (`SSB_length < K`) is the producer's K-symbol RaptorQ
683
+ * block with ESIs `SSB_length..K` zero-filled and never transmitted
684
+ * (fec-raptorq `InterleavedEncoder::force_complete`). The block records
685
+ * `SSB_length`, completes once that many source symbols arrived, and
686
+ * recovers from `SSB_length` received symbols by supplying the known
687
+ * padding itself. A conflicting `SSB_length` for one block is rejected
688
+ * without changing that block.
689
+ *
690
+ * Under `iso-ssbg1-v1` the block is `[SS_Start, SS_Start + SSB_length)`
691
+ * with `1 <= SSB_length <= K` (K is only the maximum), its RaptorQ geometry
692
+ * is K' = SSB_length with no padding, and repair ESI = SSB_length + RS_ID
693
+ * (C.5.3). The first repair defines the block and claims every held source
694
+ * in range. A conflicting SSB_length, or a range overlapping a different
695
+ * known block, is refused without changing any block. Output is the K'*T
696
+ * concatenated ssbg_mode1 symbols: split by T and trim by the length field.
697
+ * @param {number} ss_start
698
+ * @param {number} ssb_length
699
+ * @param {number} rs_id
700
+ * @param {Uint8Array} data
701
+ * @param {number} timestamp
702
+ * @returns {Uint8Array | undefined}
703
+ */
704
+ add_repair(ss_start, ssb_length, rs_id, data, timestamp) {
705
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
706
+ const len0 = WASM_VECTOR_LEN;
707
+ const ret = wasm.mmtfecdecoder_add_repair(this.__wbg_ptr, ss_start, ssb_length, rs_id, ptr0, len0, timestamp);
708
+ if (ret[3]) {
709
+ throw takeFromExternrefTable0(ret[2]);
710
+ }
711
+ let v2;
712
+ if (ret[0] !== 0) {
713
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
714
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
715
+ }
716
+ return v2;
717
+ }
718
+ /**
719
+ * Add a source symbol by SS_ID per ISO 23008-1 §C.5.2.
720
+ *
721
+ * SS_ID is a flat 32-bit counter. An unconfigured decoder rejects the
722
+ * packet.
723
+ *
724
+ * - `k-padded-v1`: derives SBN = floor(SS_ID / K), ESI = SS_ID % K and
725
+ * zero-pads `data` to T.
726
+ * - `iso-ssbg1-v1`: builds the C.3.3 ssbg_mode1 symbol
727
+ * `u16be(len) || data || zero padding` (refusing `len + 2 > T`) and
728
+ * places it at ESI = serial distance from the start of the known block
729
+ * whose `[SS_Start, SS_Start + SSB_length)` contains SS_ID. A source
730
+ * whose block no repair has defined yet is held by SS_ID until one does.
731
+ *
732
+ * # Arguments
733
+ * * `ss_id` - Source symbol ID (32-bit monotonic counter)
734
+ * * `data` - The protected MMTP packet, without its Source FEC Payload ID
735
+ * * `timestamp` - Current timestamp (performance.now())
736
+ * @param {number} ss_id
737
+ * @param {Uint8Array} data
738
+ * @param {number} timestamp
739
+ * @returns {Uint8Array | undefined}
740
+ */
741
+ add_source(ss_id, data, timestamp) {
742
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
743
+ const len0 = WASM_VECTOR_LEN;
744
+ const ret = wasm.mmtfecdecoder_add_source(this.__wbg_ptr, ss_id, ptr0, len0, timestamp);
745
+ if (ret[3]) {
746
+ throw takeFromExternrefTable0(ret[2]);
747
+ }
748
+ let v2;
749
+ if (ret[0] !== 0) {
750
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
751
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
752
+ }
753
+ return v2;
754
+ }
755
+ /**
756
+ * Reset statistics
757
+ */
758
+ reset_stats() {
759
+ wasm.mmtfecdecoder_reset_stats(this.__wbg_ptr);
760
+ }
761
+ /**
762
+ * Get alignment (Al) parameter from OTI
763
+ * @returns {number}
764
+ */
765
+ get_alignment() {
766
+ const ret = wasm.mmtfecdecoder_get_alignment(this.__wbg_ptr);
767
+ if (ret[2]) {
768
+ throw takeFromExternrefTable0(ret[1]);
769
+ }
770
+ return ret[0];
771
+ }
772
+ /**
773
+ * `k-padded-v1` only: cleanup blocks more than `interleave_depth` blocks
774
+ * behind `current_sbn`. Refused under `iso-ssbg1-v1`, which has no SBN
775
+ * (use `cleanup_by_ss_start`).
776
+ *
777
+ * Blocks are ordered by RFC 1982 serial comparison of their first SS_ID
778
+ * (`sbn * K mod 2^32`, ISO/IEC 23008-1 C.5.2; BLO-35597 iso:5). For a
779
+ * stream that has not wrapped SS_ID that is exactly the old
780
+ * `sbn < current_sbn - interleave_depth`; after the wrap it still retires
781
+ * the pre-wrap blocks instead of keeping them forever.
782
+ * @param {number} current_sbn
783
+ * @returns {Uint32Array}
784
+ */
785
+ cleanup_by_sbn(current_sbn) {
786
+ const ret = wasm.mmtfecdecoder_cleanup_by_sbn(this.__wbg_ptr, current_sbn);
787
+ if (ret[3]) {
788
+ throw takeFromExternrefTable0(ret[2]);
789
+ }
790
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
791
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
792
+ return v1;
793
+ }
794
+ /**
795
+ * Get sub-blocks (N) parameter from OTI
796
+ * @returns {number}
797
+ */
798
+ get_sub_blocks() {
799
+ const ret = wasm.mmtfecdecoder_get_sub_blocks(this.__wbg_ptr);
800
+ if (ret[2]) {
801
+ throw takeFromExternrefTable0(ret[1]);
802
+ }
803
+ return ret[0];
804
+ }
805
+ /**
806
+ * Get number of pending blocks
807
+ * @returns {number}
808
+ */
809
+ pending_blocks() {
810
+ const ret = wasm.mmtfecdecoder_pending_blocks(this.__wbg_ptr);
811
+ return ret >>> 0;
812
+ }
813
+ /**
814
+ * Get symbol size (T) parameter from OTI
815
+ * @returns {number}
816
+ */
817
+ get_symbol_size() {
818
+ const ret = wasm.mmtfecdecoder_get_symbol_size(this.__wbg_ptr);
819
+ if (ret[2]) {
820
+ throw takeFromExternrefTable0(ret[1]);
821
+ }
822
+ return ret[0];
823
+ }
824
+ /**
825
+ * `iso-ssbg1-v1` only: retire the held source symbols that no repair can
826
+ * place any more, by the same rule as `cleanup_by_ss_start`, without
827
+ * retiring any block. For a caller that retires blocks itself, by their
828
+ * deadlines (`cleanup_blocks_detailed`), and needs only this half. Returns
829
+ * how many it retired.
830
+ * @param {number} current
831
+ * @returns {number}
832
+ */
833
+ retire_unplaced(current) {
834
+ const ret = wasm.mmtfecdecoder_retire_unplaced(this.__wbg_ptr, current);
835
+ if (ret[2]) {
836
+ throw takeFromExternrefTable0(ret[1]);
837
+ }
838
+ return ret[0] >>> 0;
839
+ }
840
+ /**
841
+ * Configure FEC directly from catalog parameters (K, T).
842
+ *
843
+ * Preferred over `configure()` when the player has catalog-level params
844
+ * (fecSourceSymbols, fecSymbolSize) rather than raw 12-byte OTI.
845
+ * Derives F = K * T (Z=1, N=1, Al=8) per RFC 6330.
846
+ * @param {number} k
847
+ * @param {number} symbol_size
848
+ */
849
+ configure_params(k, symbol_size) {
850
+ const ret = wasm.mmtfecdecoder_configure_params(this.__wbg_ptr, k, symbol_size);
851
+ if (ret[1]) {
852
+ throw takeFromExternrefTable0(ret[0]);
853
+ }
854
+ }
855
+ /**
856
+ * The `fec.blockProfile` token this decoder was built for.
857
+ * @returns {string}
858
+ */
859
+ get_block_profile() {
860
+ let deferred1_0;
861
+ let deferred1_1;
862
+ try {
863
+ const ret = wasm.mmtfecdecoder_get_block_profile(this.__wbg_ptr);
864
+ deferred1_0 = ret[0];
865
+ deferred1_1 = ret[1];
866
+ return getStringFromWasm0(ret[0], ret[1]);
867
+ } finally {
868
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
869
+ }
870
+ }
871
+ /**
872
+ * Get source blocks (Z) parameter from OTI
873
+ * @returns {number}
874
+ */
875
+ get_source_blocks() {
876
+ const ret = wasm.mmtfecdecoder_get_source_blocks(this.__wbg_ptr);
877
+ if (ret[2]) {
878
+ throw takeFromExternrefTable0(ret[1]);
879
+ }
880
+ return ret[0];
881
+ }
882
+ /**
883
+ * `iso-ssbg1-v1` only: retire every block, and every held source symbol,
884
+ * lying more than `interleave_depth` blocks behind SS_ID `current`, the
885
+ * newest SS_ID the caller has seen (no block start or held source follows
886
+ * it). A block start or held source that `current` has moved at least
887
+ * half the SS_ID space past no longer precedes it and is retired too
888
+ * (`iso_past_horizon`).
889
+ *
890
+ * Blocks have no SBN under ssbg_mode1, so distance is measured on the
891
+ * first SS_ID: a block starting at `s` is
892
+ * `serial_precedes(s, current) ? floor(serial_distance(s, current) / K) : 0`
893
+ * blocks behind, a lower bound because no block exceeds the configured K
894
+ * (`iso_blocks_behind_lower_bound`, shared with the TypeScript worker and
895
+ * FECManager). Returns the retired block starts.
896
+ * @param {number} current
897
+ * @returns {Uint32Array}
898
+ */
899
+ cleanup_by_ss_start(current) {
900
+ const ret = wasm.mmtfecdecoder_cleanup_by_ss_start(this.__wbg_ptr, current);
901
+ if (ret[3]) {
902
+ throw takeFromExternrefTable0(ret[2]);
903
+ }
904
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
905
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
906
+ return v1;
907
+ }
908
+ /**
909
+ * Get current interleave depth
910
+ * @returns {number}
911
+ */
912
+ get_interleave_depth() {
913
+ const ret = wasm.mmtfecdecoder_get_interleave_depth(this.__wbg_ptr);
914
+ return ret >>> 0;
915
+ }
916
+ /**
917
+ * Finalize only the source blocks whose host-owned deadlines fired.
918
+ * Keys are SBNs under `k-padded-v1` and SS_Starts under `iso-ssbg1-v1`.
919
+ *
920
+ * The JavaScript FEC manager owns per-block repair grace. A timeout for one
921
+ * block must therefore not run the decoder's global age scan and evict a
922
+ * peer block that is still waiting for fetched repair.
923
+ * @param {Uint32Array} sbns
924
+ */
925
+ cleanup_blocks_detailed(sbns) {
926
+ const ptr0 = passArray32ToWasm0(sbns, wasm.__wbindgen_malloc);
927
+ const len0 = WASM_VECTOR_LEN;
928
+ wasm.mmtfecdecoder_cleanup_blocks_detailed(this.__wbg_ptr, ptr0, len0);
929
+ }
930
+ /**
931
+ * Create a new FEC decoder
932
+ *
933
+ * # Arguments
934
+ * * `interleave_depth` - Explicit positive number of interleaved blocks.
935
+ * * `block_profile` - Catalog `fec.blockProfile`: `"k-padded-v1"` or
936
+ * `"iso-ssbg1-v1"`. Required; any other value is refused.
937
+ * @param {number} interleave_depth
938
+ * @param {string} block_profile
939
+ */
940
+ constructor(interleave_depth, block_profile) {
941
+ const ptr0 = passStringToWasm0(block_profile, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
942
+ const len0 = WASM_VECTOR_LEN;
943
+ const ret = wasm.mmtfecdecoder_new(interleave_depth, ptr0, len0);
944
+ if (ret[2]) {
945
+ throw takeFromExternrefTable0(ret[1]);
946
+ }
947
+ this.__wbg_ptr = ret[0] >>> 0;
948
+ MmtFecDecoderFinalization.register(this, this.__wbg_ptr, this);
949
+ return this;
950
+ }
951
+ /**
952
+ * Flush all pending decoder state while preserving configuration.
953
+ */
954
+ flush() {
955
+ wasm.mmtfecdecoder_flush(this.__wbg_ptr);
956
+ }
957
+ /**
958
+ * Get K (symbols per block) derived from OTI
959
+ * @returns {number}
960
+ */
961
+ get_k() {
962
+ const ret = wasm.mmtfecdecoder_get_k(this.__wbg_ptr);
963
+ if (ret[2]) {
964
+ throw takeFromExternrefTable0(ret[1]);
965
+ }
966
+ return ret[0] >>> 0;
967
+ }
968
+ /**
969
+ * Configure FEC from 12-byte OTI
970
+ *
971
+ * # Arguments
972
+ * * `oti` - 12-byte Object Transmission Information from S-TSID fecOTI
973
+ * @param {Uint8Array} oti
974
+ */
975
+ configure(oti) {
976
+ const ptr0 = passArray8ToWasm0(oti, wasm.__wbindgen_malloc);
977
+ const len0 = WASM_VECTOR_LEN;
978
+ const ret = wasm.mmtfecdecoder_configure(this.__wbg_ptr, ptr0, len0);
979
+ if (ret[1]) {
980
+ throw takeFromExternrefTable0(ret[0]);
981
+ }
982
+ }
983
+ /**
984
+ * Get current statistics
985
+ * @returns {FecStats}
986
+ */
987
+ get_stats() {
988
+ const ret = wasm.mmtfecdecoder_get_stats(this.__wbg_ptr);
989
+ return FecStats.__wrap(ret);
990
+ }
991
+ }
992
+ if (Symbol.dispose) MmtFecDecoder.prototype[Symbol.dispose] = MmtFecDecoder.prototype.free;
993
+ __exports.MmtFecDecoder = MmtFecDecoder;
994
+
995
+ /**
996
+ * RaptorQ FEC encoder for one MMT source block.
997
+ *
998
+ * This is the encode counterpart of [`MmtFecDecoder`]. It promotes the
999
+ * previously test-only RaptorQ encoder into a shipping `#[wasm_bindgen]`
1000
+ * export so browser ingress (WHIP / ROUTE) can generate repair symbols and
1001
+ * emit them in the **exact** wire framing the existing decoder + FFmpeg path
1002
+ * already agree on.
1003
+ *
1004
+ * ## Wire framing (the important part)
1005
+ *
1006
+ * Repair packets carry the ISO/IEC 23008-1 §C.5.3 Repair FEC Payload ID, NOT
1007
+ * the bare RaptorQ packet and NOT the legacy interleaved `[block_id][symbol_id]`
1008
+ * header from `fec-raptorq/c-bindings/src/interleave.rs` (that helper uses a
1009
+ * *raw* block_id and is not the on-wire format). The on-wire layout — the one
1010
+ * `packages/mmt-base/src/mmtp.ts::extractRepairFecPayloadId` parses and feeds
1011
+ * to [`MmtFecDecoder::add_repair`] — is:
1012
+ *
1013
+ * ```text
1014
+ * [SS_Start:4][RSB_length:3][RS_ID:3][SSB_length:3][repair symbol: T]
1015
+ * ```
1016
+ *
1017
+ * with, for a block with Source Block Number `sbn` and `K` source symbols:
1018
+ * - `SS_Start = sbn * K` (32-bit) — first SS_ID of the block. The decoder
1019
+ * derives `SBN = SS_Start / K`, so this MUST be `sbn * K`.
1020
+ * - `RSB_length = P` (repair count for this block)
1021
+ * - `RS_ID = i` (0-based repair index) ⇒ RaptorQ ESI = `K + i`
1022
+ * - `SSB_length <= K` (authored source symbols in this block)
1023
+ *
1024
+ * OTI (Z=1, N=1, Al=8) is delivered out-of-band via the catalog / AL-FEC
1025
+ * signaling message — see [`MmtFecEncoder::oti`] — never per-packet.
1026
+ *
1027
+ * That framing is the `k-padded-v1` profile. Under `iso-ssbg1-v1` the same
1028
+ * fields carry ISO/IEC 23008-1 C.5.3 semantics: `SS_Start` is the first SS_ID
1029
+ * of a block of consecutive SS_IDs, `SSB_length = K'` (`1..=K`), the RaptorQ
1030
+ * block is K' symbols with no padding (F = K'*T), and RS_ID `i` is ESI
1031
+ * `K' + i`.
1032
+ */
1033
+ class MmtFecEncoder {
1034
+ __destroy_into_raw() {
1035
+ const ptr = this.__wbg_ptr;
1036
+ this.__wbg_ptr = 0;
1037
+ MmtFecEncoderFinalization.unregister(this);
1038
+ return ptr;
1039
+ }
1040
+ free() {
1041
+ const ptr = this.__destroy_into_raw();
1042
+ wasm.__wbg_mmtfecencoder_free(ptr, 0);
1043
+ }
1044
+ /**
1045
+ * Symbol size (T) in bytes.
1046
+ * @returns {number}
1047
+ */
1048
+ get symbol_size() {
1049
+ const ret = wasm.mmtfecencoder_symbol_size(this.__wbg_ptr);
1050
+ return ret;
1051
+ }
1052
+ /**
1053
+ * The `fec.blockProfile` token this encoder was built for.
1054
+ * @returns {string}
1055
+ */
1056
+ get block_profile() {
1057
+ let deferred1_0;
1058
+ let deferred1_1;
1059
+ try {
1060
+ const ret = wasm.mmtfecencoder_block_profile(this.__wbg_ptr);
1061
+ deferred1_0 = ret[0];
1062
+ deferred1_1 = ret[1];
1063
+ return getStringFromWasm0(ret[0], ret[1]);
1064
+ } finally {
1065
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1066
+ }
1067
+ }
1068
+ /**
1069
+ * Encode `repair_count` repair symbols for one source block and return them
1070
+ * framed per ISO/IEC 23008-1 §C.5.3, concatenated into one flat buffer.
1071
+ *
1072
+ * Each entry is `REPAIR_FEC_PID_SIZE + symbol_size` bytes:
1073
+ * `[SS_Start:4][RSB_length:3][RS_ID:3][SSB_length:3][symbol: T]`.
1074
+ * Callers split on that stride; `entry i` is at `i * (13 + T)`.
1075
+ *
1076
+ * `k-padded-v1`: `block` is the Source Block Number and `source_block`
1077
+ * MUST be exactly `K * symbol_size` bytes — the caller pads the final
1078
+ * (short) block with zeros, mirroring `InterleavedEncoder` and the FFmpeg
1079
+ * path. `SS_Start = block * K` (wrapping), `SSB_length = K`.
1080
+ *
1081
+ * `iso-ssbg1-v1`: `block` is the SS_Start (the block's first SS_ID) and
1082
+ * `source_block` is the block's K' ssbg_mode1 symbols (`1 <= K' <= K`,
1083
+ * `len % T == 0`, each a well-formed C.3.3 symbol). RaptorQ runs over K'
1084
+ * symbols (F = K'*T) and `SSB_length = K'`.
1085
+ *
1086
+ * # Arguments
1087
+ * * `block` - SBN (`k-padded-v1`) or SS_Start (`iso-ssbg1-v1`).
1088
+ * * `source_block` - The block's source symbols, as described above.
1089
+ * * `repair_count` - Number of repair symbols (P) to generate.
1090
+ * @param {number} block
1091
+ * @param {Uint8Array} source_block
1092
+ * @param {number} repair_count
1093
+ * @returns {Uint8Array}
1094
+ */
1095
+ encode_repair(block, source_block, repair_count) {
1096
+ const ptr0 = passArray8ToWasm0(source_block, wasm.__wbindgen_malloc);
1097
+ const len0 = WASM_VECTOR_LEN;
1098
+ const ret = wasm.mmtfecencoder_encode_repair(this.__wbg_ptr, block, ptr0, len0, repair_count);
1099
+ if (ret[3]) {
1100
+ throw takeFromExternrefTable0(ret[2]);
1101
+ }
1102
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1103
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1104
+ return v2;
1105
+ }
1106
+ /**
1107
+ * Source symbols per block (K).
1108
+ * @returns {number}
1109
+ */
1110
+ get k() {
1111
+ const ret = wasm.mmtfecencoder_k(this.__wbg_ptr);
1112
+ return ret >>> 0;
1113
+ }
1114
+ /**
1115
+ * Create an encoder for a fixed `(K, symbol_size)` block geometry.
1116
+ *
1117
+ * Builds the OTI as `ObjectTransmissionInformation::new(K*T, T, 1, 1, 8)`
1118
+ * (single source block, single sub-block, byte alignment) — matching the
1119
+ * decoder's recovery model in [`FecBlock::try_decode`] — and pre-computes
1120
+ * the shared `SourceBlockEncodingPlan` so per-block encoding is cheap.
1121
+ *
1122
+ * `block_profile` is the catalog `fec.blockProfile` (`"k-padded-v1"` or
1123
+ * `"iso-ssbg1-v1"`); any other value is refused. Under `iso-ssbg1-v1`, K
1124
+ * is the maximum SSB_length.
1125
+ * @param {number} k
1126
+ * @param {number} symbol_size
1127
+ * @param {string} block_profile
1128
+ */
1129
+ constructor(k, symbol_size, block_profile) {
1130
+ const ptr0 = passStringToWasm0(block_profile, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1131
+ const len0 = WASM_VECTOR_LEN;
1132
+ const ret = wasm.mmtfecencoder_new(k, symbol_size, ptr0, len0);
1133
+ if (ret[2]) {
1134
+ throw takeFromExternrefTable0(ret[1]);
1135
+ }
1136
+ this.__wbg_ptr = ret[0] >>> 0;
1137
+ MmtFecEncoderFinalization.register(this, this.__wbg_ptr, this);
1138
+ return this;
1139
+ }
1140
+ /**
1141
+ * The configured 12-byte OTI (RFC 6330 §3.3.2 Common FEC OTI).
1142
+ *
1143
+ * Publishers (BLO-8975 / BLO-8990 catalog-gen) emit this so the player's
1144
+ * [`MmtFecDecoder::configure`] reconstructs identical block geometry. The
1145
+ * bytes round-trip exactly through `OtiParams::from_bytes`.
1146
+ * @returns {Uint8Array}
1147
+ */
1148
+ oti() {
1149
+ const ret = wasm.mmtfecencoder_oti(this.__wbg_ptr);
1150
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1151
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1152
+ return v1;
1153
+ }
1154
+ }
1155
+ if (Symbol.dispose) MmtFecEncoder.prototype[Symbol.dispose] = MmtFecEncoder.prototype.free;
1156
+ __exports.MmtFecEncoder = MmtFecEncoder;
1157
+
1158
+ /**
1159
+ * MMT MPU fragment type (ISO/IEC 23008-1 MPU fragmentation), exposed to JS as
1160
+ * a u8-backed enum. Mirrors `mmt_core::header::FragmentType`.
1161
+ * @enum {0 | 1 | 2}
1162
+ */
1163
+ const MmtFragmentType = Object.freeze({
1164
+ /**
1165
+ * Initialization segment (ftyp + moov).
1166
+ */
1167
+ Init: 0, "0": "Init",
1168
+ /**
1169
+ * Movie fragment (moof + mdat).
1170
+ */
1171
+ Fragment: 1, "1": "Fragment",
1172
+ /**
1173
+ * Media Fragment Unit (individual samples / NAL units).
1174
+ */
1175
+ Mfu: 2, "2": "Mfu",
1176
+ });
1177
+ __exports.MmtFragmentType = MmtFragmentType;
1178
+
1179
+ /**
1180
+ * MMTP packetizer — the encode counterpart to the browser's MMTP receive path.
1181
+ *
1182
+ * Thin `#[wasm_bindgen]` wrapper over `mmt_core::MmtPacketizer` so browser
1183
+ * ingress (WHIP / ROUTE — BLO-8975 / BLO-8990) and native producers use the
1184
+ * same MMTP/MPU + MFU packet framing and MTU-fragmentation implementation.
1185
+ */
1186
+ class MmtPacketizer {
1187
+ __destroy_into_raw() {
1188
+ const ptr = this.__wbg_ptr;
1189
+ this.__wbg_ptr = 0;
1190
+ MmtPacketizerFinalization.unregister(this);
1191
+ return ptr;
1192
+ }
1193
+ free() {
1194
+ const ptr = this.__destroy_into_raw();
1195
+ wasm.__wbg_mmtpacketizer_free(ptr, 0);
1196
+ }
1197
+ /**
1198
+ * Maximum MFU payload bytes per packet at this MTU (MTU minus MMTP+MPU+MFU
1199
+ * header overhead). Use this to size access-unit fragments before
1200
+ * `build_mfu`.
1201
+ * @returns {number}
1202
+ */
1203
+ get max_payload() {
1204
+ const ret = wasm.mmtpacketizer_max_payload(this.__wbg_ptr);
1205
+ return ret >>> 0;
1206
+ }
1207
+ /**
1208
+ * Configured MTU.
1209
+ * @returns {number}
1210
+ */
1211
+ get mtu() {
1212
+ const ret = wasm.mmtpacketizer_mtu(this.__wbg_ptr);
1213
+ return ret >>> 0;
1214
+ }
1215
+ /**
1216
+ * Create a packetizer for the given link MTU (bytes).
1217
+ *
1218
+ * Errors if `mtu` is too small to leave any room for the MMTP/MPU/MFU
1219
+ * header overhead (i.e. `max_payload` would be 0) — otherwise `fragment()`
1220
+ * could never make progress. Callers in the ingress arms (BLO-8975 /
1221
+ * BLO-8990) get a clear error here instead of a hung JS thread.
1222
+ * @param {number} mtu
1223
+ */
1224
+ constructor(mtu) {
1225
+ const ret = wasm.mmtpacketizer_new(mtu);
1226
+ if (ret[2]) {
1227
+ throw takeFromExternrefTable0(ret[1]);
1228
+ }
1229
+ this.__wbg_ptr = ret[0] >>> 0;
1230
+ MmtPacketizerFinalization.register(this, this.__wbg_ptr, this);
1231
+ return this;
1232
+ }
1233
+ /**
1234
+ * MTU-fragment `payload`, returning fragment boundary offsets as a flat
1235
+ * `[0, b1, b2, ..., payload.len()]` (count + 1 entries). Fragment `i` is
1236
+ * `payload[offsets[i]..offsets[i+1]]`.
1237
+ *
1238
+ * Returns offsets rather than `Vec<Vec<u8>>` so JS slices the original
1239
+ * buffer zero-copy (`payload.subarray(offsets[i], offsets[i+1])`) instead
1240
+ * of paying one copy per fragment across the wasm boundary. An empty
1241
+ * payload yields `[0]` (zero fragments).
1242
+ * @param {Uint8Array} payload
1243
+ * @returns {Uint32Array}
1244
+ */
1245
+ fragment(payload) {
1246
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc);
1247
+ const len0 = WASM_VECTOR_LEN;
1248
+ const ret = wasm.mmtpacketizer_fragment(this.__wbg_ptr, ptr0, len0);
1249
+ var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1250
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1251
+ return v2;
1252
+ }
1253
+ /**
1254
+ * Build one complete MFU packet (MMTP + MPU + MFU headers + `sample_data`)
1255
+ * and return its bytes.
1256
+ * @param {number} packet_id
1257
+ * @param {number} mpu_sequence
1258
+ * @param {number} movie_fragment_sequence
1259
+ * @param {number} sample_number
1260
+ * @param {Uint8Array} sample_data
1261
+ * @param {boolean} rap_flag
1262
+ * @returns {Uint8Array}
1263
+ */
1264
+ build_mfu(packet_id, mpu_sequence, movie_fragment_sequence, sample_number, sample_data, rap_flag) {
1265
+ const ptr0 = passArray8ToWasm0(sample_data, wasm.__wbindgen_malloc);
1266
+ const len0 = WASM_VECTOR_LEN;
1267
+ const ret = wasm.mmtpacketizer_build_mfu(this.__wbg_ptr, packet_id, mpu_sequence, movie_fragment_sequence, sample_number, ptr0, len0, rap_flag);
1268
+ if (ret[3]) {
1269
+ throw takeFromExternrefTable0(ret[2]);
1270
+ }
1271
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1272
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1273
+ return v2;
1274
+ }
1275
+ /**
1276
+ * Build one complete MPU packet (MMTP header + MPU header + `payload`) and
1277
+ * return its bytes. `fragment_type` selects Init / Fragment / Mfu framing.
1278
+ * @param {number} packet_id
1279
+ * @param {number} mpu_sequence
1280
+ * @param {MmtFragmentType} fragment_type
1281
+ * @param {Uint8Array} payload
1282
+ * @param {boolean} rap_flag
1283
+ * @returns {Uint8Array}
1284
+ */
1285
+ build_mpu(packet_id, mpu_sequence, fragment_type, payload, rap_flag) {
1286
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc);
1287
+ const len0 = WASM_VECTOR_LEN;
1288
+ const ret = wasm.mmtpacketizer_build_mpu(this.__wbg_ptr, packet_id, mpu_sequence, fragment_type, ptr0, len0, rap_flag);
1289
+ if (ret[3]) {
1290
+ throw takeFromExternrefTable0(ret[2]);
1291
+ }
1292
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1293
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1294
+ return v2;
1295
+ }
1296
+ }
1297
+ if (Symbol.dispose) MmtPacketizer.prototype[Symbol.dispose] = MmtPacketizer.prototype.free;
1298
+ __exports.MmtPacketizer = MmtPacketizer;
1299
+
1300
+ /**
1301
+ * MMT timed-MFU reassembler — a `#[wasm_bindgen]` facade over the generic IFC
1302
+ * engine.
1303
+ *
1304
+ * Interior mutability (`RefCell`) so the exports take `&self` — required because
1305
+ * the engine's `add_fragment` / `cleanup_timeouts` / `flush` are `&mut self`.
1306
+ * Unlike [`MmtFecDecoder`] (two concurrent tracks → `try_borrow_mut` to skip a
1307
+ * re-entrant overlap), the reassembler has a single sequential caller (the MMTP
1308
+ * parse loop), so `borrow_mut` is used directly: a re-entrant call is a genuine
1309
+ * bug and should panic loudly rather than silently drop a fragment
1310
+ * (error-on-bad-state, no silent fallback).
1311
+ */
1312
+ class MmtReassembler {
1313
+ static __wrap(ptr) {
1314
+ ptr = ptr >>> 0;
1315
+ const obj = Object.create(MmtReassembler.prototype);
1316
+ obj.__wbg_ptr = ptr;
1317
+ MmtReassemblerFinalization.register(obj, obj.__wbg_ptr, obj);
1318
+ return obj;
1319
+ }
1320
+ __destroy_into_raw() {
1321
+ const ptr = this.__wbg_ptr;
1322
+ this.__wbg_ptr = 0;
1323
+ MmtReassemblerFinalization.unregister(this);
1324
+ return ptr;
1325
+ }
1326
+ free() {
1327
+ const ptr = this.__destroy_into_raw();
1328
+ wasm.__wbg_mmtreassembler_free(ptr, 0);
1329
+ }
1330
+ /**
1331
+ * Create a CLOCK-FREE reassembler — no timeout, with generic buffers and
1332
+ * authored active and continuation-only run state bounded by `max_buffered`. For hosts with no
1333
+ * monotonic clock that never call [`cleanup_timeouts`](Self::cleanup_timeouts),
1334
+ * there is no `timeout_ms` to supply, so none is invented. `max_buffered` is
1335
+ * REQUIRED, derived from the catalog (rejects `0`).
1336
+ *
1337
+ * Exposed to JS as the static `MmtReassembler.clock_free(max_buffered)`.
1338
+ * @param {number} max_buffered
1339
+ * @returns {MmtReassembler}
1340
+ */
1341
+ static clock_free(max_buffered) {
1342
+ const ret = wasm.mmtreassembler_clock_free(max_buffered);
1343
+ if (ret[2]) {
1344
+ throw takeFromExternrefTable0(ret[1]);
1345
+ }
1346
+ return MmtReassembler.__wrap(ret[0]);
1347
+ }
1348
+ /**
1349
+ * Switch to a catalog/in-band-derived numeric deadline without dropping
1350
+ * in-flight MFUs.
1351
+ * @param {number} timeout_ms
1352
+ */
1353
+ set_timeout(timeout_ms) {
1354
+ const ret = wasm.mmtreassembler_set_timeout(this.__wbg_ptr, timeout_ms);
1355
+ if (ret[1]) {
1356
+ throw takeFromExternrefTable0(ret[0]);
1357
+ }
1358
+ }
1359
+ /**
1360
+ * Add a fragment. A valid incomplete data unit returns `null`; a completed
1361
+ * one returns its MFU. Malformed or conflicting authored state throws a JS
1362
+ * `Error` whose stable `code` property is the core rejection code.
1363
+ *
1364
+ * `now` is `performance.now()` (ms), floored to the engine clock (D-1).
1365
+ * Consumes `fragment`.
1366
+ * @param {number} now
1367
+ * @param {MfuFragmentJs} fragment
1368
+ * @returns {ReassembledMfuJs | undefined}
1369
+ */
1370
+ add_fragment(now, fragment) {
1371
+ _assertClass(fragment, MfuFragmentJs);
1372
+ var ptr0 = fragment.__destroy_into_raw();
1373
+ const ret = wasm.mmtreassembler_add_fragment(this.__wbg_ptr, now, ptr0);
1374
+ if (ret[2]) {
1375
+ throw takeFromExternrefTable0(ret[1]);
1376
+ }
1377
+ return ret[0] === 0 ? undefined : ReassembledMfuJs.__wrap(ret[0]);
1378
+ }
1379
+ /**
1380
+ * Drop one stream's buffered and dedup state without disturbing other
1381
+ * tracks sharing this reassembler instance.
1382
+ * @param {number} stream_identity
1383
+ */
1384
+ reset_stream(stream_identity) {
1385
+ wasm.mmtreassembler_reset_stream(this.__wbg_ptr, stream_identity);
1386
+ }
1387
+ /**
1388
+ * Number of incomplete objects currently buffered.
1389
+ * @returns {number}
1390
+ */
1391
+ get buffered_count() {
1392
+ const ret = wasm.mmtreassembler_buffered_count(this.__wbg_ptr);
1393
+ return ret >>> 0;
1394
+ }
1395
+ /**
1396
+ * Switch to reliable-MoQ clock-free operation without dropping in-flight MFUs.
1397
+ */
1398
+ set_clock_free() {
1399
+ wasm.mmtreassembler_set_clock_free(this.__wbg_ptr);
1400
+ }
1401
+ /**
1402
+ * Earliest absolute `performance.now()` millisecond tick requiring cleanup.
1403
+ * @returns {number | undefined}
1404
+ */
1405
+ next_timeout_at() {
1406
+ const ret = wasm.mmtreassembler_next_timeout_at(this.__wbg_ptr);
1407
+ return ret[0] === 0 ? undefined : ret[1];
1408
+ }
1409
+ /**
1410
+ * Expire incomplete objects past the timeout and enforce the memory limit.
1411
+ * The host drives this — see the constructor note.
1412
+ * @param {number} now
1413
+ */
1414
+ cleanup_timeouts(now) {
1415
+ wasm.mmtreassembler_cleanup_timeouts(this.__wbg_ptr, now);
1416
+ }
1417
+ /**
1418
+ * Fragments retained across all incomplete objects.
1419
+ * @returns {number}
1420
+ */
1421
+ get pending_fragment_count() {
1422
+ const ret = wasm.mmtreassembler_pending_fragment_count(this.__wbg_ptr);
1423
+ return ret >>> 0;
1424
+ }
1425
+ /**
1426
+ * Create a reassembler. Both args are REQUIRED — no defaults.
1427
+ *
1428
+ * The caller derives them from the catalog (timeout from the FEC interleave
1429
+ * span; `max_buffered` from the count of concurrent in-flight samples),
1430
+ * never a literal. The constructor rejects `0` for either: the engine's own
1431
+ * `new` currently accepts `0` and then silently breaks reassembly
1432
+ * (`max_buffered = 0` evicts every buffer on each `cleanup_timeouts`), so the
1433
+ * facade refuses it at the boundary.
1434
+ *
1435
+ * * `timeout_ms` — incomplete-MFU timeout in ms (> 0).
1436
+ * * `max_buffered` — max concurrent incomplete objects (> 0).
1437
+ *
1438
+ * `max_buffered` is enforced eagerly on every `add_fragment`; active and
1439
+ * continuation-only producer runs share the bound, and a distinct new run
1440
+ * throws `active-data-unit-limit` at capacity.
1441
+ * `timeout_ms` adds time-based expiry of permanently-incomplete (tail-lost)
1442
+ * MFUs, which the host activates by driving
1443
+ * [`cleanup_timeouts`](Self::cleanup_timeouts) periodically. A host with no
1444
+ * clock should use [`clock_free`](Self::clock_free).
1445
+ * @param {number} timeout_ms
1446
+ * @param {number} max_buffered
1447
+ */
1448
+ constructor(timeout_ms, max_buffered) {
1449
+ const ret = wasm.mmtreassembler_new(timeout_ms, max_buffered);
1450
+ if (ret[2]) {
1451
+ throw takeFromExternrefTable0(ret[1]);
1452
+ }
1453
+ this.__wbg_ptr = ret[0] >>> 0;
1454
+ MmtReassemblerFinalization.register(this, this.__wbg_ptr, this);
1455
+ return this;
1456
+ }
1457
+ /**
1458
+ * Drop all buffered fragments and dedup state (call on stream end / seek).
1459
+ */
1460
+ flush() {
1461
+ wasm.mmtreassembler_flush(this.__wbg_ptr);
1462
+ }
1463
+ /**
1464
+ * Flush buffered state and zero statistics.
1465
+ */
1466
+ reset() {
1467
+ wasm.mmtreassembler_reset(this.__wbg_ptr);
1468
+ }
1469
+ /**
1470
+ * Statistics snapshot.
1471
+ * @returns {ReassemblerStatsJs}
1472
+ */
1473
+ stats() {
1474
+ const ret = wasm.mmtreassembler_stats(this.__wbg_ptr);
1475
+ return ReassemblerStatsJs.__wrap(ret);
1476
+ }
1477
+ }
1478
+ if (Symbol.dispose) MmtReassembler.prototype[Symbol.dispose] = MmtReassembler.prototype.free;
1479
+ __exports.MmtReassembler = MmtReassembler;
1480
+
1481
+ /**
1482
+ * Combines subsample data units of one sample (moqcast #37) into a
1483
+ * contiguous whole — a `#[wasm_bindgen]` facade over
1484
+ * [`mmt_core::reassembler::SampleCombiner`]. Each constituent data unit is
1485
+ * first reassembled independently by [`MmtReassembler`]; feed its output
1486
+ * here to combine subsample-partitioned samples back into one elementary
1487
+ * stream sample.
1488
+ *
1489
+ * Interior mutability (`RefCell`) so the exports take `&self`, mirroring
1490
+ * [`MmtReassembler`]. The host supplies `now` (`performance.now()` ms) for
1491
+ * timeout bookkeeping, matching the reassembler's clock-injected shape --
1492
+ * this module adds no independent timer tier.
1493
+ */
1494
+ class MmtSampleCombiner {
1495
+ __destroy_into_raw() {
1496
+ const ptr = this.__wbg_ptr;
1497
+ this.__wbg_ptr = 0;
1498
+ MmtSampleCombinerFinalization.unregister(this);
1499
+ return ptr;
1500
+ }
1501
+ free() {
1502
+ const ptr = this.__destroy_into_raw();
1503
+ wasm.__wbg_mmtsamplecombiner_free(ptr, 0);
1504
+ }
1505
+ /**
1506
+ * Drop one stream's buffered and registered-size state without
1507
+ * disturbing other streams sharing this combiner instance.
1508
+ * @param {number} stream_identity
1509
+ */
1510
+ reset_stream(stream_identity) {
1511
+ wasm.mmtsamplecombiner_reset_stream(this.__wbg_ptr, stream_identity);
1512
+ }
1513
+ /**
1514
+ * Number of incomplete samples currently buffered.
1515
+ * @returns {number}
1516
+ */
1517
+ get pending_count() {
1518
+ const ret = wasm.mmtsamplecombiner_pending_count(this.__wbg_ptr);
1519
+ return ret >>> 0;
1520
+ }
1521
+ /**
1522
+ * Discard samples whose oldest held segment has waited past
1523
+ * `timeout_ms`. The host drives this, mirroring
1524
+ * [`MmtReassembler::cleanup_timeouts`].
1525
+ * @param {number} now
1526
+ * @param {number} timeout_ms
1527
+ */
1528
+ cleanup_timeouts(now, timeout_ms) {
1529
+ wasm.mmtsamplecombiner_cleanup_timeouts(this.__wbg_ptr, now, timeout_ms);
1530
+ }
1531
+ /**
1532
+ * Register the authored sample size from the host's own FT=1
1533
+ * (movie-fragment-metadata) parse. `stream_identity` is `None` for a
1534
+ * single-stream host.
1535
+ * @param {number | null | undefined} stream_identity
1536
+ * @param {number} mpu_sequence_number
1537
+ * @param {number} movie_fragment_sequence_number
1538
+ * @param {number} sample_number
1539
+ * @param {number} size
1540
+ * @returns {CombinedSampleJs | undefined}
1541
+ */
1542
+ register_authored_size(stream_identity, mpu_sequence_number, movie_fragment_sequence_number, sample_number, size) {
1543
+ const ret = wasm.mmtsamplecombiner_register_authored_size(this.__wbg_ptr, isLikeNone(stream_identity) ? 0x100000001 : (stream_identity) >>> 0, mpu_sequence_number, movie_fragment_sequence_number, sample_number, size);
1544
+ return ret === 0 ? undefined : CombinedSampleJs.__wrap(ret);
1545
+ }
1546
+ /**
1547
+ * * `max_buffered` — max concurrent incomplete samples (> 0), derived from
1548
+ * the catalog (e.g. concurrent in-flight samples across tracks). A full
1549
+ * table evicts its oldest sample by insertion order, so one lost
1550
+ * subsample data unit cannot wedge every later sample.
1551
+ * * `require_authored_size` — when true, an offset-zero data unit with no
1552
+ * registered authored size waits for one instead of passing through as
1553
+ * a whole sample. Pass true when the host always drives FT=1 into
1554
+ * `register_authored_size`; false keeps the pre-moqcast-#37
1555
+ * immediate-passthrough shape.
1556
+ * * `max_segments_per_sample` — max subsample data units held for one
1557
+ * sample at once (> 0).
1558
+ * @param {number} max_buffered
1559
+ * @param {boolean} require_authored_size
1560
+ * @param {number} max_segments_per_sample
1561
+ */
1562
+ constructor(max_buffered, require_authored_size, max_segments_per_sample) {
1563
+ const ret = wasm.mmtsamplecombiner_new(max_buffered, require_authored_size, max_segments_per_sample);
1564
+ if (ret[2]) {
1565
+ throw takeFromExternrefTable0(ret[1]);
1566
+ }
1567
+ this.__wbg_ptr = ret[0] >>> 0;
1568
+ MmtSampleCombinerFinalization.register(this, this.__wbg_ptr, this);
1569
+ return this;
1570
+ }
1571
+ /**
1572
+ * Drop all buffered subsample state (call on stream end / seek).
1573
+ */
1574
+ flush() {
1575
+ wasm.mmtsamplecombiner_flush(this.__wbg_ptr);
1576
+ }
1577
+ /**
1578
+ * Statistics snapshot.
1579
+ * @returns {SampleCombinerStatsJs}
1580
+ */
1581
+ stats() {
1582
+ const ret = wasm.mmtsamplecombiner_stats(this.__wbg_ptr);
1583
+ return SampleCombinerStatsJs.__wrap(ret);
1584
+ }
1585
+ /**
1586
+ * Add one reassembled data unit (from [`MmtReassembler::add_fragment`]).
1587
+ * Returns the combined sample once every constituent data unit has
1588
+ * arrived and totals the authored size. `now` is `performance.now()`
1589
+ * (ms), floored to the engine clock (D-1). Consumes `mfu`.
1590
+ * @param {number} now
1591
+ * @param {ReassembledMfuJs} mfu
1592
+ * @returns {CombinedSampleJs | undefined}
1593
+ */
1594
+ add_mfu(now, mfu) {
1595
+ _assertClass(mfu, ReassembledMfuJs);
1596
+ var ptr0 = mfu.__destroy_into_raw();
1597
+ const ret = wasm.mmtsamplecombiner_add_mfu(this.__wbg_ptr, now, ptr0);
1598
+ if (ret[2]) {
1599
+ throw takeFromExternrefTable0(ret[1]);
1600
+ }
1601
+ return ret[0] === 0 ? undefined : CombinedSampleJs.__wrap(ret[0]);
1602
+ }
1603
+ }
1604
+ if (Symbol.dispose) MmtSampleCombiner.prototype[Symbol.dispose] = MmtSampleCombiner.prototype.free;
1605
+ __exports.MmtSampleCombiner = MmtSampleCombiner;
1606
+
1607
+ /**
1608
+ * One encoded MoQ block and its immutable source/repair symbol fixtures.
1609
+ */
1610
+ class MoqEncodedBlock {
1611
+ static __wrap(ptr) {
1612
+ ptr = ptr >>> 0;
1613
+ const obj = Object.create(MoqEncodedBlock.prototype);
1614
+ obj.__wbg_ptr = ptr;
1615
+ MoqEncodedBlockFinalization.register(obj, obj.__wbg_ptr, obj);
1616
+ return obj;
1617
+ }
1618
+ __destroy_into_raw() {
1619
+ const ptr = this.__wbg_ptr;
1620
+ this.__wbg_ptr = 0;
1621
+ MoqEncodedBlockFinalization.unregister(this);
1622
+ return ptr;
1623
+ }
1624
+ free() {
1625
+ const ptr = this.__destroy_into_raw();
1626
+ wasm.__wbg_moqencodedblock_free(ptr, 0);
1627
+ }
1628
+ /**
1629
+ * @returns {number}
1630
+ */
1631
+ get original_len() {
1632
+ const ret = wasm.moqencodedblock_original_len(this.__wbg_ptr);
1633
+ return ret >>> 0;
1634
+ }
1635
+ /**
1636
+ * @param {number} index
1637
+ * @returns {Uint8Array | undefined}
1638
+ */
1639
+ getRepairSymbol(index) {
1640
+ const ret = wasm.moqencodedblock_getRepairSymbol(this.__wbg_ptr, index);
1641
+ let v1;
1642
+ if (ret[0] !== 0) {
1643
+ v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1644
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1645
+ }
1646
+ return v1;
1647
+ }
1648
+ /**
1649
+ * @param {number} index
1650
+ * @returns {Uint8Array | undefined}
1651
+ */
1652
+ getSourceSymbol(index) {
1653
+ const ret = wasm.moqencodedblock_getSourceSymbol(this.__wbg_ptr, index);
1654
+ let v1;
1655
+ if (ret[0] !== 0) {
1656
+ v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1657
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1658
+ }
1659
+ return v1;
1660
+ }
1661
+ /**
1662
+ * @returns {number}
1663
+ */
1664
+ repairSymbolCount() {
1665
+ const ret = wasm.moqencodedblock_repairSymbolCount(this.__wbg_ptr);
1666
+ return ret >>> 0;
1667
+ }
1668
+ /**
1669
+ * @returns {number}
1670
+ */
1671
+ sourceSymbolCount() {
1672
+ const ret = wasm.moqencodedblock_sourceSymbolCount(this.__wbg_ptr);
1673
+ return ret >>> 0;
1674
+ }
1675
+ /**
1676
+ * @returns {number}
1677
+ */
1678
+ get k() {
1679
+ const ret = wasm.moqencodedblock_k(this.__wbg_ptr);
1680
+ return ret >>> 0;
1681
+ }
1682
+ /**
1683
+ * @returns {number}
1684
+ */
1685
+ get p() {
1686
+ const ret = wasm.combinedsamplejs_mpu_sequence_number(this.__wbg_ptr);
1687
+ return ret >>> 0;
1688
+ }
1689
+ /**
1690
+ * @returns {Uint8Array}
1691
+ */
1692
+ getOti() {
1693
+ const ret = wasm.moqencodedblock_getOti(this.__wbg_ptr);
1694
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1695
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1696
+ return v1;
1697
+ }
1698
+ /**
1699
+ * @returns {number}
1700
+ */
1701
+ get block_id() {
1702
+ const ret = wasm.moqencodedblock_block_id(this.__wbg_ptr);
1703
+ return ret >>> 0;
1704
+ }
1705
+ }
1706
+ if (Symbol.dispose) MoqEncodedBlock.prototype[Symbol.dispose] = MoqEncodedBlock.prototype.free;
1707
+ __exports.MoqEncodedBlock = MoqEncodedBlock;
1708
+
1709
+ /**
1710
+ * Versioned MoQ FEC configuration exposed to browser consumers.
1711
+ */
1712
+ class MoqFecConfig {
1713
+ __destroy_into_raw() {
1714
+ const ptr = this.__wbg_ptr;
1715
+ this.__wbg_ptr = 0;
1716
+ MoqFecConfigFinalization.unregister(this);
1717
+ return ptr;
1718
+ }
1719
+ free() {
1720
+ const ptr = this.__destroy_into_raw();
1721
+ wasm.__wbg_moqfecconfig_free(ptr, 0);
1722
+ }
1723
+ /**
1724
+ * @returns {number}
1725
+ */
1726
+ get symbol_size() {
1727
+ const ret = wasm.moqfecconfig_symbol_size(this.__wbg_ptr);
1728
+ return ret;
1729
+ }
1730
+ /**
1731
+ * @returns {number}
1732
+ */
1733
+ maxBlockSize() {
1734
+ const ret = wasm.moqfecconfig_maxBlockSize(this.__wbg_ptr);
1735
+ return ret >>> 0;
1736
+ }
1737
+ /**
1738
+ * @returns {number}
1739
+ */
1740
+ overheadRatio() {
1741
+ const ret = wasm.moqfecconfig_overheadRatio(this.__wbg_ptr);
1742
+ return ret;
1743
+ }
1744
+ /**
1745
+ * @returns {number}
1746
+ */
1747
+ get interleaveDepth() {
1748
+ const ret = wasm.moqfecconfig_interleaveDepth(this.__wbg_ptr);
1749
+ return ret >>> 0;
1750
+ }
1751
+ /**
1752
+ * @returns {number}
1753
+ */
1754
+ get k() {
1755
+ const ret = wasm.moqfecconfig_k(this.__wbg_ptr);
1756
+ return ret >>> 0;
1757
+ }
1758
+ /**
1759
+ * @returns {number}
1760
+ */
1761
+ get p() {
1762
+ const ret = wasm.moqfecconfig_p(this.__wbg_ptr);
1763
+ return ret >>> 0;
1764
+ }
1765
+ /**
1766
+ * @param {number} symbol_size
1767
+ * @param {number} k
1768
+ * @param {number} p
1769
+ * @param {number} interleave_depth
1770
+ */
1771
+ constructor(symbol_size, k, p, interleave_depth) {
1772
+ const ret = wasm.moqfecconfig_new(symbol_size, k, p, interleave_depth);
1773
+ if (ret[2]) {
1774
+ throw takeFromExternrefTable0(ret[1]);
1775
+ }
1776
+ this.__wbg_ptr = ret[0] >>> 0;
1777
+ MoqFecConfigFinalization.register(this, this.__wbg_ptr, this);
1778
+ return this;
1779
+ }
1780
+ }
1781
+ if (Symbol.dispose) MoqFecConfig.prototype[Symbol.dispose] = MoqFecConfig.prototype.free;
1782
+ __exports.MoqFecConfig = MoqFecConfig;
1783
+
1784
+ /**
1785
+ * Versioned browser-side MoQ FEC decoder.
1786
+ */
1787
+ class MoqFecDecoder {
1788
+ __destroy_into_raw() {
1789
+ const ptr = this.__wbg_ptr;
1790
+ this.__wbg_ptr = 0;
1791
+ MoqFecDecoderFinalization.unregister(this);
1792
+ return ptr;
1793
+ }
1794
+ free() {
1795
+ const ptr = this.__destroy_into_raw();
1796
+ wasm.__wbg_moqfecdecoder_free(ptr, 0);
1797
+ }
1798
+ /**
1799
+ * @param {number} block_id
1800
+ */
1801
+ resetBlock(block_id) {
1802
+ const ret = wasm.moqfecdecoder_resetBlock(this.__wbg_ptr, block_id);
1803
+ if (ret[1]) {
1804
+ throw takeFromExternrefTable0(ret[0]);
1805
+ }
1806
+ }
1807
+ /**
1808
+ * @param {number} block_id
1809
+ * @returns {Uint8Array}
1810
+ */
1811
+ getBlockData(block_id) {
1812
+ const ret = wasm.moqfecdecoder_getBlockData(this.__wbg_ptr, block_id);
1813
+ if (ret[3]) {
1814
+ throw takeFromExternrefTable0(ret[2]);
1815
+ }
1816
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1817
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1818
+ return v1;
1819
+ }
1820
+ /**
1821
+ * @param {number} block_id
1822
+ * @param {number} esi
1823
+ * @param {Uint8Array} symbol
1824
+ * @returns {Uint8Array | undefined}
1825
+ */
1826
+ addRepairSymbol(block_id, esi, symbol) {
1827
+ const ptr0 = passArray8ToWasm0(symbol, wasm.__wbindgen_malloc);
1828
+ const len0 = WASM_VECTOR_LEN;
1829
+ const ret = wasm.moqfecdecoder_addRepairSymbol(this.__wbg_ptr, block_id, esi, ptr0, len0);
1830
+ if (ret[3]) {
1831
+ throw takeFromExternrefTable0(ret[2]);
1832
+ }
1833
+ let v2;
1834
+ if (ret[0] !== 0) {
1835
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1836
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1837
+ }
1838
+ return v2;
1839
+ }
1840
+ /**
1841
+ * @param {number} block_id
1842
+ * @param {number} esi
1843
+ * @param {Uint8Array} symbol
1844
+ * @param {number | null} [original_len]
1845
+ * @returns {Uint8Array | undefined}
1846
+ */
1847
+ addSourceSymbol(block_id, esi, symbol, original_len) {
1848
+ const ptr0 = passArray8ToWasm0(symbol, wasm.__wbindgen_malloc);
1849
+ const len0 = WASM_VECTOR_LEN;
1850
+ const ret = wasm.moqfecdecoder_addSourceSymbol(this.__wbg_ptr, block_id, esi, ptr0, len0, isLikeNone(original_len) ? 0x100000001 : (original_len) >>> 0);
1851
+ if (ret[3]) {
1852
+ throw takeFromExternrefTable0(ret[2]);
1853
+ }
1854
+ let v2;
1855
+ if (ret[0] !== 0) {
1856
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1857
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1858
+ }
1859
+ return v2;
1860
+ }
1861
+ /**
1862
+ * @param {number} block_id
1863
+ * @returns {boolean}
1864
+ */
1865
+ isBlockComplete(block_id) {
1866
+ const ret = wasm.moqfecdecoder_isBlockComplete(this.__wbg_ptr, block_id);
1867
+ return ret !== 0;
1868
+ }
1869
+ /**
1870
+ * @param {MoqFecConfig} config
1871
+ * @param {Uint8Array} oti
1872
+ */
1873
+ constructor(config, oti) {
1874
+ _assertClass(config, MoqFecConfig);
1875
+ const ptr0 = passArray8ToWasm0(oti, wasm.__wbindgen_malloc);
1876
+ const len0 = WASM_VECTOR_LEN;
1877
+ const ret = wasm.moqfecdecoder_new(config.__wbg_ptr, ptr0, len0);
1878
+ if (ret[2]) {
1879
+ throw takeFromExternrefTable0(ret[1]);
1880
+ }
1881
+ this.__wbg_ptr = ret[0] >>> 0;
1882
+ MoqFecDecoderFinalization.register(this, this.__wbg_ptr, this);
1883
+ return this;
1884
+ }
1885
+ /**
1886
+ * @returns {MoqFecStatsJs}
1887
+ */
1888
+ getStats() {
1889
+ const ret = wasm.moqfecdecoder_getStats(this.__wbg_ptr);
1890
+ return MoqFecStatsJs.__wrap(ret);
1891
+ }
1892
+ }
1893
+ if (Symbol.dispose) MoqFecDecoder.prototype[Symbol.dispose] = MoqFecDecoder.prototype.free;
1894
+ __exports.MoqFecDecoder = MoqFecDecoder;
1895
+
1896
+ /**
1897
+ * Versioned browser-side MoQ FEC encoder.
1898
+ */
1899
+ class MoqFecEncoder {
1900
+ __destroy_into_raw() {
1901
+ const ptr = this.__wbg_ptr;
1902
+ this.__wbg_ptr = 0;
1903
+ MoqFecEncoderFinalization.unregister(this);
1904
+ return ptr;
1905
+ }
1906
+ free() {
1907
+ const ptr = this.__destroy_into_raw();
1908
+ wasm.__wbg_moqfecencoder_free(ptr, 0);
1909
+ }
1910
+ /**
1911
+ * @returns {number}
1912
+ */
1913
+ blockCount() {
1914
+ const ret = wasm.moqfecencoder_blockCount(this.__wbg_ptr);
1915
+ return ret >>> 0;
1916
+ }
1917
+ /**
1918
+ * @param {Uint8Array} data
1919
+ * @returns {MoqEncodedBlock}
1920
+ */
1921
+ encodeBlock(data) {
1922
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
1923
+ const len0 = WASM_VECTOR_LEN;
1924
+ const ret = wasm.moqfecencoder_encodeBlock(this.__wbg_ptr, ptr0, len0);
1925
+ if (ret[2]) {
1926
+ throw takeFromExternrefTable0(ret[1]);
1927
+ }
1928
+ return MoqEncodedBlock.__wrap(ret[0]);
1929
+ }
1930
+ /**
1931
+ * @param {MoqFecConfig} config
1932
+ */
1933
+ constructor(config) {
1934
+ _assertClass(config, MoqFecConfig);
1935
+ const ret = wasm.moqfecencoder_new(config.__wbg_ptr);
1936
+ if (ret[2]) {
1937
+ throw takeFromExternrefTable0(ret[1]);
1938
+ }
1939
+ this.__wbg_ptr = ret[0] >>> 0;
1940
+ MoqFecEncoderFinalization.register(this, this.__wbg_ptr, this);
1941
+ return this;
1942
+ }
1943
+ /**
1944
+ * @returns {Uint8Array}
1945
+ */
1946
+ getOti() {
1947
+ const ret = wasm.moqfecencoder_getOti(this.__wbg_ptr);
1948
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1949
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1950
+ return v1;
1951
+ }
1952
+ }
1953
+ if (Symbol.dispose) MoqFecEncoder.prototype[Symbol.dispose] = MoqFecEncoder.prototype.free;
1954
+ __exports.MoqFecEncoder = MoqFecEncoder;
1955
+
1956
+ /**
1957
+ * Snapshot of MoQ FEC decoder counters.
1958
+ */
1959
+ class MoqFecStatsJs {
1960
+ static __wrap(ptr) {
1961
+ ptr = ptr >>> 0;
1962
+ const obj = Object.create(MoqFecStatsJs.prototype);
1963
+ obj.__wbg_ptr = ptr;
1964
+ MoqFecStatsJsFinalization.register(obj, obj.__wbg_ptr, obj);
1965
+ return obj;
1966
+ }
1967
+ __destroy_into_raw() {
1968
+ const ptr = this.__wbg_ptr;
1969
+ this.__wbg_ptr = 0;
1970
+ MoqFecStatsJsFinalization.unregister(this);
1971
+ return ptr;
1972
+ }
1973
+ free() {
1974
+ const ptr = this.__destroy_into_raw();
1975
+ wasm.__wbg_moqfecstatsjs_free(ptr, 0);
1976
+ }
1977
+ /**
1978
+ * @returns {number}
1979
+ */
1980
+ recoveryRate() {
1981
+ const ret = wasm.moqfecstatsjs_recoveryRate(this.__wbg_ptr);
1982
+ return ret;
1983
+ }
1984
+ /**
1985
+ * @returns {number}
1986
+ */
1987
+ get blocksComplete() {
1988
+ const ret = wasm.moqfecconfig_k(this.__wbg_ptr);
1989
+ return ret >>> 0;
1990
+ }
1991
+ /**
1992
+ * @returns {number}
1993
+ */
1994
+ get interleaveDepth() {
1995
+ const ret = wasm.moqfecstatsjs_interleaveDepth(this.__wbg_ptr);
1996
+ return ret >>> 0;
1997
+ }
1998
+ /**
1999
+ * @returns {number}
2000
+ */
2001
+ get blocksIncomplete() {
2002
+ const ret = wasm.moqfecconfig_p(this.__wbg_ptr);
2003
+ return ret >>> 0;
2004
+ }
2005
+ /**
2006
+ * @returns {number}
2007
+ */
2008
+ effectiveLossRate() {
2009
+ const ret = wasm.moqfecstatsjs_effectiveLossRate(this.__wbg_ptr);
2010
+ return ret;
2011
+ }
2012
+ /**
2013
+ * @returns {number}
2014
+ */
2015
+ get k() {
2016
+ const ret = wasm.moqfecstatsjs_k(this.__wbg_ptr);
2017
+ return ret >>> 0;
2018
+ }
2019
+ /**
2020
+ * @returns {number}
2021
+ */
2022
+ get p() {
2023
+ const ret = wasm.moqfecstatsjs_p(this.__wbg_ptr);
2024
+ return ret >>> 0;
2025
+ }
2026
+ /**
2027
+ * @returns {number}
2028
+ */
2029
+ get totalSymbolsReceived() {
2030
+ const ret = wasm.moqfecconfig_interleaveDepth(this.__wbg_ptr);
2031
+ return ret >>> 0;
2032
+ }
2033
+ }
2034
+ if (Symbol.dispose) MoqFecStatsJs.prototype[Symbol.dispose] = MoqFecStatsJs.prototype.free;
2035
+ __exports.MoqFecStatsJs = MoqFecStatsJs;
2036
+
2037
+ /**
2038
+ * A reassembled MFU handed back to JS.
2039
+ */
2040
+ class ReassembledMfuJs {
2041
+ static __wrap(ptr) {
2042
+ ptr = ptr >>> 0;
2043
+ const obj = Object.create(ReassembledMfuJs.prototype);
2044
+ obj.__wbg_ptr = ptr;
2045
+ ReassembledMfuJsFinalization.register(obj, obj.__wbg_ptr, obj);
2046
+ return obj;
2047
+ }
2048
+ __destroy_into_raw() {
2049
+ const ptr = this.__wbg_ptr;
2050
+ this.__wbg_ptr = 0;
2051
+ ReassembledMfuJsFinalization.unregister(this);
2052
+ return ptr;
2053
+ }
2054
+ free() {
2055
+ const ptr = this.__destroy_into_raw();
2056
+ wasm.__wbg_reassembledmfujs_free(ptr, 0);
2057
+ }
2058
+ /**
2059
+ * @returns {number | undefined}
2060
+ */
2061
+ get attribution() {
2062
+ const ret = wasm.reassembledmfujs_attribution(this.__wbg_ptr);
2063
+ return ret === 0xFFFFFF ? undefined : ret;
2064
+ }
2065
+ /**
2066
+ * @returns {number | undefined}
2067
+ */
2068
+ get sample_number() {
2069
+ const ret = wasm.reassembledmfujs_sample_number(this.__wbg_ptr);
2070
+ return ret === 0x100000001 ? undefined : ret;
2071
+ }
2072
+ /**
2073
+ * @returns {number}
2074
+ */
2075
+ get fragment_count() {
2076
+ const ret = wasm.reassembledmfujs_fragment_count(this.__wbg_ptr);
2077
+ return ret >>> 0;
2078
+ }
2079
+ /**
2080
+ * @returns {number | undefined}
2081
+ */
2082
+ get stream_identity() {
2083
+ const ret = wasm.reassembledmfujs_stream_identity(this.__wbg_ptr);
2084
+ return ret === 0x100000001 ? undefined : ret;
2085
+ }
2086
+ /**
2087
+ * @returns {number}
2088
+ */
2089
+ get mpu_sequence_number() {
2090
+ const ret = wasm.reassembledmfujs_mpu_sequence_number(this.__wbg_ptr);
2091
+ return ret >>> 0;
2092
+ }
2093
+ /**
2094
+ * @returns {Uint32Array | undefined}
2095
+ */
2096
+ get packet_sequence_numbers() {
2097
+ const ret = wasm.reassembledmfujs_packet_sequence_numbers(this.__wbg_ptr);
2098
+ let v1;
2099
+ if (ret[0] !== 0) {
2100
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
2101
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2102
+ }
2103
+ return v1;
2104
+ }
2105
+ /**
2106
+ * @returns {number | undefined}
2107
+ */
2108
+ get movie_fragment_sequence_number() {
2109
+ const ret = wasm.reassembledmfujs_movie_fragment_sequence_number(this.__wbg_ptr);
2110
+ return ret === 0x100000001 ? undefined : ret;
2111
+ }
2112
+ /**
2113
+ * @returns {Uint32Array | undefined}
2114
+ */
2115
+ get repaired_packet_sequence_numbers() {
2116
+ const ret = wasm.reassembledmfujs_repaired_packet_sequence_numbers(this.__wbg_ptr);
2117
+ let v1;
2118
+ if (ret[0] !== 0) {
2119
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
2120
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2121
+ }
2122
+ return v1;
2123
+ }
2124
+ /**
2125
+ * The reassembled bytes. Two copies per access (a Rust-side clone — a
2126
+ * `&self` getter cannot move out of `Bytes` — plus the boundary
2127
+ * `Uint8Array` copy), re-incurred on every read: read once and cache.
2128
+ * A zero-copy linear-memory view is not an option — it cannot safely
2129
+ * outlive the next reassembler call.
2130
+ * @returns {Uint8Array}
2131
+ */
2132
+ get data() {
2133
+ const ret = wasm.reassembledmfujs_data(this.__wbg_ptr);
2134
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2135
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2136
+ return v1;
2137
+ }
2138
+ /**
2139
+ * This DU's authored base byte offset within its sample (moqcast #37).
2140
+ * 0 for a whole-sample DU; nonzero identifies one subsample DU among
2141
+ * siblings partitioning an oversized sample. Feed into
2142
+ * [`MmtSampleCombiner`] to reassemble the full sample.
2143
+ * @returns {number | undefined}
2144
+ */
2145
+ get offset() {
2146
+ const ret = wasm.reassembledmfujs_offset(this.__wbg_ptr);
2147
+ return ret === 0x100000001 ? undefined : ret;
2148
+ }
2149
+ /**
2150
+ * @returns {number | undefined}
2151
+ */
2152
+ get priority() {
2153
+ const ret = wasm.reassembledmfujs_priority(this.__wbg_ptr);
2154
+ return ret === 0xFFFFFF ? undefined : ret;
2155
+ }
2156
+ /**
2157
+ * @returns {boolean}
2158
+ */
2159
+ get rap_flag() {
2160
+ const ret = wasm.reassembledmfujs_rap_flag(this.__wbg_ptr);
2161
+ return ret !== 0;
2162
+ }
2163
+ /**
2164
+ * @returns {number}
2165
+ */
2166
+ get timestamp() {
2167
+ const ret = wasm.reassembledmfujs_timestamp(this.__wbg_ptr);
2168
+ return ret >>> 0;
2169
+ }
2170
+ }
2171
+ if (Symbol.dispose) ReassembledMfuJs.prototype[Symbol.dispose] = ReassembledMfuJs.prototype.free;
2172
+ __exports.ReassembledMfuJs = ReassembledMfuJs;
2173
+
2174
+ /**
2175
+ * Snapshot of [`MmtReassembler`] statistics. `u64` fields surface to JS as
2176
+ * `BigInt`, matching the existing [`FecStats`] convention.
2177
+ */
2178
+ class ReassemblerStatsJs {
2179
+ static __wrap(ptr) {
2180
+ ptr = ptr >>> 0;
2181
+ const obj = Object.create(ReassemblerStatsJs.prototype);
2182
+ obj.__wbg_ptr = ptr;
2183
+ ReassemblerStatsJsFinalization.register(obj, obj.__wbg_ptr, obj);
2184
+ return obj;
2185
+ }
2186
+ __destroy_into_raw() {
2187
+ const ptr = this.__wbg_ptr;
2188
+ this.__wbg_ptr = 0;
2189
+ ReassemblerStatsJsFinalization.unregister(this);
2190
+ return ptr;
2191
+ }
2192
+ free() {
2193
+ const ptr = this.__destroy_into_raw();
2194
+ wasm.__wbg_reassemblerstatsjs_free(ptr, 0);
2195
+ }
2196
+ /**
2197
+ * @returns {bigint}
2198
+ */
2199
+ get total_fragments() {
2200
+ const ret = wasm.__wbg_get_fecstats_source_packets(this.__wbg_ptr);
2201
+ return BigInt.asUintN(64, ret);
2202
+ }
2203
+ /**
2204
+ * @param {bigint} arg0
2205
+ */
2206
+ set total_fragments(arg0) {
2207
+ wasm.__wbg_set_fecstats_source_packets(this.__wbg_ptr, arg0);
2208
+ }
2209
+ /**
2210
+ * @returns {bigint}
2211
+ */
2212
+ get reassembled_mfus() {
2213
+ const ret = wasm.__wbg_get_fecstats_repair_packets(this.__wbg_ptr);
2214
+ return BigInt.asUintN(64, ret);
2215
+ }
2216
+ /**
2217
+ * @param {bigint} arg0
2218
+ */
2219
+ set reassembled_mfus(arg0) {
2220
+ wasm.__wbg_set_fecstats_repair_packets(this.__wbg_ptr, arg0);
2221
+ }
2222
+ /**
2223
+ * @returns {bigint}
2224
+ */
2225
+ get timed_out_mfus() {
2226
+ const ret = wasm.__wbg_get_fecstats_blocks_complete(this.__wbg_ptr);
2227
+ return BigInt.asUintN(64, ret);
2228
+ }
2229
+ /**
2230
+ * @param {bigint} arg0
2231
+ */
2232
+ set timed_out_mfus(arg0) {
2233
+ wasm.__wbg_set_fecstats_blocks_complete(this.__wbg_ptr, arg0);
2234
+ }
2235
+ /**
2236
+ * @returns {bigint}
2237
+ */
2238
+ get evicted_memory_limit() {
2239
+ const ret = wasm.__wbg_get_fecstats_blocks_recovered(this.__wbg_ptr);
2240
+ return BigInt.asUintN(64, ret);
2241
+ }
2242
+ /**
2243
+ * @param {bigint} arg0
2244
+ */
2245
+ set evicted_memory_limit(arg0) {
2246
+ wasm.__wbg_set_fecstats_blocks_recovered(this.__wbg_ptr, arg0);
2247
+ }
2248
+ /**
2249
+ * Incomplete data units released by the MMT policy's clock-free
2250
+ * replacement at `max_buffered` (BLO-31513). Distinct from
2251
+ * `evicted_memory_limit`, which counts the generic engine's own
2252
+ * memory-limit eviction; a host wanting every bound-driven drop sums the
2253
+ * two. Surfaced here because the wasm facade is a host surface: without
2254
+ * it, sustained head loss is silent on wasm-backed engines.
2255
+ * @returns {bigint}
2256
+ */
2257
+ get evicted_data_units() {
2258
+ const ret = wasm.__wbg_get_fecstats_blocks_failed(this.__wbg_ptr);
2259
+ return BigInt.asUintN(64, ret);
2260
+ }
2261
+ /**
2262
+ * Incomplete data units released by the MMT policy's clock-free
2263
+ * replacement at `max_buffered` (BLO-31513). Distinct from
2264
+ * `evicted_memory_limit`, which counts the generic engine's own
2265
+ * memory-limit eviction; a host wanting every bound-driven drop sums the
2266
+ * two. Surfaced here because the wasm facade is a host surface: without
2267
+ * it, sustained head loss is silent on wasm-backed engines.
2268
+ * @param {bigint} arg0
2269
+ */
2270
+ set evicted_data_units(arg0) {
2271
+ wasm.__wbg_set_fecstats_blocks_failed(this.__wbg_ptr, arg0);
2272
+ }
2273
+ /**
2274
+ * @returns {bigint}
2275
+ */
2276
+ get out_of_order_fragments() {
2277
+ const ret = wasm.__wbg_get_fecstats_bytes_recovered(this.__wbg_ptr);
2278
+ return BigInt.asUintN(64, ret);
2279
+ }
2280
+ /**
2281
+ * @param {bigint} arg0
2282
+ */
2283
+ set out_of_order_fragments(arg0) {
2284
+ wasm.__wbg_set_fecstats_bytes_recovered(this.__wbg_ptr, arg0);
2285
+ }
2286
+ /**
2287
+ * @returns {bigint}
2288
+ */
2289
+ get duplicate_fragments() {
2290
+ const ret = wasm.__wbg_get_fecstats_blocks_delivery_failed(this.__wbg_ptr);
2291
+ return BigInt.asUintN(64, ret);
2292
+ }
2293
+ /**
2294
+ * @param {bigint} arg0
2295
+ */
2296
+ set duplicate_fragments(arg0) {
2297
+ wasm.__wbg_set_fecstats_blocks_delivery_failed(this.__wbg_ptr, arg0);
2298
+ }
2299
+ /**
2300
+ * @returns {bigint}
2301
+ */
2302
+ get ambiguous_fallback_fragments() {
2303
+ const ret = wasm.__wbg_get_reassemblerstatsjs_ambiguous_fallback_fragments(this.__wbg_ptr);
2304
+ return BigInt.asUintN(64, ret);
2305
+ }
2306
+ /**
2307
+ * @param {bigint} arg0
2308
+ */
2309
+ set ambiguous_fallback_fragments(arg0) {
2310
+ wasm.__wbg_set_reassemblerstatsjs_ambiguous_fallback_fragments(this.__wbg_ptr, arg0);
2311
+ }
2312
+ }
2313
+ if (Symbol.dispose) ReassemblerStatsJs.prototype[Symbol.dispose] = ReassemblerStatsJs.prototype.free;
2314
+ __exports.ReassemblerStatsJs = ReassemblerStatsJs;
2315
+
2316
+ /**
2317
+ * Identity-carrying result of [`ShredFecBuffer::try_recover_all_with_identity`]:
2318
+ * the recovered FEC set's `(slot, fec_set_index)` key plus the reassembled bytes.
2319
+ *
2320
+ * `slot` surfaces to JS as `BigInt` — wasm-bindgen's native `u64` mapping — which
2321
+ * matches the buffer's existing surface (`add_shred` already takes `slot: u64`,
2322
+ * i.e. a `BigInt` from JS) and the repo convention for u64 fields
2323
+ * ([`FecStats`], [`ReassemblerStatsJs`]). An `f64` slot was rejected: mainnet
2324
+ * slots fit in 53 bits today, but the lossless representation costs nothing here.
2325
+ *
2326
+ * JS ownership: unlike the plain `Uint8Array` from `try_recover_all`, a
2327
+ * `RecoveredSet` is a wasm-owned object — its allocation (payload included)
2328
+ * stays in wasm linear memory until JS calls `.free()` (or the
2329
+ * nondeterministic `FinalizationRegistry` runs). Call `.free()` after
2330
+ * consuming each set in the drain loop; linear memory never shrinks, so
2331
+ * unfreed sets accumulate as permanent module growth.
2332
+ */
2333
+ class RecoveredSet {
2334
+ static __wrap(ptr) {
2335
+ ptr = ptr >>> 0;
2336
+ const obj = Object.create(RecoveredSet.prototype);
2337
+ obj.__wbg_ptr = ptr;
2338
+ RecoveredSetFinalization.register(obj, obj.__wbg_ptr, obj);
2339
+ return obj;
2340
+ }
2341
+ __destroy_into_raw() {
2342
+ const ptr = this.__wbg_ptr;
2343
+ this.__wbg_ptr = 0;
2344
+ RecoveredSetFinalization.unregister(this);
2345
+ return ptr;
2346
+ }
2347
+ free() {
2348
+ const ptr = this.__destroy_into_raw();
2349
+ wasm.__wbg_recoveredset_free(ptr, 0);
2350
+ }
2351
+ /**
2352
+ * FEC set index within the slot.
2353
+ * @returns {number}
2354
+ */
2355
+ get fec_set_index() {
2356
+ const ret = wasm.recoveredset_fec_set_index(this.__wbg_ptr);
2357
+ return ret >>> 0;
2358
+ }
2359
+ /**
2360
+ * Solana slot of the recovered FEC set (JS: `BigInt`).
2361
+ * @returns {bigint}
2362
+ */
2363
+ get slot() {
2364
+ const ret = wasm.recoveredset_slot(this.__wbg_ptr);
2365
+ return BigInt.asUintN(64, ret);
2366
+ }
2367
+ /**
2368
+ * The reassembled FEC-set bytes. Two copies per access (a Rust-side clone
2369
+ * — a `&self` getter cannot move the `Box` — plus the boundary
2370
+ * `Uint8Array` copy), re-incurred on every read: read once and cache.
2371
+ * Same pattern as [`ReassembledMfuJs::data`].
2372
+ * @returns {Uint8Array}
2373
+ */
2374
+ get payload() {
2375
+ const ret = wasm.recoveredset_payload(this.__wbg_ptr);
2376
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2377
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2378
+ return v1;
2379
+ }
2380
+ }
2381
+ if (Symbol.dispose) RecoveredSet.prototype[Symbol.dispose] = RecoveredSet.prototype.free;
2382
+ __exports.RecoveredSet = RecoveredSet;
2383
+
2384
+ /**
2385
+ * Snapshot of [`MmtSampleCombiner`] statistics.
2386
+ */
2387
+ class SampleCombinerStatsJs {
2388
+ static __wrap(ptr) {
2389
+ ptr = ptr >>> 0;
2390
+ const obj = Object.create(SampleCombinerStatsJs.prototype);
2391
+ obj.__wbg_ptr = ptr;
2392
+ SampleCombinerStatsJsFinalization.register(obj, obj.__wbg_ptr, obj);
2393
+ return obj;
2394
+ }
2395
+ __destroy_into_raw() {
2396
+ const ptr = this.__wbg_ptr;
2397
+ this.__wbg_ptr = 0;
2398
+ SampleCombinerStatsJsFinalization.unregister(this);
2399
+ return ptr;
2400
+ }
2401
+ free() {
2402
+ const ptr = this.__destroy_into_raw();
2403
+ wasm.__wbg_samplecombinerstatsjs_free(ptr, 0);
2404
+ }
2405
+ /**
2406
+ * @returns {bigint}
2407
+ */
2408
+ get combined_samples() {
2409
+ const ret = wasm.__wbg_get_fecstats_source_packets(this.__wbg_ptr);
2410
+ return BigInt.asUintN(64, ret);
2411
+ }
2412
+ /**
2413
+ * @param {bigint} arg0
2414
+ */
2415
+ set combined_samples(arg0) {
2416
+ wasm.__wbg_set_fecstats_source_packets(this.__wbg_ptr, arg0);
2417
+ }
2418
+ /**
2419
+ * @returns {bigint}
2420
+ */
2421
+ get passthrough_samples() {
2422
+ const ret = wasm.__wbg_get_fecstats_repair_packets(this.__wbg_ptr);
2423
+ return BigInt.asUintN(64, ret);
2424
+ }
2425
+ /**
2426
+ * @param {bigint} arg0
2427
+ */
2428
+ set passthrough_samples(arg0) {
2429
+ wasm.__wbg_set_fecstats_repair_packets(this.__wbg_ptr, arg0);
2430
+ }
2431
+ /**
2432
+ * @returns {bigint}
2433
+ */
2434
+ get timed_out_samples() {
2435
+ const ret = wasm.__wbg_get_fecstats_blocks_complete(this.__wbg_ptr);
2436
+ return BigInt.asUintN(64, ret);
2437
+ }
2438
+ /**
2439
+ * @param {bigint} arg0
2440
+ */
2441
+ set timed_out_samples(arg0) {
2442
+ wasm.__wbg_set_fecstats_blocks_complete(this.__wbg_ptr, arg0);
2443
+ }
2444
+ /**
2445
+ * Incomplete samples discarded to enforce `max_buffered`.
2446
+ * @returns {bigint}
2447
+ */
2448
+ get evicted_samples() {
2449
+ const ret = wasm.__wbg_get_fecstats_blocks_recovered(this.__wbg_ptr);
2450
+ return BigInt.asUintN(64, ret);
2451
+ }
2452
+ /**
2453
+ * Incomplete samples discarded to enforce `max_buffered`.
2454
+ * @param {bigint} arg0
2455
+ */
2456
+ set evicted_samples(arg0) {
2457
+ wasm.__wbg_set_fecstats_blocks_recovered(this.__wbg_ptr, arg0);
2458
+ }
2459
+ }
2460
+ if (Symbol.dispose) SampleCombinerStatsJs.prototype[Symbol.dispose] = SampleCombinerStatsJs.prototype.free;
2461
+ __exports.SampleCombinerStatsJs = SampleCombinerStatsJs;
2462
+
2463
+ /**
2464
+ * Solana FEC-set buffer with Reed-Solomon erasure recovery (wire v3).
2465
+ *
2466
+ * Accepts both data and coding shreds as agave *erasure shards* (equal length within
2467
+ * a set). Happy path: once all `num_data` data shreds are present the set completes
2468
+ * immediately (num_data known from the DATA_COMPLETE data shred or any coding shred).
2469
+ * Loss path: buffer whatever arrives and call `try_recover_all()` periodically —
2470
+ * when `received_data + received_coding >= num_data`, RS reconstructs the missing
2471
+ * data shards. On completion the real data is extracted from each data shard's
2472
+ * embedded `size` field and concatenated in order.
2473
+ */
2474
+ class ShredFecBuffer {
2475
+ __destroy_into_raw() {
2476
+ const ptr = this.__wbg_ptr;
2477
+ this.__wbg_ptr = 0;
2478
+ ShredFecBufferFinalization.unregister(this);
2479
+ return ptr;
2480
+ }
2481
+ free() {
2482
+ const ptr = this.__destroy_into_raw();
2483
+ wasm.__wbg_shredfecbuffer_free(ptr, 0);
2484
+ }
2485
+ /**
2486
+ * Call periodically (every ~50ms) to attempt RS recovery on a stale FEC set.
2487
+ * Returns one recovered set's bytes or null — the caller should loop until null
2488
+ * to drain a backlog (a single set per tick cannot keep up with the shred rate).
2489
+ *
2490
+ * The payload alone carries no set identity; use
2491
+ * [`try_recover_all_with_identity`](Self::try_recover_all_with_identity) when
2492
+ * the caller needs to attribute the bytes to a `(slot, fec_set_index)`. Both
2493
+ * methods drain the SAME backlog (a set is returned by whichever is called
2494
+ * first, never both), and every call advances the staleness clock — run
2495
+ * exactly one variant per buffer, not both interleaved.
2496
+ * @param {number} _now_ms
2497
+ * @returns {Uint8Array | undefined}
2498
+ */
2499
+ try_recover_all(_now_ms) {
2500
+ const ret = wasm.shredfecbuffer_try_recover_all(this.__wbg_ptr, _now_ms);
2501
+ let v1;
2502
+ if (ret[0] !== 0) {
2503
+ v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2504
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2505
+ }
2506
+ return v1;
2507
+ }
2508
+ /**
2509
+ * Number of incomplete (non-tombstone) FEC sets buffered.
2510
+ * @returns {number}
2511
+ */
2512
+ pending_fec_sets() {
2513
+ const ret = wasm.shredfecbuffer_pending_fec_sets(this.__wbg_ptr);
2514
+ return ret >>> 0;
2515
+ }
2516
+ /**
2517
+ * Identity-carrying variant of [`try_recover_all`](Self::try_recover_all):
2518
+ * same recovery pass, same drain semantics (loop until null), but the result
2519
+ * also carries the recovered set's `(slot, fec_set_index)` key. ADDITIVE —
2520
+ * `try_recover_all` is unchanged (the in-flight pim player uses it); both
2521
+ * methods drain the same underlying backlog, so a set is returned by
2522
+ * whichever is called first, never both. They are alternatives for a single
2523
+ * consumer — interleaving them doubles the tick rate, aging pending sets out
2524
+ * of the recovery window in half the wall-clock time.
2525
+ *
2526
+ * JS ownership: the returned [`RecoveredSet`] is wasm-owned — call `.free()`
2527
+ * after consuming each set (see the type's docs), unlike `try_recover_all`'s
2528
+ * auto-freed `Uint8Array`.
2529
+ * @param {number} _now_ms
2530
+ * @returns {RecoveredSet | undefined}
2531
+ */
2532
+ try_recover_all_with_identity(_now_ms) {
2533
+ const ret = wasm.shredfecbuffer_try_recover_all_with_identity(this.__wbg_ptr, _now_ms);
2534
+ return ret === 0 ? undefined : RecoveredSet.__wrap(ret);
2535
+ }
2536
+ /**
2537
+ * @param {bigint} timeout_ms
2538
+ * @param {number} max_buffered
2539
+ */
2540
+ constructor(timeout_ms, max_buffered) {
2541
+ const ret = wasm.shredfecbuffer_new(timeout_ms, max_buffered);
2542
+ this.__wbg_ptr = ret >>> 0;
2543
+ ShredFecBufferFinalization.register(this, this.__wbg_ptr, this);
2544
+ return this;
2545
+ }
2546
+ /**
2547
+ * Feed a data or coding shred (wire-v3 erasure shard).
2548
+ * Returns reassembled FEC-set bytes if the set just completed, null otherwise.
2549
+ * @param {bigint} slot
2550
+ * @param {number} fec_set_index
2551
+ * @param {number} local_index
2552
+ * @param {number} num_data
2553
+ * @param {number} num_coding
2554
+ * @param {boolean} is_coding
2555
+ * @param {Uint8Array} payload
2556
+ * @param {boolean} last_in_set
2557
+ * @returns {Uint8Array | undefined}
2558
+ */
2559
+ add_shred(slot, fec_set_index, local_index, num_data, num_coding, is_coding, payload, last_in_set) {
2560
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc);
2561
+ const len0 = WASM_VECTOR_LEN;
2562
+ const ret = wasm.shredfecbuffer_add_shred(this.__wbg_ptr, slot, fec_set_index, local_index, num_data, num_coding, is_coding, ptr0, len0, last_in_set);
2563
+ let v2;
2564
+ if (ret[0] !== 0) {
2565
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2566
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2567
+ }
2568
+ return v2;
2569
+ }
2570
+ }
2571
+ if (Symbol.dispose) ShredFecBuffer.prototype[Symbol.dispose] = ShredFecBuffer.prototype.free;
2572
+ __exports.ShredFecBuffer = ShredFecBuffer;
2573
+
2574
+ /**
2575
+ * Browser-side Solana FEC-set reassembler.
2576
+ *
2577
+ * Feed data shreds as they arrive from a multicast subscription. Returns the
2578
+ * reassembled FEC-set payload when all shreds for a (slot, fec_set_index) group
2579
+ * have been received in order, or null if the set is still incomplete.
2580
+ */
2581
+ class ShredReassembler {
2582
+ __destroy_into_raw() {
2583
+ const ptr = this.__wbg_ptr;
2584
+ this.__wbg_ptr = 0;
2585
+ ShredReassemblerFinalization.unregister(this);
2586
+ return ptr;
2587
+ }
2588
+ free() {
2589
+ const ptr = this.__destroy_into_raw();
2590
+ wasm.__wbg_shredreassembler_free(ptr, 0);
2591
+ }
2592
+ /**
2593
+ * Number of FEC sets currently buffered (incomplete).
2594
+ * @returns {number}
2595
+ */
2596
+ pending_fec_sets() {
2597
+ const ret = wasm.combinedsamplejs_mpu_sequence_number(this.__wbg_ptr);
2598
+ return ret >>> 0;
2599
+ }
2600
+ /**
2601
+ * @param {bigint} timeout_ms
2602
+ * @param {number} max_buffered
2603
+ */
2604
+ constructor(timeout_ms, max_buffered) {
2605
+ const ret = wasm.shredreassembler_new(timeout_ms, max_buffered);
2606
+ this.__wbg_ptr = ret >>> 0;
2607
+ ShredReassemblerFinalization.register(this, this.__wbg_ptr, this);
2608
+ return this;
2609
+ }
2610
+ /**
2611
+ * Feed one data shred.
2612
+ * Returns the reassembled FEC-set bytes when the set is complete, otherwise null.
2613
+ * @param {bigint} slot
2614
+ * @param {number} fec_set_index
2615
+ * @param {number} local_index
2616
+ * @param {Uint8Array} payload
2617
+ * @param {boolean} last_in_set
2618
+ * @returns {Uint8Array | undefined}
2619
+ */
2620
+ add_shred(slot, fec_set_index, local_index, payload, last_in_set) {
2621
+ const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc);
2622
+ const len0 = WASM_VECTOR_LEN;
2623
+ const ret = wasm.shredreassembler_add_shred(this.__wbg_ptr, slot, fec_set_index, local_index, ptr0, len0, last_in_set);
2624
+ let v2;
2625
+ if (ret[0] !== 0) {
2626
+ v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2627
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2628
+ }
2629
+ return v2;
2630
+ }
2631
+ }
2632
+ if (Symbol.dispose) ShredReassembler.prototype[Symbol.dispose] = ShredReassembler.prototype.free;
2633
+ __exports.ShredReassembler = ShredReassembler;
2634
+
2635
+ /**
2636
+ * True when an Annex B access unit contains a keyframe slice for the
2637
+ * catalog codec's family. Every NAL unit header is validated.
2638
+ * @param {string} codec
2639
+ * @param {Uint8Array} access_unit
2640
+ * @returns {boolean}
2641
+ */
2642
+ function annexb_access_unit_is_keyframe(codec, access_unit) {
2643
+ const ptr0 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2644
+ const len0 = WASM_VECTOR_LEN;
2645
+ const ptr1 = passArray8ToWasm0(access_unit, wasm.__wbindgen_malloc);
2646
+ const len1 = WASM_VECTOR_LEN;
2647
+ const ret = wasm.annexb_access_unit_is_keyframe(ptr0, len0, ptr1, len1);
2648
+ if (ret[2]) {
2649
+ throw takeFromExternrefTable0(ret[1]);
2650
+ }
2651
+ return ret[0] !== 0;
2652
+ }
2653
+ __exports.annexb_access_unit_is_keyframe = annexb_access_unit_is_keyframe;
2654
+
2655
+ /**
2656
+ * The RFC 6381 codec string of an HEVC stream derived from its SPS NAL unit
2657
+ * (ISO/IEC 14496-15 Annex E.3), using the sample entry (`hev1`/`hvc1`) of
2658
+ * the catalog codec string.
2659
+ * @param {string} codec
2660
+ * @param {Uint8Array} sps
2661
+ * @returns {string}
2662
+ */
2663
+ function hevc_codec_string(codec, sps) {
2664
+ let deferred4_0;
2665
+ let deferred4_1;
2666
+ try {
2667
+ const ptr0 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2668
+ const len0 = WASM_VECTOR_LEN;
2669
+ const ptr1 = passArray8ToWasm0(sps, wasm.__wbindgen_malloc);
2670
+ const len1 = WASM_VECTOR_LEN;
2671
+ const ret = wasm.hevc_codec_string(ptr0, len0, ptr1, len1);
2672
+ var ptr3 = ret[0];
2673
+ var len3 = ret[1];
2674
+ if (ret[3]) {
2675
+ ptr3 = 0; len3 = 0;
2676
+ throw takeFromExternrefTable0(ret[2]);
2677
+ }
2678
+ deferred4_0 = ptr3;
2679
+ deferred4_1 = len3;
2680
+ return getStringFromWasm0(ptr3, len3);
2681
+ } finally {
2682
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2683
+ }
2684
+ }
2685
+ __exports.hevc_codec_string = hevc_codec_string;
2686
+
2687
+ /**
2688
+ * The `hvcC` HEVCDecoderConfigurationRecord (ISO/IEC 14496-15 8.3.3.1)
2689
+ * built from the VPS, SPS and PPS carried in an Annex B IRAP access unit;
2690
+ * usable as the fMP4 `hvcC` box payload and the WebCodecs `description`.
2691
+ * Samples must then be 4-byte length-prefixed (`lengthSizeMinusOne` = 3).
2692
+ * @param {string} codec
2693
+ * @param {Uint8Array} access_unit
2694
+ * @returns {Uint8Array}
2695
+ */
2696
+ function hevc_hvcc_from_annexb(codec, access_unit) {
2697
+ const ptr0 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2698
+ const len0 = WASM_VECTOR_LEN;
2699
+ const ptr1 = passArray8ToWasm0(access_unit, wasm.__wbindgen_malloc);
2700
+ const len1 = WASM_VECTOR_LEN;
2701
+ const ret = wasm.hevc_hvcc_from_annexb(ptr0, len0, ptr1, len1);
2702
+ if (ret[3]) {
2703
+ throw takeFromExternrefTable0(ret[2]);
2704
+ }
2705
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2706
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2707
+ return v3;
2708
+ }
2709
+ __exports.hevc_hvcc_from_annexb = hevc_hvcc_from_annexb;
2710
+
2711
+ /**
2712
+ * Initialize the WASM module
2713
+ */
2714
+ function init() {
2715
+ wasm.init();
2716
+ }
2717
+ __exports.init = init;
2718
+
2719
+ /**
2720
+ * True when one NAL unit (no start code or length prefix) is a keyframe
2721
+ * slice for the catalog codec's family: an AVC IDR slice (H.264 Table 7-1)
2722
+ * or an HEVC IRAP picture (H.265 Table 7-1, `nal_unit_type` 16..=23).
2723
+ * Throws for an unknown family or a malformed NAL unit header.
2724
+ * @param {string} codec
2725
+ * @param {Uint8Array} nal
2726
+ * @returns {boolean}
2727
+ */
2728
+ function is_keyframe_nal(codec, nal) {
2729
+ const ptr0 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2730
+ const len0 = WASM_VECTOR_LEN;
2731
+ const ptr1 = passArray8ToWasm0(nal, wasm.__wbindgen_malloc);
2732
+ const len1 = WASM_VECTOR_LEN;
2733
+ const ret = wasm.is_keyframe_nal(ptr0, len0, ptr1, len1);
2734
+ if (ret[2]) {
2735
+ throw takeFromExternrefTable0(ret[1]);
2736
+ }
2737
+ return ret[0] !== 0;
2738
+ }
2739
+ __exports.is_keyframe_nal = is_keyframe_nal;
2740
+
2741
+ /**
2742
+ * Exact browser-facing MoQ FEC contract implemented by this module.
2743
+ * @returns {string}
2744
+ */
2745
+ function moq_fec_contract_version() {
2746
+ let deferred1_0;
2747
+ let deferred1_1;
2748
+ try {
2749
+ const ret = wasm.moq_fec_contract_version();
2750
+ deferred1_0 = ret[0];
2751
+ deferred1_1 = ret[1];
2752
+ return getStringFromWasm0(ret[0], ret[1]);
2753
+ } finally {
2754
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2755
+ }
2756
+ }
2757
+ __exports.moq_fec_contract_version = moq_fec_contract_version;
2758
+
2759
+ /**
2760
+ * Hash one authenticated object on the browser main thread.
2761
+ * @param {Uint8Array} object
2762
+ * @returns {Uint8Array}
2763
+ */
2764
+ function source_auth_blake3(object) {
2765
+ const ptr0 = passArray8ToWasm0(object, wasm.__wbindgen_malloc);
2766
+ const len0 = WASM_VECTOR_LEN;
2767
+ const ret = wasm.source_auth_blake3(ptr0, len0);
2768
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2769
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2770
+ return v2;
2771
+ }
2772
+ __exports.source_auth_blake3 = source_auth_blake3;
2773
+
2774
+ /**
2775
+ * Build one `iso-ssbg1-v1` source symbol (ISO/IEC 23008-1 C.3.3
2776
+ * ssbg_mode1): `u16be(len) || packet || zero padding` to `symbol_size` bytes.
2777
+ * `packet` is the protected MMTP packet without its Source FEC Payload ID;
2778
+ * a packet with `len + 2 > symbol_size` is refused.
2779
+ * @param {Uint8Array} packet
2780
+ * @param {number} symbol_size
2781
+ * @returns {Uint8Array}
2782
+ */
2783
+ function ssbg1_source_symbol(packet, symbol_size) {
2784
+ const ptr0 = passArray8ToWasm0(packet, wasm.__wbindgen_malloc);
2785
+ const len0 = WASM_VECTOR_LEN;
2786
+ const ret = wasm.ssbg1_source_symbol(ptr0, len0, symbol_size);
2787
+ if (ret[3]) {
2788
+ throw takeFromExternrefTable0(ret[2]);
2789
+ }
2790
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2791
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2792
+ return v2;
2793
+ }
2794
+ __exports.ssbg1_source_symbol = ssbg1_source_symbol;
2795
+
2796
+ /**
2797
+ * The sample entry four-character code (`avc1`, `avc3`, `hev1`, `hvc1`)
2798
+ * named by a catalog codec string. Throws for any other codec family.
2799
+ * @param {string} codec
2800
+ * @returns {string}
2801
+ */
2802
+ function video_sample_entry_from_codec_string(codec) {
2803
+ let deferred3_0;
2804
+ let deferred3_1;
2805
+ try {
2806
+ const ptr0 = passStringToWasm0(codec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2807
+ const len0 = WASM_VECTOR_LEN;
2808
+ const ret = wasm.video_sample_entry_from_codec_string(ptr0, len0);
2809
+ var ptr2 = ret[0];
2810
+ var len2 = ret[1];
2811
+ if (ret[3]) {
2812
+ ptr2 = 0; len2 = 0;
2813
+ throw takeFromExternrefTable0(ret[2]);
2814
+ }
2815
+ deferred3_0 = ptr2;
2816
+ deferred3_1 = len2;
2817
+ return getStringFromWasm0(ptr2, len2);
2818
+ } finally {
2819
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2820
+ }
2821
+ }
2822
+ __exports.video_sample_entry_from_codec_string = video_sample_entry_from_codec_string;
2823
+
2824
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2825
+
2826
+ async function __wbg_load(module, imports) {
2827
+ if (typeof Response === 'function' && module instanceof Response) {
2828
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2829
+ try {
2830
+ return await WebAssembly.instantiateStreaming(module, imports);
2831
+ } catch (e) {
2832
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
2833
+
2834
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2835
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2836
+
2837
+ } else {
2838
+ throw e;
2839
+ }
2840
+ }
2841
+ }
2842
+
2843
+ const bytes = await module.arrayBuffer();
2844
+ return await WebAssembly.instantiate(bytes, imports);
2845
+ } else {
2846
+ const instance = await WebAssembly.instantiate(module, imports);
2847
+
2848
+ if (instance instanceof WebAssembly.Instance) {
2849
+ return { instance, module };
2850
+ } else {
2851
+ return instance;
2852
+ }
2853
+ }
2854
+ }
2855
+
2856
+ function __wbg_get_imports() {
2857
+ const imports = {};
2858
+ imports.wbg = {};
2859
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
2860
+ const ret = debugString(arg1);
2861
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2862
+ const len1 = WASM_VECTOR_LEN;
2863
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2864
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2865
+ };
2866
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
2867
+ const ret = arg0 === undefined;
2868
+ return ret;
2869
+ };
2870
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2871
+ throw new Error(getStringFromWasm0(arg0, arg1));
2872
+ };
2873
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
2874
+ const ret = arg0.call(arg1);
2875
+ return ret;
2876
+ }, arguments) };
2877
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
2878
+ let deferred0_0;
2879
+ let deferred0_1;
2880
+ try {
2881
+ deferred0_0 = arg0;
2882
+ deferred0_1 = arg1;
2883
+ console.error(getStringFromWasm0(arg0, arg1));
2884
+ } finally {
2885
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2886
+ }
2887
+ };
2888
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
2889
+ const ret = Reflect.get(arg0, arg1);
2890
+ return ret;
2891
+ }, arguments) };
2892
+ imports.wbg.__wbg_log_443cb9527570529b = function(arg0, arg1) {
2893
+ console.log(getStringFromWasm0(arg0, arg1));
2894
+ };
2895
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
2896
+ const ret = new Error();
2897
+ return ret;
2898
+ };
2899
+ imports.wbg.__wbg_new_df1173567d5ff028 = function(arg0, arg1) {
2900
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2901
+ return ret;
2902
+ };
2903
+ imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
2904
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
2905
+ return ret;
2906
+ };
2907
+ imports.wbg.__wbg_now_8cf15d6e317793e1 = function(arg0) {
2908
+ const ret = arg0.now();
2909
+ return ret;
2910
+ };
2911
+ imports.wbg.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
2912
+ const ret = Reflect.set(arg0, arg1, arg2);
2913
+ return ret;
2914
+ }, arguments) };
2915
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
2916
+ const ret = arg1.stack;
2917
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2918
+ const len1 = WASM_VECTOR_LEN;
2919
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2920
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2921
+ };
2922
+ imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
2923
+ const ret = typeof global === 'undefined' ? null : global;
2924
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2925
+ };
2926
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
2927
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2928
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2929
+ };
2930
+ imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
2931
+ const ret = typeof self === 'undefined' ? null : self;
2932
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2933
+ };
2934
+ imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
2935
+ const ret = typeof window === 'undefined' ? null : window;
2936
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2937
+ };
2938
+ imports.wbg.__wbg_warn_620e34c9218c1711 = function(arg0, arg1) {
2939
+ console.warn(getStringFromWasm0(arg0, arg1));
2940
+ };
2941
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
2942
+ // Cast intrinsic for `Ref(String) -> Externref`.
2943
+ const ret = getStringFromWasm0(arg0, arg1);
2944
+ return ret;
2945
+ };
2946
+ imports.wbg.__wbindgen_init_externref_table = function() {
2947
+ const table = wasm.__wbindgen_externrefs;
2948
+ const offset = table.grow(4);
2949
+ table.set(0, undefined);
2950
+ table.set(offset + 0, undefined);
2951
+ table.set(offset + 1, null);
2952
+ table.set(offset + 2, true);
2953
+ table.set(offset + 3, false);
2954
+ };
2955
+
2956
+ return imports;
2957
+ }
2958
+
2959
+ function __wbg_finalize_init(instance, module) {
2960
+ wasm = instance.exports;
2961
+ __wbg_init.__wbindgen_wasm_module = module;
2962
+ cachedDataViewMemory0 = null;
2963
+ cachedUint32ArrayMemory0 = null;
2964
+ cachedUint8ArrayMemory0 = null;
2965
+
2966
+
2967
+ wasm.__wbindgen_start();
2968
+ return wasm;
2969
+ }
2970
+
2971
+ function initSync(module) {
2972
+ if (wasm !== undefined) return wasm;
2973
+
2974
+
2975
+ if (typeof module !== 'undefined') {
2976
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2977
+ ({module} = module)
2978
+ } else {
2979
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2980
+ }
2981
+ }
2982
+
2983
+ const imports = __wbg_get_imports();
2984
+ if (!(module instanceof WebAssembly.Module)) {
2985
+ module = new WebAssembly.Module(module);
2986
+ }
2987
+ const instance = new WebAssembly.Instance(module, imports);
2988
+ return __wbg_finalize_init(instance, module);
2989
+ }
2990
+
2991
+ async function __wbg_init(module_or_path) {
2992
+ if (wasm !== undefined) return wasm;
2993
+
2994
+
2995
+ if (typeof module_or_path !== 'undefined') {
2996
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2997
+ ({module_or_path} = module_or_path)
2998
+ } else {
2999
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
3000
+ }
3001
+ }
3002
+
3003
+ if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') {
3004
+ module_or_path = script_src.replace(/\.js$/, '_bg.wasm');
3005
+ }
3006
+ const imports = __wbg_get_imports();
3007
+
3008
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
3009
+ module_or_path = fetch(module_or_path);
3010
+ }
3011
+
3012
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
3013
+
3014
+ return __wbg_finalize_init(instance, module);
3015
+ }
3016
+
3017
+ wasm_bindgen = Object.assign(__wbg_init, { initSync }, __exports);
3018
+ })();