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