moqtail 0.13.0 → 0.14.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 +43 -0
- package/dist/{client-BzncAN14.mjs → client-BW1agDFV.mjs} +1268 -686
- package/dist/{client-DahXR3l4.cjs → client-Z7egUKTO.cjs} +1240 -628
- package/dist/client.cjs +6 -1
- package/dist/client.d.cts +583 -331
- package/dist/client.d.mts +583 -331
- package/dist/client.mjs +2 -2
- package/dist/{index-C8pNnaj0.d.cts → index-DBbxKcc1.d.cts} +594 -357
- package/dist/{index-C8pNnaj0.d.mts → index-DBbxKcc1.d.mts} +594 -357
- package/dist/index.cjs +30 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/model.cjs +1139 -489
- package/dist/model.d.cts +2 -2
- package/dist/model.d.mts +2 -2
- package/dist/model.mjs +1116 -475
- package/package.json +1 -1
package/dist/model.mjs
CHANGED
|
@@ -213,7 +213,7 @@ var TerminationError = class extends MOQtailError {
|
|
|
213
213
|
* limitations under the License.
|
|
214
214
|
*/
|
|
215
215
|
const MAX_VALUE_LENGTH = 2 ** 16 - 1;
|
|
216
|
-
const MAX_U64 = 2n ** 64n - 1n;
|
|
216
|
+
const MAX_U64$2 = 2n ** 64n - 1n;
|
|
217
217
|
/**
|
|
218
218
|
* @public
|
|
219
219
|
* Represents a key-value pair for MOQT protocol parameters.
|
|
@@ -222,6 +222,8 @@ const MAX_U64 = 2n ** 64n - 1n;
|
|
|
222
222
|
* - If `typeValue` is **odd**, the value is a binary blob (`Uint8Array`) with a maximum length of 65535 bytes.
|
|
223
223
|
*
|
|
224
224
|
* Use {@link KeyValuePair.tryNewVarInt} for varint pairs and {@link KeyValuePair.tryNewBytes} for blob pairs.
|
|
225
|
+
* A Type whose own namespace fixes the value encoding overrides the parity rule; see
|
|
226
|
+
* {@link KeyValuePair.newBytes}.
|
|
225
227
|
*/
|
|
226
228
|
var KeyValuePair = class KeyValuePair {
|
|
227
229
|
/**
|
|
@@ -260,6 +262,17 @@ var KeyValuePair = class KeyValuePair {
|
|
|
260
262
|
return new KeyValuePair(tv, v);
|
|
261
263
|
}
|
|
262
264
|
/**
|
|
265
|
+
* Creates a varint KeyValuePair for a Type whose namespace defines a numeric value
|
|
266
|
+
* regardless of parity. Prefer {@link KeyValuePair.tryNewVarInt}.
|
|
267
|
+
* @param typeValue - The key/type identifier; parity is not checked.
|
|
268
|
+
* @param value - The varint value.
|
|
269
|
+
*/
|
|
270
|
+
static newVarInt(typeValue, value) {
|
|
271
|
+
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
272
|
+
const v = typeof value === "number" ? BigInt(value) : value;
|
|
273
|
+
return new KeyValuePair(tv, v);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
263
276
|
* Creates a new blob KeyValuePair.
|
|
264
277
|
* @param typeValue - Must be odd.
|
|
265
278
|
* @param value - The binary blob value.
|
|
@@ -270,8 +283,19 @@ var KeyValuePair = class KeyValuePair {
|
|
|
270
283
|
static tryNewBytes(typeValue, value) {
|
|
271
284
|
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
272
285
|
if (tv % 2n === 0n) throw new KeyValueFormattingError("KeyValuePair.tryNewBytes");
|
|
286
|
+
return KeyValuePair.newBytes(tv, value);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Creates a blob KeyValuePair for a Type whose namespace defines a byte-string
|
|
290
|
+
* value regardless of parity. Prefer {@link KeyValuePair.tryNewBytes}.
|
|
291
|
+
* @param typeValue - The key/type identifier; parity is not checked.
|
|
292
|
+
* @param value - The binary blob value.
|
|
293
|
+
* @throws LengthExceedsMaxError if value length exceeds 65535 bytes.
|
|
294
|
+
*/
|
|
295
|
+
static newBytes(typeValue, value) {
|
|
296
|
+
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
273
297
|
const len = value.length;
|
|
274
|
-
if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.
|
|
298
|
+
if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.newBytes", MAX_VALUE_LENGTH, len);
|
|
275
299
|
return new KeyValuePair(tv, value);
|
|
276
300
|
}
|
|
277
301
|
/**
|
|
@@ -320,7 +344,7 @@ var KeyValuePair = class KeyValuePair {
|
|
|
320
344
|
static deserializeDelta(buf, prevType) {
|
|
321
345
|
const deltaType = buf.getVI();
|
|
322
346
|
const typeValue = prevType + deltaType;
|
|
323
|
-
if (typeValue > MAX_U64) throw new ProtocolViolationError("KeyValuePair.deserializeDelta", `previous type ${prevType} plus delta type ${deltaType} exceeds 2^64 - 1`);
|
|
347
|
+
if (typeValue > MAX_U64$2) throw new ProtocolViolationError("KeyValuePair.deserializeDelta", `previous type ${prevType} plus delta type ${deltaType} exceeds 2^64 - 1`);
|
|
324
348
|
return KeyValuePair.deserializeValue(buf, typeValue);
|
|
325
349
|
}
|
|
326
350
|
/**
|
|
@@ -334,12 +358,20 @@ var KeyValuePair = class KeyValuePair {
|
|
|
334
358
|
if (typeValue % 2n === 0n) {
|
|
335
359
|
const value = buf.getVI();
|
|
336
360
|
return new KeyValuePair(typeValue, value);
|
|
337
|
-
} else {
|
|
338
|
-
const len = buf.getNumberVI();
|
|
339
|
-
if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.deserialize", MAX_VALUE_LENGTH, len);
|
|
340
|
-
const value = buf.getBytes(len);
|
|
341
|
-
return new KeyValuePair(typeValue, value);
|
|
342
361
|
}
|
|
362
|
+
return KeyValuePair.deserializeBytesValue(buf, typeValue);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Reads a length-prefixed byte-string Value, independent of Type parity.
|
|
366
|
+
* @param buf - The buffer to read from.
|
|
367
|
+
* @param typeValue - The already-decoded Type.
|
|
368
|
+
* @throws LengthExceedsMaxError if the length exceeds 65535 bytes.
|
|
369
|
+
*/
|
|
370
|
+
static deserializeBytesValue(buf, typeValue) {
|
|
371
|
+
const len = buf.getNumberVI();
|
|
372
|
+
if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.deserializeBytesValue", MAX_VALUE_LENGTH, len);
|
|
373
|
+
const value = buf.getBytes(len);
|
|
374
|
+
return new KeyValuePair(typeValue, value);
|
|
343
375
|
}
|
|
344
376
|
/**
|
|
345
377
|
* Checks if this pair is equal to another.
|
|
@@ -402,20 +434,20 @@ function deserializeKvpListUntilEmpty(buf) {
|
|
|
402
434
|
return items;
|
|
403
435
|
}
|
|
404
436
|
/**
|
|
405
|
-
* Checks if the KeyValuePair
|
|
437
|
+
* Checks if the KeyValuePair carries a varint value.
|
|
406
438
|
* @param pair - The KeyValuePair to check.
|
|
407
439
|
* @returns True if value is a varint.
|
|
408
440
|
*/
|
|
409
441
|
function isVarInt(pair) {
|
|
410
|
-
return pair.
|
|
442
|
+
return typeof pair.value === "bigint";
|
|
411
443
|
}
|
|
412
444
|
/**
|
|
413
|
-
* Checks if the KeyValuePair
|
|
445
|
+
* Checks if the KeyValuePair carries a blob value.
|
|
414
446
|
* @param pair - The KeyValuePair to check.
|
|
415
447
|
* @returns True if value is a Uint8Array.
|
|
416
448
|
*/
|
|
417
449
|
function isBytes(pair) {
|
|
418
|
-
return pair.
|
|
450
|
+
return pair.value instanceof Uint8Array;
|
|
419
451
|
}
|
|
420
452
|
//#endregion
|
|
421
453
|
//#region src/model/common/location.ts
|
|
@@ -811,12 +843,12 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
|
|
|
811
843
|
TerminationCode[TerminationCode["DATA_STREAM_TIMEOUT"] = 18] = "DATA_STREAM_TIMEOUT";
|
|
812
844
|
TerminationCode[TerminationCode["AUTH_TOKEN_CACHE_OVERFLOW"] = 19] = "AUTH_TOKEN_CACHE_OVERFLOW";
|
|
813
845
|
TerminationCode[TerminationCode["DUPLICATE_AUTH_TOKEN_ALIAS"] = 20] = "DUPLICATE_AUTH_TOKEN_ALIAS";
|
|
814
|
-
TerminationCode[TerminationCode["VERSION_NEGOTIATION_FAILED"] = 21] = "VERSION_NEGOTIATION_FAILED";
|
|
815
846
|
TerminationCode[TerminationCode["MALFORMED_AUTH_TOKEN"] = 22] = "MALFORMED_AUTH_TOKEN";
|
|
816
847
|
TerminationCode[TerminationCode["UNKNOWN_AUTH_TOKEN_ALIAS"] = 23] = "UNKNOWN_AUTH_TOKEN_ALIAS";
|
|
817
848
|
TerminationCode[TerminationCode["EXPIRED_AUTH_TOKEN"] = 24] = "EXPIRED_AUTH_TOKEN";
|
|
818
849
|
TerminationCode[TerminationCode["INVALID_AUTHORITY"] = 25] = "INVALID_AUTHORITY";
|
|
819
850
|
TerminationCode[TerminationCode["MALFORMED_AUTHORITY"] = 26] = "MALFORMED_AUTHORITY";
|
|
851
|
+
TerminationCode[TerminationCode["TOO_MANY_REQUEST_UPDATES"] = 27] = "TOO_MANY_REQUEST_UPDATES";
|
|
820
852
|
return TerminationCode;
|
|
821
853
|
}({});
|
|
822
854
|
(function(_TerminationCode) {
|
|
@@ -836,12 +868,12 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
|
|
|
836
868
|
case 18: return 18;
|
|
837
869
|
case 19: return 19;
|
|
838
870
|
case 20: return 20;
|
|
839
|
-
case 21: return 21;
|
|
840
871
|
case 22: return 22;
|
|
841
872
|
case 23: return 23;
|
|
842
873
|
case 24: return 24;
|
|
843
874
|
case 25: return 25;
|
|
844
875
|
case 26: return 26;
|
|
876
|
+
case 27: return 27;
|
|
845
877
|
default: throw new InvalidTypeError("TerminationCode.tryFrom", `Unknown termination code: ${code}`);
|
|
846
878
|
}
|
|
847
879
|
}
|
|
@@ -866,8 +898,7 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
|
|
|
866
898
|
*/
|
|
867
899
|
/**
|
|
868
900
|
* @public
|
|
869
|
-
* Codes carried when resetting a request stream or sending STOP_SENDING on one
|
|
870
|
-
* draft-18 §3.3.3.
|
|
901
|
+
* Codes carried when resetting a request stream or sending STOP_SENDING on one.
|
|
871
902
|
*
|
|
872
903
|
* A separate registry from {@link (RequestErrorCode:enum)}, which disagrees with it on
|
|
873
904
|
* the same names: `GOING_AWAY` is `0x4` here but `0x6` there.
|
|
@@ -922,7 +953,7 @@ let StreamResetCode = /* @__PURE__ */ function(StreamResetCode) {
|
|
|
922
953
|
*/
|
|
923
954
|
/**
|
|
924
955
|
* @public
|
|
925
|
-
* Object datagram types for MOQT objects
|
|
956
|
+
* Object datagram types for MOQT objects.
|
|
926
957
|
*
|
|
927
958
|
* Type bit layout (form 0b00X0XXXX):
|
|
928
959
|
* - Bit 0 (0x01): PROPERTIES - Properties field present
|
|
@@ -1226,7 +1257,7 @@ let ObjectStatus = /* @__PURE__ */ function(ObjectStatus) {
|
|
|
1226
1257
|
* limitations under the License.
|
|
1227
1258
|
*/
|
|
1228
1259
|
/**
|
|
1229
|
-
* Represents a unified OBJECT_DATAGRAM message
|
|
1260
|
+
* Represents a unified OBJECT_DATAGRAM message.
|
|
1230
1261
|
*
|
|
1231
1262
|
* Type bit layout (form 0b00X0XXXX):
|
|
1232
1263
|
* - Bit 0 (0x01): PROPERTIES
|
|
@@ -1356,53 +1387,6 @@ var FetchHeader = class FetchHeader {
|
|
|
1356
1387
|
}
|
|
1357
1388
|
};
|
|
1358
1389
|
//#endregion
|
|
1359
|
-
//#region src/model/common/grease.ts
|
|
1360
|
-
/**
|
|
1361
|
-
* Copyright 2026 The MOQtail Authors
|
|
1362
|
-
*
|
|
1363
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1364
|
-
* you may not use this file except in compliance with the License.
|
|
1365
|
-
* You may obtain a copy of the License at
|
|
1366
|
-
*
|
|
1367
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1368
|
-
*
|
|
1369
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1370
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1371
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1372
|
-
* See the License for the specific language governing permissions and
|
|
1373
|
-
* limitations under the License.
|
|
1374
|
-
*/
|
|
1375
|
-
/**
|
|
1376
|
-
* GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
|
|
1377
|
-
* several registries (Setup Options, Properties, error codes) so peers can emit them
|
|
1378
|
-
* to exercise unknown-value handling. Receivers treat them like any other unknown
|
|
1379
|
-
* value: ignore, never fatal.
|
|
1380
|
-
*/
|
|
1381
|
-
/** Step between successive GREASE values. */
|
|
1382
|
-
const GREASE_STEP = 127n;
|
|
1383
|
-
/** The smallest GREASE value (N = 0). */
|
|
1384
|
-
const GREASE_BASE = 157n;
|
|
1385
|
-
/** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
|
|
1386
|
-
const GREASE_MAX = 4611686018427387870n;
|
|
1387
|
-
/**
|
|
1388
|
-
* @public
|
|
1389
|
-
* True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
|
|
1390
|
-
* non-negative `N`.
|
|
1391
|
-
*/
|
|
1392
|
-
function isGrease(value) {
|
|
1393
|
-
const v = BigInt(value);
|
|
1394
|
-
return v >= 157n && (v - 157n) % 127n === 0n;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* @public
|
|
1398
|
-
* The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
|
|
1399
|
-
* varint can carry (the pattern is capped at `0x3fffffffffffffde`).
|
|
1400
|
-
*/
|
|
1401
|
-
function greaseValue(n) {
|
|
1402
|
-
const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
|
|
1403
|
-
return value > GREASE_MAX ? void 0 : value;
|
|
1404
|
-
}
|
|
1405
|
-
//#endregion
|
|
1406
1390
|
//#region src/model/control/constant.ts
|
|
1407
1391
|
/**
|
|
1408
1392
|
* Copyright 2025 The MOQtail Authors
|
|
@@ -1422,21 +1406,10 @@ function greaseValue(n) {
|
|
|
1422
1406
|
/**
|
|
1423
1407
|
* Protocol string array exchanged in wt-available-protocols header
|
|
1424
1408
|
*/
|
|
1425
|
-
const SUPPORTED_VERSIONS = ["moqt-
|
|
1409
|
+
const SUPPORTED_VERSIONS = ["moqt-22"];
|
|
1426
1410
|
/**
|
|
1427
1411
|
* @public
|
|
1428
|
-
* Control message types
|
|
1429
|
-
*
|
|
1430
|
-
* The comment on each member is the Stream column: `Control` is the control stream
|
|
1431
|
-
* (§3.3), `Request` a bidirectional request stream, and `First` means the message MUST
|
|
1432
|
-
* be the first on a new request stream.
|
|
1433
|
-
*
|
|
1434
|
-
* Table 5 reserves `0x01` (SETUP for version 00), `0x40`/`0x41` (CLIENT_SETUP /
|
|
1435
|
-
* SERVER_SETUP for versions 10 and below) and `0x20`/`0x21` (CLIENT_SETUP /
|
|
1436
|
-
* SERVER_SETUP for versions 16 and below — folded into Setup by #256). All five stay
|
|
1437
|
-
* in the enum as documentation, but `tryFrom` rejects every RESERVED codepoint, which
|
|
1438
|
-
* is what §10 requires — an endpoint receiving an unknown message type MUST close the
|
|
1439
|
-
* session.
|
|
1412
|
+
* Control message types.
|
|
1440
1413
|
*/
|
|
1441
1414
|
let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
|
|
1442
1415
|
ControlMessageType[ControlMessageType["ReservedSetupV00"] = 1] = "ReservedSetupV00";
|
|
@@ -1462,8 +1435,7 @@ let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
|
|
|
1462
1435
|
ControlMessageType[ControlMessageType["SubscribeTracks"] = 81] = "SubscribeTracks";
|
|
1463
1436
|
ControlMessageType[ControlMessageType["Publish"] = 29] = "Publish";
|
|
1464
1437
|
ControlMessageType[ControlMessageType["PublishOk"] = 30] = "PublishOk";
|
|
1465
|
-
ControlMessageType[ControlMessageType["
|
|
1466
|
-
ControlMessageType[ControlMessageType["Switch"] = 34] = "Switch";
|
|
1438
|
+
ControlMessageType[ControlMessageType["PublishSkipped"] = 15] = "PublishSkipped";
|
|
1467
1439
|
return ControlMessageType;
|
|
1468
1440
|
}({});
|
|
1469
1441
|
(function(_ControlMessageType) {
|
|
@@ -1520,48 +1492,45 @@ let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
|
|
|
1520
1492
|
})(ControlMessageType || (ControlMessageType = {}));
|
|
1521
1493
|
/**
|
|
1522
1494
|
* @public
|
|
1523
|
-
*
|
|
1524
|
-
*/
|
|
1525
|
-
let
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1495
|
+
* Which fields of a LOCATION_FILTER follow its type, and how they are read.
|
|
1496
|
+
*/
|
|
1497
|
+
let LocationFilterType = /* @__PURE__ */ function(LocationFilterType) {
|
|
1498
|
+
/** No filter: every Object passes. */
|
|
1499
|
+
LocationFilterType[LocationFilterType["None"] = 0] = "None";
|
|
1500
|
+
/** Starts StartGroup groups before the Next Group. */
|
|
1501
|
+
LocationFilterType[LocationFilterType["RelativeStart"] = 1] = "RelativeStart";
|
|
1502
|
+
LocationFilterType[LocationFilterType["AbsoluteStart"] = 2] = "AbsoluteStart";
|
|
1503
|
+
/** Ends with the last Object of the End Group. */
|
|
1504
|
+
LocationFilterType[LocationFilterType["AbsoluteStartGroupEnd"] = 3] = "AbsoluteStartGroupEnd";
|
|
1505
|
+
/** Ends with End Object of the End Group. */
|
|
1506
|
+
LocationFilterType[LocationFilterType["AbsoluteRange"] = 4] = "AbsoluteRange";
|
|
1507
|
+
/** Starts at the Object after the Largest Object. */
|
|
1508
|
+
LocationFilterType[LocationFilterType["NextObject"] = 5] = "NextObject";
|
|
1509
|
+
return LocationFilterType;
|
|
1531
1510
|
}({});
|
|
1532
|
-
(function(
|
|
1511
|
+
(function(_LocationFilterType) {
|
|
1533
1512
|
function tryFrom(v) {
|
|
1534
1513
|
switch (v) {
|
|
1514
|
+
case 0n: return 0;
|
|
1535
1515
|
case 1n: return 1;
|
|
1536
1516
|
case 2n: return 2;
|
|
1537
1517
|
case 3n: return 3;
|
|
1538
1518
|
case 4n: return 4;
|
|
1539
|
-
|
|
1519
|
+
case 5n: return 5;
|
|
1520
|
+
default: throw new InvalidEnumValue("LocationFilterType.tryFrom", v);
|
|
1540
1521
|
}
|
|
1541
1522
|
}
|
|
1542
|
-
|
|
1543
|
-
})(
|
|
1523
|
+
_LocationFilterType.tryFrom = tryFrom;
|
|
1524
|
+
})(LocationFilterType || (LocationFilterType = {}));
|
|
1544
1525
|
/**
|
|
1545
1526
|
* @public
|
|
1546
|
-
*
|
|
1527
|
+
* Switch modes for subscription switching requests.
|
|
1547
1528
|
*/
|
|
1548
|
-
let
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
return FetchType;
|
|
1529
|
+
let SwitchMode = /* @__PURE__ */ function(SwitchMode) {
|
|
1530
|
+
SwitchMode[SwitchMode["Hard"] = 0] = "Hard";
|
|
1531
|
+
SwitchMode[SwitchMode["Soft"] = 1] = "Soft";
|
|
1532
|
+
return SwitchMode;
|
|
1553
1533
|
}({});
|
|
1554
|
-
(function(_FetchType) {
|
|
1555
|
-
function tryFrom(v) {
|
|
1556
|
-
switch (v) {
|
|
1557
|
-
case 1n: return 1;
|
|
1558
|
-
case 2n: return 2;
|
|
1559
|
-
case 3n: return 3;
|
|
1560
|
-
default: throw new InvalidEnumValue("FetchType.tryFrom", v);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
_FetchType.tryFrom = tryFrom;
|
|
1564
|
-
})(FetchType || (FetchType = {}));
|
|
1565
1534
|
/**
|
|
1566
1535
|
* @public
|
|
1567
1536
|
* Group ordering options for object delivery.
|
|
@@ -1616,7 +1585,6 @@ let PublishDoneStatusCode = /* @__PURE__ */ function(PublishDoneStatusCode) {
|
|
|
1616
1585
|
PublishDoneStatusCode[PublishDoneStatusCode["InternalError"] = 0] = "InternalError";
|
|
1617
1586
|
PublishDoneStatusCode[PublishDoneStatusCode["Unauthorized"] = 1] = "Unauthorized";
|
|
1618
1587
|
PublishDoneStatusCode[PublishDoneStatusCode["TrackEnded"] = 2] = "TrackEnded";
|
|
1619
|
-
PublishDoneStatusCode[PublishDoneStatusCode["SubscriptionEnded"] = 3] = "SubscriptionEnded";
|
|
1620
1588
|
PublishDoneStatusCode[PublishDoneStatusCode["GoingAway"] = 4] = "GoingAway";
|
|
1621
1589
|
PublishDoneStatusCode[PublishDoneStatusCode["TooFarBehind"] = 5] = "TooFarBehind";
|
|
1622
1590
|
PublishDoneStatusCode[PublishDoneStatusCode["Expired"] = 6] = "Expired";
|
|
@@ -1631,7 +1599,6 @@ let PublishDoneStatusCode = /* @__PURE__ */ function(PublishDoneStatusCode) {
|
|
|
1631
1599
|
case 0n: return 0;
|
|
1632
1600
|
case 1n: return 1;
|
|
1633
1601
|
case 2n: return 2;
|
|
1634
|
-
case 3n: return 3;
|
|
1635
1602
|
case 4n: return 4;
|
|
1636
1603
|
case 5n: return 5;
|
|
1637
1604
|
case 6n: return 6;
|
|
@@ -1670,13 +1637,14 @@ let RequestErrorCode = /* @__PURE__ */ function(RequestErrorCode) {
|
|
|
1670
1637
|
RequestErrorCode[RequestErrorCode["DoesNotExist"] = 16] = "DoesNotExist";
|
|
1671
1638
|
RequestErrorCode[RequestErrorCode["InvalidRange"] = 17] = "InvalidRange";
|
|
1672
1639
|
RequestErrorCode[RequestErrorCode["MalformedTrack"] = 18] = "MalformedTrack";
|
|
1673
|
-
RequestErrorCode[RequestErrorCode["DuplicateSubscription"] = 25] = "DuplicateSubscription";
|
|
1674
1640
|
RequestErrorCode[RequestErrorCode["Uninterested"] = 32] = "Uninterested";
|
|
1675
1641
|
RequestErrorCode[RequestErrorCode["PrefixOverlap"] = 48] = "PrefixOverlap";
|
|
1676
1642
|
RequestErrorCode[RequestErrorCode["NamespaceTooLarge"] = 49] = "NamespaceTooLarge";
|
|
1677
|
-
RequestErrorCode[RequestErrorCode["
|
|
1643
|
+
RequestErrorCode[RequestErrorCode["InvalidSwitch"] = 50] = "InvalidSwitch";
|
|
1678
1644
|
RequestErrorCode[RequestErrorCode["UnsupportedExtension"] = 51] = "UnsupportedExtension";
|
|
1679
1645
|
RequestErrorCode[RequestErrorCode["Redirect"] = 52] = "Redirect";
|
|
1646
|
+
RequestErrorCode[RequestErrorCode["ConflictingFilters"] = 53] = "ConflictingFilters";
|
|
1647
|
+
RequestErrorCode[RequestErrorCode["InvalidFilter"] = 54] = "InvalidFilter";
|
|
1680
1648
|
return RequestErrorCode;
|
|
1681
1649
|
}({});
|
|
1682
1650
|
(function(_RequestErrorCode) {
|
|
@@ -1693,13 +1661,14 @@ let RequestErrorCode = /* @__PURE__ */ function(RequestErrorCode) {
|
|
|
1693
1661
|
case 16n: return 16;
|
|
1694
1662
|
case 17n: return 17;
|
|
1695
1663
|
case 18n: return 18;
|
|
1696
|
-
case 25n: return 25;
|
|
1697
1664
|
case 32n: return 32;
|
|
1698
1665
|
case 48n: return 48;
|
|
1699
1666
|
case 49n: return 49;
|
|
1700
1667
|
case 50n: return 50;
|
|
1701
1668
|
case 51n: return 51;
|
|
1702
1669
|
case 52n: return 52;
|
|
1670
|
+
case 53n: return 53;
|
|
1671
|
+
case 54n: return 54;
|
|
1703
1672
|
default: throw new InvalidEnumValue("RequestErrorCode.tryFrom", v);
|
|
1704
1673
|
}
|
|
1705
1674
|
}
|
|
@@ -1953,7 +1922,7 @@ const MAX_FULL_TRACK_NAME_LENGTH = 4096;
|
|
|
1953
1922
|
* Fully-qualified track identifier = hierarchical namespace (tuple) + leaf name bytes.
|
|
1954
1923
|
*
|
|
1955
1924
|
* Constraints enforced (throws {@link TrackNameError}):
|
|
1956
|
-
* - Namespace tuple field count: 0 .. {@link MAX_NAMESPACE_TUPLE_COUNT} (
|
|
1925
|
+
* - Namespace tuple field count: 0 .. {@link MAX_NAMESPACE_TUPLE_COUNT} (an empty namespace is legal).
|
|
1957
1926
|
* - Total serialized length (namespace tuple + raw name bytes) less than or equals {@link MAX_FULL_TRACK_NAME_LENGTH} bytes.
|
|
1958
1927
|
*
|
|
1959
1928
|
* Namespace input may be:
|
|
@@ -2081,11 +2050,8 @@ function locPropertyIdFromNumber(value) {
|
|
|
2081
2050
|
}
|
|
2082
2051
|
/**
|
|
2083
2052
|
* @public
|
|
2084
|
-
* Registration-policy ranges for the Property Type space
|
|
2053
|
+
* Registration-policy ranges for the Property Type space.
|
|
2085
2054
|
*
|
|
2086
|
-
* §2.5 gives the 1-byte application-specific range as `0x38-0x3F`; that is stale text
|
|
2087
|
-
* from before draft-18's varint change, which made the 1-byte space `0x00-0x7F`.
|
|
2088
|
-
* §15.8 is the correct table and is what these constants follow.
|
|
2089
2055
|
*/
|
|
2090
2056
|
const PropertyRanges = {
|
|
2091
2057
|
/** Standards Action or IESG Approval (1-byte encoding). */
|
|
@@ -2350,6 +2316,53 @@ var LOCProperties = class {
|
|
|
2350
2316
|
}
|
|
2351
2317
|
};
|
|
2352
2318
|
//#endregion
|
|
2319
|
+
//#region src/model/common/grease.ts
|
|
2320
|
+
/**
|
|
2321
|
+
* Copyright 2026 The MOQtail Authors
|
|
2322
|
+
*
|
|
2323
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2324
|
+
* you may not use this file except in compliance with the License.
|
|
2325
|
+
* You may obtain a copy of the License at
|
|
2326
|
+
*
|
|
2327
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2328
|
+
*
|
|
2329
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2330
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2331
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2332
|
+
* See the License for the specific language governing permissions and
|
|
2333
|
+
* limitations under the License.
|
|
2334
|
+
*/
|
|
2335
|
+
/**
|
|
2336
|
+
* GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
|
|
2337
|
+
* several registries (Setup Options, Properties, error codes) so peers can emit them
|
|
2338
|
+
* to exercise unknown-value handling. Receivers treat them like any other unknown
|
|
2339
|
+
* value: ignore, never fatal.
|
|
2340
|
+
*/
|
|
2341
|
+
/** Step between successive GREASE values. */
|
|
2342
|
+
const GREASE_STEP = 127n;
|
|
2343
|
+
/** The smallest GREASE value (N = 0). */
|
|
2344
|
+
const GREASE_BASE = 157n;
|
|
2345
|
+
/** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
|
|
2346
|
+
const GREASE_MAX = 4611686018427387870n;
|
|
2347
|
+
/**
|
|
2348
|
+
* @public
|
|
2349
|
+
* True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
|
|
2350
|
+
* non-negative `N`.
|
|
2351
|
+
*/
|
|
2352
|
+
function isGrease(value) {
|
|
2353
|
+
const v = BigInt(value);
|
|
2354
|
+
return v >= 157n && (v - 157n) % 127n === 0n;
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* @public
|
|
2358
|
+
* The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
|
|
2359
|
+
* varint can carry (the pattern is capped at `0x3fffffffffffffde`).
|
|
2360
|
+
*/
|
|
2361
|
+
function greaseValue(n) {
|
|
2362
|
+
const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
|
|
2363
|
+
return value > GREASE_MAX ? void 0 : value;
|
|
2364
|
+
}
|
|
2365
|
+
//#endregion
|
|
2353
2366
|
//#region src/model/property/track_property.ts
|
|
2354
2367
|
/**
|
|
2355
2368
|
* Copyright 2026 The MOQtail Authors
|
|
@@ -2674,7 +2687,7 @@ var SubgroupObject = class SubgroupObject {
|
|
|
2674
2687
|
return new SubgroupObject(objectId, normalizeProperties(properties), null, payload);
|
|
2675
2688
|
}
|
|
2676
2689
|
serialize(previousObjectId) {
|
|
2677
|
-
let objectIdDelta = previousObjectId ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
|
|
2690
|
+
let objectIdDelta = previousObjectId !== void 0 ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
|
|
2678
2691
|
const buf = new ByteBuffer();
|
|
2679
2692
|
buf.putVI(objectIdDelta);
|
|
2680
2693
|
if (this.properties !== null) buf.putLengthPrefixedBytes(serializeKvpList(this.properties).toUint8Array());
|
|
@@ -2761,7 +2774,7 @@ var MoqtObject = class MoqtObject {
|
|
|
2761
2774
|
return new MoqtObject(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, objectStatus, properties, null);
|
|
2762
2775
|
}
|
|
2763
2776
|
/**
|
|
2764
|
-
* Create a MoqtObject from a Datagram
|
|
2777
|
+
* Create a MoqtObject from a Datagram.
|
|
2765
2778
|
* @param datagram - The received Datagram.
|
|
2766
2779
|
* @param fullTrackName - The resolved full track name.
|
|
2767
2780
|
* @param defaultPriority - The default publisher priority from the control message (used when DEFAULT_PRIORITY bit is set).
|
|
@@ -2788,7 +2801,7 @@ var MoqtObject = class MoqtObject {
|
|
|
2788
2801
|
return new MoqtObject(fullTrackName, new Location(groupId, subgroupObject.objectId), publisherPriority ?? 128, "Subgroup", subgroupId, subgroupObject.objectStatus || 0, subgroupObject.properties, subgroupObject.payload);
|
|
2789
2802
|
}
|
|
2790
2803
|
/**
|
|
2791
|
-
* Convert to Datagram for wire transmission
|
|
2804
|
+
* Convert to Datagram for wire transmission.
|
|
2792
2805
|
* Automatically creates a payload or status Datagram based on the object's state.
|
|
2793
2806
|
* @param trackAlias - The track alias to use.
|
|
2794
2807
|
* @param endOfGroup - Whether this is the last object in the group (only for payload datagrams).
|
|
@@ -3236,8 +3249,7 @@ var ByteBuffer = class extends BaseByteBuffer {
|
|
|
3236
3249
|
}
|
|
3237
3250
|
/**
|
|
3238
3251
|
/**
|
|
3239
|
-
* Encode a MOQT
|
|
3240
|
-
* See section 1.4.1 https://datatracker.ietf.org/doc/draft-ietf-moq-transport/
|
|
3252
|
+
* Encode a MOQT varint using the minimal length.
|
|
3241
3253
|
*/
|
|
3242
3254
|
putVI(v) {
|
|
3243
3255
|
const value = typeof v === "number" ? BigInt(v) : v;
|
|
@@ -3308,7 +3320,7 @@ var FrozenByteBuffer = class extends BaseByteBuffer {
|
|
|
3308
3320
|
}
|
|
3309
3321
|
};
|
|
3310
3322
|
//#endregion
|
|
3311
|
-
//#region src/model/control/
|
|
3323
|
+
//#region src/model/control/publish_skipped.ts
|
|
3312
3324
|
/**
|
|
3313
3325
|
* Copyright 2026 The MOQtail Authors
|
|
3314
3326
|
*
|
|
@@ -3326,15 +3338,13 @@ var FrozenByteBuffer = class extends BaseByteBuffer {
|
|
|
3326
3338
|
*/
|
|
3327
3339
|
/**
|
|
3328
3340
|
* @public
|
|
3329
|
-
*
|
|
3330
|
-
* would start a subscription to a track under a SUBSCRIBE_TRACKS namespace
|
|
3331
|
-
* is blocked by the peer's bidirectional stream limit. It MUST NOT send PUBLISH for
|
|
3332
|
-
* that track until the limit lifts (§10.20).
|
|
3341
|
+
* PUBLISH_SKIPPED (0xF): a publisher tells the peer it cannot send the PUBLISH that
|
|
3342
|
+
* would start a subscription to a track under a SUBSCRIBE_TRACKS namespace.
|
|
3333
3343
|
*
|
|
3334
3344
|
* Sent on the SUBSCRIBE_TRACKS response stream, so only the namespace suffix after that
|
|
3335
3345
|
* subscription's prefix is carried.
|
|
3336
3346
|
*/
|
|
3337
|
-
var
|
|
3347
|
+
var PublishSkipped = class PublishSkipped {
|
|
3338
3348
|
trackNamespaceSuffix;
|
|
3339
3349
|
trackName;
|
|
3340
3350
|
constructor(trackNamespaceSuffix, trackName) {
|
|
@@ -3351,7 +3361,7 @@ var PublishBlocked = class PublishBlocked {
|
|
|
3351
3361
|
payload.putTuple(this.trackNamespaceSuffix);
|
|
3352
3362
|
payload.putLengthPrefixedBytes(this.trackName);
|
|
3353
3363
|
const payloadBytes = payload.toUint8Array();
|
|
3354
|
-
if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("
|
|
3364
|
+
if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("PublishSkipped::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3355
3365
|
buf.putU16(payloadBytes.length);
|
|
3356
3366
|
buf.putBytes(payloadBytes);
|
|
3357
3367
|
return buf.freeze();
|
|
@@ -3359,10 +3369,135 @@ var PublishBlocked = class PublishBlocked {
|
|
|
3359
3369
|
static parsePayload(buf) {
|
|
3360
3370
|
const trackNamespaceSuffix = buf.getTuple();
|
|
3361
3371
|
const trackName = buf.getLengthPrefixedBytes();
|
|
3362
|
-
return new
|
|
3372
|
+
return new PublishSkipped(trackNamespaceSuffix, trackName);
|
|
3363
3373
|
}
|
|
3364
3374
|
};
|
|
3365
3375
|
//#endregion
|
|
3376
|
+
//#region src/model/parameter/constant.ts
|
|
3377
|
+
/**
|
|
3378
|
+
* Copyright 2026 The MOQtail Authors
|
|
3379
|
+
*
|
|
3380
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3381
|
+
* you may not use this file except in compliance with the License.
|
|
3382
|
+
* You may obtain a copy of the License at
|
|
3383
|
+
*
|
|
3384
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3385
|
+
*
|
|
3386
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3387
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3388
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3389
|
+
* See the License for the specific language governing permissions and
|
|
3390
|
+
* limitations under the License.
|
|
3391
|
+
*/
|
|
3392
|
+
let SetupOptionType = /* @__PURE__ */ function(SetupOptionType) {
|
|
3393
|
+
SetupOptionType[SetupOptionType["Path"] = 1] = "Path";
|
|
3394
|
+
SetupOptionType[SetupOptionType["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3395
|
+
SetupOptionType[SetupOptionType["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
|
|
3396
|
+
/** Raw-QUIC only. Client-only; MUST NOT be sent over WebTransport. */
|
|
3397
|
+
SetupOptionType[SetupOptionType["Authority"] = 5] = "Authority";
|
|
3398
|
+
SetupOptionType[SetupOptionType["MaxFilterRanges"] = 6] = "MaxFilterRanges";
|
|
3399
|
+
SetupOptionType[SetupOptionType["MoqtImplementation"] = 7] = "MoqtImplementation";
|
|
3400
|
+
SetupOptionType[SetupOptionType["MaxRequestUpdates"] = 8] = "MaxRequestUpdates";
|
|
3401
|
+
/**
|
|
3402
|
+
* PROVISIONAL: sender-side track switching is not an adopted extension, so this
|
|
3403
|
+
* codepoint is absent from the registry the conformance fixture tracks. It sits in the
|
|
3404
|
+
* 0x07-0x7F range of this space, which that registry leaves free.
|
|
3405
|
+
*/
|
|
3406
|
+
SetupOptionType[SetupOptionType["SstsAlgorithms"] = 9] = "SstsAlgorithms";
|
|
3407
|
+
return SetupOptionType;
|
|
3408
|
+
}({});
|
|
3409
|
+
function setupOptionTypeFromNumber(value) {
|
|
3410
|
+
switch (value) {
|
|
3411
|
+
case 1: return 1;
|
|
3412
|
+
case 3: return 3;
|
|
3413
|
+
case 4: return 4;
|
|
3414
|
+
case 5: return 5;
|
|
3415
|
+
case 6: return 6;
|
|
3416
|
+
case 7: return 7;
|
|
3417
|
+
case 8: return 8;
|
|
3418
|
+
case 9: return 9;
|
|
3419
|
+
default: throw new InvalidTypeError("setupOptionTypeFromNumber", `Invalid setup option type: ${value}`);
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
let MessageParameterType = /* @__PURE__ */ function(MessageParameterType) {
|
|
3423
|
+
MessageParameterType[MessageParameterType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
|
|
3424
|
+
MessageParameterType[MessageParameterType["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3425
|
+
MessageParameterType[MessageParameterType["RendezvousTimeout"] = 4] = "RendezvousTimeout";
|
|
3426
|
+
MessageParameterType[MessageParameterType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
|
|
3427
|
+
MessageParameterType[MessageParameterType["Expires"] = 8] = "Expires";
|
|
3428
|
+
MessageParameterType[MessageParameterType["LargestObject"] = 9] = "LargestObject";
|
|
3429
|
+
MessageParameterType[MessageParameterType["FillTimeout"] = 10] = "FillTimeout";
|
|
3430
|
+
MessageParameterType[MessageParameterType["Forward"] = 16] = "Forward";
|
|
3431
|
+
MessageParameterType[MessageParameterType["SubscriberPriority"] = 32] = "SubscriberPriority";
|
|
3432
|
+
MessageParameterType[MessageParameterType["LocationFilter"] = 33] = "LocationFilter";
|
|
3433
|
+
MessageParameterType[MessageParameterType["GroupOrder"] = 34] = "GroupOrder";
|
|
3434
|
+
MessageParameterType[MessageParameterType["FillParameters"] = 35] = "FillParameters";
|
|
3435
|
+
MessageParameterType[MessageParameterType["SwitchFrom"] = 36] = "SwitchFrom";
|
|
3436
|
+
MessageParameterType[MessageParameterType["SubgroupFilter"] = 37] = "SubgroupFilter";
|
|
3437
|
+
MessageParameterType[MessageParameterType["ObjectIdFilter"] = 38] = "ObjectIdFilter";
|
|
3438
|
+
MessageParameterType[MessageParameterType["PriorityFilter"] = 39] = "PriorityFilter";
|
|
3439
|
+
MessageParameterType[MessageParameterType["ObjectPropertyFilter"] = 40] = "ObjectPropertyFilter";
|
|
3440
|
+
MessageParameterType[MessageParameterType["TrackPropertyFilter"] = 41] = "TrackPropertyFilter";
|
|
3441
|
+
MessageParameterType[MessageParameterType["NewGroupRequest"] = 50] = "NewGroupRequest";
|
|
3442
|
+
/**
|
|
3443
|
+
* Registered codepoint with no typed parameter yet: its consumer is REQUEST_UPDATE for
|
|
3444
|
+
* SUBSCRIBE_TRACKS (TS-11), and the value is a Track Namespace tuple rather than the
|
|
3445
|
+
* varint its even Type implies.
|
|
3446
|
+
*/
|
|
3447
|
+
MessageParameterType[MessageParameterType["TrackNamespacePrefix"] = 52] = "TrackNamespacePrefix";
|
|
3448
|
+
MessageParameterType[MessageParameterType["IncludeProperties"] = 53] = "IncludeProperties";
|
|
3449
|
+
/**
|
|
3450
|
+
* PROVISIONAL: sender-side track switching is not an adopted extension, so this
|
|
3451
|
+
* codepoint is absent from the registry the conformance fixture tracks; see its
|
|
3452
|
+
* `local_extensions`.
|
|
3453
|
+
*/
|
|
3454
|
+
MessageParameterType[MessageParameterType["SwitchingSetAssignment"] = 65] = "SwitchingSetAssignment";
|
|
3455
|
+
return MessageParameterType;
|
|
3456
|
+
}({});
|
|
3457
|
+
function messageParameterTypeFromNumber(value) {
|
|
3458
|
+
switch (Number(value)) {
|
|
3459
|
+
case 2: return 2;
|
|
3460
|
+
case 3: return 3;
|
|
3461
|
+
case 4: return 4;
|
|
3462
|
+
case 6: return 6;
|
|
3463
|
+
case 8: return 8;
|
|
3464
|
+
case 9: return 9;
|
|
3465
|
+
case 10: return 10;
|
|
3466
|
+
case 16: return 16;
|
|
3467
|
+
case 32: return 32;
|
|
3468
|
+
case 33: return 33;
|
|
3469
|
+
case 34: return 34;
|
|
3470
|
+
case 35: return 35;
|
|
3471
|
+
case 36: return 36;
|
|
3472
|
+
case 37: return 37;
|
|
3473
|
+
case 38: return 38;
|
|
3474
|
+
case 39: return 39;
|
|
3475
|
+
case 40: return 40;
|
|
3476
|
+
case 41: return 41;
|
|
3477
|
+
case 50: return 50;
|
|
3478
|
+
case 52: return 52;
|
|
3479
|
+
case 53: return 53;
|
|
3480
|
+
case 65: return 65;
|
|
3481
|
+
default: throw new InvalidTypeError("messageParameterTypeFromNumber", `Unknown message parameter type: ${value}`);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
let TokenAliasType = /* @__PURE__ */ function(TokenAliasType) {
|
|
3485
|
+
TokenAliasType[TokenAliasType["Delete"] = 0] = "Delete";
|
|
3486
|
+
TokenAliasType[TokenAliasType["Register"] = 1] = "Register";
|
|
3487
|
+
TokenAliasType[TokenAliasType["UseAlias"] = 2] = "UseAlias";
|
|
3488
|
+
TokenAliasType[TokenAliasType["UseValue"] = 3] = "UseValue";
|
|
3489
|
+
return TokenAliasType;
|
|
3490
|
+
}({});
|
|
3491
|
+
function tokenAliasTypeFromNumber(value) {
|
|
3492
|
+
switch (value) {
|
|
3493
|
+
case 0: return 0;
|
|
3494
|
+
case 1: return 1;
|
|
3495
|
+
case 2: return 2;
|
|
3496
|
+
case 3: return 3;
|
|
3497
|
+
default: throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
//#endregion
|
|
3366
3501
|
//#region src/model/common/moqt_url.ts
|
|
3367
3502
|
/**
|
|
3368
3503
|
* Copyright 2026 The MOQtail Authors
|
|
@@ -3381,7 +3516,7 @@ var PublishBlocked = class PublishBlocked {
|
|
|
3381
3516
|
*/
|
|
3382
3517
|
/**
|
|
3383
3518
|
* @public
|
|
3384
|
-
* A parsed `moqt://authority/path[?query][#fragment]` URI
|
|
3519
|
+
* A parsed `moqt://authority/path[?query][#fragment]` URI.
|
|
3385
3520
|
*
|
|
3386
3521
|
* `moqt-URI = "moqt" "://" authority path-abempty [ "?" query ]`, with an optional
|
|
3387
3522
|
* local-only fragment. `authority` is `host[:port]`; `path` keeps its leading `/`
|
|
@@ -3521,112 +3656,7 @@ var Redirect = class Redirect {
|
|
|
3521
3656
|
}
|
|
3522
3657
|
};
|
|
3523
3658
|
//#endregion
|
|
3524
|
-
//#region src/model/parameter/
|
|
3525
|
-
/**
|
|
3526
|
-
* Copyright 2026 The MOQtail Authors
|
|
3527
|
-
*
|
|
3528
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3529
|
-
* you may not use this file except in compliance with the License.
|
|
3530
|
-
* You may obtain a copy of the License at
|
|
3531
|
-
*
|
|
3532
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3533
|
-
*
|
|
3534
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3535
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3536
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3537
|
-
* See the License for the specific language governing permissions and
|
|
3538
|
-
* limitations under the License.
|
|
3539
|
-
*/
|
|
3540
|
-
let SetupOptionType = /* @__PURE__ */ function(SetupOptionType) {
|
|
3541
|
-
SetupOptionType[SetupOptionType["Path"] = 1] = "Path";
|
|
3542
|
-
SetupOptionType[SetupOptionType["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3543
|
-
SetupOptionType[SetupOptionType["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
|
|
3544
|
-
/** Raw-QUIC only. Client-only; MUST NOT be sent over WebTransport (draft-18 §10.3.1.1). */
|
|
3545
|
-
SetupOptionType[SetupOptionType["Authority"] = 5] = "Authority";
|
|
3546
|
-
SetupOptionType[SetupOptionType["MoqtImplementation"] = 7] = "MoqtImplementation";
|
|
3547
|
-
/**
|
|
3548
|
-
* PROVISIONAL: sender-side track switching is not an adopted extension, so this
|
|
3549
|
-
* codepoint is absent from the registry the conformance fixture tracks. It sits in the
|
|
3550
|
-
* 0x07-0x7F range of this space, which that registry leaves free.
|
|
3551
|
-
*/
|
|
3552
|
-
SetupOptionType[SetupOptionType["SstsAlgorithms"] = 9] = "SstsAlgorithms";
|
|
3553
|
-
return SetupOptionType;
|
|
3554
|
-
}({});
|
|
3555
|
-
function setupOptionTypeFromNumber(value) {
|
|
3556
|
-
switch (value) {
|
|
3557
|
-
case 1: return 1;
|
|
3558
|
-
case 3: return 3;
|
|
3559
|
-
case 4: return 4;
|
|
3560
|
-
case 5: return 5;
|
|
3561
|
-
case 7: return 7;
|
|
3562
|
-
case 9: return 9;
|
|
3563
|
-
default: throw new InvalidTypeError("setupOptionTypeFromNumber", `Invalid setup option type: ${value}`);
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
let MessageParameterType = /* @__PURE__ */ function(MessageParameterType) {
|
|
3567
|
-
MessageParameterType[MessageParameterType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
|
|
3568
|
-
MessageParameterType[MessageParameterType["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3569
|
-
MessageParameterType[MessageParameterType["RendezvousTimeout"] = 4] = "RendezvousTimeout";
|
|
3570
|
-
MessageParameterType[MessageParameterType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
|
|
3571
|
-
MessageParameterType[MessageParameterType["Expires"] = 8] = "Expires";
|
|
3572
|
-
MessageParameterType[MessageParameterType["LargestObject"] = 9] = "LargestObject";
|
|
3573
|
-
MessageParameterType[MessageParameterType["FillTimeout"] = 10] = "FillTimeout";
|
|
3574
|
-
MessageParameterType[MessageParameterType["Forward"] = 16] = "Forward";
|
|
3575
|
-
MessageParameterType[MessageParameterType["SubscriberPriority"] = 32] = "SubscriberPriority";
|
|
3576
|
-
MessageParameterType[MessageParameterType["SubscriptionFilter"] = 33] = "SubscriptionFilter";
|
|
3577
|
-
MessageParameterType[MessageParameterType["GroupOrder"] = 34] = "GroupOrder";
|
|
3578
|
-
MessageParameterType[MessageParameterType["NewGroupRequest"] = 50] = "NewGroupRequest";
|
|
3579
|
-
/**
|
|
3580
|
-
* Registered codepoint with no typed parameter yet: its consumer is REQUEST_UPDATE for
|
|
3581
|
-
* SUBSCRIBE_TRACKS (TS-11), and the value is a Track Namespace tuple rather than the
|
|
3582
|
-
* varint its even Type implies.
|
|
3583
|
-
*/
|
|
3584
|
-
MessageParameterType[MessageParameterType["TrackNamespacePrefix"] = 52] = "TrackNamespacePrefix";
|
|
3585
|
-
/**
|
|
3586
|
-
* PROVISIONAL: sender-side track switching is not an adopted extension, so this
|
|
3587
|
-
* codepoint is absent from the registry the conformance fixture tracks; see its
|
|
3588
|
-
* `local_extensions`.
|
|
3589
|
-
*/
|
|
3590
|
-
MessageParameterType[MessageParameterType["SwitchingSetAssignment"] = 65] = "SwitchingSetAssignment";
|
|
3591
|
-
return MessageParameterType;
|
|
3592
|
-
}({});
|
|
3593
|
-
function messageParameterTypeFromNumber(value) {
|
|
3594
|
-
switch (Number(value)) {
|
|
3595
|
-
case 2: return 2;
|
|
3596
|
-
case 3: return 3;
|
|
3597
|
-
case 4: return 4;
|
|
3598
|
-
case 6: return 6;
|
|
3599
|
-
case 8: return 8;
|
|
3600
|
-
case 9: return 9;
|
|
3601
|
-
case 10: return 10;
|
|
3602
|
-
case 16: return 16;
|
|
3603
|
-
case 32: return 32;
|
|
3604
|
-
case 33: return 33;
|
|
3605
|
-
case 34: return 34;
|
|
3606
|
-
case 50: return 50;
|
|
3607
|
-
case 52: return 52;
|
|
3608
|
-
case 65: return 65;
|
|
3609
|
-
default: throw new InvalidTypeError("messageParameterTypeFromNumber", `Unknown message parameter type: ${value}`);
|
|
3610
|
-
}
|
|
3611
|
-
}
|
|
3612
|
-
let TokenAliasType = /* @__PURE__ */ function(TokenAliasType) {
|
|
3613
|
-
TokenAliasType[TokenAliasType["Delete"] = 0] = "Delete";
|
|
3614
|
-
TokenAliasType[TokenAliasType["Register"] = 1] = "Register";
|
|
3615
|
-
TokenAliasType[TokenAliasType["UseAlias"] = 2] = "UseAlias";
|
|
3616
|
-
TokenAliasType[TokenAliasType["UseValue"] = 3] = "UseValue";
|
|
3617
|
-
return TokenAliasType;
|
|
3618
|
-
}({});
|
|
3619
|
-
function tokenAliasTypeFromNumber(value) {
|
|
3620
|
-
switch (value) {
|
|
3621
|
-
case 0: return 0;
|
|
3622
|
-
case 1: return 1;
|
|
3623
|
-
case 2: return 2;
|
|
3624
|
-
case 3: return 3;
|
|
3625
|
-
default: throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
//#endregion
|
|
3629
|
-
//#region src/model/parameter/common/authorization_token.ts
|
|
3659
|
+
//#region src/model/parameter/common/authorization_token.ts
|
|
3630
3660
|
/**
|
|
3631
3661
|
* Copyright 2026 The MOQtail Authors
|
|
3632
3662
|
*
|
|
@@ -3956,6 +3986,45 @@ var Forward = class Forward {
|
|
|
3956
3986
|
}
|
|
3957
3987
|
};
|
|
3958
3988
|
//#endregion
|
|
3989
|
+
//#region src/model/parameter/message/include_properties.ts
|
|
3990
|
+
/**
|
|
3991
|
+
* Copyright 2026 The MOQtail Authors
|
|
3992
|
+
*
|
|
3993
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3994
|
+
* you may not use this file except in compliance with the License.
|
|
3995
|
+
* You may obtain a copy of the License at
|
|
3996
|
+
*
|
|
3997
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3998
|
+
*
|
|
3999
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4000
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4001
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4002
|
+
* See the License for the specific language governing permissions and
|
|
4003
|
+
* limitations under the License.
|
|
4004
|
+
*/
|
|
4005
|
+
/**
|
|
4006
|
+
* Whether the response carries Track Properties: the OK answering a SUBSCRIBE,
|
|
4007
|
+
* TRACK_STATUS or FETCH, or each PUBLISH a SUBSCRIBE_TRACKS brings. With 0 the
|
|
4008
|
+
* Track Properties field is still there, but empty.
|
|
4009
|
+
* Allowed wire values: 0 or 1; any other value is a PROTOCOL_VIOLATION.
|
|
4010
|
+
* Default (when omitted) is 1 (include them).
|
|
4011
|
+
*/
|
|
4012
|
+
var IncludeProperties = class IncludeProperties {
|
|
4013
|
+
include;
|
|
4014
|
+
static TYPE = 53;
|
|
4015
|
+
constructor(include) {
|
|
4016
|
+
this.include = include;
|
|
4017
|
+
}
|
|
4018
|
+
toKeyValuePair() {
|
|
4019
|
+
return KeyValuePair.newVarInt(IncludeProperties.TYPE, this.include ? 1n : 0n);
|
|
4020
|
+
}
|
|
4021
|
+
static fromKeyValuePair(pair) {
|
|
4022
|
+
if (Number(pair.typeValue) !== IncludeProperties.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4023
|
+
if (pair.value !== 0n && pair.value !== 1n) throw new ProtocolViolationError("IncludeProperties.fromKeyValuePair", `INCLUDE_PROPERTIES must be 0 or 1, got ${pair.value}`);
|
|
4024
|
+
return new IncludeProperties(pair.value === 1n);
|
|
4025
|
+
}
|
|
4026
|
+
};
|
|
4027
|
+
//#endregion
|
|
3959
4028
|
//#region src/model/parameter/message/group_order_param.ts
|
|
3960
4029
|
/**
|
|
3961
4030
|
* Copyright 2026 The MOQtail Authors
|
|
@@ -4094,7 +4163,7 @@ var NewGroupRequest = class NewGroupRequest {
|
|
|
4094
4163
|
*
|
|
4095
4164
|
* PROVISIONAL: sender-side track switching is not an adopted extension, so
|
|
4096
4165
|
* this parameter has no codepoint in the registry the conformance fixture
|
|
4097
|
-
* tracks (`dev/conformance/
|
|
4166
|
+
* tracks (`dev/conformance/draft22`) and is never asserted against it. Id 0 is
|
|
4098
4167
|
* the default allocation every implementation runs; other ids select an
|
|
4099
4168
|
* algorithm specific to one implementation.
|
|
4100
4169
|
*/
|
|
@@ -4178,7 +4247,7 @@ var SubscriberPriority = class SubscriberPriority {
|
|
|
4178
4247
|
}
|
|
4179
4248
|
};
|
|
4180
4249
|
//#endregion
|
|
4181
|
-
//#region src/model/parameter/message/
|
|
4250
|
+
//#region src/model/parameter/message/location_filter.ts
|
|
4182
4251
|
/**
|
|
4183
4252
|
* Copyright 2026 The MOQtail Authors
|
|
4184
4253
|
*
|
|
@@ -4194,40 +4263,466 @@ var SubscriberPriority = class SubscriberPriority {
|
|
|
4194
4263
|
* See the License for the specific language governing permissions and
|
|
4195
4264
|
* limitations under the License.
|
|
4196
4265
|
*/
|
|
4266
|
+
const MAX_U64$1 = 18446744073709551615n;
|
|
4267
|
+
/** The fields each Location Filter Type carries, in wire order. */
|
|
4268
|
+
const FIELD_COUNT = {
|
|
4269
|
+
[0]: 0,
|
|
4270
|
+
[1]: 1,
|
|
4271
|
+
[2]: 2,
|
|
4272
|
+
[3]: 3,
|
|
4273
|
+
[4]: 4,
|
|
4274
|
+
[5]: 0
|
|
4275
|
+
};
|
|
4197
4276
|
/**
|
|
4198
|
-
*
|
|
4199
|
-
*
|
|
4277
|
+
* The range of Locations a subscription or fetch selects. The Location Filter
|
|
4278
|
+
* Type decides which fields are set, and the value is not length-prefixed.
|
|
4279
|
+
*
|
|
4280
|
+
* Every Group here is absolute, except `startGroup` of a
|
|
4281
|
+
* {@link (LocationFilterType:enum).RelativeStart}, which counts back from the Next
|
|
4282
|
+
* Group: 0 is the Next Group, 1 the current one. The wire carries the End Group
|
|
4283
|
+
* as a delta from the Start Group; that is undone on the way in and redone on
|
|
4284
|
+
* the way out.
|
|
4285
|
+
*
|
|
4286
|
+
* If omitted from SUBSCRIBE or FETCH, the subscription or fetch is unfiltered.
|
|
4200
4287
|
* If omitted from REQUEST_UPDATE, the value is unchanged.
|
|
4201
4288
|
*/
|
|
4202
|
-
var
|
|
4289
|
+
var LocationFilter = class LocationFilter {
|
|
4203
4290
|
filterType;
|
|
4204
|
-
|
|
4291
|
+
startGroup;
|
|
4292
|
+
startObject;
|
|
4205
4293
|
endGroup;
|
|
4294
|
+
endObject;
|
|
4206
4295
|
static TYPE = 33;
|
|
4207
|
-
|
|
4296
|
+
/**
|
|
4297
|
+
* @throws :{@link ProtocolViolationError} When a field the type calls for is
|
|
4298
|
+
* missing, or the End Group is before the Start Group.
|
|
4299
|
+
*/
|
|
4300
|
+
constructor(filterType, startGroup, startObject, endGroup, endObject) {
|
|
4208
4301
|
this.filterType = filterType;
|
|
4209
|
-
this.
|
|
4302
|
+
this.startGroup = startGroup;
|
|
4303
|
+
this.startObject = startObject;
|
|
4210
4304
|
this.endGroup = endGroup;
|
|
4305
|
+
this.endObject = endObject;
|
|
4306
|
+
const fields = [
|
|
4307
|
+
startGroup,
|
|
4308
|
+
startObject,
|
|
4309
|
+
endGroup,
|
|
4310
|
+
endObject
|
|
4311
|
+
];
|
|
4312
|
+
const count = FIELD_COUNT[filterType];
|
|
4313
|
+
if (count === void 0) throw new ProtocolViolationError("LocationFilter", `unknown Location Filter Type ${filterType}`);
|
|
4314
|
+
fields.forEach((field, i) => {
|
|
4315
|
+
if (field !== void 0 !== i < count) throw new ProtocolViolationError("LocationFilter", `Location Filter Type ${filterType} carries ${count} fields; field ${i + 1} is ${field === void 0 ? "missing" : "not one of them"}`);
|
|
4316
|
+
});
|
|
4317
|
+
if (endGroup !== void 0 && endGroup < startGroup) throw new ProtocolViolationError("LocationFilter", `End Group ${endGroup} is before Start Group ${startGroup}`);
|
|
4211
4318
|
}
|
|
4212
|
-
|
|
4319
|
+
/**
|
|
4320
|
+
* The first Location the filter passes, given the track's Largest Object, or
|
|
4321
|
+
* `undefined` when there is no filter. A relative start that would fall before
|
|
4322
|
+
* group 0 is group 0; a track with nothing published yet starts a relative
|
|
4323
|
+
* filter at `{0,0}`.
|
|
4324
|
+
*/
|
|
4325
|
+
startLocation(largest) {
|
|
4326
|
+
switch (this.filterType) {
|
|
4327
|
+
case 0: return;
|
|
4328
|
+
case 1: {
|
|
4329
|
+
if (!largest) return new Location(0n, 0n);
|
|
4330
|
+
const group = largest.group + 1n - this.startGroup;
|
|
4331
|
+
return new Location(group < 0n ? 0n : group > MAX_U64$1 ? MAX_U64$1 : group, 0n);
|
|
4332
|
+
}
|
|
4333
|
+
case 5: return largest ? new Location(largest.group, largest.object + 1n) : new Location(0n, 0n);
|
|
4334
|
+
default: return new Location(this.startGroup, this.startObject);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
/** The Start Location an absolute filter carries; `undefined` for the others. */
|
|
4338
|
+
get absoluteStart() {
|
|
4339
|
+
switch (this.filterType) {
|
|
4340
|
+
case 2:
|
|
4341
|
+
case 3:
|
|
4342
|
+
case 4: return new Location(this.startGroup, this.startObject);
|
|
4343
|
+
default: return;
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* The last Location the filter passes, inclusive, or `undefined` when it is
|
|
4348
|
+
* open-ended. A Group End is the whole of that group, so its Object is 2^64-1.
|
|
4349
|
+
*/
|
|
4350
|
+
endLocation() {
|
|
4351
|
+
switch (this.filterType) {
|
|
4352
|
+
case 3: return new Location(this.endGroup, MAX_U64$1);
|
|
4353
|
+
case 4: return new Location(this.endGroup, this.endObject);
|
|
4354
|
+
default: return;
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
/**
|
|
4358
|
+
* The inclusive range the filter selects under the rules for a Fetch, which
|
|
4359
|
+
* never reach past the Largest Object: an open end is the Largest Object, and
|
|
4360
|
+
* no filter at all is the whole track up to it.
|
|
4361
|
+
*
|
|
4362
|
+
* `undefined` when that range is empty, which includes a track with nothing
|
|
4363
|
+
* published yet and a Next Object filter, whose start is always past the
|
|
4364
|
+
* Largest Object.
|
|
4365
|
+
*/
|
|
4366
|
+
fetchRange(largest) {
|
|
4367
|
+
if (!largest) return void 0;
|
|
4368
|
+
const start = this.startLocation(largest) ?? new Location(0n, 0n);
|
|
4369
|
+
const filterEnd = this.endLocation();
|
|
4370
|
+
const end = filterEnd && filterEnd.compare(largest) < 0 ? filterEnd : largest;
|
|
4371
|
+
return start.compare(end) <= 0 ? {
|
|
4372
|
+
start,
|
|
4373
|
+
end
|
|
4374
|
+
} : void 0;
|
|
4375
|
+
}
|
|
4376
|
+
/** The Location Filter Type and its fields, without the Parameter Type. */
|
|
4377
|
+
serializeValue() {
|
|
4213
4378
|
const buf = new ByteBuffer();
|
|
4214
4379
|
buf.putVI(this.filterType);
|
|
4215
|
-
|
|
4216
|
-
|
|
4380
|
+
const count = FIELD_COUNT[this.filterType];
|
|
4381
|
+
if (count > 0) buf.putVI(this.startGroup);
|
|
4382
|
+
if (count > 1) buf.putVI(this.startObject);
|
|
4383
|
+
if (count > 2) buf.putVI(this.endGroup - this.startGroup);
|
|
4384
|
+
if (count > 3) buf.putVI(this.endObject);
|
|
4385
|
+
return buf.toUint8Array();
|
|
4386
|
+
}
|
|
4387
|
+
/**
|
|
4388
|
+
* Reads a Location Filter Type and exactly the fields it calls for.
|
|
4389
|
+
* @throws :{@link ProtocolViolationError} For an unknown Location Filter Type,
|
|
4390
|
+
* or an End Group past 2^64-1.
|
|
4391
|
+
*/
|
|
4392
|
+
static deserializeValue(buf) {
|
|
4393
|
+
const raw = buf.getVI();
|
|
4394
|
+
let filterType;
|
|
4395
|
+
try {
|
|
4396
|
+
filterType = LocationFilterType.tryFrom(raw);
|
|
4397
|
+
} catch {
|
|
4398
|
+
throw new ProtocolViolationError("LocationFilter.deserializeValue", `unknown Location Filter Type ${raw}`);
|
|
4399
|
+
}
|
|
4400
|
+
const count = FIELD_COUNT[filterType];
|
|
4401
|
+
const startGroup = count > 0 ? buf.getVI() : void 0;
|
|
4402
|
+
const startObject = count > 1 ? buf.getVI() : void 0;
|
|
4403
|
+
let endGroup;
|
|
4404
|
+
if (count > 2) {
|
|
4405
|
+
endGroup = startGroup + buf.getVI();
|
|
4406
|
+
if (endGroup > MAX_U64$1) throw new ProtocolViolationError("LocationFilter.deserializeValue", `StartGroup plus EndGroupDelta exceeds 2^64 - 1`);
|
|
4217
4407
|
}
|
|
4218
|
-
|
|
4219
|
-
return
|
|
4408
|
+
const endObject = count > 3 ? buf.getVI() : void 0;
|
|
4409
|
+
return new LocationFilter(filterType, startGroup, startObject, endGroup, endObject);
|
|
4410
|
+
}
|
|
4411
|
+
toKeyValuePair() {
|
|
4412
|
+
return KeyValuePair.tryNewBytes(LocationFilter.TYPE, this.serializeValue());
|
|
4220
4413
|
}
|
|
4221
4414
|
static fromKeyValuePair(pair) {
|
|
4222
|
-
if (Number(pair.typeValue) !==
|
|
4415
|
+
if (Number(pair.typeValue) !== LocationFilter.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4223
4416
|
const buf = new ByteBuffer();
|
|
4224
4417
|
buf.putBytes(pair.value);
|
|
4225
|
-
const
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4418
|
+
const frozen = buf.freeze();
|
|
4419
|
+
const filter = LocationFilter.deserializeValue(frozen);
|
|
4420
|
+
if (frozen.remaining > 0) throw new ProtocolViolationError("LocationFilter.fromKeyValuePair", "trailing bytes after the Location Filter");
|
|
4421
|
+
return filter;
|
|
4422
|
+
}
|
|
4423
|
+
};
|
|
4424
|
+
//#endregion
|
|
4425
|
+
//#region src/model/parameter/message/switch_from.ts
|
|
4426
|
+
/**
|
|
4427
|
+
* Copyright 2026 The MOQtail Authors
|
|
4428
|
+
*
|
|
4429
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4430
|
+
* you may not use this file except in compliance with the License.
|
|
4431
|
+
* You may obtain a copy of the License at
|
|
4432
|
+
*
|
|
4433
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4434
|
+
*
|
|
4435
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4436
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4437
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4438
|
+
* See the License for the specific language governing permissions and
|
|
4439
|
+
* limitations under the License.
|
|
4440
|
+
*/
|
|
4441
|
+
/**
|
|
4442
|
+
* Identifies the subscription being replaced by a switch request.
|
|
4443
|
+
* The value is two varints followed by a flags byte: bit 7 (MSB) is Publish Done;
|
|
4444
|
+
* bits 0 through 6 are reserved and must be zero.
|
|
4445
|
+
*/
|
|
4446
|
+
var SwitchFrom = class SwitchFrom {
|
|
4447
|
+
requestId;
|
|
4448
|
+
mode;
|
|
4449
|
+
publishDone;
|
|
4450
|
+
static TYPE = 36;
|
|
4451
|
+
constructor(requestId, mode, publishDone) {
|
|
4452
|
+
this.requestId = requestId;
|
|
4453
|
+
this.mode = mode;
|
|
4454
|
+
this.publishDone = publishDone;
|
|
4455
|
+
}
|
|
4456
|
+
toKeyValuePair() {
|
|
4457
|
+
const buf = new ByteBuffer();
|
|
4458
|
+
buf.putVI(this.requestId);
|
|
4459
|
+
buf.putVI(this.mode);
|
|
4460
|
+
buf.putU8(this.publishDone ? 128 : 0);
|
|
4461
|
+
return KeyValuePair.newBytes(SwitchFrom.TYPE, buf.toUint8Array());
|
|
4462
|
+
}
|
|
4463
|
+
static fromKeyValuePair(pair) {
|
|
4464
|
+
if (Number(pair.typeValue) !== SwitchFrom.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4465
|
+
const buf = new ByteBuffer();
|
|
4466
|
+
buf.putBytes(pair.value);
|
|
4467
|
+
const requestId = buf.getVI();
|
|
4468
|
+
const modeValue = buf.getVI();
|
|
4469
|
+
if (modeValue !== BigInt(0) && modeValue !== BigInt(1)) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", `invalid mode ${modeValue}`);
|
|
4470
|
+
const flags = buf.getU8();
|
|
4471
|
+
if ((flags & 127) !== 0) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", `reserved bits must be zero, got ${flags}`);
|
|
4472
|
+
if (buf.remaining !== 0) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", "unexpected trailing bytes");
|
|
4473
|
+
return new SwitchFrom(requestId, Number(modeValue), (flags & 128) !== 0);
|
|
4474
|
+
}
|
|
4475
|
+
};
|
|
4476
|
+
//#endregion
|
|
4477
|
+
//#region src/model/parameter/message/fill_parameters.ts
|
|
4478
|
+
/**
|
|
4479
|
+
* Copyright 2026 The MOQtail Authors
|
|
4480
|
+
*
|
|
4481
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4482
|
+
* you may not use this file except in compliance with the License.
|
|
4483
|
+
* You may obtain a copy of the License at
|
|
4484
|
+
*
|
|
4485
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4486
|
+
*
|
|
4487
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4488
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4489
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4490
|
+
* See the License for the specific language governing permissions and
|
|
4491
|
+
* limitations under the License.
|
|
4492
|
+
*/
|
|
4493
|
+
/** The only parameters that may override anything for the fill fetch stream. */
|
|
4494
|
+
const ALLOWED = [
|
|
4495
|
+
10,
|
|
4496
|
+
32,
|
|
4497
|
+
33,
|
|
4498
|
+
34,
|
|
4499
|
+
37,
|
|
4500
|
+
38,
|
|
4501
|
+
39,
|
|
4502
|
+
40
|
|
4503
|
+
];
|
|
4504
|
+
/**
|
|
4505
|
+
* Requests a fill fetch stream, and overrides for it. An omitted parameter keeps
|
|
4506
|
+
* the value it has for the live subscription; an omitted LOCATION_FILTER fills
|
|
4507
|
+
* over the subscription's own.
|
|
4508
|
+
*/
|
|
4509
|
+
var FillParameters = class FillParameters {
|
|
4510
|
+
parameters;
|
|
4511
|
+
static TYPE = 35;
|
|
4512
|
+
constructor(parameters) {
|
|
4513
|
+
this.parameters = parameters;
|
|
4514
|
+
}
|
|
4515
|
+
toKeyValuePair() {
|
|
4516
|
+
const pairs = this.parameters.map((p) => p.toKeyValuePair());
|
|
4517
|
+
for (const pair of pairs) if (!ALLOWED.includes(Number(pair.typeValue))) throw new ProtocolViolationError("FillParameters.toKeyValuePair", `parameter type 0x${pair.typeValue.toString(16)} is not allowed inside FILL_PARAMETERS`);
|
|
4518
|
+
const value = new ByteBuffer();
|
|
4519
|
+
value.putVI(pairs.length);
|
|
4520
|
+
value.putBytes(serializeMessageParameterKvps(pairs).toUint8Array());
|
|
4521
|
+
return KeyValuePair.tryNewBytes(FillParameters.TYPE, value.toUint8Array());
|
|
4522
|
+
}
|
|
4523
|
+
static fromKeyValuePair(pair) {
|
|
4524
|
+
if (Number(pair.typeValue) !== FillParameters.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4525
|
+
const buf = new ByteBuffer();
|
|
4526
|
+
buf.putBytes(pair.value);
|
|
4527
|
+
const frozen = buf.freeze();
|
|
4528
|
+
const count = frozen.getVI();
|
|
4529
|
+
const pairs = deserializeMessageParameterKvps(frozen, count);
|
|
4530
|
+
if (frozen.remaining > 0) throw new ProtocolViolationError("FillParameters.fromKeyValuePair", `${frozen.remaining} bytes left after ${count} parameters`);
|
|
4531
|
+
for (const inner of pairs) if (!ALLOWED.includes(Number(inner.typeValue))) throw new ProtocolViolationError("FillParameters.fromKeyValuePair", `parameter type 0x${inner.typeValue.toString(16)} is not allowed inside FILL_PARAMETERS`);
|
|
4532
|
+
return new FillParameters(MessageParameters.fromKeyValuePairs(pairs));
|
|
4533
|
+
}
|
|
4534
|
+
};
|
|
4535
|
+
//#endregion
|
|
4536
|
+
//#region src/model/parameter/message/range_filter.ts
|
|
4537
|
+
/**
|
|
4538
|
+
* Copyright 2026 The MOQtail Authors
|
|
4539
|
+
*
|
|
4540
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4541
|
+
* you may not use this file except in compliance with the License.
|
|
4542
|
+
* You may obtain a copy of the License at
|
|
4543
|
+
*
|
|
4544
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4545
|
+
*
|
|
4546
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4547
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4548
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4549
|
+
* See the License for the specific language governing permissions and
|
|
4550
|
+
* limitations under the License.
|
|
4551
|
+
*/
|
|
4552
|
+
const MAX_U64 = 18446744073709551615n;
|
|
4553
|
+
/**
|
|
4554
|
+
* What a Range Filter selects on. Each kind is its own parameter type, and the two
|
|
4555
|
+
* property kinds also name the Property they read.
|
|
4556
|
+
*/
|
|
4557
|
+
let RangeFilterKind = /* @__PURE__ */ function(RangeFilterKind) {
|
|
4558
|
+
RangeFilterKind[RangeFilterKind["Subgroup"] = 37] = "Subgroup";
|
|
4559
|
+
RangeFilterKind[RangeFilterKind["ObjectId"] = 38] = "ObjectId";
|
|
4560
|
+
/** Publisher Priority, which is a single byte. */
|
|
4561
|
+
RangeFilterKind[RangeFilterKind["Priority"] = 39] = "Priority";
|
|
4562
|
+
RangeFilterKind[RangeFilterKind["ObjectProperty"] = 40] = "ObjectProperty";
|
|
4563
|
+
/** Selects tracks rather than Objects, so it only rides SUBSCRIBE_TRACKS. */
|
|
4564
|
+
RangeFilterKind[RangeFilterKind["TrackProperty"] = 41] = "TrackProperty";
|
|
4565
|
+
return RangeFilterKind;
|
|
4566
|
+
}({});
|
|
4567
|
+
(function(_RangeFilterKind) {
|
|
4568
|
+
function hasPropertyType(kind) {
|
|
4569
|
+
return kind === RangeFilterKind.ObjectProperty || kind === RangeFilterKind.TrackProperty;
|
|
4570
|
+
}
|
|
4571
|
+
_RangeFilterKind.hasPropertyType = hasPropertyType;
|
|
4572
|
+
function isRangeFilterType(typeValue) {
|
|
4573
|
+
const n = Number(typeValue);
|
|
4574
|
+
return n >= 37 && n <= 41;
|
|
4575
|
+
}
|
|
4576
|
+
_RangeFilterKind.isRangeFilterType = isRangeFilterType;
|
|
4577
|
+
})(RangeFilterKind || (RangeFilterKind = {}));
|
|
4578
|
+
/**
|
|
4579
|
+
* A Range Filter that cannot be honoured. A peer that sends one is answered with
|
|
4580
|
+
* REQUEST_ERROR INVALID_FILTER rather than a closed session: the request is
|
|
4581
|
+
* well-formed, it just asks for something that cannot be applied.
|
|
4582
|
+
*/
|
|
4583
|
+
var InvalidFilterError = class extends MOQtailError {
|
|
4584
|
+
context;
|
|
4585
|
+
details;
|
|
4586
|
+
constructor(context, details) {
|
|
4587
|
+
super(`Invalid filter in ${context}: ${details}`);
|
|
4588
|
+
this.context = context;
|
|
4589
|
+
this.details = details;
|
|
4590
|
+
}
|
|
4591
|
+
};
|
|
4592
|
+
/**
|
|
4593
|
+
* Delta-encodes ascending `ranges`. Only the last may be open-ended.
|
|
4594
|
+
* @throws :{@link InvalidFilterError} When the ranges do not ascend.
|
|
4595
|
+
*/
|
|
4596
|
+
function encodeRanges(ranges) {
|
|
4597
|
+
const deltas = [];
|
|
4598
|
+
let priorEnd = 0n;
|
|
4599
|
+
ranges.forEach((range, i) => {
|
|
4600
|
+
if (range.start < priorEnd || range.end !== void 0 && range.end < range.start) throw new InvalidFilterError("encodeRanges", "ranges are not ascending");
|
|
4601
|
+
if (range.end === void 0) {
|
|
4602
|
+
if (i + 1 !== ranges.length) throw new InvalidFilterError("encodeRanges", "only the last range can be open-ended");
|
|
4603
|
+
deltas.push([range.start - priorEnd]);
|
|
4604
|
+
return;
|
|
4605
|
+
}
|
|
4606
|
+
deltas.push([range.start - priorEnd, range.end - range.start]);
|
|
4607
|
+
priorEnd = range.end;
|
|
4608
|
+
});
|
|
4609
|
+
return deltas;
|
|
4610
|
+
}
|
|
4611
|
+
/**
|
|
4612
|
+
* One Range Filter parameter. Unlike other parameters it may repeat in a message,
|
|
4613
|
+
* once per SetID (and Property Type).
|
|
4614
|
+
*
|
|
4615
|
+
* Without a `setId` it is the zero-length form, which in REQUEST_UPDATE removes the
|
|
4616
|
+
* filters of its kind.
|
|
4617
|
+
*
|
|
4618
|
+
* The Ranges are held as the wire's deltas and only added back by {@link
|
|
4619
|
+
* RangeFilter.ranges}: a sum past 2^64-1 is answered with a REQUEST_ERROR for the
|
|
4620
|
+
* request that carried it, which a parser that rejected it could not do.
|
|
4621
|
+
*/
|
|
4622
|
+
var RangeFilter = class RangeFilter {
|
|
4623
|
+
kind;
|
|
4624
|
+
setId;
|
|
4625
|
+
propertyType;
|
|
4626
|
+
deltas;
|
|
4627
|
+
/**
|
|
4628
|
+
* @throws :{@link ProtocolViolationError} When the Property Type's presence does not
|
|
4629
|
+
* match the kind, or a removal carries anything but its kind.
|
|
4630
|
+
*/
|
|
4631
|
+
constructor(kind, setId, propertyType, deltas = []) {
|
|
4632
|
+
this.kind = kind;
|
|
4633
|
+
this.setId = setId;
|
|
4634
|
+
this.propertyType = propertyType;
|
|
4635
|
+
this.deltas = deltas;
|
|
4636
|
+
if (setId === void 0) {
|
|
4637
|
+
if (propertyType !== void 0 || deltas.length > 0) throw new ProtocolViolationError("RangeFilter", "a removal carries no SetID, Property Type or Ranges");
|
|
4638
|
+
return;
|
|
4639
|
+
}
|
|
4640
|
+
if (!Number.isInteger(setId) || setId < 0 || setId > 255) throw new ProtocolViolationError("RangeFilter", `SetID ${setId} is not a single byte`);
|
|
4641
|
+
if (RangeFilterKind.hasPropertyType(kind) !== (propertyType !== void 0)) throw new ProtocolViolationError("RangeFilter", `${RangeFilterKind[kind]} filter has the wrong Property Type presence`);
|
|
4642
|
+
deltas.forEach(([, end], i) => {
|
|
4643
|
+
if (end === void 0 && i + 1 !== deltas.length) throw new ProtocolViolationError("RangeFilter", "only the last range can be open-ended");
|
|
4644
|
+
});
|
|
4645
|
+
}
|
|
4646
|
+
/** The zero-length form, which removes the filters of its kind. */
|
|
4647
|
+
get isRemoval() {
|
|
4648
|
+
return this.setId === void 0;
|
|
4649
|
+
}
|
|
4650
|
+
/** How many Ranges the filter holds, which is what a peer's range limit counts. */
|
|
4651
|
+
get rangeCount() {
|
|
4652
|
+
return this.deltas.length;
|
|
4653
|
+
}
|
|
4654
|
+
/**
|
|
4655
|
+
* The Ranges with their deltas added back.
|
|
4656
|
+
* @throws :{@link InvalidFilterError} When a bound exceeds 2^64-1.
|
|
4657
|
+
*/
|
|
4658
|
+
ranges() {
|
|
4659
|
+
const ranges = [];
|
|
4660
|
+
let priorEnd = 0n;
|
|
4661
|
+
for (const [startDelta, endDelta] of this.deltas) {
|
|
4662
|
+
const start = priorEnd + startDelta;
|
|
4663
|
+
if (start > MAX_U64) throw new InvalidFilterError("RangeFilter.ranges", "a range bound exceeds 2^64 - 1");
|
|
4664
|
+
if (endDelta === void 0) {
|
|
4665
|
+
ranges.push({ start });
|
|
4666
|
+
continue;
|
|
4667
|
+
}
|
|
4668
|
+
const end = start + endDelta;
|
|
4669
|
+
if (end > MAX_U64) throw new InvalidFilterError("RangeFilter.ranges", "a range bound exceeds 2^64 - 1");
|
|
4670
|
+
ranges.push({
|
|
4671
|
+
start,
|
|
4672
|
+
end
|
|
4673
|
+
});
|
|
4674
|
+
priorEnd = end;
|
|
4675
|
+
}
|
|
4676
|
+
return ranges;
|
|
4677
|
+
}
|
|
4678
|
+
/**
|
|
4679
|
+
* The Ranges, once everything a filter of this kind has to satisfy holds.
|
|
4680
|
+
* @throws :{@link InvalidFilterError} For an odd Property Type, a priority above
|
|
4681
|
+
* 255, or a bound past 2^64-1.
|
|
4682
|
+
*/
|
|
4683
|
+
validate() {
|
|
4684
|
+
if (this.propertyType !== void 0 && this.propertyType % 2n !== 0n) throw new InvalidFilterError("RangeFilter.validate", `property type 0x${this.propertyType.toString(16)} is odd`);
|
|
4685
|
+
const ranges = this.ranges();
|
|
4686
|
+
if (this.kind === RangeFilterKind.Priority) {
|
|
4687
|
+
const over = ranges.flatMap((r) => [r.start, r.end]).find((v) => v !== void 0 && v > 255n);
|
|
4688
|
+
if (over !== void 0) throw new InvalidFilterError("RangeFilter.validate", `priority ${over} is outside 0-255`);
|
|
4689
|
+
}
|
|
4690
|
+
return ranges;
|
|
4691
|
+
}
|
|
4692
|
+
/** The SetID, Property Type if any, and the Ranges, without the Type or Length. */
|
|
4693
|
+
serializeValue() {
|
|
4694
|
+
if (this.setId === void 0) return /* @__PURE__ */ new Uint8Array();
|
|
4695
|
+
const buf = new ByteBuffer();
|
|
4696
|
+
buf.putU8(this.setId);
|
|
4697
|
+
if (this.propertyType !== void 0) buf.putVI(this.propertyType);
|
|
4698
|
+
for (const [start, end] of this.deltas) {
|
|
4699
|
+
buf.putVI(start);
|
|
4700
|
+
if (end !== void 0) buf.putVI(end);
|
|
4701
|
+
}
|
|
4702
|
+
return buf.toUint8Array();
|
|
4703
|
+
}
|
|
4704
|
+
toKeyValuePair() {
|
|
4705
|
+
return KeyValuePair.newBytes(this.kind, this.serializeValue());
|
|
4706
|
+
}
|
|
4707
|
+
/**
|
|
4708
|
+
* Decodes a Range Filter value. The Value ends with the last Range, so a Start
|
|
4709
|
+
* with nothing after it is an open-ended last Range.
|
|
4710
|
+
*/
|
|
4711
|
+
static fromKeyValuePair(pair) {
|
|
4712
|
+
if (!RangeFilterKind.isRangeFilterType(pair.typeValue) || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4713
|
+
const kind = Number(pair.typeValue);
|
|
4714
|
+
if (pair.value.length === 0) return new RangeFilter(kind);
|
|
4715
|
+
const buf = new ByteBuffer();
|
|
4716
|
+
buf.putBytes(pair.value);
|
|
4717
|
+
const frozen = buf.freeze();
|
|
4718
|
+
const setId = frozen.getU8();
|
|
4719
|
+
const propertyType = RangeFilterKind.hasPropertyType(kind) ? frozen.getVI() : void 0;
|
|
4720
|
+
const deltas = [];
|
|
4721
|
+
while (frozen.remaining > 0) {
|
|
4722
|
+
const start = frozen.getVI();
|
|
4723
|
+
deltas.push(frozen.remaining > 0 ? [start, frozen.getVI()] : [start]);
|
|
4724
|
+
}
|
|
4725
|
+
return new RangeFilter(kind, setId, propertyType, deltas);
|
|
4231
4726
|
}
|
|
4232
4727
|
};
|
|
4233
4728
|
//#endregion
|
|
@@ -4250,7 +4745,7 @@ var SubscriptionFilter = class SubscriptionFilter {
|
|
|
4250
4745
|
let MessageParameter;
|
|
4251
4746
|
(function(_MessageParameter) {
|
|
4252
4747
|
function fromKeyValuePair(pair) {
|
|
4253
|
-
return ObjectDeliveryTimeout.fromKeyValuePair(pair) ?? SubgroupDeliveryTimeout.fromKeyValuePair(pair) ?? RendezvousTimeout.fromKeyValuePair(pair) ?? FillTimeout.fromKeyValuePair(pair) ?? AuthorizationToken.fromKeyValuePair(pair) ?? Expires.fromKeyValuePair(pair) ?? LargestObject.fromKeyValuePair(pair) ?? Forward.fromKeyValuePair(pair) ?? SubscriberPriority.fromKeyValuePair(pair) ?? GroupOrderParam.fromKeyValuePair(pair) ??
|
|
4748
|
+
return ObjectDeliveryTimeout.fromKeyValuePair(pair) ?? SubgroupDeliveryTimeout.fromKeyValuePair(pair) ?? RendezvousTimeout.fromKeyValuePair(pair) ?? FillTimeout.fromKeyValuePair(pair) ?? AuthorizationToken.fromKeyValuePair(pair) ?? Expires.fromKeyValuePair(pair) ?? LargestObject.fromKeyValuePair(pair) ?? Forward.fromKeyValuePair(pair) ?? SubscriberPriority.fromKeyValuePair(pair) ?? GroupOrderParam.fromKeyValuePair(pair) ?? LocationFilter.fromKeyValuePair(pair) ?? NewGroupRequest.fromKeyValuePair(pair) ?? SwitchFrom.fromKeyValuePair(pair) ?? FillParameters.fromKeyValuePair(pair) ?? RangeFilter.fromKeyValuePair(pair) ?? IncludeProperties.fromKeyValuePair(pair) ?? SwitchingSetAssignment.fromKeyValuePair(pair);
|
|
4254
4749
|
}
|
|
4255
4750
|
_MessageParameter.fromKeyValuePair = fromKeyValuePair;
|
|
4256
4751
|
function toKeyValuePair(param) {
|
|
@@ -4305,14 +4800,42 @@ let MessageParameter;
|
|
|
4305
4800
|
return params.find(isGroupOrderParam)?.order ?? 0;
|
|
4306
4801
|
}
|
|
4307
4802
|
_MessageParameter.groupOrderOf = groupOrderOf;
|
|
4308
|
-
function
|
|
4309
|
-
return param instanceof
|
|
4803
|
+
function isLocationFilter(param) {
|
|
4804
|
+
return param instanceof LocationFilter;
|
|
4310
4805
|
}
|
|
4311
|
-
_MessageParameter.
|
|
4806
|
+
_MessageParameter.isLocationFilter = isLocationFilter;
|
|
4312
4807
|
function isNewGroupRequest(param) {
|
|
4313
4808
|
return param instanceof NewGroupRequest;
|
|
4314
4809
|
}
|
|
4315
4810
|
_MessageParameter.isNewGroupRequest = isNewGroupRequest;
|
|
4811
|
+
function isSwitchFrom(param) {
|
|
4812
|
+
return param instanceof SwitchFrom;
|
|
4813
|
+
}
|
|
4814
|
+
_MessageParameter.isSwitchFrom = isSwitchFrom;
|
|
4815
|
+
function isFillParameters(param) {
|
|
4816
|
+
return param instanceof FillParameters;
|
|
4817
|
+
}
|
|
4818
|
+
_MessageParameter.isFillParameters = isFillParameters;
|
|
4819
|
+
function isRangeFilter(param) {
|
|
4820
|
+
return param instanceof RangeFilter;
|
|
4821
|
+
}
|
|
4822
|
+
_MessageParameter.isRangeFilter = isRangeFilter;
|
|
4823
|
+
function carriesRangeFilter(params) {
|
|
4824
|
+
return params.some((p) => isRangeFilter(p) || isFillParameters(p) && carriesRangeFilter(p.parameters));
|
|
4825
|
+
}
|
|
4826
|
+
_MessageParameter.carriesRangeFilter = carriesRangeFilter;
|
|
4827
|
+
function isIncludeProperties(param) {
|
|
4828
|
+
return param instanceof IncludeProperties;
|
|
4829
|
+
}
|
|
4830
|
+
_MessageParameter.isIncludeProperties = isIncludeProperties;
|
|
4831
|
+
function publishParametersFor(subscribeTracks) {
|
|
4832
|
+
return subscribeTracks.filter((p) => isForward(p) || isGroupOrderParam(p) || isLocationFilter(p));
|
|
4833
|
+
}
|
|
4834
|
+
_MessageParameter.publishParametersFor = publishParametersFor;
|
|
4835
|
+
function includesProperties(params) {
|
|
4836
|
+
return !params.some((p) => isIncludeProperties(p) && !p.include);
|
|
4837
|
+
}
|
|
4838
|
+
_MessageParameter.includesProperties = includesProperties;
|
|
4316
4839
|
})(MessageParameter || (MessageParameter = {}));
|
|
4317
4840
|
/**
|
|
4318
4841
|
* Builder for constructing a list of MessageParameters.
|
|
@@ -4345,18 +4868,30 @@ var MessageParameters = class {
|
|
|
4345
4868
|
addForward(forward) {
|
|
4346
4869
|
return this.add(new Forward(forward));
|
|
4347
4870
|
}
|
|
4871
|
+
addIncludeProperties(include) {
|
|
4872
|
+
return this.add(new IncludeProperties(include));
|
|
4873
|
+
}
|
|
4348
4874
|
addSubscriberPriority(priority) {
|
|
4349
4875
|
return this.add(new SubscriberPriority(priority));
|
|
4350
4876
|
}
|
|
4351
4877
|
addGroupOrder(order) {
|
|
4352
4878
|
return this.add(new GroupOrderParam(order));
|
|
4353
4879
|
}
|
|
4354
|
-
|
|
4880
|
+
addLocationFilter(filter) {
|
|
4355
4881
|
return this.add(filter);
|
|
4356
4882
|
}
|
|
4357
4883
|
addNewGroupRequest(group) {
|
|
4358
4884
|
return this.add(new NewGroupRequest(BigInt(group)));
|
|
4359
4885
|
}
|
|
4886
|
+
addSwitchFrom(requestId, mode, publishDone) {
|
|
4887
|
+
return this.add(new SwitchFrom(BigInt(requestId), mode, publishDone));
|
|
4888
|
+
}
|
|
4889
|
+
addFillParameters(parameters) {
|
|
4890
|
+
return this.add(new FillParameters(parameters));
|
|
4891
|
+
}
|
|
4892
|
+
addRangeFilter(filter) {
|
|
4893
|
+
return this.add(filter);
|
|
4894
|
+
}
|
|
4360
4895
|
build() {
|
|
4361
4896
|
return [...this.params];
|
|
4362
4897
|
}
|
|
@@ -4374,24 +4909,23 @@ var MessageParameters = class {
|
|
|
4374
4909
|
return result;
|
|
4375
4910
|
}
|
|
4376
4911
|
};
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
return typeValue === 16n || typeValue === 32n || typeValue === 34n;
|
|
4912
|
+
function valueShapeOf(typeValue) {
|
|
4913
|
+
switch (typeValue) {
|
|
4914
|
+
case BigInt(16):
|
|
4915
|
+
case BigInt(32):
|
|
4916
|
+
case BigInt(34):
|
|
4917
|
+
case BigInt(53): return 1;
|
|
4918
|
+
case BigInt(9): return 2;
|
|
4919
|
+
case BigInt(33): return 3;
|
|
4920
|
+
case BigInt(36):
|
|
4921
|
+
case BigInt(52):
|
|
4922
|
+
case BigInt(37):
|
|
4923
|
+
case BigInt(38):
|
|
4924
|
+
case BigInt(39):
|
|
4925
|
+
case BigInt(40):
|
|
4926
|
+
case BigInt(41): return 4;
|
|
4927
|
+
default: return typeValue % 2n === 0n ? 0 : 4;
|
|
4928
|
+
}
|
|
4395
4929
|
}
|
|
4396
4930
|
/**
|
|
4397
4931
|
* Serializes a list of message-parameter KVPs, delta-encoding the Types.
|
|
@@ -4403,12 +4937,22 @@ function serializeMessageParameterKvps(items) {
|
|
|
4403
4937
|
let prevType = 0n;
|
|
4404
4938
|
for (const kvp of sorted) {
|
|
4405
4939
|
buf.putVI(kvp.typeValue - prevType);
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4940
|
+
switch (valueShapeOf(kvp.typeValue)) {
|
|
4941
|
+
case 1:
|
|
4942
|
+
if (!isVarInt(kvp) || kvp.value < 0n || kvp.value > 255n) throw new ProtocolViolationError("serializeMessageParameterKvps", `uint8 parameter 0x${kvp.typeValue.toString(16)} value ${kvp.value} exceeds 255`);
|
|
4943
|
+
buf.putU8(Number(kvp.value));
|
|
4944
|
+
break;
|
|
4945
|
+
case 2:
|
|
4946
|
+
case 3:
|
|
4947
|
+
if (isBytes(kvp)) buf.putBytes(kvp.value);
|
|
4948
|
+
break;
|
|
4949
|
+
case 4:
|
|
4950
|
+
if (isBytes(kvp)) buf.putLengthPrefixedBytes(kvp.value);
|
|
4951
|
+
break;
|
|
4952
|
+
case 0:
|
|
4953
|
+
if (isVarInt(kvp)) buf.putVI(kvp.value);
|
|
4954
|
+
break;
|
|
4955
|
+
}
|
|
4412
4956
|
prevType = kvp.typeValue;
|
|
4413
4957
|
}
|
|
4414
4958
|
return buf.freeze();
|
|
@@ -4419,33 +4963,53 @@ function serializeMessageParameterKvps(items) {
|
|
|
4419
4963
|
*/
|
|
4420
4964
|
function deserializeMessageParameterKvps(buf, count) {
|
|
4421
4965
|
const n = typeof count === "bigint" ? Number(count) : count;
|
|
4422
|
-
|
|
4966
|
+
let read = 0;
|
|
4967
|
+
return readMessageParameterKvps(buf, () => read++ < n);
|
|
4968
|
+
}
|
|
4969
|
+
function readMessageParameterKvps(buf, more) {
|
|
4970
|
+
const items = [];
|
|
4423
4971
|
let prevType = 0n;
|
|
4424
|
-
|
|
4972
|
+
while (more()) {
|
|
4425
4973
|
const typeValue = prevType + buf.getVI();
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4974
|
+
switch (valueShapeOf(typeValue)) {
|
|
4975
|
+
case 1:
|
|
4976
|
+
items.push(KeyValuePair.newVarInt(typeValue, BigInt(buf.getU8())));
|
|
4977
|
+
break;
|
|
4978
|
+
case 2: {
|
|
4979
|
+
const loc = new ByteBuffer();
|
|
4980
|
+
loc.putVI(buf.getVI());
|
|
4981
|
+
loc.putVI(buf.getVI());
|
|
4982
|
+
items.push(KeyValuePair.newBytes(typeValue, loc.toUint8Array()));
|
|
4983
|
+
break;
|
|
4984
|
+
}
|
|
4985
|
+
case 3:
|
|
4986
|
+
items.push(KeyValuePair.newBytes(typeValue, LocationFilter.deserializeValue(buf).serializeValue()));
|
|
4987
|
+
break;
|
|
4988
|
+
case 4:
|
|
4989
|
+
items.push(KeyValuePair.deserializeBytesValue(buf, typeValue));
|
|
4990
|
+
break;
|
|
4991
|
+
case 0:
|
|
4992
|
+
items.push(KeyValuePair.tryNewVarInt(typeValue, buf.getVI()));
|
|
4993
|
+
break;
|
|
4994
|
+
}
|
|
4433
4995
|
prevType = typeValue;
|
|
4434
4996
|
}
|
|
4435
4997
|
return items;
|
|
4436
4998
|
}
|
|
4437
4999
|
/**
|
|
4438
5000
|
* Applies a set of parameter updates to an existing parameter list.
|
|
4439
|
-
*
|
|
4440
|
-
*
|
|
5001
|
+
*
|
|
5002
|
+
* A Type the update leaves out keeps its value. A Type it carries is replaced
|
|
5003
|
+
* outright, every instance of it: a Range Filter can repeat, and an update that
|
|
5004
|
+
* names a filter kind states the whole of that kind, so one left over from before
|
|
5005
|
+
* would quietly widen or narrow what the subscriber asked for. A zero-length Range
|
|
5006
|
+
* Filter replaces its kind with nothing.
|
|
4441
5007
|
*/
|
|
4442
5008
|
function applyMessageParameterUpdate(current, updates) {
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
else current.push(update);
|
|
4448
|
-
}
|
|
5009
|
+
const typeOf = (p) => p.toKeyValuePair().typeValue;
|
|
5010
|
+
const updated = new Set(updates.map(typeOf));
|
|
5011
|
+
const kept = current.filter((p) => !updated.has(typeOf(p)));
|
|
5012
|
+
current.splice(0, current.length, ...kept, ...updates.filter((u) => !(u instanceof RangeFilter && u.isRemoval)));
|
|
4449
5013
|
}
|
|
4450
5014
|
//#endregion
|
|
4451
5015
|
//#region src/model/control/publish_namespace.ts
|
|
@@ -4642,11 +5206,10 @@ var NamespaceDone = class NamespaceDone {
|
|
|
4642
5206
|
* limitations under the License.
|
|
4643
5207
|
*/
|
|
4644
5208
|
/**
|
|
4645
|
-
* The first message each endpoint sends on its control stream
|
|
5209
|
+
* The first message each endpoint sends on its control stream.
|
|
4646
5210
|
*
|
|
4647
5211
|
* Both peers send the same message; there are no separate client and server forms and
|
|
4648
|
-
* no version fields, since version negotiation happens over ALPN
|
|
4649
|
-
* CLIENT_SETUP / SERVER_SETUP.
|
|
5212
|
+
* no version fields, since version negotiation happens over ALPN.
|
|
4650
5213
|
*
|
|
4651
5214
|
* Some options are client-only (see {@link SetupOptionType}); whether a peer is
|
|
4652
5215
|
* allowed to send a given option depends on which side it is and on the transport,
|
|
@@ -4694,13 +5257,20 @@ var Setup = class Setup {
|
|
|
4694
5257
|
*/
|
|
4695
5258
|
var Fetch = class Fetch {
|
|
4696
5259
|
requestId;
|
|
4697
|
-
|
|
5260
|
+
fullTrackName;
|
|
4698
5261
|
parameters;
|
|
4699
|
-
constructor(requestId,
|
|
5262
|
+
constructor(requestId, fullTrackName, parameters) {
|
|
4700
5263
|
this.requestId = requestId;
|
|
4701
|
-
this.
|
|
5264
|
+
this.fullTrackName = fullTrackName;
|
|
4702
5265
|
this.parameters = parameters;
|
|
4703
5266
|
}
|
|
5267
|
+
/**
|
|
5268
|
+
* The requested range. A FETCH without a LOCATION_FILTER parameter asks for the
|
|
5269
|
+
* whole track up to the Largest Object, the same as a {@link (LocationFilterType:enum).None} filter.
|
|
5270
|
+
*/
|
|
5271
|
+
get locationFilter() {
|
|
5272
|
+
return this.parameters.find(MessageParameter.isLocationFilter) ?? new LocationFilter(0);
|
|
5273
|
+
}
|
|
4704
5274
|
getType() {
|
|
4705
5275
|
return 22;
|
|
4706
5276
|
}
|
|
@@ -4709,19 +5279,7 @@ var Fetch = class Fetch {
|
|
|
4709
5279
|
buf.putVI(22);
|
|
4710
5280
|
const payload = new ByteBuffer();
|
|
4711
5281
|
payload.putVI(this.requestId);
|
|
4712
|
-
payload.
|
|
4713
|
-
switch (this.typeAndProps.type) {
|
|
4714
|
-
case 3:
|
|
4715
|
-
case 2:
|
|
4716
|
-
payload.putVI(this.typeAndProps.props.joiningRequestId);
|
|
4717
|
-
payload.putVI(this.typeAndProps.props.joiningStart);
|
|
4718
|
-
break;
|
|
4719
|
-
case 1:
|
|
4720
|
-
payload.putFullTrackName(this.typeAndProps.props.fullTrackName);
|
|
4721
|
-
payload.putLocation(this.typeAndProps.props.startLocation);
|
|
4722
|
-
payload.putLocation(this.typeAndProps.props.endLocation);
|
|
4723
|
-
break;
|
|
4724
|
-
}
|
|
5282
|
+
payload.putFullTrackName(this.fullTrackName);
|
|
4725
5283
|
payload.putVI(this.parameters.length);
|
|
4726
5284
|
payload.putBytes(serializeMessageParameterKvps(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4727
5285
|
const payloadBytes = payload.toUint8Array();
|
|
@@ -4732,35 +5290,10 @@ var Fetch = class Fetch {
|
|
|
4732
5290
|
}
|
|
4733
5291
|
static parsePayload(buf) {
|
|
4734
5292
|
const requestId = buf.getVI();
|
|
4735
|
-
const
|
|
4736
|
-
const fetchType = FetchType.tryFrom(fetchTypeRaw);
|
|
4737
|
-
let props;
|
|
4738
|
-
switch (fetchType) {
|
|
4739
|
-
case 3:
|
|
4740
|
-
case 2:
|
|
4741
|
-
props = {
|
|
4742
|
-
type: fetchType,
|
|
4743
|
-
props: {
|
|
4744
|
-
joiningRequestId: buf.getVI(),
|
|
4745
|
-
joiningStart: buf.getVI()
|
|
4746
|
-
}
|
|
4747
|
-
};
|
|
4748
|
-
break;
|
|
4749
|
-
case 1:
|
|
4750
|
-
props = {
|
|
4751
|
-
type: 1,
|
|
4752
|
-
props: {
|
|
4753
|
-
fullTrackName: buf.getFullTrackName(),
|
|
4754
|
-
startLocation: buf.getLocation(),
|
|
4755
|
-
endLocation: buf.getLocation()
|
|
4756
|
-
}
|
|
4757
|
-
};
|
|
4758
|
-
break;
|
|
4759
|
-
default: throw new Error(`Unknown fetch type: ${fetchType}`);
|
|
4760
|
-
}
|
|
5293
|
+
const fullTrackName = buf.getFullTrackName();
|
|
4761
5294
|
const rawParams = deserializeMessageParameterKvps(buf, buf.getNumberVI());
|
|
4762
5295
|
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
4763
|
-
return new Fetch(requestId,
|
|
5296
|
+
return new Fetch(requestId, fullTrackName, parameters);
|
|
4764
5297
|
}
|
|
4765
5298
|
};
|
|
4766
5299
|
//#endregion
|
|
@@ -4849,7 +5382,7 @@ var FetchOk = class FetchOk {
|
|
|
4849
5382
|
const MAX_NEW_SESSION_URI_LENGTH = 8192;
|
|
4850
5383
|
/**
|
|
4851
5384
|
* GOAWAY (0x10) winds down a session, or — on a request stream — migrates that one
|
|
4852
|
-
* request
|
|
5385
|
+
* request.
|
|
4853
5386
|
*/
|
|
4854
5387
|
var GoAway = class GoAway {
|
|
4855
5388
|
newSessionUri;
|
|
@@ -4859,16 +5392,10 @@ var GoAway = class GoAway {
|
|
|
4859
5392
|
* on a request stream it resets the stream with `GOING_AWAY`.
|
|
4860
5393
|
*/
|
|
4861
5394
|
timeout;
|
|
4862
|
-
|
|
4863
|
-
* The smallest peer Request ID that was not or might not have been processed. Present
|
|
4864
|
-
* only on the control stream, so a GOAWAY migrating a single request omits it.
|
|
4865
|
-
*/
|
|
4866
|
-
requestId;
|
|
4867
|
-
constructor(newSessionUri, timeout = 0n, requestId) {
|
|
5395
|
+
constructor(newSessionUri, timeout = 0n) {
|
|
4868
5396
|
if (newSessionUri && newSessionUri.length === 0) this.newSessionUri = void 0;
|
|
4869
5397
|
else this.newSessionUri = newSessionUri;
|
|
4870
5398
|
this.timeout = timeout;
|
|
4871
|
-
this.requestId = requestId;
|
|
4872
5399
|
}
|
|
4873
5400
|
getType() {
|
|
4874
5401
|
return 16;
|
|
@@ -4887,7 +5414,6 @@ var GoAway = class GoAway {
|
|
|
4887
5414
|
payload.putLengthPrefixedBytes(uriBytes);
|
|
4888
5415
|
} else payload.putVI(0);
|
|
4889
5416
|
payload.putVI(this.timeout);
|
|
4890
|
-
if (this.requestId !== void 0) payload.putVI(this.requestId);
|
|
4891
5417
|
const payloadBytes = payload.toUint8Array();
|
|
4892
5418
|
if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("GoAway::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4893
5419
|
buf.putU16(payloadBytes.length);
|
|
@@ -4908,8 +5434,7 @@ var GoAway = class GoAway {
|
|
|
4908
5434
|
}
|
|
4909
5435
|
}
|
|
4910
5436
|
const timeout = buf.getVI();
|
|
4911
|
-
|
|
4912
|
-
return new GoAway(newSessionUri, timeout, requestId);
|
|
5437
|
+
return new GoAway(newSessionUri, timeout);
|
|
4913
5438
|
}
|
|
4914
5439
|
};
|
|
4915
5440
|
//#endregion
|
|
@@ -4938,19 +5463,6 @@ var Subscribe = class Subscribe {
|
|
|
4938
5463
|
this.fullTrackName = fullTrackName;
|
|
4939
5464
|
this.parameters = parameters;
|
|
4940
5465
|
}
|
|
4941
|
-
static newNextGroupStart(requestId, fullTrackName, parameters) {
|
|
4942
|
-
return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(1)]);
|
|
4943
|
-
}
|
|
4944
|
-
static newLatestObject(requestId, fullTrackName, parameters) {
|
|
4945
|
-
return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(2)]);
|
|
4946
|
-
}
|
|
4947
|
-
static newAbsoluteStart(requestId, fullTrackName, startLocation, parameters) {
|
|
4948
|
-
return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(3, startLocation)]);
|
|
4949
|
-
}
|
|
4950
|
-
static newAbsoluteRange(requestId, fullTrackName, startLocation, endGroup, parameters) {
|
|
4951
|
-
if (endGroup < startLocation.group) throw new Error("End Group must be >= Start Group");
|
|
4952
|
-
return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(4, startLocation, endGroup)]);
|
|
4953
|
-
}
|
|
4954
5466
|
getType() {
|
|
4955
5467
|
return 3;
|
|
4956
5468
|
}
|
|
@@ -5000,6 +5512,11 @@ var PublishDone = class PublishDone {
|
|
|
5000
5512
|
statusCode;
|
|
5001
5513
|
streamCount;
|
|
5002
5514
|
errorReason;
|
|
5515
|
+
/**
|
|
5516
|
+
* The Stream Count a publisher sends when it cannot name the exact number of streams
|
|
5517
|
+
* it opened. Receivers fall back on a timeout to end the subscription.
|
|
5518
|
+
*/
|
|
5519
|
+
static UNKNOWN_STREAM_COUNT = 2n ** 64n - 1n;
|
|
5003
5520
|
constructor(statusCode, streamCount, errorReason) {
|
|
5004
5521
|
this.statusCode = statusCode;
|
|
5005
5522
|
this.streamCount = streamCount;
|
|
@@ -5238,35 +5755,18 @@ var TrackStatus = class TrackStatus {
|
|
|
5238
5755
|
subscriberPriority;
|
|
5239
5756
|
groupOrder;
|
|
5240
5757
|
forward;
|
|
5241
|
-
|
|
5242
|
-
startLocation;
|
|
5243
|
-
endGroup;
|
|
5758
|
+
locationFilter;
|
|
5244
5759
|
subscribeParameters;
|
|
5245
|
-
constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward,
|
|
5760
|
+
constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, locationFilter, subscribeParameters) {
|
|
5246
5761
|
this.requestId = requestId;
|
|
5247
5762
|
this.trackAlias = trackAlias;
|
|
5248
5763
|
this.fullTrackName = fullTrackName;
|
|
5249
5764
|
this.subscriberPriority = subscriberPriority;
|
|
5250
5765
|
this.groupOrder = groupOrder;
|
|
5251
5766
|
this.forward = forward;
|
|
5252
|
-
this.
|
|
5253
|
-
this.startLocation = startLocation;
|
|
5254
|
-
this.endGroup = endGroup;
|
|
5767
|
+
this.locationFilter = locationFilter;
|
|
5255
5768
|
this.subscribeParameters = subscribeParameters;
|
|
5256
5769
|
}
|
|
5257
|
-
static newNextGroupStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
5258
|
-
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 1, void 0, void 0, subscribeParameters);
|
|
5259
|
-
}
|
|
5260
|
-
static newLatestObject(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
5261
|
-
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 2, void 0, void 0, subscribeParameters);
|
|
5262
|
-
}
|
|
5263
|
-
static newAbsoluteStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, subscribeParameters) {
|
|
5264
|
-
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 3, startLocation, void 0, subscribeParameters);
|
|
5265
|
-
}
|
|
5266
|
-
static newAbsoluteRange(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, endGroup, subscribeParameters) {
|
|
5267
|
-
if (endGroup < startLocation.group) throw new Error("End Group must be >= Start Group");
|
|
5268
|
-
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 4, startLocation, endGroup, subscribeParameters);
|
|
5269
|
-
}
|
|
5270
5770
|
getType() {
|
|
5271
5771
|
return 13;
|
|
5272
5772
|
}
|
|
@@ -5280,15 +5780,7 @@ var TrackStatus = class TrackStatus {
|
|
|
5280
5780
|
payload.putU8(this.subscriberPriority);
|
|
5281
5781
|
payload.putU8(this.groupOrder);
|
|
5282
5782
|
payload.putU8(this.forward ? 1 : 0);
|
|
5283
|
-
payload.
|
|
5284
|
-
if (this.filterType === 3 || this.filterType === 4) {
|
|
5285
|
-
if (!this.startLocation) throw new Error("StartLocation required for selected filterType");
|
|
5286
|
-
payload.putLocation(this.startLocation);
|
|
5287
|
-
}
|
|
5288
|
-
if (this.filterType === 4) {
|
|
5289
|
-
if (this.endGroup == null) throw new Error("EndGroup required for AbsoluteRange");
|
|
5290
|
-
payload.putVI(this.endGroup);
|
|
5291
|
-
}
|
|
5783
|
+
payload.putBytes(this.locationFilter.serializeValue());
|
|
5292
5784
|
payload.putVI(this.subscribeParameters.length);
|
|
5293
5785
|
payload.putBytes(serializeMessageParameterKvps(this.subscribeParameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
5294
5786
|
const payloadBytes = payload.toUint8Array();
|
|
@@ -5303,14 +5795,10 @@ var TrackStatus = class TrackStatus {
|
|
|
5303
5795
|
const subscriberPriority = buf.getU8();
|
|
5304
5796
|
const groupOrder = buf.getU8();
|
|
5305
5797
|
const forward = buf.getU8() === 1;
|
|
5306
|
-
const
|
|
5307
|
-
let startLocation = void 0;
|
|
5308
|
-
let endGroup = void 0;
|
|
5309
|
-
if (filterType === 3 || filterType === 4) startLocation = buf.getLocation();
|
|
5310
|
-
if (filterType === 4) endGroup = buf.getVI();
|
|
5798
|
+
const locationFilter = LocationFilter.deserializeValue(buf);
|
|
5311
5799
|
const rawParams = deserializeMessageParameterKvps(buf, Number(buf.getVI()));
|
|
5312
5800
|
const subscribeParameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
5313
|
-
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward,
|
|
5801
|
+
return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, locationFilter, subscribeParameters);
|
|
5314
5802
|
}
|
|
5315
5803
|
};
|
|
5316
5804
|
//#endregion
|
|
@@ -5446,13 +5934,12 @@ var SubscribeTracks = class SubscribeTracks {
|
|
|
5446
5934
|
* names (PUBLISH_OK, TRACK_STATUS_OK, ...) are shorthands for logging, not distinct
|
|
5447
5935
|
* messages. SUBSCRIBE_OK (0x4) and FETCH_OK (0x18) do keep bodies of their own.
|
|
5448
5936
|
*
|
|
5449
|
-
* It carries no Request ID: the request stream it arrives on identifies the request
|
|
5450
|
-
* (§10.1).
|
|
5937
|
+
* It carries no Request ID: the request stream it arrives on identifies the request.
|
|
5451
5938
|
*/
|
|
5452
5939
|
var RequestOk = class RequestOk {
|
|
5453
5940
|
parameters;
|
|
5454
5941
|
/**
|
|
5455
|
-
*
|
|
5942
|
+
* Track Properties, which the trailing bytes of the payload carry with no
|
|
5456
5943
|
* count of their own. Populated only in TRACK_STATUS_OK; empty for every other request
|
|
5457
5944
|
* type — see {@link RequestOk.validateTrackProperties}.
|
|
5458
5945
|
*/
|
|
@@ -5614,7 +6101,7 @@ let ControlMessage;
|
|
|
5614
6101
|
case 80: return SubscribeNamespace.parsePayload(payload);
|
|
5615
6102
|
case 81: return SubscribeTracks.parsePayload(payload);
|
|
5616
6103
|
case 12032: return Setup.parsePayload(payload);
|
|
5617
|
-
case 15: return
|
|
6104
|
+
case 15: return PublishSkipped.parsePayload(payload);
|
|
5618
6105
|
default: throw new Error(`Unknown or unhandled ControlMessageType: ${messageType}`);
|
|
5619
6106
|
}
|
|
5620
6107
|
}
|
|
@@ -5793,59 +6280,6 @@ var CMSFCatalog = class CMSFCatalog {
|
|
|
5793
6280
|
}
|
|
5794
6281
|
};
|
|
5795
6282
|
//#endregion
|
|
5796
|
-
//#region src/model/control/switch.ts
|
|
5797
|
-
/**
|
|
5798
|
-
* Copyright 2025 The MOQtail Authors
|
|
5799
|
-
*
|
|
5800
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5801
|
-
* you may not use this file except in compliance with the License.
|
|
5802
|
-
* You may obtain a copy of the License at
|
|
5803
|
-
*
|
|
5804
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5805
|
-
*
|
|
5806
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5807
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5808
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5809
|
-
* See the License for the specific language governing permissions and
|
|
5810
|
-
* limitations under the License.
|
|
5811
|
-
*/
|
|
5812
|
-
var Switch = class Switch {
|
|
5813
|
-
requestId;
|
|
5814
|
-
fullTrackName;
|
|
5815
|
-
subscriptionRequestId;
|
|
5816
|
-
parameters;
|
|
5817
|
-
constructor(requestId, fullTrackName, subscriptionRequestId, parameters) {
|
|
5818
|
-
this.requestId = requestId;
|
|
5819
|
-
this.fullTrackName = fullTrackName;
|
|
5820
|
-
this.subscriptionRequestId = subscriptionRequestId;
|
|
5821
|
-
this.parameters = parameters;
|
|
5822
|
-
}
|
|
5823
|
-
getType() {
|
|
5824
|
-
return 34;
|
|
5825
|
-
}
|
|
5826
|
-
serialize() {
|
|
5827
|
-
const buf = new ByteBuffer();
|
|
5828
|
-
buf.putVI(34);
|
|
5829
|
-
const payload = new ByteBuffer();
|
|
5830
|
-
payload.putVI(this.requestId);
|
|
5831
|
-
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
5832
|
-
payload.putVI(this.subscriptionRequestId);
|
|
5833
|
-
payload.putVI(this.parameters.length);
|
|
5834
|
-
payload.putBytes(serializeMessageParameterKvps(this.parameters).toUint8Array());
|
|
5835
|
-
const payloadBytes = payload.toUint8Array();
|
|
5836
|
-
buf.putU16(payloadBytes.length);
|
|
5837
|
-
buf.putBytes(payloadBytes);
|
|
5838
|
-
return buf.freeze();
|
|
5839
|
-
}
|
|
5840
|
-
static parsePayload(buf) {
|
|
5841
|
-
const requestId = buf.getVI();
|
|
5842
|
-
const fullTrackName = buf.getFullTrackName();
|
|
5843
|
-
const subscriptionRequestId = buf.getVI();
|
|
5844
|
-
const parameters = deserializeMessageParameterKvps(buf, Number(buf.getVI()));
|
|
5845
|
-
return new Switch(requestId, fullTrackName, subscriptionRequestId, parameters);
|
|
5846
|
-
}
|
|
5847
|
-
};
|
|
5848
|
-
//#endregion
|
|
5849
6283
|
//#region src/model/parameter/setup/path.ts
|
|
5850
6284
|
/**
|
|
5851
6285
|
* Copyright 2025 The MOQtail Authors
|
|
@@ -5928,7 +6362,7 @@ var MaxAuthTokenCacheSize = class MaxAuthTokenCacheSize {
|
|
|
5928
6362
|
*/
|
|
5929
6363
|
/**
|
|
5930
6364
|
* Raw-QUIC only: the authority component of the `moqt://` URI, carried in SETUP because
|
|
5931
|
-
* there is no HTTP CONNECT to carry it
|
|
6365
|
+
* there is no HTTP CONNECT to carry it.
|
|
5932
6366
|
*
|
|
5933
6367
|
* Client-only; MUST NOT be sent by a server or over WebTransport. moqtail-ts always
|
|
5934
6368
|
* connects over WebTransport, so its own handshake never sends this — see
|
|
@@ -5951,6 +6385,42 @@ var Authority = class Authority {
|
|
|
5951
6385
|
}
|
|
5952
6386
|
};
|
|
5953
6387
|
//#endregion
|
|
6388
|
+
//#region src/model/parameter/setup/max_filter_ranges.ts
|
|
6389
|
+
/**
|
|
6390
|
+
* Copyright 2026 The MOQtail Authors
|
|
6391
|
+
*
|
|
6392
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6393
|
+
* you may not use this file except in compliance with the License.
|
|
6394
|
+
* You may obtain a copy of the License at
|
|
6395
|
+
*
|
|
6396
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6397
|
+
*
|
|
6398
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6399
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6400
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6401
|
+
* See the License for the specific language governing permissions and
|
|
6402
|
+
* limitations under the License.
|
|
6403
|
+
*/
|
|
6404
|
+
/**
|
|
6405
|
+
* Limits the total number of Ranges the peer may have across all Range filter parameters
|
|
6406
|
+
* of a single subscription or fetch. Zero, the default when absent, means the peer may
|
|
6407
|
+
* not send Range filters at all.
|
|
6408
|
+
*/
|
|
6409
|
+
var MaxFilterRanges = class MaxFilterRanges {
|
|
6410
|
+
value;
|
|
6411
|
+
static TYPE = 6;
|
|
6412
|
+
constructor(value) {
|
|
6413
|
+
this.value = value;
|
|
6414
|
+
}
|
|
6415
|
+
toKeyValuePair() {
|
|
6416
|
+
return KeyValuePair.tryNewVarInt(MaxFilterRanges.TYPE, this.value);
|
|
6417
|
+
}
|
|
6418
|
+
static fromKeyValuePair(pair) {
|
|
6419
|
+
if (Number(pair.typeValue) !== MaxFilterRanges.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
6420
|
+
return new MaxFilterRanges(pair.value);
|
|
6421
|
+
}
|
|
6422
|
+
};
|
|
6423
|
+
//#endregion
|
|
5954
6424
|
//#region src/model/parameter/setup/moqt_implementation.ts
|
|
5955
6425
|
/**
|
|
5956
6426
|
* Copyright 2026 The MOQtail Authors
|
|
@@ -5968,8 +6438,8 @@ var Authority = class Authority {
|
|
|
5968
6438
|
* limitations under the License.
|
|
5969
6439
|
*/
|
|
5970
6440
|
/**
|
|
5971
|
-
* Free-form implementation identification string, e.g. for logging and debugging
|
|
5972
|
-
*
|
|
6441
|
+
* Free-form implementation identification string, e.g. for logging and debugging.
|
|
6442
|
+
* Either peer may send it.
|
|
5973
6443
|
*/
|
|
5974
6444
|
var MoqtImplementation = class MoqtImplementation {
|
|
5975
6445
|
info;
|
|
@@ -5988,6 +6458,42 @@ var MoqtImplementation = class MoqtImplementation {
|
|
|
5988
6458
|
}
|
|
5989
6459
|
};
|
|
5990
6460
|
//#endregion
|
|
6461
|
+
//#region src/model/parameter/setup/max_request_updates.ts
|
|
6462
|
+
/**
|
|
6463
|
+
* Copyright 2026 The MOQtail Authors
|
|
6464
|
+
*
|
|
6465
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6466
|
+
* you may not use this file except in compliance with the License.
|
|
6467
|
+
* You may obtain a copy of the License at
|
|
6468
|
+
*
|
|
6469
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6470
|
+
*
|
|
6471
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6472
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6473
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6474
|
+
* See the License for the specific language governing permissions and
|
|
6475
|
+
* limitations under the License.
|
|
6476
|
+
*/
|
|
6477
|
+
/**
|
|
6478
|
+
* Maximum number of outstanding REQUEST_UPDATEs per request stream: an update counts
|
|
6479
|
+
* until its REQUEST_OK or REQUEST_ERROR arrives. Zero, the default when absent, means
|
|
6480
|
+
* no limit. Receiving one past the limit closes the session with TOO_MANY_REQUEST_UPDATES.
|
|
6481
|
+
*/
|
|
6482
|
+
var MaxRequestUpdates = class MaxRequestUpdates {
|
|
6483
|
+
value;
|
|
6484
|
+
static TYPE = 8;
|
|
6485
|
+
constructor(value) {
|
|
6486
|
+
this.value = value;
|
|
6487
|
+
}
|
|
6488
|
+
toKeyValuePair() {
|
|
6489
|
+
return KeyValuePair.tryNewVarInt(MaxRequestUpdates.TYPE, this.value);
|
|
6490
|
+
}
|
|
6491
|
+
static fromKeyValuePair(pair) {
|
|
6492
|
+
if (Number(pair.typeValue) !== MaxRequestUpdates.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
6493
|
+
return new MaxRequestUpdates(pair.value);
|
|
6494
|
+
}
|
|
6495
|
+
};
|
|
6496
|
+
//#endregion
|
|
5991
6497
|
//#region src/model/parameter/setup/ssts_algorithms.ts
|
|
5992
6498
|
/**
|
|
5993
6499
|
* Copyright 2026 The MOQtail Authors
|
|
@@ -6009,7 +6515,7 @@ var MoqtImplementation = class MoqtImplementation {
|
|
|
6009
6515
|
*
|
|
6010
6516
|
* PROVISIONAL: sender-side track switching is not an adopted extension, so
|
|
6011
6517
|
* this option has no codepoint in the registry the conformance fixture tracks
|
|
6012
|
-
* (`dev/conformance/
|
|
6518
|
+
* (`dev/conformance/draft22`) and is never asserted against it. An empty list
|
|
6013
6519
|
* — or the absence of the option — prohibits the use of SSTS.
|
|
6014
6520
|
*/
|
|
6015
6521
|
var SstsAlgorithms = class SstsAlgorithms {
|
|
@@ -6037,7 +6543,7 @@ var SstsAlgorithms = class SstsAlgorithms {
|
|
|
6037
6543
|
let SetupOption;
|
|
6038
6544
|
(function(_SetupOption) {
|
|
6039
6545
|
function fromKeyValuePair(pair) {
|
|
6040
|
-
return Path.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair) || Authority.fromKeyValuePair(pair) || MoqtImplementation.fromKeyValuePair(pair) || SstsAlgorithms.fromKeyValuePair(pair);
|
|
6546
|
+
return Path.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair) || Authority.fromKeyValuePair(pair) || MaxFilterRanges.fromKeyValuePair(pair) || MoqtImplementation.fromKeyValuePair(pair) || MaxRequestUpdates.fromKeyValuePair(pair) || SstsAlgorithms.fromKeyValuePair(pair);
|
|
6041
6547
|
}
|
|
6042
6548
|
_SetupOption.fromKeyValuePair = fromKeyValuePair;
|
|
6043
6549
|
function toKeyValuePair(param) {
|
|
@@ -6060,6 +6566,14 @@ let SetupOption;
|
|
|
6060
6566
|
return param instanceof Authority;
|
|
6061
6567
|
}
|
|
6062
6568
|
_SetupOption.isAuthority = isAuthority;
|
|
6569
|
+
function isMaxFilterRanges(param) {
|
|
6570
|
+
return param instanceof MaxFilterRanges;
|
|
6571
|
+
}
|
|
6572
|
+
_SetupOption.isMaxFilterRanges = isMaxFilterRanges;
|
|
6573
|
+
function isMaxRequestUpdates(param) {
|
|
6574
|
+
return param instanceof MaxRequestUpdates;
|
|
6575
|
+
}
|
|
6576
|
+
_SetupOption.isMaxRequestUpdates = isMaxRequestUpdates;
|
|
6063
6577
|
function isMoqtImplementation(param) {
|
|
6064
6578
|
return param instanceof MoqtImplementation;
|
|
6065
6579
|
}
|
|
@@ -6071,7 +6585,7 @@ let SetupOption;
|
|
|
6071
6585
|
})(SetupOption || (SetupOption = {}));
|
|
6072
6586
|
/** Throws if `params` carries AUTHORITY, which MUST NOT be sent over WebTransport. */
|
|
6073
6587
|
function assertNoAuthorityOverWebTransport(params) {
|
|
6074
|
-
if (params.some((p) => Number(p.typeValue) === 5)) throw new ProtocolViolationError("assertNoAuthorityOverWebTransport", "AUTHORITY setup option MUST NOT be sent over WebTransport
|
|
6588
|
+
if (params.some((p) => Number(p.typeValue) === 5)) throw new ProtocolViolationError("assertNoAuthorityOverWebTransport", "AUTHORITY setup option MUST NOT be sent over WebTransport");
|
|
6075
6589
|
}
|
|
6076
6590
|
var SetupOptions = class {
|
|
6077
6591
|
kvps = [];
|
|
@@ -6087,6 +6601,14 @@ var SetupOptions = class {
|
|
|
6087
6601
|
this.kvps.push(auth.toKeyValuePair());
|
|
6088
6602
|
return this;
|
|
6089
6603
|
}
|
|
6604
|
+
addMaxFilterRanges(value) {
|
|
6605
|
+
this.kvps.push(new MaxFilterRanges(BigInt(value)).toKeyValuePair());
|
|
6606
|
+
return this;
|
|
6607
|
+
}
|
|
6608
|
+
addMaxRequestUpdates(value) {
|
|
6609
|
+
this.kvps.push(new MaxRequestUpdates(BigInt(value)).toKeyValuePair());
|
|
6610
|
+
return this;
|
|
6611
|
+
}
|
|
6090
6612
|
addMoqtImplementation(info) {
|
|
6091
6613
|
this.kvps.push(new MoqtImplementation(info).toKeyValuePair());
|
|
6092
6614
|
return this;
|
|
@@ -6105,11 +6627,130 @@ var SetupOptions = class {
|
|
|
6105
6627
|
static fromKeyValuePairs(kvps) {
|
|
6106
6628
|
const result = [];
|
|
6107
6629
|
for (const kvp of kvps) {
|
|
6108
|
-
const parsed = Path.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp) || Authority.fromKeyValuePair(kvp) || MoqtImplementation.fromKeyValuePair(kvp) || SstsAlgorithms.fromKeyValuePair(kvp);
|
|
6630
|
+
const parsed = Path.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp) || Authority.fromKeyValuePair(kvp) || MaxFilterRanges.fromKeyValuePair(kvp) || MoqtImplementation.fromKeyValuePair(kvp) || MaxRequestUpdates.fromKeyValuePair(kvp) || SstsAlgorithms.fromKeyValuePair(kvp);
|
|
6109
6631
|
if (parsed) result.push(parsed);
|
|
6110
6632
|
}
|
|
6111
6633
|
return result;
|
|
6112
6634
|
}
|
|
6113
6635
|
};
|
|
6114
6636
|
//#endregion
|
|
6115
|
-
|
|
6637
|
+
//#region src/model/parameter/message/combined_filter.ts
|
|
6638
|
+
/**
|
|
6639
|
+
* Copyright 2026 The MOQtail Authors
|
|
6640
|
+
*
|
|
6641
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6642
|
+
* you may not use this file except in compliance with the License.
|
|
6643
|
+
* You may obtain a copy of the License at
|
|
6644
|
+
*
|
|
6645
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6646
|
+
*
|
|
6647
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6648
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6649
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6650
|
+
* See the License for the specific language governing permissions and
|
|
6651
|
+
* limitations under the License.
|
|
6652
|
+
*/
|
|
6653
|
+
const within = (ranges, value) => ranges.some((r) => value >= r.start && (r.end === void 0 || value <= r.end));
|
|
6654
|
+
/**
|
|
6655
|
+
* The object filter a request's Range Filters add up to.
|
|
6656
|
+
*
|
|
6657
|
+
* Ranges within one filter are OR'd, filters sharing a SetID are AND'd, and the
|
|
6658
|
+
* SetIDs are OR'd with each other. No filter at all passes every Object.
|
|
6659
|
+
*/
|
|
6660
|
+
var CombinedFilter = class {
|
|
6661
|
+
#sets = /* @__PURE__ */ new Map();
|
|
6662
|
+
/** How many Ranges the filters hold, which is what a range limit counts. */
|
|
6663
|
+
rangeCount;
|
|
6664
|
+
/**
|
|
6665
|
+
* Builds the filter from every Range Filter in `params`; anything else, and a
|
|
6666
|
+
* zero-length removal, is ignored.
|
|
6667
|
+
*
|
|
6668
|
+
* @throws :{@link InvalidFilterError} For a filter that cannot be applied: one
|
|
6669
|
+
* that repeats a Type, SetID and Property Type already given, one with an odd
|
|
6670
|
+
* Property Type, a priority above 255 or a bound past 2^64-1, or a track filter,
|
|
6671
|
+
* which selects tracks rather than Objects.
|
|
6672
|
+
*/
|
|
6673
|
+
constructor(params) {
|
|
6674
|
+
let rangeCount = 0;
|
|
6675
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6676
|
+
for (const param of params) {
|
|
6677
|
+
if (!(param instanceof RangeFilter) || param.isRemoval) continue;
|
|
6678
|
+
const filter = param;
|
|
6679
|
+
if (filter.kind === RangeFilterKind.TrackProperty) throw new InvalidFilterError("CombinedFilter", "a track property filter selects tracks, not Objects");
|
|
6680
|
+
const key = `${filter.kind}/${filter.setId}/${filter.propertyType ?? ""}`;
|
|
6681
|
+
if (seen.has(key)) throw new InvalidFilterError("CombinedFilter", `${RangeFilterKind[filter.kind]} filter repeats SetID ${filter.setId}` + (filter.propertyType !== void 0 ? ` for property 0x${filter.propertyType.toString(16)}` : ""));
|
|
6682
|
+
seen.add(key);
|
|
6683
|
+
const ranges = filter.validate();
|
|
6684
|
+
rangeCount += ranges.length;
|
|
6685
|
+
let set = this.#sets.get(filter.setId);
|
|
6686
|
+
if (!set) {
|
|
6687
|
+
set = { properties: /* @__PURE__ */ new Map() };
|
|
6688
|
+
this.#sets.set(filter.setId, set);
|
|
6689
|
+
}
|
|
6690
|
+
switch (filter.kind) {
|
|
6691
|
+
case RangeFilterKind.Subgroup:
|
|
6692
|
+
set.subgroup = ranges;
|
|
6693
|
+
break;
|
|
6694
|
+
case RangeFilterKind.ObjectId:
|
|
6695
|
+
set.objectId = ranges;
|
|
6696
|
+
break;
|
|
6697
|
+
case RangeFilterKind.Priority:
|
|
6698
|
+
set.priority = ranges;
|
|
6699
|
+
break;
|
|
6700
|
+
case RangeFilterKind.ObjectProperty:
|
|
6701
|
+
set.properties.set(filter.propertyType, ranges);
|
|
6702
|
+
break;
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
this.rangeCount = rangeCount;
|
|
6706
|
+
}
|
|
6707
|
+
/** Whether the filter passes everything. */
|
|
6708
|
+
get isEmpty() {
|
|
6709
|
+
return this.#sets.size === 0;
|
|
6710
|
+
}
|
|
6711
|
+
/**
|
|
6712
|
+
* Whether `obj` passes.
|
|
6713
|
+
*
|
|
6714
|
+
* @param subgroupId - The Subgroup ID `obj` travels in. It is passed in because an
|
|
6715
|
+
* Object whose Subgroup ID is its subgroup's first Object ID does not know it
|
|
6716
|
+
* itself. `null` — a datagram — has no subgroup, so no subgroup filter passes it.
|
|
6717
|
+
*/
|
|
6718
|
+
matches(obj, subgroupId = obj.subgroupId) {
|
|
6719
|
+
if (this.isEmpty) return true;
|
|
6720
|
+
for (const set of this.#sets.values()) {
|
|
6721
|
+
if (set.subgroup && (subgroupId === null || !within(set.subgroup, subgroupId))) continue;
|
|
6722
|
+
if (set.objectId && !within(set.objectId, obj.location.object)) continue;
|
|
6723
|
+
if (set.priority && !within(set.priority, BigInt(obj.publisherPriority))) continue;
|
|
6724
|
+
if (!propertiesPass(set.properties, obj.properties)) continue;
|
|
6725
|
+
return true;
|
|
6726
|
+
}
|
|
6727
|
+
return false;
|
|
6728
|
+
}
|
|
6729
|
+
};
|
|
6730
|
+
/**
|
|
6731
|
+
* Whether each required Property is present with a value in its Ranges. One the
|
|
6732
|
+
* Object does not carry fails. Properties inside ImmutableProperties count as the
|
|
6733
|
+
* Object's own.
|
|
6734
|
+
*/
|
|
6735
|
+
function propertiesPass(required, properties) {
|
|
6736
|
+
if (required.size === 0) return true;
|
|
6737
|
+
const values = /* @__PURE__ */ new Map();
|
|
6738
|
+
const collect = (pairs) => {
|
|
6739
|
+
for (const pair of pairs) {
|
|
6740
|
+
if (isVarInt(pair)) {
|
|
6741
|
+
if (!values.has(pair.typeValue)) values.set(pair.typeValue, pair.value);
|
|
6742
|
+
continue;
|
|
6743
|
+
}
|
|
6744
|
+
const immutable = ImmutablePropertiesObjectProperty.fromKeyValuePair(pair);
|
|
6745
|
+
if (immutable) collect(immutable.properties);
|
|
6746
|
+
}
|
|
6747
|
+
};
|
|
6748
|
+
collect(properties ?? []);
|
|
6749
|
+
for (const [type, ranges] of required) {
|
|
6750
|
+
const value = values.get(type);
|
|
6751
|
+
if (value === void 0 || !within(ranges, value)) return false;
|
|
6752
|
+
}
|
|
6753
|
+
return true;
|
|
6754
|
+
}
|
|
6755
|
+
//#endregion
|
|
6756
|
+
export { AudioLevel, Authority, AuthorizationToken, BaseByteBuffer, ByteBuffer, CMSFCatalog, CastingError, CombinedFilter, ControlMessage, ControlMessageType, DEFAULT_PUBLISHER_PRIORITY, Datagram, DefaultPublisherGroupOrderProperty, DefaultPublisherPriorityProperty, DynamicGroupsProperty, EndOfRangeKind, Expires, Fetch, FetchHeader, FetchHeaderType, FetchObject, FetchOk, FillParameters, FillTimeout, Forward, FrozenByteBuffer, FullTrackName, GREASE_BASE, GREASE_STEP, GoAway, GroupOrder, GroupOrderParam, Header, ImmutablePropertiesObjectProperty, ImmutablePropertiesTrackProperty, IncludeProperties, InternalError, InvalidEnumValue, InvalidFilterError, InvalidTypeError, InvalidUTF8Error, KeyValueFormattingError, KeyValuePair, LOCProperties, LOCProperty, LOCPropertyId, LargestObject, LengthExceedsMaxError, Location, LocationFilter, LocationFilterType, MAX_FULL_TRACK_NAME_LENGTH, MAX_NAMESPACE_TUPLE_COUNT, MAX_NEW_SESSION_URI_LENGTH, MAX_REASON_PHRASE_LEN, MOQtailError, MaxAuthTokenCacheSize, MaxCacheDurationProperty, MaxFilterRanges, MaxRequestUpdates, MessageParameter, MessageParameterType, MessageParameters, MoqtImplementation, MoqtObject, MoqtUrl, Namespace, NamespaceDone, NewGroupRequest, NotEnoughBytesError, ObjectDatagramType, ObjectDeliveryTimeout, ObjectDeliveryTimeoutProperty, ObjectForwardingPreference, ObjectProperty, ObjectStatus, Path, PriorGroupIdGapProperty, PriorObjectIdGapProperty, PropertyRanges, ProtocolViolationError, Publish, PublishDone, PublishDoneStatusCode, PublishNamespace, PublishSkipped, RangeFilter, RangeFilterKind, ReasonPhrase, Redirect, RendezvousTimeout, RequestError, RequestErrorCode, RequestIdError, RequestIdMap, RequestOk, RequestUpdate, SUPPORTED_VERSIONS, Setup, SetupOption, SetupOptionType, SetupOptions, SstsAlgorithms, StreamResetCode, SubgroupDeliveryTimeout, SubgroupDeliveryTimeoutProperty, SubgroupHeader, SubgroupHeaderType, SubgroupObject, Subscribe, SubscribeNamespace, SubscribeOk, SubscribeTracks, SubscriberPriority, SwitchFrom, SwitchMode, SwitchingSetAssignment, TerminationCode, TerminationError, TimeoutError, Timescale, Timestamp, TokenAliasType, TrackNameError, TrackProperty, TrackPropertyType, TrackStatus, TrackStatusCode, Tuple, TupleField, UnknownObjectProperty, UnknownTrackProperty, VarIntOverflowError, VideoConfig, VideoFrameMarking, applyMessageParameterUpdate, assertNoAuthorityOverWebTransport, deserializeKvpList, deserializeKvpListUntilEmpty, deserializeMessageParameterKvps, encodeRanges, greaseValue, isApplicationSpecificProperty, isBytes, isGrease, isVarInt, locPropertyIdFromNumber, messageParameterTypeFromNumber, resolveTransportUrl, serializeKvpList, serializeMessageParameterKvps, setupOptionTypeFromNumber, tokenAliasTypeFromNumber };
|