moqtail 0.16.0 → 0.17.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/dist/model.mjs CHANGED
@@ -1232,6 +1232,267 @@ let ObjectStatus = /* @__PURE__ */ function(ObjectStatus) {
1232
1232
  }
1233
1233
  _ObjectStatus.tryFrom = tryFrom;
1234
1234
  })(ObjectStatus || (ObjectStatus = {}));
1235
+ // src/model/common/grease.ts
1236
+ /**
1237
+ * Copyright 2026 The MOQtail Authors
1238
+ *
1239
+ * Licensed under the Apache License, Version 2.0 (the "License");
1240
+ * you may not use this file except in compliance with the License.
1241
+ * You may obtain a copy of the License at
1242
+ *
1243
+ * http://www.apache.org/licenses/LICENSE-2.0
1244
+ *
1245
+ * Unless required by applicable law or agreed to in writing, software
1246
+ * distributed under the License is distributed on an "AS IS" BASIS,
1247
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1248
+ * See the License for the specific language governing permissions and
1249
+ * limitations under the License.
1250
+ */
1251
+ /**
1252
+ * GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
1253
+ * several registries (Setup Options, Properties, error codes) so peers can emit them
1254
+ * to exercise unknown-value handling. Receivers treat them like any other unknown
1255
+ * value: ignore, never fatal.
1256
+ */
1257
+ /** Step between successive GREASE values. */
1258
+ const GREASE_STEP = 127n;
1259
+ /** The smallest GREASE value (N = 0). */
1260
+ const GREASE_BASE = 157n;
1261
+ /** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
1262
+ const GREASE_MAX = 4611686018427387870n;
1263
+ /**
1264
+ * @public
1265
+ * True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
1266
+ * non-negative `N`.
1267
+ */
1268
+ function isGrease(value) {
1269
+ const v = BigInt(value);
1270
+ return v >= 157n && (v - 157n) % 127n === 0n;
1271
+ }
1272
+ /**
1273
+ * @public
1274
+ * The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
1275
+ * varint can carry (the pattern is capped at `0x3fffffffffffffde`).
1276
+ */
1277
+ function greaseValue(n) {
1278
+ const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
1279
+ return value > GREASE_MAX ? void 0 : value;
1280
+ }
1281
+ // src/model/property/constant.ts
1282
+ /**
1283
+ * Copyright 2025 The MOQtail Authors
1284
+ *
1285
+ * Licensed under the Apache License, Version 2.0 (the "License");
1286
+ * you may not use this file except in compliance with the License.
1287
+ * You may obtain a copy of the License at
1288
+ *
1289
+ * http://www.apache.org/licenses/LICENSE-2.0
1290
+ *
1291
+ * Unless required by applicable law or agreed to in writing, software
1292
+ * distributed under the License is distributed on an "AS IS" BASIS,
1293
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1294
+ * See the License for the specific language governing permissions and
1295
+ * limitations under the License.
1296
+ */
1297
+ let LOCPropertyId = /* @__PURE__ */ function(LOCPropertyId) {
1298
+ LOCPropertyId[LOCPropertyId["Timescale"] = 8] = "Timescale";
1299
+ LOCPropertyId[LOCPropertyId["VideoFrameMarking"] = 9] = "VideoFrameMarking";
1300
+ LOCPropertyId[LOCPropertyId["AudioLevel"] = 12] = "AudioLevel";
1301
+ LOCPropertyId[LOCPropertyId["VideoConfig"] = 13] = "VideoConfig";
1302
+ LOCPropertyId[LOCPropertyId["AudioConfig"] = 15] = "AudioConfig";
1303
+ LOCPropertyId[LOCPropertyId["Timestamp"] = 16] = "Timestamp";
1304
+ return LOCPropertyId;
1305
+ }({});
1306
+ let TrackPropertyType = /* @__PURE__ */ function(TrackPropertyType) {
1307
+ TrackPropertyType[TrackPropertyType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
1308
+ TrackPropertyType[TrackPropertyType["MaxCacheDuration"] = 4] = "MaxCacheDuration";
1309
+ TrackPropertyType[TrackPropertyType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
1310
+ TrackPropertyType[TrackPropertyType["ImmutableProperties"] = 11] = "ImmutableProperties";
1311
+ TrackPropertyType[TrackPropertyType["DefaultPublisherPriority"] = 14] = "DefaultPublisherPriority";
1312
+ TrackPropertyType[TrackPropertyType["DefaultPublisherGroupOrder"] = 34] = "DefaultPublisherGroupOrder";
1313
+ TrackPropertyType[TrackPropertyType["DynamicGroups"] = 48] = "DynamicGroups";
1314
+ TrackPropertyType[TrackPropertyType["PriorGroupIdGap"] = 60] = "PriorGroupIdGap";
1315
+ TrackPropertyType[TrackPropertyType["PriorObjectIdGap"] = 62] = "PriorObjectIdGap";
1316
+ return TrackPropertyType;
1317
+ }({});
1318
+ function locPropertyIdFromNumber(value) {
1319
+ switch (value) {
1320
+ case 8: return 8;
1321
+ case 9: return 9;
1322
+ case 12: return 12;
1323
+ case 13: return 13;
1324
+ case 15: return 15;
1325
+ case 16: return 16;
1326
+ default: throw new InvalidTypeError("locPropertyIdFromNumber", `Invalid LOC property id: ${value}`);
1327
+ }
1328
+ }
1329
+ /**
1330
+ * @public
1331
+ * Registration-policy ranges for the Property Type space.
1332
+ *
1333
+ */
1334
+ const PropertyRanges = {
1335
+ /** Standards Action or IESG Approval (1-byte encoding). */
1336
+ StandardsAction: {
1337
+ from: 0n,
1338
+ to: 119n
1339
+ },
1340
+ /** Application-specific use, no registration permitted (1-byte encoding). */
1341
+ AppSpecific1Byte: {
1342
+ from: 120n,
1343
+ to: 127n
1344
+ },
1345
+ /** Specification Required (2-byte encoding). */
1346
+ SpecRequired: {
1347
+ from: 128n,
1348
+ to: 14335n
1349
+ },
1350
+ /** Application-specific use, no registration permitted (2-byte encoding). */
1351
+ AppSpecific2Byte: {
1352
+ from: 14336n,
1353
+ to: 16383n
1354
+ },
1355
+ /** Mandatory Track Properties; Track scope only. */
1356
+ MandatoryTrack: {
1357
+ from: 16384n,
1358
+ to: 32767n
1359
+ },
1360
+ /** First Come First Served begins here (open-ended). */
1361
+ Fcfs: { from: 32768n }
1362
+ };
1363
+ function inRange(range, typeValue) {
1364
+ return typeValue >= range.from && (range.to === void 0 || typeValue <= range.to);
1365
+ }
1366
+ /**
1367
+ * @public
1368
+ * True if a Property Type is reserved for application-specific use (either encoding-width
1369
+ * range), for which no IANA registration is permitted.
1370
+ */
1371
+ function isApplicationSpecificProperty(typeValue) {
1372
+ const v = BigInt(typeValue);
1373
+ return inRange(PropertyRanges.AppSpecific1Byte, v) || inRange(PropertyRanges.AppSpecific2Byte, v);
1374
+ }
1375
+ // src/model/property/object_property.ts
1376
+ /**
1377
+ * Copyright 2026 The MOQtail Authors
1378
+ *
1379
+ * Licensed under the Apache License, Version 2.0 (the "License");
1380
+ * you may not use this file except in compliance with the License.
1381
+ * You may obtain a copy of the License at
1382
+ *
1383
+ * http://www.apache.org/licenses/LICENSE-2.0
1384
+ *
1385
+ * Unless required by applicable law or agreed to in writing, software
1386
+ * distributed under the License is distributed on an "AS IS" BASIS,
1387
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1388
+ * See the License for the specific language governing permissions and
1389
+ * limitations under the License.
1390
+ */
1391
+ var ImmutablePropertiesObjectProperty = class ImmutablePropertiesObjectProperty {
1392
+ properties;
1393
+ static TYPE = 11;
1394
+ constructor(properties) {
1395
+ this.properties = properties;
1396
+ }
1397
+ toKeyValuePair() {
1398
+ return KeyValuePair.tryNewBytes(ImmutablePropertiesObjectProperty.TYPE, serializeKvpList(this.properties).toUint8Array());
1399
+ }
1400
+ static fromKeyValuePair(pair) {
1401
+ if (Number(pair.typeValue) !== ImmutablePropertiesObjectProperty.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
1402
+ const properties = deserializeKvpListUntilEmpty(new FrozenByteBuffer(pair.value));
1403
+ properties.forEach(rejectMandatoryTrackProperty);
1404
+ if (properties.some((inner) => Number(inner.typeValue) === 11)) throw new ProtocolViolationError("ImmutablePropertiesObjectProperty.fromKeyValuePair", "ImmutableProperties must not contain nested ImmutableProperties (0x0B)");
1405
+ return new ImmutablePropertiesObjectProperty(properties);
1406
+ }
1407
+ };
1408
+ function rejectMandatoryTrackProperty(pair) {
1409
+ const { from, to } = PropertyRanges.MandatoryTrack;
1410
+ if (pair.typeValue >= from && pair.typeValue <= to && !isGrease(pair.typeValue)) throw new ProtocolViolationError("ObjectProperty.fromKeyValuePair", `Mandatory Track Property 0x${pair.typeValue.toString(16)} is not allowed on an Object`);
1411
+ }
1412
+ var PriorGroupIdGapProperty = class PriorGroupIdGapProperty {
1413
+ gap;
1414
+ static TYPE = 60;
1415
+ constructor(gap) {
1416
+ this.gap = gap;
1417
+ }
1418
+ toKeyValuePair() {
1419
+ return KeyValuePair.tryNewVarInt(PriorGroupIdGapProperty.TYPE, this.gap);
1420
+ }
1421
+ static fromKeyValuePair(pair) {
1422
+ if (Number(pair.typeValue) !== PriorGroupIdGapProperty.TYPE || typeof pair.value !== "bigint") return void 0;
1423
+ return new PriorGroupIdGapProperty(pair.value);
1424
+ }
1425
+ };
1426
+ var PriorObjectIdGapProperty = class PriorObjectIdGapProperty {
1427
+ gap;
1428
+ static TYPE = 62;
1429
+ constructor(gap) {
1430
+ this.gap = gap;
1431
+ }
1432
+ toKeyValuePair() {
1433
+ return KeyValuePair.tryNewVarInt(PriorObjectIdGapProperty.TYPE, this.gap);
1434
+ }
1435
+ static fromKeyValuePair(pair) {
1436
+ if (Number(pair.typeValue) !== PriorObjectIdGapProperty.TYPE || typeof pair.value !== "bigint") return void 0;
1437
+ return new PriorObjectIdGapProperty(pair.value);
1438
+ }
1439
+ };
1440
+ var UnknownObjectProperty = class {
1441
+ kvp;
1442
+ constructor(kvp) {
1443
+ this.kvp = kvp;
1444
+ }
1445
+ toKeyValuePair() {
1446
+ return this.kvp;
1447
+ }
1448
+ };
1449
+ let ObjectProperty;
1450
+ (function(_ObjectProperty) {
1451
+ function fromKeyValuePair(pair) {
1452
+ rejectMandatoryTrackProperty(pair);
1453
+ return ImmutablePropertiesObjectProperty.fromKeyValuePair(pair) ?? PriorGroupIdGapProperty.fromKeyValuePair(pair) ?? PriorObjectIdGapProperty.fromKeyValuePair(pair) ?? new UnknownObjectProperty(pair);
1454
+ }
1455
+ _ObjectProperty.fromKeyValuePair = fromKeyValuePair;
1456
+ function deserializeRaw(buf) {
1457
+ try {
1458
+ const pairs = deserializeKvpListUntilEmpty(buf);
1459
+ pairs.forEach(fromKeyValuePair);
1460
+ return pairs;
1461
+ } catch (e) {
1462
+ if (e instanceof NotEnoughBytesError) throw new ProtocolViolationError("ObjectProperty.deserializeRaw", e.message);
1463
+ throw e;
1464
+ }
1465
+ }
1466
+ _ObjectProperty.deserializeRaw = deserializeRaw;
1467
+ function toKeyValuePair(ext) {
1468
+ return ext.toKeyValuePair();
1469
+ }
1470
+ _ObjectProperty.toKeyValuePair = toKeyValuePair;
1471
+ function deserializeAll(buf) {
1472
+ return deserializeKvpListUntilEmpty(buf).map(fromKeyValuePair);
1473
+ }
1474
+ _ObjectProperty.deserializeAll = deserializeAll;
1475
+ function serializeInto(exts, payload) {
1476
+ payload.putBytes(serializeKvpList(exts.map((ext) => ext.toKeyValuePair())).toUint8Array());
1477
+ }
1478
+ _ObjectProperty.serializeInto = serializeInto;
1479
+ function isImmutableProperties(ext) {
1480
+ return ext instanceof ImmutablePropertiesObjectProperty;
1481
+ }
1482
+ _ObjectProperty.isImmutableProperties = isImmutableProperties;
1483
+ function isPriorGroupIdGap(ext) {
1484
+ return ext instanceof PriorGroupIdGapProperty;
1485
+ }
1486
+ _ObjectProperty.isPriorGroupIdGap = isPriorGroupIdGap;
1487
+ function isPriorObjectIdGap(ext) {
1488
+ return ext instanceof PriorObjectIdGapProperty;
1489
+ }
1490
+ _ObjectProperty.isPriorObjectIdGap = isPriorObjectIdGap;
1491
+ function isUnknown(ext) {
1492
+ return ext instanceof UnknownObjectProperty;
1493
+ }
1494
+ _ObjectProperty.isUnknown = isUnknown;
1495
+ })(ObjectProperty || (ObjectProperty = {}));
1235
1496
  // src/model/data/datagram.ts
1236
1497
  /**
1237
1498
  * Copyright 2026 The MOQtail Authors
@@ -1332,7 +1593,10 @@ var Datagram = class Datagram {
1332
1593
  if (ObjectDatagramType.hasDefaultPriority(msgType)) publisherPriority = null;
1333
1594
  else publisherPriority = buf.getU8();
1334
1595
  let properties = null;
1335
- if (ObjectDatagramType.hasProperties(msgType)) properties = deserializeKvpListUntilEmpty(new FrozenByteBuffer(buf.getLengthPrefixedBytes()));
1596
+ if (ObjectDatagramType.hasProperties(msgType)) {
1597
+ const headerBytes = new FrozenByteBuffer(buf.getLengthPrefixedBytes());
1598
+ properties = ObjectProperty.deserializeRaw(headerBytes);
1599
+ }
1336
1600
  let payload = null;
1337
1601
  let objectStatus = null;
1338
1602
  if (ObjectDatagramType.isStatus(msgType)) objectStatus = ObjectStatus.tryFrom(buf.getVI());
@@ -1897,7 +2161,8 @@ var FetchObject = class FetchObject {
1897
2161
  let properties = null;
1898
2162
  if (hasProperties) {
1899
2163
  const extLen = buf.getNumberVI();
1900
- properties = deserializeKvpListUntilEmpty(new FrozenByteBuffer(buf.getBytes(extLen)));
2164
+ const headerBytes = new FrozenByteBuffer(buf.getBytes(extLen));
2165
+ properties = ObjectProperty.deserializeRaw(headerBytes);
1901
2166
  }
1902
2167
  const payloadLen = buf.getNumberVI();
1903
2168
  const payload = buf.getBytes(payloadLen);
@@ -2007,100 +2272,6 @@ var FullTrackName = class FullTrackName {
2007
2272
  return new FullTrackName(namespace, name);
2008
2273
  }
2009
2274
  };
2010
- // src/model/property/constant.ts
2011
- /**
2012
- * Copyright 2025 The MOQtail Authors
2013
- *
2014
- * Licensed under the Apache License, Version 2.0 (the "License");
2015
- * you may not use this file except in compliance with the License.
2016
- * You may obtain a copy of the License at
2017
- *
2018
- * http://www.apache.org/licenses/LICENSE-2.0
2019
- *
2020
- * Unless required by applicable law or agreed to in writing, software
2021
- * distributed under the License is distributed on an "AS IS" BASIS,
2022
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2023
- * See the License for the specific language governing permissions and
2024
- * limitations under the License.
2025
- */
2026
- let LOCPropertyId = /* @__PURE__ */ function(LOCPropertyId) {
2027
- LOCPropertyId[LOCPropertyId["Timescale"] = 8] = "Timescale";
2028
- LOCPropertyId[LOCPropertyId["VideoFrameMarking"] = 9] = "VideoFrameMarking";
2029
- LOCPropertyId[LOCPropertyId["AudioLevel"] = 12] = "AudioLevel";
2030
- LOCPropertyId[LOCPropertyId["VideoConfig"] = 13] = "VideoConfig";
2031
- LOCPropertyId[LOCPropertyId["AudioConfig"] = 15] = "AudioConfig";
2032
- LOCPropertyId[LOCPropertyId["Timestamp"] = 16] = "Timestamp";
2033
- return LOCPropertyId;
2034
- }({});
2035
- let TrackPropertyType = /* @__PURE__ */ function(TrackPropertyType) {
2036
- TrackPropertyType[TrackPropertyType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
2037
- TrackPropertyType[TrackPropertyType["MaxCacheDuration"] = 4] = "MaxCacheDuration";
2038
- TrackPropertyType[TrackPropertyType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
2039
- TrackPropertyType[TrackPropertyType["ImmutableProperties"] = 11] = "ImmutableProperties";
2040
- TrackPropertyType[TrackPropertyType["DefaultPublisherPriority"] = 14] = "DefaultPublisherPriority";
2041
- TrackPropertyType[TrackPropertyType["DefaultPublisherGroupOrder"] = 34] = "DefaultPublisherGroupOrder";
2042
- TrackPropertyType[TrackPropertyType["DynamicGroups"] = 48] = "DynamicGroups";
2043
- TrackPropertyType[TrackPropertyType["PriorGroupIdGap"] = 60] = "PriorGroupIdGap";
2044
- TrackPropertyType[TrackPropertyType["PriorObjectIdGap"] = 62] = "PriorObjectIdGap";
2045
- return TrackPropertyType;
2046
- }({});
2047
- function locPropertyIdFromNumber(value) {
2048
- switch (value) {
2049
- case 8: return 8;
2050
- case 9: return 9;
2051
- case 12: return 12;
2052
- case 13: return 13;
2053
- case 15: return 15;
2054
- case 16: return 16;
2055
- default: throw new InvalidTypeError("locPropertyIdFromNumber", `Invalid LOC property id: ${value}`);
2056
- }
2057
- }
2058
- /**
2059
- * @public
2060
- * Registration-policy ranges for the Property Type space.
2061
- *
2062
- */
2063
- const PropertyRanges = {
2064
- /** Standards Action or IESG Approval (1-byte encoding). */
2065
- StandardsAction: {
2066
- from: 0n,
2067
- to: 119n
2068
- },
2069
- /** Application-specific use, no registration permitted (1-byte encoding). */
2070
- AppSpecific1Byte: {
2071
- from: 120n,
2072
- to: 127n
2073
- },
2074
- /** Specification Required (2-byte encoding). */
2075
- SpecRequired: {
2076
- from: 128n,
2077
- to: 14335n
2078
- },
2079
- /** Application-specific use, no registration permitted (2-byte encoding). */
2080
- AppSpecific2Byte: {
2081
- from: 14336n,
2082
- to: 16383n
2083
- },
2084
- /** Mandatory Track Properties; Track scope only. */
2085
- MandatoryTrack: {
2086
- from: 16384n,
2087
- to: 32767n
2088
- },
2089
- /** First Come First Served begins here (open-ended). */
2090
- Fcfs: { from: 32768n }
2091
- };
2092
- function inRange(range, typeValue) {
2093
- return typeValue >= range.from && (range.to === void 0 || typeValue <= range.to);
2094
- }
2095
- /**
2096
- * @public
2097
- * True if a Property Type is reserved for application-specific use (either encoding-width
2098
- * range), for which no IANA registration is permitted.
2099
- */
2100
- function isApplicationSpecificProperty(typeValue) {
2101
- const v = BigInt(typeValue);
2102
- return inRange(PropertyRanges.AppSpecific1Byte, v) || inRange(PropertyRanges.AppSpecific2Byte, v);
2103
- }
2104
2275
  // src/model/property/timestamp.ts
2105
2276
  /**
2106
2277
  * Copyright 2025 The MOQtail Authors
@@ -2361,52 +2532,6 @@ var LOCProperties = class {
2361
2532
  return result;
2362
2533
  }
2363
2534
  };
2364
- // src/model/common/grease.ts
2365
- /**
2366
- * Copyright 2026 The MOQtail Authors
2367
- *
2368
- * Licensed under the Apache License, Version 2.0 (the "License");
2369
- * you may not use this file except in compliance with the License.
2370
- * You may obtain a copy of the License at
2371
- *
2372
- * http://www.apache.org/licenses/LICENSE-2.0
2373
- *
2374
- * Unless required by applicable law or agreed to in writing, software
2375
- * distributed under the License is distributed on an "AS IS" BASIS,
2376
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2377
- * See the License for the specific language governing permissions and
2378
- * limitations under the License.
2379
- */
2380
- /**
2381
- * GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
2382
- * several registries (Setup Options, Properties, error codes) so peers can emit them
2383
- * to exercise unknown-value handling. Receivers treat them like any other unknown
2384
- * value: ignore, never fatal.
2385
- */
2386
- /** Step between successive GREASE values. */
2387
- const GREASE_STEP = 127n;
2388
- /** The smallest GREASE value (N = 0). */
2389
- const GREASE_BASE = 157n;
2390
- /** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
2391
- const GREASE_MAX = 4611686018427387870n;
2392
- /**
2393
- * @public
2394
- * True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
2395
- * non-negative `N`.
2396
- */
2397
- function isGrease(value) {
2398
- const v = BigInt(value);
2399
- return v >= 157n && (v - 157n) % 127n === 0n;
2400
- }
2401
- /**
2402
- * @public
2403
- * The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
2404
- * varint can carry (the pattern is capped at `0x3fffffffffffffde`).
2405
- */
2406
- function greaseValue(n) {
2407
- const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
2408
- return value > GREASE_MAX ? void 0 : value;
2409
- }
2410
2535
  // src/model/property/track_property.ts
2411
2536
  /**
2412
2537
  * Copyright 2026 The MOQtail Authors
@@ -2587,110 +2712,6 @@ let TrackProperty;
2587
2712
  }
2588
2713
  _TrackProperty.isUnknown = isUnknown;
2589
2714
  })(TrackProperty || (TrackProperty = {}));
2590
- // src/model/property/object_property.ts
2591
- /**
2592
- * Copyright 2026 The MOQtail Authors
2593
- *
2594
- * Licensed under the Apache License, Version 2.0 (the "License");
2595
- * you may not use this file except in compliance with the License.
2596
- * You may obtain a copy of the License at
2597
- *
2598
- * http://www.apache.org/licenses/LICENSE-2.0
2599
- *
2600
- * Unless required by applicable law or agreed to in writing, software
2601
- * distributed under the License is distributed on an "AS IS" BASIS,
2602
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2603
- * See the License for the specific language governing permissions and
2604
- * limitations under the License.
2605
- */
2606
- var ImmutablePropertiesObjectProperty = class ImmutablePropertiesObjectProperty {
2607
- properties;
2608
- static TYPE = 11;
2609
- constructor(properties) {
2610
- this.properties = properties;
2611
- }
2612
- toKeyValuePair() {
2613
- return KeyValuePair.tryNewBytes(ImmutablePropertiesObjectProperty.TYPE, serializeKvpList(this.properties).toUint8Array());
2614
- }
2615
- static fromKeyValuePair(pair) {
2616
- if (Number(pair.typeValue) !== ImmutablePropertiesObjectProperty.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
2617
- const properties = deserializeKvpListUntilEmpty(new FrozenByteBuffer(pair.value));
2618
- if (properties.some((inner) => Number(inner.typeValue) === 11)) throw new ProtocolViolationError("ImmutablePropertiesObjectProperty.fromKeyValuePair", "ImmutableProperties must not contain nested ImmutableProperties (0x0B)");
2619
- return new ImmutablePropertiesObjectProperty(properties);
2620
- }
2621
- };
2622
- var PriorGroupIdGapProperty = class PriorGroupIdGapProperty {
2623
- gap;
2624
- static TYPE = 60;
2625
- constructor(gap) {
2626
- this.gap = gap;
2627
- }
2628
- toKeyValuePair() {
2629
- return KeyValuePair.tryNewVarInt(PriorGroupIdGapProperty.TYPE, this.gap);
2630
- }
2631
- static fromKeyValuePair(pair) {
2632
- if (Number(pair.typeValue) !== PriorGroupIdGapProperty.TYPE || typeof pair.value !== "bigint") return void 0;
2633
- return new PriorGroupIdGapProperty(pair.value);
2634
- }
2635
- };
2636
- var PriorObjectIdGapProperty = class PriorObjectIdGapProperty {
2637
- gap;
2638
- static TYPE = 62;
2639
- constructor(gap) {
2640
- this.gap = gap;
2641
- }
2642
- toKeyValuePair() {
2643
- return KeyValuePair.tryNewVarInt(PriorObjectIdGapProperty.TYPE, this.gap);
2644
- }
2645
- static fromKeyValuePair(pair) {
2646
- if (Number(pair.typeValue) !== PriorObjectIdGapProperty.TYPE || typeof pair.value !== "bigint") return void 0;
2647
- return new PriorObjectIdGapProperty(pair.value);
2648
- }
2649
- };
2650
- var UnknownObjectProperty = class {
2651
- kvp;
2652
- constructor(kvp) {
2653
- this.kvp = kvp;
2654
- }
2655
- toKeyValuePair() {
2656
- return this.kvp;
2657
- }
2658
- };
2659
- let ObjectProperty;
2660
- (function(_ObjectProperty) {
2661
- function fromKeyValuePair(pair) {
2662
- return ImmutablePropertiesObjectProperty.fromKeyValuePair(pair) ?? PriorGroupIdGapProperty.fromKeyValuePair(pair) ?? PriorObjectIdGapProperty.fromKeyValuePair(pair) ?? new UnknownObjectProperty(pair);
2663
- }
2664
- _ObjectProperty.fromKeyValuePair = fromKeyValuePair;
2665
- function toKeyValuePair(ext) {
2666
- return ext.toKeyValuePair();
2667
- }
2668
- _ObjectProperty.toKeyValuePair = toKeyValuePair;
2669
- function deserializeAll(buf) {
2670
- return deserializeKvpListUntilEmpty(buf).map(fromKeyValuePair);
2671
- }
2672
- _ObjectProperty.deserializeAll = deserializeAll;
2673
- function serializeInto(exts, payload) {
2674
- payload.putBytes(serializeKvpList(exts.map((ext) => ext.toKeyValuePair())).toUint8Array());
2675
- }
2676
- _ObjectProperty.serializeInto = serializeInto;
2677
- function isImmutableProperties(ext) {
2678
- return ext instanceof ImmutablePropertiesObjectProperty;
2679
- }
2680
- _ObjectProperty.isImmutableProperties = isImmutableProperties;
2681
- function isPriorGroupIdGap(ext) {
2682
- return ext instanceof PriorGroupIdGapProperty;
2683
- }
2684
- _ObjectProperty.isPriorGroupIdGap = isPriorGroupIdGap;
2685
- function isPriorObjectIdGap(ext) {
2686
- return ext instanceof PriorObjectIdGapProperty;
2687
- }
2688
- _ObjectProperty.isPriorObjectIdGap = isPriorObjectIdGap;
2689
- function isUnknown(ext) {
2690
- return ext instanceof UnknownObjectProperty;
2691
- }
2692
- _ObjectProperty.isUnknown = isUnknown;
2693
- })(ObjectProperty || (ObjectProperty = {}));
2694
2715
  // src/model/property/find.ts
2695
2716
  /**
2696
2717
  * Copyright 2026 The MOQtail Authors
@@ -2780,7 +2801,8 @@ var SubgroupObject = class SubgroupObject {
2780
2801
  let properties = null;
2781
2802
  if (hasProperties) {
2782
2803
  const extLen = buf.getNumberVI();
2783
- properties = deserializeKvpListUntilEmpty(new FrozenByteBuffer(buf.getBytes(extLen)));
2804
+ const headerBytes = new FrozenByteBuffer(buf.getBytes(extLen));
2805
+ properties = ObjectProperty.deserializeRaw(headerBytes);
2784
2806
  }
2785
2807
  const payloadLen = buf.getNumberVI();
2786
2808
  let objectStatus = null;
@@ -4967,14 +4989,14 @@ function valueShapeOf(typeValue) {
4967
4989
  case BigInt(53): return 1;
4968
4990
  case BigInt(9): return 2;
4969
4991
  case BigInt(33): return 3;
4992
+ case BigInt(52): return 4;
4970
4993
  case BigInt(36):
4971
- case BigInt(52):
4972
4994
  case BigInt(37):
4973
4995
  case BigInt(38):
4974
4996
  case BigInt(39):
4975
4997
  case BigInt(40):
4976
- case BigInt(41): return 4;
4977
- default: return typeValue % 2n === 0n ? 0 : 4;
4998
+ case BigInt(41): return 5;
4999
+ default: return typeValue % 2n === 0n ? 0 : 5;
4978
5000
  }
4979
5001
  }
4980
5002
  /**
@@ -4994,9 +5016,10 @@ function serializeMessageParameterKvps(items) {
4994
5016
  break;
4995
5017
  case 2:
4996
5018
  case 3:
5019
+ case 4:
4997
5020
  if (isBytes(kvp)) buf.putBytes(kvp.value);
4998
5021
  break;
4999
- case 4:
5022
+ case 5:
5000
5023
  if (isBytes(kvp)) buf.putLengthPrefixedBytes(kvp.value);
5001
5024
  break;
5002
5025
  case 0: if (isVarInt(kvp)) buf.putVI(kvp.value);
@@ -5034,6 +5057,9 @@ function readMessageParameterKvps(buf, more) {
5034
5057
  items.push(KeyValuePair.newBytes(typeValue, LocationFilter.deserializeValue(buf).serializeValue()));
5035
5058
  break;
5036
5059
  case 4:
5060
+ items.push(KeyValuePair.newBytes(typeValue, Tuple.deserialize(buf).serialize().toUint8Array()));
5061
+ break;
5062
+ case 5:
5037
5063
  items.push(KeyValuePair.deserializeBytesValue(buf, typeValue));
5038
5064
  break;
5039
5065
  case 0: items.push(KeyValuePair.tryNewVarInt(typeValue, buf.getVI()));
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_player = require("../player-C6y-qpHz.cjs");
2
3
  const require_emitter = require("../emitter-qNJYD3yQ.cjs");
3
- const require_player = require("../player-CJayEzwt.cjs");
4
- require("../util.cjs");
5
4
  let custom_media_element = require("custom-media-element");
6
5
  let media_tracks = require("media-tracks");
7
6
  // src/player/component/renditions.ts
@@ -196,14 +195,43 @@ var MOQtailVideoElement = class extends (0, media_tracks.MediaTracksMixin)(custo
196
195
  }
197
196
  /** Proposal 0007: where the live edge starts, in seconds; `NaN` on demand. */
198
197
  get liveEdgeStart() {
199
- return this.#player?.mediaSink?.liveEdgeStart ?? NaN;
198
+ return (this.#player?.mediaSink?.liveEdgeStart ?? NaN) - this.#offset();
200
199
  }
201
200
  /**
202
- * Proposal 0007: `Infinity` while live, since earlier groups stay seekable through FETCH; `NaN`
203
- * otherwise. Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
201
+ * Proposal 0007: live, `Infinity` with an accessible window (DVR) and `0` without; `NaN` otherwise.
202
+ * Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
204
203
  */
205
204
  get targetLiveWindow() {
206
- return this.#streamType === "live" ? Infinity : NaN;
205
+ if (this.#streamType !== "live") return NaN;
206
+ return this.#dvrRange ? Infinity : 0;
207
+ }
208
+ /**
209
+ * Live with an accessible window, the element's times count from the window's start: seekbars
210
+ * such as Video.js's start at 0. The inner video and the player keep media time.
211
+ */
212
+ get currentTime() {
213
+ return this.nativeEl.currentTime - this.#offset();
214
+ }
215
+ set currentTime(value) {
216
+ if (this.#streamType === "live" && !this.#dvrRange) return;
217
+ this.nativeEl.currentTime = value + this.#offset();
218
+ }
219
+ /** Live, the accessible window, or nothing without one. */
220
+ get seekable() {
221
+ if (this.#streamType !== "live") return this.nativeEl.seekable;
222
+ const range = this.#dvrRange;
223
+ return timeRanges(range ? [[0, range.end - range.start]] : []);
224
+ }
225
+ get buffered() {
226
+ const offset = this.#offset();
227
+ const native = this.nativeEl.buffered;
228
+ if (offset === 0) return native;
229
+ const pairs = [];
230
+ for (let i = 0; i < native.length; i++) {
231
+ const end = native.end(i) - offset;
232
+ if (end > 0) pairs.push([Math.max(0, native.start(i) - offset), end]);
233
+ }
234
+ return timeRanges(pairs);
207
235
  }
208
236
  get error() {
209
237
  return this.#error;
@@ -264,6 +292,12 @@ var MOQtailVideoElement = class extends (0, media_tracks.MediaTracksMixin)(custo
264
292
  this.#setStreamType("unknown");
265
293
  if (player) this.#destroyed = player.destroy().catch(() => {});
266
294
  }
295
+ get #dvrRange() {
296
+ return this.#streamType === "live" ? this.#player?.mediaSink?.dvrRange : void 0;
297
+ }
298
+ #offset() {
299
+ return this.#dvrRange?.start ?? 0;
300
+ }
267
301
  #setStreamType(type) {
268
302
  if (type === this.#streamType) return;
269
303
  this.#streamType = type;
@@ -281,6 +315,19 @@ function asPlayerError(error) {
281
315
  cause: error
282
316
  });
283
317
  }
318
+ /** `TimeRanges` can't be constructed either. */
319
+ function timeRanges(pairs) {
320
+ const at = (i, edge) => {
321
+ const pair = pairs[i];
322
+ if (!pair) throw new DOMException(`No range ${i}`, "IndexSizeError");
323
+ return pair[edge];
324
+ };
325
+ return {
326
+ length: pairs.length,
327
+ start: (i) => at(i, 0),
328
+ end: (i) => at(i, 1)
329
+ };
330
+ }
284
331
  /** `MediaError` can't be constructed, so this has its shape. */
285
332
  function mediaError(error) {
286
333
  return {