moqtail 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2814 @@
1
+ //#region src/model/common/pair.d.ts
2
+ /**
3
+ * @public
4
+ * Represents a key-value pair for MOQT protocol parameters.
5
+ *
6
+ * - If `typeValue` is **even**, the value is a varint (`bigint`).
7
+ * - If `typeValue` is **odd**, the value is a binary blob (`Uint8Array`) with a maximum length of 65535 bytes.
8
+ *
9
+ * Use {@link KeyValuePair.tryNewVarInt} for varint pairs and {@link KeyValuePair.tryNewBytes} for blob pairs.
10
+ */
11
+ declare class KeyValuePair {
12
+ /**
13
+ * The key/type identifier for this pair.
14
+ * - Even: value is a varint.
15
+ * - Odd: value is a blob.
16
+ */
17
+ readonly typeValue: bigint;
18
+ /**
19
+ * The value for this pair.
20
+ * - If `typeValue` is even: a varint (`bigint`).
21
+ * - If `typeValue` is odd: a binary blob (`Uint8Array`).
22
+ */
23
+ readonly value: bigint | Uint8Array;
24
+ /**
25
+ * Constructs a new KeyValuePair.
26
+ * @param typeValue - The key/type identifier.
27
+ * @param value - The value (varint or blob).
28
+ * @internal Use static factory methods instead.
29
+ */
30
+ private constructor();
31
+ /**
32
+ * Creates a new varint KeyValuePair.
33
+ * @param typeValue - Must be even.
34
+ * @param value - The varint value.
35
+ * @returns A KeyValuePair with varint value.
36
+ * @throws KeyValueFormattingError if typeValue is not even.
37
+ */
38
+ static tryNewVarInt(typeValue: bigint | number, value: bigint | number): KeyValuePair;
39
+ /**
40
+ * Creates a new blob KeyValuePair.
41
+ * @param typeValue - Must be odd.
42
+ * @param value - The binary blob value.
43
+ * @returns A KeyValuePair with blob value.
44
+ * @throws KeyValueFormattingError if typeValue is not odd.
45
+ * @throws LengthExceedsMaxError if value length exceeds 65535 bytes.
46
+ */
47
+ static tryNewBytes(typeValue: bigint | number, value: Uint8Array): KeyValuePair;
48
+ /**
49
+ * Serializes this key-value pair to a frozen byte buffer.
50
+ * Equivalent to {@link KeyValuePair.serializeDelta} with `prevType = 0n`.
51
+ * @returns The serialized buffer.
52
+ */
53
+ serialize(): FrozenByteBuffer;
54
+ /**
55
+ * Serializes this pair's wire form, encoding the Type as a delta from
56
+ * `prevType` (the type of the previous KVP in the same list, or 0n if this
57
+ * is the first entry).
58
+ * @param prevType - The type of the previous KVP in the same list.
59
+ * @throws ProtocolViolationError if this pair's type is less than prevType
60
+ * (Delta Type is an unsigned varint, so the list must be sorted ascending).
61
+ */
62
+ serializeDelta(prevType: bigint): FrozenByteBuffer;
63
+ /**
64
+ * Deserializes a KeyValuePair from a buffer.
65
+ * Equivalent to {@link KeyValuePair.deserializeDelta} with `prevType = 0n`.
66
+ * @param buf - The buffer to read from.
67
+ * @returns The deserialized KeyValuePair.
68
+ * @throws LengthExceedsMaxError if blob length exceeds 65535 bytes.
69
+ * @throws NotEnoughBytesError if buffer does not contain enough bytes.
70
+ */
71
+ static deserialize(buf: BaseByteBuffer): KeyValuePair;
72
+ /**
73
+ * Deserializes a wire-form KVP whose Type field is a delta from `prevType`
74
+ * (the type of the previous KVP in the same list, or 0n if this is the
75
+ * first entry).
76
+ * @param buf - The buffer to read from.
77
+ * @param prevType - The type of the previous KVP in the same list.
78
+ * @throws ProtocolViolationError if prevType + delta exceeds 2^64 - 1.
79
+ */
80
+ static deserializeDelta(buf: BaseByteBuffer, prevType: bigint): KeyValuePair;
81
+ /**
82
+ * Reads a value whose Type has already been decoded, applying the parity
83
+ * rule. Callers in a type namespace where a Type uses a different encoding
84
+ * read that value themselves and do not call this.
85
+ * @param buf - The buffer to read from.
86
+ * @param typeValue - The already-decoded Type.
87
+ */
88
+ static deserializeValue(buf: BaseByteBuffer, typeValue: bigint): KeyValuePair;
89
+ /**
90
+ * Checks if this pair is equal to another.
91
+ * @param other - The other KeyValuePair.
92
+ * @returns True if both type and value are equal.
93
+ */
94
+ equals(other: KeyValuePair): boolean;
95
+ }
96
+ /**
97
+ * Delta-encodes and serializes a list of Key-Value-Pairs to wire bytes.
98
+ * The list is sorted by ascending type first, since Delta Type is an
99
+ * unsigned varint and cannot represent a type decrease.
100
+ */
101
+ declare function serializeKvpList(items: KeyValuePair[]): FrozenByteBuffer;
102
+ /**
103
+ * Reads exactly `count` delta-encoded Key-Value-Pairs from `buf`.
104
+ */
105
+ declare function deserializeKvpList(buf: BaseByteBuffer, count: number | bigint): KeyValuePair[];
106
+ /**
107
+ * Reads delta-encoded Key-Value-Pairs from `buf` until it is exhausted.
108
+ */
109
+ declare function deserializeKvpListUntilEmpty(buf: BaseByteBuffer): KeyValuePair[];
110
+ /**
111
+ * Checks if the KeyValuePair is a varint pair (even typeValue).
112
+ * @param pair - The KeyValuePair to check.
113
+ * @returns True if value is a varint.
114
+ */
115
+ declare function isVarInt(pair: KeyValuePair): pair is KeyValuePair & {
116
+ value: bigint;
117
+ };
118
+ /**
119
+ * Checks if the KeyValuePair is a blob pair (odd typeValue).
120
+ * @param pair - The KeyValuePair to check.
121
+ * @returns True if value is a Uint8Array.
122
+ */
123
+ declare function isBytes(pair: KeyValuePair): pair is KeyValuePair & {
124
+ value: Uint8Array;
125
+ };
126
+ //#endregion
127
+ //#region src/model/common/location.d.ts
128
+ /**
129
+ * @public
130
+ * Represents a position in a MOQT track, consisting of a group and object index.
131
+ *
132
+ * Used for specifying start/end positions in subscription and fetch requests.
133
+ * - `group`: The group index (e.g. segment, GOP, or logical group).
134
+ * - `object`: The object index within the group (e.g. frame, chunk).
135
+ */
136
+ declare class Location {
137
+ /**
138
+ * The group index for this location.
139
+ */
140
+ readonly group: bigint;
141
+ /**
142
+ * The object index within the group for this location.
143
+ */
144
+ readonly object: bigint;
145
+ /**
146
+ * Constructs a new Location.
147
+ * @param group - The group index (number or bigint).
148
+ * @param object - The object index (number or bigint).
149
+ */
150
+ constructor(group: bigint | number, object: bigint | number);
151
+ /**
152
+ * Serializes this Location to a FrozenByteBuffer.
153
+ * @returns The serialized buffer.
154
+ * @throws CastingError if group or object is negative.
155
+ * @throws VarIntOverflowError if group or object exceeds varint encoding limits.
156
+ */
157
+ serialize(): FrozenByteBuffer;
158
+ /**
159
+ * Deserializes a Location from a buffer.
160
+ * @param buf - The buffer to read from.
161
+ * @returns The deserialized Location.
162
+ * @throws NotEnoughBytesError if buffer does not contain enough bytes.
163
+ */
164
+ static deserialize(buf: BaseByteBuffer): Location;
165
+ /**
166
+ * Checks if this Location is equal to another.
167
+ * @param other - The other Location to compare.
168
+ * @returns True if both group and object are equal.
169
+ */
170
+ equals(other: Location): boolean;
171
+ /**
172
+ * Compares this Location to another for ordering.
173
+ * @param other - The other Location to compare.
174
+ * @returns -1 if this \< other, 1 if this \> other, 0 if equal.
175
+ */
176
+ compare(other: Location): number;
177
+ }
178
+ //#endregion
179
+ //#region src/model/common/tuple.d.ts
180
+ /**
181
+ * @public
182
+ * Represents a single field in a Tuple, storing a value as a UTF-8 encoded byte array.
183
+ *
184
+ * Used for path segments or protocol fields in MOQT.
185
+ */
186
+ declare class TupleField {
187
+ readonly value: Uint8Array;
188
+ /**
189
+ * The raw value of the field as a byte array.
190
+ */
191
+ constructor(value: Uint8Array);
192
+ /**
193
+ * Creates a TupleField from a UTF-8 string.
194
+ * @param str - The string to encode.
195
+ * @returns A new TupleField containing the encoded value.
196
+ */
197
+ static fromUtf8(str: string): TupleField;
198
+ /**
199
+ * Decodes the field value to a UTF-8 string.
200
+ * @returns The decoded string.
201
+ */
202
+ toUtf8(): string;
203
+ /**
204
+ * Serializes this field to a length-prefixed byte array.
205
+ * @returns The serialized bytes.
206
+ */
207
+ serialize(): Uint8Array;
208
+ /**
209
+ * Deserializes a TupleField from a buffer.
210
+ * @param buf - The buffer to read from.
211
+ * @returns The deserialized TupleField.
212
+ * @throws CastingError if the length cannot be safely cast to number.
213
+ * @throws NotEnoughBytesError if buffer does not contain enough bytes.
214
+ */
215
+ static deserialize(buf: BaseByteBuffer): TupleField;
216
+ }
217
+ /**
218
+ * @public
219
+ * Represents a sequence of TupleFields, typically used for hierarchical paths or protocol tuples in MOQT.
220
+ */
221
+ declare class Tuple {
222
+ readonly fields: TupleField[];
223
+ /**
224
+ * The ordered list of fields in this tuple.
225
+ */
226
+ constructor(fields?: TupleField[]);
227
+ /**
228
+ * Creates a Tuple from a path string, splitting on '/'.
229
+ * @param path - The path string (e.g. '/foo/bar').
230
+ * @returns A Tuple with each segment as a field.
231
+ */
232
+ static fromUtf8Path(path: string): Tuple;
233
+ /**
234
+ * Converts the tuple to a path string, joining fields with '/'.
235
+ * @returns The path string (e.g. '/foo/bar').
236
+ */
237
+ toUtf8Path(): string;
238
+ /**
239
+ * Adds a field to the tuple.
240
+ * @param field - The TupleField to add.
241
+ */
242
+ add(field: TupleField): void;
243
+ /**
244
+ * Gets the field at the specified index.
245
+ * @param index - The field index.
246
+ * @returns The TupleField at the index.
247
+ * @throws Error if no field exists at the index.
248
+ */
249
+ get(index: number): TupleField;
250
+ /**
251
+ * Sets the field at the specified index.
252
+ * @param index - The field index.
253
+ * @param field - The TupleField to set.
254
+ */
255
+ set(index: number, field: TupleField): void;
256
+ /**
257
+ * Clears all fields from the tuple.
258
+ */
259
+ clear(): void;
260
+ /**
261
+ * Serializes the tuple to a FrozenByteBuffer.
262
+ * @returns The serialized buffer.
263
+ */
264
+ serialize(): FrozenByteBuffer;
265
+ /**
266
+ * Deserializes a Tuple from a buffer.
267
+ * @param buf - The buffer to read from.
268
+ * @returns The deserialized Tuple.
269
+ * @throws CastingError if the count cannot be safely cast to number.
270
+ * @throws NotEnoughBytesError if buffer does not contain enough bytes.
271
+ */
272
+ static deserialize(buf: BaseByteBuffer): Tuple;
273
+ /**
274
+ * Checks if this tuple is equal to another.
275
+ * @param other - The other Tuple to compare.
276
+ * @returns True if all fields are equal.
277
+ */
278
+ equals(other: Tuple): boolean;
279
+ }
280
+ //#endregion
281
+ //#region src/model/common/reason_phrase.d.ts
282
+ /**
283
+ * The maximum allowed length (in bytes) for a ReasonPhrase.
284
+ * @public
285
+ */
286
+ declare const MAX_REASON_PHRASE_LEN = 1024;
287
+ /**
288
+ * Represents a protocol ReasonPhrase, a short UTF-8 string used for error or status reporting.
289
+ * Enforces a maximum byte length and validates encoding.
290
+ *
291
+ * @public
292
+ */
293
+ declare class ReasonPhrase {
294
+ #private;
295
+ /**
296
+ * Constructs a ReasonPhrase, validating UTF-8 encoding and length.
297
+ *
298
+ * @param phrase - The string to use as the reason phrase.
299
+ * @throws {@link InvalidUTF8Error} if encoding fails.
300
+ * @throws {@link LengthExceedsMaxError} if the encoded phrase exceeds {@link MAX_REASON_PHRASE_LEN} bytes.
301
+ * @public
302
+ */
303
+ constructor(phrase: string);
304
+ /**
305
+ * Returns the phrase string.
306
+ * @public
307
+ */
308
+ get phrase(): string;
309
+ /**
310
+ * Serializes the ReasonPhrase into a {@link FrozenByteBuffer} containing:
311
+ * varint(length_of_phrase_bytes) || phrase_bytes
312
+ *
313
+ * @returns The serialized buffer.
314
+ * @public
315
+ */
316
+ serialize(): FrozenByteBuffer;
317
+ /**
318
+ * Deserializes a ReasonPhrase from the given buffer.
319
+ * Reads varint(length) || utf8‑bytes.
320
+ *
321
+ * @param buf - The buffer to read from.
322
+ * @returns The deserialized ReasonPhrase.
323
+ * @throws :{@link CastingError} if the length cannot be safely cast to a number.
324
+ * @throws :{@link LengthExceedsMaxError} if the length exceeds {@link MAX_REASON_PHRASE_LEN}.
325
+ * @throws :{@link NotEnoughBytesError} if the buffer does not contain enough bytes.
326
+ * @throws :{@link InvalidUTF8Error} if decoding fails.
327
+ * @public
328
+ */
329
+ static deserialize(buf: BaseByteBuffer): ReasonPhrase;
330
+ }
331
+ //#endregion
332
+ //#region src/model/data/constant.d.ts
333
+ /**
334
+ * Copyright 2025 The MOQtail Authors
335
+ *
336
+ * Licensed under the Apache License, Version 2.0 (the "License");
337
+ * you may not use this file except in compliance with the License.
338
+ * You may obtain a copy of the License at
339
+ *
340
+ * http://www.apache.org/licenses/LICENSE-2.0
341
+ *
342
+ * Unless required by applicable law or agreed to in writing, software
343
+ * distributed under the License is distributed on an "AS IS" BASIS,
344
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345
+ * See the License for the specific language governing permissions and
346
+ * limitations under the License.
347
+ */
348
+ /**
349
+ * @public
350
+ * Object datagram types for MOQT objects (Draft-16).
351
+ *
352
+ * Type bit layout (form 0b00X0XXXX):
353
+ * - Bit 0 (0x01): PROPERTIES - Properties field present
354
+ * - Bit 1 (0x02): END_OF_GROUP - Last object in group
355
+ * - Bit 2 (0x04): ZERO_OBJECT_ID - Object ID omitted (assumed 0)
356
+ * - Bit 3 (0x08): DEFAULT_PRIORITY - Publisher Priority omitted (inherited)
357
+ * - Bit 5 (0x20): STATUS - Object Status replaces Object Payload
358
+ *
359
+ * Invalid combinations:
360
+ * - STATUS (0x20) + END_OF_GROUP (0x02) together is a PROTOCOL_VIOLATION
361
+ * - Types outside the form 0b00X0XXXX are invalid
362
+ */
363
+ declare enum ObjectDatagramType {
364
+ Type0x00 = 0,
365
+ Type0x01 = 1,
366
+ Type0x02 = 2,
367
+ Type0x03 = 3,
368
+ Type0x04 = 4,
369
+ Type0x05 = 5,
370
+ Type0x06 = 6,
371
+ Type0x07 = 7,
372
+ Type0x08 = 8,
373
+ Type0x09 = 9,
374
+ Type0x0A = 10,
375
+ Type0x0B = 11,
376
+ Type0x0C = 12,
377
+ Type0x0D = 13,
378
+ Type0x0E = 14,
379
+ Type0x0F = 15,
380
+ Type0x20 = 32,
381
+ Type0x21 = 33,
382
+ Type0x24 = 36,
383
+ Type0x25 = 37,
384
+ Type0x28 = 40,
385
+ Type0x29 = 41,
386
+ Type0x2C = 44,
387
+ Type0x2D = 45
388
+ }
389
+ /**
390
+ * @public
391
+ * Namespace for ObjectDatagramType utilities.
392
+ */
393
+ declare namespace ObjectDatagramType {
394
+ /** Properties field present (bit 0). */
395
+ const PROPERTIES = 1;
396
+ /** Last object in the group (bit 1). */
397
+ const END_OF_GROUP = 2;
398
+ /** Object ID omitted, taken as 0 (bit 2). */
399
+ const ZERO_OBJECT_ID = 4;
400
+ /** Publisher Priority omitted, taken from the subscription (bit 3). */
401
+ const DEFAULT_PRIORITY = 8;
402
+ /** Carries an object status rather than a payload (bit 5). */
403
+ const STATUS = 32;
404
+ /** Mask for bits that must be zero: bits 4, 6, 7 (form `0b00X0XXXX`). */
405
+ const INVALID_BITS_MASK = 208;
406
+ /**
407
+ * Converts a number or bigint to ObjectDatagramType.
408
+ * Validates using bitmask: must match form 0b00X0XXXX,
409
+ * and STATUS + END_OF_GROUP cannot both be set.
410
+ * @param value - The value to convert.
411
+ * @returns The corresponding ObjectDatagramType.
412
+ * @throws Error if the value is not valid.
413
+ */
414
+ function tryFrom(value: number | bigint): ObjectDatagramType;
415
+ /**
416
+ * Returns true if the type has properties (bit 0 set).
417
+ * @param t - The ObjectDatagramType.
418
+ */
419
+ function hasProperties(t: ObjectDatagramType): boolean;
420
+ /**
421
+ * Returns true if the type indicates End of Group (bit 1 set).
422
+ * @param t - The ObjectDatagramType.
423
+ */
424
+ function isEndOfGroup(t: ObjectDatagramType): boolean;
425
+ /**
426
+ * Returns true if Object ID is absent (bit 2 set).
427
+ * When true, Object ID is omitted and assumed to be 0.
428
+ * @param t - The ObjectDatagramType.
429
+ */
430
+ function isZeroObjectId(t: ObjectDatagramType): boolean;
431
+ /**
432
+ * Returns true if Publisher Priority is omitted (bit 3 set).
433
+ * When true, the priority is inherited from the control message.
434
+ * @param t - The ObjectDatagramType.
435
+ */
436
+ function hasDefaultPriority(t: ObjectDatagramType): boolean;
437
+ /**
438
+ * Returns true if the datagram carries Object Status instead of payload (bit 5 set).
439
+ * @param t - The ObjectDatagramType.
440
+ */
441
+ function isStatus(t: ObjectDatagramType): boolean;
442
+ /**
443
+ * Determines the appropriate type for given properties.
444
+ * @param hasProperties - Whether properties are present.
445
+ * @param endOfGroup - Whether this is the last object in the group.
446
+ * @param objectIdIsZero - Whether the objectId is 0.
447
+ * @param defaultPriority - Whether publisher priority is inherited (omitted).
448
+ * @param isStatus - Whether the datagram carries status instead of payload.
449
+ * @throws Error if STATUS and END_OF_GROUP are both true (PROTOCOL_VIOLATION).
450
+ */
451
+ function fromProperties(hasProperties: boolean, endOfGroup: boolean, objectIdIsZero: boolean, defaultPriority: boolean, isStatus: boolean): ObjectDatagramType;
452
+ }
453
+ /**
454
+ * @public
455
+ * Fetch header types for MOQT fetch requests.
456
+ */
457
+ declare enum FetchHeaderType {
458
+ Type0x05 = 5
459
+ }
460
+ /**
461
+ * Namespace for FetchHeaderType utilities.
462
+ */
463
+ declare namespace FetchHeaderType {
464
+ /**
465
+ * Converts a number or bigint to FetchHeaderType.
466
+ * @param value - The value to convert.
467
+ * @returns The corresponding FetchHeaderType.
468
+ * @throws Error if the value is not valid.
469
+ */
470
+ function tryFrom(value: number | bigint): FetchHeaderType;
471
+ }
472
+ /**
473
+ * @public
474
+ * Subgroup header types for MOQT subgroups.
475
+ *
476
+ * Type bit layout (0b0XX1XXXX):
477
+ * - Bit 0 (0x01): PROPERTIES - Properties present in all objects
478
+ * - Bits 1-2 (0x06): SUBGROUP_ID_MODE - How subgroup ID is encoded (0b00=zero, 0b01=firstObjId, 0b10=explicit, 0b11=invalid)
479
+ * - Bit 3 (0x08): END_OF_GROUP - This subgroup contains the final object in the group
480
+ * - Bit 4 (0x10): Always set (distinguishes subgroup from other header types)
481
+ * - Bit 5 (0x20): DEFAULT_PRIORITY - Publisher priority field omitted, inherited from subscription
482
+ * - Bit 6 (0x40): FIRST_OBJECT - The first object on this stream is the first the original
483
+ * publisher published in the subgroup
484
+ * - Bit 7 (0x80): Must be zero
485
+ *
486
+ * Valid ranges: 0x10-0x15, 0x18-0x1D, 0x30-0x35, 0x38-0x3D, 0x50-0x55, 0x58-0x5D, 0x70-0x75, 0x78-0x7D
487
+ * Invalid: 0x16, 0x17, 0x1E, 0x1F, 0x36, 0x37, 0x3E, 0x3F, 0x56, 0x57, 0x5E, 0x5F, 0x76, 0x77, 0x7E,
488
+ * 0x7F (SUBGROUP_ID_MODE=0b11)
489
+ */
490
+ declare enum SubgroupHeaderType {
491
+ Type0x10 = 16,
492
+ Type0x11 = 17,
493
+ Type0x12 = 18,
494
+ Type0x13 = 19,
495
+ Type0x14 = 20,
496
+ Type0x15 = 21,
497
+ Type0x18 = 24,
498
+ Type0x19 = 25,
499
+ Type0x1A = 26,
500
+ Type0x1B = 27,
501
+ Type0x1C = 28,
502
+ Type0x1D = 29,
503
+ Type0x30 = 48,
504
+ Type0x31 = 49,
505
+ Type0x32 = 50,
506
+ Type0x33 = 51,
507
+ Type0x34 = 52,
508
+ Type0x35 = 53,
509
+ Type0x38 = 56,
510
+ Type0x39 = 57,
511
+ Type0x3A = 58,
512
+ Type0x3B = 59,
513
+ Type0x3C = 60,
514
+ Type0x3D = 61,
515
+ Type0x50 = 80,
516
+ Type0x51 = 81,
517
+ Type0x52 = 82,
518
+ Type0x53 = 83,
519
+ Type0x54 = 84,
520
+ Type0x55 = 85,
521
+ Type0x58 = 88,
522
+ Type0x59 = 89,
523
+ Type0x5A = 90,
524
+ Type0x5B = 91,
525
+ Type0x5C = 92,
526
+ Type0x5D = 93,
527
+ Type0x70 = 112,
528
+ Type0x71 = 113,
529
+ Type0x72 = 114,
530
+ Type0x73 = 115,
531
+ Type0x74 = 116,
532
+ Type0x75 = 117,
533
+ Type0x78 = 120,
534
+ Type0x79 = 121,
535
+ Type0x7A = 122,
536
+ Type0x7B = 123,
537
+ Type0x7C = 124,
538
+ Type0x7D = 125
539
+ }
540
+ /**
541
+ * Namespace for SubgroupHeaderType utilities and bit constants.
542
+ */
543
+ /**
544
+ * @public
545
+ * The Publisher Priority to assume where a header omits the field, having set its
546
+ * DEFAULT_PRIORITY bit. A track may name its own with the DEFAULT_PUBLISHER_PRIORITY
547
+ * track property; this is the value for one that does not. Priority runs from 0 (most
548
+ * important) to 255, so a wrong default here is not a small error: 0 makes every such
549
+ * object outrank all others.
550
+ */
551
+ declare const DEFAULT_PUBLISHER_PRIORITY = 128;
552
+ declare namespace SubgroupHeaderType {
553
+ /** Properties present in all objects (bit 0) */
554
+ const PROPERTIES = 1;
555
+ /** Mask for SUBGROUP_ID_MODE (bits 1-2) */
556
+ const SUBGROUP_ID_MODE_MASK = 6;
557
+ /** This subgroup contains the final object in the group (bit 3) */
558
+ const END_OF_GROUP = 8;
559
+ /** Required bit that must always be set (bit 4) */
560
+ const REQUIRED_BIT = 16;
561
+ /** Publisher priority field omitted, inherited from subscription (bit 5) */
562
+ const DEFAULT_PRIORITY = 32;
563
+ /** First object on this stream is the first published in the subgroup (bit 6) */
564
+ const FIRST_OBJECT = 64;
565
+ /** Mask for bits that must be zero: bit 7 only */
566
+ const INVALID_BITS_MASK = 128;
567
+ function hasProperties(t: SubgroupHeaderType): boolean;
568
+ function hasExplicitSubgroupId(t: SubgroupHeaderType): boolean;
569
+ function isSubgroupIdZero(t: SubgroupHeaderType): boolean;
570
+ function isSubgroupIdFirstObjectId(t: SubgroupHeaderType): boolean;
571
+ function containsEndOfGroup(t: SubgroupHeaderType): boolean;
572
+ function hasDefaultPriority(t: SubgroupHeaderType): boolean;
573
+ function isFirstObject(t: SubgroupHeaderType): boolean;
574
+ /**
575
+ * Converts a number or bigint to SubgroupHeaderType.
576
+ * Validates bit 7 must be zero, bit 4 must be set, SUBGROUP_ID_MODE must not be 0b11.
577
+ */
578
+ function tryFrom(value: number | bigint): SubgroupHeaderType;
579
+ /**
580
+ * Determines the appropriate type for given properties.
581
+ * @param subgroupIdMode - SUBGROUP_ID_MODE (0=zero, 1=firstObjId, 2=explicit).
582
+ * @param firstObject - Whether the first object on the stream is the first the original
583
+ * publisher published in the subgroup.
584
+ */
585
+ function fromProperties(hasProperties: boolean, subgroupIdMode: 0 | 1 | 2, containsEndOfGroup: boolean, hasDefaultPriority?: boolean, firstObject?: boolean): SubgroupHeaderType;
586
+ }
587
+ /**
588
+ * @public
589
+ * Publisher's preferred object delivery mechanism for a track.
590
+ * - `Subgroup`: Use ordered subgroups (reliable).
591
+ * - `Datagram`: Use unreliable datagrams when feasible.
592
+ *
593
+ * The preference is advisory: the relay/transport layer MAY override based on negotiated capabilities.
594
+ */
595
+ declare enum ObjectForwardingPreference {
596
+ Subgroup = "Subgroup",
597
+ Datagram = "Datagram"
598
+ }
599
+ /**
600
+ * Namespace for ObjectForwardingPreference utilities.
601
+ */
602
+ declare namespace ObjectForwardingPreference {
603
+ /**
604
+ * Converts a number, bigint, or string to ObjectForwardingPreference.
605
+ * @param value - The value to convert.
606
+ * @returns The corresponding ObjectForwardingPreference.
607
+ * @throws Error if the value is not valid.
608
+ */
609
+ function tryFrom(value: number | bigint | string): ObjectForwardingPreference;
610
+ }
611
+ /**
612
+ * @public
613
+ * Object status codes for MOQT objects.
614
+ * - `Normal`: Object exists and is available.
615
+ * - `EndOfGroup`: End of group marker.
616
+ * - `EndOfTrack`: End of track marker.
617
+ */
618
+ declare enum ObjectStatus {
619
+ Normal = 0,
620
+ EndOfGroup = 3,
621
+ EndOfTrack = 4
622
+ }
623
+ /**
624
+ * Namespace for ObjectStatus utilities.
625
+ */
626
+ declare namespace ObjectStatus {
627
+ /**
628
+ * Converts a number or bigint to ObjectStatus.
629
+ * @param value - The value to convert.
630
+ * @returns The corresponding ObjectStatus.
631
+ * @throws Error if the value is not valid.
632
+ */
633
+ function tryFrom(value: number | bigint): ObjectStatus;
634
+ }
635
+ //#endregion
636
+ //#region src/model/data/datagram.d.ts
637
+ /**
638
+ * Represents a unified OBJECT_DATAGRAM message (Draft-16).
639
+ *
640
+ * Type bit layout (form 0b00X0XXXX):
641
+ * - Bit 0 (0x01): PROPERTIES
642
+ * - Bit 1 (0x02): END_OF_GROUP
643
+ * - Bit 2 (0x04): ZERO_OBJECT_ID
644
+ * - Bit 3 (0x08): DEFAULT_PRIORITY
645
+ * - Bit 5 (0x20): STATUS
646
+ */
647
+ declare class Datagram {
648
+ readonly type: ObjectDatagramType;
649
+ readonly publisherPriority: number | null;
650
+ readonly properties: KeyValuePair[] | null;
651
+ readonly payload: Uint8Array | null;
652
+ readonly objectStatus: ObjectStatus | null;
653
+ readonly endOfGroup: boolean;
654
+ readonly trackAlias: bigint;
655
+ readonly location: Location;
656
+ private constructor();
657
+ get groupId(): bigint;
658
+ get objectId(): bigint;
659
+ /**
660
+ * Create a new Datagram with payload content.
661
+ * The type is automatically determined based on the properties.
662
+ */
663
+ static newPayload(trackAlias: bigint, groupId: bigint, objectId: bigint, publisherPriority: number | null, properties: KeyValuePair[] | null, payload: Uint8Array, endOfGroup?: boolean): Datagram;
664
+ /**
665
+ * Create a new Datagram with Object Status (no payload).
666
+ * endOfGroup is always false since STATUS + END_OF_GROUP is invalid.
667
+ */
668
+ static newStatus(trackAlias: bigint, groupId: bigint, objectId: bigint, publisherPriority: number | null, properties: KeyValuePair[] | null, objectStatus: ObjectStatus): Datagram;
669
+ serialize(): FrozenByteBuffer;
670
+ static deserialize(buf: BaseByteBuffer): Datagram;
671
+ }
672
+ //#endregion
673
+ //#region src/model/data/fetch_header.d.ts
674
+ declare class FetchHeader {
675
+ readonly type: FetchHeaderType;
676
+ readonly requestId: bigint;
677
+ constructor(type: FetchHeaderType, requestId: bigint | number);
678
+ serialize(): FrozenByteBuffer;
679
+ static deserialize(buf: BaseByteBuffer): FetchHeader;
680
+ }
681
+ //#endregion
682
+ //#region src/model/control/constant.d.ts
683
+ /**
684
+ * Copyright 2025 The MOQtail Authors
685
+ *
686
+ * Licensed under the Apache License, Version 2.0 (the "License");
687
+ * you may not use this file except in compliance with the License.
688
+ * You may obtain a copy of the License at
689
+ *
690
+ * http://www.apache.org/licenses/LICENSE-2.0
691
+ *
692
+ * Unless required by applicable law or agreed to in writing, software
693
+ * distributed under the License is distributed on an "AS IS" BASIS,
694
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
695
+ * See the License for the specific language governing permissions and
696
+ * limitations under the License.
697
+ */
698
+ /**
699
+ * Protocol string array exchanged in wt-available-protocols header
700
+ */
701
+ declare const SUPPORTED_VERSIONS: string[];
702
+ /**
703
+ * @public
704
+ * Control message types, per draft-18 Table 5.
705
+ *
706
+ * The comment on each member is the Stream column: `Control` is the control stream
707
+ * (§3.3), `Request` a bidirectional request stream, and `First` means the message MUST
708
+ * be the first on a new request stream.
709
+ *
710
+ * Table 5 reserves `0x01` (SETUP for version 00), `0x40`/`0x41` (CLIENT_SETUP /
711
+ * SERVER_SETUP for versions 10 and below) and `0x20`/`0x21` (CLIENT_SETUP /
712
+ * SERVER_SETUP for versions 16 and below — folded into Setup by #256). All five stay
713
+ * in the enum as documentation, but `tryFrom` rejects every RESERVED codepoint, which
714
+ * is what §10 requires — an endpoint receiving an unknown message type MUST close the
715
+ * session.
716
+ */
717
+ declare enum ControlMessageType {
718
+ ReservedSetupV00 = 1,
719
+ // RESERVED; rejected by tryFrom
720
+ ReservedClientSetupV10 = 64,
721
+ // RESERVED; rejected by tryFrom
722
+ ReservedServerSetupV10 = 65,
723
+ // RESERVED; rejected by tryFrom
724
+ ReservedClientSetupV16 = 32,
725
+ // RESERVED; rejected by tryFrom
726
+ ReservedServerSetupV16 = 33,
727
+ // RESERVED; rejected by tryFrom
728
+ Setup = 12032,
729
+ // Control
730
+ GoAway = 16,
731
+ // Control, Request
732
+ Subscribe = 3,
733
+ // Request, First
734
+ SubscribeOk = 4,
735
+ // Request
736
+ RequestError = 5,
737
+ // Request
738
+ RequestUpdate = 2,
739
+ // Request
740
+ PublishDone = 11,
741
+ // Request
742
+ Fetch = 22,
743
+ // Request, First
744
+ FetchOk = 24,
745
+ // Request
746
+ TrackStatus = 13,
747
+ // Request, First
748
+ PublishNamespace = 6,
749
+ // Request, First
750
+ RequestOk = 7,
751
+ // Request
752
+ Namespace = 8,
753
+ // Request
754
+ NamespaceDone = 14,
755
+ // Request
756
+ SubscribeNamespace = 80,
757
+ // Request, First
758
+ SubscribeTracks = 81,
759
+ // Request, First
760
+ Publish = 29,
761
+ // Request, First
762
+ PublishOk = 30,
763
+ // Request; an alias of RequestOk (§10.5), not its own body
764
+ PublishBlocked = 15,
765
+ // Request
766
+ Switch = 34
767
+ }
768
+ /**
769
+ * Converts a bigint value to a ControlMessageType enum.
770
+ * @param v - The bigint value.
771
+ * @returns The corresponding ControlMessageType.
772
+ * @throws InvalidEnumValue if the value is not a valid control message type.
773
+ */
774
+ declare namespace ControlMessageType {
775
+ /**
776
+ * True for the seven types marked `First` in Table 5: each one MUST be the first
777
+ * message on a new bidirectional request stream, and no other type may open one.
778
+ * Every remaining type travels on the control stream or on an already-open request
779
+ * stream.
780
+ */
781
+ function isFirst(t: ControlMessageType): boolean;
782
+ /**
783
+ * True for the six request types §10.9 lets a REQUEST_UPDATE modify. TRACK_STATUS
784
+ * opens a request stream but is not one of them, so an update on its stream is
785
+ * refused with a REQUEST_ERROR.
786
+ */
787
+ function isUpdatable(t: ControlMessageType): boolean;
788
+ /** Convert bigint discriminant to enum value or throw on invalid. */
789
+ function tryFrom(v: bigint): ControlMessageType;
790
+ }
791
+ /**
792
+ * @public
793
+ * Filter types for subscription requests.
794
+ */
795
+ declare enum FilterType {
796
+ NextGroupStart = 1,
797
+ LatestObject = 2,
798
+ AbsoluteStart = 3,
799
+ AbsoluteRange = 4
800
+ }
801
+ /**
802
+ * Converts a bigint value to a FilterType enum.
803
+ * @param v - The bigint value.
804
+ * @returns The corresponding FilterType.
805
+ * @throws InvalidEnumValue if the value is not a valid filter type.
806
+ */
807
+ declare namespace FilterType {
808
+ function tryFrom(v: bigint): FilterType;
809
+ }
810
+ /**
811
+ * @public
812
+ * Fetch request types for MOQT protocol.
813
+ */
814
+ declare enum FetchType {
815
+ Standalone = 1,
816
+ Relative = 2,
817
+ Absolute = 3
818
+ }
819
+ /**
820
+ * Converts a bigint value to a FetchType enum.
821
+ * @param v - The bigint value.
822
+ * @returns The corresponding FetchType.
823
+ * @throws InvalidEnumValue if the value is not a valid fetch type.
824
+ */
825
+ declare namespace FetchType {
826
+ function tryFrom(v: bigint): FetchType;
827
+ }
828
+ /**
829
+ * @public
830
+ * Group ordering options for object delivery.
831
+ */
832
+ declare enum GroupOrder {
833
+ Original = 0,
834
+ Ascending = 1,
835
+ Descending = 2
836
+ }
837
+ /**
838
+ * Converts a number value to a GroupOrder enum.
839
+ * @param v - The number value.
840
+ * @returns The corresponding GroupOrder.
841
+ * @throws InvalidEnumValue if the value is not a valid group order.
842
+ */
843
+ declare namespace GroupOrder {
844
+ function tryFrom(v: number): GroupOrder;
845
+ }
846
+ /**
847
+ * @public
848
+ * Status codes for track status responses.
849
+ */
850
+ declare enum TrackStatusCode {
851
+ InProgress = 0,
852
+ DoesNotExist = 1,
853
+ NotYetBegun = 2,
854
+ Finished = 3,
855
+ RelayUnavailable = 4
856
+ }
857
+ /**
858
+ * Converts a bigint value to a TrackStatusCode enum.
859
+ * @param v - The bigint value.
860
+ * @returns The corresponding TrackStatusCode.
861
+ * @throws InvalidEnumValue if the value is not a valid track status code.
862
+ */
863
+ declare namespace TrackStatusCode {
864
+ function tryFrom(v: bigint): TrackStatusCode;
865
+ }
866
+ /**
867
+ * @public
868
+ * Status codes for PublishDone control messages.
869
+ */
870
+ declare enum PublishDoneStatusCode {
871
+ InternalError = 0,
872
+ Unauthorized = 1,
873
+ TrackEnded = 2,
874
+ SubscriptionEnded = 3,
875
+ GoingAway = 4,
876
+ TooFarBehind = 5,
877
+ Expired = 6,
878
+ UpdateFailed = 8,
879
+ ExcessiveLoad = 9,
880
+ MalformedTrack = 18
881
+ }
882
+ /**
883
+ * Converts a bigint value to a PublishDoneStatusCode enum.
884
+ * @param v - The bigint value.
885
+ * @returns The corresponding PublishDoneStatusCode.
886
+ * @throws InvalidEnumValue if the value is not a valid subscribe done status code.
887
+ */
888
+ declare namespace PublishDoneStatusCode {
889
+ function tryFrom(v: bigint): PublishDoneStatusCode;
890
+ /**
891
+ * Maps a received status code to a known variant, treating any unknown value
892
+ * (including GREASE) as InternalError. An unknown code is never fatal.
893
+ */
894
+ function fromWire(v: bigint): PublishDoneStatusCode;
895
+ }
896
+ /**
897
+ * @public
898
+ * Unified error codes for REQUEST_ERROR control messages.
899
+ *
900
+ * A separate registry from {@link (StreamResetCode:enum)}, which disagrees with it on
901
+ * the same names: `GOING_AWAY` is `0x6` here but `0x4` as a stream reset code.
902
+ */
903
+ declare enum RequestErrorCode {
904
+ InternalError = 0,
905
+ Unauthorized = 1,
906
+ Timeout = 2,
907
+ NotSupported = 3,
908
+ MalformedAuthToken = 4,
909
+ ExpiredAuthToken = 5,
910
+ GoingAway = 6,
911
+ ExcessiveLoad = 9,
912
+ DoesNotExist = 16,
913
+ InvalidRange = 17,
914
+ MalformedTrack = 18,
915
+ DuplicateSubscription = 25,
916
+ Uninterested = 32,
917
+ PrefixOverlap = 48,
918
+ NamespaceTooLarge = 49,
919
+ InvalidJoiningRequestId = 50,
920
+ UnsupportedExtension = 51,
921
+ Redirect = 52
922
+ }
923
+ /**
924
+ * Converts a bigint value to a RequestErrorCode enum.
925
+ * @param v - The bigint value.
926
+ * @returns The corresponding RequestErrorCode.
927
+ * @throws InvalidEnumValue if the value is not a valid request error code.
928
+ */
929
+ declare namespace RequestErrorCode {
930
+ function tryFrom(v: bigint): RequestErrorCode;
931
+ /**
932
+ * Maps a received error code to a known variant, treating any unknown value
933
+ * (including GREASE) as InternalError. An unknown error code is never fatal and
934
+ * never closes the session.
935
+ */
936
+ function fromWire(v: bigint): RequestErrorCode;
937
+ }
938
+ //#endregion
939
+ //#region src/model/data/fetch_object.d.ts
940
+ /**
941
+ * Prior-object state threaded across successive Fetch Objects on the same stream.
942
+ */
943
+ type FetchObjectContext = {
944
+ groupId: bigint;
945
+ subgroupId: bigint;
946
+ objectId: bigint;
947
+ publisherPriority: number;
948
+ };
949
+ /**
950
+ * Kind discriminator for End-of-Range markers (§11.5).
951
+ */
952
+ declare enum EndOfRangeKind {
953
+ NonExistent = 140,
954
+ Unknown = 268
955
+ }
956
+ /**
957
+ * Payload-bearing fetch object (§11.5, non-End-of-Range form).
958
+ *
959
+ * FETCH objects carry no Object Status field; a zero-length payload
960
+ * signals a zero-length Normal object.
961
+ */
962
+ declare class FetchObject {
963
+ readonly kind: 'object' | 'end_of_range';
964
+ readonly publisherPriority: number;
965
+ readonly forwardingPreference: ObjectForwardingPreference;
966
+ readonly properties: KeyValuePair[] | null;
967
+ readonly payload: Uint8Array | null;
968
+ readonly endOfRange: EndOfRangeKind | null;
969
+ readonly location: Location;
970
+ readonly subgroupId: bigint;
971
+ private constructor();
972
+ get groupId(): bigint;
973
+ get objectId(): bigint;
974
+ /**
975
+ * Context to thread into the next call on this stream.
976
+ * Returns null for EndOfRange markers — they MUST NOT update prior state.
977
+ */
978
+ toContext(): FetchObjectContext | null;
979
+ static newObject(groupId: bigint | number, subgroupId: bigint | number, objectId: bigint | number, publisherPriority: number, forwardingPreference: ObjectForwardingPreference, properties: KeyValuePair[] | null, payload: Uint8Array): FetchObject;
980
+ static newEndOfRange(kind: EndOfRangeKind, groupId: bigint | number, objectId: bigint | number): FetchObject;
981
+ serialize(prev?: FetchObjectContext, groupOrder?: GroupOrder): FrozenByteBuffer;
982
+ static deserialize(buf: BaseByteBuffer, prev?: FetchObjectContext, groupOrder?: GroupOrder): FetchObject;
983
+ }
984
+ //#endregion
985
+ //#region src/model/data/full_track_name.d.ts
986
+ declare const MAX_NAMESPACE_TUPLE_COUNT = 32;
987
+ declare const MAX_FULL_TRACK_NAME_LENGTH = 4096;
988
+ /**
989
+ * Fully-qualified track identifier = hierarchical namespace (tuple) + leaf name bytes.
990
+ *
991
+ * Constraints enforced (throws {@link TrackNameError}):
992
+ * - Namespace tuple field count: 0 .. {@link MAX_NAMESPACE_TUPLE_COUNT} (draft-18 §2.4.1; an empty namespace is legal).
993
+ * - Total serialized length (namespace tuple + raw name bytes) less than or equals {@link MAX_FULL_TRACK_NAME_LENGTH} bytes.
994
+ *
995
+ * Namespace input may be:
996
+ * - `string` path with segments separated by `/` (converted via {@link Tuple.fromUtf8Path}). Empty segments are dropped,
997
+ * so `''` and `'/'` both yield a zero-element namespace.
998
+ * - Existing {@link Tuple} instance.
999
+ *
1000
+ * Name input may be:
1001
+ * - UTF-8 string (encoded)
1002
+ * - Raw `Uint8Array` (used directly)
1003
+ *
1004
+ * Instances are created via {@link FullTrackName.tryNew} (validates) or {@link FullTrackName.deserialize}.
1005
+ * Use {@link FullTrackName.serialize} for wire encoding and {@link FullTrackName.toString} for a human friendly
1006
+ * diagnostic format: `namespace/segments:hexname` (name rendered as lowercase hex, no 0x prefix).
1007
+ *
1008
+ * The string form is intended for logs/debug only; do not parse it for protocol operations.
1009
+ */
1010
+ declare class FullTrackName {
1011
+ readonly namespace: Tuple;
1012
+ readonly name: Uint8Array;
1013
+ private constructor();
1014
+ /**
1015
+ * Human-readable representation: `\<namespace path joined by '/'\>:\<name as lowercase hex\>`.
1016
+ * If the underlying {@link Tuple} exposes `toUtf8Path`, it's used; otherwise the raw fields are joined.
1017
+ * This is lossy only in the sense that name bytes are hex encoded; round-tripping requires serialization.
1018
+ */
1019
+ toString(): string;
1020
+ /**
1021
+ * Construct a validated full track name.
1022
+ *
1023
+ * Validation steps:
1024
+ * 1. Convert namespace string -\> {@link Tuple} (split on '/') if needed.
1025
+ * 2. Reject if namespace tuple field count is \> {@link MAX_NAMESPACE_TUPLE_COUNT}.
1026
+ * 3. Encode name string to UTF-8 if needed.
1027
+ * 4. Reject if total serialized length (namespace tuple + name bytes) \> {@link MAX_FULL_TRACK_NAME_LENGTH}.
1028
+ *
1029
+ * @throws :{@link TrackNameError} on any constraint violation.
1030
+ * @example
1031
+ * ```ts
1032
+ * const full = FullTrackName.tryNew('media/video', 'keyframe')
1033
+ * console.log(full.toString()) // media/video:6b65796672616d65
1034
+ * ```
1035
+ */
1036
+ static tryNew(namespace: string | Tuple, name: string | Uint8Array): FullTrackName;
1037
+ /**
1038
+ * Serialize to a frozen buffer: tuple (namespace) followed by length‑prefixed name bytes.
1039
+ * Consumers needing raw bytes should call `.toUint8Array()` on the returned {@link FrozenByteBuffer}.
1040
+ */
1041
+ serialize(): FrozenByteBuffer;
1042
+ /**
1043
+ * Parse a serialized full track name. Performs the same validations as {@link FullTrackName.tryNew}.
1044
+ * The provided buffer's read cursor advances accordingly.
1045
+ * @throws :{@link TrackNameError} if constraints are violated.
1046
+ */
1047
+ static deserialize(buf: BaseByteBuffer): FullTrackName;
1048
+ }
1049
+ //#endregion
1050
+ //#region src/model/data/subgroup_object.d.ts
1051
+ declare class SubgroupObject {
1052
+ readonly properties: KeyValuePair[] | null;
1053
+ readonly objectStatus: ObjectStatus | null;
1054
+ readonly payload: Uint8Array | null;
1055
+ readonly objectId: bigint;
1056
+ private constructor();
1057
+ static newWithStatus(objectId: bigint | number, properties: KeyValuePair[] | null, objectStatus: ObjectStatus): SubgroupObject;
1058
+ static newWithPayload(objectId: bigint | number, properties: KeyValuePair[] | null, payload: Uint8Array): SubgroupObject;
1059
+ serialize(previousObjectId: bigint | undefined): FrozenByteBuffer;
1060
+ static deserialize(buf: BaseByteBuffer, hasProperties: boolean, previousObjectId: bigint | undefined): SubgroupObject;
1061
+ }
1062
+ //#endregion
1063
+ //#region src/model/data/object.d.ts
1064
+ declare class MoqtObject {
1065
+ readonly fullTrackName: FullTrackName;
1066
+ readonly publisherPriority: number;
1067
+ readonly objectForwardingPreference: ObjectForwardingPreference;
1068
+ readonly objectStatus: ObjectStatus;
1069
+ readonly properties: KeyValuePair[] | null;
1070
+ readonly payload: Uint8Array | null;
1071
+ readonly location: Location;
1072
+ readonly subgroupId: bigint | null;
1073
+ private constructor();
1074
+ get groupId(): bigint;
1075
+ get objectId(): bigint;
1076
+ getSubgroupHeaderType(containsEnd: boolean, useDefaultPriority?: boolean, firstObject?: boolean): SubgroupHeaderType;
1077
+ isDatagram(): boolean;
1078
+ isSubgroup(): boolean;
1079
+ isEndOfGroup(): boolean;
1080
+ isEndOfTrack(): boolean;
1081
+ hasPayload(): boolean;
1082
+ hasStatus(): boolean;
1083
+ static newWithPayload(fullTrackName: FullTrackName, location: Location, publisherPriority: number, objectForwardingPreference: ObjectForwardingPreference, subgroupId: bigint | number | null, properties: KeyValuePair[] | null, payload: Uint8Array): MoqtObject;
1084
+ static newWithStatus(fullTrackName: FullTrackName, location: Location, publisherPriority: number, objectForwardingPreference: ObjectForwardingPreference, subgroupId: bigint | number | null, properties: KeyValuePair[] | null, objectStatus: ObjectStatus): MoqtObject;
1085
+ /**
1086
+ * Create a MoqtObject from a Datagram (Draft-16).
1087
+ * @param datagram - The received Datagram.
1088
+ * @param fullTrackName - The resolved full track name.
1089
+ * @param defaultPriority - The default publisher priority from the control message (used when DEFAULT_PRIORITY bit is set).
1090
+ */
1091
+ static fromDatagram(datagram: Datagram, fullTrackName: FullTrackName, defaultPriority?: number): MoqtObject;
1092
+ /**
1093
+ * Returns the endOfGroup flag from the source Datagram.
1094
+ * This is separate from ObjectStatus.EndOfGroup - the flag indicates
1095
+ * this is the last object in the group even with Normal status.
1096
+ */
1097
+ static isDatagramEndOfGroup(datagram: Datagram): boolean;
1098
+ static fromFetchObject(fetchObject: FetchObject, fullTrackName: FullTrackName): MoqtObject;
1099
+ static fromSubgroupObject(subgroupObject: SubgroupObject, groupId: bigint | number, publisherPriority: number | undefined, subgroupId: bigint | number | null, fullTrackName: FullTrackName): MoqtObject;
1100
+ /**
1101
+ * Convert to Datagram for wire transmission (Draft-16).
1102
+ * Automatically creates a payload or status Datagram based on the object's state.
1103
+ * @param trackAlias - The track alias to use.
1104
+ * @param endOfGroup - Whether this is the last object in the group (only for payload datagrams).
1105
+ * @param defaultPriority - If provided and matches this object's priority, the DEFAULT_PRIORITY bit is set.
1106
+ */
1107
+ tryIntoDatagram(trackAlias: bigint | number, endOfGroup?: boolean, defaultPriority?: number): Datagram;
1108
+ tryIntoFetchObject(): FetchObject;
1109
+ tryIntoSubgroupObject(): SubgroupObject;
1110
+ }
1111
+ //#endregion
1112
+ //#region src/model/data/subgroup_header.d.ts
1113
+ declare class SubgroupHeader {
1114
+ readonly type: SubgroupHeaderType;
1115
+ readonly publisherPriority: number | undefined;
1116
+ /**
1117
+ * Absent on the wire, and still unknown here, when the type says the Subgroup ID
1118
+ * is the first Object ID: that object has not been read yet at header time.
1119
+ * `resolveSubgroupId` fills it in, so consumers can read this rather than each
1120
+ * deriving it again.
1121
+ */
1122
+ subgroupId: bigint | undefined;
1123
+ readonly trackAlias: bigint;
1124
+ readonly groupId: bigint;
1125
+ constructor(type: SubgroupHeaderType, trackAlias: bigint | number, groupId: bigint | number, subgroupId: bigint | number | undefined, publisherPriority: number | undefined);
1126
+ serialize(): FrozenByteBuffer;
1127
+ static deserialize(buf: BaseByteBuffer): SubgroupHeader;
1128
+ /**
1129
+ * Name this subgroup from the first object read off its stream, for the header
1130
+ * type that defers the Subgroup ID to it. Ignored for every other type, and for
1131
+ * a header already named, so later objects on the stream cannot rename it.
1132
+ */
1133
+ resolveSubgroupId(firstObjectId: bigint): void;
1134
+ }
1135
+ //#endregion
1136
+ //#region src/model/data/request_id.d.ts
1137
+ /**
1138
+ * A bidirectional map between requestId (bigint) and full track names.
1139
+ * Used to efficiently look up either by requestId or by name, enforcing uniqueness.
1140
+ *
1141
+ * @public
1142
+ */
1143
+ declare class RequestIdMap {
1144
+ private requestIdToName;
1145
+ private nameToRequestId;
1146
+ /**
1147
+ * @public
1148
+ * Adds a mapping between a requestId and a full track name.
1149
+ *
1150
+ * @param requestId - The requestId to associate.
1151
+ * @param name - The full track name to associate.
1152
+ * @throws :{@link RequestIdError} if the requestId or name is already mapped to a different value.
1153
+ */
1154
+ addMapping(requestId: bigint, name: FullTrackName): void;
1155
+ /**
1156
+ * @public
1157
+ * Gets the full track name for a given requestId.
1158
+ *
1159
+ * @param requestId - The requestId to look up.
1160
+ * @returns The associated full track name.
1161
+ * @throws :{@link RequestIdError} if the requestId does not exist.
1162
+ */
1163
+ getNameByRequestId(requestId: bigint): FullTrackName;
1164
+ /**
1165
+ * @public
1166
+ * Gets the requestId for a given full track name.
1167
+ *
1168
+ * @param name - The full track name to look up.
1169
+ * @returns The associated requestId.
1170
+ * @throws :{@link RequestIdError} if the name does not exist.
1171
+ */
1172
+ getRequestIdByName(name: FullTrackName): bigint;
1173
+ /**
1174
+ * @public
1175
+ * Removes a mapping by requestId.
1176
+ *
1177
+ * @param requestId - The requestId to remove.
1178
+ * @returns The removed full track name, or undefined if not found.
1179
+ */
1180
+ removeMappingByRequestId(requestId: bigint): FullTrackName | undefined;
1181
+ /**
1182
+ * @public
1183
+ * Removes a mapping by full track name.
1184
+ *
1185
+ * @param name - The full track name to remove.
1186
+ * @returns The removed requestId, or undefined if not found.
1187
+ */
1188
+ removeMappingByName(name: FullTrackName): bigint | undefined;
1189
+ /**
1190
+ * @public
1191
+ * Checks if the map contains a given requestId.
1192
+ *
1193
+ * @param requestId - The requestId to check.
1194
+ * @returns True if the requestId exists, false otherwise.
1195
+ */
1196
+ containsRequestId(requestId: bigint): boolean;
1197
+ /**
1198
+ * @public
1199
+ * Checks if the map contains a given full track name.
1200
+ *
1201
+ * @param name - The full track name to check.
1202
+ * @returns True if the name exists, false otherwise.
1203
+ */
1204
+ containsName(name: FullTrackName): boolean;
1205
+ }
1206
+ //#endregion
1207
+ //#region src/model/data/header.d.ts
1208
+ type Header = FetchHeader | SubgroupHeader;
1209
+ declare namespace Header {
1210
+ function newFetch(...args: ConstructorParameters<typeof FetchHeader>): Header;
1211
+ function newSubgroup(...args: ConstructorParameters<typeof SubgroupHeader>): Header;
1212
+ function isFetch(header: Header): header is FetchHeader;
1213
+ function isSubgroup(header: Header): header is SubgroupHeader;
1214
+ function serialize(header: Header): FrozenByteBuffer;
1215
+ function deserialize(buf: BaseByteBuffer): Header;
1216
+ }
1217
+ //#endregion
1218
+ //#region src/model/common/byte_buffer.d.ts
1219
+ declare abstract class BaseByteBuffer {
1220
+ protected buf: Uint8Array;
1221
+ protected view: DataView;
1222
+ protected _offset: number;
1223
+ protected _checkpoint: number;
1224
+ constructor(buf: Uint8Array);
1225
+ get offset(): number;
1226
+ abstract get length(): number;
1227
+ get remaining(): number;
1228
+ /**
1229
+ * Save current read position for potential rollback
1230
+ */
1231
+ checkpoint(): void;
1232
+ /**
1233
+ * Restore read position to last checkpoint
1234
+ */
1235
+ restore(): void;
1236
+ toUint8Array(): Uint8Array;
1237
+ getU8(): number;
1238
+ getU16(): number;
1239
+ getVI(): bigint;
1240
+ countLeadingOnes(byte: number): number;
1241
+ firstByteValueBits(first: number, length: number): bigint;
1242
+ getNumberVI(): number;
1243
+ getBytes(len: number): Uint8Array;
1244
+ getLengthPrefixedBytes(): Uint8Array;
1245
+ getKeyValuePair(): KeyValuePair;
1246
+ getReasonPhrase(): ReasonPhrase;
1247
+ getLocation(): Location;
1248
+ getTuple(): Tuple;
1249
+ getFullTrackName(): FullTrackName;
1250
+ }
1251
+ declare class ByteBuffer extends BaseByteBuffer {
1252
+ private _length;
1253
+ constructor(initialSize?: number);
1254
+ get length(): number;
1255
+ /**
1256
+ * Clear all data and reset all positions
1257
+ */
1258
+ clear(): void;
1259
+ /**
1260
+ * Drop all data before current offset and reset positions
1261
+ * This is the key method for memory management - removes processed data
1262
+ */
1263
+ commit(): void;
1264
+ private ensureCapacity;
1265
+ putU8(v: number): void;
1266
+ putU16(v: number): void;
1267
+ /**
1268
+ /**
1269
+ * Encode a MOQT draft-18 varint using the minimal length.
1270
+ * See section 1.4.1 https://datatracker.ietf.org/doc/draft-ietf-moq-transport/
1271
+ */
1272
+ putVI(v: bigint | number): void;
1273
+ putBytes(src: Uint8Array): void;
1274
+ putLengthPrefixedBytes(src: Uint8Array): void;
1275
+ putKeyValuePair(pair: KeyValuePair): void;
1276
+ putReasonPhrase(reason: ReasonPhrase): void;
1277
+ toUint8Array(): Uint8Array;
1278
+ freeze(): FrozenByteBuffer;
1279
+ putLocation(loc: Location): void;
1280
+ putTuple(tuple: Tuple): void;
1281
+ putFullTrackName(fullTrackName: FullTrackName): void;
1282
+ }
1283
+ declare class FrozenByteBuffer extends BaseByteBuffer {
1284
+ constructor(buf: Uint8Array);
1285
+ get length(): number;
1286
+ }
1287
+ //#endregion
1288
+ //#region src/model/control/publish_blocked.d.ts
1289
+ /**
1290
+ * @public
1291
+ * PUBLISH_BLOCKED (0xF): a publisher tells the peer it cannot send the PUBLISH that
1292
+ * would start a subscription to a track under a SUBSCRIBE_TRACKS namespace, because it
1293
+ * is blocked by the peer's bidirectional stream limit. It MUST NOT send PUBLISH for
1294
+ * that track until the limit lifts (§10.20).
1295
+ *
1296
+ * Sent on the SUBSCRIBE_TRACKS response stream, so only the namespace suffix after that
1297
+ * subscription's prefix is carried.
1298
+ */
1299
+ declare class PublishBlocked {
1300
+ readonly trackNamespaceSuffix: Tuple;
1301
+ readonly trackName: Uint8Array;
1302
+ constructor(trackNamespaceSuffix: Tuple, trackName: Uint8Array);
1303
+ getType(): ControlMessageType;
1304
+ serialize(): FrozenByteBuffer;
1305
+ static parsePayload(buf: BaseByteBuffer): PublishBlocked;
1306
+ }
1307
+ //#endregion
1308
+ //#region src/model/parameter/constant.d.ts
1309
+ /**
1310
+ * Copyright 2026 The MOQtail Authors
1311
+ *
1312
+ * Licensed under the Apache License, Version 2.0 (the "License");
1313
+ * you may not use this file except in compliance with the License.
1314
+ * You may obtain a copy of the License at
1315
+ *
1316
+ * http://www.apache.org/licenses/LICENSE-2.0
1317
+ *
1318
+ * Unless required by applicable law or agreed to in writing, software
1319
+ * distributed under the License is distributed on an "AS IS" BASIS,
1320
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1321
+ * See the License for the specific language governing permissions and
1322
+ * limitations under the License.
1323
+ */
1324
+ declare enum SetupOptionType {
1325
+ Path = 1,
1326
+ AuthorizationToken = 3,
1327
+ MaxAuthTokenCacheSize = 4,
1328
+ /** Raw-QUIC only. Client-only; MUST NOT be sent over WebTransport (draft-18 §10.3.1.1). */
1329
+ Authority = 5,
1330
+ MoqtImplementation = 7,
1331
+ /**
1332
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so this
1333
+ * codepoint is absent from the registry the conformance fixture tracks. It sits in the
1334
+ * 0x07-0x7F range of this space, which that registry leaves free.
1335
+ */
1336
+ SstsAlgorithms = 9
1337
+ }
1338
+ declare function setupOptionTypeFromNumber(value: number): SetupOptionType;
1339
+ declare enum MessageParameterType {
1340
+ ObjectDeliveryTimeout = 2,
1341
+ AuthorizationToken = 3,
1342
+ RendezvousTimeout = 4,
1343
+ SubgroupDeliveryTimeout = 6,
1344
+ Expires = 8,
1345
+ LargestObject = 9,
1346
+ FillTimeout = 10,
1347
+ Forward = 16,
1348
+ SubscriberPriority = 32,
1349
+ SubscriptionFilter = 33,
1350
+ GroupOrder = 34,
1351
+ NewGroupRequest = 50,
1352
+ /**
1353
+ * Registered codepoint with no typed parameter yet: its consumer is REQUEST_UPDATE for
1354
+ * SUBSCRIBE_TRACKS (TS-11), and the value is a Track Namespace tuple rather than the
1355
+ * varint its even Type implies.
1356
+ */
1357
+ TrackNamespacePrefix = 52,
1358
+ /**
1359
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so this
1360
+ * codepoint is absent from the registry the conformance fixture tracks; see its
1361
+ * `local_extensions`.
1362
+ */
1363
+ SwitchingSetAssignment = 65
1364
+ }
1365
+ declare function messageParameterTypeFromNumber(value: bigint | number): MessageParameterType;
1366
+ declare enum TokenAliasType {
1367
+ Delete = 0,
1368
+ Register = 1,
1369
+ UseAlias = 2,
1370
+ UseValue = 3
1371
+ }
1372
+ declare function tokenAliasTypeFromNumber(value: number): TokenAliasType;
1373
+ //#endregion
1374
+ //#region src/model/parameter/parameter.d.ts
1375
+ interface Parameter {
1376
+ toKeyValuePair(): KeyValuePair;
1377
+ }
1378
+ //#endregion
1379
+ //#region src/model/parameter/common/authorization_token.d.ts
1380
+ type AuthTokenVariant = {
1381
+ aliasType: TokenAliasType.Delete;
1382
+ tokenAlias: bigint;
1383
+ } | {
1384
+ aliasType: TokenAliasType.Register;
1385
+ tokenAlias: bigint;
1386
+ tokenType: bigint;
1387
+ tokenValue: Uint8Array;
1388
+ } | {
1389
+ aliasType: TokenAliasType.UseAlias;
1390
+ tokenAlias: bigint;
1391
+ } | {
1392
+ aliasType: TokenAliasType.UseValue;
1393
+ tokenType: bigint;
1394
+ tokenValue: Uint8Array;
1395
+ };
1396
+ declare class AuthorizationToken implements Parameter {
1397
+ readonly variant: AuthTokenVariant;
1398
+ static readonly TYPE = MessageParameterType.AuthorizationToken;
1399
+ private constructor();
1400
+ static newDelete(tokenAlias: bigint | number): AuthorizationToken;
1401
+ static newRegister(tokenAlias: bigint | number, tokenType: bigint | number, tokenValue: Uint8Array): AuthorizationToken;
1402
+ static newUseAlias(tokenAlias: bigint | number): AuthorizationToken;
1403
+ static newUseValue(tokenType: bigint | number, tokenValue: Uint8Array): AuthorizationToken;
1404
+ toKeyValuePair(): KeyValuePair;
1405
+ static fromKeyValuePair(pair: KeyValuePair): AuthorizationToken | undefined;
1406
+ }
1407
+ //#endregion
1408
+ //#region src/model/parameter/message/fill_timeout.d.ts
1409
+ /**
1410
+ * Duration in milliseconds a relay SHOULD wait for objects it does not yet hold before
1411
+ * ending the FETCH. FETCH only (§10.2.5).
1412
+ */
1413
+ declare class FillTimeout implements Parameter {
1414
+ readonly timeout: bigint;
1415
+ static readonly TYPE = MessageParameterType.FillTimeout;
1416
+ constructor(timeout: bigint);
1417
+ toKeyValuePair(): KeyValuePair;
1418
+ static fromKeyValuePair(pair: KeyValuePair): FillTimeout | undefined;
1419
+ }
1420
+ //#endregion
1421
+ //#region src/model/parameter/message/object_delivery_timeout.d.ts
1422
+ /**
1423
+ * Duration in milliseconds the relay SHOULD continue to attempt forwarding an Object.
1424
+ * A value of 0 means no timeout is set (§8).
1425
+ * This parameter is subscription-specific and SHOULD NOT be forwarded upstream
1426
+ * by a relay serving multiple subscriptions for the same track.
1427
+ */
1428
+ declare class ObjectDeliveryTimeout implements Parameter {
1429
+ readonly timeout: bigint;
1430
+ static readonly TYPE = MessageParameterType.ObjectDeliveryTimeout;
1431
+ constructor(timeout: bigint);
1432
+ toKeyValuePair(): KeyValuePair;
1433
+ static fromKeyValuePair(pair: KeyValuePair): ObjectDeliveryTimeout | undefined;
1434
+ }
1435
+ //#endregion
1436
+ //#region src/model/parameter/message/rendezvous_timeout.d.ts
1437
+ /**
1438
+ * Duration in milliseconds a relay SHOULD wait for a publisher of a track that has none
1439
+ * before answering the SUBSCRIBE. SUBSCRIBE only (§10.2.6).
1440
+ */
1441
+ declare class RendezvousTimeout implements Parameter {
1442
+ readonly timeout: bigint;
1443
+ static readonly TYPE = MessageParameterType.RendezvousTimeout;
1444
+ constructor(timeout: bigint);
1445
+ toKeyValuePair(): KeyValuePair;
1446
+ static fromKeyValuePair(pair: KeyValuePair): RendezvousTimeout | undefined;
1447
+ }
1448
+ //#endregion
1449
+ //#region src/model/parameter/message/subgroup_delivery_timeout.d.ts
1450
+ /**
1451
+ * Duration in milliseconds the relay SHOULD continue to attempt forwarding a Subgroup.
1452
+ * A value of 0 means no timeout is set (§8).
1453
+ */
1454
+ declare class SubgroupDeliveryTimeout implements Parameter {
1455
+ readonly timeout: bigint;
1456
+ static readonly TYPE = MessageParameterType.SubgroupDeliveryTimeout;
1457
+ constructor(timeout: bigint);
1458
+ toKeyValuePair(): KeyValuePair;
1459
+ static fromKeyValuePair(pair: KeyValuePair): SubgroupDeliveryTimeout | undefined;
1460
+ }
1461
+ //#endregion
1462
+ //#region src/model/parameter/message/expires.d.ts
1463
+ /**
1464
+ * Time in milliseconds after which the sender will terminate the subscription.
1465
+ * A value of 0 means the subscription does not expire or expires at an unknown time.
1466
+ * The receiver can extend the subscription by sending a REQUEST_UPDATE.
1467
+ */
1468
+ declare class Expires implements Parameter {
1469
+ readonly expires: bigint;
1470
+ static readonly TYPE = MessageParameterType.Expires;
1471
+ constructor(expires: bigint);
1472
+ toKeyValuePair(): KeyValuePair;
1473
+ static fromKeyValuePair(pair: KeyValuePair): Expires | undefined;
1474
+ }
1475
+ //#endregion
1476
+ //#region src/model/parameter/message/forward.d.ts
1477
+ /**
1478
+ * Forwarding state for affected subscriptions.
1479
+ * Allowed wire values: 0 (don't forward) or 1 (forward).
1480
+ * Any other value is a PROTOCOL_VIOLATION.
1481
+ * Default (when omitted) is 1 (forward).
1482
+ */
1483
+ declare class Forward implements Parameter {
1484
+ readonly forward: boolean;
1485
+ static readonly TYPE = MessageParameterType.Forward;
1486
+ constructor(forward: boolean);
1487
+ toKeyValuePair(): KeyValuePair;
1488
+ static fromKeyValuePair(pair: KeyValuePair): Forward | undefined;
1489
+ }
1490
+ //#endregion
1491
+ //#region src/model/parameter/message/group_order_param.d.ts
1492
+ /**
1493
+ * How to prioritize Objects from different groups (Ascending=0x1 or Descending=0x2).
1494
+ * Values outside this range are a PROTOCOL_VIOLATION (Original/0x0 is not a valid wire value).
1495
+ * If omitted from SUBSCRIBE, the publisher's track preference is used.
1496
+ * If omitted from FETCH, Ascending (0x1) is used.
1497
+ */
1498
+ declare class GroupOrderParam implements Parameter {
1499
+ readonly order: GroupOrder.Ascending | GroupOrder.Descending;
1500
+ static readonly TYPE = MessageParameterType.GroupOrder;
1501
+ constructor(order: GroupOrder.Ascending | GroupOrder.Descending);
1502
+ toKeyValuePair(): KeyValuePair;
1503
+ static fromKeyValuePair(pair: KeyValuePair): GroupOrderParam | undefined;
1504
+ }
1505
+ //#endregion
1506
+ //#region src/model/common/grease.d.ts
1507
+ /**
1508
+ * Copyright 2026 The MOQtail Authors
1509
+ *
1510
+ * Licensed under the Apache License, Version 2.0 (the "License");
1511
+ * you may not use this file except in compliance with the License.
1512
+ * You may obtain a copy of the License at
1513
+ *
1514
+ * http://www.apache.org/licenses/LICENSE-2.0
1515
+ *
1516
+ * Unless required by applicable law or agreed to in writing, software
1517
+ * distributed under the License is distributed on an "AS IS" BASIS,
1518
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1519
+ * See the License for the specific language governing permissions and
1520
+ * limitations under the License.
1521
+ */
1522
+ /**
1523
+ * GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
1524
+ * several registries (Setup Options, Properties, error codes) so peers can emit them
1525
+ * to exercise unknown-value handling. Receivers treat them like any other unknown
1526
+ * value: ignore, never fatal.
1527
+ */
1528
+ /** Step between successive GREASE values. */
1529
+ declare const GREASE_STEP = 127n;
1530
+ /** The smallest GREASE value (N = 0). */
1531
+ declare const GREASE_BASE = 157n;
1532
+ /**
1533
+ * @public
1534
+ * True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
1535
+ * non-negative `N`.
1536
+ */
1537
+ declare function isGrease(value: bigint | number): boolean;
1538
+ /**
1539
+ * @public
1540
+ * The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
1541
+ * varint can carry (the pattern is capped at `0x3fffffffffffffde`).
1542
+ */
1543
+ declare function greaseValue(n: bigint | number): bigint | undefined;
1544
+ //#endregion
1545
+ //#region src/model/common/moqt_url.d.ts
1546
+ /**
1547
+ * Copyright 2026 The MOQtail Authors
1548
+ *
1549
+ * Licensed under the Apache License, Version 2.0 (the "License");
1550
+ * you may not use this file except in compliance with the License.
1551
+ * You may obtain a copy of the License at
1552
+ *
1553
+ * http://www.apache.org/licenses/LICENSE-2.0
1554
+ *
1555
+ * Unless required by applicable law or agreed to in writing, software
1556
+ * distributed under the License is distributed on an "AS IS" BASIS,
1557
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1558
+ * See the License for the specific language governing permissions and
1559
+ * limitations under the License.
1560
+ */
1561
+ /**
1562
+ * @public
1563
+ * A `moqt://` fragment, `#<type>:<value>`. Processed locally and never sent to the
1564
+ * server (§3.1).
1565
+ */
1566
+ interface MoqtFragment {
1567
+ kind: string;
1568
+ value: string;
1569
+ }
1570
+ /**
1571
+ * @public
1572
+ * A parsed `moqt://authority/path[?query][#fragment]` URI (draft-18 §3.1).
1573
+ *
1574
+ * `moqt-URI = "moqt" "://" authority path-abempty [ "?" query ]`, with an optional
1575
+ * local-only fragment. `authority` is `host[:port]`; `path` keeps its leading `/`
1576
+ * (empty when absent); `query` excludes the `?`.
1577
+ *
1578
+ * This is the TypeScript twin of `MoqtUrl` in `apps/client/src/connection.rs`; the two
1579
+ * must agree on what a given URL means.
1580
+ */
1581
+ declare class MoqtUrl {
1582
+ readonly authority: string;
1583
+ readonly path: string;
1584
+ readonly query: string | undefined;
1585
+ readonly fragment: MoqtFragment | undefined;
1586
+ constructor(authority: string, path: string, query: string | undefined, fragment: MoqtFragment | undefined);
1587
+ static parse(input: string): MoqtUrl;
1588
+ /** The `path[?query]` string carried in the PATH setup option on native QUIC. */
1589
+ pathAndQuery(): string;
1590
+ /** The equivalent `https://` URL for WebTransport, dropping the local fragment. */
1591
+ toHttps(): string;
1592
+ }
1593
+ /**
1594
+ * @public
1595
+ * Resolves a session URL to the URL WebTransport is actually opened with.
1596
+ *
1597
+ * `moqt://` is the scheme callers are meant to use (§3.1); it is mapped to the
1598
+ * equivalent `https://` here because the browser's WebTransport constructor only speaks
1599
+ * HTTP/3. An `https://` input is passed through unchanged so existing callers keep
1600
+ * working. Over WebTransport the authority and path travel in the HTTP CONNECT request,
1601
+ * so neither is repeated as a setup option -- AUTHORITY over WebTransport is a protocol
1602
+ * violation, and PATH would be redundant.
1603
+ */
1604
+ declare function resolveTransportUrl(url: string | URL): {
1605
+ transportUrl: string;
1606
+ moqtUrl: MoqtUrl | undefined;
1607
+ };
1608
+ //#endregion
1609
+ //#region src/model/common/redirect.d.ts
1610
+ /**
1611
+ * @public
1612
+ * Directs the peer to retry a request at a different URI and/or for a different Full
1613
+ * Track Name (§10.6.1). Carried by a REQUEST_ERROR whose code is `REDIRECT`.
1614
+ */
1615
+ declare class Redirect {
1616
+ /** Empty, together with an empty {@link Redirect.trackName}, means reuse the original request's track. */
1617
+ readonly trackNamespace: Tuple;
1618
+ /** Empty for namespace-scoped requests, which have no track name to redirect. */
1619
+ readonly trackName: Uint8Array;
1620
+ /** Undefined means reuse the current session's URI. */
1621
+ readonly connectUri: string | undefined;
1622
+ constructor(connectUri: string | undefined, /** Empty, together with an empty {@link Redirect.trackName}, means reuse the original request's track. */
1623
+
1624
+ trackNamespace: Tuple, /** Empty for namespace-scoped requests, which have no track name to redirect. */
1625
+
1626
+ trackName: Uint8Array);
1627
+ /** True when the redirect names no track of its own, so the original request's track carries over. */
1628
+ get keepsOriginalTrack(): boolean;
1629
+ serialize(): FrozenByteBuffer;
1630
+ static deserialize(buf: BaseByteBuffer): Redirect;
1631
+ }
1632
+ //#endregion
1633
+ //#region src/model/parameter/message/largest_object.d.ts
1634
+ /**
1635
+ * The largest Location in the Track observed by the sending endpoint.
1636
+ * If omitted from a message, the sending endpoint has not published or
1637
+ * received any Objects in the Track.
1638
+ */
1639
+ declare class LargestObject implements Parameter {
1640
+ readonly location: Location;
1641
+ static readonly TYPE = MessageParameterType.LargestObject;
1642
+ constructor(location: Location);
1643
+ toKeyValuePair(): KeyValuePair;
1644
+ static fromKeyValuePair(pair: KeyValuePair): LargestObject | undefined;
1645
+ }
1646
+ //#endregion
1647
+ //#region src/model/parameter/message/new_group_request.d.ts
1648
+ /**
1649
+ * The largest Group ID in the Track known by the subscriber, plus 1.
1650
+ * A value of 0 indicates the subscriber has no Group information for the Track.
1651
+ * Only valid for tracks with the DYNAMIC_GROUPS property (value 1).
1652
+ */
1653
+ declare class NewGroupRequest implements Parameter {
1654
+ readonly group: bigint;
1655
+ static readonly TYPE = MessageParameterType.NewGroupRequest;
1656
+ constructor(group: bigint);
1657
+ toKeyValuePair(): KeyValuePair;
1658
+ static fromKeyValuePair(pair: KeyValuePair): NewGroupRequest | undefined;
1659
+ }
1660
+ //#endregion
1661
+ //#region src/model/parameter/message/switching_set_assignment.d.ts
1662
+ /**
1663
+ * Assigns a subscription to an SSTS (sender-side track switching) switching
1664
+ * set. Carried on SUBSCRIBE and on the PUBLISH_OK of a pushed track.
1665
+ *
1666
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so
1667
+ * this parameter has no codepoint in the registry the conformance fixture
1668
+ * tracks (`dev/conformance/draft18`) and is never asserted against it. Id 0 is
1669
+ * the default allocation every implementation runs; other ids select an
1670
+ * algorithm specific to one implementation.
1671
+ */
1672
+ declare class SwitchingSetAssignment implements Parameter {
1673
+ readonly switchingSetId: bigint;
1674
+ readonly algorithmId: bigint;
1675
+ readonly throughputThresholdKbps: bigint;
1676
+ /** Relative bandwidth weight among same-rank sets, 1 through 10. */
1677
+ readonly setThroughputWeight: bigint;
1678
+ /** 0 pauses SSTS for the set; switching activates once the number of assigned tracks reaches this value. */
1679
+ readonly activateSwitching: bigint;
1680
+ /** Degradation priority; lower values are protected first. Default 0. */
1681
+ readonly setRank: number;
1682
+ static readonly TYPE = MessageParameterType.SwitchingSetAssignment;
1683
+ constructor(switchingSetId: bigint, algorithmId: bigint, throughputThresholdKbps: bigint, /** Relative bandwidth weight among same-rank sets, 1 through 10. */
1684
+
1685
+ setThroughputWeight: bigint, /** 0 pauses SSTS for the set; switching activates once the number of assigned tracks reaches this value. */
1686
+
1687
+ activateSwitching: bigint, /** Degradation priority; lower values are protected first. Default 0. */
1688
+
1689
+ setRank?: number);
1690
+ toKeyValuePair(): KeyValuePair;
1691
+ static fromKeyValuePair(pair: KeyValuePair): SwitchingSetAssignment | undefined;
1692
+ }
1693
+ //#endregion
1694
+ //#region src/model/parameter/message/subscriber_priority.d.ts
1695
+ /**
1696
+ * Priority of a subscription relative to others in the same session.
1697
+ * Lower numbers have higher priority. Range: 0-255.
1698
+ * Values outside this range are a PROTOCOL_VIOLATION.
1699
+ * Default (when omitted from SUBSCRIBE, PUBLISH_OK, or FETCH) is 128.
1700
+ */
1701
+ declare class SubscriberPriority implements Parameter {
1702
+ readonly priority: number;
1703
+ static readonly TYPE = MessageParameterType.SubscriberPriority;
1704
+ constructor(priority: number);
1705
+ toKeyValuePair(): KeyValuePair;
1706
+ static fromKeyValuePair(pair: KeyValuePair): SubscriberPriority | undefined;
1707
+ }
1708
+ //#endregion
1709
+ //#region src/model/parameter/message/subscription_filter.d.ts
1710
+ /**
1711
+ * Length-prefixed Subscription Filter specifying what objects the subscriber wants.
1712
+ * If omitted from SUBSCRIBE or PUBLISH_OK, the subscription is unfiltered (LatestObject).
1713
+ * If omitted from REQUEST_UPDATE, the value is unchanged.
1714
+ */
1715
+ declare class SubscriptionFilter implements Parameter {
1716
+ readonly filterType: FilterType;
1717
+ readonly startLocation?: Location | undefined;
1718
+ readonly endGroup?: bigint | undefined;
1719
+ static readonly TYPE = MessageParameterType.SubscriptionFilter;
1720
+ constructor(filterType: FilterType, startLocation?: Location | undefined, endGroup?: bigint | undefined);
1721
+ toKeyValuePair(): KeyValuePair;
1722
+ static fromKeyValuePair(pair: KeyValuePair): SubscriptionFilter | undefined;
1723
+ }
1724
+ //#endregion
1725
+ //#region src/model/parameter/message_parameter.d.ts
1726
+ type MessageParameter = ObjectDeliveryTimeout | SubgroupDeliveryTimeout | RendezvousTimeout | FillTimeout | AuthorizationToken | Expires | LargestObject | Forward | SubscriberPriority | GroupOrderParam | SubscriptionFilter | NewGroupRequest | SwitchingSetAssignment;
1727
+ declare namespace MessageParameter {
1728
+ /**
1729
+ * Parses a single KeyValuePair into a MessageParameter.
1730
+ * Returns undefined for unrecognized parameter types (be forgiving).
1731
+ * Still throws ProtocolViolationError for known types with invalid values.
1732
+ */
1733
+ function fromKeyValuePair(pair: KeyValuePair): MessageParameter | undefined;
1734
+ function toKeyValuePair(param: MessageParameter): KeyValuePair;
1735
+ function isObjectDeliveryTimeout(param: MessageParameter): param is ObjectDeliveryTimeout;
1736
+ function isSubgroupDeliveryTimeout(param: MessageParameter): param is SubgroupDeliveryTimeout;
1737
+ function isRendezvousTimeout(param: MessageParameter): param is RendezvousTimeout;
1738
+ function isFillTimeout(param: MessageParameter): param is FillTimeout;
1739
+ function isAuthorizationToken(param: MessageParameter): param is AuthorizationToken;
1740
+ function isExpires(param: MessageParameter): param is Expires;
1741
+ function isLargestObject(param: MessageParameter): param is LargestObject;
1742
+ function isForward(param: MessageParameter): param is Forward;
1743
+ function isSubscriberPriority(param: MessageParameter): param is SubscriberPriority;
1744
+ function isGroupOrderParam(param: MessageParameter): param is GroupOrderParam;
1745
+ function isSwitchingSetAssignment(param: MessageParameter): param is SwitchingSetAssignment;
1746
+ /** The negotiated Group Order, or {@link (GroupOrder:enum).Original} when unparameterized. */
1747
+ function groupOrderOf(params: readonly MessageParameter[]): GroupOrder;
1748
+ function isSubscriptionFilter(param: MessageParameter): param is SubscriptionFilter;
1749
+ function isNewGroupRequest(param: MessageParameter): param is NewGroupRequest;
1750
+ }
1751
+ /**
1752
+ * Builder for constructing a list of MessageParameters.
1753
+ * Mirrors the SetupOptions builder pattern.
1754
+ */
1755
+ declare class MessageParameters {
1756
+ private params;
1757
+ add(param: MessageParameter): this;
1758
+ addObjectDeliveryTimeout(timeout: bigint | number): this;
1759
+ addSubgroupDeliveryTimeout(timeout: bigint | number): this;
1760
+ addRendezvousTimeout(timeout: bigint | number): this;
1761
+ addFillTimeout(timeout: bigint | number): this;
1762
+ addAuthorizationToken(token: AuthorizationToken): this;
1763
+ addExpires(expires: bigint | number): this;
1764
+ addForward(forward: boolean): this;
1765
+ addSubscriberPriority(priority: number): this;
1766
+ addGroupOrder(order: GroupOrderParam['order']): this;
1767
+ addSubscriptionFilter(filter: SubscriptionFilter): this;
1768
+ addNewGroupRequest(group: bigint | number): this;
1769
+ build(): MessageParameter[];
1770
+ /**
1771
+ * Parses an array of KeyValuePairs into a list of MessageParameters.
1772
+ * Unrecognized parameter types are silently skipped.
1773
+ * Known parameter types with invalid values still throw ProtocolViolationError.
1774
+ */
1775
+ static fromKeyValuePairs(pairs: KeyValuePair[]): MessageParameter[];
1776
+ }
1777
+ /**
1778
+ * Serializes a list of message-parameter KVPs, delta-encoding the Types.
1779
+ * Mirrors {@link serializeKvpList} but honours per-parameter value encodings.
1780
+ */
1781
+ declare function serializeMessageParameterKvps(items: KeyValuePair[]): FrozenByteBuffer;
1782
+ /**
1783
+ * Reads exactly `count` delta-encoded message-parameter KVPs.
1784
+ * Mirrors {@link deserializeKvpList} but honours per-parameter value encodings.
1785
+ */
1786
+ declare function deserializeMessageParameterKvps(buf: BaseByteBuffer, count: number | bigint): KeyValuePair[];
1787
+ /**
1788
+ * Applies a set of parameter updates to an existing parameter list.
1789
+ * For each update, replaces the matching parameter (by wire type value) or appends it.
1790
+ * Per spec: "If omitted from REQUEST_UPDATE/SUBSCRIBE_UPDATE, the value is unchanged."
1791
+ */
1792
+ declare function applyMessageParameterUpdate(current: MessageParameter[], updates: MessageParameter[]): void;
1793
+ //#endregion
1794
+ //#region src/model/control/publish_namespace.d.ts
1795
+ /**
1796
+ * Represents a protocol PublishNamespace message, used to announce a track and its parameters.
1797
+ *
1798
+ * @public
1799
+ */
1800
+ declare class PublishNamespace {
1801
+ readonly requestId: bigint;
1802
+ readonly trackNamespace: Tuple;
1803
+ readonly parameters: MessageParameter[];
1804
+ /**
1805
+ * @public
1806
+ * Constructs a PublishNamespace message.
1807
+ *
1808
+ * @param requestId - The request ID for this publish namespace message.
1809
+ * @param trackNamespace - The track namespace as a Tuple.
1810
+ * @param parameters - The list of strongly-typed message parameters for the track.
1811
+ */
1812
+ constructor(requestId: bigint, trackNamespace: Tuple, parameters: MessageParameter[]);
1813
+ /**
1814
+ * @public
1815
+ * Gets the message type for this PublishNamespace message.
1816
+ *
1817
+ * @returns The ControlMessageType.PublishNamespace value.
1818
+ */
1819
+ getType(): ControlMessageType;
1820
+ /**
1821
+ * @public
1822
+ * Serializes the PublishNamespace message into a {@link FrozenByteBuffer}.
1823
+ *
1824
+ * @returns The serialized buffer.
1825
+ * @throws :{@link LengthExceedsMaxError} If the payload exceeds 65535 bytes.
1826
+ */
1827
+ serialize(): FrozenByteBuffer;
1828
+ /**
1829
+ * @public
1830
+ * Parses a PublishNamespace message from the given buffer.
1831
+ *
1832
+ * @param buf - The buffer to parse from.
1833
+ * @returns The parsed PublishNamespace message.
1834
+ * @throws :{@link NotEnoughBytesError} If the buffer does not contain enough bytes.
1835
+ */
1836
+ static parsePayload(buf: BaseByteBuffer): PublishNamespace;
1837
+ }
1838
+ //#endregion
1839
+ //#region src/model/control/namespace.d.ts
1840
+ /**
1841
+ * @public
1842
+ * Represents a NAMESPACE message sent on a SUBSCRIBE_NAMESPACE bi-stream.
1843
+ * Carries the namespace suffix (fields after the subscriber's prefix).
1844
+ */
1845
+ declare class Namespace {
1846
+ readonly trackNamespaceSuffix: Tuple;
1847
+ constructor(trackNamespaceSuffix: Tuple);
1848
+ getType(): ControlMessageType;
1849
+ serialize(): FrozenByteBuffer;
1850
+ static parsePayload(buf: BaseByteBuffer): Namespace;
1851
+ }
1852
+ //#endregion
1853
+ //#region src/model/control/namespace_done.d.ts
1854
+ /**
1855
+ * @public
1856
+ * Represents a NAMESPACE_DONE message sent on a SUBSCRIBE_NAMESPACE bi-stream.
1857
+ * Signals that a previously announced namespace suffix is no longer available.
1858
+ */
1859
+ declare class NamespaceDone {
1860
+ readonly trackNamespaceSuffix: Tuple;
1861
+ constructor(trackNamespaceSuffix: Tuple);
1862
+ getType(): ControlMessageType;
1863
+ serialize(): FrozenByteBuffer;
1864
+ static parsePayload(buf: BaseByteBuffer): NamespaceDone;
1865
+ }
1866
+ //#endregion
1867
+ //#region src/model/control/setup.d.ts
1868
+ /**
1869
+ * The first message each endpoint sends on its control stream (draft-18 §10.3).
1870
+ *
1871
+ * Both peers send the same message; there are no separate client and server forms and
1872
+ * no version fields, since version negotiation happens over ALPN (§3.1). Replaces
1873
+ * CLIENT_SETUP / SERVER_SETUP.
1874
+ *
1875
+ * Some options are client-only (see {@link SetupOptionType}); whether a peer is
1876
+ * allowed to send a given option depends on which side it is and on the transport,
1877
+ * neither of which is knowable here, so that rule is enforced by the caller rather than
1878
+ * by this class.
1879
+ */
1880
+ declare class Setup {
1881
+ readonly setupOptions: KeyValuePair[];
1882
+ constructor(setupOptions: KeyValuePair[]);
1883
+ getType(): ControlMessageType;
1884
+ serialize(): FrozenByteBuffer;
1885
+ static parsePayload(buf: BaseByteBuffer): Setup;
1886
+ }
1887
+ //#endregion
1888
+ //#region src/model/control/fetch.d.ts
1889
+ declare class Fetch {
1890
+ readonly requestId: bigint;
1891
+ readonly typeAndProps: {
1892
+ readonly type: FetchType.Standalone;
1893
+ readonly props: {
1894
+ fullTrackName: FullTrackName;
1895
+ startLocation: Location;
1896
+ endLocation: Location;
1897
+ };
1898
+ } | {
1899
+ readonly type: FetchType.Relative;
1900
+ readonly props: {
1901
+ joiningRequestId: bigint;
1902
+ joiningStart: bigint;
1903
+ };
1904
+ } | {
1905
+ readonly type: FetchType.Absolute;
1906
+ readonly props: {
1907
+ joiningRequestId: bigint;
1908
+ joiningStart: bigint;
1909
+ };
1910
+ };
1911
+ readonly parameters: MessageParameter[];
1912
+ constructor(requestId: bigint, typeAndProps: {
1913
+ readonly type: FetchType.Standalone;
1914
+ readonly props: {
1915
+ fullTrackName: FullTrackName;
1916
+ startLocation: Location;
1917
+ endLocation: Location;
1918
+ };
1919
+ } | {
1920
+ readonly type: FetchType.Relative;
1921
+ readonly props: {
1922
+ joiningRequestId: bigint;
1923
+ joiningStart: bigint;
1924
+ };
1925
+ } | {
1926
+ readonly type: FetchType.Absolute;
1927
+ readonly props: {
1928
+ joiningRequestId: bigint;
1929
+ joiningStart: bigint;
1930
+ };
1931
+ }, parameters: MessageParameter[]);
1932
+ getType(): ControlMessageType;
1933
+ serialize(): FrozenByteBuffer;
1934
+ static parsePayload(buf: BaseByteBuffer): Fetch;
1935
+ }
1936
+ //#endregion
1937
+ //#region src/model/property/constant.d.ts
1938
+ /**
1939
+ * Copyright 2025 The MOQtail Authors
1940
+ *
1941
+ * Licensed under the Apache License, Version 2.0 (the "License");
1942
+ * you may not use this file except in compliance with the License.
1943
+ * You may obtain a copy of the License at
1944
+ *
1945
+ * http://www.apache.org/licenses/LICENSE-2.0
1946
+ *
1947
+ * Unless required by applicable law or agreed to in writing, software
1948
+ * distributed under the License is distributed on an "AS IS" BASIS,
1949
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1950
+ * See the License for the specific language governing permissions and
1951
+ * limitations under the License.
1952
+ */
1953
+ declare enum LOCPropertyId {
1954
+ Timestamp = 6,
1955
+ Timescale = 8,
1956
+ VideoFrameMarking = 10,
1957
+ AudioLevel = 12,
1958
+ VideoConfig = 13
1959
+ }
1960
+ declare enum TrackPropertyType {
1961
+ ObjectDeliveryTimeout = 2,
1962
+ MaxCacheDuration = 4,
1963
+ SubgroupDeliveryTimeout = 6,
1964
+ ImmutableProperties = 11,
1965
+ DefaultPublisherPriority = 14,
1966
+ DefaultPublisherGroupOrder = 34,
1967
+ DynamicGroups = 48,
1968
+ PriorGroupIdGap = 60,
1969
+ PriorObjectIdGap = 62
1970
+ }
1971
+ declare function locPropertyIdFromNumber(value: number): LOCPropertyId;
1972
+ /**
1973
+ * @public
1974
+ * A registration-policy range in the Property Type space. `to` is absent for the
1975
+ * open-ended top range.
1976
+ */
1977
+ interface PropertyRange {
1978
+ readonly from: bigint;
1979
+ readonly to?: bigint;
1980
+ }
1981
+ /**
1982
+ * @public
1983
+ * Registration-policy ranges for the Property Type space (§15.8).
1984
+ *
1985
+ * §2.5 gives the 1-byte application-specific range as `0x38-0x3F`; that is stale text
1986
+ * from before draft-18's varint change, which made the 1-byte space `0x00-0x7F`.
1987
+ * §15.8 is the correct table and is what these constants follow.
1988
+ */
1989
+ declare const PropertyRanges: {
1990
+ /** Standards Action or IESG Approval (1-byte encoding). */readonly StandardsAction: {
1991
+ readonly from: 0n;
1992
+ readonly to: 119n;
1993
+ }; /** Application-specific use, no registration permitted (1-byte encoding). */
1994
+ readonly AppSpecific1Byte: {
1995
+ readonly from: 120n;
1996
+ readonly to: 127n;
1997
+ }; /** Specification Required (2-byte encoding). */
1998
+ readonly SpecRequired: {
1999
+ readonly from: 128n;
2000
+ readonly to: 14335n;
2001
+ }; /** Application-specific use, no registration permitted (2-byte encoding). */
2002
+ readonly AppSpecific2Byte: {
2003
+ readonly from: 14336n;
2004
+ readonly to: 16383n;
2005
+ }; /** Mandatory Track Properties; Track scope only. */
2006
+ readonly MandatoryTrack: {
2007
+ readonly from: 16384n;
2008
+ readonly to: 32767n;
2009
+ }; /** First Come First Served begins here (open-ended). */
2010
+ readonly Fcfs: {
2011
+ readonly from: 32768n;
2012
+ };
2013
+ };
2014
+ /**
2015
+ * @public
2016
+ * True if a Property Type is reserved for application-specific use (either encoding-width
2017
+ * range), for which no IANA registration is permitted.
2018
+ */
2019
+ declare function isApplicationSpecificProperty(typeValue: bigint | number): boolean;
2020
+ //#endregion
2021
+ //#region src/model/property/track_property.d.ts
2022
+ /** A timeout of 0 means no timeout is set (§8), on this side as on the parameter side. */
2023
+ declare class ObjectDeliveryTimeoutProperty {
2024
+ readonly timeoutMs: bigint;
2025
+ static readonly TYPE = TrackPropertyType.ObjectDeliveryTimeout;
2026
+ constructor(timeoutMs: bigint);
2027
+ toKeyValuePair(): KeyValuePair;
2028
+ static fromKeyValuePair(pair: KeyValuePair): ObjectDeliveryTimeoutProperty | undefined;
2029
+ }
2030
+ declare class SubgroupDeliveryTimeoutProperty {
2031
+ readonly timeoutMs: bigint;
2032
+ static readonly TYPE = TrackPropertyType.SubgroupDeliveryTimeout;
2033
+ constructor(timeoutMs: bigint);
2034
+ toKeyValuePair(): KeyValuePair;
2035
+ static fromKeyValuePair(pair: KeyValuePair): SubgroupDeliveryTimeoutProperty | undefined;
2036
+ }
2037
+ declare class MaxCacheDurationProperty {
2038
+ readonly durationMs: bigint;
2039
+ static readonly TYPE = TrackPropertyType.MaxCacheDuration;
2040
+ constructor(durationMs: bigint);
2041
+ toKeyValuePair(): KeyValuePair;
2042
+ static fromKeyValuePair(pair: KeyValuePair): MaxCacheDurationProperty | undefined;
2043
+ }
2044
+ declare class ImmutablePropertiesTrackProperty {
2045
+ readonly properties: KeyValuePair[];
2046
+ static readonly TYPE = TrackPropertyType.ImmutableProperties;
2047
+ constructor(properties: KeyValuePair[]);
2048
+ toKeyValuePair(): KeyValuePair;
2049
+ static fromKeyValuePair(pair: KeyValuePair): ImmutablePropertiesTrackProperty | undefined;
2050
+ }
2051
+ declare class DefaultPublisherPriorityProperty {
2052
+ readonly priority: number;
2053
+ static readonly TYPE = TrackPropertyType.DefaultPublisherPriority;
2054
+ constructor(priority: number);
2055
+ toKeyValuePair(): KeyValuePair;
2056
+ static fromKeyValuePair(pair: KeyValuePair): DefaultPublisherPriorityProperty | undefined;
2057
+ }
2058
+ declare class DefaultPublisherGroupOrderProperty {
2059
+ readonly order: GroupOrder;
2060
+ static readonly TYPE = TrackPropertyType.DefaultPublisherGroupOrder;
2061
+ constructor(order: GroupOrder);
2062
+ toKeyValuePair(): KeyValuePair;
2063
+ static fromKeyValuePair(pair: KeyValuePair): DefaultPublisherGroupOrderProperty | undefined;
2064
+ }
2065
+ declare class DynamicGroupsProperty {
2066
+ readonly enabled: boolean;
2067
+ static readonly TYPE = TrackPropertyType.DynamicGroups;
2068
+ constructor(enabled: boolean);
2069
+ toKeyValuePair(): KeyValuePair;
2070
+ static fromKeyValuePair(pair: KeyValuePair): DynamicGroupsProperty | undefined;
2071
+ }
2072
+ declare class UnknownTrackProperty {
2073
+ readonly kvp: KeyValuePair;
2074
+ constructor(kvp: KeyValuePair);
2075
+ toKeyValuePair(): KeyValuePair;
2076
+ }
2077
+ type TrackProperty = ObjectDeliveryTimeoutProperty | SubgroupDeliveryTimeoutProperty | MaxCacheDurationProperty | ImmutablePropertiesTrackProperty | DefaultPublisherPriorityProperty | DefaultPublisherGroupOrderProperty | DynamicGroupsProperty | UnknownTrackProperty;
2078
+ declare namespace TrackProperty {
2079
+ function fromKeyValuePair(pair: KeyValuePair): TrackProperty;
2080
+ function toKeyValuePair(ext: TrackProperty): KeyValuePair;
2081
+ function deserializeAll(buf: BaseByteBuffer): TrackProperty[];
2082
+ function serializeInto(exts: TrackProperty[], payload: ByteBuffer): void;
2083
+ function isObjectDeliveryTimeout(ext: TrackProperty): ext is ObjectDeliveryTimeoutProperty;
2084
+ function isSubgroupDeliveryTimeout(ext: TrackProperty): ext is SubgroupDeliveryTimeoutProperty;
2085
+ function isMaxCacheDuration(ext: TrackProperty): ext is MaxCacheDurationProperty;
2086
+ function isImmutableProperties(ext: TrackProperty): ext is ImmutablePropertiesTrackProperty;
2087
+ function isDefaultPublisherPriority(ext: TrackProperty): ext is DefaultPublisherPriorityProperty;
2088
+ function isDefaultPublisherGroupOrder(ext: TrackProperty): ext is DefaultPublisherGroupOrderProperty;
2089
+ function isDynamicGroups(ext: TrackProperty): ext is DynamicGroupsProperty;
2090
+ function isUnknown(ext: TrackProperty): ext is UnknownTrackProperty;
2091
+ }
2092
+ //#endregion
2093
+ //#region src/model/control/fetch_ok.d.ts
2094
+ /**
2095
+ * FETCH_OK (0x18) keeps a body of its own rather than folding into REQUEST_OK, but like
2096
+ * every other response it carries no Request ID: the request stream it arrives on
2097
+ * identifies the request (§10.1).
2098
+ */
2099
+ declare class FetchOk {
2100
+ readonly endOfTrack: boolean;
2101
+ readonly endLocation: Location;
2102
+ readonly parameters: MessageParameter[];
2103
+ readonly trackProperties: TrackProperty[];
2104
+ constructor(endOfTrack: boolean, endLocation: Location, parameters: MessageParameter[], trackProperties?: TrackProperty[]);
2105
+ getType(): ControlMessageType;
2106
+ serialize(): FrozenByteBuffer;
2107
+ static parsePayload(buf: BaseByteBuffer): FetchOk;
2108
+ }
2109
+ //#endregion
2110
+ //#region src/model/control/goaway.d.ts
2111
+ /** §10.4: a longer New Session URI is a protocol violation. */
2112
+ declare const MAX_NEW_SESSION_URI_LENGTH = 8192;
2113
+ /**
2114
+ * GOAWAY (0x10) winds down a session, or — on a request stream — migrates that one
2115
+ * request (§10.4).
2116
+ */
2117
+ declare class GoAway {
2118
+ newSessionUri?: string | undefined;
2119
+ /**
2120
+ * Milliseconds the sender waits for graceful closure; 0 means no specific timeout.
2121
+ * On the control stream the sender closes the session with `GOAWAY_TIMEOUT` after it,
2122
+ * on a request stream it resets the stream with `GOING_AWAY`.
2123
+ */
2124
+ readonly timeout: bigint;
2125
+ /**
2126
+ * The smallest peer Request ID that was not or might not have been processed. Present
2127
+ * only on the control stream, so a GOAWAY migrating a single request omits it.
2128
+ */
2129
+ readonly requestId?: bigint | undefined;
2130
+ constructor(newSessionUri?: string, timeout?: bigint, requestId?: bigint);
2131
+ getType(): ControlMessageType;
2132
+ serialize(): FrozenByteBuffer;
2133
+ static parsePayload(buf: BaseByteBuffer): GoAway;
2134
+ }
2135
+ //#endregion
2136
+ //#region src/model/control/subscribe.d.ts
2137
+ declare class Subscribe {
2138
+ requestId: bigint;
2139
+ fullTrackName: FullTrackName;
2140
+ parameters: MessageParameter[];
2141
+ private constructor();
2142
+ static newNextGroupStart(requestId: bigint, fullTrackName: FullTrackName, parameters: MessageParameter[]): Subscribe;
2143
+ static newLatestObject(requestId: bigint, fullTrackName: FullTrackName, parameters: MessageParameter[]): Subscribe;
2144
+ static newAbsoluteStart(requestId: bigint, fullTrackName: FullTrackName, startLocation: Location, parameters: MessageParameter[]): Subscribe;
2145
+ static newAbsoluteRange(requestId: bigint, fullTrackName: FullTrackName, startLocation: Location, endGroup: bigint, parameters: MessageParameter[]): Subscribe;
2146
+ getType(): ControlMessageType;
2147
+ serialize(): FrozenByteBuffer;
2148
+ static parsePayload(buf: BaseByteBuffer): Subscribe;
2149
+ }
2150
+ //#endregion
2151
+ //#region src/model/control/publish_done.d.ts
2152
+ declare class PublishDone {
2153
+ readonly statusCode: PublishDoneStatusCode;
2154
+ readonly streamCount: bigint;
2155
+ readonly errorReason: ReasonPhrase;
2156
+ constructor(statusCode: PublishDoneStatusCode, streamCount: bigint, errorReason: ReasonPhrase);
2157
+ static new(statusCode: PublishDoneStatusCode, streamCount: bigint, errorReason: ReasonPhrase): PublishDone;
2158
+ getType(): ControlMessageType;
2159
+ serialize(): FrozenByteBuffer;
2160
+ static parsePayload(buf: BaseByteBuffer): PublishDone;
2161
+ }
2162
+ //#endregion
2163
+ //#region src/model/control/publish.d.ts
2164
+ declare class Publish {
2165
+ readonly requestId: bigint;
2166
+ readonly fullTrackName: FullTrackName;
2167
+ readonly trackAlias: bigint;
2168
+ readonly parameters: MessageParameter[];
2169
+ readonly trackProperties: TrackProperty[];
2170
+ constructor(requestId: bigint, fullTrackName: FullTrackName, trackAlias: bigint, parameters: MessageParameter[], trackProperties?: TrackProperty[]);
2171
+ getType(): ControlMessageType;
2172
+ serialize(): FrozenByteBuffer;
2173
+ static parsePayload(buf: BaseByteBuffer): Publish;
2174
+ }
2175
+ //#endregion
2176
+ //#region src/model/control/subscribe_ok.d.ts
2177
+ /**
2178
+ * SUBSCRIBE_OK (0x4) keeps a body of its own rather than folding into REQUEST_OK, but
2179
+ * like every other response it carries no Request ID: the request stream it arrives on
2180
+ * identifies the request (§10.1).
2181
+ */
2182
+ declare class SubscribeOk {
2183
+ trackAlias: bigint;
2184
+ parameters: MessageParameter[];
2185
+ trackProperties: TrackProperty[];
2186
+ private constructor();
2187
+ static create(trackAlias: bigint, parameters: MessageParameter[], trackProperties?: TrackProperty[]): SubscribeOk;
2188
+ getType(): ControlMessageType;
2189
+ serialize(): FrozenByteBuffer;
2190
+ static parsePayload(buf: BaseByteBuffer): SubscribeOk;
2191
+ }
2192
+ //#endregion
2193
+ //#region src/model/control/request_update.d.ts
2194
+ declare class RequestUpdate {
2195
+ requestId: bigint;
2196
+ parameters: MessageParameter[];
2197
+ constructor(requestId: bigint, parameters: MessageParameter[]);
2198
+ getType(): ControlMessageType;
2199
+ serialize(): FrozenByteBuffer;
2200
+ static parsePayload(buf: BaseByteBuffer): RequestUpdate;
2201
+ equals(other: RequestUpdate): boolean;
2202
+ }
2203
+ //#endregion
2204
+ //#region src/model/control/track_status.d.ts
2205
+ declare class TrackStatus {
2206
+ requestId: bigint;
2207
+ trackAlias: bigint;
2208
+ fullTrackName: FullTrackName;
2209
+ subscriberPriority: number;
2210
+ groupOrder: GroupOrder;
2211
+ forward: boolean;
2212
+ filterType: FilterType;
2213
+ startLocation: Location | undefined;
2214
+ endGroup: bigint | undefined;
2215
+ subscribeParameters: MessageParameter[];
2216
+ private constructor();
2217
+ static newNextGroupStart(requestId: bigint, trackAlias: bigint, fullTrackName: FullTrackName, subscriberPriority: number, groupOrder: GroupOrder, forward: boolean, subscribeParameters: MessageParameter[]): TrackStatus;
2218
+ static newLatestObject(requestId: bigint, trackAlias: bigint, fullTrackName: FullTrackName, subscriberPriority: number, groupOrder: GroupOrder, forward: boolean, subscribeParameters: MessageParameter[]): TrackStatus;
2219
+ static newAbsoluteStart(requestId: bigint, trackAlias: bigint, fullTrackName: FullTrackName, subscriberPriority: number, groupOrder: GroupOrder, forward: boolean, startLocation: Location, subscribeParameters: MessageParameter[]): TrackStatus;
2220
+ static newAbsoluteRange(requestId: bigint, trackAlias: bigint, fullTrackName: FullTrackName, subscriberPriority: number, groupOrder: GroupOrder, forward: boolean, startLocation: Location, endGroup: bigint, subscribeParameters: MessageParameter[]): TrackStatus;
2221
+ getType(): ControlMessageType;
2222
+ serialize(): FrozenByteBuffer;
2223
+ static parsePayload(buf: BaseByteBuffer): TrackStatus;
2224
+ }
2225
+ //#endregion
2226
+ //#region src/model/control/subscribe_namespace.d.ts
2227
+ declare class SubscribeNamespace {
2228
+ readonly requestId: bigint;
2229
+ readonly trackNamespacePrefix: Tuple;
2230
+ readonly parameters: MessageParameter[];
2231
+ constructor(requestId: bigint, trackNamespacePrefix: Tuple, parameters: MessageParameter[]);
2232
+ getType(): ControlMessageType;
2233
+ serialize(): FrozenByteBuffer;
2234
+ static parsePayload(buf: BaseByteBuffer): SubscribeNamespace;
2235
+ }
2236
+ //#endregion
2237
+ //#region src/model/control/subscribe_tracks.d.ts
2238
+ /**
2239
+ * SUBSCRIBE_TRACKS (0x51) asks for a PUBLISH for every track under a matching
2240
+ * namespace prefix, present and future (§10.19).
2241
+ *
2242
+ * Shares SUBSCRIBE_NAMESPACE's wire shape but has its own prefix-overlap space: the
2243
+ * two types may hold the same prefix, two of the same type may not.
2244
+ */
2245
+ declare class SubscribeTracks {
2246
+ readonly requestId: bigint;
2247
+ readonly trackNamespacePrefix: Tuple;
2248
+ readonly parameters: MessageParameter[];
2249
+ constructor(requestId: bigint, trackNamespacePrefix: Tuple, parameters: MessageParameter[]);
2250
+ getType(): ControlMessageType;
2251
+ serialize(): FrozenByteBuffer;
2252
+ static parsePayload(buf: BaseByteBuffer): SubscribeTracks;
2253
+ }
2254
+ //#endregion
2255
+ //#region src/model/control/switch.d.ts
2256
+ declare class Switch {
2257
+ requestId: bigint;
2258
+ fullTrackName: FullTrackName;
2259
+ subscriptionRequestId: bigint;
2260
+ parameters: KeyValuePair[];
2261
+ constructor(requestId: bigint, fullTrackName: FullTrackName, subscriptionRequestId: bigint, parameters: KeyValuePair[]);
2262
+ getType(): ControlMessageType;
2263
+ serialize(): FrozenByteBuffer;
2264
+ static parsePayload(buf: BaseByteBuffer): Switch;
2265
+ }
2266
+ //#endregion
2267
+ //#region src/model/control/request_ok.d.ts
2268
+ /**
2269
+ * @public
2270
+ * REQUEST_OK (0x7) answers PUBLISH, REQUEST_UPDATE, TRACK_STATUS, SUBSCRIBE_NAMESPACE,
2271
+ * SUBSCRIBE_TRACKS and PUBLISH_NAMESPACE. There is one wire type; the per-request-type
2272
+ * names (PUBLISH_OK, TRACK_STATUS_OK, ...) are shorthands for logging, not distinct
2273
+ * messages. SUBSCRIBE_OK (0x4) and FETCH_OK (0x18) do keep bodies of their own.
2274
+ *
2275
+ * It carries no Request ID: the request stream it arrives on identifies the request
2276
+ * (§10.1).
2277
+ */
2278
+ declare class RequestOk {
2279
+ readonly parameters: MessageParameter[];
2280
+ /**
2281
+ * Draft-18 Track Properties, which the trailing bytes of the payload carry with no
2282
+ * count of their own. Populated only in TRACK_STATUS_OK; empty for every other request
2283
+ * type — see {@link RequestOk.validateTrackProperties}.
2284
+ */
2285
+ readonly trackProperties: TrackProperty[];
2286
+ constructor(parameters?: MessageParameter[], trackProperties?: TrackProperty[]);
2287
+ getType(): ControlMessageType;
2288
+ /**
2289
+ * Track Properties may only be non-empty when this REQUEST_OK answers a TRACK_STATUS
2290
+ * request (§10.5). A receiver that sees them in any other REQUEST_OK — PUBLISH_OK,
2291
+ * REQUEST_UPDATE_OK, SUBSCRIBE_NAMESPACE_OK or PUBLISH_NAMESPACE_OK — MUST close the
2292
+ * session with a PROTOCOL_VIOLATION.
2293
+ *
2294
+ * @throws :{@link ProtocolViolationError} If Track Properties are present and this
2295
+ * REQUEST_OK does not answer a TRACK_STATUS.
2296
+ */
2297
+ validateTrackProperties(answersTrackStatus: boolean): void;
2298
+ serialize(): FrozenByteBuffer;
2299
+ /**
2300
+ * Parses a REQUEST_OK body. `buf` must hold exactly the payload: whatever follows the
2301
+ * parameters is read as Track Properties, so trailing bytes from a longer buffer would
2302
+ * be parsed as properties.
2303
+ */
2304
+ static parsePayload(buf: BaseByteBuffer): RequestOk;
2305
+ }
2306
+ //#endregion
2307
+ //#region src/model/control/request_error.d.ts
2308
+ /**
2309
+ * REQUEST_ERROR (0x5) refuses any request type. It carries no Request ID: the request
2310
+ * stream it arrives on identifies the request (§10.1).
2311
+ */
2312
+ declare class RequestError {
2313
+ readonly errorCode: RequestErrorCode;
2314
+ readonly retryInterval: bigint;
2315
+ readonly reasonPhrase: ReasonPhrase;
2316
+ /** Present exactly when {@link RequestError.errorCode} is `REDIRECT` (§10.6.2). */
2317
+ readonly redirect: Redirect | undefined;
2318
+ constructor(errorCode: RequestErrorCode, retryInterval: bigint, reasonPhrase: ReasonPhrase, redirect?: Redirect);
2319
+ /** A REQUEST_ERROR that redirects the request elsewhere (§10.6.1). */
2320
+ static redirect(retryInterval: bigint, reasonPhrase: ReasonPhrase, redirect: Redirect): RequestError;
2321
+ getType(): ControlMessageType;
2322
+ serialize(): FrozenByteBuffer;
2323
+ static parsePayload(buf: BaseByteBuffer): RequestError;
2324
+ }
2325
+ //#endregion
2326
+ //#region src/model/control/control_message.d.ts
2327
+ type ControlMessage = Publish | PublishBlocked | PublishDone | PublishNamespace | Namespace | NamespaceDone | Setup | Fetch | FetchOk | GoAway | Subscribe | RequestError | SubscribeOk | RequestUpdate | TrackStatus | SubscribeNamespace | SubscribeTracks | RequestOk | Switch;
2328
+ declare namespace ControlMessage {
2329
+ function deserialize(buf: FrozenByteBuffer): ControlMessage;
2330
+ function serialize(msg: ControlMessage): FrozenByteBuffer;
2331
+ }
2332
+ //#endregion
2333
+ //#region src/model/catalog/cmsf.d.ts
2334
+ /**
2335
+ * Copyright 2026 The MOQtail Authors
2336
+ *
2337
+ * Licensed under the Apache License, Version 2.0 (the "License");
2338
+ * you may not use this file except in compliance with the License.
2339
+ * You may obtain a copy of the License at
2340
+ *
2341
+ * http://www.apache.org/licenses/LICENSE-2.0
2342
+ *
2343
+ * Unless required by applicable law or agreed to in writing, software
2344
+ * distributed under the License is distributed on an "AS IS" BASIS,
2345
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2346
+ * See the License for the specific language governing permissions and
2347
+ * limitations under the License.
2348
+ */
2349
+ interface CMSFTrack {
2350
+ name: string;
2351
+ packaging: 'cmaf' | 'chunk-per-object' | 'timeline';
2352
+ codec?: string;
2353
+ role: 'video' | 'audio' | 'timeline';
2354
+ depends?: string[];
2355
+ mimeType?: string;
2356
+ width?: number;
2357
+ height?: number;
2358
+ timescale?: number;
2359
+ bitrate?: number;
2360
+ initData?: string;
2361
+ }
2362
+ interface CMSF {
2363
+ version: string;
2364
+ tracks: CMSFTrack[];
2365
+ }
2366
+ declare class CMSFCatalog {
2367
+ #private;
2368
+ private constructor();
2369
+ static from(payload: ArrayBufferLike): CMSFCatalog;
2370
+ getByTrackName(trackName: string): CMSFTrack | undefined;
2371
+ getTracks(role?: CMSF['tracks'][number]['role']): CMSFTrack[];
2372
+ getVideo(index?: number): CMSFTrack | undefined;
2373
+ getAudio(index?: number): CMSFTrack | undefined;
2374
+ getTimeline(index?: number): CMSFTrack | undefined;
2375
+ getCodecString(trackName: string): string | undefined;
2376
+ getRole(trackName: string): "video" | "audio" | "timeline" | undefined;
2377
+ getPackaging(trackName: string): "timeline" | "cmaf" | "chunk-per-object" | undefined;
2378
+ isCMAF(trackName: string): boolean;
2379
+ getTimescale(trackName: string): number | undefined;
2380
+ getInitData(trackName: string): Uint8Array<ArrayBuffer> | undefined;
2381
+ private extractTrackName;
2382
+ }
2383
+ //#endregion
2384
+ //#region src/model/error/error.d.ts
2385
+ /**
2386
+ * Copyright 2025 The MOQtail Authors
2387
+ *
2388
+ * Licensed under the Apache License, Version 2.0 (the "License");
2389
+ * you may not use this file except in compliance with the License.
2390
+ * You may obtain a copy of the License at
2391
+ *
2392
+ * http://www.apache.org/licenses/LICENSE-2.0
2393
+ *
2394
+ * Unless required by applicable law or agreed to in writing, software
2395
+ * distributed under the License is distributed on an "AS IS" BASIS,
2396
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2397
+ * See the License for the specific language governing permissions and
2398
+ * limitations under the License.
2399
+ */
2400
+ /**
2401
+ * Base class for all MOQtail errors.
2402
+ */
2403
+ declare class MOQtailError extends Error {
2404
+ constructor(cause?: string);
2405
+ }
2406
+ /**
2407
+ * Not enough bytes in buffer to satisfy a read.
2408
+ */
2409
+ declare class NotEnoughBytesError extends MOQtailError {
2410
+ context: string;
2411
+ needed: number;
2412
+ available: number;
2413
+ constructor(context: string, needed: number, available: number);
2414
+ }
2415
+ /**
2416
+ * Cannot cast between two incompatible types.
2417
+ */
2418
+ declare class CastingError extends MOQtailError {
2419
+ context: string;
2420
+ fromType: string;
2421
+ toType: string;
2422
+ details: string;
2423
+ constructor(context: string, fromType: string, toType: string, details: string);
2424
+ }
2425
+ /**
2426
+ * Value too large to encode as varint.
2427
+ */
2428
+ declare class VarIntOverflowError extends MOQtailError {
2429
+ context: string;
2430
+ value: number;
2431
+ constructor(context: string, value: number);
2432
+ }
2433
+ /**
2434
+ * Length exceeds maximum allowed by protocol.
2435
+ */
2436
+ declare class LengthExceedsMaxError extends MOQtailError {
2437
+ context: string;
2438
+ max: number;
2439
+ len: number;
2440
+ constructor(context: string, max: number, len: number);
2441
+ }
2442
+ /**
2443
+ * Key/value formatting error.
2444
+ */
2445
+ declare class KeyValueFormattingError extends MOQtailError {
2446
+ context: string;
2447
+ constructor(context: string);
2448
+ }
2449
+ /**
2450
+ * Invalid discriminant or type tag.
2451
+ */
2452
+ declare class InvalidTypeError extends MOQtailError {
2453
+ context: string;
2454
+ details: string;
2455
+ constructor(context: string, details: string);
2456
+ }
2457
+ /**
2458
+ * Invalid enum discriminant / value encountered when mapping to a protocol enum.
2459
+ */
2460
+ declare class InvalidEnumValue extends MOQtailError {
2461
+ context: string;
2462
+ value: bigint | number;
2463
+ constructor(context: string, value: bigint | number);
2464
+ }
2465
+ /**
2466
+ * Invalid UTF-8 encountered in a string or bytes field.
2467
+ */
2468
+ declare class InvalidUTF8Error extends MOQtailError {
2469
+ context: string;
2470
+ details: string;
2471
+ constructor(context: string, details: string);
2472
+ }
2473
+ /**
2474
+ * Generic protocol violation.
2475
+ */
2476
+ declare class ProtocolViolationError extends MOQtailError {
2477
+ context: string;
2478
+ details: string;
2479
+ constructor(context: string, details: string);
2480
+ }
2481
+ /**
2482
+ * Track naming error.
2483
+ */
2484
+ declare class TrackNameError extends MOQtailError {
2485
+ context: string;
2486
+ details: string;
2487
+ constructor(context: string, details: string);
2488
+ }
2489
+ /**
2490
+ * Request ID error.
2491
+ */
2492
+ declare class RequestIdError extends MOQtailError {
2493
+ context: string;
2494
+ details: string;
2495
+ constructor(context: string, details: string);
2496
+ }
2497
+ /**
2498
+ * Operation timed out.
2499
+ */
2500
+ declare class TimeoutError extends MOQtailError {
2501
+ context: string;
2502
+ constructor(context: string);
2503
+ }
2504
+ /**
2505
+ * Internal error.
2506
+ */
2507
+ declare class InternalError extends MOQtailError {
2508
+ context: string;
2509
+ details: string;
2510
+ constructor(context: string, details: string);
2511
+ }
2512
+ /**
2513
+ * Connection terminated.
2514
+ */
2515
+ declare class TerminationError extends MOQtailError {
2516
+ context: string;
2517
+ terminationCode: number;
2518
+ constructor(context: string, terminationCode: number);
2519
+ }
2520
+ //#endregion
2521
+ //#region src/model/error/constant.d.ts
2522
+ /**
2523
+ * Copyright 2025 The MOQtail Authors
2524
+ *
2525
+ * Licensed under the Apache License, Version 2.0 (the "License");
2526
+ * you may not use this file except in compliance with the License.
2527
+ * You may obtain a copy of the License at
2528
+ *
2529
+ * http://www.apache.org/licenses/LICENSE-2.0
2530
+ *
2531
+ * Unless required by applicable law or agreed to in writing, software
2532
+ * distributed under the License is distributed on an "AS IS" BASIS,
2533
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2534
+ * See the License for the specific language governing permissions and
2535
+ * limitations under the License.
2536
+ */
2537
+ declare enum TerminationCode {
2538
+ NO_ERROR = 0,
2539
+ INTERNAL_ERROR = 1,
2540
+ UNAUTHORIZED = 2,
2541
+ PROTOCOL_VIOLATION = 3,
2542
+ INVALID_REQUEST_ID = 4,
2543
+ DUPLICATE_TRACK_ALIAS = 5,
2544
+ KEY_VALUE_FORMATTING_ERROR = 6,
2545
+ INVALID_PATH = 8,
2546
+ MALFORMED_PATH = 9,
2547
+ GOAWAY_TIMEOUT = 16,
2548
+ CONTROL_MESSAGE_TIMEOUT = 17,
2549
+ DATA_STREAM_TIMEOUT = 18,
2550
+ AUTH_TOKEN_CACHE_OVERFLOW = 19,
2551
+ DUPLICATE_AUTH_TOKEN_ALIAS = 20,
2552
+ VERSION_NEGOTIATION_FAILED = 21,
2553
+ MALFORMED_AUTH_TOKEN = 22,
2554
+ UNKNOWN_AUTH_TOKEN_ALIAS = 23,
2555
+ EXPIRED_AUTH_TOKEN = 24,
2556
+ INVALID_AUTHORITY = 25,
2557
+ MALFORMED_AUTHORITY = 26
2558
+ }
2559
+ declare namespace TerminationCode {
2560
+ /**
2561
+ * Tries to convert a number to a TerminationCode enum member.
2562
+ *
2563
+ * @param code - The numeric code to convert.
2564
+ * @returns The corresponding TerminationCode member, or throws InvalidTypeError if the code is not valid.
2565
+ */
2566
+ function tryFrom(code: number): TerminationCode;
2567
+ }
2568
+ //#endregion
2569
+ //#region src/model/error/stream_reset.d.ts
2570
+ /**
2571
+ * Copyright 2026 The MOQtail Authors
2572
+ *
2573
+ * Licensed under the Apache License, Version 2.0 (the "License");
2574
+ * you may not use this file except in compliance with the License.
2575
+ * You may obtain a copy of the License at
2576
+ *
2577
+ * http://www.apache.org/licenses/LICENSE-2.0
2578
+ *
2579
+ * Unless required by applicable law or agreed to in writing, software
2580
+ * distributed under the License is distributed on an "AS IS" BASIS,
2581
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2582
+ * See the License for the specific language governing permissions and
2583
+ * limitations under the License.
2584
+ */
2585
+ /**
2586
+ * @public
2587
+ * Codes carried when resetting a request stream or sending STOP_SENDING on one, per
2588
+ * draft-18 §3.3.3.
2589
+ *
2590
+ * A separate registry from {@link (RequestErrorCode:enum)}, which disagrees with it on
2591
+ * the same names: `GOING_AWAY` is `0x4` here but `0x6` there.
2592
+ */
2593
+ declare enum StreamResetCode {
2594
+ InternalError = 0,
2595
+ Cancelled = 1,
2596
+ DeliveryTimeout = 2,
2597
+ SessionClosed = 3,
2598
+ GoingAway = 4,
2599
+ TooFarBehind = 5,
2600
+ UnknownObjectStatus = 6,
2601
+ ExpiredAuthToken = 7,
2602
+ ExcessiveLoad = 9,
2603
+ MalformedTrack = 18
2604
+ }
2605
+ declare namespace StreamResetCode {
2606
+ /**
2607
+ * Converts a numeric application error code to a StreamResetCode. The code is a
2608
+ * `number` because that is what the transport reports it as
2609
+ * (`WebTransportError.streamErrorCode`, an `unsigned long`).
2610
+ *
2611
+ * @throws :{@link InvalidEnumValue} if the code is not a defined stream reset code.
2612
+ */
2613
+ function tryFrom(code: number): StreamResetCode;
2614
+ }
2615
+ //#endregion
2616
+ //#region src/model/property/timestamp.d.ts
2617
+ declare class Timestamp {
2618
+ readonly timestamp: bigint;
2619
+ static readonly TYPE = LOCPropertyId.Timestamp;
2620
+ constructor(timestamp: bigint);
2621
+ toKeyValuePair(): KeyValuePair;
2622
+ static fromKeyValuePair(pair: KeyValuePair): Timestamp | undefined;
2623
+ }
2624
+ //#endregion
2625
+ //#region src/model/property/timescale.d.ts
2626
+ declare class Timescale {
2627
+ readonly timescale: bigint;
2628
+ static readonly TYPE = LOCPropertyId.Timescale;
2629
+ constructor(timescale: bigint);
2630
+ toKeyValuePair(): KeyValuePair;
2631
+ static fromKeyValuePair(pair: KeyValuePair): Timescale | undefined;
2632
+ }
2633
+ //#endregion
2634
+ //#region src/model/property/video_frame_marking.d.ts
2635
+ declare class VideoFrameMarking {
2636
+ readonly value: bigint;
2637
+ static readonly TYPE = LOCPropertyId.VideoFrameMarking;
2638
+ constructor(value: bigint);
2639
+ toKeyValuePair(): KeyValuePair;
2640
+ static fromKeyValuePair(pair: KeyValuePair): VideoFrameMarking | undefined;
2641
+ }
2642
+ //#endregion
2643
+ //#region src/model/property/audio_level.d.ts
2644
+ declare class AudioLevel {
2645
+ readonly audioLevel: bigint;
2646
+ static readonly TYPE = LOCPropertyId.AudioLevel;
2647
+ constructor(audioLevel: bigint);
2648
+ toKeyValuePair(): KeyValuePair;
2649
+ static fromKeyValuePair(pair: KeyValuePair): AudioLevel | undefined;
2650
+ }
2651
+ //#endregion
2652
+ //#region src/model/property/video_config.d.ts
2653
+ declare class VideoConfig {
2654
+ readonly config: Uint8Array;
2655
+ static readonly TYPE = LOCPropertyId.VideoConfig;
2656
+ constructor(config: Uint8Array);
2657
+ toKeyValuePair(): KeyValuePair;
2658
+ static fromKeyValuePair(pair: KeyValuePair): VideoConfig | undefined;
2659
+ }
2660
+ //#endregion
2661
+ //#region src/model/property/loc.d.ts
2662
+ type LOCProperty = Timestamp | Timescale | VideoFrameMarking | AudioLevel | VideoConfig;
2663
+ declare namespace LOCProperty {
2664
+ function fromKeyValuePair(pair: KeyValuePair): LOCProperty | undefined;
2665
+ function toKeyValuePair(header: LOCProperty): KeyValuePair;
2666
+ function isTimestamp(header: LOCProperty): header is Timestamp;
2667
+ function isTimescale(header: LOCProperty): header is Timescale;
2668
+ function isVideoFrameMarking(header: LOCProperty): header is VideoFrameMarking;
2669
+ function isAudioLevel(header: LOCProperty): header is AudioLevel;
2670
+ function isVideoConfig(header: LOCProperty): header is VideoConfig;
2671
+ }
2672
+ declare class LOCProperties {
2673
+ private kvps;
2674
+ addTimestamp(timestamp: bigint | number): this;
2675
+ addTimescale(timescale: bigint | number): this;
2676
+ addVideoFrameMarking(marking: bigint | number): this;
2677
+ addAudioLevel(audioLevel: bigint | number): this;
2678
+ addVideoConfig(config: Uint8Array): this;
2679
+ addRaw(pair: KeyValuePair): this;
2680
+ build(): KeyValuePair[];
2681
+ static fromKeyValuePairs(kvps: KeyValuePair[]): LOCProperty[];
2682
+ }
2683
+ //#endregion
2684
+ //#region src/model/property/object_property.d.ts
2685
+ declare class ImmutablePropertiesObjectProperty {
2686
+ readonly properties: KeyValuePair[];
2687
+ static readonly TYPE = TrackPropertyType.ImmutableProperties;
2688
+ constructor(properties: KeyValuePair[]);
2689
+ toKeyValuePair(): KeyValuePair;
2690
+ static fromKeyValuePair(pair: KeyValuePair): ImmutablePropertiesObjectProperty | undefined;
2691
+ }
2692
+ declare class PriorGroupIdGapProperty {
2693
+ readonly gap: bigint;
2694
+ static readonly TYPE = TrackPropertyType.PriorGroupIdGap;
2695
+ constructor(gap: bigint);
2696
+ toKeyValuePair(): KeyValuePair;
2697
+ static fromKeyValuePair(pair: KeyValuePair): PriorGroupIdGapProperty | undefined;
2698
+ }
2699
+ declare class PriorObjectIdGapProperty {
2700
+ readonly gap: bigint;
2701
+ static readonly TYPE = TrackPropertyType.PriorObjectIdGap;
2702
+ constructor(gap: bigint);
2703
+ toKeyValuePair(): KeyValuePair;
2704
+ static fromKeyValuePair(pair: KeyValuePair): PriorObjectIdGapProperty | undefined;
2705
+ }
2706
+ declare class UnknownObjectProperty {
2707
+ readonly kvp: KeyValuePair;
2708
+ constructor(kvp: KeyValuePair);
2709
+ toKeyValuePair(): KeyValuePair;
2710
+ }
2711
+ type ObjectProperty = ImmutablePropertiesObjectProperty | PriorGroupIdGapProperty | PriorObjectIdGapProperty | UnknownObjectProperty;
2712
+ declare namespace ObjectProperty {
2713
+ function fromKeyValuePair(pair: KeyValuePair): ObjectProperty;
2714
+ function toKeyValuePair(ext: ObjectProperty): KeyValuePair;
2715
+ function deserializeAll(buf: BaseByteBuffer): ObjectProperty[];
2716
+ function serializeInto(exts: ObjectProperty[], payload: ByteBuffer): void;
2717
+ function isImmutableProperties(ext: ObjectProperty): ext is ImmutablePropertiesObjectProperty;
2718
+ function isPriorGroupIdGap(ext: ObjectProperty): ext is PriorGroupIdGapProperty;
2719
+ function isPriorObjectIdGap(ext: ObjectProperty): ext is PriorObjectIdGapProperty;
2720
+ function isUnknown(ext: ObjectProperty): ext is UnknownObjectProperty;
2721
+ }
2722
+ //#endregion
2723
+ //#region src/model/parameter/setup/path.d.ts
2724
+ declare class Path implements Parameter {
2725
+ readonly moqtPath: string;
2726
+ static readonly TYPE = SetupOptionType.Path;
2727
+ constructor(moqtPath: string);
2728
+ toKeyValuePair(): KeyValuePair;
2729
+ static fromKeyValuePair(pair: KeyValuePair): Path | undefined;
2730
+ }
2731
+ //#endregion
2732
+ //#region src/model/parameter/setup/max_auth_token_cache_size.d.ts
2733
+ declare class MaxAuthTokenCacheSize implements Parameter {
2734
+ readonly maxSize: bigint;
2735
+ static readonly TYPE = SetupOptionType.MaxAuthTokenCacheSize;
2736
+ constructor(maxSize: bigint);
2737
+ toKeyValuePair(): KeyValuePair;
2738
+ static fromKeyValuePair(pair: KeyValuePair): MaxAuthTokenCacheSize | undefined;
2739
+ }
2740
+ //#endregion
2741
+ //#region src/model/parameter/setup/authority.d.ts
2742
+ /**
2743
+ * Raw-QUIC only: the authority component of the `moqt://` URI, carried in SETUP because
2744
+ * there is no HTTP CONNECT to carry it (draft-18 §10.3.1.1).
2745
+ *
2746
+ * Client-only; MUST NOT be sent by a server or over WebTransport. moqtail-ts always
2747
+ * connects over WebTransport, so its own handshake never sends this — see
2748
+ * `MOQtailClient.new`.
2749
+ */
2750
+ declare class Authority implements Parameter {
2751
+ readonly authority: string;
2752
+ static readonly TYPE = SetupOptionType.Authority;
2753
+ constructor(authority: string);
2754
+ toKeyValuePair(): KeyValuePair;
2755
+ static fromKeyValuePair(pair: KeyValuePair): Authority | undefined;
2756
+ }
2757
+ //#endregion
2758
+ //#region src/model/parameter/setup/moqt_implementation.d.ts
2759
+ /**
2760
+ * Free-form implementation identification string, e.g. for logging and debugging
2761
+ * (draft-18 §10.3.1.5). Either peer may send it.
2762
+ */
2763
+ declare class MoqtImplementation implements Parameter {
2764
+ readonly info: string;
2765
+ static readonly TYPE = SetupOptionType.MoqtImplementation;
2766
+ constructor(info: string);
2767
+ toKeyValuePair(): KeyValuePair;
2768
+ static fromKeyValuePair(pair: KeyValuePair): MoqtImplementation | undefined;
2769
+ }
2770
+ //#endregion
2771
+ //#region src/model/parameter/setup/ssts_algorithms.d.ts
2772
+ /**
2773
+ * The sender-side track switching (SSTS) algorithms this endpoint supports.
2774
+ *
2775
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so
2776
+ * this option has no codepoint in the registry the conformance fixture tracks
2777
+ * (`dev/conformance/draft18`) and is never asserted against it. An empty list
2778
+ * — or the absence of the option — prohibits the use of SSTS.
2779
+ */
2780
+ declare class SstsAlgorithms implements Parameter {
2781
+ readonly algorithms: bigint[];
2782
+ static readonly TYPE = SetupOptionType.SstsAlgorithms;
2783
+ constructor(algorithms: bigint[]);
2784
+ toKeyValuePair(): KeyValuePair;
2785
+ static fromKeyValuePair(pair: KeyValuePair): SstsAlgorithms | undefined;
2786
+ }
2787
+ //#endregion
2788
+ //#region src/model/parameter/setup_option.d.ts
2789
+ type SetupOption = Path | MaxAuthTokenCacheSize | AuthorizationToken | Authority | MoqtImplementation | SstsAlgorithms;
2790
+ declare namespace SetupOption {
2791
+ function fromKeyValuePair(pair: KeyValuePair): SetupOption | undefined;
2792
+ function toKeyValuePair(param: SetupOption): KeyValuePair;
2793
+ function isPath(param: SetupOption): param is Path;
2794
+ function isMaxAuthTokenCacheSize(param: SetupOption): param is MaxAuthTokenCacheSize;
2795
+ function isAuthorizationToken(param: SetupOption): param is AuthorizationToken;
2796
+ function isAuthority(param: SetupOption): param is Authority;
2797
+ function isMoqtImplementation(param: SetupOption): param is MoqtImplementation;
2798
+ function isSstsAlgorithms(param: SetupOption): param is SstsAlgorithms;
2799
+ }
2800
+ /** Throws if `params` carries AUTHORITY, which MUST NOT be sent over WebTransport. */
2801
+ declare function assertNoAuthorityOverWebTransport(params: KeyValuePair[]): void;
2802
+ declare class SetupOptions {
2803
+ private kvps;
2804
+ addMaxAuthTokenCacheSize(maxSize: bigint | number): this;
2805
+ addPath(moqtPath: string): this;
2806
+ addAuthorizationToken(auth: AuthorizationToken): this;
2807
+ addMoqtImplementation(info: string): this;
2808
+ addSstsAlgorithms(algorithms: (bigint | number)[]): this;
2809
+ addRaw(pair: KeyValuePair): this;
2810
+ build(): KeyValuePair[];
2811
+ static fromKeyValuePairs(kvps: KeyValuePair[]): SetupOption[];
2812
+ }
2813
+ //#endregion
2814
+ export { GoAway as $, messageParameterTypeFromNumber as $t, MOQtailError as A, ObjectForwardingPreference as An, NewGroupRequest as At, CMSFTrack as B, deserializeKvpListUntilEmpty as Bn, GroupOrderParam as Bt, CastingError as C, SUPPORTED_VERSIONS as Cn, MessageParameters as Ct, InvalidUTF8Error as D, DEFAULT_PUBLISHER_PRIORITY as Dn, SubscriptionFilter as Dt, InvalidTypeError as E, Datagram as En, serializeMessageParameterKvps as Et, TimeoutError as F, Tuple as Fn, resolveTransportUrl as Ft, SubscribeTracks as G, ObjectDeliveryTimeout as Gt, RequestError as H, isVarInt as Hn, Expires as Ht, TrackNameError as I, TupleField as In, GREASE_BASE as It, RequestUpdate as J, AuthorizationToken as Jt, SubscribeNamespace as K, FillTimeout as Kt, VarIntOverflowError as L, Location as Ln, GREASE_STEP as Lt, ProtocolViolationError as M, SubgroupHeaderType as Mn, Redirect as Mt, RequestIdError as N, MAX_REASON_PHRASE_LEN as Nn, MoqtFragment as Nt, KeyValueFormattingError as O, FetchHeaderType as On, SubscriberPriority as Ot, TerminationError as P, ReasonPhrase as Pn, MoqtUrl as Pt, Subscribe as Q, TokenAliasType as Qt, CMSF as R, KeyValuePair as Rn, greaseValue as Rt, TerminationCode as S, RequestErrorCode as Sn, MessageParameter as St, InvalidEnumValue as T, FetchHeader as Tn, deserializeMessageParameterKvps as Tt, RequestOk as U, serializeKvpList as Un, SubgroupDeliveryTimeout as Ut, ControlMessage as V, isBytes as Vn, Forward as Vt, Switch as W, RendezvousTimeout as Wt, Publish as X, MessageParameterType as Xt, SubscribeOk as Y, Parameter as Yt, PublishDone as Z, SetupOptionType as Zt, AudioLevel as _, ControlMessageType as _n, Fetch as _t, MoqtImplementation as a, FrozenByteBuffer as an, ImmutablePropertiesTrackProperty as at, Timestamp as b, GroupOrder as bn, Namespace as bt, Path as c, SubgroupHeader as cn, SubgroupDeliveryTimeoutProperty as ct, PriorGroupIdGapProperty as d, FullTrackName as dn, LOCPropertyId as dt, setupOptionTypeFromNumber as en, MAX_NEW_SESSION_URI_LENGTH as et, PriorObjectIdGapProperty as f, MAX_FULL_TRACK_NAME_LENGTH as fn, PropertyRange as ft, VideoConfig as g, FetchObjectContext as gn, locPropertyIdFromNumber as gt, LOCProperty as h, FetchObject as hn, isApplicationSpecificProperty as ht, SstsAlgorithms as i, ByteBuffer as in, DynamicGroupsProperty as it, NotEnoughBytesError as j, ObjectStatus as jn, LargestObject as jt, LengthExceedsMaxError as k, ObjectDatagramType as kn, SwitchingSetAssignment as kt, ImmutablePropertiesObjectProperty as l, MoqtObject as ln, TrackProperty as lt, LOCProperties as m, EndOfRangeKind as mn, TrackPropertyType as mt, SetupOptions as n, PublishBlocked as nn, DefaultPublisherGroupOrderProperty as nt, Authority as o, Header as on, MaxCacheDurationProperty as ot, UnknownObjectProperty as p, MAX_NAMESPACE_TUPLE_COUNT as pn, PropertyRanges as pt, TrackStatus as q, AuthTokenVariant as qt, assertNoAuthorityOverWebTransport as r, BaseByteBuffer as rn, DefaultPublisherPriorityProperty as rt, MaxAuthTokenCacheSize as s, RequestIdMap as sn, ObjectDeliveryTimeoutProperty as st, SetupOption as t, tokenAliasTypeFromNumber as tn, FetchOk as tt, ObjectProperty as u, SubgroupObject as un, UnknownTrackProperty as ut, VideoFrameMarking as v, FetchType as vn, Setup as vt, InternalError as w, TrackStatusCode as wn, applyMessageParameterUpdate as wt, StreamResetCode as x, PublishDoneStatusCode as xn, PublishNamespace as xt, Timescale as y, FilterType as yn, NamespaceDone as yt, CMSFCatalog as z, deserializeKvpList as zn, isGrease as zt };