moqtail 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +514 -0
- package/dist/byte_buffer-BOK6VPTF.d.cts +864 -0
- package/dist/byte_buffer-BOK6VPTF.d.ts +864 -0
- package/dist/client/index.cjs +7785 -0
- package/dist/client/index.d.cts +1665 -0
- package/dist/client/index.d.ts +1665 -0
- package/dist/client/index.js +7767 -0
- package/dist/index.cjs +8559 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8459 -0
- package/dist/model/index.cjs +4759 -0
- package/dist/model/index.d.cts +362 -0
- package/dist/model/index.d.ts +362 -0
- package/dist/model/index.js +4645 -0
- package/dist/util/index.cjs +1799 -0
- package/dist/util/index.d.cts +205 -0
- package/dist/util/index.d.ts +205 -0
- package/dist/util/index.js +1789 -0
- package/dist/version_parameter-CgEPNuUt.d.ts +1660 -0
- package/dist/version_parameter-DCE9_itC.d.cts +1660 -0
- package/package.json +97 -0
|
@@ -0,0 +1,4759 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/model/error/error.ts
|
|
4
|
+
var MOQtailError = class extends Error {
|
|
5
|
+
constructor(cause) {
|
|
6
|
+
super(cause);
|
|
7
|
+
this.name = this.constructor.name;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var NotEnoughBytesError = class extends MOQtailError {
|
|
11
|
+
constructor(context, needed, available) {
|
|
12
|
+
super(`[${context}] not enough bytes: needed ${needed}, available ${available}`);
|
|
13
|
+
this.context = context;
|
|
14
|
+
this.needed = needed;
|
|
15
|
+
this.available = available;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var CastingError = class extends MOQtailError {
|
|
19
|
+
constructor(context, fromType, toType, details) {
|
|
20
|
+
super(`[${context}] cannot cast from ${fromType} to ${toType}, [${details}]`);
|
|
21
|
+
this.context = context;
|
|
22
|
+
this.fromType = fromType;
|
|
23
|
+
this.toType = toType;
|
|
24
|
+
this.details = details;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var VarIntOverflowError = class extends MOQtailError {
|
|
28
|
+
constructor(context, value) {
|
|
29
|
+
super(`[${context}] value ${value} too large to encode as varint`);
|
|
30
|
+
this.context = context;
|
|
31
|
+
this.value = value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var LengthExceedsMaxError = class extends MOQtailError {
|
|
35
|
+
constructor(context, max, len) {
|
|
36
|
+
super(`[${context}] length ${len} exceeds maximum of ${max}, protocol violation`);
|
|
37
|
+
this.context = context;
|
|
38
|
+
this.max = max;
|
|
39
|
+
this.len = len;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var KeyValueFormattingError = class extends MOQtailError {
|
|
43
|
+
constructor(context) {
|
|
44
|
+
super(`[${context}] key value formatting error`);
|
|
45
|
+
this.context = context;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var InvalidTypeError = class extends MOQtailError {
|
|
49
|
+
constructor(context, details) {
|
|
50
|
+
super(`Invalid type: [${context}], [${details}]`);
|
|
51
|
+
this.context = context;
|
|
52
|
+
this.details = details;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var InvalidUTF8Error = class extends MOQtailError {
|
|
56
|
+
constructor(context, details) {
|
|
57
|
+
super(`Invalid UTF8: [${context}], [${details}]`);
|
|
58
|
+
this.context = context;
|
|
59
|
+
this.details = details;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var ProtocolViolationError = class extends MOQtailError {
|
|
63
|
+
constructor(context, details) {
|
|
64
|
+
super(`Protocol violation: [${context}], [${details}]`);
|
|
65
|
+
this.context = context;
|
|
66
|
+
this.details = details;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var TrackNameError = class extends MOQtailError {
|
|
70
|
+
constructor(context, details) {
|
|
71
|
+
super(`Track naming error: [${context}], [${details}]`);
|
|
72
|
+
this.context = context;
|
|
73
|
+
this.details = details;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var RequestIdError = class extends MOQtailError {
|
|
77
|
+
constructor(context, details) {
|
|
78
|
+
super(`Request ID error: [${context}], [${details}]`);
|
|
79
|
+
this.context = context;
|
|
80
|
+
this.details = details;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var TimeoutError = class extends MOQtailError {
|
|
84
|
+
constructor(context) {
|
|
85
|
+
super(`Timeout: [${context}]`);
|
|
86
|
+
this.context = context;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var InternalError = class extends MOQtailError {
|
|
90
|
+
constructor(context, details) {
|
|
91
|
+
super(`Internal error: [${context}], [${details}]`);
|
|
92
|
+
this.context = context;
|
|
93
|
+
this.details = details;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var TerminationError = class extends MOQtailError {
|
|
97
|
+
constructor(context, terminationCode) {
|
|
98
|
+
super(`Connection terminated with code ${terminationCode}: ${context}`);
|
|
99
|
+
this.context = context;
|
|
100
|
+
this.terminationCode = terminationCode;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/model/common/pair.ts
|
|
105
|
+
var MAX_VALUE_LENGTH = 2 ** 16 - 1;
|
|
106
|
+
var KeyValuePair = class _KeyValuePair {
|
|
107
|
+
/**
|
|
108
|
+
* The key/type identifier for this pair.
|
|
109
|
+
* - Even: value is a varint.
|
|
110
|
+
* - Odd: value is a blob.
|
|
111
|
+
*/
|
|
112
|
+
typeValue;
|
|
113
|
+
/**
|
|
114
|
+
* The value for this pair.
|
|
115
|
+
* - If `typeValue` is even: a varint (`bigint`).
|
|
116
|
+
* - If `typeValue` is odd: a binary blob (`Uint8Array`).
|
|
117
|
+
*/
|
|
118
|
+
value;
|
|
119
|
+
/**
|
|
120
|
+
* Constructs a new KeyValuePair.
|
|
121
|
+
* @param typeValue - The key/type identifier.
|
|
122
|
+
* @param value - The value (varint or blob).
|
|
123
|
+
* @internal Use static factory methods instead.
|
|
124
|
+
*/
|
|
125
|
+
constructor(typeValue, value) {
|
|
126
|
+
this.typeValue = typeValue;
|
|
127
|
+
this.value = value;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new varint KeyValuePair.
|
|
131
|
+
* @param typeValue - Must be even.
|
|
132
|
+
* @param value - The varint value.
|
|
133
|
+
* @returns A KeyValuePair with varint value.
|
|
134
|
+
* @throws KeyValueFormattingError if typeValue is not even.
|
|
135
|
+
*/
|
|
136
|
+
static tryNewVarInt(typeValue, value) {
|
|
137
|
+
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
138
|
+
if (tv % 2n !== 0n) {
|
|
139
|
+
throw new KeyValueFormattingError("KeyValuePair.tryNewVarInt");
|
|
140
|
+
}
|
|
141
|
+
const v = typeof value === "number" ? BigInt(value) : value;
|
|
142
|
+
return new _KeyValuePair(tv, v);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates a new blob KeyValuePair.
|
|
146
|
+
* @param typeValue - Must be odd.
|
|
147
|
+
* @param value - The binary blob value.
|
|
148
|
+
* @returns A KeyValuePair with blob value.
|
|
149
|
+
* @throws KeyValueFormattingError if typeValue is not odd.
|
|
150
|
+
* @throws LengthExceedsMaxError if value length exceeds 65535 bytes.
|
|
151
|
+
*/
|
|
152
|
+
static tryNewBytes(typeValue, value) {
|
|
153
|
+
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
154
|
+
if (tv % 2n === 0n) {
|
|
155
|
+
throw new KeyValueFormattingError("KeyValuePair.tryNewBytes");
|
|
156
|
+
}
|
|
157
|
+
const len = value.length;
|
|
158
|
+
if (len > MAX_VALUE_LENGTH) {
|
|
159
|
+
throw new LengthExceedsMaxError("KeyValuePair.tryNewBytes", MAX_VALUE_LENGTH, len);
|
|
160
|
+
}
|
|
161
|
+
return new _KeyValuePair(tv, value);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Serializes this key-value pair to a frozen byte buffer.
|
|
165
|
+
* @returns The serialized buffer.
|
|
166
|
+
*/
|
|
167
|
+
serialize() {
|
|
168
|
+
const buf = new ByteBuffer();
|
|
169
|
+
buf.putVI(this.typeValue);
|
|
170
|
+
if (isVarInt(this)) {
|
|
171
|
+
buf.putVI(this.value);
|
|
172
|
+
} else if (isBytes(this)) {
|
|
173
|
+
buf.putLengthPrefixedBytes(this.value);
|
|
174
|
+
}
|
|
175
|
+
return buf.freeze();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Deserializes a KeyValuePair from a buffer.
|
|
179
|
+
* @param buf - The buffer to read from.
|
|
180
|
+
* @returns The deserialized KeyValuePair.
|
|
181
|
+
* @throws LengthExceedsMaxError if blob length exceeds 65535 bytes.
|
|
182
|
+
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
183
|
+
*/
|
|
184
|
+
static deserialize(buf) {
|
|
185
|
+
const typeValue = buf.getVI();
|
|
186
|
+
if (typeValue % 2n === 0n) {
|
|
187
|
+
const value = buf.getVI();
|
|
188
|
+
return new _KeyValuePair(typeValue, value);
|
|
189
|
+
} else {
|
|
190
|
+
const len = buf.getNumberVI();
|
|
191
|
+
if (len > MAX_VALUE_LENGTH) {
|
|
192
|
+
throw new LengthExceedsMaxError("KeyValuePair.deserialize", MAX_VALUE_LENGTH, len);
|
|
193
|
+
}
|
|
194
|
+
const value = buf.getBytes(len);
|
|
195
|
+
return new _KeyValuePair(typeValue, value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Checks if this pair is equal to another.
|
|
200
|
+
* @param other - The other KeyValuePair.
|
|
201
|
+
* @returns True if both type and value are equal.
|
|
202
|
+
*/
|
|
203
|
+
equals(other) {
|
|
204
|
+
if (this.typeValue !== other.typeValue) return false;
|
|
205
|
+
if (isVarInt(this) && isVarInt(other)) {
|
|
206
|
+
return this.value === other.value;
|
|
207
|
+
}
|
|
208
|
+
if (isBytes(this) && isBytes(other)) {
|
|
209
|
+
const a = this.value;
|
|
210
|
+
const b = other.value;
|
|
211
|
+
if (a.length !== b.length) return false;
|
|
212
|
+
for (let i = 0; i < a.length; i++) {
|
|
213
|
+
if (a[i] !== b[i]) return false;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
function isVarInt(pair) {
|
|
221
|
+
return pair.typeValue % 2n === 0n;
|
|
222
|
+
}
|
|
223
|
+
function isBytes(pair) {
|
|
224
|
+
return pair.typeValue % 2n !== 0n;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/model/common/location.ts
|
|
228
|
+
var Location = class _Location {
|
|
229
|
+
/**
|
|
230
|
+
* The group index for this location.
|
|
231
|
+
*/
|
|
232
|
+
group;
|
|
233
|
+
/**
|
|
234
|
+
* The object index within the group for this location.
|
|
235
|
+
*/
|
|
236
|
+
object;
|
|
237
|
+
/**
|
|
238
|
+
* Constructs a new Location.
|
|
239
|
+
* @param group - The group index (number or bigint).
|
|
240
|
+
* @param object - The object index (number or bigint).
|
|
241
|
+
*/
|
|
242
|
+
constructor(group, object) {
|
|
243
|
+
this.group = BigInt(group);
|
|
244
|
+
this.object = BigInt(object);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Serializes this Location to a FrozenByteBuffer.
|
|
248
|
+
* @returns The serialized buffer.
|
|
249
|
+
* @throws CastingError if group or object is negative.
|
|
250
|
+
* @throws VarIntOverflowError if group or object exceeds varint encoding limits.
|
|
251
|
+
*/
|
|
252
|
+
serialize() {
|
|
253
|
+
const buf = new ByteBuffer();
|
|
254
|
+
buf.putVI(this.group);
|
|
255
|
+
buf.putVI(this.object);
|
|
256
|
+
return buf.freeze();
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Deserializes a Location from a buffer.
|
|
260
|
+
* @param buf - The buffer to read from.
|
|
261
|
+
* @returns The deserialized Location.
|
|
262
|
+
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
263
|
+
*/
|
|
264
|
+
static deserialize(buf) {
|
|
265
|
+
const group = buf.getVI();
|
|
266
|
+
const object = buf.getVI();
|
|
267
|
+
return new _Location(group, object);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Checks if this Location is equal to another.
|
|
271
|
+
* @param other - The other Location to compare.
|
|
272
|
+
* @returns True if both group and object are equal.
|
|
273
|
+
*/
|
|
274
|
+
equals(other) {
|
|
275
|
+
return this.group === other.group && this.object === other.object;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Compares this Location to another for ordering.
|
|
279
|
+
* @param other - The other Location to compare.
|
|
280
|
+
* @returns -1 if this \< other, 1 if this \> other, 0 if equal.
|
|
281
|
+
*/
|
|
282
|
+
compare(other) {
|
|
283
|
+
if (this.group < other.group) return -1;
|
|
284
|
+
if (this.group > other.group) return 1;
|
|
285
|
+
if (this.object < other.object) return -1;
|
|
286
|
+
if (this.object > other.object) return 1;
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// src/model/common/tuple.ts
|
|
292
|
+
var PATH_SEPARATOR = "/";
|
|
293
|
+
var TupleField = class _TupleField {
|
|
294
|
+
/**
|
|
295
|
+
* The raw value of the field as a byte array.
|
|
296
|
+
*/
|
|
297
|
+
constructor(value) {
|
|
298
|
+
this.value = value;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Creates a TupleField from a UTF-8 string.
|
|
302
|
+
* @param str - The string to encode.
|
|
303
|
+
* @returns A new TupleField containing the encoded value.
|
|
304
|
+
*/
|
|
305
|
+
static fromUtf8(str) {
|
|
306
|
+
return new _TupleField(new TextEncoder().encode(str));
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Decodes the field value to a UTF-8 string.
|
|
310
|
+
* @returns The decoded string.
|
|
311
|
+
*/
|
|
312
|
+
toUtf8() {
|
|
313
|
+
return new TextDecoder().decode(this.value);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Serializes this field to a length-prefixed byte array.
|
|
317
|
+
* @returns The serialized bytes.
|
|
318
|
+
*/
|
|
319
|
+
serialize() {
|
|
320
|
+
const buf = new ByteBuffer();
|
|
321
|
+
buf.putVI(this.value.length);
|
|
322
|
+
buf.putBytes(this.value);
|
|
323
|
+
return buf.toUint8Array();
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Deserializes a TupleField from a buffer.
|
|
327
|
+
* @param buf - The buffer to read from.
|
|
328
|
+
* @returns The deserialized TupleField.
|
|
329
|
+
* @throws CastingError if the length cannot be safely cast to number.
|
|
330
|
+
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
331
|
+
*/
|
|
332
|
+
static deserialize(buf) {
|
|
333
|
+
const lenBig = buf.getVI();
|
|
334
|
+
const len = Number(lenBig);
|
|
335
|
+
if (BigInt(len) !== lenBig) {
|
|
336
|
+
throw new CastingError("TupleField.deserialize", "bigint", "number", `${lenBig}`);
|
|
337
|
+
}
|
|
338
|
+
const bytes = buf.getBytes(len);
|
|
339
|
+
return new _TupleField(bytes);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var Tuple = class _Tuple {
|
|
343
|
+
/**
|
|
344
|
+
* The ordered list of fields in this tuple.
|
|
345
|
+
*/
|
|
346
|
+
constructor(fields = []) {
|
|
347
|
+
this.fields = fields;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Creates a Tuple from a path string, splitting on '/'.
|
|
351
|
+
* @param path - The path string (e.g. '/foo/bar').
|
|
352
|
+
* @returns A Tuple with each segment as a field.
|
|
353
|
+
*/
|
|
354
|
+
static fromUtf8Path(path) {
|
|
355
|
+
const parts = path.split(PATH_SEPARATOR).filter(Boolean);
|
|
356
|
+
const fields = parts.map(TupleField.fromUtf8);
|
|
357
|
+
return new _Tuple(fields);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Converts the tuple to a path string, joining fields with '/'.
|
|
361
|
+
* @returns The path string (e.g. '/foo/bar').
|
|
362
|
+
*/
|
|
363
|
+
toUtf8Path() {
|
|
364
|
+
return this.fields.map((f) => PATH_SEPARATOR + f.toUtf8()).join("");
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Adds a field to the tuple.
|
|
368
|
+
* @param field - The TupleField to add.
|
|
369
|
+
*/
|
|
370
|
+
add(field) {
|
|
371
|
+
this.fields.push(field);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Gets the field at the specified index.
|
|
375
|
+
* @param index - The field index.
|
|
376
|
+
* @returns The TupleField at the index.
|
|
377
|
+
* @throws Error if no field exists at the index.
|
|
378
|
+
*/
|
|
379
|
+
get(index) {
|
|
380
|
+
const field = this.fields[index];
|
|
381
|
+
if (!field) throw new Error("Field not found at index");
|
|
382
|
+
return field;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Sets the field at the specified index.
|
|
386
|
+
* @param index - The field index.
|
|
387
|
+
* @param field - The TupleField to set.
|
|
388
|
+
*/
|
|
389
|
+
set(index, field) {
|
|
390
|
+
this.fields[index] = field;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Clears all fields from the tuple.
|
|
394
|
+
*/
|
|
395
|
+
clear() {
|
|
396
|
+
this.fields.length = 0;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Serializes the tuple to a FrozenByteBuffer.
|
|
400
|
+
* @returns The serialized buffer.
|
|
401
|
+
*/
|
|
402
|
+
serialize() {
|
|
403
|
+
const buf = new ByteBuffer();
|
|
404
|
+
buf.putVI(this.fields.length);
|
|
405
|
+
for (const field of this.fields) {
|
|
406
|
+
buf.putBytes(field.serialize());
|
|
407
|
+
}
|
|
408
|
+
return buf.freeze();
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Deserializes a Tuple from a buffer.
|
|
412
|
+
* @param buf - The buffer to read from.
|
|
413
|
+
* @returns The deserialized Tuple.
|
|
414
|
+
* @throws CastingError if the count cannot be safely cast to number.
|
|
415
|
+
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
416
|
+
*/
|
|
417
|
+
static deserialize(buf) {
|
|
418
|
+
const countBig = buf.getVI();
|
|
419
|
+
const count = Number(countBig);
|
|
420
|
+
if (BigInt(count) !== countBig) {
|
|
421
|
+
throw new CastingError("Tuple.deserialize", "bigint", "number", `${countBig}`);
|
|
422
|
+
}
|
|
423
|
+
const fields = [];
|
|
424
|
+
for (let i = 0; i < count; i++) {
|
|
425
|
+
const field = TupleField.deserialize(buf);
|
|
426
|
+
fields.push(field);
|
|
427
|
+
}
|
|
428
|
+
return new _Tuple(fields);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Checks if this tuple is equal to another.
|
|
432
|
+
* @param other - The other Tuple to compare.
|
|
433
|
+
* @returns True if all fields are equal.
|
|
434
|
+
*/
|
|
435
|
+
equals(other) {
|
|
436
|
+
if (this.fields.length !== other.fields.length) return false;
|
|
437
|
+
return this.fields.every((f, i) => f.value.toString() === other.fields[i].value.toString());
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
// src/model/common/reason_phrase.ts
|
|
442
|
+
var MAX_REASON_PHRASE_LEN = 1024;
|
|
443
|
+
var ReasonPhrase = class _ReasonPhrase {
|
|
444
|
+
/**
|
|
445
|
+
* The underlying phrase string.
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
#phrase;
|
|
449
|
+
/**
|
|
450
|
+
* Constructs a ReasonPhrase, validating UTF-8 encoding and length.
|
|
451
|
+
*
|
|
452
|
+
* @param phrase - The string to use as the reason phrase.
|
|
453
|
+
* @throws {@link InvalidUTF8Error} if encoding fails.
|
|
454
|
+
* @throws {@link LengthExceedsMaxError} if the encoded phrase exceeds {@link MAX_REASON_PHRASE_LEN} bytes.
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
constructor(phrase) {
|
|
458
|
+
let encodedPhrase;
|
|
459
|
+
try {
|
|
460
|
+
encodedPhrase = new TextEncoder().encode(phrase);
|
|
461
|
+
} catch (e) {
|
|
462
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
463
|
+
throw new InvalidUTF8Error("ReasonPhrase.constructor (TextEncoder failed)", errorMessage);
|
|
464
|
+
}
|
|
465
|
+
if (encodedPhrase.length > MAX_REASON_PHRASE_LEN) {
|
|
466
|
+
throw new LengthExceedsMaxError("ReasonPhrase.constructor", MAX_REASON_PHRASE_LEN, encodedPhrase.length);
|
|
467
|
+
}
|
|
468
|
+
this.#phrase = phrase;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Returns the phrase string.
|
|
472
|
+
* @public
|
|
473
|
+
*/
|
|
474
|
+
get phrase() {
|
|
475
|
+
return this.#phrase;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Serializes the ReasonPhrase into a {@link FrozenByteBuffer} containing:
|
|
479
|
+
* varint(length_of_phrase_bytes) || phrase_bytes
|
|
480
|
+
*
|
|
481
|
+
* @returns The serialized buffer.
|
|
482
|
+
* @public
|
|
483
|
+
*/
|
|
484
|
+
serialize() {
|
|
485
|
+
const buf = new ByteBuffer();
|
|
486
|
+
const phraseBytes = new TextEncoder().encode(this.#phrase);
|
|
487
|
+
buf.putVI(phraseBytes.length);
|
|
488
|
+
buf.putBytes(phraseBytes);
|
|
489
|
+
return buf.freeze();
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Deserializes a ReasonPhrase from the given buffer.
|
|
493
|
+
* Reads varint(length) || utf8‑bytes.
|
|
494
|
+
*
|
|
495
|
+
* @param buf - The buffer to read from.
|
|
496
|
+
* @returns The deserialized ReasonPhrase.
|
|
497
|
+
* @throws :{@link CastingError} if the length cannot be safely cast to a number.
|
|
498
|
+
* @throws :{@link LengthExceedsMaxError} if the length exceeds {@link MAX_REASON_PHRASE_LEN}.
|
|
499
|
+
* @throws :{@link NotEnoughBytesError} if the buffer does not contain enough bytes.
|
|
500
|
+
* @throws :{@link InvalidUTF8Error} if decoding fails.
|
|
501
|
+
* @public
|
|
502
|
+
*/
|
|
503
|
+
static deserialize(buf) {
|
|
504
|
+
const lenBig = buf.getVI();
|
|
505
|
+
let len;
|
|
506
|
+
try {
|
|
507
|
+
len = Number(lenBig);
|
|
508
|
+
if (BigInt(len) !== lenBig) {
|
|
509
|
+
throw new Error(`Value ${lenBig.toString()} cannot be accurately represented as a number.`);
|
|
510
|
+
}
|
|
511
|
+
} catch (e) {
|
|
512
|
+
const errorDetails = e instanceof Error ? e.message : String(e);
|
|
513
|
+
throw new CastingError("ReasonPhrase.deserialize length", "bigint", "number", errorDetails);
|
|
514
|
+
}
|
|
515
|
+
if (len > MAX_REASON_PHRASE_LEN) {
|
|
516
|
+
throw new LengthExceedsMaxError("ReasonPhrase.deserialize", MAX_REASON_PHRASE_LEN, len);
|
|
517
|
+
}
|
|
518
|
+
if (buf.remaining < len) {
|
|
519
|
+
throw new NotEnoughBytesError("ReasonPhrase.deserialize value", len, buf.remaining);
|
|
520
|
+
}
|
|
521
|
+
const phraseBytes = buf.getBytes(len);
|
|
522
|
+
try {
|
|
523
|
+
const phraseStr = new TextDecoder("utf-8", { fatal: true }).decode(phraseBytes);
|
|
524
|
+
return new _ReasonPhrase(phraseStr);
|
|
525
|
+
} catch (e) {
|
|
526
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
527
|
+
throw new InvalidUTF8Error("ReasonPhrase.deserialize (decode)", errorMessage);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// src/model/data/constant.ts
|
|
533
|
+
exports.ObjectDatagramStatusType = /* @__PURE__ */ ((ObjectDatagramStatusType2) => {
|
|
534
|
+
ObjectDatagramStatusType2[ObjectDatagramStatusType2["WithoutExtensions"] = 2] = "WithoutExtensions";
|
|
535
|
+
ObjectDatagramStatusType2[ObjectDatagramStatusType2["WithExtensions"] = 3] = "WithExtensions";
|
|
536
|
+
return ObjectDatagramStatusType2;
|
|
537
|
+
})(exports.ObjectDatagramStatusType || {});
|
|
538
|
+
((ObjectDatagramStatusType2) => {
|
|
539
|
+
function tryFrom(value) {
|
|
540
|
+
const v = typeof value === "bigint" ? Number(value) : value;
|
|
541
|
+
switch (v) {
|
|
542
|
+
case 2:
|
|
543
|
+
return 2 /* WithoutExtensions */;
|
|
544
|
+
case 3:
|
|
545
|
+
return 3 /* WithExtensions */;
|
|
546
|
+
default:
|
|
547
|
+
throw new Error(`Invalid ObjectDatagramStatusType: ${value}`);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
ObjectDatagramStatusType2.tryFrom = tryFrom;
|
|
551
|
+
})(exports.ObjectDatagramStatusType || (exports.ObjectDatagramStatusType = {}));
|
|
552
|
+
exports.ObjectDatagramType = /* @__PURE__ */ ((ObjectDatagramType2) => {
|
|
553
|
+
ObjectDatagramType2[ObjectDatagramType2["WithoutExtensions"] = 0] = "WithoutExtensions";
|
|
554
|
+
ObjectDatagramType2[ObjectDatagramType2["WithExtensions"] = 1] = "WithExtensions";
|
|
555
|
+
return ObjectDatagramType2;
|
|
556
|
+
})(exports.ObjectDatagramType || {});
|
|
557
|
+
((ObjectDatagramType2) => {
|
|
558
|
+
function tryFrom(value) {
|
|
559
|
+
const v = typeof value === "bigint" ? Number(value) : value;
|
|
560
|
+
switch (v) {
|
|
561
|
+
case 0:
|
|
562
|
+
return 0 /* WithoutExtensions */;
|
|
563
|
+
case 1:
|
|
564
|
+
return 1 /* WithExtensions */;
|
|
565
|
+
default:
|
|
566
|
+
throw new Error(`Invalid ObjectDatagramType: ${value}`);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
ObjectDatagramType2.tryFrom = tryFrom;
|
|
570
|
+
})(exports.ObjectDatagramType || (exports.ObjectDatagramType = {}));
|
|
571
|
+
exports.FetchHeaderType = /* @__PURE__ */ ((FetchHeaderType2) => {
|
|
572
|
+
FetchHeaderType2[FetchHeaderType2["Type0x05"] = 5] = "Type0x05";
|
|
573
|
+
return FetchHeaderType2;
|
|
574
|
+
})(exports.FetchHeaderType || {});
|
|
575
|
+
((FetchHeaderType2) => {
|
|
576
|
+
function tryFrom(value) {
|
|
577
|
+
const v = typeof value === "bigint" ? Number(value) : value;
|
|
578
|
+
switch (v) {
|
|
579
|
+
case 5:
|
|
580
|
+
return 5 /* Type0x05 */;
|
|
581
|
+
default:
|
|
582
|
+
throw new Error(`Invalid FetchHeaderType: ${value}`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
FetchHeaderType2.tryFrom = tryFrom;
|
|
586
|
+
})(exports.FetchHeaderType || (exports.FetchHeaderType = {}));
|
|
587
|
+
exports.SubgroupHeaderType = /* @__PURE__ */ ((SubgroupHeaderType2) => {
|
|
588
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x10"] = 16] = "Type0x10";
|
|
589
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x11"] = 17] = "Type0x11";
|
|
590
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x12"] = 18] = "Type0x12";
|
|
591
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x13"] = 19] = "Type0x13";
|
|
592
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x14"] = 20] = "Type0x14";
|
|
593
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x15"] = 21] = "Type0x15";
|
|
594
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x18"] = 24] = "Type0x18";
|
|
595
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x19"] = 25] = "Type0x19";
|
|
596
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1A"] = 26] = "Type0x1A";
|
|
597
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1B"] = 27] = "Type0x1B";
|
|
598
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1C"] = 28] = "Type0x1C";
|
|
599
|
+
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1D"] = 29] = "Type0x1D";
|
|
600
|
+
return SubgroupHeaderType2;
|
|
601
|
+
})(exports.SubgroupHeaderType || {});
|
|
602
|
+
((SubgroupHeaderType2) => {
|
|
603
|
+
function hasExplicitSubgroupId(t) {
|
|
604
|
+
switch (t) {
|
|
605
|
+
case 20 /* Type0x14 */:
|
|
606
|
+
case 21 /* Type0x15 */:
|
|
607
|
+
case 28 /* Type0x1C */:
|
|
608
|
+
case 29 /* Type0x1D */:
|
|
609
|
+
return true;
|
|
610
|
+
default:
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
SubgroupHeaderType2.hasExplicitSubgroupId = hasExplicitSubgroupId;
|
|
615
|
+
function isSubgroupIdZero(t) {
|
|
616
|
+
switch (t) {
|
|
617
|
+
case 16 /* Type0x10 */:
|
|
618
|
+
case 17 /* Type0x11 */:
|
|
619
|
+
case 24 /* Type0x18 */:
|
|
620
|
+
case 25 /* Type0x19 */:
|
|
621
|
+
return true;
|
|
622
|
+
default:
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
SubgroupHeaderType2.isSubgroupIdZero = isSubgroupIdZero;
|
|
627
|
+
function hasExtensions(t) {
|
|
628
|
+
switch (t) {
|
|
629
|
+
case 17 /* Type0x11 */:
|
|
630
|
+
case 19 /* Type0x13 */:
|
|
631
|
+
case 21 /* Type0x15 */:
|
|
632
|
+
case 25 /* Type0x19 */:
|
|
633
|
+
case 27 /* Type0x1B */:
|
|
634
|
+
case 29 /* Type0x1D */:
|
|
635
|
+
return true;
|
|
636
|
+
default:
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
SubgroupHeaderType2.hasExtensions = hasExtensions;
|
|
641
|
+
function tryFrom(value) {
|
|
642
|
+
const v = typeof value === "bigint" ? Number(value) : value;
|
|
643
|
+
switch (v) {
|
|
644
|
+
case 16:
|
|
645
|
+
return 16 /* Type0x10 */;
|
|
646
|
+
case 17:
|
|
647
|
+
return 17 /* Type0x11 */;
|
|
648
|
+
case 18:
|
|
649
|
+
return 18 /* Type0x12 */;
|
|
650
|
+
case 19:
|
|
651
|
+
return 19 /* Type0x13 */;
|
|
652
|
+
case 20:
|
|
653
|
+
return 20 /* Type0x14 */;
|
|
654
|
+
case 21:
|
|
655
|
+
return 21 /* Type0x15 */;
|
|
656
|
+
case 24:
|
|
657
|
+
return 24 /* Type0x18 */;
|
|
658
|
+
case 25:
|
|
659
|
+
return 25 /* Type0x19 */;
|
|
660
|
+
case 26:
|
|
661
|
+
return 26 /* Type0x1A */;
|
|
662
|
+
case 27:
|
|
663
|
+
return 27 /* Type0x1B */;
|
|
664
|
+
case 28:
|
|
665
|
+
return 28 /* Type0x1C */;
|
|
666
|
+
case 29:
|
|
667
|
+
return 29 /* Type0x1D */;
|
|
668
|
+
default:
|
|
669
|
+
throw new Error(`Invalid SubgroupHeaderType: ${value}`);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
SubgroupHeaderType2.tryFrom = tryFrom;
|
|
673
|
+
})(exports.SubgroupHeaderType || (exports.SubgroupHeaderType = {}));
|
|
674
|
+
exports.ObjectForwardingPreference = /* @__PURE__ */ ((ObjectForwardingPreference2) => {
|
|
675
|
+
ObjectForwardingPreference2["Subgroup"] = "Subgroup";
|
|
676
|
+
ObjectForwardingPreference2["Datagram"] = "Datagram";
|
|
677
|
+
return ObjectForwardingPreference2;
|
|
678
|
+
})(exports.ObjectForwardingPreference || {});
|
|
679
|
+
((ObjectForwardingPreference2) => {
|
|
680
|
+
function tryFrom(value) {
|
|
681
|
+
if (value === "Subgroup") return "Subgroup" /* Subgroup */;
|
|
682
|
+
if (value === "Datagram") return "Datagram" /* Datagram */;
|
|
683
|
+
throw new Error(`Invalid ObjectForwardingPreference: ${value}`);
|
|
684
|
+
}
|
|
685
|
+
ObjectForwardingPreference2.tryFrom = tryFrom;
|
|
686
|
+
})(exports.ObjectForwardingPreference || (exports.ObjectForwardingPreference = {}));
|
|
687
|
+
exports.ObjectStatus = /* @__PURE__ */ ((ObjectStatus2) => {
|
|
688
|
+
ObjectStatus2[ObjectStatus2["Normal"] = 0] = "Normal";
|
|
689
|
+
ObjectStatus2[ObjectStatus2["DoesNotExist"] = 1] = "DoesNotExist";
|
|
690
|
+
ObjectStatus2[ObjectStatus2["EndOfGroup"] = 3] = "EndOfGroup";
|
|
691
|
+
ObjectStatus2[ObjectStatus2["EndOfTrack"] = 4] = "EndOfTrack";
|
|
692
|
+
return ObjectStatus2;
|
|
693
|
+
})(exports.ObjectStatus || {});
|
|
694
|
+
((ObjectStatus2) => {
|
|
695
|
+
function tryFrom(value) {
|
|
696
|
+
const v = typeof value === "bigint" ? Number(value) : value;
|
|
697
|
+
switch (v) {
|
|
698
|
+
case 0:
|
|
699
|
+
return 0 /* Normal */;
|
|
700
|
+
case 1:
|
|
701
|
+
return 1 /* DoesNotExist */;
|
|
702
|
+
case 3:
|
|
703
|
+
return 3 /* EndOfGroup */;
|
|
704
|
+
case 4:
|
|
705
|
+
return 4 /* EndOfTrack */;
|
|
706
|
+
default:
|
|
707
|
+
throw new Error(`Invalid ObjectStatus: ${value}`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
ObjectStatus2.tryFrom = tryFrom;
|
|
711
|
+
})(exports.ObjectStatus || (exports.ObjectStatus = {}));
|
|
712
|
+
|
|
713
|
+
// src/model/data/datagram_object.ts
|
|
714
|
+
var DatagramObject = class _DatagramObject {
|
|
715
|
+
constructor(type, trackAlias, location, publisherPriority, extensionHeaders, payload) {
|
|
716
|
+
this.type = type;
|
|
717
|
+
this.publisherPriority = publisherPriority;
|
|
718
|
+
this.extensionHeaders = extensionHeaders;
|
|
719
|
+
this.payload = payload;
|
|
720
|
+
this.trackAlias = BigInt(trackAlias);
|
|
721
|
+
this.location = location;
|
|
722
|
+
}
|
|
723
|
+
trackAlias;
|
|
724
|
+
location;
|
|
725
|
+
get groupId() {
|
|
726
|
+
return this.location.group;
|
|
727
|
+
}
|
|
728
|
+
get objectId() {
|
|
729
|
+
return this.location.object;
|
|
730
|
+
}
|
|
731
|
+
static newWithExtensions(trackAlias, groupId, objectId, publisherPriority, extensionHeaders, payload) {
|
|
732
|
+
return new _DatagramObject(
|
|
733
|
+
1 /* WithExtensions */,
|
|
734
|
+
trackAlias,
|
|
735
|
+
new Location(groupId, objectId),
|
|
736
|
+
publisherPriority,
|
|
737
|
+
extensionHeaders,
|
|
738
|
+
payload
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
static newWithoutExtensions(trackAlias, groupId, objectId, publisherPriority, payload) {
|
|
742
|
+
return new _DatagramObject(
|
|
743
|
+
0 /* WithoutExtensions */,
|
|
744
|
+
trackAlias,
|
|
745
|
+
new Location(groupId, objectId),
|
|
746
|
+
publisherPriority,
|
|
747
|
+
null,
|
|
748
|
+
payload
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
serialize() {
|
|
752
|
+
const buf = new ByteBuffer();
|
|
753
|
+
buf.putVI(this.type);
|
|
754
|
+
buf.putVI(this.trackAlias);
|
|
755
|
+
buf.putVI(this.location.group);
|
|
756
|
+
buf.putVI(this.location.object);
|
|
757
|
+
buf.putU8(this.publisherPriority);
|
|
758
|
+
if (this.type === 1 /* WithExtensions */) {
|
|
759
|
+
const extBuf = new ByteBuffer();
|
|
760
|
+
if (this.extensionHeaders) {
|
|
761
|
+
for (const header of this.extensionHeaders) {
|
|
762
|
+
extBuf.putKeyValuePair(header);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const extBytes = extBuf.toUint8Array();
|
|
766
|
+
buf.putLengthPrefixedBytes(extBytes);
|
|
767
|
+
}
|
|
768
|
+
buf.putBytes(this.payload);
|
|
769
|
+
return buf.freeze();
|
|
770
|
+
}
|
|
771
|
+
static deserialize(buf) {
|
|
772
|
+
const msgTypeRaw = buf.getNumberVI();
|
|
773
|
+
const msgType = exports.ObjectDatagramType.tryFrom(msgTypeRaw);
|
|
774
|
+
const trackAlias = buf.getVI();
|
|
775
|
+
const groupId = buf.getVI();
|
|
776
|
+
const objectId = buf.getVI();
|
|
777
|
+
const publisherPriority = buf.getU8();
|
|
778
|
+
let extensionHeaders = null;
|
|
779
|
+
switch (msgType) {
|
|
780
|
+
case 1 /* WithExtensions */: {
|
|
781
|
+
const extBytes = buf.getLengthPrefixedBytes();
|
|
782
|
+
const headerBytes = new FrozenByteBuffer5(extBytes);
|
|
783
|
+
extensionHeaders = [];
|
|
784
|
+
while (headerBytes.remaining > 0) {
|
|
785
|
+
extensionHeaders.push(headerBytes.getKeyValuePair());
|
|
786
|
+
}
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
const payload = buf.getBytes(buf.remaining);
|
|
791
|
+
return new _DatagramObject(
|
|
792
|
+
msgType,
|
|
793
|
+
trackAlias,
|
|
794
|
+
new Location(groupId, objectId),
|
|
795
|
+
publisherPriority,
|
|
796
|
+
extensionHeaders,
|
|
797
|
+
payload
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
// src/model/data/datagram_status.ts
|
|
803
|
+
var DatagramStatus = class _DatagramStatus {
|
|
804
|
+
constructor(type, trackAlias, location, publisherPriority, extensionHeaders, objectStatus) {
|
|
805
|
+
this.type = type;
|
|
806
|
+
this.publisherPriority = publisherPriority;
|
|
807
|
+
this.extensionHeaders = extensionHeaders;
|
|
808
|
+
this.objectStatus = objectStatus;
|
|
809
|
+
this.trackAlias = BigInt(trackAlias);
|
|
810
|
+
this.location = location;
|
|
811
|
+
}
|
|
812
|
+
trackAlias;
|
|
813
|
+
location;
|
|
814
|
+
get groupId() {
|
|
815
|
+
return this.location.group;
|
|
816
|
+
}
|
|
817
|
+
get objectId() {
|
|
818
|
+
return this.location.object;
|
|
819
|
+
}
|
|
820
|
+
static withExtensions(trackAlias, location, publisherPriority, extensionHeaders, objectStatus) {
|
|
821
|
+
return new _DatagramStatus(
|
|
822
|
+
3 /* WithExtensions */,
|
|
823
|
+
trackAlias,
|
|
824
|
+
location,
|
|
825
|
+
publisherPriority,
|
|
826
|
+
extensionHeaders,
|
|
827
|
+
objectStatus
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
static newWithoutExtensions(trackAlias, location, publisherPriority, objectStatus) {
|
|
831
|
+
return new _DatagramStatus(
|
|
832
|
+
2 /* WithoutExtensions */,
|
|
833
|
+
trackAlias,
|
|
834
|
+
location,
|
|
835
|
+
publisherPriority,
|
|
836
|
+
null,
|
|
837
|
+
objectStatus
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
serialize() {
|
|
841
|
+
const buf = new ByteBuffer();
|
|
842
|
+
buf.putVI(this.type);
|
|
843
|
+
buf.putVI(this.trackAlias);
|
|
844
|
+
buf.putVI(this.location.group);
|
|
845
|
+
buf.putVI(this.location.object);
|
|
846
|
+
buf.putU8(this.publisherPriority);
|
|
847
|
+
if (this.type === 3 /* WithExtensions */) {
|
|
848
|
+
const extBuf = new ByteBuffer();
|
|
849
|
+
if (this.extensionHeaders) {
|
|
850
|
+
for (const header of this.extensionHeaders) {
|
|
851
|
+
extBuf.putKeyValuePair(header);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
const extBytes = extBuf.toUint8Array();
|
|
855
|
+
buf.putLengthPrefixedBytes(extBytes);
|
|
856
|
+
}
|
|
857
|
+
buf.putVI(this.objectStatus);
|
|
858
|
+
return buf.freeze();
|
|
859
|
+
}
|
|
860
|
+
static deserialize(buf) {
|
|
861
|
+
const msgTypeRaw = buf.getNumberVI();
|
|
862
|
+
const msgType = exports.ObjectDatagramStatusType.tryFrom(msgTypeRaw);
|
|
863
|
+
const trackAlias = buf.getVI();
|
|
864
|
+
const groupId = buf.getVI();
|
|
865
|
+
const objectId = buf.getVI();
|
|
866
|
+
const publisherPriority = buf.getU8();
|
|
867
|
+
let extensionHeaders = null;
|
|
868
|
+
switch (msgType) {
|
|
869
|
+
case 3 /* WithExtensions */: {
|
|
870
|
+
const extBytes = buf.getLengthPrefixedBytes();
|
|
871
|
+
const headerBytes = new FrozenByteBuffer5(extBytes);
|
|
872
|
+
extensionHeaders = [];
|
|
873
|
+
while (headerBytes.remaining > 0) {
|
|
874
|
+
extensionHeaders.push(headerBytes.getKeyValuePair());
|
|
875
|
+
}
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
console.log("Came here for trying tryFrom with object status");
|
|
880
|
+
const objectStatus = exports.ObjectStatus.tryFrom(buf.getVI());
|
|
881
|
+
return new _DatagramStatus(
|
|
882
|
+
msgType,
|
|
883
|
+
trackAlias,
|
|
884
|
+
new Location(groupId, objectId),
|
|
885
|
+
publisherPriority,
|
|
886
|
+
extensionHeaders,
|
|
887
|
+
objectStatus
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
// src/model/data/fetch_header.ts
|
|
893
|
+
var FetchHeader = class _FetchHeader {
|
|
894
|
+
constructor(type, requestId) {
|
|
895
|
+
this.type = type;
|
|
896
|
+
this.requestId = BigInt(requestId);
|
|
897
|
+
}
|
|
898
|
+
requestId;
|
|
899
|
+
serialize() {
|
|
900
|
+
const buf = new ByteBuffer();
|
|
901
|
+
buf.putVI(this.type);
|
|
902
|
+
buf.putVI(this.requestId);
|
|
903
|
+
return buf.freeze();
|
|
904
|
+
}
|
|
905
|
+
static deserialize(buf) {
|
|
906
|
+
const typeRaw = buf.getVI();
|
|
907
|
+
const type = exports.FetchHeaderType.tryFrom(typeRaw);
|
|
908
|
+
const requestId = buf.getVI();
|
|
909
|
+
return new _FetchHeader(type, requestId);
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
// src/model/data/fetch_object.ts
|
|
914
|
+
var FetchObject = class _FetchObject {
|
|
915
|
+
constructor(location, subgroupId, publisherPriority, extensionHeaders, objectStatus, payload) {
|
|
916
|
+
this.publisherPriority = publisherPriority;
|
|
917
|
+
this.extensionHeaders = extensionHeaders;
|
|
918
|
+
this.objectStatus = objectStatus;
|
|
919
|
+
this.payload = payload;
|
|
920
|
+
this.location = location;
|
|
921
|
+
this.subgroupId = BigInt(subgroupId);
|
|
922
|
+
}
|
|
923
|
+
location;
|
|
924
|
+
subgroupId;
|
|
925
|
+
get groupId() {
|
|
926
|
+
return this.location.group;
|
|
927
|
+
}
|
|
928
|
+
get objectId() {
|
|
929
|
+
return this.location.object;
|
|
930
|
+
}
|
|
931
|
+
static newWithStatus(groupId, subgroupId, objectId, publisherPriority, extensionHeaders, objectStatus) {
|
|
932
|
+
return new _FetchObject(
|
|
933
|
+
new Location(groupId, objectId),
|
|
934
|
+
subgroupId,
|
|
935
|
+
publisherPriority,
|
|
936
|
+
extensionHeaders,
|
|
937
|
+
objectStatus,
|
|
938
|
+
null
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
static newWithPayload(groupId, subgroupId, objectId, publisherPriority, extensionHeaders, payload) {
|
|
942
|
+
return new _FetchObject(
|
|
943
|
+
new Location(groupId, objectId),
|
|
944
|
+
subgroupId,
|
|
945
|
+
publisherPriority,
|
|
946
|
+
extensionHeaders,
|
|
947
|
+
null,
|
|
948
|
+
payload
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
// to be compatible with subgroup_object serialize method
|
|
952
|
+
serialize(_previousObjectId) {
|
|
953
|
+
const buf = new ByteBuffer();
|
|
954
|
+
buf.putVI(this.location.group);
|
|
955
|
+
buf.putVI(this.subgroupId);
|
|
956
|
+
buf.putVI(this.location.object);
|
|
957
|
+
buf.putU8(this.publisherPriority);
|
|
958
|
+
const extensionHeaders = new ByteBuffer();
|
|
959
|
+
if (this.extensionHeaders) {
|
|
960
|
+
for (const header of this.extensionHeaders) {
|
|
961
|
+
extensionHeaders.putKeyValuePair(header);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
const extBytes = extensionHeaders.toUint8Array();
|
|
965
|
+
buf.putLengthPrefixedBytes(extBytes);
|
|
966
|
+
if (this.payload) {
|
|
967
|
+
buf.putLengthPrefixedBytes(this.payload);
|
|
968
|
+
} else {
|
|
969
|
+
buf.putVI(0);
|
|
970
|
+
buf.putVI(this.objectStatus);
|
|
971
|
+
}
|
|
972
|
+
return buf.freeze();
|
|
973
|
+
}
|
|
974
|
+
static deserialize(buf) {
|
|
975
|
+
const groupId = buf.getVI();
|
|
976
|
+
const subgroupId = buf.getVI();
|
|
977
|
+
const objectId = buf.getVI();
|
|
978
|
+
const publisherPriority = buf.getU8();
|
|
979
|
+
const extLen = buf.getNumberVI();
|
|
980
|
+
let extensionHeaders = null;
|
|
981
|
+
if (extLen > 0) {
|
|
982
|
+
const headerBytes = new FrozenByteBuffer5(buf.getBytes(extLen));
|
|
983
|
+
extensionHeaders = [];
|
|
984
|
+
while (headerBytes.remaining > 0) {
|
|
985
|
+
extensionHeaders.push(headerBytes.getKeyValuePair());
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
const payloadLen = buf.getNumberVI();
|
|
989
|
+
let objectStatus = null;
|
|
990
|
+
let payload = null;
|
|
991
|
+
if (payloadLen === 0) {
|
|
992
|
+
objectStatus = exports.ObjectStatus.tryFrom(buf.getVI());
|
|
993
|
+
} else {
|
|
994
|
+
payload = buf.getBytes(payloadLen);
|
|
995
|
+
}
|
|
996
|
+
return new _FetchObject(
|
|
997
|
+
new Location(groupId, objectId),
|
|
998
|
+
subgroupId,
|
|
999
|
+
publisherPriority,
|
|
1000
|
+
extensionHeaders,
|
|
1001
|
+
objectStatus,
|
|
1002
|
+
payload
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
// src/model/data/full_track_name.ts
|
|
1008
|
+
var MAX_NAMESPACE_TUPLE_COUNT = 32;
|
|
1009
|
+
var MAX_FULL_TRACK_NAME_LENGTH = 4096;
|
|
1010
|
+
var FullTrackName = class _FullTrackName {
|
|
1011
|
+
constructor(namespace, name) {
|
|
1012
|
+
this.namespace = namespace;
|
|
1013
|
+
this.name = name;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Human-readable representation: `\<namespace path joined by '/'\>:\<name as lowercase hex\>`.
|
|
1017
|
+
* If the underlying {@link Tuple} exposes `toUtf8Path`, it's used; otherwise the raw fields are joined.
|
|
1018
|
+
* This is lossy only in the sense that name bytes are hex encoded; round-tripping requires serialization.
|
|
1019
|
+
*/
|
|
1020
|
+
toString() {
|
|
1021
|
+
const nsStr = this.namespace.toUtf8Path ? this.namespace.toUtf8Path() : Array.from(this.namespace.fields).join("/");
|
|
1022
|
+
const nameStr = Array.from(this.name).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1023
|
+
return `${nsStr}:${nameStr}`;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Construct a validated full track name.
|
|
1027
|
+
*
|
|
1028
|
+
* Validation steps:
|
|
1029
|
+
* 1. Convert namespace string -\> {@link Tuple} (split on '/') if needed.
|
|
1030
|
+
* 2. Reject if namespace tuple field count is 0 or \> {@link MAX_NAMESPACE_TUPLE_COUNT}.
|
|
1031
|
+
* 3. Encode name string to UTF-8 if needed.
|
|
1032
|
+
* 4. Reject if total serialized length (namespace tuple + name bytes) \> {@link MAX_FULL_TRACK_NAME_LENGTH}.
|
|
1033
|
+
*
|
|
1034
|
+
* @throws :{@link TrackNameError} on any constraint violation.
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* const full = FullTrackName.tryNew('media/video', 'keyframe')
|
|
1038
|
+
* console.log(full.toString()) // media/video:6b65796672616d65
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
static tryNew(namespace, name) {
|
|
1042
|
+
const nsTuple = typeof namespace === "string" ? Tuple.fromUtf8Path(namespace) : namespace;
|
|
1043
|
+
const nsCount = nsTuple.fields.length;
|
|
1044
|
+
if (nsCount === 0 || nsCount > MAX_NAMESPACE_TUPLE_COUNT) {
|
|
1045
|
+
throw new TrackNameError(
|
|
1046
|
+
"FullTrackName::tryNew(nsCount)",
|
|
1047
|
+
`Namespace cannot be empty or cannot exceed ${MAX_NAMESPACE_TUPLE_COUNT} fields`
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
const nameBytes = typeof name === "string" ? new TextEncoder().encode(name) : name;
|
|
1051
|
+
const totalLen = nsTuple.serialize().toUint8Array().length + nameBytes.length;
|
|
1052
|
+
if (totalLen > MAX_FULL_TRACK_NAME_LENGTH) {
|
|
1053
|
+
throw new TrackNameError(
|
|
1054
|
+
"FullTrackName::tryNew(totalLen)",
|
|
1055
|
+
`Total length cannot exceed ${MAX_FULL_TRACK_NAME_LENGTH}`
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
return new _FullTrackName(nsTuple, nameBytes);
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Serialize to a frozen buffer: tuple (namespace) followed by length‑prefixed name bytes.
|
|
1062
|
+
* Consumers needing raw bytes should call `.toUint8Array()` on the returned {@link FrozenByteBuffer}.
|
|
1063
|
+
*/
|
|
1064
|
+
serialize() {
|
|
1065
|
+
const buf = new ByteBuffer();
|
|
1066
|
+
buf.putTuple(this.namespace);
|
|
1067
|
+
buf.putLengthPrefixedBytes(this.name);
|
|
1068
|
+
return buf.freeze();
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Parse a serialized full track name. Performs the same validations as {@link FullTrackName.tryNew}.
|
|
1072
|
+
* The provided buffer's read cursor advances accordingly.
|
|
1073
|
+
* @throws :{@link TrackNameError} if constraints are violated.
|
|
1074
|
+
*/
|
|
1075
|
+
static deserialize(buf) {
|
|
1076
|
+
const namespace = buf.getTuple();
|
|
1077
|
+
const nsCount = namespace.fields.length;
|
|
1078
|
+
if (nsCount === 0 || nsCount > MAX_NAMESPACE_TUPLE_COUNT) {
|
|
1079
|
+
throw new TrackNameError(
|
|
1080
|
+
"FullTrackName::deserialize(nsCount)",
|
|
1081
|
+
`Namespace cannot be empty or cannot exceed ${MAX_NAMESPACE_TUPLE_COUNT} fields`
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
const name = buf.getLengthPrefixedBytes();
|
|
1085
|
+
const totalLen = namespace.serialize().toUint8Array().length + name.length;
|
|
1086
|
+
if (totalLen > MAX_FULL_TRACK_NAME_LENGTH) {
|
|
1087
|
+
throw new TrackNameError(
|
|
1088
|
+
"FullTrackName::deserialize(totalLen)",
|
|
1089
|
+
`Total length cannot exceed ${MAX_FULL_TRACK_NAME_LENGTH}`
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
return new _FullTrackName(namespace, name);
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
// src/model/error/constant.ts
|
|
1097
|
+
exports.TerminationCode = /* @__PURE__ */ ((TerminationCode2) => {
|
|
1098
|
+
TerminationCode2[TerminationCode2["NO_ERROR"] = 0] = "NO_ERROR";
|
|
1099
|
+
TerminationCode2[TerminationCode2["INTERNAL_ERROR"] = 1] = "INTERNAL_ERROR";
|
|
1100
|
+
TerminationCode2[TerminationCode2["UNAUTHORIZED"] = 2] = "UNAUTHORIZED";
|
|
1101
|
+
TerminationCode2[TerminationCode2["PROTOCOL_VIOLATION"] = 3] = "PROTOCOL_VIOLATION";
|
|
1102
|
+
TerminationCode2[TerminationCode2["INVALID_REQUEST_ID"] = 4] = "INVALID_REQUEST_ID";
|
|
1103
|
+
TerminationCode2[TerminationCode2["DUPLICATE_TRACK_ALIAS"] = 5] = "DUPLICATE_TRACK_ALIAS";
|
|
1104
|
+
TerminationCode2[TerminationCode2["KEY_VALUE_FORMATTING_ERROR"] = 6] = "KEY_VALUE_FORMATTING_ERROR";
|
|
1105
|
+
TerminationCode2[TerminationCode2["TOO_MANY_REQUESTS"] = 7] = "TOO_MANY_REQUESTS";
|
|
1106
|
+
TerminationCode2[TerminationCode2["INVALID_PATH"] = 8] = "INVALID_PATH";
|
|
1107
|
+
TerminationCode2[TerminationCode2["MALFORMED_PATH"] = 9] = "MALFORMED_PATH";
|
|
1108
|
+
TerminationCode2[TerminationCode2["GOAWAY_TIMEOUT"] = 16] = "GOAWAY_TIMEOUT";
|
|
1109
|
+
TerminationCode2[TerminationCode2["CONTROL_MESSAGE_TIMEOUT"] = 17] = "CONTROL_MESSAGE_TIMEOUT";
|
|
1110
|
+
TerminationCode2[TerminationCode2["DATA_STREAM_TIMEOUT"] = 18] = "DATA_STREAM_TIMEOUT";
|
|
1111
|
+
TerminationCode2[TerminationCode2["AUTH_TOKEN_CACHE_OVERFLOW"] = 19] = "AUTH_TOKEN_CACHE_OVERFLOW";
|
|
1112
|
+
TerminationCode2[TerminationCode2["DUPLICATE_AUTH_TOKEN_ALIAS"] = 20] = "DUPLICATE_AUTH_TOKEN_ALIAS";
|
|
1113
|
+
TerminationCode2[TerminationCode2["VERSION_NEGOTIATION_FAILED"] = 21] = "VERSION_NEGOTIATION_FAILED";
|
|
1114
|
+
TerminationCode2[TerminationCode2["MALFORMED_AUTH_TOKEN"] = 22] = "MALFORMED_AUTH_TOKEN";
|
|
1115
|
+
TerminationCode2[TerminationCode2["UNKNOWN_AUTH_TOKEN_ALIAS"] = 23] = "UNKNOWN_AUTH_TOKEN_ALIAS";
|
|
1116
|
+
TerminationCode2[TerminationCode2["EXPIRED_AUTH_TOKEN"] = 24] = "EXPIRED_AUTH_TOKEN";
|
|
1117
|
+
TerminationCode2[TerminationCode2["INVALID_AUTHORITY"] = 25] = "INVALID_AUTHORITY";
|
|
1118
|
+
TerminationCode2[TerminationCode2["MALFORMED_AUTHORITY"] = 26] = "MALFORMED_AUTHORITY";
|
|
1119
|
+
return TerminationCode2;
|
|
1120
|
+
})(exports.TerminationCode || {});
|
|
1121
|
+
((TerminationCode2) => {
|
|
1122
|
+
function tryFrom(code) {
|
|
1123
|
+
switch (code) {
|
|
1124
|
+
case 0 /* NO_ERROR */:
|
|
1125
|
+
return 0 /* NO_ERROR */;
|
|
1126
|
+
case 1 /* INTERNAL_ERROR */:
|
|
1127
|
+
return 1 /* INTERNAL_ERROR */;
|
|
1128
|
+
case 2 /* UNAUTHORIZED */:
|
|
1129
|
+
return 2 /* UNAUTHORIZED */;
|
|
1130
|
+
case 3 /* PROTOCOL_VIOLATION */:
|
|
1131
|
+
return 3 /* PROTOCOL_VIOLATION */;
|
|
1132
|
+
case 4 /* INVALID_REQUEST_ID */:
|
|
1133
|
+
return 4 /* INVALID_REQUEST_ID */;
|
|
1134
|
+
case 5 /* DUPLICATE_TRACK_ALIAS */:
|
|
1135
|
+
return 5 /* DUPLICATE_TRACK_ALIAS */;
|
|
1136
|
+
case 6 /* KEY_VALUE_FORMATTING_ERROR */:
|
|
1137
|
+
return 6 /* KEY_VALUE_FORMATTING_ERROR */;
|
|
1138
|
+
case 7 /* TOO_MANY_REQUESTS */:
|
|
1139
|
+
return 7 /* TOO_MANY_REQUESTS */;
|
|
1140
|
+
case 8 /* INVALID_PATH */:
|
|
1141
|
+
return 8 /* INVALID_PATH */;
|
|
1142
|
+
case 9 /* MALFORMED_PATH */:
|
|
1143
|
+
return 9 /* MALFORMED_PATH */;
|
|
1144
|
+
case 16 /* GOAWAY_TIMEOUT */:
|
|
1145
|
+
return 16 /* GOAWAY_TIMEOUT */;
|
|
1146
|
+
case 17 /* CONTROL_MESSAGE_TIMEOUT */:
|
|
1147
|
+
return 17 /* CONTROL_MESSAGE_TIMEOUT */;
|
|
1148
|
+
case 18 /* DATA_STREAM_TIMEOUT */:
|
|
1149
|
+
return 18 /* DATA_STREAM_TIMEOUT */;
|
|
1150
|
+
case 19 /* AUTH_TOKEN_CACHE_OVERFLOW */:
|
|
1151
|
+
return 19 /* AUTH_TOKEN_CACHE_OVERFLOW */;
|
|
1152
|
+
case 20 /* DUPLICATE_AUTH_TOKEN_ALIAS */:
|
|
1153
|
+
return 20 /* DUPLICATE_AUTH_TOKEN_ALIAS */;
|
|
1154
|
+
case 21 /* VERSION_NEGOTIATION_FAILED */:
|
|
1155
|
+
return 21 /* VERSION_NEGOTIATION_FAILED */;
|
|
1156
|
+
default:
|
|
1157
|
+
throw new InvalidTypeError("TerminationCode.tryFrom", `Unknown termination code: ${code}`);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
TerminationCode2.tryFrom = tryFrom;
|
|
1161
|
+
})(exports.TerminationCode || (exports.TerminationCode = {}));
|
|
1162
|
+
|
|
1163
|
+
// src/model/extension_header/constant.ts
|
|
1164
|
+
var LOCHeaderExtensionId = /* @__PURE__ */ ((LOCHeaderExtensionId2) => {
|
|
1165
|
+
LOCHeaderExtensionId2[LOCHeaderExtensionId2["CaptureTimestamp"] = 2] = "CaptureTimestamp";
|
|
1166
|
+
LOCHeaderExtensionId2[LOCHeaderExtensionId2["VideoFrameMarking"] = 4] = "VideoFrameMarking";
|
|
1167
|
+
LOCHeaderExtensionId2[LOCHeaderExtensionId2["AudioLevel"] = 6] = "AudioLevel";
|
|
1168
|
+
LOCHeaderExtensionId2[LOCHeaderExtensionId2["VideoConfig"] = 13] = "VideoConfig";
|
|
1169
|
+
return LOCHeaderExtensionId2;
|
|
1170
|
+
})(LOCHeaderExtensionId || {});
|
|
1171
|
+
function locHeaderExtensionIdFromNumber(value) {
|
|
1172
|
+
switch (value) {
|
|
1173
|
+
case 2:
|
|
1174
|
+
return 2 /* CaptureTimestamp */;
|
|
1175
|
+
case 4:
|
|
1176
|
+
return 4 /* VideoFrameMarking */;
|
|
1177
|
+
case 6:
|
|
1178
|
+
return 6 /* AudioLevel */;
|
|
1179
|
+
case 13:
|
|
1180
|
+
return 13 /* VideoConfig */;
|
|
1181
|
+
default:
|
|
1182
|
+
throw new InvalidTypeError("locHeaderExtensionIdFromNumber", `Invalid LOC header extension id: ${value}`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// src/model/extension_header/capture_time_stamp.ts
|
|
1187
|
+
var CaptureTimestamp = class _CaptureTimestamp {
|
|
1188
|
+
constructor(timestamp) {
|
|
1189
|
+
this.timestamp = timestamp;
|
|
1190
|
+
}
|
|
1191
|
+
static TYPE = 2 /* CaptureTimestamp */;
|
|
1192
|
+
toKeyValuePair() {
|
|
1193
|
+
return KeyValuePair.tryNewVarInt(_CaptureTimestamp.TYPE, this.timestamp);
|
|
1194
|
+
}
|
|
1195
|
+
static fromKeyValuePair(pair) {
|
|
1196
|
+
const type = Number(pair.typeValue);
|
|
1197
|
+
if (type === _CaptureTimestamp.TYPE && typeof pair.value === "bigint") {
|
|
1198
|
+
return new _CaptureTimestamp(pair.value);
|
|
1199
|
+
}
|
|
1200
|
+
return void 0;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
// src/model/extension_header/video_frame_marking.ts
|
|
1205
|
+
var VideoFrameMarking = class _VideoFrameMarking {
|
|
1206
|
+
constructor(value) {
|
|
1207
|
+
this.value = value;
|
|
1208
|
+
}
|
|
1209
|
+
static TYPE = 4 /* VideoFrameMarking */;
|
|
1210
|
+
toKeyValuePair() {
|
|
1211
|
+
return KeyValuePair.tryNewVarInt(_VideoFrameMarking.TYPE, this.value);
|
|
1212
|
+
}
|
|
1213
|
+
static fromKeyValuePair(pair) {
|
|
1214
|
+
const type = Number(pair.typeValue);
|
|
1215
|
+
if (type === _VideoFrameMarking.TYPE && typeof pair.value === "bigint") {
|
|
1216
|
+
return new _VideoFrameMarking(pair.value);
|
|
1217
|
+
}
|
|
1218
|
+
return void 0;
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
// src/model/extension_header/audio_level.ts
|
|
1223
|
+
var AudioLevel = class _AudioLevel {
|
|
1224
|
+
constructor(audioLevel) {
|
|
1225
|
+
this.audioLevel = audioLevel;
|
|
1226
|
+
}
|
|
1227
|
+
static TYPE = 6 /* AudioLevel */;
|
|
1228
|
+
toKeyValuePair() {
|
|
1229
|
+
return KeyValuePair.tryNewVarInt(_AudioLevel.TYPE, this.audioLevel);
|
|
1230
|
+
}
|
|
1231
|
+
static fromKeyValuePair(pair) {
|
|
1232
|
+
const type = Number(pair.typeValue);
|
|
1233
|
+
if (type === _AudioLevel.TYPE && typeof pair.value === "bigint") {
|
|
1234
|
+
return new _AudioLevel(pair.value);
|
|
1235
|
+
}
|
|
1236
|
+
return void 0;
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
// src/model/extension_header/video_config.ts
|
|
1241
|
+
var VideoConfig = class _VideoConfig {
|
|
1242
|
+
constructor(config) {
|
|
1243
|
+
this.config = config;
|
|
1244
|
+
}
|
|
1245
|
+
static TYPE = 13 /* VideoConfig */;
|
|
1246
|
+
toKeyValuePair() {
|
|
1247
|
+
return KeyValuePair.tryNewBytes(_VideoConfig.TYPE, this.config);
|
|
1248
|
+
}
|
|
1249
|
+
static fromKeyValuePair(pair) {
|
|
1250
|
+
const type = Number(pair.typeValue);
|
|
1251
|
+
if (type === _VideoConfig.TYPE && pair.value instanceof Uint8Array) {
|
|
1252
|
+
return new _VideoConfig(pair.value);
|
|
1253
|
+
}
|
|
1254
|
+
return void 0;
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// src/model/extension_header/extension_header.ts
|
|
1259
|
+
exports.ExtensionHeader = void 0;
|
|
1260
|
+
((ExtensionHeader2) => {
|
|
1261
|
+
function fromKeyValuePair(pair) {
|
|
1262
|
+
return CaptureTimestamp.fromKeyValuePair(pair) || VideoFrameMarking.fromKeyValuePair(pair) || AudioLevel.fromKeyValuePair(pair) || VideoConfig.fromKeyValuePair(pair);
|
|
1263
|
+
}
|
|
1264
|
+
ExtensionHeader2.fromKeyValuePair = fromKeyValuePair;
|
|
1265
|
+
function toKeyValuePair(header) {
|
|
1266
|
+
return header.toKeyValuePair();
|
|
1267
|
+
}
|
|
1268
|
+
ExtensionHeader2.toKeyValuePair = toKeyValuePair;
|
|
1269
|
+
function isCaptureTimestamp(header) {
|
|
1270
|
+
return header instanceof CaptureTimestamp;
|
|
1271
|
+
}
|
|
1272
|
+
ExtensionHeader2.isCaptureTimestamp = isCaptureTimestamp;
|
|
1273
|
+
function isVideoFrameMarking(header) {
|
|
1274
|
+
return header instanceof VideoFrameMarking;
|
|
1275
|
+
}
|
|
1276
|
+
ExtensionHeader2.isVideoFrameMarking = isVideoFrameMarking;
|
|
1277
|
+
function isAudioLevel(header) {
|
|
1278
|
+
return header instanceof AudioLevel;
|
|
1279
|
+
}
|
|
1280
|
+
ExtensionHeader2.isAudioLevel = isAudioLevel;
|
|
1281
|
+
function isVideoConfig(header) {
|
|
1282
|
+
return header instanceof VideoConfig;
|
|
1283
|
+
}
|
|
1284
|
+
ExtensionHeader2.isVideoConfig = isVideoConfig;
|
|
1285
|
+
})(exports.ExtensionHeader || (exports.ExtensionHeader = {}));
|
|
1286
|
+
var ExtensionHeaders = class {
|
|
1287
|
+
kvps = [];
|
|
1288
|
+
addCaptureTimestamp(timestamp) {
|
|
1289
|
+
this.kvps.push(new CaptureTimestamp(BigInt(timestamp)).toKeyValuePair());
|
|
1290
|
+
return this;
|
|
1291
|
+
}
|
|
1292
|
+
addVideoFrameMarking(marking) {
|
|
1293
|
+
this.kvps.push(new VideoFrameMarking(BigInt(marking)).toKeyValuePair());
|
|
1294
|
+
return this;
|
|
1295
|
+
}
|
|
1296
|
+
addAudioLevel(audioLevel) {
|
|
1297
|
+
this.kvps.push(new AudioLevel(BigInt(audioLevel)).toKeyValuePair());
|
|
1298
|
+
return this;
|
|
1299
|
+
}
|
|
1300
|
+
addVideoConfig(config) {
|
|
1301
|
+
this.kvps.push(new VideoConfig(config).toKeyValuePair());
|
|
1302
|
+
return this;
|
|
1303
|
+
}
|
|
1304
|
+
addRaw(pair) {
|
|
1305
|
+
this.kvps.push(pair);
|
|
1306
|
+
return this;
|
|
1307
|
+
}
|
|
1308
|
+
build() {
|
|
1309
|
+
return this.kvps;
|
|
1310
|
+
}
|
|
1311
|
+
static fromKeyValuePairs(kvps) {
|
|
1312
|
+
const result = [];
|
|
1313
|
+
for (const kvp of kvps) {
|
|
1314
|
+
const parsed = exports.ExtensionHeader.fromKeyValuePair(kvp);
|
|
1315
|
+
if (parsed) result.push(parsed);
|
|
1316
|
+
}
|
|
1317
|
+
return result;
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
// src/model/data/subgroup_object.ts
|
|
1322
|
+
var SubgroupObject = class _SubgroupObject {
|
|
1323
|
+
constructor(objectId, extensionHeaders, objectStatus, payload) {
|
|
1324
|
+
this.extensionHeaders = extensionHeaders;
|
|
1325
|
+
this.objectStatus = objectStatus;
|
|
1326
|
+
this.payload = payload;
|
|
1327
|
+
this.objectId = BigInt(objectId);
|
|
1328
|
+
}
|
|
1329
|
+
objectId;
|
|
1330
|
+
static newWithStatus(objectId, extensionHeaders, objectStatus) {
|
|
1331
|
+
return new _SubgroupObject(objectId, extensionHeaders, objectStatus, null);
|
|
1332
|
+
}
|
|
1333
|
+
static newWithPayload(objectId, extensionHeaders, payload) {
|
|
1334
|
+
return new _SubgroupObject(objectId, extensionHeaders, null, payload);
|
|
1335
|
+
}
|
|
1336
|
+
// TODO: object delta encoding is missing here...
|
|
1337
|
+
serialize(previousObjectId) {
|
|
1338
|
+
let objectIdDelta = previousObjectId ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
|
|
1339
|
+
const buf = new ByteBuffer();
|
|
1340
|
+
buf.putVI(objectIdDelta);
|
|
1341
|
+
const extensionHeaders = new ByteBuffer();
|
|
1342
|
+
if (this.extensionHeaders) {
|
|
1343
|
+
for (const header of this.extensionHeaders) {
|
|
1344
|
+
extensionHeaders.putKeyValuePair(header);
|
|
1345
|
+
}
|
|
1346
|
+
const headerBytes = extensionHeaders.toUint8Array();
|
|
1347
|
+
buf.putLengthPrefixedBytes(headerBytes);
|
|
1348
|
+
}
|
|
1349
|
+
if (this.payload) {
|
|
1350
|
+
buf.putLengthPrefixedBytes(this.payload);
|
|
1351
|
+
} else {
|
|
1352
|
+
buf.putVI(0);
|
|
1353
|
+
buf.putVI(this.objectStatus);
|
|
1354
|
+
}
|
|
1355
|
+
return buf.freeze();
|
|
1356
|
+
}
|
|
1357
|
+
static deserialize(buf, hasExtensions, previousObjectId) {
|
|
1358
|
+
const objectDelta = buf.getVI();
|
|
1359
|
+
let objectId = previousObjectId !== void 0 ? previousObjectId + objectDelta + BigInt(1) : objectDelta;
|
|
1360
|
+
let extensionHeaders = null;
|
|
1361
|
+
if (hasExtensions) {
|
|
1362
|
+
extensionHeaders = [];
|
|
1363
|
+
const extLen = buf.getNumberVI();
|
|
1364
|
+
const headerBytes = new FrozenByteBuffer5(buf.getBytes(extLen));
|
|
1365
|
+
while (headerBytes.remaining > 0) {
|
|
1366
|
+
extensionHeaders.push(headerBytes.getKeyValuePair());
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
const payloadLen = buf.getNumberVI();
|
|
1370
|
+
let objectStatus = null;
|
|
1371
|
+
let payload = null;
|
|
1372
|
+
if (payloadLen === 0) {
|
|
1373
|
+
objectStatus = exports.ObjectStatus.tryFrom(buf.getVI());
|
|
1374
|
+
} else {
|
|
1375
|
+
payload = buf.getBytes(payloadLen);
|
|
1376
|
+
}
|
|
1377
|
+
return new _SubgroupObject(objectId, extensionHeaders, objectStatus, payload);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
// src/model/data/object.ts
|
|
1382
|
+
var MoqtObject = class _MoqtObject {
|
|
1383
|
+
constructor(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, objectStatus, extensionHeaders, payload) {
|
|
1384
|
+
this.fullTrackName = fullTrackName;
|
|
1385
|
+
this.publisherPriority = publisherPriority;
|
|
1386
|
+
this.objectForwardingPreference = objectForwardingPreference;
|
|
1387
|
+
this.objectStatus = objectStatus;
|
|
1388
|
+
this.extensionHeaders = extensionHeaders;
|
|
1389
|
+
this.payload = payload;
|
|
1390
|
+
this.location = location;
|
|
1391
|
+
this.subgroupId = subgroupId !== null ? BigInt(subgroupId) : null;
|
|
1392
|
+
}
|
|
1393
|
+
location;
|
|
1394
|
+
subgroupId;
|
|
1395
|
+
get groupId() {
|
|
1396
|
+
return this.location.group;
|
|
1397
|
+
}
|
|
1398
|
+
get objectId() {
|
|
1399
|
+
return this.location.object;
|
|
1400
|
+
}
|
|
1401
|
+
getSubgroupHeaderType(containsEnd) {
|
|
1402
|
+
const hasExtensions = !!this.extensionHeaders && this.extensionHeaders.length > 0;
|
|
1403
|
+
const hasSubgroupId = this.subgroupId !== null;
|
|
1404
|
+
const isSubgroupIdZero = this.subgroupId === 0n;
|
|
1405
|
+
if (containsEnd) {
|
|
1406
|
+
if (hasSubgroupId) {
|
|
1407
|
+
return hasExtensions ? 29 /* Type0x1D */ : 28 /* Type0x1C */;
|
|
1408
|
+
} else if (isSubgroupIdZero) {
|
|
1409
|
+
return hasExtensions ? 25 /* Type0x19 */ : 24 /* Type0x18 */;
|
|
1410
|
+
} else {
|
|
1411
|
+
return hasExtensions ? 27 /* Type0x1B */ : 26 /* Type0x1A */;
|
|
1412
|
+
}
|
|
1413
|
+
} else {
|
|
1414
|
+
if (hasSubgroupId) {
|
|
1415
|
+
return hasExtensions ? 21 /* Type0x15 */ : 20 /* Type0x14 */;
|
|
1416
|
+
} else if (isSubgroupIdZero) {
|
|
1417
|
+
return hasExtensions ? 17 /* Type0x11 */ : 16 /* Type0x10 */;
|
|
1418
|
+
} else {
|
|
1419
|
+
return hasExtensions ? 19 /* Type0x13 */ : 18 /* Type0x12 */;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
isDatagram() {
|
|
1424
|
+
return this.objectForwardingPreference === "Datagram" /* Datagram */;
|
|
1425
|
+
}
|
|
1426
|
+
isSubgroup() {
|
|
1427
|
+
return this.objectForwardingPreference === "Subgroup" /* Subgroup */;
|
|
1428
|
+
}
|
|
1429
|
+
isEndOfGroup() {
|
|
1430
|
+
return this.objectStatus === 3 /* EndOfGroup */;
|
|
1431
|
+
}
|
|
1432
|
+
isEndOfTrack() {
|
|
1433
|
+
return this.objectStatus === 4 /* EndOfTrack */;
|
|
1434
|
+
}
|
|
1435
|
+
doesNotExist() {
|
|
1436
|
+
return this.objectStatus === 1 /* DoesNotExist */;
|
|
1437
|
+
}
|
|
1438
|
+
hasPayload() {
|
|
1439
|
+
return this.payload !== null;
|
|
1440
|
+
}
|
|
1441
|
+
hasStatus() {
|
|
1442
|
+
return this.objectStatus !== 0 /* Normal */;
|
|
1443
|
+
}
|
|
1444
|
+
static newWithPayload(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, extensionHeaders, payload) {
|
|
1445
|
+
return new _MoqtObject(
|
|
1446
|
+
fullTrackName,
|
|
1447
|
+
location,
|
|
1448
|
+
publisherPriority,
|
|
1449
|
+
objectForwardingPreference,
|
|
1450
|
+
subgroupId,
|
|
1451
|
+
0 /* Normal */,
|
|
1452
|
+
extensionHeaders,
|
|
1453
|
+
payload
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
static newWithStatus(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, extensionHeaders, objectStatus) {
|
|
1457
|
+
return new _MoqtObject(
|
|
1458
|
+
fullTrackName,
|
|
1459
|
+
location,
|
|
1460
|
+
publisherPriority,
|
|
1461
|
+
objectForwardingPreference,
|
|
1462
|
+
subgroupId,
|
|
1463
|
+
objectStatus,
|
|
1464
|
+
extensionHeaders,
|
|
1465
|
+
null
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
static fromDatagramObject(datagramObject, fullTrackName) {
|
|
1469
|
+
return new _MoqtObject(
|
|
1470
|
+
fullTrackName,
|
|
1471
|
+
new Location(datagramObject.groupId, datagramObject.objectId),
|
|
1472
|
+
datagramObject.publisherPriority,
|
|
1473
|
+
"Datagram" /* Datagram */,
|
|
1474
|
+
null,
|
|
1475
|
+
0 /* Normal */,
|
|
1476
|
+
datagramObject.extensionHeaders,
|
|
1477
|
+
datagramObject.payload
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
static fromDatagramStatus(datagramStatus, fullTrackName) {
|
|
1481
|
+
return new _MoqtObject(
|
|
1482
|
+
fullTrackName,
|
|
1483
|
+
datagramStatus.location,
|
|
1484
|
+
datagramStatus.publisherPriority,
|
|
1485
|
+
"Datagram" /* Datagram */,
|
|
1486
|
+
null,
|
|
1487
|
+
datagramStatus.objectStatus,
|
|
1488
|
+
datagramStatus.extensionHeaders,
|
|
1489
|
+
null
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
static fromFetchObject(fetchObject, fullTrackName) {
|
|
1493
|
+
return new _MoqtObject(
|
|
1494
|
+
fullTrackName,
|
|
1495
|
+
fetchObject.location,
|
|
1496
|
+
fetchObject.publisherPriority,
|
|
1497
|
+
"Subgroup" /* Subgroup */,
|
|
1498
|
+
fetchObject.subgroupId,
|
|
1499
|
+
fetchObject.objectStatus || 0 /* Normal */,
|
|
1500
|
+
fetchObject.extensionHeaders,
|
|
1501
|
+
fetchObject.payload
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
1504
|
+
static fromSubgroupObject(subgroupObject, groupId, publisherPriority, subgroupId, fullTrackName) {
|
|
1505
|
+
return new _MoqtObject(
|
|
1506
|
+
fullTrackName,
|
|
1507
|
+
new Location(groupId, subgroupObject.objectId),
|
|
1508
|
+
publisherPriority,
|
|
1509
|
+
"Subgroup" /* Subgroup */,
|
|
1510
|
+
subgroupId,
|
|
1511
|
+
subgroupObject.objectStatus || 0 /* Normal */,
|
|
1512
|
+
subgroupObject.extensionHeaders,
|
|
1513
|
+
subgroupObject.payload
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
tryIntoDatagramObject(trackAlias) {
|
|
1517
|
+
if (this.objectForwardingPreference !== "Datagram" /* Datagram */) {
|
|
1518
|
+
throw new CastingError(
|
|
1519
|
+
"MoqtObject.tryIntoDatagramObject",
|
|
1520
|
+
"MoqtObject",
|
|
1521
|
+
"DatagramObject",
|
|
1522
|
+
"Object Forwarding Preference must be Datagram"
|
|
1523
|
+
);
|
|
1524
|
+
}
|
|
1525
|
+
if (this.objectStatus !== 0 /* Normal */ || !this.payload) {
|
|
1526
|
+
throw new ProtocolViolationError(
|
|
1527
|
+
"MoqtObject.tryIntoDatagramObject",
|
|
1528
|
+
"Object must have Normal status and payload for DatagramObject conversion"
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
const alias = BigInt(trackAlias);
|
|
1532
|
+
if (this.extensionHeaders && this.extensionHeaders.length > 0) {
|
|
1533
|
+
return DatagramObject.newWithExtensions(
|
|
1534
|
+
alias,
|
|
1535
|
+
this.groupId,
|
|
1536
|
+
this.objectId,
|
|
1537
|
+
this.publisherPriority,
|
|
1538
|
+
this.extensionHeaders,
|
|
1539
|
+
this.payload
|
|
1540
|
+
);
|
|
1541
|
+
} else {
|
|
1542
|
+
return DatagramObject.newWithoutExtensions(
|
|
1543
|
+
alias,
|
|
1544
|
+
this.groupId,
|
|
1545
|
+
this.objectId,
|
|
1546
|
+
this.publisherPriority,
|
|
1547
|
+
this.payload
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
tryIntoDatagramStatus(trackAlias) {
|
|
1552
|
+
if (this.objectForwardingPreference !== "Datagram" /* Datagram */) {
|
|
1553
|
+
throw new CastingError(
|
|
1554
|
+
"MoqtObject.tryIntoDatagramStatus",
|
|
1555
|
+
"MoqtObject",
|
|
1556
|
+
"DatagramStatus",
|
|
1557
|
+
"Object Forwarding Preference must be Datagram"
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
if (this.objectStatus === 0 /* Normal */) {
|
|
1561
|
+
throw new ProtocolViolationError(
|
|
1562
|
+
"MoqtObject.tryIntoDatagramStatus",
|
|
1563
|
+
"Object Status must not be Normal for DatagramStatus conversion"
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
const alias = BigInt(trackAlias);
|
|
1567
|
+
if (this.extensionHeaders && this.extensionHeaders.length > 0) {
|
|
1568
|
+
return DatagramStatus.withExtensions(
|
|
1569
|
+
alias,
|
|
1570
|
+
this.location,
|
|
1571
|
+
this.publisherPriority,
|
|
1572
|
+
this.extensionHeaders,
|
|
1573
|
+
this.objectStatus
|
|
1574
|
+
);
|
|
1575
|
+
} else {
|
|
1576
|
+
return DatagramStatus.newWithoutExtensions(alias, this.location, this.publisherPriority, this.objectStatus);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
tryIntoFetchObject() {
|
|
1580
|
+
if (this.objectForwardingPreference !== "Subgroup" /* Subgroup */) {
|
|
1581
|
+
throw new CastingError(
|
|
1582
|
+
"MoqtObject.tryIntoFetchObject",
|
|
1583
|
+
"MoqtObject",
|
|
1584
|
+
"FetchObject",
|
|
1585
|
+
"Object Forwarding Preference must be Subgroup"
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
if (this.subgroupId === null) {
|
|
1589
|
+
throw new ProtocolViolationError(
|
|
1590
|
+
"MoqtObject.tryIntoFetchObject",
|
|
1591
|
+
"Subgroup ID is required for Subgroup forwarding preference"
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
if (this.objectStatus === 0 /* Normal */ && this.payload) {
|
|
1595
|
+
return FetchObject.newWithPayload(
|
|
1596
|
+
this.groupId,
|
|
1597
|
+
this.subgroupId,
|
|
1598
|
+
this.objectId,
|
|
1599
|
+
this.publisherPriority,
|
|
1600
|
+
this.extensionHeaders,
|
|
1601
|
+
this.payload
|
|
1602
|
+
);
|
|
1603
|
+
} else {
|
|
1604
|
+
return FetchObject.newWithStatus(
|
|
1605
|
+
this.groupId,
|
|
1606
|
+
this.subgroupId,
|
|
1607
|
+
this.objectId,
|
|
1608
|
+
this.publisherPriority,
|
|
1609
|
+
this.extensionHeaders,
|
|
1610
|
+
this.objectStatus
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
tryIntoSubgroupObject() {
|
|
1615
|
+
if (this.objectForwardingPreference !== "Subgroup" /* Subgroup */) {
|
|
1616
|
+
throw new CastingError(
|
|
1617
|
+
"MoqtObject.tryIntoSubgroupObject",
|
|
1618
|
+
"MoqtObject",
|
|
1619
|
+
"SubgroupObject",
|
|
1620
|
+
"Object Forwarding Preference must be Subgroup"
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
if (this.objectStatus === 0 /* Normal */ && this.payload) {
|
|
1624
|
+
return SubgroupObject.newWithPayload(this.location.object, this.extensionHeaders, this.payload);
|
|
1625
|
+
} else {
|
|
1626
|
+
return SubgroupObject.newWithStatus(this.location.object, this.extensionHeaders, this.objectStatus);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1631
|
+
// src/model/data/subgroup_header.ts
|
|
1632
|
+
var SubgroupHeader = class _SubgroupHeader {
|
|
1633
|
+
constructor(type, trackAlias, groupId, subgroupId, publisherPriority) {
|
|
1634
|
+
this.type = type;
|
|
1635
|
+
this.publisherPriority = publisherPriority;
|
|
1636
|
+
this.trackAlias = BigInt(trackAlias);
|
|
1637
|
+
this.groupId = BigInt(groupId);
|
|
1638
|
+
if (subgroupId !== void 0) {
|
|
1639
|
+
this.subgroupId = BigInt(subgroupId);
|
|
1640
|
+
} else {
|
|
1641
|
+
this.subgroupId = subgroupId;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
subgroupId;
|
|
1645
|
+
trackAlias;
|
|
1646
|
+
groupId;
|
|
1647
|
+
serialize() {
|
|
1648
|
+
const buf = new ByteBuffer();
|
|
1649
|
+
buf.putVI(this.type);
|
|
1650
|
+
buf.putVI(this.trackAlias);
|
|
1651
|
+
buf.putVI(this.groupId);
|
|
1652
|
+
if (exports.SubgroupHeaderType.hasExplicitSubgroupId(this.type)) {
|
|
1653
|
+
if (this.subgroupId === void 0) {
|
|
1654
|
+
throw new ProtocolViolationError(
|
|
1655
|
+
"SubgroupHeader.serialize",
|
|
1656
|
+
"Subgroup_id field is required for this header type"
|
|
1657
|
+
);
|
|
1658
|
+
}
|
|
1659
|
+
buf.putVI(this.subgroupId);
|
|
1660
|
+
}
|
|
1661
|
+
buf.putU8(this.publisherPriority);
|
|
1662
|
+
return buf.freeze();
|
|
1663
|
+
}
|
|
1664
|
+
static deserialize(buf) {
|
|
1665
|
+
const headerType = exports.SubgroupHeaderType.tryFrom(buf.getNumberVI());
|
|
1666
|
+
const trackAlias = buf.getVI();
|
|
1667
|
+
const groupId = buf.getVI();
|
|
1668
|
+
let subgroupId;
|
|
1669
|
+
if (exports.SubgroupHeaderType.hasExplicitSubgroupId(headerType)) {
|
|
1670
|
+
subgroupId = buf.getVI();
|
|
1671
|
+
} else if (exports.SubgroupHeaderType.isSubgroupIdZero(headerType)) {
|
|
1672
|
+
subgroupId = 0n;
|
|
1673
|
+
}
|
|
1674
|
+
const publisherPriority = buf.getU8();
|
|
1675
|
+
return new _SubgroupHeader(headerType, trackAlias, groupId, subgroupId, publisherPriority);
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1679
|
+
// src/model/data/request_id.ts
|
|
1680
|
+
var RequestIdMap = class {
|
|
1681
|
+
requestIdToName = /* @__PURE__ */ new Map();
|
|
1682
|
+
nameToRequestId = /* @__PURE__ */ new Map();
|
|
1683
|
+
/**
|
|
1684
|
+
* @public
|
|
1685
|
+
* Adds a mapping between a requestId and a full track name.
|
|
1686
|
+
*
|
|
1687
|
+
* @param requestId - The requestId to associate.
|
|
1688
|
+
* @param name - The full track name to associate.
|
|
1689
|
+
* @throws :{@link RequestIdError} if the requestId or name is already mapped to a different value.
|
|
1690
|
+
*/
|
|
1691
|
+
addMapping(requestId, name) {
|
|
1692
|
+
if (this.requestIdToName.has(requestId)) {
|
|
1693
|
+
const existingName = this.requestIdToName.get(requestId);
|
|
1694
|
+
if (existingName === name) return;
|
|
1695
|
+
throw new RequestIdError(
|
|
1696
|
+
"RequestIdMap::addMapping(existingName)",
|
|
1697
|
+
`Full track name already exists for requestId: ${requestId}`
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
if (this.nameToRequestId.has(name)) {
|
|
1701
|
+
const existingRequestId = this.nameToRequestId.get(name);
|
|
1702
|
+
if (existingRequestId === requestId) return;
|
|
1703
|
+
throw new RequestIdError(
|
|
1704
|
+
"RequestIdMap::addMapping(existingRequestId)",
|
|
1705
|
+
`A requestId already exists for full track name: ${name}`
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
this.requestIdToName.set(requestId, name);
|
|
1709
|
+
this.nameToRequestId.set(name, requestId);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* @public
|
|
1713
|
+
* Gets the full track name for a given requestId.
|
|
1714
|
+
*
|
|
1715
|
+
* @param requestId - The requestId to look up.
|
|
1716
|
+
* @returns The associated full track name.
|
|
1717
|
+
* @throws :{@link RequestIdError} if the requestId does not exist.
|
|
1718
|
+
*/
|
|
1719
|
+
getNameByRequestId(requestId) {
|
|
1720
|
+
const name = this.requestIdToName.get(requestId);
|
|
1721
|
+
if (!name)
|
|
1722
|
+
throw new RequestIdError("RequestIdMap::getNameByRequestId(name)", `RequestId: ${requestId} doesn't exist`);
|
|
1723
|
+
return name;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* @public
|
|
1727
|
+
* Gets the requestId for a given full track name.
|
|
1728
|
+
*
|
|
1729
|
+
* @param name - The full track name to look up.
|
|
1730
|
+
* @returns The associated requestId.
|
|
1731
|
+
* @throws :{@link RequestIdError} if the name does not exist.
|
|
1732
|
+
*/
|
|
1733
|
+
getRequestIdByName(name) {
|
|
1734
|
+
const requestId = this.nameToRequestId.get(name);
|
|
1735
|
+
if (requestId === void 0)
|
|
1736
|
+
throw new RequestIdError("RequestIdMap::getRequestIdByName(requestId)", `Name does not exist`);
|
|
1737
|
+
return requestId;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* @public
|
|
1741
|
+
* Removes a mapping by requestId.
|
|
1742
|
+
*
|
|
1743
|
+
* @param requestId - The requestId to remove.
|
|
1744
|
+
* @returns The removed full track name, or undefined if not found.
|
|
1745
|
+
*/
|
|
1746
|
+
removeMappingByRequestId(requestId) {
|
|
1747
|
+
const name = this.requestIdToName.get(requestId);
|
|
1748
|
+
if (name) {
|
|
1749
|
+
this.requestIdToName.delete(requestId);
|
|
1750
|
+
this.nameToRequestId.delete(name);
|
|
1751
|
+
return name;
|
|
1752
|
+
}
|
|
1753
|
+
return void 0;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* @public
|
|
1757
|
+
* Removes a mapping by full track name.
|
|
1758
|
+
*
|
|
1759
|
+
* @param name - The full track name to remove.
|
|
1760
|
+
* @returns The removed requestId, or undefined if not found.
|
|
1761
|
+
*/
|
|
1762
|
+
removeMappingByName(name) {
|
|
1763
|
+
const requestId = this.nameToRequestId.get(name);
|
|
1764
|
+
if (requestId !== void 0) {
|
|
1765
|
+
this.nameToRequestId.delete(name);
|
|
1766
|
+
this.requestIdToName.delete(requestId);
|
|
1767
|
+
return requestId;
|
|
1768
|
+
}
|
|
1769
|
+
return void 0;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* @public
|
|
1773
|
+
* Checks if the map contains a given requestId.
|
|
1774
|
+
*
|
|
1775
|
+
* @param requestId - The requestId to check.
|
|
1776
|
+
* @returns True if the requestId exists, false otherwise.
|
|
1777
|
+
*/
|
|
1778
|
+
containsRequestId(requestId) {
|
|
1779
|
+
return this.requestIdToName.has(requestId);
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* @public
|
|
1783
|
+
* Checks if the map contains a given full track name.
|
|
1784
|
+
*
|
|
1785
|
+
* @param name - The full track name to check.
|
|
1786
|
+
* @returns True if the name exists, false otherwise.
|
|
1787
|
+
*/
|
|
1788
|
+
containsName(name) {
|
|
1789
|
+
return this.nameToRequestId.has(name);
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
// src/model/data/header.ts
|
|
1794
|
+
exports.Header = void 0;
|
|
1795
|
+
((Header2) => {
|
|
1796
|
+
function newFetch(...args) {
|
|
1797
|
+
return new FetchHeader(...args);
|
|
1798
|
+
}
|
|
1799
|
+
Header2.newFetch = newFetch;
|
|
1800
|
+
function newSubgroup(...args) {
|
|
1801
|
+
return new SubgroupHeader(...args);
|
|
1802
|
+
}
|
|
1803
|
+
Header2.newSubgroup = newSubgroup;
|
|
1804
|
+
function isFetch(header) {
|
|
1805
|
+
return header instanceof FetchHeader;
|
|
1806
|
+
}
|
|
1807
|
+
Header2.isFetch = isFetch;
|
|
1808
|
+
function isSubgroup(header) {
|
|
1809
|
+
return header instanceof SubgroupHeader;
|
|
1810
|
+
}
|
|
1811
|
+
Header2.isSubgroup = isSubgroup;
|
|
1812
|
+
function serialize(header) {
|
|
1813
|
+
return header.serialize();
|
|
1814
|
+
}
|
|
1815
|
+
Header2.serialize = serialize;
|
|
1816
|
+
function deserialize(buf) {
|
|
1817
|
+
buf.checkpoint();
|
|
1818
|
+
const type = buf.getNumberVI();
|
|
1819
|
+
buf.restore();
|
|
1820
|
+
switch (type) {
|
|
1821
|
+
case 5:
|
|
1822
|
+
return FetchHeader.deserialize(buf);
|
|
1823
|
+
case 16:
|
|
1824
|
+
case 17:
|
|
1825
|
+
case 18:
|
|
1826
|
+
case 19:
|
|
1827
|
+
case 20:
|
|
1828
|
+
case 21:
|
|
1829
|
+
case 24:
|
|
1830
|
+
case 25:
|
|
1831
|
+
case 26:
|
|
1832
|
+
case 27:
|
|
1833
|
+
case 28:
|
|
1834
|
+
case 29:
|
|
1835
|
+
return SubgroupHeader.deserialize(buf);
|
|
1836
|
+
default:
|
|
1837
|
+
throw new InvalidTypeError("Header::deserialize(type)", `Unknown header type: ${type}`);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
Header2.deserialize = deserialize;
|
|
1841
|
+
})(exports.Header || (exports.Header = {}));
|
|
1842
|
+
|
|
1843
|
+
// src/model/common/byte_buffer.ts
|
|
1844
|
+
var MAX_VARINT_1BYTE = 2n ** 6n - 1n;
|
|
1845
|
+
var MAX_VARINT_2BYTE = 2n ** 14n - 1n;
|
|
1846
|
+
var MAX_VARINT_4BYTE = 2n ** 30n - 1n;
|
|
1847
|
+
var MAX_VARINT_8BYTE = 2n ** 62n - 1n;
|
|
1848
|
+
var BaseByteBuffer12 = class {
|
|
1849
|
+
buf;
|
|
1850
|
+
view;
|
|
1851
|
+
_offset = 0;
|
|
1852
|
+
_checkpoint = 0;
|
|
1853
|
+
constructor(buf) {
|
|
1854
|
+
this.buf = buf;
|
|
1855
|
+
this.view = new DataView(buf.buffer, buf.byteOffset, buf.length);
|
|
1856
|
+
}
|
|
1857
|
+
get offset() {
|
|
1858
|
+
return this._offset;
|
|
1859
|
+
}
|
|
1860
|
+
get remaining() {
|
|
1861
|
+
return this.length - this._offset;
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Save current read position for potential rollback
|
|
1865
|
+
*/
|
|
1866
|
+
checkpoint() {
|
|
1867
|
+
this._checkpoint = this._offset;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Restore read position to last checkpoint
|
|
1871
|
+
*/
|
|
1872
|
+
restore() {
|
|
1873
|
+
this._offset = this._checkpoint;
|
|
1874
|
+
}
|
|
1875
|
+
toUint8Array() {
|
|
1876
|
+
return this.buf.slice();
|
|
1877
|
+
}
|
|
1878
|
+
getU8() {
|
|
1879
|
+
if (this.remaining < 1) throw new NotEnoughBytesError("getU8", 1, this.remaining);
|
|
1880
|
+
return this.view.getUint8(this._offset++);
|
|
1881
|
+
}
|
|
1882
|
+
getU16() {
|
|
1883
|
+
if (this.remaining < 2) throw new NotEnoughBytesError("getU16", 2, this.remaining);
|
|
1884
|
+
const v = this.view.getUint16(this._offset, false);
|
|
1885
|
+
this._offset += 2;
|
|
1886
|
+
return v;
|
|
1887
|
+
}
|
|
1888
|
+
getVI() {
|
|
1889
|
+
if (this.remaining < 1) throw new NotEnoughBytesError("getVI.first_byte", 1, this.remaining);
|
|
1890
|
+
const first = this.getU8();
|
|
1891
|
+
const prefix = first >> 6;
|
|
1892
|
+
let numBytes;
|
|
1893
|
+
switch (prefix) {
|
|
1894
|
+
case 0:
|
|
1895
|
+
numBytes = 1;
|
|
1896
|
+
break;
|
|
1897
|
+
case 1:
|
|
1898
|
+
numBytes = 2;
|
|
1899
|
+
break;
|
|
1900
|
+
case 2:
|
|
1901
|
+
numBytes = 4;
|
|
1902
|
+
break;
|
|
1903
|
+
case 3:
|
|
1904
|
+
numBytes = 8;
|
|
1905
|
+
break;
|
|
1906
|
+
default:
|
|
1907
|
+
throw new Error("Invalid varint prefix");
|
|
1908
|
+
}
|
|
1909
|
+
if (numBytes > 1 && this.remaining < numBytes - 1) {
|
|
1910
|
+
this._offset--;
|
|
1911
|
+
throw new NotEnoughBytesError("getVI.continuation", numBytes, this.remaining + 1);
|
|
1912
|
+
}
|
|
1913
|
+
let result = BigInt(first & 63);
|
|
1914
|
+
if (numBytes > 1) {
|
|
1915
|
+
result <<= BigInt((numBytes - 1) * 8);
|
|
1916
|
+
for (let i = 1; i < numBytes; i++) {
|
|
1917
|
+
const b = BigInt(this.getU8());
|
|
1918
|
+
result |= b << BigInt((numBytes - 1 - i) * 8);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return result;
|
|
1922
|
+
}
|
|
1923
|
+
getNumberVI() {
|
|
1924
|
+
let big = this.getVI();
|
|
1925
|
+
if (big > Number.MAX_SAFE_INTEGER)
|
|
1926
|
+
throw new CastingError(
|
|
1927
|
+
"BaseByteBuffer.getNumberVI()",
|
|
1928
|
+
"bigint",
|
|
1929
|
+
"number",
|
|
1930
|
+
"bigint exceeds Number.MAX_SAFE_INTEGER"
|
|
1931
|
+
);
|
|
1932
|
+
return Number(big);
|
|
1933
|
+
}
|
|
1934
|
+
getBytes(len) {
|
|
1935
|
+
if (this.remaining < len) throw new NotEnoughBytesError("getBytes", len, this.remaining);
|
|
1936
|
+
const slice = this.buf.slice(this._offset, this._offset + len);
|
|
1937
|
+
this._offset += len;
|
|
1938
|
+
return slice;
|
|
1939
|
+
}
|
|
1940
|
+
getLengthPrefixedBytes() {
|
|
1941
|
+
const len = this.getNumberVI();
|
|
1942
|
+
if (this.length < this.offset + len)
|
|
1943
|
+
throw new NotEnoughBytesError("BaseByteBuffer.getLengthPrefixedBytes", len, this.length - this.offset);
|
|
1944
|
+
return this.getBytes(len);
|
|
1945
|
+
}
|
|
1946
|
+
getKeyValuePair() {
|
|
1947
|
+
return KeyValuePair.deserialize(this);
|
|
1948
|
+
}
|
|
1949
|
+
getReasonPhrase() {
|
|
1950
|
+
return ReasonPhrase.deserialize(this);
|
|
1951
|
+
}
|
|
1952
|
+
getLocation() {
|
|
1953
|
+
return Location.deserialize(this);
|
|
1954
|
+
}
|
|
1955
|
+
getTuple() {
|
|
1956
|
+
return Tuple.deserialize(this);
|
|
1957
|
+
}
|
|
1958
|
+
getFullTrackName() {
|
|
1959
|
+
return FullTrackName.deserialize(this);
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
var ByteBuffer = class extends BaseByteBuffer12 {
|
|
1963
|
+
_length = 0;
|
|
1964
|
+
constructor(initialSize = 128) {
|
|
1965
|
+
super(new Uint8Array(initialSize));
|
|
1966
|
+
}
|
|
1967
|
+
get length() {
|
|
1968
|
+
return this._length;
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Clear all data and reset all positions
|
|
1972
|
+
*/
|
|
1973
|
+
clear() {
|
|
1974
|
+
this._length = 0;
|
|
1975
|
+
this._offset = 0;
|
|
1976
|
+
this._checkpoint = 0;
|
|
1977
|
+
this.buf = new Uint8Array();
|
|
1978
|
+
this.view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.length);
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Drop all data before current offset and reset positions
|
|
1982
|
+
* This is the key method for memory management - removes processed data
|
|
1983
|
+
*/
|
|
1984
|
+
commit() {
|
|
1985
|
+
if (this._offset === 0) {
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
if (this._offset >= this._length) {
|
|
1989
|
+
this.clear();
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
this.buf.set(this.buf.subarray(this._offset, this._length), 0);
|
|
1993
|
+
this._length = this._length - this._offset;
|
|
1994
|
+
this._offset = 0;
|
|
1995
|
+
this._checkpoint = 0;
|
|
1996
|
+
this.view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.length);
|
|
1997
|
+
}
|
|
1998
|
+
ensureCapacity(add) {
|
|
1999
|
+
const need = this._length + add;
|
|
2000
|
+
if (need <= this.buf.length) return;
|
|
2001
|
+
let newSize = this.buf.length * 2 + 1;
|
|
2002
|
+
while (newSize < need) newSize *= 2;
|
|
2003
|
+
const newBuf = new Uint8Array(newSize);
|
|
2004
|
+
newBuf.set(this.buf.subarray(0, this._length));
|
|
2005
|
+
this.buf = newBuf;
|
|
2006
|
+
this.view = new DataView(this.buf.buffer);
|
|
2007
|
+
}
|
|
2008
|
+
// --------- WRITE OPERATIONS ---------
|
|
2009
|
+
putU8(v) {
|
|
2010
|
+
if (v < 0 || v > 255) {
|
|
2011
|
+
throw new RangeError(`Value ${v} is out of range for a U8 (0-255).`);
|
|
2012
|
+
}
|
|
2013
|
+
this.ensureCapacity(1);
|
|
2014
|
+
this.view.setUint8(this._length++, v);
|
|
2015
|
+
}
|
|
2016
|
+
putU16(v) {
|
|
2017
|
+
if (v < 0 || v > 65535) {
|
|
2018
|
+
throw new RangeError(`Value ${v} is out of range for a U16 (0-65535).`);
|
|
2019
|
+
}
|
|
2020
|
+
this.ensureCapacity(2);
|
|
2021
|
+
this.view.setUint16(this._length, v, false);
|
|
2022
|
+
this._length += 2;
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Write a variable-length integer (QUIC-style varint)
|
|
2026
|
+
* Encoding:
|
|
2027
|
+
* - 2 MSB = 00: 1 byte (6 bits) for values 0-63
|
|
2028
|
+
* - 2 MSB = 01: 2 bytes (14 bits) for values 0-16383
|
|
2029
|
+
* - 2 MSB = 10: 4 bytes (30 bits) for values 0-1073741823
|
|
2030
|
+
* - 2 MSB = 11: 8 bytes (62 bits) for values 0-4611686018427387903
|
|
2031
|
+
*/
|
|
2032
|
+
putVI(v) {
|
|
2033
|
+
const value = typeof v === "number" ? BigInt(v) : v;
|
|
2034
|
+
if (value < 0) {
|
|
2035
|
+
throw new CastingError("putVI", typeof v, "unsigned varint", "negative values are not supported");
|
|
2036
|
+
}
|
|
2037
|
+
if (value <= MAX_VARINT_1BYTE) {
|
|
2038
|
+
this.putU8(Number(value));
|
|
2039
|
+
} else if (value <= MAX_VARINT_2BYTE) {
|
|
2040
|
+
this.ensureCapacity(2);
|
|
2041
|
+
this.view.setUint8(this._length++, Number(value >> 8n | 0b01000000n));
|
|
2042
|
+
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
2043
|
+
} else if (value <= MAX_VARINT_4BYTE) {
|
|
2044
|
+
this.ensureCapacity(4);
|
|
2045
|
+
this.view.setUint8(this._length++, Number(value >> 24n | 0b10000000n));
|
|
2046
|
+
this.view.setUint8(this._length++, Number(value >> 16n & 0xffn));
|
|
2047
|
+
this.view.setUint8(this._length++, Number(value >> 8n & 0xffn));
|
|
2048
|
+
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
2049
|
+
} else if (value <= MAX_VARINT_8BYTE) {
|
|
2050
|
+
this.ensureCapacity(8);
|
|
2051
|
+
this.view.setUint8(this._length++, Number(value >> 56n | 0b11000000n));
|
|
2052
|
+
this.view.setUint8(this._length++, Number(value >> 48n & 0xffn));
|
|
2053
|
+
this.view.setUint8(this._length++, Number(value >> 40n & 0xffn));
|
|
2054
|
+
this.view.setUint8(this._length++, Number(value >> 32n & 0xffn));
|
|
2055
|
+
this.view.setUint8(this._length++, Number(value >> 24n & 0xffn));
|
|
2056
|
+
this.view.setUint8(this._length++, Number(value >> 16n & 0xffn));
|
|
2057
|
+
this.view.setUint8(this._length++, Number(value >> 8n & 0xffn));
|
|
2058
|
+
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
2059
|
+
} else {
|
|
2060
|
+
throw new VarIntOverflowError("putVI", Number(value));
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
putBytes(src) {
|
|
2064
|
+
this.ensureCapacity(src.length);
|
|
2065
|
+
this.buf.set(src, this._length);
|
|
2066
|
+
this._length += src.length;
|
|
2067
|
+
}
|
|
2068
|
+
putLengthPrefixedBytes(src) {
|
|
2069
|
+
this.putVI(src.length);
|
|
2070
|
+
this.putBytes(src);
|
|
2071
|
+
}
|
|
2072
|
+
putKeyValuePair(pair) {
|
|
2073
|
+
const b = pair.serialize().toUint8Array();
|
|
2074
|
+
this.putBytes(b);
|
|
2075
|
+
}
|
|
2076
|
+
putReasonPhrase(reason) {
|
|
2077
|
+
const b = reason.serialize().toUint8Array();
|
|
2078
|
+
this.putBytes(b);
|
|
2079
|
+
}
|
|
2080
|
+
toUint8Array() {
|
|
2081
|
+
return this.buf.slice(0, this._length);
|
|
2082
|
+
}
|
|
2083
|
+
freeze() {
|
|
2084
|
+
const snap = this.buf.slice(0, this._length);
|
|
2085
|
+
return new FrozenByteBuffer5(snap);
|
|
2086
|
+
}
|
|
2087
|
+
putLocation(loc) {
|
|
2088
|
+
this.putVI(loc.group);
|
|
2089
|
+
this.putVI(loc.object);
|
|
2090
|
+
}
|
|
2091
|
+
putTuple(tuple) {
|
|
2092
|
+
const serialized = tuple.serialize();
|
|
2093
|
+
this.putBytes(serialized.toUint8Array());
|
|
2094
|
+
}
|
|
2095
|
+
putFullTrackName(fullTrackName) {
|
|
2096
|
+
const serialized = fullTrackName.serialize();
|
|
2097
|
+
this.putBytes(serialized.toUint8Array());
|
|
2098
|
+
}
|
|
2099
|
+
};
|
|
2100
|
+
var FrozenByteBuffer5 = class extends BaseByteBuffer12 {
|
|
2101
|
+
constructor(buf) {
|
|
2102
|
+
super(buf);
|
|
2103
|
+
}
|
|
2104
|
+
get length() {
|
|
2105
|
+
return this.buf.length;
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
// src/model/control/constant.ts
|
|
2110
|
+
var DRAFT_14 = 4278190094;
|
|
2111
|
+
var ControlMessageType = /* @__PURE__ */ ((ControlMessageType2) => {
|
|
2112
|
+
ControlMessageType2[ControlMessageType2["ReservedSetupV00"] = 1] = "ReservedSetupV00";
|
|
2113
|
+
ControlMessageType2[ControlMessageType2["ReservedClientSetupV10"] = 64] = "ReservedClientSetupV10";
|
|
2114
|
+
ControlMessageType2[ControlMessageType2["ReservedServerSetupV10"] = 65] = "ReservedServerSetupV10";
|
|
2115
|
+
ControlMessageType2[ControlMessageType2["ClientSetup"] = 32] = "ClientSetup";
|
|
2116
|
+
ControlMessageType2[ControlMessageType2["ServerSetup"] = 33] = "ServerSetup";
|
|
2117
|
+
ControlMessageType2[ControlMessageType2["GoAway"] = 16] = "GoAway";
|
|
2118
|
+
ControlMessageType2[ControlMessageType2["MaxRequestId"] = 21] = "MaxRequestId";
|
|
2119
|
+
ControlMessageType2[ControlMessageType2["RequestsBlocked"] = 26] = "RequestsBlocked";
|
|
2120
|
+
ControlMessageType2[ControlMessageType2["Subscribe"] = 3] = "Subscribe";
|
|
2121
|
+
ControlMessageType2[ControlMessageType2["SubscribeOk"] = 4] = "SubscribeOk";
|
|
2122
|
+
ControlMessageType2[ControlMessageType2["SubscribeError"] = 5] = "SubscribeError";
|
|
2123
|
+
ControlMessageType2[ControlMessageType2["Unsubscribe"] = 10] = "Unsubscribe";
|
|
2124
|
+
ControlMessageType2[ControlMessageType2["SubscribeUpdate"] = 2] = "SubscribeUpdate";
|
|
2125
|
+
ControlMessageType2[ControlMessageType2["PublishDone"] = 11] = "PublishDone";
|
|
2126
|
+
ControlMessageType2[ControlMessageType2["Fetch"] = 22] = "Fetch";
|
|
2127
|
+
ControlMessageType2[ControlMessageType2["FetchOk"] = 24] = "FetchOk";
|
|
2128
|
+
ControlMessageType2[ControlMessageType2["FetchError"] = 25] = "FetchError";
|
|
2129
|
+
ControlMessageType2[ControlMessageType2["FetchCancel"] = 23] = "FetchCancel";
|
|
2130
|
+
ControlMessageType2[ControlMessageType2["TrackStatus"] = 13] = "TrackStatus";
|
|
2131
|
+
ControlMessageType2[ControlMessageType2["TrackStatusOk"] = 14] = "TrackStatusOk";
|
|
2132
|
+
ControlMessageType2[ControlMessageType2["TrackStatusError"] = 15] = "TrackStatusError";
|
|
2133
|
+
ControlMessageType2[ControlMessageType2["PublishNamespace"] = 6] = "PublishNamespace";
|
|
2134
|
+
ControlMessageType2[ControlMessageType2["PublishNamespaceOk"] = 7] = "PublishNamespaceOk";
|
|
2135
|
+
ControlMessageType2[ControlMessageType2["PublishNamespaceError"] = 8] = "PublishNamespaceError";
|
|
2136
|
+
ControlMessageType2[ControlMessageType2["PublishNamespaceDone"] = 9] = "PublishNamespaceDone";
|
|
2137
|
+
ControlMessageType2[ControlMessageType2["PublishNamespaceCancel"] = 12] = "PublishNamespaceCancel";
|
|
2138
|
+
ControlMessageType2[ControlMessageType2["SubscribeNamespace"] = 17] = "SubscribeNamespace";
|
|
2139
|
+
ControlMessageType2[ControlMessageType2["SubscribeNamespaceOk"] = 18] = "SubscribeNamespaceOk";
|
|
2140
|
+
ControlMessageType2[ControlMessageType2["SubscribeNamespaceError"] = 19] = "SubscribeNamespaceError";
|
|
2141
|
+
ControlMessageType2[ControlMessageType2["UnsubscribeNamespace"] = 20] = "UnsubscribeNamespace";
|
|
2142
|
+
ControlMessageType2[ControlMessageType2["Publish"] = 29] = "Publish";
|
|
2143
|
+
ControlMessageType2[ControlMessageType2["PublishOk"] = 30] = "PublishOk";
|
|
2144
|
+
ControlMessageType2[ControlMessageType2["PublishError"] = 31] = "PublishError";
|
|
2145
|
+
ControlMessageType2[ControlMessageType2["Switch"] = 34] = "Switch";
|
|
2146
|
+
return ControlMessageType2;
|
|
2147
|
+
})(ControlMessageType || {});
|
|
2148
|
+
function controlMessageTypeFromBigInt(v) {
|
|
2149
|
+
switch (v) {
|
|
2150
|
+
case 0x01n:
|
|
2151
|
+
return 1 /* ReservedSetupV00 */;
|
|
2152
|
+
case 0x40n:
|
|
2153
|
+
return 64 /* ReservedClientSetupV10 */;
|
|
2154
|
+
case 0x41n:
|
|
2155
|
+
return 65 /* ReservedServerSetupV10 */;
|
|
2156
|
+
case 0x20n:
|
|
2157
|
+
return 32 /* ClientSetup */;
|
|
2158
|
+
case 0x21n:
|
|
2159
|
+
return 33 /* ServerSetup */;
|
|
2160
|
+
case 0x10n:
|
|
2161
|
+
return 16 /* GoAway */;
|
|
2162
|
+
case 0x15n:
|
|
2163
|
+
return 21 /* MaxRequestId */;
|
|
2164
|
+
case 0x1an:
|
|
2165
|
+
return 26 /* RequestsBlocked */;
|
|
2166
|
+
case 0x03n:
|
|
2167
|
+
return 3 /* Subscribe */;
|
|
2168
|
+
case 0x04n:
|
|
2169
|
+
return 4 /* SubscribeOk */;
|
|
2170
|
+
case 0x05n:
|
|
2171
|
+
return 5 /* SubscribeError */;
|
|
2172
|
+
case 0x0an:
|
|
2173
|
+
return 10 /* Unsubscribe */;
|
|
2174
|
+
case 0x02n:
|
|
2175
|
+
return 2 /* SubscribeUpdate */;
|
|
2176
|
+
case 0x0bn:
|
|
2177
|
+
return 11 /* PublishDone */;
|
|
2178
|
+
case 0x16n:
|
|
2179
|
+
return 22 /* Fetch */;
|
|
2180
|
+
case 0x18n:
|
|
2181
|
+
return 24 /* FetchOk */;
|
|
2182
|
+
case 0x19n:
|
|
2183
|
+
return 25 /* FetchError */;
|
|
2184
|
+
case 0x17n:
|
|
2185
|
+
return 23 /* FetchCancel */;
|
|
2186
|
+
case 0x0dn:
|
|
2187
|
+
return 13 /* TrackStatus */;
|
|
2188
|
+
case 0x0en:
|
|
2189
|
+
return 13 /* TrackStatus */;
|
|
2190
|
+
case 0x06n:
|
|
2191
|
+
return 6 /* PublishNamespace */;
|
|
2192
|
+
case 0x07n:
|
|
2193
|
+
return 7 /* PublishNamespaceOk */;
|
|
2194
|
+
case 0x08n:
|
|
2195
|
+
return 8 /* PublishNamespaceError */;
|
|
2196
|
+
case 0x09n:
|
|
2197
|
+
return 9 /* PublishNamespaceDone */;
|
|
2198
|
+
case 0x0cn:
|
|
2199
|
+
return 12 /* PublishNamespaceCancel */;
|
|
2200
|
+
case 0x11n:
|
|
2201
|
+
return 17 /* SubscribeNamespace */;
|
|
2202
|
+
case 0x12n:
|
|
2203
|
+
return 18 /* SubscribeNamespaceOk */;
|
|
2204
|
+
case 0x13n:
|
|
2205
|
+
return 19 /* SubscribeNamespaceError */;
|
|
2206
|
+
case 0x14n:
|
|
2207
|
+
return 20 /* UnsubscribeNamespace */;
|
|
2208
|
+
case 0x1dn:
|
|
2209
|
+
return 29 /* Publish */;
|
|
2210
|
+
case 0x1en:
|
|
2211
|
+
return 30 /* PublishOk */;
|
|
2212
|
+
case 0x1fn:
|
|
2213
|
+
return 31 /* PublishError */;
|
|
2214
|
+
default:
|
|
2215
|
+
throw new Error(`Invalid ControlMessageType: ${v}`);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
var PublishNamespaceErrorCode = /* @__PURE__ */ ((PublishNamespaceErrorCode4) => {
|
|
2219
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["InternalError"] = 0] = "InternalError";
|
|
2220
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["Unauthorized"] = 1] = "Unauthorized";
|
|
2221
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["Timeout"] = 2] = "Timeout";
|
|
2222
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["NotSupported"] = 3] = "NotSupported";
|
|
2223
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["Uninterested"] = 4] = "Uninterested";
|
|
2224
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["MalformedAuthToken"] = 16] = "MalformedAuthToken";
|
|
2225
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["UnknownAuthTokenAlias"] = 17] = "UnknownAuthTokenAlias";
|
|
2226
|
+
PublishNamespaceErrorCode4[PublishNamespaceErrorCode4["ExpiredAuthToken"] = 18] = "ExpiredAuthToken";
|
|
2227
|
+
return PublishNamespaceErrorCode4;
|
|
2228
|
+
})(PublishNamespaceErrorCode || {});
|
|
2229
|
+
function publishNamespaceErrorCodeFromBigInt(v) {
|
|
2230
|
+
switch (v) {
|
|
2231
|
+
case 0x0n:
|
|
2232
|
+
return 0 /* InternalError */;
|
|
2233
|
+
case 0x1n:
|
|
2234
|
+
return 1 /* Unauthorized */;
|
|
2235
|
+
case 0x2n:
|
|
2236
|
+
return 2 /* Timeout */;
|
|
2237
|
+
case 0x3n:
|
|
2238
|
+
return 3 /* NotSupported */;
|
|
2239
|
+
case 0x4n:
|
|
2240
|
+
return 4 /* Uninterested */;
|
|
2241
|
+
case 0x10n:
|
|
2242
|
+
return 16 /* MalformedAuthToken */;
|
|
2243
|
+
case 0x11n:
|
|
2244
|
+
return 17 /* UnknownAuthTokenAlias */;
|
|
2245
|
+
case 0x12n:
|
|
2246
|
+
return 18 /* ExpiredAuthToken */;
|
|
2247
|
+
default:
|
|
2248
|
+
throw new Error(`Invalid PublishNamespaceErrorCode: ${v}`);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
var FilterType = /* @__PURE__ */ ((FilterType2) => {
|
|
2252
|
+
FilterType2[FilterType2["NextGroupStart"] = 1] = "NextGroupStart";
|
|
2253
|
+
FilterType2[FilterType2["LatestObject"] = 2] = "LatestObject";
|
|
2254
|
+
FilterType2[FilterType2["AbsoluteStart"] = 3] = "AbsoluteStart";
|
|
2255
|
+
FilterType2[FilterType2["AbsoluteRange"] = 4] = "AbsoluteRange";
|
|
2256
|
+
return FilterType2;
|
|
2257
|
+
})(FilterType || {});
|
|
2258
|
+
function filterTypeFromBigInt(v) {
|
|
2259
|
+
switch (v) {
|
|
2260
|
+
case 0x1n:
|
|
2261
|
+
return 1 /* NextGroupStart */;
|
|
2262
|
+
case 0x2n:
|
|
2263
|
+
return 2 /* LatestObject */;
|
|
2264
|
+
case 0x3n:
|
|
2265
|
+
return 3 /* AbsoluteStart */;
|
|
2266
|
+
case 0x4n:
|
|
2267
|
+
return 4 /* AbsoluteRange */;
|
|
2268
|
+
default:
|
|
2269
|
+
throw new Error(`Invalid FilterType: ${v}`);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
var FetchType = /* @__PURE__ */ ((FetchType3) => {
|
|
2273
|
+
FetchType3[FetchType3["StandAlone"] = 1] = "StandAlone";
|
|
2274
|
+
FetchType3[FetchType3["Relative"] = 2] = "Relative";
|
|
2275
|
+
FetchType3[FetchType3["Absolute"] = 3] = "Absolute";
|
|
2276
|
+
return FetchType3;
|
|
2277
|
+
})(FetchType || {});
|
|
2278
|
+
function fetchTypeFromBigInt(v) {
|
|
2279
|
+
switch (v) {
|
|
2280
|
+
case 0x1n:
|
|
2281
|
+
return 1 /* StandAlone */;
|
|
2282
|
+
case 0x2n:
|
|
2283
|
+
return 2 /* Relative */;
|
|
2284
|
+
case 0x3n:
|
|
2285
|
+
return 3 /* Absolute */;
|
|
2286
|
+
default:
|
|
2287
|
+
throw new CastingError("fetchTypeFromBigInt", "bigint", "FetchType", `Invalid FetchType:${v}`);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
var GroupOrder = /* @__PURE__ */ ((GroupOrder6) => {
|
|
2291
|
+
GroupOrder6[GroupOrder6["Original"] = 0] = "Original";
|
|
2292
|
+
GroupOrder6[GroupOrder6["Ascending"] = 1] = "Ascending";
|
|
2293
|
+
GroupOrder6[GroupOrder6["Descending"] = 2] = "Descending";
|
|
2294
|
+
return GroupOrder6;
|
|
2295
|
+
})(GroupOrder || {});
|
|
2296
|
+
function groupOrderFromNumber(v) {
|
|
2297
|
+
switch (v) {
|
|
2298
|
+
case 0:
|
|
2299
|
+
return 0 /* Original */;
|
|
2300
|
+
case 1:
|
|
2301
|
+
return 1 /* Ascending */;
|
|
2302
|
+
case 2:
|
|
2303
|
+
return 2 /* Descending */;
|
|
2304
|
+
default:
|
|
2305
|
+
throw new CastingError("groupOrderFromNumber", "number", "GroupOrder", `Invalid GroupOrder: ${v}`);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
var SubscribeErrorCode = /* @__PURE__ */ ((SubscribeErrorCode4) => {
|
|
2309
|
+
SubscribeErrorCode4[SubscribeErrorCode4["InternalError"] = 0] = "InternalError";
|
|
2310
|
+
SubscribeErrorCode4[SubscribeErrorCode4["Unauthorized"] = 1] = "Unauthorized";
|
|
2311
|
+
SubscribeErrorCode4[SubscribeErrorCode4["Timeout"] = 2] = "Timeout";
|
|
2312
|
+
SubscribeErrorCode4[SubscribeErrorCode4["NotSupported"] = 3] = "NotSupported";
|
|
2313
|
+
SubscribeErrorCode4[SubscribeErrorCode4["TrackDoesNotExist"] = 4] = "TrackDoesNotExist";
|
|
2314
|
+
SubscribeErrorCode4[SubscribeErrorCode4["InvalidRange"] = 5] = "InvalidRange";
|
|
2315
|
+
SubscribeErrorCode4[SubscribeErrorCode4["MalformedAuthToken"] = 16] = "MalformedAuthToken";
|
|
2316
|
+
SubscribeErrorCode4[SubscribeErrorCode4["ExpiredAuthToken"] = 18] = "ExpiredAuthToken";
|
|
2317
|
+
return SubscribeErrorCode4;
|
|
2318
|
+
})(SubscribeErrorCode || {});
|
|
2319
|
+
function subscribeErrorCodeFromBigInt(v) {
|
|
2320
|
+
switch (v) {
|
|
2321
|
+
case 0x0n:
|
|
2322
|
+
return 0 /* InternalError */;
|
|
2323
|
+
case 0x1n:
|
|
2324
|
+
return 1 /* Unauthorized */;
|
|
2325
|
+
case 0x2n:
|
|
2326
|
+
return 2 /* Timeout */;
|
|
2327
|
+
case 0x3n:
|
|
2328
|
+
return 3 /* NotSupported */;
|
|
2329
|
+
case 0x4n:
|
|
2330
|
+
return 4 /* TrackDoesNotExist */;
|
|
2331
|
+
case 0x5n:
|
|
2332
|
+
return 5 /* InvalidRange */;
|
|
2333
|
+
case 0x10n:
|
|
2334
|
+
return 16 /* MalformedAuthToken */;
|
|
2335
|
+
case 0x12n:
|
|
2336
|
+
return 18 /* ExpiredAuthToken */;
|
|
2337
|
+
default:
|
|
2338
|
+
throw new Error(`Invalid SubscribeErrorCode: ${v}`);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
var FetchErrorCode = /* @__PURE__ */ ((FetchErrorCode3) => {
|
|
2342
|
+
FetchErrorCode3[FetchErrorCode3["InternalError"] = 0] = "InternalError";
|
|
2343
|
+
FetchErrorCode3[FetchErrorCode3["Unauthorized"] = 1] = "Unauthorized";
|
|
2344
|
+
FetchErrorCode3[FetchErrorCode3["Timeout"] = 2] = "Timeout";
|
|
2345
|
+
FetchErrorCode3[FetchErrorCode3["NotSupported"] = 3] = "NotSupported";
|
|
2346
|
+
FetchErrorCode3[FetchErrorCode3["TrackDoesNotExist"] = 4] = "TrackDoesNotExist";
|
|
2347
|
+
FetchErrorCode3[FetchErrorCode3["InvalidRange"] = 5] = "InvalidRange";
|
|
2348
|
+
FetchErrorCode3[FetchErrorCode3["NoObjects"] = 6] = "NoObjects";
|
|
2349
|
+
FetchErrorCode3[FetchErrorCode3["InvalidJoiningRequestId"] = 7] = "InvalidJoiningRequestId";
|
|
2350
|
+
FetchErrorCode3[FetchErrorCode3["UnknownStatusInRange"] = 8] = "UnknownStatusInRange";
|
|
2351
|
+
FetchErrorCode3[FetchErrorCode3["MalformedTrack"] = 9] = "MalformedTrack";
|
|
2352
|
+
FetchErrorCode3[FetchErrorCode3["MalformedAuthToken"] = 16] = "MalformedAuthToken";
|
|
2353
|
+
FetchErrorCode3[FetchErrorCode3["ExpiredAuthToken"] = 18] = "ExpiredAuthToken";
|
|
2354
|
+
return FetchErrorCode3;
|
|
2355
|
+
})(FetchErrorCode || {});
|
|
2356
|
+
function fetchErrorCodeFromBigInt(v) {
|
|
2357
|
+
switch (v) {
|
|
2358
|
+
case 0x0n:
|
|
2359
|
+
return 0 /* InternalError */;
|
|
2360
|
+
case 0x1n:
|
|
2361
|
+
return 1 /* Unauthorized */;
|
|
2362
|
+
case 0x2n:
|
|
2363
|
+
return 2 /* Timeout */;
|
|
2364
|
+
case 0x3n:
|
|
2365
|
+
return 3 /* NotSupported */;
|
|
2366
|
+
case 0x4n:
|
|
2367
|
+
return 4 /* TrackDoesNotExist */;
|
|
2368
|
+
case 0x5n:
|
|
2369
|
+
return 5 /* InvalidRange */;
|
|
2370
|
+
case 0x6n:
|
|
2371
|
+
return 6 /* NoObjects */;
|
|
2372
|
+
case 0x7n:
|
|
2373
|
+
return 7 /* InvalidJoiningRequestId */;
|
|
2374
|
+
case 0x8n:
|
|
2375
|
+
return 8 /* UnknownStatusInRange */;
|
|
2376
|
+
case 0x9n:
|
|
2377
|
+
return 9 /* MalformedTrack */;
|
|
2378
|
+
case 0x10n:
|
|
2379
|
+
return 16 /* MalformedAuthToken */;
|
|
2380
|
+
case 0x12n:
|
|
2381
|
+
return 18 /* ExpiredAuthToken */;
|
|
2382
|
+
default:
|
|
2383
|
+
throw new CastingError("fetchErrorCodeFromBigInt", "number", "FetchErrorCode", "Invalid fetch error code");
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
var TrackStatusCode = /* @__PURE__ */ ((TrackStatusCode2) => {
|
|
2387
|
+
TrackStatusCode2[TrackStatusCode2["InProgress"] = 0] = "InProgress";
|
|
2388
|
+
TrackStatusCode2[TrackStatusCode2["DoesNotExist"] = 1] = "DoesNotExist";
|
|
2389
|
+
TrackStatusCode2[TrackStatusCode2["NotYetBegun"] = 2] = "NotYetBegun";
|
|
2390
|
+
TrackStatusCode2[TrackStatusCode2["Finished"] = 3] = "Finished";
|
|
2391
|
+
TrackStatusCode2[TrackStatusCode2["RelayUnavailable"] = 4] = "RelayUnavailable";
|
|
2392
|
+
return TrackStatusCode2;
|
|
2393
|
+
})(TrackStatusCode || {});
|
|
2394
|
+
function trackStatusCodeFromBigInt(v) {
|
|
2395
|
+
switch (v) {
|
|
2396
|
+
case 0x00n:
|
|
2397
|
+
return 0 /* InProgress */;
|
|
2398
|
+
case 0x01n:
|
|
2399
|
+
return 1 /* DoesNotExist */;
|
|
2400
|
+
case 0x02n:
|
|
2401
|
+
return 2 /* NotYetBegun */;
|
|
2402
|
+
case 0x03n:
|
|
2403
|
+
return 3 /* Finished */;
|
|
2404
|
+
case 0x04n:
|
|
2405
|
+
return 4 /* RelayUnavailable */;
|
|
2406
|
+
default:
|
|
2407
|
+
throw new Error(`Invalid TrackStatusCode: ${v}`);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
var SubscribeNamespaceErrorCode = /* @__PURE__ */ ((SubscribeNamespaceErrorCode3) => {
|
|
2411
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["InternalError"] = 0] = "InternalError";
|
|
2412
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["Unauthorized"] = 1] = "Unauthorized";
|
|
2413
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["Timeout"] = 2] = "Timeout";
|
|
2414
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["NotSupported"] = 3] = "NotSupported";
|
|
2415
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["NamespacePrefixUnknown"] = 4] = "NamespacePrefixUnknown";
|
|
2416
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["NamespacePrefixOverlap"] = 5] = "NamespacePrefixOverlap";
|
|
2417
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["MalformedAuthToken"] = 16] = "MalformedAuthToken";
|
|
2418
|
+
SubscribeNamespaceErrorCode3[SubscribeNamespaceErrorCode3["ExpiredAuthToken"] = 18] = "ExpiredAuthToken";
|
|
2419
|
+
return SubscribeNamespaceErrorCode3;
|
|
2420
|
+
})(SubscribeNamespaceErrorCode || {});
|
|
2421
|
+
function subscribeNamespaceErrorCodeFromBigInt(v) {
|
|
2422
|
+
switch (v) {
|
|
2423
|
+
case 0x0n:
|
|
2424
|
+
return 0 /* InternalError */;
|
|
2425
|
+
case 0x1n:
|
|
2426
|
+
return 1 /* Unauthorized */;
|
|
2427
|
+
case 0x2n:
|
|
2428
|
+
return 2 /* Timeout */;
|
|
2429
|
+
case 0x3n:
|
|
2430
|
+
return 3 /* NotSupported */;
|
|
2431
|
+
case 0x4n:
|
|
2432
|
+
return 4 /* NamespacePrefixUnknown */;
|
|
2433
|
+
case 0x5n:
|
|
2434
|
+
return 5 /* NamespacePrefixOverlap */;
|
|
2435
|
+
case 0x10n:
|
|
2436
|
+
return 16 /* MalformedAuthToken */;
|
|
2437
|
+
case 0x12n:
|
|
2438
|
+
return 18 /* ExpiredAuthToken */;
|
|
2439
|
+
default:
|
|
2440
|
+
throw new Error(`Invalid SubscribeNamespaceErrorCode: ${v}`);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
var PublishDoneStatusCode = /* @__PURE__ */ ((PublishDoneStatusCode3) => {
|
|
2444
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["InternalError"] = 0] = "InternalError";
|
|
2445
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["Unauthorized"] = 1] = "Unauthorized";
|
|
2446
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["TrackEnded"] = 2] = "TrackEnded";
|
|
2447
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["SubscriptionEnded"] = 3] = "SubscriptionEnded";
|
|
2448
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["GoingAway"] = 4] = "GoingAway";
|
|
2449
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["Expired"] = 5] = "Expired";
|
|
2450
|
+
PublishDoneStatusCode3[PublishDoneStatusCode3["TooFarBehind"] = 6] = "TooFarBehind";
|
|
2451
|
+
return PublishDoneStatusCode3;
|
|
2452
|
+
})(PublishDoneStatusCode || {});
|
|
2453
|
+
function publishDoneStatusCodeFromBigInt(v) {
|
|
2454
|
+
switch (v) {
|
|
2455
|
+
case 0x0n:
|
|
2456
|
+
return 0 /* InternalError */;
|
|
2457
|
+
case 0x1n:
|
|
2458
|
+
return 1 /* Unauthorized */;
|
|
2459
|
+
case 0x2n:
|
|
2460
|
+
return 2 /* TrackEnded */;
|
|
2461
|
+
case 0x3n:
|
|
2462
|
+
return 3 /* SubscriptionEnded */;
|
|
2463
|
+
case 0x4n:
|
|
2464
|
+
return 4 /* GoingAway */;
|
|
2465
|
+
case 0x5n:
|
|
2466
|
+
return 5 /* Expired */;
|
|
2467
|
+
case 0x6n:
|
|
2468
|
+
return 6 /* TooFarBehind */;
|
|
2469
|
+
default:
|
|
2470
|
+
throw new Error(`Invalid PublishDoneStatusCode: ${v}`);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
var PublishErrorCode = /* @__PURE__ */ ((PublishErrorCode3) => {
|
|
2474
|
+
PublishErrorCode3[PublishErrorCode3["InternalError"] = 0] = "InternalError";
|
|
2475
|
+
PublishErrorCode3[PublishErrorCode3["Unauthorized"] = 1] = "Unauthorized";
|
|
2476
|
+
PublishErrorCode3[PublishErrorCode3["Timeout"] = 2] = "Timeout";
|
|
2477
|
+
PublishErrorCode3[PublishErrorCode3["NotSupported"] = 3] = "NotSupported";
|
|
2478
|
+
PublishErrorCode3[PublishErrorCode3["InvalidNamespace"] = 4] = "InvalidNamespace";
|
|
2479
|
+
PublishErrorCode3[PublishErrorCode3["InvalidTrackName"] = 5] = "InvalidTrackName";
|
|
2480
|
+
PublishErrorCode3[PublishErrorCode3["MalformedAuthToken"] = 16] = "MalformedAuthToken";
|
|
2481
|
+
PublishErrorCode3[PublishErrorCode3["UnknownAuthTokenAlias"] = 17] = "UnknownAuthTokenAlias";
|
|
2482
|
+
PublishErrorCode3[PublishErrorCode3["ExpiredAuthToken"] = 18] = "ExpiredAuthToken";
|
|
2483
|
+
return PublishErrorCode3;
|
|
2484
|
+
})(PublishErrorCode || {});
|
|
2485
|
+
function publishErrorCodeFromBigInt(v) {
|
|
2486
|
+
switch (v) {
|
|
2487
|
+
case 0x0n:
|
|
2488
|
+
return 0 /* InternalError */;
|
|
2489
|
+
case 0x1n:
|
|
2490
|
+
return 1 /* Unauthorized */;
|
|
2491
|
+
case 0x2n:
|
|
2492
|
+
return 2 /* Timeout */;
|
|
2493
|
+
case 0x3n:
|
|
2494
|
+
return 3 /* NotSupported */;
|
|
2495
|
+
case 0x4n:
|
|
2496
|
+
return 4 /* InvalidNamespace */;
|
|
2497
|
+
case 0x5n:
|
|
2498
|
+
return 5 /* InvalidTrackName */;
|
|
2499
|
+
case 0x10n:
|
|
2500
|
+
return 16 /* MalformedAuthToken */;
|
|
2501
|
+
case 0x11n:
|
|
2502
|
+
return 17 /* UnknownAuthTokenAlias */;
|
|
2503
|
+
case 0x12n:
|
|
2504
|
+
return 18 /* ExpiredAuthToken */;
|
|
2505
|
+
default:
|
|
2506
|
+
throw new Error(`Invalid PublishErrorCode: ${v}`);
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
// src/model/control/publish_namespace.ts
|
|
2511
|
+
var PublishNamespace = class _PublishNamespace {
|
|
2512
|
+
/**
|
|
2513
|
+
* @public
|
|
2514
|
+
* Constructs a PublishNamespace message.
|
|
2515
|
+
*
|
|
2516
|
+
* @param requestId - The request ID for this publish namespace message.
|
|
2517
|
+
* @param trackNamespace - The track namespace as a Tuple.
|
|
2518
|
+
* @param parameters - The list of key-value parameters for the track.
|
|
2519
|
+
*/
|
|
2520
|
+
constructor(requestId, trackNamespace, parameters) {
|
|
2521
|
+
this.requestId = requestId;
|
|
2522
|
+
this.trackNamespace = trackNamespace;
|
|
2523
|
+
this.parameters = parameters;
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* @public
|
|
2527
|
+
* Gets the message type for this PublishNamespace message.
|
|
2528
|
+
*
|
|
2529
|
+
* @returns The ControlMessageType.Announce value.
|
|
2530
|
+
*/
|
|
2531
|
+
getType() {
|
|
2532
|
+
return 6 /* PublishNamespace */;
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* @public
|
|
2536
|
+
* Serializes the PublishNamespace message into a {@link FrozenByteBuffer}.
|
|
2537
|
+
*
|
|
2538
|
+
* @returns The serialized buffer.
|
|
2539
|
+
* @throws :{@link LengthExceedsMaxError} If the payload exceeds 65535 bytes.
|
|
2540
|
+
*/
|
|
2541
|
+
serialize() {
|
|
2542
|
+
const buf = new ByteBuffer();
|
|
2543
|
+
buf.putVI(6 /* PublishNamespace */);
|
|
2544
|
+
const payload = new ByteBuffer();
|
|
2545
|
+
payload.putVI(this.requestId);
|
|
2546
|
+
payload.putTuple(this.trackNamespace);
|
|
2547
|
+
payload.putVI(this.parameters.length);
|
|
2548
|
+
for (const param of this.parameters) {
|
|
2549
|
+
payload.putKeyValuePair(param);
|
|
2550
|
+
}
|
|
2551
|
+
const payloadBytes = payload.toUint8Array();
|
|
2552
|
+
if (payloadBytes.length > 65535) {
|
|
2553
|
+
throw new LengthExceedsMaxError("PublishNamespace::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
2554
|
+
}
|
|
2555
|
+
buf.putU16(payloadBytes.length);
|
|
2556
|
+
buf.putBytes(payloadBytes);
|
|
2557
|
+
return buf.freeze();
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* @public
|
|
2561
|
+
* Parses a PublishNamespace message from the given buffer.
|
|
2562
|
+
*
|
|
2563
|
+
* @param buf - The buffer to parse from.
|
|
2564
|
+
* @returns The parsed PublishNamespace message.
|
|
2565
|
+
* @throws :{@link NotEnoughBytesError} If the buffer does not contain enough bytes.
|
|
2566
|
+
*/
|
|
2567
|
+
static parsePayload(buf) {
|
|
2568
|
+
const requestId = buf.getVI();
|
|
2569
|
+
const trackNamespace = buf.getTuple();
|
|
2570
|
+
const paramCount = buf.getNumberVI();
|
|
2571
|
+
const parameters = new Array(paramCount);
|
|
2572
|
+
for (let i = 0; i < paramCount; i++) {
|
|
2573
|
+
parameters[i] = buf.getKeyValuePair();
|
|
2574
|
+
}
|
|
2575
|
+
return new _PublishNamespace(requestId, trackNamespace, parameters);
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2579
|
+
// src/model/control/subscribe.ts
|
|
2580
|
+
var Subscribe = class _Subscribe {
|
|
2581
|
+
constructor(requestId, fullTrackName, subscriberPriority, groupOrder, forward, filterType, startLocation, endGroup, parameters) {
|
|
2582
|
+
this.requestId = requestId;
|
|
2583
|
+
this.fullTrackName = fullTrackName;
|
|
2584
|
+
this.subscriberPriority = subscriberPriority;
|
|
2585
|
+
this.groupOrder = groupOrder;
|
|
2586
|
+
this.forward = forward;
|
|
2587
|
+
this.filterType = filterType;
|
|
2588
|
+
this.startLocation = startLocation;
|
|
2589
|
+
this.endGroup = endGroup;
|
|
2590
|
+
this.parameters = parameters;
|
|
2591
|
+
}
|
|
2592
|
+
static newNextGroupStart(requestId, fullTrackName, subscriberPriority, groupOrder, forward, parameters) {
|
|
2593
|
+
return new _Subscribe(
|
|
2594
|
+
requestId,
|
|
2595
|
+
fullTrackName,
|
|
2596
|
+
subscriberPriority,
|
|
2597
|
+
groupOrder,
|
|
2598
|
+
forward,
|
|
2599
|
+
1 /* NextGroupStart */,
|
|
2600
|
+
void 0,
|
|
2601
|
+
void 0,
|
|
2602
|
+
parameters
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
static newLatestObject(requestId, fullTrackName, subscriberPriority, groupOrder, forward, parameters) {
|
|
2606
|
+
return new _Subscribe(
|
|
2607
|
+
requestId,
|
|
2608
|
+
fullTrackName,
|
|
2609
|
+
subscriberPriority,
|
|
2610
|
+
groupOrder,
|
|
2611
|
+
forward,
|
|
2612
|
+
2 /* LatestObject */,
|
|
2613
|
+
void 0,
|
|
2614
|
+
void 0,
|
|
2615
|
+
parameters
|
|
2616
|
+
);
|
|
2617
|
+
}
|
|
2618
|
+
static newAbsoluteStart(requestId, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, parameters) {
|
|
2619
|
+
return new _Subscribe(
|
|
2620
|
+
requestId,
|
|
2621
|
+
fullTrackName,
|
|
2622
|
+
subscriberPriority,
|
|
2623
|
+
groupOrder,
|
|
2624
|
+
forward,
|
|
2625
|
+
3 /* AbsoluteStart */,
|
|
2626
|
+
startLocation,
|
|
2627
|
+
void 0,
|
|
2628
|
+
parameters
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
static newAbsoluteRange(requestId, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, endGroup, parameters) {
|
|
2632
|
+
if (endGroup < startLocation.group) {
|
|
2633
|
+
throw new Error("End Group must be >= Start Group");
|
|
2634
|
+
}
|
|
2635
|
+
return new _Subscribe(
|
|
2636
|
+
requestId,
|
|
2637
|
+
fullTrackName,
|
|
2638
|
+
subscriberPriority,
|
|
2639
|
+
groupOrder,
|
|
2640
|
+
forward,
|
|
2641
|
+
4 /* AbsoluteRange */,
|
|
2642
|
+
startLocation,
|
|
2643
|
+
endGroup,
|
|
2644
|
+
parameters
|
|
2645
|
+
);
|
|
2646
|
+
}
|
|
2647
|
+
serialize() {
|
|
2648
|
+
const buf = new ByteBuffer();
|
|
2649
|
+
buf.putVI(3 /* Subscribe */);
|
|
2650
|
+
const payload = new ByteBuffer();
|
|
2651
|
+
payload.putVI(this.requestId);
|
|
2652
|
+
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
2653
|
+
payload.putU8(this.subscriberPriority);
|
|
2654
|
+
payload.putU8(this.groupOrder);
|
|
2655
|
+
payload.putU8(this.forward ? 1 : 0);
|
|
2656
|
+
payload.putVI(this.filterType);
|
|
2657
|
+
if (this.filterType === 3 /* AbsoluteStart */ || this.filterType === 4 /* AbsoluteRange */) {
|
|
2658
|
+
if (!this.startLocation) {
|
|
2659
|
+
throw new Error("StartLocation required for selected filterType");
|
|
2660
|
+
}
|
|
2661
|
+
payload.putLocation(this.startLocation);
|
|
2662
|
+
}
|
|
2663
|
+
if (this.filterType === 4 /* AbsoluteRange */) {
|
|
2664
|
+
if (this.endGroup == null) {
|
|
2665
|
+
throw new Error("EndGroup required for AbsoluteRange");
|
|
2666
|
+
}
|
|
2667
|
+
payload.putVI(this.endGroup);
|
|
2668
|
+
}
|
|
2669
|
+
payload.putVI(this.parameters.length);
|
|
2670
|
+
for (const param of this.parameters) {
|
|
2671
|
+
payload.putBytes(param.serialize().toUint8Array());
|
|
2672
|
+
}
|
|
2673
|
+
const payloadBytes = payload.toUint8Array();
|
|
2674
|
+
buf.putU16(payloadBytes.length);
|
|
2675
|
+
buf.putBytes(payloadBytes);
|
|
2676
|
+
return buf.freeze();
|
|
2677
|
+
}
|
|
2678
|
+
static parsePayload(buf) {
|
|
2679
|
+
const requestId = buf.getVI();
|
|
2680
|
+
const fullTrackName = buf.getFullTrackName();
|
|
2681
|
+
const subscriberPriority = buf.getU8();
|
|
2682
|
+
const groupOrder = buf.getU8();
|
|
2683
|
+
const forward = buf.getU8() === 1;
|
|
2684
|
+
const filterType = Number(buf.getVI());
|
|
2685
|
+
let startLocation = void 0;
|
|
2686
|
+
let endGroup = void 0;
|
|
2687
|
+
if (filterType === 3 /* AbsoluteStart */ || filterType === 4 /* AbsoluteRange */) {
|
|
2688
|
+
startLocation = buf.getLocation();
|
|
2689
|
+
}
|
|
2690
|
+
if (filterType === 4 /* AbsoluteRange */) {
|
|
2691
|
+
endGroup = buf.getVI();
|
|
2692
|
+
}
|
|
2693
|
+
const paramCount = Number(buf.getVI());
|
|
2694
|
+
const parameters = [];
|
|
2695
|
+
for (let i = 0; i < paramCount; i++) {
|
|
2696
|
+
parameters.push(KeyValuePair.deserialize(buf));
|
|
2697
|
+
}
|
|
2698
|
+
return new _Subscribe(
|
|
2699
|
+
requestId,
|
|
2700
|
+
fullTrackName,
|
|
2701
|
+
subscriberPriority,
|
|
2702
|
+
groupOrder,
|
|
2703
|
+
forward,
|
|
2704
|
+
filterType,
|
|
2705
|
+
startLocation,
|
|
2706
|
+
endGroup,
|
|
2707
|
+
parameters
|
|
2708
|
+
);
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
// src/model/control/switch.ts
|
|
2713
|
+
var Switch = class _Switch {
|
|
2714
|
+
constructor(requestId, fullTrackName, subscriptionRequestId, parameters) {
|
|
2715
|
+
this.requestId = requestId;
|
|
2716
|
+
this.fullTrackName = fullTrackName;
|
|
2717
|
+
this.subscriptionRequestId = subscriptionRequestId;
|
|
2718
|
+
this.parameters = parameters;
|
|
2719
|
+
}
|
|
2720
|
+
serialize() {
|
|
2721
|
+
const buf = new ByteBuffer();
|
|
2722
|
+
buf.putVI(34 /* Switch */);
|
|
2723
|
+
const payload = new ByteBuffer();
|
|
2724
|
+
payload.putVI(this.requestId);
|
|
2725
|
+
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
2726
|
+
payload.putVI(this.subscriptionRequestId);
|
|
2727
|
+
payload.putVI(this.parameters.length);
|
|
2728
|
+
for (const param of this.parameters) {
|
|
2729
|
+
payload.putBytes(param.serialize().toUint8Array());
|
|
2730
|
+
}
|
|
2731
|
+
const payloadBytes = payload.toUint8Array();
|
|
2732
|
+
buf.putU16(payloadBytes.length);
|
|
2733
|
+
buf.putBytes(payloadBytes);
|
|
2734
|
+
return buf.freeze();
|
|
2735
|
+
}
|
|
2736
|
+
static parsePayload(buf) {
|
|
2737
|
+
const requestId = buf.getVI();
|
|
2738
|
+
const fullTrackName = buf.getFullTrackName();
|
|
2739
|
+
const subscriptionRequestId = buf.getVI();
|
|
2740
|
+
const paramCount = Number(buf.getVI());
|
|
2741
|
+
const parameters = [];
|
|
2742
|
+
for (let i = 0; i < paramCount; i++) {
|
|
2743
|
+
parameters.push(KeyValuePair.deserialize(buf));
|
|
2744
|
+
}
|
|
2745
|
+
return new _Switch(requestId, fullTrackName, subscriptionRequestId, parameters);
|
|
2746
|
+
}
|
|
2747
|
+
};
|
|
2748
|
+
|
|
2749
|
+
// src/model/control/publish_namespace_error.ts
|
|
2750
|
+
var PublishNamespaceError = class _PublishNamespaceError {
|
|
2751
|
+
constructor(requestId, errorCode, reasonPhrase) {
|
|
2752
|
+
this.requestId = requestId;
|
|
2753
|
+
this.errorCode = errorCode;
|
|
2754
|
+
this.reasonPhrase = reasonPhrase;
|
|
2755
|
+
}
|
|
2756
|
+
getType() {
|
|
2757
|
+
return 8 /* PublishNamespaceError */;
|
|
2758
|
+
}
|
|
2759
|
+
serialize() {
|
|
2760
|
+
const buf = new ByteBuffer();
|
|
2761
|
+
buf.putVI(8 /* PublishNamespaceError */);
|
|
2762
|
+
const payload = new ByteBuffer();
|
|
2763
|
+
payload.putVI(this.requestId);
|
|
2764
|
+
payload.putVI(this.errorCode);
|
|
2765
|
+
payload.putReasonPhrase(this.reasonPhrase);
|
|
2766
|
+
const payloadBytes = payload.toUint8Array();
|
|
2767
|
+
if (payloadBytes.length > 65535) {
|
|
2768
|
+
throw new LengthExceedsMaxError(
|
|
2769
|
+
"PublishNamespaceError::serialize(payloadBytes.length)",
|
|
2770
|
+
65535,
|
|
2771
|
+
payloadBytes.length
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
buf.putU16(payloadBytes.length);
|
|
2775
|
+
buf.putBytes(payloadBytes);
|
|
2776
|
+
return buf.freeze();
|
|
2777
|
+
}
|
|
2778
|
+
static parsePayload(buf) {
|
|
2779
|
+
const requestId = buf.getVI();
|
|
2780
|
+
const errorCodeRaw = buf.getVI();
|
|
2781
|
+
const errorCode = publishNamespaceErrorCodeFromBigInt(errorCodeRaw);
|
|
2782
|
+
const reasonPhrase = buf.getReasonPhrase();
|
|
2783
|
+
return new _PublishNamespaceError(requestId, errorCode, reasonPhrase);
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2786
|
+
|
|
2787
|
+
// src/model/control/publish_namespace_ok.ts
|
|
2788
|
+
var PublishNamespaceOk = class _PublishNamespaceOk {
|
|
2789
|
+
requestId;
|
|
2790
|
+
constructor(requestId) {
|
|
2791
|
+
this.requestId = BigInt(requestId);
|
|
2792
|
+
}
|
|
2793
|
+
getType() {
|
|
2794
|
+
return 7 /* PublishNamespaceOk */;
|
|
2795
|
+
}
|
|
2796
|
+
serialize() {
|
|
2797
|
+
const buf = new ByteBuffer();
|
|
2798
|
+
const payload = new ByteBuffer();
|
|
2799
|
+
payload.putVI(this.requestId);
|
|
2800
|
+
buf.putVI(7 /* PublishNamespaceOk */);
|
|
2801
|
+
const payloadBytes = payload.toUint8Array();
|
|
2802
|
+
if (payloadBytes.length > 65535) {
|
|
2803
|
+
throw new LengthExceedsMaxError("PublishNamespaceOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
2804
|
+
}
|
|
2805
|
+
buf.putU16(payloadBytes.length);
|
|
2806
|
+
buf.putBytes(payloadBytes);
|
|
2807
|
+
return buf.freeze();
|
|
2808
|
+
}
|
|
2809
|
+
static parsePayload(buf) {
|
|
2810
|
+
const requestId = buf.getVI();
|
|
2811
|
+
return new _PublishNamespaceOk(requestId);
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
|
|
2815
|
+
// src/model/control/publish_namespace_cancel.ts
|
|
2816
|
+
var PublishNamespaceCancel = class _PublishNamespaceCancel {
|
|
2817
|
+
constructor(trackNamespace, errorCode, reasonPhrase) {
|
|
2818
|
+
this.trackNamespace = trackNamespace;
|
|
2819
|
+
this.errorCode = errorCode;
|
|
2820
|
+
this.reasonPhrase = reasonPhrase;
|
|
2821
|
+
}
|
|
2822
|
+
getType() {
|
|
2823
|
+
return 12 /* PublishNamespaceCancel */;
|
|
2824
|
+
}
|
|
2825
|
+
serialize() {
|
|
2826
|
+
const buf = new ByteBuffer();
|
|
2827
|
+
buf.putVI(12 /* PublishNamespaceCancel */);
|
|
2828
|
+
const payload = new ByteBuffer();
|
|
2829
|
+
payload.putTuple(this.trackNamespace);
|
|
2830
|
+
payload.putVI(this.errorCode);
|
|
2831
|
+
payload.putReasonPhrase(this.reasonPhrase);
|
|
2832
|
+
const payloadBytes = payload.toUint8Array();
|
|
2833
|
+
if (payloadBytes.length > 65535) {
|
|
2834
|
+
throw new LengthExceedsMaxError(
|
|
2835
|
+
"PublishNamespaceCancel::serialize(payloadBytes.length)",
|
|
2836
|
+
65535,
|
|
2837
|
+
payloadBytes.length
|
|
2838
|
+
);
|
|
2839
|
+
}
|
|
2840
|
+
buf.putU16(payloadBytes.length);
|
|
2841
|
+
buf.putBytes(payloadBytes);
|
|
2842
|
+
return buf.freeze();
|
|
2843
|
+
}
|
|
2844
|
+
static parsePayload(buf) {
|
|
2845
|
+
const trackNamespace = buf.getTuple();
|
|
2846
|
+
const errorCodeRaw = buf.getVI();
|
|
2847
|
+
const errorCode = publishNamespaceErrorCodeFromBigInt(errorCodeRaw);
|
|
2848
|
+
const reasonPhrase = buf.getReasonPhrase();
|
|
2849
|
+
return new _PublishNamespaceCancel(trackNamespace, errorCode, reasonPhrase);
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
|
|
2853
|
+
// src/model/control/client_setup.ts
|
|
2854
|
+
var ClientSetup = class _ClientSetup {
|
|
2855
|
+
constructor(supportedVersions, setupParameters) {
|
|
2856
|
+
this.supportedVersions = supportedVersions;
|
|
2857
|
+
this.setupParameters = setupParameters;
|
|
2858
|
+
}
|
|
2859
|
+
getType() {
|
|
2860
|
+
return 32 /* ClientSetup */;
|
|
2861
|
+
}
|
|
2862
|
+
serialize() {
|
|
2863
|
+
const buf = new ByteBuffer();
|
|
2864
|
+
buf.putVI(32 /* ClientSetup */);
|
|
2865
|
+
const payload = new ByteBuffer();
|
|
2866
|
+
payload.putVI(this.supportedVersions.length);
|
|
2867
|
+
for (const version of this.supportedVersions) {
|
|
2868
|
+
payload.putVI(version);
|
|
2869
|
+
}
|
|
2870
|
+
payload.putVI(this.setupParameters.length);
|
|
2871
|
+
for (const param of this.setupParameters) {
|
|
2872
|
+
payload.putKeyValuePair(param);
|
|
2873
|
+
}
|
|
2874
|
+
const payloadBytes = payload.toUint8Array();
|
|
2875
|
+
if (payloadBytes.length > 65535) {
|
|
2876
|
+
throw new LengthExceedsMaxError("ClientSetup::serialize(payload_length)", 65535, payloadBytes.length);
|
|
2877
|
+
}
|
|
2878
|
+
buf.putU16(payloadBytes.length);
|
|
2879
|
+
buf.putBytes(payloadBytes);
|
|
2880
|
+
return buf.freeze();
|
|
2881
|
+
}
|
|
2882
|
+
static parsePayload(buf) {
|
|
2883
|
+
const numberOfSupportedVersions = buf.getNumberVI();
|
|
2884
|
+
const supportedVersions = new Array(numberOfSupportedVersions);
|
|
2885
|
+
for (let i = 0; i < numberOfSupportedVersions; i++) {
|
|
2886
|
+
supportedVersions[i] = buf.getNumberVI();
|
|
2887
|
+
}
|
|
2888
|
+
const paramCount = buf.getNumberVI();
|
|
2889
|
+
const setupParameters = new Array(paramCount);
|
|
2890
|
+
for (let i = 0; i < paramCount; i++) {
|
|
2891
|
+
setupParameters[i] = buf.getKeyValuePair();
|
|
2892
|
+
}
|
|
2893
|
+
return new _ClientSetup(supportedVersions, setupParameters);
|
|
2894
|
+
}
|
|
2895
|
+
};
|
|
2896
|
+
|
|
2897
|
+
// src/model/control/fetch.ts
|
|
2898
|
+
var Fetch = class _Fetch {
|
|
2899
|
+
constructor(requestId, subscriberPriority, groupOrder, typeAndProps, parameters) {
|
|
2900
|
+
this.requestId = requestId;
|
|
2901
|
+
this.subscriberPriority = subscriberPriority;
|
|
2902
|
+
this.groupOrder = groupOrder;
|
|
2903
|
+
this.typeAndProps = typeAndProps;
|
|
2904
|
+
this.parameters = parameters;
|
|
2905
|
+
}
|
|
2906
|
+
getType() {
|
|
2907
|
+
return 22 /* Fetch */;
|
|
2908
|
+
}
|
|
2909
|
+
serialize() {
|
|
2910
|
+
const buf = new ByteBuffer();
|
|
2911
|
+
buf.putVI(22 /* Fetch */);
|
|
2912
|
+
const payload = new ByteBuffer();
|
|
2913
|
+
payload.putVI(this.requestId);
|
|
2914
|
+
payload.putU8(this.subscriberPriority);
|
|
2915
|
+
payload.putU8(this.groupOrder);
|
|
2916
|
+
payload.putVI(this.typeAndProps.type);
|
|
2917
|
+
switch (this.typeAndProps.type) {
|
|
2918
|
+
case 3 /* Absolute */:
|
|
2919
|
+
case 2 /* Relative */: {
|
|
2920
|
+
payload.putVI(this.typeAndProps.props.joiningRequestId);
|
|
2921
|
+
payload.putVI(this.typeAndProps.props.joiningStart);
|
|
2922
|
+
break;
|
|
2923
|
+
}
|
|
2924
|
+
case 1 /* StandAlone */: {
|
|
2925
|
+
payload.putFullTrackName(this.typeAndProps.props.fullTrackName);
|
|
2926
|
+
payload.putLocation(this.typeAndProps.props.startLocation);
|
|
2927
|
+
payload.putLocation(this.typeAndProps.props.endLocation);
|
|
2928
|
+
break;
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
payload.putVI(this.parameters.length);
|
|
2932
|
+
for (const param of this.parameters) {
|
|
2933
|
+
payload.putKeyValuePair(param);
|
|
2934
|
+
}
|
|
2935
|
+
const payloadBytes = payload.toUint8Array();
|
|
2936
|
+
if (payloadBytes.length > 65535) {
|
|
2937
|
+
throw new LengthExceedsMaxError("Fetch::serialize(payload_length)", 65535, payloadBytes.length);
|
|
2938
|
+
}
|
|
2939
|
+
buf.putU16(payloadBytes.length);
|
|
2940
|
+
buf.putBytes(payloadBytes);
|
|
2941
|
+
return buf.freeze();
|
|
2942
|
+
}
|
|
2943
|
+
static parsePayload(buf) {
|
|
2944
|
+
const requestId = buf.getVI();
|
|
2945
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("Fetch::parse_payload(subscriber_priority)", 1, buf.remaining);
|
|
2946
|
+
const subscriberPriority = buf.getU8();
|
|
2947
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("Fetch::parse_payload(group_order)", 1, buf.remaining);
|
|
2948
|
+
const groupOrderRaw = buf.getU8();
|
|
2949
|
+
const groupOrder = groupOrderFromNumber(groupOrderRaw);
|
|
2950
|
+
const fetchTypeRaw = buf.getVI();
|
|
2951
|
+
const fetchType = fetchTypeFromBigInt(fetchTypeRaw);
|
|
2952
|
+
let props;
|
|
2953
|
+
switch (fetchType) {
|
|
2954
|
+
case 3 /* Absolute */:
|
|
2955
|
+
case 2 /* Relative */: {
|
|
2956
|
+
const joiningRequestId = buf.getVI();
|
|
2957
|
+
const joiningStart = buf.getVI();
|
|
2958
|
+
props = {
|
|
2959
|
+
type: fetchType,
|
|
2960
|
+
props: { joiningRequestId, joiningStart }
|
|
2961
|
+
};
|
|
2962
|
+
break;
|
|
2963
|
+
}
|
|
2964
|
+
case 1 /* StandAlone */: {
|
|
2965
|
+
const fullTrackName = buf.getFullTrackName();
|
|
2966
|
+
const startLocation = buf.getLocation();
|
|
2967
|
+
const endLocation = buf.getLocation();
|
|
2968
|
+
props = {
|
|
2969
|
+
type: 1 /* StandAlone */,
|
|
2970
|
+
props: { fullTrackName, startLocation, endLocation }
|
|
2971
|
+
};
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
default:
|
|
2975
|
+
throw new Error(`Unknown fetch type: ${fetchType}`);
|
|
2976
|
+
}
|
|
2977
|
+
const paramCount = buf.getNumberVI();
|
|
2978
|
+
const parameters = new Array(paramCount);
|
|
2979
|
+
for (let i = 0; i < paramCount; i++) {
|
|
2980
|
+
parameters[i] = buf.getKeyValuePair();
|
|
2981
|
+
}
|
|
2982
|
+
return new _Fetch(requestId, subscriberPriority, groupOrder, props, parameters);
|
|
2983
|
+
}
|
|
2984
|
+
};
|
|
2985
|
+
|
|
2986
|
+
// src/model/control/fetch_cancel.ts
|
|
2987
|
+
var FetchCancel = class _FetchCancel {
|
|
2988
|
+
requestId;
|
|
2989
|
+
constructor(requestId) {
|
|
2990
|
+
this.requestId = BigInt(requestId);
|
|
2991
|
+
}
|
|
2992
|
+
getType() {
|
|
2993
|
+
return 23 /* FetchCancel */;
|
|
2994
|
+
}
|
|
2995
|
+
serialize() {
|
|
2996
|
+
const buf = new ByteBuffer();
|
|
2997
|
+
buf.putVI(23 /* FetchCancel */);
|
|
2998
|
+
const payload = new ByteBuffer();
|
|
2999
|
+
payload.putVI(this.requestId);
|
|
3000
|
+
const payloadBytes = payload.toUint8Array();
|
|
3001
|
+
if (payloadBytes.length > 65535) {
|
|
3002
|
+
throw new LengthExceedsMaxError("FetchCancel::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3003
|
+
}
|
|
3004
|
+
buf.putU16(payloadBytes.length);
|
|
3005
|
+
buf.putBytes(payloadBytes);
|
|
3006
|
+
return buf.freeze();
|
|
3007
|
+
}
|
|
3008
|
+
static parsePayload(buf) {
|
|
3009
|
+
const requestId = buf.getVI();
|
|
3010
|
+
return new _FetchCancel(requestId);
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
|
|
3014
|
+
// src/model/control/fetch_error.ts
|
|
3015
|
+
var FetchError = class _FetchError {
|
|
3016
|
+
requestId;
|
|
3017
|
+
errorCode;
|
|
3018
|
+
reasonPhrase;
|
|
3019
|
+
constructor(requestId, errorCode, reasonPhrase) {
|
|
3020
|
+
this.requestId = requestId;
|
|
3021
|
+
this.errorCode = errorCode;
|
|
3022
|
+
this.reasonPhrase = reasonPhrase;
|
|
3023
|
+
}
|
|
3024
|
+
getType() {
|
|
3025
|
+
return 25 /* FetchError */;
|
|
3026
|
+
}
|
|
3027
|
+
serialize() {
|
|
3028
|
+
const buf = new ByteBuffer();
|
|
3029
|
+
buf.putVI(25 /* FetchError */);
|
|
3030
|
+
const payload = new ByteBuffer();
|
|
3031
|
+
payload.putVI(this.requestId);
|
|
3032
|
+
payload.putVI(this.errorCode);
|
|
3033
|
+
payload.putReasonPhrase(this.reasonPhrase);
|
|
3034
|
+
const payloadBytes = payload.toUint8Array();
|
|
3035
|
+
if (payloadBytes.length > 65535) {
|
|
3036
|
+
throw new LengthExceedsMaxError("FetchError::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3037
|
+
}
|
|
3038
|
+
buf.putU16(payloadBytes.length);
|
|
3039
|
+
buf.putBytes(payloadBytes);
|
|
3040
|
+
return buf.freeze();
|
|
3041
|
+
}
|
|
3042
|
+
static parsePayload(buf) {
|
|
3043
|
+
const requestId = buf.getVI();
|
|
3044
|
+
const errorCodeRaw = buf.getVI();
|
|
3045
|
+
const errorCode = fetchErrorCodeFromBigInt(errorCodeRaw);
|
|
3046
|
+
const reasonPhrase = buf.getReasonPhrase();
|
|
3047
|
+
return new _FetchError(requestId, errorCode, reasonPhrase);
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
|
|
3051
|
+
// src/model/control/fetch_ok.ts
|
|
3052
|
+
var FetchOk = class _FetchOk {
|
|
3053
|
+
constructor(requestId, groupOrder, endOfTrack, endLocation, parameters) {
|
|
3054
|
+
this.requestId = requestId;
|
|
3055
|
+
this.groupOrder = groupOrder;
|
|
3056
|
+
this.endOfTrack = endOfTrack;
|
|
3057
|
+
this.endLocation = endLocation;
|
|
3058
|
+
this.parameters = parameters;
|
|
3059
|
+
}
|
|
3060
|
+
static newAscending(requestId, endOfTrack, endLocation, parameters) {
|
|
3061
|
+
return new _FetchOk(BigInt(requestId), 1 /* Ascending */, endOfTrack, endLocation, parameters);
|
|
3062
|
+
}
|
|
3063
|
+
static newDescending(requestId, endOfTrack, endLocation, parameters) {
|
|
3064
|
+
return new _FetchOk(BigInt(requestId), 2 /* Descending */, endOfTrack, endLocation, parameters);
|
|
3065
|
+
}
|
|
3066
|
+
serialize() {
|
|
3067
|
+
const buf = new ByteBuffer();
|
|
3068
|
+
buf.putVI(BigInt(24 /* FetchOk */));
|
|
3069
|
+
const payload = new ByteBuffer();
|
|
3070
|
+
payload.putVI(this.requestId);
|
|
3071
|
+
payload.putU8(this.groupOrder);
|
|
3072
|
+
payload.putU8(this.endOfTrack ? 1 : 0);
|
|
3073
|
+
payload.putLocation(this.endLocation);
|
|
3074
|
+
payload.putVI(this.parameters.length);
|
|
3075
|
+
for (const param of this.parameters) {
|
|
3076
|
+
payload.putKeyValuePair(param);
|
|
3077
|
+
}
|
|
3078
|
+
const payloadBytes = payload.toUint8Array();
|
|
3079
|
+
if (payloadBytes.length > 65535) {
|
|
3080
|
+
throw new LengthExceedsMaxError("FetchOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3081
|
+
}
|
|
3082
|
+
buf.putU16(payloadBytes.length);
|
|
3083
|
+
buf.putBytes(payloadBytes);
|
|
3084
|
+
return buf.freeze();
|
|
3085
|
+
}
|
|
3086
|
+
static parsePayload(buf) {
|
|
3087
|
+
const requestId = buf.getVI();
|
|
3088
|
+
if (buf.remaining < 1) {
|
|
3089
|
+
throw new NotEnoughBytesError("FetchOk::parsePayload(group_order)", 1, 0);
|
|
3090
|
+
}
|
|
3091
|
+
const groupOrderRaw = buf.getU8();
|
|
3092
|
+
const groupOrder = groupOrderFromNumber(groupOrderRaw);
|
|
3093
|
+
if (groupOrder === 0 /* Original */) {
|
|
3094
|
+
throw new ProtocolViolationError(
|
|
3095
|
+
"FetchOk::parsePayload(groupOrder)",
|
|
3096
|
+
"Group order must be Ascending(0x01) or Descending(0x02)"
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
if (buf.remaining < 1) {
|
|
3100
|
+
throw new NotEnoughBytesError("FetchOk::parsePayload(endOfTrack)", 1, 0);
|
|
3101
|
+
}
|
|
3102
|
+
const endOfTrackRaw = buf.getU8();
|
|
3103
|
+
let endOfTrack;
|
|
3104
|
+
if (endOfTrackRaw === 0) {
|
|
3105
|
+
endOfTrack = false;
|
|
3106
|
+
} else if (endOfTrackRaw === 1) {
|
|
3107
|
+
endOfTrack = true;
|
|
3108
|
+
} else {
|
|
3109
|
+
throw new ProtocolViolationError(
|
|
3110
|
+
"FetchOk::parsePayload(endOfTrack)",
|
|
3111
|
+
"End of track must be true(0x01) or false(0x00)"
|
|
3112
|
+
);
|
|
3113
|
+
}
|
|
3114
|
+
const endLocation = buf.getLocation();
|
|
3115
|
+
const paramCount = buf.getNumberVI();
|
|
3116
|
+
const parameters = new Array(paramCount);
|
|
3117
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3118
|
+
parameters[i] = buf.getKeyValuePair();
|
|
3119
|
+
}
|
|
3120
|
+
return new _FetchOk(requestId, groupOrder, endOfTrack, endLocation, parameters);
|
|
3121
|
+
}
|
|
3122
|
+
};
|
|
3123
|
+
|
|
3124
|
+
// src/model/control/goaway.ts
|
|
3125
|
+
var GoAway = class _GoAway {
|
|
3126
|
+
newSessionUri;
|
|
3127
|
+
constructor(newSessionUri) {
|
|
3128
|
+
if (newSessionUri && newSessionUri.length === 0) {
|
|
3129
|
+
this.newSessionUri = void 0;
|
|
3130
|
+
} else {
|
|
3131
|
+
this.newSessionUri = newSessionUri;
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
static getType() {
|
|
3135
|
+
return 16 /* GoAway */;
|
|
3136
|
+
}
|
|
3137
|
+
serialize() {
|
|
3138
|
+
const buf = new ByteBuffer();
|
|
3139
|
+
buf.putVI(16 /* GoAway */);
|
|
3140
|
+
const payload = new ByteBuffer();
|
|
3141
|
+
if (this.newSessionUri) {
|
|
3142
|
+
let uriBytes;
|
|
3143
|
+
try {
|
|
3144
|
+
const encoder = new TextEncoder();
|
|
3145
|
+
uriBytes = encoder.encode(this.newSessionUri);
|
|
3146
|
+
} catch (error) {
|
|
3147
|
+
throw new InvalidUTF8Error(
|
|
3148
|
+
"GoAway::serialize(newSessionUri)",
|
|
3149
|
+
error instanceof Error ? error.message : String(error)
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
payload.putLengthPrefixedBytes(uriBytes);
|
|
3153
|
+
} else {
|
|
3154
|
+
payload.putVI(0);
|
|
3155
|
+
}
|
|
3156
|
+
const payloadBytes = payload.toUint8Array();
|
|
3157
|
+
if (payloadBytes.length > 65535) {
|
|
3158
|
+
throw new LengthExceedsMaxError("GoAway::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3159
|
+
}
|
|
3160
|
+
buf.putU16(payloadBytes.length);
|
|
3161
|
+
buf.putBytes(payloadBytes);
|
|
3162
|
+
return buf.freeze();
|
|
3163
|
+
}
|
|
3164
|
+
static parsePayload(buf) {
|
|
3165
|
+
const uriLength = buf.getNumberVI();
|
|
3166
|
+
if (uriLength === 0) {
|
|
3167
|
+
return new _GoAway(void 0);
|
|
3168
|
+
}
|
|
3169
|
+
if (buf.remaining < uriLength) {
|
|
3170
|
+
throw new NotEnoughBytesError("GoAway::parsePayload(uriLength)", uriLength, buf.remaining);
|
|
3171
|
+
}
|
|
3172
|
+
const uriBytes = buf.getBytes(uriLength);
|
|
3173
|
+
let newSessionUri;
|
|
3174
|
+
try {
|
|
3175
|
+
const decoder = new TextDecoder();
|
|
3176
|
+
newSessionUri = decoder.decode(uriBytes);
|
|
3177
|
+
} catch (error) {
|
|
3178
|
+
throw new InvalidUTF8Error(
|
|
3179
|
+
"GoAway::parsePayload(newSessionUri)",
|
|
3180
|
+
error instanceof Error ? error.message : String(error)
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
3183
|
+
return new _GoAway(newSessionUri);
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
// src/model/control/max_request_id.ts
|
|
3188
|
+
var MaxRequestId = class _MaxRequestId {
|
|
3189
|
+
requestId;
|
|
3190
|
+
constructor(requestId) {
|
|
3191
|
+
this.requestId = BigInt(requestId);
|
|
3192
|
+
}
|
|
3193
|
+
getType() {
|
|
3194
|
+
return 21 /* MaxRequestId */;
|
|
3195
|
+
}
|
|
3196
|
+
serialize() {
|
|
3197
|
+
const buf = new ByteBuffer();
|
|
3198
|
+
const payload = new ByteBuffer();
|
|
3199
|
+
payload.putVI(this.requestId + 1n);
|
|
3200
|
+
buf.putVI(21 /* MaxRequestId */);
|
|
3201
|
+
const payloadBytes = payload.toUint8Array();
|
|
3202
|
+
if (payloadBytes.length > 65535) {
|
|
3203
|
+
throw new LengthExceedsMaxError("MaxRequestId::serialize(payload_length)", 65535, payloadBytes.length);
|
|
3204
|
+
}
|
|
3205
|
+
buf.putU16(payloadBytes.length);
|
|
3206
|
+
buf.putBytes(payloadBytes);
|
|
3207
|
+
return buf.freeze();
|
|
3208
|
+
}
|
|
3209
|
+
static parsePayload(buf) {
|
|
3210
|
+
const requestId = buf.getVI();
|
|
3211
|
+
return new _MaxRequestId(requestId);
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3215
|
+
// src/model/control/server_setup.ts
|
|
3216
|
+
var ServerSetup = class _ServerSetup {
|
|
3217
|
+
constructor(selectedVersion, setupParameters) {
|
|
3218
|
+
this.selectedVersion = selectedVersion;
|
|
3219
|
+
this.setupParameters = setupParameters;
|
|
3220
|
+
}
|
|
3221
|
+
getType() {
|
|
3222
|
+
return 33 /* ServerSetup */;
|
|
3223
|
+
}
|
|
3224
|
+
serialize() {
|
|
3225
|
+
const buf = new ByteBuffer();
|
|
3226
|
+
buf.putVI(33 /* ServerSetup */);
|
|
3227
|
+
const payload = new ByteBuffer();
|
|
3228
|
+
payload.putVI(this.selectedVersion);
|
|
3229
|
+
payload.putVI(this.setupParameters.length);
|
|
3230
|
+
for (const param of this.setupParameters) {
|
|
3231
|
+
payload.putKeyValuePair(param);
|
|
3232
|
+
}
|
|
3233
|
+
const payloadBytes = payload.toUint8Array();
|
|
3234
|
+
if (payloadBytes.length > 65535) {
|
|
3235
|
+
throw new LengthExceedsMaxError("ServerSetup::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3236
|
+
}
|
|
3237
|
+
buf.putU16(payloadBytes.length);
|
|
3238
|
+
buf.putBytes(payloadBytes);
|
|
3239
|
+
return buf.freeze();
|
|
3240
|
+
}
|
|
3241
|
+
static parsePayload(buf) {
|
|
3242
|
+
const selectedVersion = buf.getNumberVI();
|
|
3243
|
+
const paramCount = buf.getNumberVI();
|
|
3244
|
+
const setupParameters = new Array(paramCount);
|
|
3245
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3246
|
+
setupParameters[i] = buf.getKeyValuePair();
|
|
3247
|
+
}
|
|
3248
|
+
return new _ServerSetup(selectedVersion, setupParameters);
|
|
3249
|
+
}
|
|
3250
|
+
};
|
|
3251
|
+
|
|
3252
|
+
// src/model/control/publish_done.ts
|
|
3253
|
+
var PublishDone = class _PublishDone {
|
|
3254
|
+
constructor(requestId, statusCode, streamCount, errorReason) {
|
|
3255
|
+
this.requestId = requestId;
|
|
3256
|
+
this.statusCode = statusCode;
|
|
3257
|
+
this.streamCount = streamCount;
|
|
3258
|
+
this.errorReason = errorReason;
|
|
3259
|
+
}
|
|
3260
|
+
static new(requestId, statusCode, streamCount, errorReason) {
|
|
3261
|
+
return new _PublishDone(BigInt(requestId), statusCode, streamCount, errorReason);
|
|
3262
|
+
}
|
|
3263
|
+
getType() {
|
|
3264
|
+
return 11 /* PublishDone */;
|
|
3265
|
+
}
|
|
3266
|
+
serialize() {
|
|
3267
|
+
const buf = new ByteBuffer();
|
|
3268
|
+
buf.putVI(11 /* PublishDone */);
|
|
3269
|
+
const payload = new ByteBuffer();
|
|
3270
|
+
payload.putVI(this.requestId);
|
|
3271
|
+
payload.putVI(this.statusCode);
|
|
3272
|
+
payload.putVI(this.streamCount);
|
|
3273
|
+
payload.putReasonPhrase(this.errorReason);
|
|
3274
|
+
const payloadBytes = payload.toUint8Array();
|
|
3275
|
+
if (payloadBytes.length > 65535) {
|
|
3276
|
+
throw new LengthExceedsMaxError("PublishDone::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3277
|
+
}
|
|
3278
|
+
buf.putU16(payloadBytes.length);
|
|
3279
|
+
buf.putBytes(payloadBytes);
|
|
3280
|
+
return buf.freeze();
|
|
3281
|
+
}
|
|
3282
|
+
static parsePayload(buf) {
|
|
3283
|
+
const requestId = buf.getVI();
|
|
3284
|
+
const statusCodeRaw = buf.getVI();
|
|
3285
|
+
const statusCode = publishDoneStatusCodeFromBigInt(statusCodeRaw);
|
|
3286
|
+
const streamCount = buf.getVI();
|
|
3287
|
+
const errorReason = buf.getReasonPhrase();
|
|
3288
|
+
return new _PublishDone(requestId, statusCode, streamCount, errorReason);
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
// src/model/control/publish.ts
|
|
3293
|
+
var Publish = class _Publish {
|
|
3294
|
+
constructor(requestId, trackNamespace, trackName, trackAlias, groupOrder, contentExists, largestLocation, forward, parameters) {
|
|
3295
|
+
this.requestId = requestId;
|
|
3296
|
+
this.trackNamespace = trackNamespace;
|
|
3297
|
+
this.trackName = trackName;
|
|
3298
|
+
this.trackAlias = trackAlias;
|
|
3299
|
+
this.groupOrder = groupOrder;
|
|
3300
|
+
this.contentExists = contentExists;
|
|
3301
|
+
this.largestLocation = largestLocation;
|
|
3302
|
+
this.forward = forward;
|
|
3303
|
+
this.parameters = parameters;
|
|
3304
|
+
}
|
|
3305
|
+
static new(requestId, trackNamespace, trackName, trackAlias, groupOrder, contentExists, largestLocation, forward, parameters) {
|
|
3306
|
+
return new _Publish(
|
|
3307
|
+
BigInt(requestId),
|
|
3308
|
+
trackNamespace,
|
|
3309
|
+
trackName,
|
|
3310
|
+
BigInt(trackAlias),
|
|
3311
|
+
groupOrder,
|
|
3312
|
+
contentExists,
|
|
3313
|
+
largestLocation,
|
|
3314
|
+
forward,
|
|
3315
|
+
parameters
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3318
|
+
getType() {
|
|
3319
|
+
return 29 /* Publish */;
|
|
3320
|
+
}
|
|
3321
|
+
serialize() {
|
|
3322
|
+
const buf = new ByteBuffer();
|
|
3323
|
+
buf.putVI(29 /* Publish */);
|
|
3324
|
+
const payload = new ByteBuffer();
|
|
3325
|
+
payload.putVI(this.requestId);
|
|
3326
|
+
payload.putTuple(this.trackNamespace);
|
|
3327
|
+
payload.putVI(this.trackName.length);
|
|
3328
|
+
payload.putBytes(new TextEncoder().encode(this.trackName));
|
|
3329
|
+
payload.putVI(this.trackAlias);
|
|
3330
|
+
payload.putU8(this.groupOrder);
|
|
3331
|
+
payload.putU8(this.contentExists);
|
|
3332
|
+
if (this.largestLocation !== void 0) {
|
|
3333
|
+
payload.putBytes(this.largestLocation.serialize().toUint8Array());
|
|
3334
|
+
}
|
|
3335
|
+
payload.putU8(this.forward);
|
|
3336
|
+
payload.putVI(this.parameters.length);
|
|
3337
|
+
for (const param of this.parameters) {
|
|
3338
|
+
payload.putKeyValuePair(param);
|
|
3339
|
+
}
|
|
3340
|
+
const payloadBytes = payload.toUint8Array();
|
|
3341
|
+
if (payloadBytes.length > 65535) {
|
|
3342
|
+
throw new LengthExceedsMaxError("Publish::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3343
|
+
}
|
|
3344
|
+
buf.putU16(payloadBytes.length);
|
|
3345
|
+
buf.putBytes(payloadBytes);
|
|
3346
|
+
return buf.freeze();
|
|
3347
|
+
}
|
|
3348
|
+
static parsePayload(buf) {
|
|
3349
|
+
const requestId = buf.getVI();
|
|
3350
|
+
const trackNamespace = buf.getTuple();
|
|
3351
|
+
const trackNameLength = buf.getVI();
|
|
3352
|
+
const trackNameBytes = buf.getBytes(Number(trackNameLength));
|
|
3353
|
+
const trackName = new TextDecoder().decode(trackNameBytes);
|
|
3354
|
+
const trackAlias = buf.getVI();
|
|
3355
|
+
const groupOrder = buf.getU8();
|
|
3356
|
+
const contentExists = buf.getU8();
|
|
3357
|
+
let largestLocation;
|
|
3358
|
+
if (contentExists === 1) {
|
|
3359
|
+
largestLocation = Location.deserialize(buf);
|
|
3360
|
+
}
|
|
3361
|
+
const forward = buf.getU8();
|
|
3362
|
+
const paramCount = buf.getVI();
|
|
3363
|
+
const parameters = new Array(Number(paramCount));
|
|
3364
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3365
|
+
parameters[i] = buf.getKeyValuePair();
|
|
3366
|
+
}
|
|
3367
|
+
return new _Publish(
|
|
3368
|
+
requestId,
|
|
3369
|
+
trackNamespace,
|
|
3370
|
+
trackName,
|
|
3371
|
+
trackAlias,
|
|
3372
|
+
groupOrder,
|
|
3373
|
+
contentExists,
|
|
3374
|
+
largestLocation,
|
|
3375
|
+
forward,
|
|
3376
|
+
parameters
|
|
3377
|
+
);
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
|
|
3381
|
+
// src/model/control/publish_ok.ts
|
|
3382
|
+
var PublishOk = class _PublishOk {
|
|
3383
|
+
constructor(requestId, forward, subscriberPriority, groupOrder, filterType, startLocation, endGroup, parameters) {
|
|
3384
|
+
this.requestId = requestId;
|
|
3385
|
+
this.forward = forward;
|
|
3386
|
+
this.subscriberPriority = subscriberPriority;
|
|
3387
|
+
this.groupOrder = groupOrder;
|
|
3388
|
+
this.filterType = filterType;
|
|
3389
|
+
this.startLocation = startLocation;
|
|
3390
|
+
this.endGroup = endGroup;
|
|
3391
|
+
this.parameters = parameters;
|
|
3392
|
+
}
|
|
3393
|
+
static new(requestId, forward, subscriberPriority, groupOrder, filterType, startLocation, endGroup, parameters) {
|
|
3394
|
+
return new _PublishOk(
|
|
3395
|
+
BigInt(requestId),
|
|
3396
|
+
forward,
|
|
3397
|
+
subscriberPriority,
|
|
3398
|
+
groupOrder,
|
|
3399
|
+
filterType,
|
|
3400
|
+
startLocation,
|
|
3401
|
+
endGroup !== void 0 ? BigInt(endGroup) : void 0,
|
|
3402
|
+
parameters
|
|
3403
|
+
);
|
|
3404
|
+
}
|
|
3405
|
+
getType() {
|
|
3406
|
+
return 30 /* PublishOk */;
|
|
3407
|
+
}
|
|
3408
|
+
serialize() {
|
|
3409
|
+
const buf = new ByteBuffer();
|
|
3410
|
+
buf.putVI(30 /* PublishOk */);
|
|
3411
|
+
const payload = new ByteBuffer();
|
|
3412
|
+
payload.putVI(this.requestId);
|
|
3413
|
+
payload.putU8(this.forward);
|
|
3414
|
+
payload.putU8(this.subscriberPriority);
|
|
3415
|
+
payload.putU8(this.groupOrder);
|
|
3416
|
+
payload.putVI(this.filterType);
|
|
3417
|
+
if (this.filterType === 3 /* AbsoluteStart */ || this.filterType === 4 /* AbsoluteRange */) {
|
|
3418
|
+
if (this.startLocation !== void 0) {
|
|
3419
|
+
payload.putBytes(this.startLocation.serialize().toUint8Array());
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
if (this.filterType === 4 /* AbsoluteRange */) {
|
|
3423
|
+
if (this.endGroup !== void 0) {
|
|
3424
|
+
payload.putVI(this.endGroup);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
payload.putVI(this.parameters.length);
|
|
3428
|
+
for (const param of this.parameters) {
|
|
3429
|
+
payload.putKeyValuePair(param);
|
|
3430
|
+
}
|
|
3431
|
+
const payloadBytes = payload.toUint8Array();
|
|
3432
|
+
if (payloadBytes.length > 65535) {
|
|
3433
|
+
throw new LengthExceedsMaxError("PublishOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3434
|
+
}
|
|
3435
|
+
buf.putU16(payloadBytes.length);
|
|
3436
|
+
buf.putBytes(payloadBytes);
|
|
3437
|
+
return buf.freeze();
|
|
3438
|
+
}
|
|
3439
|
+
static parsePayload(buf) {
|
|
3440
|
+
const requestId = buf.getVI();
|
|
3441
|
+
const forward = buf.getU8();
|
|
3442
|
+
const subscriberPriority = buf.getU8();
|
|
3443
|
+
const groupOrder = buf.getU8();
|
|
3444
|
+
const filterTypeRaw = buf.getVI();
|
|
3445
|
+
const filterType = filterTypeFromBigInt(filterTypeRaw);
|
|
3446
|
+
let startLocation;
|
|
3447
|
+
let endGroup;
|
|
3448
|
+
if (filterType === 3 /* AbsoluteStart */ || filterType === 4 /* AbsoluteRange */) {
|
|
3449
|
+
startLocation = Location.deserialize(buf);
|
|
3450
|
+
}
|
|
3451
|
+
if (filterType === 4 /* AbsoluteRange */) {
|
|
3452
|
+
endGroup = buf.getVI();
|
|
3453
|
+
}
|
|
3454
|
+
const paramCount = buf.getVI();
|
|
3455
|
+
const parameters = new Array(Number(paramCount));
|
|
3456
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3457
|
+
parameters[i] = buf.getKeyValuePair();
|
|
3458
|
+
}
|
|
3459
|
+
return new _PublishOk(
|
|
3460
|
+
requestId,
|
|
3461
|
+
forward,
|
|
3462
|
+
subscriberPriority,
|
|
3463
|
+
groupOrder,
|
|
3464
|
+
filterType,
|
|
3465
|
+
startLocation,
|
|
3466
|
+
endGroup,
|
|
3467
|
+
parameters
|
|
3468
|
+
);
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
|
|
3472
|
+
// src/model/control/publish_error.ts
|
|
3473
|
+
var PublishError = class _PublishError {
|
|
3474
|
+
constructor(requestId, errorCode, errorReason) {
|
|
3475
|
+
this.requestId = requestId;
|
|
3476
|
+
this.errorCode = errorCode;
|
|
3477
|
+
this.errorReason = errorReason;
|
|
3478
|
+
}
|
|
3479
|
+
static new(requestId, errorCode, errorReason) {
|
|
3480
|
+
return new _PublishError(BigInt(requestId), errorCode, errorReason);
|
|
3481
|
+
}
|
|
3482
|
+
getType() {
|
|
3483
|
+
return 31 /* PublishError */;
|
|
3484
|
+
}
|
|
3485
|
+
serialize() {
|
|
3486
|
+
const buf = new ByteBuffer();
|
|
3487
|
+
buf.putVI(31 /* PublishError */);
|
|
3488
|
+
const payload = new ByteBuffer();
|
|
3489
|
+
payload.putVI(this.requestId);
|
|
3490
|
+
payload.putVI(this.errorCode);
|
|
3491
|
+
payload.putReasonPhrase(this.errorReason);
|
|
3492
|
+
const payloadBytes = payload.toUint8Array();
|
|
3493
|
+
if (payloadBytes.length > 65535) {
|
|
3494
|
+
throw new LengthExceedsMaxError("PublishError::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3495
|
+
}
|
|
3496
|
+
buf.putU16(payloadBytes.length);
|
|
3497
|
+
buf.putBytes(payloadBytes);
|
|
3498
|
+
return buf.freeze();
|
|
3499
|
+
}
|
|
3500
|
+
static parsePayload(buf) {
|
|
3501
|
+
const requestId = buf.getVI();
|
|
3502
|
+
const errorCodeRaw = buf.getVI();
|
|
3503
|
+
const errorCode = publishErrorCodeFromBigInt(errorCodeRaw);
|
|
3504
|
+
const errorReason = buf.getReasonPhrase();
|
|
3505
|
+
return new _PublishError(requestId, errorCode, errorReason);
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
|
|
3509
|
+
// src/model/control/subscribe_error.ts
|
|
3510
|
+
var SubscribeError = class _SubscribeError {
|
|
3511
|
+
constructor(requestId, errorCode, errorReason) {
|
|
3512
|
+
this.requestId = requestId;
|
|
3513
|
+
this.errorCode = errorCode;
|
|
3514
|
+
this.errorReason = errorReason;
|
|
3515
|
+
}
|
|
3516
|
+
static new(requestId, errorCode, errorReason) {
|
|
3517
|
+
return new _SubscribeError(BigInt(requestId), errorCode, errorReason);
|
|
3518
|
+
}
|
|
3519
|
+
getType() {
|
|
3520
|
+
return 5 /* SubscribeError */;
|
|
3521
|
+
}
|
|
3522
|
+
serialize() {
|
|
3523
|
+
const buf = new ByteBuffer();
|
|
3524
|
+
buf.putVI(5 /* SubscribeError */);
|
|
3525
|
+
const payload = new ByteBuffer();
|
|
3526
|
+
payload.putVI(this.requestId);
|
|
3527
|
+
payload.putVI(this.errorCode);
|
|
3528
|
+
payload.putReasonPhrase(this.errorReason);
|
|
3529
|
+
const payloadBytes = payload.toUint8Array();
|
|
3530
|
+
if (payloadBytes.length > 65535) {
|
|
3531
|
+
throw new LengthExceedsMaxError("SubscribeError::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3532
|
+
}
|
|
3533
|
+
buf.putU16(payloadBytes.length);
|
|
3534
|
+
buf.putBytes(payloadBytes);
|
|
3535
|
+
return buf.freeze();
|
|
3536
|
+
}
|
|
3537
|
+
static parsePayload(buf) {
|
|
3538
|
+
const requestId = buf.getVI();
|
|
3539
|
+
const errorCodeRaw = buf.getVI();
|
|
3540
|
+
const errorCode = subscribeErrorCodeFromBigInt(errorCodeRaw);
|
|
3541
|
+
const errorReason = buf.getReasonPhrase();
|
|
3542
|
+
return new _SubscribeError(requestId, errorCode, errorReason);
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
// src/model/control/subscribe_ok.ts
|
|
3547
|
+
var SubscribeOk = class _SubscribeOk {
|
|
3548
|
+
requestId;
|
|
3549
|
+
trackAlias;
|
|
3550
|
+
expires;
|
|
3551
|
+
groupOrder;
|
|
3552
|
+
contentExists;
|
|
3553
|
+
largestLocation;
|
|
3554
|
+
parameters;
|
|
3555
|
+
constructor(requestId, trackAlias, expires, groupOrder, contentExists, largestLocation, parameters) {
|
|
3556
|
+
this.requestId = requestId;
|
|
3557
|
+
this.trackAlias = trackAlias;
|
|
3558
|
+
this.expires = expires;
|
|
3559
|
+
this.groupOrder = groupOrder;
|
|
3560
|
+
this.contentExists = contentExists;
|
|
3561
|
+
this.largestLocation = largestLocation;
|
|
3562
|
+
this.parameters = parameters;
|
|
3563
|
+
}
|
|
3564
|
+
static newAscendingNoContent(requestId, trackAlias, expires, parameters) {
|
|
3565
|
+
return new _SubscribeOk(requestId, trackAlias, expires, 1 /* Ascending */, false, void 0, parameters);
|
|
3566
|
+
}
|
|
3567
|
+
static newDescendingNoContent(requestId, trackAlias, expires, parameters) {
|
|
3568
|
+
return new _SubscribeOk(requestId, trackAlias, expires, 2 /* Descending */, false, void 0, parameters);
|
|
3569
|
+
}
|
|
3570
|
+
static newAscendingWithContent(requestId, trackAlias, expires, largestLocation, parameters) {
|
|
3571
|
+
return new _SubscribeOk(requestId, trackAlias, expires, 1 /* Ascending */, true, largestLocation, parameters);
|
|
3572
|
+
}
|
|
3573
|
+
static newDescendingWithContent(requestId, trackAlias, expires, largestLocation, parameters) {
|
|
3574
|
+
return new _SubscribeOk(requestId, trackAlias, expires, 2 /* Descending */, true, largestLocation, parameters);
|
|
3575
|
+
}
|
|
3576
|
+
serialize() {
|
|
3577
|
+
const buf = new ByteBuffer();
|
|
3578
|
+
buf.putVI(4 /* SubscribeOk */);
|
|
3579
|
+
const payload = new ByteBuffer();
|
|
3580
|
+
payload.putVI(this.requestId);
|
|
3581
|
+
payload.putVI(this.trackAlias);
|
|
3582
|
+
payload.putVI(this.expires);
|
|
3583
|
+
payload.putU8(this.groupOrder);
|
|
3584
|
+
if (this.contentExists) {
|
|
3585
|
+
payload.putU8(1);
|
|
3586
|
+
payload.putLocation(this.largestLocation);
|
|
3587
|
+
} else {
|
|
3588
|
+
payload.putU8(0);
|
|
3589
|
+
}
|
|
3590
|
+
payload.putVI(this.parameters.length);
|
|
3591
|
+
for (const param of this.parameters) {
|
|
3592
|
+
payload.putKeyValuePair(param);
|
|
3593
|
+
}
|
|
3594
|
+
const payloadBytes = payload.toUint8Array();
|
|
3595
|
+
if (payloadBytes.length > 65535) {
|
|
3596
|
+
throw new LengthExceedsMaxError("SubscribeOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3597
|
+
}
|
|
3598
|
+
buf.putU16(payloadBytes.length);
|
|
3599
|
+
buf.putBytes(payloadBytes);
|
|
3600
|
+
return buf.freeze();
|
|
3601
|
+
}
|
|
3602
|
+
static parsePayload(buf) {
|
|
3603
|
+
const requestId = buf.getVI();
|
|
3604
|
+
const trackAlias = buf.getVI();
|
|
3605
|
+
const expires = buf.getVI();
|
|
3606
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("SubscribeOk::parsePayload(groupOrder)", 1, buf.remaining);
|
|
3607
|
+
const groupOrderRaw = buf.getU8();
|
|
3608
|
+
const groupOrder = groupOrderFromNumber(groupOrderRaw);
|
|
3609
|
+
if (groupOrder === 0 /* Original */) {
|
|
3610
|
+
throw new ProtocolViolationError(
|
|
3611
|
+
"SubscribeOk::parsePayload(groupOrder)",
|
|
3612
|
+
"Group order must be Ascending(0x01) or Descending(0x02)"
|
|
3613
|
+
);
|
|
3614
|
+
}
|
|
3615
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("SubscribeOk::parsePayload(contentExists)", 1, buf.remaining);
|
|
3616
|
+
const contentExistsRaw = buf.getU8();
|
|
3617
|
+
let contentExists;
|
|
3618
|
+
if (contentExistsRaw === 0) {
|
|
3619
|
+
contentExists = false;
|
|
3620
|
+
} else if (contentExistsRaw === 1) {
|
|
3621
|
+
contentExists = true;
|
|
3622
|
+
} else {
|
|
3623
|
+
throw new ProtocolViolationError("SubscribeOk::parsePayload", `Invalid Content Exists value: ${contentExistsRaw}`);
|
|
3624
|
+
}
|
|
3625
|
+
let largestLocation = void 0;
|
|
3626
|
+
if (contentExists) {
|
|
3627
|
+
largestLocation = buf.getLocation();
|
|
3628
|
+
}
|
|
3629
|
+
const paramCount = buf.getNumberVI();
|
|
3630
|
+
const parameters = new Array(paramCount);
|
|
3631
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3632
|
+
parameters[i] = buf.getKeyValuePair();
|
|
3633
|
+
}
|
|
3634
|
+
return new _SubscribeOk(requestId, trackAlias, expires, groupOrder, contentExists, largestLocation, parameters);
|
|
3635
|
+
}
|
|
3636
|
+
};
|
|
3637
|
+
|
|
3638
|
+
// src/model/control/subscribe_update.ts
|
|
3639
|
+
var SubscribeUpdate = class _SubscribeUpdate {
|
|
3640
|
+
constructor(requestId, subscriptionRequestId, startLocation, endGroup, subscriberPriority, forward, parameters) {
|
|
3641
|
+
this.requestId = requestId;
|
|
3642
|
+
this.subscriptionRequestId = subscriptionRequestId;
|
|
3643
|
+
this.startLocation = startLocation;
|
|
3644
|
+
this.endGroup = endGroup;
|
|
3645
|
+
this.subscriberPriority = subscriberPriority;
|
|
3646
|
+
this.forward = forward;
|
|
3647
|
+
this.parameters = parameters;
|
|
3648
|
+
}
|
|
3649
|
+
serialize() {
|
|
3650
|
+
const buf = new ByteBuffer();
|
|
3651
|
+
buf.putVI(2 /* SubscribeUpdate */);
|
|
3652
|
+
const payload = new ByteBuffer();
|
|
3653
|
+
payload.putVI(this.requestId);
|
|
3654
|
+
payload.putVI(this.subscriptionRequestId);
|
|
3655
|
+
payload.putLocation(this.startLocation);
|
|
3656
|
+
payload.putVI(this.endGroup);
|
|
3657
|
+
payload.putU8(this.subscriberPriority);
|
|
3658
|
+
payload.putU8(this.forward ? 1 : 0);
|
|
3659
|
+
payload.putVI(this.parameters.length);
|
|
3660
|
+
for (const param of this.parameters) {
|
|
3661
|
+
payload.putBytes(param.serialize().toUint8Array());
|
|
3662
|
+
}
|
|
3663
|
+
const payloadBytes = payload.toUint8Array();
|
|
3664
|
+
buf.putU16(payloadBytes.length);
|
|
3665
|
+
buf.putBytes(payloadBytes);
|
|
3666
|
+
return buf.freeze();
|
|
3667
|
+
}
|
|
3668
|
+
static parsePayload(buf) {
|
|
3669
|
+
const requestId = buf.getVI();
|
|
3670
|
+
const subscriptionRequestId = buf.getVI();
|
|
3671
|
+
const startLocation = buf.getLocation();
|
|
3672
|
+
const endGroup = buf.getVI();
|
|
3673
|
+
const subscriberPriority = buf.getU8();
|
|
3674
|
+
const forward = buf.getU8();
|
|
3675
|
+
const paramCountBig = buf.getVI();
|
|
3676
|
+
const paramCount = Number(paramCountBig);
|
|
3677
|
+
if (BigInt(paramCount) !== paramCountBig) {
|
|
3678
|
+
throw new CastingError("SubscribeUpdate.deserialize paramCount", "bigint", "number", `${paramCountBig}`);
|
|
3679
|
+
}
|
|
3680
|
+
const parameters = [];
|
|
3681
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3682
|
+
parameters.push(KeyValuePair.deserialize(buf));
|
|
3683
|
+
}
|
|
3684
|
+
return new _SubscribeUpdate(
|
|
3685
|
+
requestId,
|
|
3686
|
+
subscriptionRequestId,
|
|
3687
|
+
startLocation,
|
|
3688
|
+
endGroup,
|
|
3689
|
+
subscriberPriority,
|
|
3690
|
+
forward === 1,
|
|
3691
|
+
parameters
|
|
3692
|
+
);
|
|
3693
|
+
}
|
|
3694
|
+
equals(other) {
|
|
3695
|
+
if (this.requestId !== other.requestId || this.subscriptionRequestId !== other.subscriptionRequestId || this.endGroup !== other.endGroup || this.subscriberPriority !== other.subscriberPriority || this.forward !== other.forward || this.startLocation === void 0 !== (other.startLocation === void 0) || this.startLocation && other.startLocation && !this.startLocation.equals(other.startLocation) || this.parameters.length !== other.parameters.length) {
|
|
3696
|
+
return false;
|
|
3697
|
+
}
|
|
3698
|
+
for (let i = 0; i < this.parameters.length; i++) {
|
|
3699
|
+
const a = this.parameters[i];
|
|
3700
|
+
const b = other.parameters[i];
|
|
3701
|
+
if (!a || !b || !a.equals(b)) {
|
|
3702
|
+
return false;
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
return true;
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3708
|
+
|
|
3709
|
+
// src/model/control/requests_blocked.ts
|
|
3710
|
+
var RequestsBlocked = class _RequestsBlocked {
|
|
3711
|
+
maximumRequestId;
|
|
3712
|
+
constructor(maximumRequestId) {
|
|
3713
|
+
this.maximumRequestId = BigInt(maximumRequestId);
|
|
3714
|
+
}
|
|
3715
|
+
getType() {
|
|
3716
|
+
return 26 /* RequestsBlocked */;
|
|
3717
|
+
}
|
|
3718
|
+
serialize() {
|
|
3719
|
+
const buf = new ByteBuffer();
|
|
3720
|
+
buf.putVI(26 /* RequestsBlocked */);
|
|
3721
|
+
const payload = new ByteBuffer();
|
|
3722
|
+
payload.putVI(this.maximumRequestId);
|
|
3723
|
+
const payloadBytes = payload.toUint8Array();
|
|
3724
|
+
if (payloadBytes.length > 65535) {
|
|
3725
|
+
throw new LengthExceedsMaxError("RequestsBlocked::serialize", 65535, payloadBytes.length);
|
|
3726
|
+
}
|
|
3727
|
+
buf.putU16(payloadBytes.length);
|
|
3728
|
+
buf.putBytes(payloadBytes);
|
|
3729
|
+
return buf.freeze();
|
|
3730
|
+
}
|
|
3731
|
+
static parsePayload(buf) {
|
|
3732
|
+
const maximumRequestId = buf.getVI();
|
|
3733
|
+
return new _RequestsBlocked(maximumRequestId);
|
|
3734
|
+
}
|
|
3735
|
+
};
|
|
3736
|
+
|
|
3737
|
+
// src/model/control/track_status.ts
|
|
3738
|
+
var TrackStatus = class _TrackStatus {
|
|
3739
|
+
constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, filterType, startLocation, endGroup, subscribeParameters) {
|
|
3740
|
+
this.requestId = requestId;
|
|
3741
|
+
this.trackAlias = trackAlias;
|
|
3742
|
+
this.fullTrackName = fullTrackName;
|
|
3743
|
+
this.subscriberPriority = subscriberPriority;
|
|
3744
|
+
this.groupOrder = groupOrder;
|
|
3745
|
+
this.forward = forward;
|
|
3746
|
+
this.filterType = filterType;
|
|
3747
|
+
this.startLocation = startLocation;
|
|
3748
|
+
this.endGroup = endGroup;
|
|
3749
|
+
this.subscribeParameters = subscribeParameters;
|
|
3750
|
+
}
|
|
3751
|
+
static newNextGroupStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
3752
|
+
return new _TrackStatus(
|
|
3753
|
+
requestId,
|
|
3754
|
+
trackAlias,
|
|
3755
|
+
fullTrackName,
|
|
3756
|
+
subscriberPriority,
|
|
3757
|
+
groupOrder,
|
|
3758
|
+
forward,
|
|
3759
|
+
1 /* NextGroupStart */,
|
|
3760
|
+
void 0,
|
|
3761
|
+
void 0,
|
|
3762
|
+
subscribeParameters
|
|
3763
|
+
);
|
|
3764
|
+
}
|
|
3765
|
+
static newLatestObject(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
3766
|
+
return new _TrackStatus(
|
|
3767
|
+
requestId,
|
|
3768
|
+
trackAlias,
|
|
3769
|
+
fullTrackName,
|
|
3770
|
+
subscriberPriority,
|
|
3771
|
+
groupOrder,
|
|
3772
|
+
forward,
|
|
3773
|
+
2 /* LatestObject */,
|
|
3774
|
+
void 0,
|
|
3775
|
+
void 0,
|
|
3776
|
+
subscribeParameters
|
|
3777
|
+
);
|
|
3778
|
+
}
|
|
3779
|
+
static newAbsoluteStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, subscribeParameters) {
|
|
3780
|
+
return new _TrackStatus(
|
|
3781
|
+
requestId,
|
|
3782
|
+
trackAlias,
|
|
3783
|
+
fullTrackName,
|
|
3784
|
+
subscriberPriority,
|
|
3785
|
+
groupOrder,
|
|
3786
|
+
forward,
|
|
3787
|
+
3 /* AbsoluteStart */,
|
|
3788
|
+
startLocation,
|
|
3789
|
+
void 0,
|
|
3790
|
+
subscribeParameters
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
static newAbsoluteRange(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, endGroup, subscribeParameters) {
|
|
3794
|
+
if (endGroup < startLocation.group) {
|
|
3795
|
+
throw new Error("End Group must be >= Start Group");
|
|
3796
|
+
}
|
|
3797
|
+
return new _TrackStatus(
|
|
3798
|
+
requestId,
|
|
3799
|
+
trackAlias,
|
|
3800
|
+
fullTrackName,
|
|
3801
|
+
subscriberPriority,
|
|
3802
|
+
groupOrder,
|
|
3803
|
+
forward,
|
|
3804
|
+
4 /* AbsoluteRange */,
|
|
3805
|
+
startLocation,
|
|
3806
|
+
endGroup,
|
|
3807
|
+
subscribeParameters
|
|
3808
|
+
);
|
|
3809
|
+
}
|
|
3810
|
+
serialize() {
|
|
3811
|
+
const buf = new ByteBuffer();
|
|
3812
|
+
buf.putVI(13 /* TrackStatus */);
|
|
3813
|
+
const payload = new ByteBuffer();
|
|
3814
|
+
payload.putVI(this.requestId);
|
|
3815
|
+
payload.putVI(this.trackAlias);
|
|
3816
|
+
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
3817
|
+
payload.putU8(this.subscriberPriority);
|
|
3818
|
+
payload.putU8(this.groupOrder);
|
|
3819
|
+
payload.putU8(this.forward ? 1 : 0);
|
|
3820
|
+
payload.putVI(this.filterType);
|
|
3821
|
+
if (this.filterType === 3 /* AbsoluteStart */ || this.filterType === 4 /* AbsoluteRange */) {
|
|
3822
|
+
if (!this.startLocation) {
|
|
3823
|
+
throw new Error("StartLocation required for selected filterType");
|
|
3824
|
+
}
|
|
3825
|
+
payload.putLocation(this.startLocation);
|
|
3826
|
+
}
|
|
3827
|
+
if (this.filterType === 4 /* AbsoluteRange */) {
|
|
3828
|
+
if (this.endGroup == null) {
|
|
3829
|
+
throw new Error("EndGroup required for AbsoluteRange");
|
|
3830
|
+
}
|
|
3831
|
+
payload.putVI(this.endGroup);
|
|
3832
|
+
}
|
|
3833
|
+
payload.putVI(this.subscribeParameters.length);
|
|
3834
|
+
for (const param of this.subscribeParameters) {
|
|
3835
|
+
payload.putBytes(param.serialize().toUint8Array());
|
|
3836
|
+
}
|
|
3837
|
+
const payloadBytes = payload.toUint8Array();
|
|
3838
|
+
buf.putU16(payloadBytes.length);
|
|
3839
|
+
buf.putBytes(payloadBytes);
|
|
3840
|
+
return buf.freeze();
|
|
3841
|
+
}
|
|
3842
|
+
static parsePayload(buf) {
|
|
3843
|
+
const requestId = buf.getVI();
|
|
3844
|
+
const trackAlias = buf.getVI();
|
|
3845
|
+
const fullTrackName = buf.getFullTrackName();
|
|
3846
|
+
const subscriberPriority = buf.getU8();
|
|
3847
|
+
const groupOrder = buf.getU8();
|
|
3848
|
+
const forward = buf.getU8() === 1;
|
|
3849
|
+
const filterType = Number(buf.getVI());
|
|
3850
|
+
let startLocation = void 0;
|
|
3851
|
+
let endGroup = void 0;
|
|
3852
|
+
if (filterType === 3 /* AbsoluteStart */ || filterType === 4 /* AbsoluteRange */) {
|
|
3853
|
+
startLocation = buf.getLocation();
|
|
3854
|
+
}
|
|
3855
|
+
if (filterType === 4 /* AbsoluteRange */) {
|
|
3856
|
+
endGroup = buf.getVI();
|
|
3857
|
+
}
|
|
3858
|
+
const paramCount = Number(buf.getVI());
|
|
3859
|
+
const subscribeParameters = [];
|
|
3860
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3861
|
+
subscribeParameters.push(KeyValuePair.deserialize(buf));
|
|
3862
|
+
}
|
|
3863
|
+
return new _TrackStatus(
|
|
3864
|
+
requestId,
|
|
3865
|
+
trackAlias,
|
|
3866
|
+
fullTrackName,
|
|
3867
|
+
subscriberPriority,
|
|
3868
|
+
groupOrder,
|
|
3869
|
+
forward,
|
|
3870
|
+
filterType,
|
|
3871
|
+
startLocation,
|
|
3872
|
+
endGroup,
|
|
3873
|
+
subscribeParameters
|
|
3874
|
+
);
|
|
3875
|
+
}
|
|
3876
|
+
};
|
|
3877
|
+
|
|
3878
|
+
// src/model/control/publish_namespace_done.ts
|
|
3879
|
+
var PublishNamespaceDone = class _PublishNamespaceDone {
|
|
3880
|
+
/**
|
|
3881
|
+
* Constructs a PublishNamespaceDone message.
|
|
3882
|
+
* @param trackNamespace - The track namespace to unpublish.
|
|
3883
|
+
*/
|
|
3884
|
+
constructor(trackNamespace) {
|
|
3885
|
+
this.trackNamespace = trackNamespace;
|
|
3886
|
+
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Gets the control message type for this PublishNamespaceDone message.
|
|
3889
|
+
* @returns The ControlMessageType.PublishNamespaceDone enum value.
|
|
3890
|
+
*/
|
|
3891
|
+
getType() {
|
|
3892
|
+
return 9 /* PublishNamespaceDone */;
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Serializes the PublishNamespaceDone message to a frozen byte buffer.
|
|
3896
|
+
* @returns The serialized message as a FrozenByteBuffer.
|
|
3897
|
+
* @throws :{@link LengthExceedsMaxError} If the payload exceeds 65535 bytes.
|
|
3898
|
+
*/
|
|
3899
|
+
serialize() {
|
|
3900
|
+
const buf = new ByteBuffer();
|
|
3901
|
+
buf.putVI(9 /* PublishNamespaceDone */);
|
|
3902
|
+
const payload = new ByteBuffer();
|
|
3903
|
+
payload.putTuple(this.trackNamespace);
|
|
3904
|
+
const payloadBytes = payload.toUint8Array();
|
|
3905
|
+
if (payloadBytes.length > 65535) {
|
|
3906
|
+
throw new LengthExceedsMaxError(
|
|
3907
|
+
"PublishNamespaceDone::serialize(payloadBytes.length)",
|
|
3908
|
+
65535,
|
|
3909
|
+
payloadBytes.length
|
|
3910
|
+
);
|
|
3911
|
+
}
|
|
3912
|
+
buf.putU16(payloadBytes.length);
|
|
3913
|
+
buf.putBytes(payloadBytes);
|
|
3914
|
+
return buf.freeze();
|
|
3915
|
+
}
|
|
3916
|
+
/**
|
|
3917
|
+
* Parses a PublishNamespaceDone message payload from a buffer.
|
|
3918
|
+
* @param buf - The buffer containing the payload.
|
|
3919
|
+
* @returns The parsed PublishNamespaceDone message.
|
|
3920
|
+
*/
|
|
3921
|
+
static parsePayload(buf) {
|
|
3922
|
+
const trackNamespace = buf.getTuple();
|
|
3923
|
+
return new _PublishNamespaceDone(trackNamespace);
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3927
|
+
// src/model/control/unsubscribe.ts
|
|
3928
|
+
var Unsubscribe = class _Unsubscribe {
|
|
3929
|
+
requestId;
|
|
3930
|
+
constructor(requestId) {
|
|
3931
|
+
this.requestId = BigInt(requestId);
|
|
3932
|
+
}
|
|
3933
|
+
getType() {
|
|
3934
|
+
return 10 /* Unsubscribe */;
|
|
3935
|
+
}
|
|
3936
|
+
serialize() {
|
|
3937
|
+
const buf = new ByteBuffer();
|
|
3938
|
+
buf.putVI(10 /* Unsubscribe */);
|
|
3939
|
+
const payload = new ByteBuffer();
|
|
3940
|
+
payload.putVI(this.requestId);
|
|
3941
|
+
const payloadBytes = payload.toUint8Array();
|
|
3942
|
+
if (payloadBytes.length > 65535) {
|
|
3943
|
+
throw new LengthExceedsMaxError("Unsubscribe::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3944
|
+
}
|
|
3945
|
+
buf.putU16(payloadBytes.length);
|
|
3946
|
+
buf.putBytes(payloadBytes);
|
|
3947
|
+
return buf.freeze();
|
|
3948
|
+
}
|
|
3949
|
+
static parsePayload(buf) {
|
|
3950
|
+
const requestId = buf.getVI();
|
|
3951
|
+
return new _Unsubscribe(requestId);
|
|
3952
|
+
}
|
|
3953
|
+
};
|
|
3954
|
+
|
|
3955
|
+
// src/model/control/subscribe_namespace.ts
|
|
3956
|
+
var SubscribeNamespace = class _SubscribeNamespace {
|
|
3957
|
+
constructor(requestId, trackNamespacePrefix, parameters) {
|
|
3958
|
+
this.requestId = requestId;
|
|
3959
|
+
this.trackNamespacePrefix = trackNamespacePrefix;
|
|
3960
|
+
this.parameters = parameters;
|
|
3961
|
+
}
|
|
3962
|
+
getType() {
|
|
3963
|
+
return 17 /* SubscribeNamespace */;
|
|
3964
|
+
}
|
|
3965
|
+
serialize() {
|
|
3966
|
+
const buf = new ByteBuffer();
|
|
3967
|
+
buf.putVI(17 /* SubscribeNamespace */);
|
|
3968
|
+
const payload = new ByteBuffer();
|
|
3969
|
+
payload.putVI(this.requestId);
|
|
3970
|
+
payload.putTuple(this.trackNamespacePrefix);
|
|
3971
|
+
payload.putVI(this.parameters.length);
|
|
3972
|
+
for (const param of this.parameters) {
|
|
3973
|
+
payload.putKeyValuePair(param);
|
|
3974
|
+
}
|
|
3975
|
+
const payloadBytes = payload.toUint8Array();
|
|
3976
|
+
if (payloadBytes.length > 65535) {
|
|
3977
|
+
throw new LengthExceedsMaxError("SubscribeNamespace::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3978
|
+
}
|
|
3979
|
+
buf.putU16(payloadBytes.length);
|
|
3980
|
+
buf.putBytes(payloadBytes);
|
|
3981
|
+
return buf.freeze();
|
|
3982
|
+
}
|
|
3983
|
+
static parsePayload(buf) {
|
|
3984
|
+
const requestId = buf.getVI();
|
|
3985
|
+
const trackNamespacePrefix = buf.getTuple();
|
|
3986
|
+
const paramCount = buf.getNumberVI();
|
|
3987
|
+
const parameters = new Array(paramCount);
|
|
3988
|
+
for (let i = 0; i < paramCount; i++) {
|
|
3989
|
+
parameters[i] = buf.getKeyValuePair();
|
|
3990
|
+
}
|
|
3991
|
+
return new _SubscribeNamespace(requestId, trackNamespacePrefix, parameters);
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
|
|
3995
|
+
// src/model/control/subscribe_namespace_ok.ts
|
|
3996
|
+
var SubscribeNamespaceOk = class _SubscribeNamespaceOk {
|
|
3997
|
+
requestId;
|
|
3998
|
+
constructor(requestId) {
|
|
3999
|
+
this.requestId = BigInt(requestId);
|
|
4000
|
+
}
|
|
4001
|
+
getType() {
|
|
4002
|
+
return 18 /* SubscribeNamespaceOk */;
|
|
4003
|
+
}
|
|
4004
|
+
serialize() {
|
|
4005
|
+
const buf = new ByteBuffer();
|
|
4006
|
+
buf.putVI(18 /* SubscribeNamespaceOk */);
|
|
4007
|
+
const payload = new ByteBuffer();
|
|
4008
|
+
payload.putVI(this.requestId);
|
|
4009
|
+
const payloadBytes = payload.toUint8Array();
|
|
4010
|
+
if (payloadBytes.length > 65535) {
|
|
4011
|
+
throw new LengthExceedsMaxError("SubscribeNamespaceOk::serialize(payloadBytes)", 65535, payloadBytes.length);
|
|
4012
|
+
}
|
|
4013
|
+
buf.putU16(payloadBytes.length);
|
|
4014
|
+
buf.putBytes(payloadBytes);
|
|
4015
|
+
return buf.freeze();
|
|
4016
|
+
}
|
|
4017
|
+
static parsePayload(buf) {
|
|
4018
|
+
const requestId = buf.getVI();
|
|
4019
|
+
return new _SubscribeNamespaceOk(requestId);
|
|
4020
|
+
}
|
|
4021
|
+
};
|
|
4022
|
+
|
|
4023
|
+
// src/model/control/subscribe_namespace_error.ts
|
|
4024
|
+
var SubscribeNamespaceError = class _SubscribeNamespaceError {
|
|
4025
|
+
constructor(requestId, errorCode, reasonPhrase) {
|
|
4026
|
+
this.requestId = requestId;
|
|
4027
|
+
this.errorCode = errorCode;
|
|
4028
|
+
this.reasonPhrase = reasonPhrase;
|
|
4029
|
+
}
|
|
4030
|
+
getType() {
|
|
4031
|
+
return 19 /* SubscribeNamespaceError */;
|
|
4032
|
+
}
|
|
4033
|
+
serialize() {
|
|
4034
|
+
const buf = new ByteBuffer();
|
|
4035
|
+
buf.putVI(19 /* SubscribeNamespaceError */);
|
|
4036
|
+
const payload = new ByteBuffer();
|
|
4037
|
+
payload.putVI(this.requestId);
|
|
4038
|
+
payload.putVI(this.errorCode);
|
|
4039
|
+
payload.putReasonPhrase(this.reasonPhrase);
|
|
4040
|
+
const payloadBytes = payload.toUint8Array();
|
|
4041
|
+
if (payloadBytes.length > 65535) {
|
|
4042
|
+
throw new LengthExceedsMaxError("SubscribeNamespaceError::serialize(payload_length)", 65535, payloadBytes.length);
|
|
4043
|
+
}
|
|
4044
|
+
buf.putU16(payloadBytes.length);
|
|
4045
|
+
buf.putBytes(payloadBytes);
|
|
4046
|
+
return buf.freeze();
|
|
4047
|
+
}
|
|
4048
|
+
static parsePayload(buf) {
|
|
4049
|
+
const requestId = buf.getVI();
|
|
4050
|
+
const errorCodeRaw = buf.getVI();
|
|
4051
|
+
const errorCode = subscribeNamespaceErrorCodeFromBigInt(errorCodeRaw);
|
|
4052
|
+
const reasonPhrase = buf.getReasonPhrase();
|
|
4053
|
+
return new _SubscribeNamespaceError(requestId, errorCode, reasonPhrase);
|
|
4054
|
+
}
|
|
4055
|
+
};
|
|
4056
|
+
|
|
4057
|
+
// src/model/control/unsubscribe_namespace.ts
|
|
4058
|
+
var UnsubscribeNamespace = class _UnsubscribeNamespace {
|
|
4059
|
+
constructor(trackNamespacePrefix) {
|
|
4060
|
+
this.trackNamespacePrefix = trackNamespacePrefix;
|
|
4061
|
+
}
|
|
4062
|
+
getType() {
|
|
4063
|
+
return 20 /* UnsubscribeNamespace */;
|
|
4064
|
+
}
|
|
4065
|
+
serialize() {
|
|
4066
|
+
const buf = new ByteBuffer();
|
|
4067
|
+
buf.putVI(20 /* UnsubscribeNamespace */);
|
|
4068
|
+
const payload = new ByteBuffer();
|
|
4069
|
+
payload.putTuple(this.trackNamespacePrefix);
|
|
4070
|
+
const payloadBytes = payload.toUint8Array();
|
|
4071
|
+
if (payloadBytes.length > 65535) {
|
|
4072
|
+
throw new LengthExceedsMaxError("UnsubscribeNamespace::serialize(payload_length)", 65535, payloadBytes.length);
|
|
4073
|
+
}
|
|
4074
|
+
buf.putU16(payloadBytes.length);
|
|
4075
|
+
buf.putBytes(payloadBytes);
|
|
4076
|
+
return buf.freeze();
|
|
4077
|
+
}
|
|
4078
|
+
static parsePayload(buf) {
|
|
4079
|
+
const trackNamespacePrefix = buf.getTuple();
|
|
4080
|
+
return new _UnsubscribeNamespace(trackNamespacePrefix);
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
|
|
4084
|
+
// src/model/control/control_message.ts
|
|
4085
|
+
exports.ControlMessage = void 0;
|
|
4086
|
+
((ControlMessage2) => {
|
|
4087
|
+
function deserialize(buf) {
|
|
4088
|
+
const messageTypeRaw = buf.getVI();
|
|
4089
|
+
const messageType = controlMessageTypeFromBigInt(messageTypeRaw);
|
|
4090
|
+
const payloadLength = buf.getU16();
|
|
4091
|
+
if (buf.remaining < payloadLength)
|
|
4092
|
+
throw new NotEnoughBytesError("ControlMessage.deserialize(payload_bytes)", payloadLength, buf.remaining);
|
|
4093
|
+
const payloadBytes = buf.getBytes(payloadLength);
|
|
4094
|
+
const payload = new FrozenByteBuffer5(payloadBytes);
|
|
4095
|
+
switch (messageType) {
|
|
4096
|
+
case 29 /* Publish */:
|
|
4097
|
+
return Publish.parsePayload(payload);
|
|
4098
|
+
case 30 /* PublishOk */:
|
|
4099
|
+
return PublishOk.parsePayload(payload);
|
|
4100
|
+
case 31 /* PublishError */:
|
|
4101
|
+
return PublishError.parsePayload(payload);
|
|
4102
|
+
case 11 /* PublishDone */:
|
|
4103
|
+
return PublishDone.parsePayload(payload);
|
|
4104
|
+
case 6 /* PublishNamespace */:
|
|
4105
|
+
return PublishNamespace.parsePayload(payload);
|
|
4106
|
+
case 12 /* PublishNamespaceCancel */:
|
|
4107
|
+
return PublishNamespaceCancel.parsePayload(payload);
|
|
4108
|
+
case 8 /* PublishNamespaceError */:
|
|
4109
|
+
return PublishNamespaceError.parsePayload(payload);
|
|
4110
|
+
case 7 /* PublishNamespaceOk */:
|
|
4111
|
+
return PublishNamespaceOk.parsePayload(payload);
|
|
4112
|
+
case 32 /* ClientSetup */:
|
|
4113
|
+
return ClientSetup.parsePayload(payload);
|
|
4114
|
+
case 22 /* Fetch */:
|
|
4115
|
+
return Fetch.parsePayload(payload);
|
|
4116
|
+
case 23 /* FetchCancel */:
|
|
4117
|
+
return FetchCancel.parsePayload(payload);
|
|
4118
|
+
case 25 /* FetchError */:
|
|
4119
|
+
return FetchError.parsePayload(payload);
|
|
4120
|
+
case 24 /* FetchOk */:
|
|
4121
|
+
return FetchOk.parsePayload(payload);
|
|
4122
|
+
case 16 /* GoAway */:
|
|
4123
|
+
return GoAway.parsePayload(payload);
|
|
4124
|
+
case 21 /* MaxRequestId */:
|
|
4125
|
+
return MaxRequestId.parsePayload(payload);
|
|
4126
|
+
case 33 /* ServerSetup */:
|
|
4127
|
+
return ServerSetup.parsePayload(payload);
|
|
4128
|
+
case 3 /* Subscribe */:
|
|
4129
|
+
return Subscribe.parsePayload(payload);
|
|
4130
|
+
case 5 /* SubscribeError */:
|
|
4131
|
+
return SubscribeError.parsePayload(payload);
|
|
4132
|
+
case 4 /* SubscribeOk */:
|
|
4133
|
+
return SubscribeOk.parsePayload(payload);
|
|
4134
|
+
case 2 /* SubscribeUpdate */:
|
|
4135
|
+
return SubscribeUpdate.parsePayload(payload);
|
|
4136
|
+
case 26 /* RequestsBlocked */:
|
|
4137
|
+
return RequestsBlocked.parsePayload(payload);
|
|
4138
|
+
case 13 /* TrackStatus */:
|
|
4139
|
+
return TrackStatus.parsePayload(payload);
|
|
4140
|
+
case 13 /* TrackStatus */:
|
|
4141
|
+
return TrackStatus.parsePayload(payload);
|
|
4142
|
+
case 9 /* PublishNamespaceDone */:
|
|
4143
|
+
return PublishNamespaceDone.parsePayload(payload);
|
|
4144
|
+
case 10 /* Unsubscribe */:
|
|
4145
|
+
return Unsubscribe.parsePayload(payload);
|
|
4146
|
+
case 17 /* SubscribeNamespace */:
|
|
4147
|
+
return SubscribeNamespace.parsePayload(payload);
|
|
4148
|
+
case 18 /* SubscribeNamespaceOk */:
|
|
4149
|
+
return SubscribeNamespaceOk.parsePayload(payload);
|
|
4150
|
+
case 19 /* SubscribeNamespaceError */:
|
|
4151
|
+
return SubscribeNamespaceError.parsePayload(payload);
|
|
4152
|
+
case 20 /* UnsubscribeNamespace */:
|
|
4153
|
+
return UnsubscribeNamespace.parsePayload(payload);
|
|
4154
|
+
default:
|
|
4155
|
+
throw new Error(`Unknown or unhandled ControlMessageType: ${messageType}`);
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
ControlMessage2.deserialize = deserialize;
|
|
4159
|
+
function serialize(msg) {
|
|
4160
|
+
return msg.serialize();
|
|
4161
|
+
}
|
|
4162
|
+
ControlMessage2.serialize = serialize;
|
|
4163
|
+
})(exports.ControlMessage || (exports.ControlMessage = {}));
|
|
4164
|
+
|
|
4165
|
+
// src/model/control/track_status_error.ts
|
|
4166
|
+
var TrackStatusError = class _TrackStatusError {
|
|
4167
|
+
constructor(requestId, errorCode, errorReason, trackAlias) {
|
|
4168
|
+
this.requestId = requestId;
|
|
4169
|
+
this.errorCode = errorCode;
|
|
4170
|
+
this.errorReason = errorReason;
|
|
4171
|
+
this.trackAlias = trackAlias;
|
|
4172
|
+
}
|
|
4173
|
+
static new(requestId, errorCode, errorReason, trackAlias) {
|
|
4174
|
+
return new _TrackStatusError(BigInt(requestId), errorCode, errorReason, trackAlias);
|
|
4175
|
+
}
|
|
4176
|
+
getType() {
|
|
4177
|
+
return 15 /* TrackStatusError */;
|
|
4178
|
+
}
|
|
4179
|
+
serialize() {
|
|
4180
|
+
const buf = new ByteBuffer();
|
|
4181
|
+
buf.putVI(15 /* TrackStatusError */);
|
|
4182
|
+
const payload = new ByteBuffer();
|
|
4183
|
+
payload.putVI(this.requestId);
|
|
4184
|
+
payload.putVI(this.errorCode);
|
|
4185
|
+
payload.putReasonPhrase(this.errorReason);
|
|
4186
|
+
payload.putVI(this.trackAlias);
|
|
4187
|
+
const payloadBytes = payload.toUint8Array();
|
|
4188
|
+
if (payloadBytes.length > 65535) {
|
|
4189
|
+
throw new LengthExceedsMaxError("TrackStatusError::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4190
|
+
}
|
|
4191
|
+
buf.putU16(payloadBytes.length);
|
|
4192
|
+
buf.putBytes(payloadBytes);
|
|
4193
|
+
return buf.freeze();
|
|
4194
|
+
}
|
|
4195
|
+
static parsePayload(buf) {
|
|
4196
|
+
const requestId = buf.getVI();
|
|
4197
|
+
const errorCodeRaw = buf.getVI();
|
|
4198
|
+
const errorCode = subscribeErrorCodeFromBigInt(errorCodeRaw);
|
|
4199
|
+
const errorReason = buf.getReasonPhrase();
|
|
4200
|
+
const trackAlias = buf.getVI();
|
|
4201
|
+
return new _TrackStatusError(requestId, errorCode, errorReason, trackAlias);
|
|
4202
|
+
}
|
|
4203
|
+
};
|
|
4204
|
+
|
|
4205
|
+
// src/model/control/track_status_ok.ts
|
|
4206
|
+
var TrackStatusOk = class _TrackStatusOk {
|
|
4207
|
+
requestId;
|
|
4208
|
+
expires;
|
|
4209
|
+
groupOrder;
|
|
4210
|
+
contentExists;
|
|
4211
|
+
largestLocation;
|
|
4212
|
+
subscribeParameters;
|
|
4213
|
+
constructor(requestId, expires, groupOrder, contentExists, largestLocation, subscribeParameters) {
|
|
4214
|
+
this.requestId = requestId;
|
|
4215
|
+
this.expires = expires;
|
|
4216
|
+
this.groupOrder = groupOrder;
|
|
4217
|
+
this.contentExists = contentExists;
|
|
4218
|
+
this.largestLocation = largestLocation;
|
|
4219
|
+
this.subscribeParameters = subscribeParameters;
|
|
4220
|
+
}
|
|
4221
|
+
static newAscendingNoContent(requestId, expires, subscribeParameters) {
|
|
4222
|
+
return new _TrackStatusOk(requestId, expires, 1 /* Ascending */, false, void 0, subscribeParameters);
|
|
4223
|
+
}
|
|
4224
|
+
static newDescendingNoContent(requestId, expires, subscribeParameters) {
|
|
4225
|
+
return new _TrackStatusOk(requestId, expires, 2 /* Descending */, false, void 0, subscribeParameters);
|
|
4226
|
+
}
|
|
4227
|
+
static newAscendingWithContent(requestId, expires, largestLocation, subscribeParameters) {
|
|
4228
|
+
return new _TrackStatusOk(requestId, expires, 1 /* Ascending */, true, largestLocation, subscribeParameters);
|
|
4229
|
+
}
|
|
4230
|
+
static newDescendingWithContent(requestId, expires, largestLocation, subscribeParameters) {
|
|
4231
|
+
return new _TrackStatusOk(requestId, expires, 2 /* Descending */, true, largestLocation, subscribeParameters);
|
|
4232
|
+
}
|
|
4233
|
+
serialize() {
|
|
4234
|
+
const buf = new ByteBuffer();
|
|
4235
|
+
buf.putVI(14 /* TrackStatusOk */);
|
|
4236
|
+
const payload = new ByteBuffer();
|
|
4237
|
+
payload.putVI(this.requestId);
|
|
4238
|
+
payload.putVI(this.expires);
|
|
4239
|
+
payload.putU8(this.groupOrder);
|
|
4240
|
+
if (this.contentExists) {
|
|
4241
|
+
payload.putU8(1);
|
|
4242
|
+
payload.putLocation(this.largestLocation);
|
|
4243
|
+
} else {
|
|
4244
|
+
payload.putU8(0);
|
|
4245
|
+
}
|
|
4246
|
+
payload.putVI(this.subscribeParameters.length);
|
|
4247
|
+
for (const param of this.subscribeParameters) {
|
|
4248
|
+
payload.putKeyValuePair(param);
|
|
4249
|
+
}
|
|
4250
|
+
const payloadBytes = payload.toUint8Array();
|
|
4251
|
+
if (payloadBytes.length > 65535) {
|
|
4252
|
+
throw new LengthExceedsMaxError("TrackStatusOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4253
|
+
}
|
|
4254
|
+
buf.putU16(payloadBytes.length);
|
|
4255
|
+
buf.putBytes(payloadBytes);
|
|
4256
|
+
return buf.freeze();
|
|
4257
|
+
}
|
|
4258
|
+
static parsePayload(buf) {
|
|
4259
|
+
const requestId = buf.getVI();
|
|
4260
|
+
const expires = buf.getVI();
|
|
4261
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("TrackStatusOk::parsePayload(groupOrder)", 1, buf.remaining);
|
|
4262
|
+
const groupOrderRaw = buf.getU8();
|
|
4263
|
+
const groupOrder = groupOrderFromNumber(groupOrderRaw);
|
|
4264
|
+
if (groupOrder === 0 /* Original */) {
|
|
4265
|
+
throw new ProtocolViolationError(
|
|
4266
|
+
"TrackStatusOk::parsePayload(groupOrder)",
|
|
4267
|
+
"Group order must be Ascending(0x01) or Descending(0x02)"
|
|
4268
|
+
);
|
|
4269
|
+
}
|
|
4270
|
+
if (buf.remaining < 1) throw new NotEnoughBytesError("TrackStatusOk::parsePayload(contentExists)", 1, buf.remaining);
|
|
4271
|
+
const contentExistsRaw = buf.getU8();
|
|
4272
|
+
let contentExists;
|
|
4273
|
+
if (contentExistsRaw === 0) {
|
|
4274
|
+
contentExists = false;
|
|
4275
|
+
} else if (contentExistsRaw === 1) {
|
|
4276
|
+
contentExists = true;
|
|
4277
|
+
} else {
|
|
4278
|
+
throw new ProtocolViolationError(
|
|
4279
|
+
"TrackStatusOk::parsePayload",
|
|
4280
|
+
`Invalid Content Exists value: ${contentExistsRaw}`
|
|
4281
|
+
);
|
|
4282
|
+
}
|
|
4283
|
+
let largestLocation = void 0;
|
|
4284
|
+
if (contentExists) {
|
|
4285
|
+
largestLocation = buf.getLocation();
|
|
4286
|
+
}
|
|
4287
|
+
const paramCount = buf.getNumberVI();
|
|
4288
|
+
const subscribeParameters = new Array(paramCount);
|
|
4289
|
+
for (let i = 0; i < paramCount; i++) {
|
|
4290
|
+
subscribeParameters[i] = buf.getKeyValuePair();
|
|
4291
|
+
}
|
|
4292
|
+
return new _TrackStatusOk(requestId, expires, groupOrder, contentExists, largestLocation, subscribeParameters);
|
|
4293
|
+
}
|
|
4294
|
+
};
|
|
4295
|
+
|
|
4296
|
+
// src/model/parameter/constant.ts
|
|
4297
|
+
var CommonType = /* @__PURE__ */ ((CommonType2) => {
|
|
4298
|
+
CommonType2[CommonType2["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
4299
|
+
return CommonType2;
|
|
4300
|
+
})(CommonType || {});
|
|
4301
|
+
function commonTypeFromNumber(value) {
|
|
4302
|
+
switch (value) {
|
|
4303
|
+
case 3:
|
|
4304
|
+
return 3 /* AuthorizationToken */;
|
|
4305
|
+
default:
|
|
4306
|
+
throw new InvalidTypeError("commonTypeFromNumber", `Invalid common type: ${value}`);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
var SetupParameterType = /* @__PURE__ */ ((SetupParameterType2) => {
|
|
4310
|
+
SetupParameterType2[SetupParameterType2["Path"] = 1] = "Path";
|
|
4311
|
+
SetupParameterType2[SetupParameterType2["MaxRequestId"] = 2] = "MaxRequestId";
|
|
4312
|
+
SetupParameterType2[SetupParameterType2["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
|
|
4313
|
+
return SetupParameterType2;
|
|
4314
|
+
})(SetupParameterType || {});
|
|
4315
|
+
function setupParameterTypeFromNumber(value) {
|
|
4316
|
+
switch (value) {
|
|
4317
|
+
case 1:
|
|
4318
|
+
return 1 /* Path */;
|
|
4319
|
+
case 2:
|
|
4320
|
+
return 2 /* MaxRequestId */;
|
|
4321
|
+
case 4:
|
|
4322
|
+
return 4 /* MaxAuthTokenCacheSize */;
|
|
4323
|
+
default:
|
|
4324
|
+
throw new InvalidTypeError("setupParameterTypeFromNumber", `Invalid setup parameter type: ${value}`);
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
var VersionSpecificParameterType = /* @__PURE__ */ ((VersionSpecificParameterType2) => {
|
|
4328
|
+
VersionSpecificParameterType2[VersionSpecificParameterType2["AuthorizationToken"] = 1] = "AuthorizationToken";
|
|
4329
|
+
VersionSpecificParameterType2[VersionSpecificParameterType2["DeliveryTimeout"] = 2] = "DeliveryTimeout";
|
|
4330
|
+
VersionSpecificParameterType2[VersionSpecificParameterType2["MaxCacheDuration"] = 4] = "MaxCacheDuration";
|
|
4331
|
+
return VersionSpecificParameterType2;
|
|
4332
|
+
})(VersionSpecificParameterType || {});
|
|
4333
|
+
function versionSpecificParameterTypeFromNumber(value) {
|
|
4334
|
+
switch (value) {
|
|
4335
|
+
case 1:
|
|
4336
|
+
return 1 /* AuthorizationToken */;
|
|
4337
|
+
case 2:
|
|
4338
|
+
return 2 /* DeliveryTimeout */;
|
|
4339
|
+
case 4:
|
|
4340
|
+
return 4 /* MaxCacheDuration */;
|
|
4341
|
+
default:
|
|
4342
|
+
throw new InvalidTypeError("versionSpecificParameterTypeFromNumber", `Invalid version parameter type: ${value}`);
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
var TokenAliasType = /* @__PURE__ */ ((TokenAliasType3) => {
|
|
4346
|
+
TokenAliasType3[TokenAliasType3["Delete"] = 0] = "Delete";
|
|
4347
|
+
TokenAliasType3[TokenAliasType3["Register"] = 1] = "Register";
|
|
4348
|
+
TokenAliasType3[TokenAliasType3["UseAlias"] = 2] = "UseAlias";
|
|
4349
|
+
TokenAliasType3[TokenAliasType3["UseValue"] = 3] = "UseValue";
|
|
4350
|
+
return TokenAliasType3;
|
|
4351
|
+
})(TokenAliasType || {});
|
|
4352
|
+
function tokenAliasTypeFromNumber(value) {
|
|
4353
|
+
switch (value) {
|
|
4354
|
+
case 0:
|
|
4355
|
+
return 0 /* Delete */;
|
|
4356
|
+
case 1:
|
|
4357
|
+
return 1 /* Register */;
|
|
4358
|
+
case 2:
|
|
4359
|
+
return 2 /* UseAlias */;
|
|
4360
|
+
case 3:
|
|
4361
|
+
return 3 /* UseValue */;
|
|
4362
|
+
default:
|
|
4363
|
+
throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
// src/model/parameter/setup/max_request_id.ts
|
|
4368
|
+
var MaxRequestId2 = class _MaxRequestId {
|
|
4369
|
+
constructor(maxId) {
|
|
4370
|
+
this.maxId = maxId;
|
|
4371
|
+
}
|
|
4372
|
+
static TYPE = 2 /* MaxRequestId */;
|
|
4373
|
+
toKeyValuePair() {
|
|
4374
|
+
return KeyValuePair.tryNewVarInt(_MaxRequestId.TYPE, this.maxId);
|
|
4375
|
+
}
|
|
4376
|
+
static fromKeyValuePair(pair) {
|
|
4377
|
+
if (Number(pair.typeValue) !== _MaxRequestId.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4378
|
+
return new _MaxRequestId(pair.value);
|
|
4379
|
+
}
|
|
4380
|
+
};
|
|
4381
|
+
|
|
4382
|
+
// src/model/parameter/setup/path.ts
|
|
4383
|
+
var Path = class _Path {
|
|
4384
|
+
constructor(moqtPath) {
|
|
4385
|
+
this.moqtPath = moqtPath;
|
|
4386
|
+
}
|
|
4387
|
+
static TYPE = 1 /* Path */;
|
|
4388
|
+
toKeyValuePair() {
|
|
4389
|
+
const encoder = new TextEncoder();
|
|
4390
|
+
const bytes = encoder.encode(this.moqtPath);
|
|
4391
|
+
return KeyValuePair.tryNewBytes(_Path.TYPE, bytes);
|
|
4392
|
+
}
|
|
4393
|
+
static fromKeyValuePair(pair) {
|
|
4394
|
+
if (Number(pair.typeValue) !== _Path.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4395
|
+
const moqtPath = new TextDecoder().decode(pair.value);
|
|
4396
|
+
return new _Path(moqtPath);
|
|
4397
|
+
}
|
|
4398
|
+
};
|
|
4399
|
+
|
|
4400
|
+
// src/model/parameter/setup/max_auth_token_cache_size.ts
|
|
4401
|
+
var MaxAuthTokenCacheSize = class _MaxAuthTokenCacheSize {
|
|
4402
|
+
constructor(maxSize) {
|
|
4403
|
+
this.maxSize = maxSize;
|
|
4404
|
+
}
|
|
4405
|
+
static TYPE = 4 /* MaxAuthTokenCacheSize */;
|
|
4406
|
+
toKeyValuePair() {
|
|
4407
|
+
return KeyValuePair.tryNewVarInt(_MaxAuthTokenCacheSize.TYPE, this.maxSize);
|
|
4408
|
+
}
|
|
4409
|
+
static fromKeyValuePair(pair) {
|
|
4410
|
+
if (Number(pair.typeValue) !== _MaxAuthTokenCacheSize.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4411
|
+
return new _MaxAuthTokenCacheSize(pair.value);
|
|
4412
|
+
}
|
|
4413
|
+
};
|
|
4414
|
+
|
|
4415
|
+
// src/model/parameter/common/authorization_token.ts
|
|
4416
|
+
var AuthorizationToken = class _AuthorizationToken {
|
|
4417
|
+
constructor(variant) {
|
|
4418
|
+
this.variant = variant;
|
|
4419
|
+
}
|
|
4420
|
+
static TYPE = 3 /* AuthorizationToken */;
|
|
4421
|
+
static newDelete(tokenAlias) {
|
|
4422
|
+
return new _AuthorizationToken({
|
|
4423
|
+
aliasType: 0 /* Delete */,
|
|
4424
|
+
tokenAlias: BigInt(tokenAlias)
|
|
4425
|
+
});
|
|
4426
|
+
}
|
|
4427
|
+
static newRegister(tokenAlias, tokenType, tokenValue) {
|
|
4428
|
+
return new _AuthorizationToken({
|
|
4429
|
+
aliasType: 1 /* Register */,
|
|
4430
|
+
tokenAlias: BigInt(tokenAlias),
|
|
4431
|
+
tokenType: BigInt(tokenType),
|
|
4432
|
+
tokenValue
|
|
4433
|
+
});
|
|
4434
|
+
}
|
|
4435
|
+
static newUseAlias(tokenAlias) {
|
|
4436
|
+
return new _AuthorizationToken({
|
|
4437
|
+
aliasType: 2 /* UseAlias */,
|
|
4438
|
+
tokenAlias: BigInt(tokenAlias)
|
|
4439
|
+
});
|
|
4440
|
+
}
|
|
4441
|
+
static newUseValue(tokenType, tokenValue) {
|
|
4442
|
+
return new _AuthorizationToken({
|
|
4443
|
+
aliasType: 3 /* UseValue */,
|
|
4444
|
+
tokenType: BigInt(tokenType),
|
|
4445
|
+
tokenValue
|
|
4446
|
+
});
|
|
4447
|
+
}
|
|
4448
|
+
toKeyValuePair() {
|
|
4449
|
+
const payload = new ByteBuffer();
|
|
4450
|
+
payload.putVI(this.variant.aliasType);
|
|
4451
|
+
switch (this.variant.aliasType) {
|
|
4452
|
+
case 0 /* Delete */:
|
|
4453
|
+
payload.putVI(this.variant.tokenAlias);
|
|
4454
|
+
break;
|
|
4455
|
+
case 1 /* Register */:
|
|
4456
|
+
payload.putVI(this.variant.tokenAlias);
|
|
4457
|
+
payload.putVI(this.variant.tokenType);
|
|
4458
|
+
payload.putBytes(this.variant.tokenValue);
|
|
4459
|
+
break;
|
|
4460
|
+
case 2 /* UseAlias */:
|
|
4461
|
+
payload.putVI(this.variant.tokenAlias);
|
|
4462
|
+
break;
|
|
4463
|
+
case 3 /* UseValue */:
|
|
4464
|
+
payload.putVI(this.variant.tokenType);
|
|
4465
|
+
payload.putBytes(this.variant.tokenValue);
|
|
4466
|
+
break;
|
|
4467
|
+
}
|
|
4468
|
+
return KeyValuePair.tryNewBytes(_AuthorizationToken.TYPE, payload.toUint8Array());
|
|
4469
|
+
}
|
|
4470
|
+
static fromKeyValuePair(pair) {
|
|
4471
|
+
if (Number(pair.typeValue) !== _AuthorizationToken.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4472
|
+
const frozen = new FrozenByteBuffer5(pair.value);
|
|
4473
|
+
const aliasTypeRaw = frozen.getNumberVI();
|
|
4474
|
+
const aliasType = tokenAliasTypeFromNumber(aliasTypeRaw);
|
|
4475
|
+
switch (aliasType) {
|
|
4476
|
+
case 0 /* Delete */: {
|
|
4477
|
+
const tokenAlias = frozen.getVI();
|
|
4478
|
+
return new _AuthorizationToken({ aliasType, tokenAlias });
|
|
4479
|
+
}
|
|
4480
|
+
case 1 /* Register */: {
|
|
4481
|
+
const tokenAlias = frozen.getVI();
|
|
4482
|
+
const tokenType = frozen.getVI();
|
|
4483
|
+
const tokenValue = frozen.getBytes(frozen.remaining);
|
|
4484
|
+
return new _AuthorizationToken({ aliasType, tokenAlias, tokenType, tokenValue });
|
|
4485
|
+
}
|
|
4486
|
+
case 2 /* UseAlias */: {
|
|
4487
|
+
const tokenAlias = frozen.getVI();
|
|
4488
|
+
return new _AuthorizationToken({ aliasType, tokenAlias });
|
|
4489
|
+
}
|
|
4490
|
+
case 3 /* UseValue */: {
|
|
4491
|
+
const tokenType = frozen.getVI();
|
|
4492
|
+
const tokenValue = frozen.getBytes(frozen.remaining);
|
|
4493
|
+
return new _AuthorizationToken({ aliasType, tokenType, tokenValue });
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
}
|
|
4497
|
+
};
|
|
4498
|
+
|
|
4499
|
+
// src/model/parameter/setup_parameter.ts
|
|
4500
|
+
exports.SetupParameter = void 0;
|
|
4501
|
+
((SetupParameter2) => {
|
|
4502
|
+
function fromKeyValuePair(pair) {
|
|
4503
|
+
return Path.fromKeyValuePair(pair) || MaxRequestId2.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair);
|
|
4504
|
+
}
|
|
4505
|
+
SetupParameter2.fromKeyValuePair = fromKeyValuePair;
|
|
4506
|
+
function toKeyValuePair(param) {
|
|
4507
|
+
return param.toKeyValuePair();
|
|
4508
|
+
}
|
|
4509
|
+
SetupParameter2.toKeyValuePair = toKeyValuePair;
|
|
4510
|
+
function isPath(param) {
|
|
4511
|
+
return param instanceof Path;
|
|
4512
|
+
}
|
|
4513
|
+
SetupParameter2.isPath = isPath;
|
|
4514
|
+
function isMaxRequestId(param) {
|
|
4515
|
+
return param instanceof MaxRequestId2;
|
|
4516
|
+
}
|
|
4517
|
+
SetupParameter2.isMaxRequestId = isMaxRequestId;
|
|
4518
|
+
function isMaxAuthTokenCacheSize(param) {
|
|
4519
|
+
return param instanceof MaxAuthTokenCacheSize;
|
|
4520
|
+
}
|
|
4521
|
+
SetupParameter2.isMaxAuthTokenCacheSize = isMaxAuthTokenCacheSize;
|
|
4522
|
+
function isAuthorizationToken(param) {
|
|
4523
|
+
return param instanceof AuthorizationToken;
|
|
4524
|
+
}
|
|
4525
|
+
SetupParameter2.isAuthorizationToken = isAuthorizationToken;
|
|
4526
|
+
})(exports.SetupParameter || (exports.SetupParameter = {}));
|
|
4527
|
+
var SetupParameters = class {
|
|
4528
|
+
kvps = [];
|
|
4529
|
+
addMaxAuthTokenCacheSize(maxSize) {
|
|
4530
|
+
this.kvps.push(new MaxAuthTokenCacheSize(BigInt(maxSize)).toKeyValuePair());
|
|
4531
|
+
return this;
|
|
4532
|
+
}
|
|
4533
|
+
addMaxRequestId(maxId) {
|
|
4534
|
+
this.kvps.push(new MaxRequestId2(BigInt(maxId)).toKeyValuePair());
|
|
4535
|
+
return this;
|
|
4536
|
+
}
|
|
4537
|
+
addPath(moqtPath) {
|
|
4538
|
+
this.kvps.push(new Path(moqtPath).toKeyValuePair());
|
|
4539
|
+
return this;
|
|
4540
|
+
}
|
|
4541
|
+
addAuthorizationToken(auth) {
|
|
4542
|
+
this.kvps.push(auth.toKeyValuePair());
|
|
4543
|
+
return this;
|
|
4544
|
+
}
|
|
4545
|
+
addRaw(pair) {
|
|
4546
|
+
this.kvps.push(pair);
|
|
4547
|
+
return this;
|
|
4548
|
+
}
|
|
4549
|
+
build() {
|
|
4550
|
+
return this.kvps;
|
|
4551
|
+
}
|
|
4552
|
+
static fromKeyValuePairs(kvps) {
|
|
4553
|
+
const result = [];
|
|
4554
|
+
for (const kvp of kvps) {
|
|
4555
|
+
const parsed = Path.fromKeyValuePair(kvp) || MaxRequestId2.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp);
|
|
4556
|
+
if (parsed) result.push(parsed);
|
|
4557
|
+
}
|
|
4558
|
+
return result;
|
|
4559
|
+
}
|
|
4560
|
+
};
|
|
4561
|
+
|
|
4562
|
+
// src/model/parameter/version/delivery_timeout.ts
|
|
4563
|
+
var DeliveryTimeout = class _DeliveryTimeout {
|
|
4564
|
+
constructor(objectTimeout) {
|
|
4565
|
+
this.objectTimeout = objectTimeout;
|
|
4566
|
+
}
|
|
4567
|
+
static TYPE = 2 /* DeliveryTimeout */;
|
|
4568
|
+
toKeyValuePair() {
|
|
4569
|
+
return KeyValuePair.tryNewVarInt(_DeliveryTimeout.TYPE, this.objectTimeout);
|
|
4570
|
+
}
|
|
4571
|
+
static fromKeyValuePair(pair) {
|
|
4572
|
+
if (Number(pair.typeValue) !== _DeliveryTimeout.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4573
|
+
return new _DeliveryTimeout(pair.value);
|
|
4574
|
+
}
|
|
4575
|
+
};
|
|
4576
|
+
|
|
4577
|
+
// src/model/parameter/version/max_cache_duration.ts
|
|
4578
|
+
var MaxCacheDuration = class _MaxCacheDuration {
|
|
4579
|
+
constructor(duration) {
|
|
4580
|
+
this.duration = duration;
|
|
4581
|
+
}
|
|
4582
|
+
static TYPE = 4 /* MaxCacheDuration */;
|
|
4583
|
+
toKeyValuePair() {
|
|
4584
|
+
return KeyValuePair.tryNewVarInt(_MaxCacheDuration.TYPE, this.duration);
|
|
4585
|
+
}
|
|
4586
|
+
static fromKeyValuePair(pair) {
|
|
4587
|
+
if (Number(pair.typeValue) !== _MaxCacheDuration.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4588
|
+
return new _MaxCacheDuration(pair.value);
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
|
|
4592
|
+
// src/model/parameter/version_parameter.ts
|
|
4593
|
+
exports.VersionSpecificParameter = void 0;
|
|
4594
|
+
((VersionSpecificParameter2) => {
|
|
4595
|
+
function fromKeyValuePair(pair) {
|
|
4596
|
+
return MaxCacheDuration.fromKeyValuePair(pair) || DeliveryTimeout.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair);
|
|
4597
|
+
}
|
|
4598
|
+
VersionSpecificParameter2.fromKeyValuePair = fromKeyValuePair;
|
|
4599
|
+
function toKeyValuePair(param) {
|
|
4600
|
+
return param.toKeyValuePair();
|
|
4601
|
+
}
|
|
4602
|
+
VersionSpecificParameter2.toKeyValuePair = toKeyValuePair;
|
|
4603
|
+
function isMaxCacheDuration(param) {
|
|
4604
|
+
return param instanceof MaxCacheDuration;
|
|
4605
|
+
}
|
|
4606
|
+
VersionSpecificParameter2.isMaxCacheDuration = isMaxCacheDuration;
|
|
4607
|
+
function isDeliveryTimeout(param) {
|
|
4608
|
+
return param instanceof DeliveryTimeout;
|
|
4609
|
+
}
|
|
4610
|
+
VersionSpecificParameter2.isDeliveryTimeout = isDeliveryTimeout;
|
|
4611
|
+
function isAuthorizationToken(param) {
|
|
4612
|
+
return param instanceof AuthorizationToken;
|
|
4613
|
+
}
|
|
4614
|
+
VersionSpecificParameter2.isAuthorizationToken = isAuthorizationToken;
|
|
4615
|
+
})(exports.VersionSpecificParameter || (exports.VersionSpecificParameter = {}));
|
|
4616
|
+
var VersionSpecificParameters = class {
|
|
4617
|
+
kvps = [];
|
|
4618
|
+
addMaxCacheDuration(duration) {
|
|
4619
|
+
this.kvps.push(new MaxCacheDuration(BigInt(duration)).toKeyValuePair());
|
|
4620
|
+
return this;
|
|
4621
|
+
}
|
|
4622
|
+
addDeliveryTimeout(timeout) {
|
|
4623
|
+
this.kvps.push(new DeliveryTimeout(BigInt(timeout)).toKeyValuePair());
|
|
4624
|
+
return this;
|
|
4625
|
+
}
|
|
4626
|
+
addAuthorizationToken(auth) {
|
|
4627
|
+
this.kvps.push(auth.toKeyValuePair());
|
|
4628
|
+
return this;
|
|
4629
|
+
}
|
|
4630
|
+
addRaw(pair) {
|
|
4631
|
+
this.kvps.push(pair);
|
|
4632
|
+
return this;
|
|
4633
|
+
}
|
|
4634
|
+
build() {
|
|
4635
|
+
return this.kvps;
|
|
4636
|
+
}
|
|
4637
|
+
static fromKeyValuePairs(kvps) {
|
|
4638
|
+
const result = [];
|
|
4639
|
+
for (const kvp of kvps) {
|
|
4640
|
+
const parsed = MaxCacheDuration.fromKeyValuePair(kvp) || DeliveryTimeout.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp);
|
|
4641
|
+
if (parsed) result.push(parsed);
|
|
4642
|
+
}
|
|
4643
|
+
return result;
|
|
4644
|
+
}
|
|
4645
|
+
};
|
|
4646
|
+
|
|
4647
|
+
exports.AudioLevel = AudioLevel;
|
|
4648
|
+
exports.AuthorizationToken = AuthorizationToken;
|
|
4649
|
+
exports.BaseByteBuffer = BaseByteBuffer12;
|
|
4650
|
+
exports.ByteBuffer = ByteBuffer;
|
|
4651
|
+
exports.CaptureTimestamp = CaptureTimestamp;
|
|
4652
|
+
exports.CastingError = CastingError;
|
|
4653
|
+
exports.ClientSetup = ClientSetup;
|
|
4654
|
+
exports.CommonType = CommonType;
|
|
4655
|
+
exports.ControlMessageType = ControlMessageType;
|
|
4656
|
+
exports.DRAFT_14 = DRAFT_14;
|
|
4657
|
+
exports.DatagramObject = DatagramObject;
|
|
4658
|
+
exports.DatagramStatus = DatagramStatus;
|
|
4659
|
+
exports.DeliveryTimeout = DeliveryTimeout;
|
|
4660
|
+
exports.ExtensionHeaders = ExtensionHeaders;
|
|
4661
|
+
exports.Fetch = Fetch;
|
|
4662
|
+
exports.FetchCancel = FetchCancel;
|
|
4663
|
+
exports.FetchError = FetchError;
|
|
4664
|
+
exports.FetchErrorCode = FetchErrorCode;
|
|
4665
|
+
exports.FetchHeader = FetchHeader;
|
|
4666
|
+
exports.FetchObject = FetchObject;
|
|
4667
|
+
exports.FetchOk = FetchOk;
|
|
4668
|
+
exports.FetchType = FetchType;
|
|
4669
|
+
exports.FilterType = FilterType;
|
|
4670
|
+
exports.FrozenByteBuffer = FrozenByteBuffer5;
|
|
4671
|
+
exports.FullTrackName = FullTrackName;
|
|
4672
|
+
exports.GoAway = GoAway;
|
|
4673
|
+
exports.GroupOrder = GroupOrder;
|
|
4674
|
+
exports.InternalError = InternalError;
|
|
4675
|
+
exports.InvalidTypeError = InvalidTypeError;
|
|
4676
|
+
exports.InvalidUTF8Error = InvalidUTF8Error;
|
|
4677
|
+
exports.KeyValueFormattingError = KeyValueFormattingError;
|
|
4678
|
+
exports.KeyValuePair = KeyValuePair;
|
|
4679
|
+
exports.LOCHeaderExtensionId = LOCHeaderExtensionId;
|
|
4680
|
+
exports.LengthExceedsMaxError = LengthExceedsMaxError;
|
|
4681
|
+
exports.Location = Location;
|
|
4682
|
+
exports.MAX_FULL_TRACK_NAME_LENGTH = MAX_FULL_TRACK_NAME_LENGTH;
|
|
4683
|
+
exports.MAX_NAMESPACE_TUPLE_COUNT = MAX_NAMESPACE_TUPLE_COUNT;
|
|
4684
|
+
exports.MAX_REASON_PHRASE_LEN = MAX_REASON_PHRASE_LEN;
|
|
4685
|
+
exports.MOQtailError = MOQtailError;
|
|
4686
|
+
exports.MaxAuthTokenCacheSize = MaxAuthTokenCacheSize;
|
|
4687
|
+
exports.MaxCacheDuration = MaxCacheDuration;
|
|
4688
|
+
exports.MaxRequestId = MaxRequestId;
|
|
4689
|
+
exports.MaxRequestIdParameter = MaxRequestId2;
|
|
4690
|
+
exports.MoqtObject = MoqtObject;
|
|
4691
|
+
exports.NotEnoughBytesError = NotEnoughBytesError;
|
|
4692
|
+
exports.Path = Path;
|
|
4693
|
+
exports.ProtocolViolationError = ProtocolViolationError;
|
|
4694
|
+
exports.Publish = Publish;
|
|
4695
|
+
exports.PublishDone = PublishDone;
|
|
4696
|
+
exports.PublishDoneStatusCode = PublishDoneStatusCode;
|
|
4697
|
+
exports.PublishError = PublishError;
|
|
4698
|
+
exports.PublishErrorCode = PublishErrorCode;
|
|
4699
|
+
exports.PublishNamespace = PublishNamespace;
|
|
4700
|
+
exports.PublishNamespaceCancel = PublishNamespaceCancel;
|
|
4701
|
+
exports.PublishNamespaceDone = PublishNamespaceDone;
|
|
4702
|
+
exports.PublishNamespaceError = PublishNamespaceError;
|
|
4703
|
+
exports.PublishNamespaceErrorCode = PublishNamespaceErrorCode;
|
|
4704
|
+
exports.PublishNamespaceOk = PublishNamespaceOk;
|
|
4705
|
+
exports.PublishOk = PublishOk;
|
|
4706
|
+
exports.ReasonPhrase = ReasonPhrase;
|
|
4707
|
+
exports.RequestIdError = RequestIdError;
|
|
4708
|
+
exports.RequestIdMap = RequestIdMap;
|
|
4709
|
+
exports.RequestsBlocked = RequestsBlocked;
|
|
4710
|
+
exports.ServerSetup = ServerSetup;
|
|
4711
|
+
exports.SetupParameterType = SetupParameterType;
|
|
4712
|
+
exports.SetupParameters = SetupParameters;
|
|
4713
|
+
exports.SubgroupHeader = SubgroupHeader;
|
|
4714
|
+
exports.SubgroupObject = SubgroupObject;
|
|
4715
|
+
exports.Subscribe = Subscribe;
|
|
4716
|
+
exports.SubscribeError = SubscribeError;
|
|
4717
|
+
exports.SubscribeErrorCode = SubscribeErrorCode;
|
|
4718
|
+
exports.SubscribeNamespace = SubscribeNamespace;
|
|
4719
|
+
exports.SubscribeNamespaceError = SubscribeNamespaceError;
|
|
4720
|
+
exports.SubscribeNamespaceErrorCode = SubscribeNamespaceErrorCode;
|
|
4721
|
+
exports.SubscribeNamespaceOk = SubscribeNamespaceOk;
|
|
4722
|
+
exports.SubscribeOk = SubscribeOk;
|
|
4723
|
+
exports.SubscribeUpdate = SubscribeUpdate;
|
|
4724
|
+
exports.Switch = Switch;
|
|
4725
|
+
exports.TerminationError = TerminationError;
|
|
4726
|
+
exports.TimeoutError = TimeoutError;
|
|
4727
|
+
exports.TokenAliasType = TokenAliasType;
|
|
4728
|
+
exports.TrackNameError = TrackNameError;
|
|
4729
|
+
exports.TrackStatus = TrackStatus;
|
|
4730
|
+
exports.TrackStatusCode = TrackStatusCode;
|
|
4731
|
+
exports.TrackStatusError = TrackStatusError;
|
|
4732
|
+
exports.TrackStatusOk = TrackStatusOk;
|
|
4733
|
+
exports.Tuple = Tuple;
|
|
4734
|
+
exports.TupleField = TupleField;
|
|
4735
|
+
exports.Unsubscribe = Unsubscribe;
|
|
4736
|
+
exports.UnsubscribeNamespace = UnsubscribeNamespace;
|
|
4737
|
+
exports.VarIntOverflowError = VarIntOverflowError;
|
|
4738
|
+
exports.VersionSpecificParameterType = VersionSpecificParameterType;
|
|
4739
|
+
exports.VersionSpecificParameters = VersionSpecificParameters;
|
|
4740
|
+
exports.VideoConfig = VideoConfig;
|
|
4741
|
+
exports.VideoFrameMarking = VideoFrameMarking;
|
|
4742
|
+
exports.commonTypeFromNumber = commonTypeFromNumber;
|
|
4743
|
+
exports.controlMessageTypeFromBigInt = controlMessageTypeFromBigInt;
|
|
4744
|
+
exports.fetchErrorCodeFromBigInt = fetchErrorCodeFromBigInt;
|
|
4745
|
+
exports.fetchTypeFromBigInt = fetchTypeFromBigInt;
|
|
4746
|
+
exports.filterTypeFromBigInt = filterTypeFromBigInt;
|
|
4747
|
+
exports.groupOrderFromNumber = groupOrderFromNumber;
|
|
4748
|
+
exports.isBytes = isBytes;
|
|
4749
|
+
exports.isVarInt = isVarInt;
|
|
4750
|
+
exports.locHeaderExtensionIdFromNumber = locHeaderExtensionIdFromNumber;
|
|
4751
|
+
exports.publishDoneStatusCodeFromBigInt = publishDoneStatusCodeFromBigInt;
|
|
4752
|
+
exports.publishErrorCodeFromBigInt = publishErrorCodeFromBigInt;
|
|
4753
|
+
exports.publishNamespaceErrorCodeFromBigInt = publishNamespaceErrorCodeFromBigInt;
|
|
4754
|
+
exports.setupParameterTypeFromNumber = setupParameterTypeFromNumber;
|
|
4755
|
+
exports.subscribeErrorCodeFromBigInt = subscribeErrorCodeFromBigInt;
|
|
4756
|
+
exports.subscribeNamespaceErrorCodeFromBigInt = subscribeNamespaceErrorCodeFromBigInt;
|
|
4757
|
+
exports.tokenAliasTypeFromNumber = tokenAliasTypeFromNumber;
|
|
4758
|
+
exports.trackStatusCodeFromBigInt = trackStatusCodeFromBigInt;
|
|
4759
|
+
exports.versionSpecificParameterTypeFromNumber = versionSpecificParameterTypeFromNumber;
|