@blockcast/mmt-container 2.1.0-main.36792a9d6614 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-runtime.js +42 -325
- package/dist/browser-runtime.js.map +4 -4
- package/dist/cmcd-producer.d.ts +0 -5
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/mmtp-router.d.ts +1 -9
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +14 -1456
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-manager.d.ts +2 -13
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +5297 -5580
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +3 -11
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +19 -255
- package/dist/multicast-transport.js.map +4 -4
- package/package.json +5 -5
- package/src/cmcd-producer.ts +0 -5
- package/src/mmtp-router.ts +16 -81
- package/src/multicast-manager.ts +5 -23
- package/src/multicast-transport.ts +20 -44
|
@@ -42,13 +42,7 @@ export interface MulticastTransportConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
protected?: boolean;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
* The leg a join resolved to. `'user-agent'`: the browser's own
|
|
47
|
-
* `MulticastReceiver` delivers it, which picks native or AMT itself and does
|
|
48
|
-
* not say which. CMCD has no user-agent value, so a caller reports a
|
|
49
|
-
* `'user-agent'` join as `'native'` (`TransportSnapshot.transport`).
|
|
50
|
-
*/
|
|
51
|
-
export type ResolvedMulticastTransport = 'native' | 'amt' | 'user-agent';
|
|
45
|
+
export type ResolvedMulticastTransport = 'native' | 'amt';
|
|
52
46
|
/**
|
|
53
47
|
* Why a joined transport handed control back to MoQ.
|
|
54
48
|
*
|
|
@@ -274,10 +268,8 @@ export declare class MulticastTransport<TPacketContext = never> {
|
|
|
274
268
|
/** Whether a subscription is live: joined, and not yet released or replaced. */
|
|
275
269
|
get joined(): boolean;
|
|
276
270
|
/**
|
|
277
|
-
*
|
|
278
|
-
* the last setContext), or undefined without a live join.
|
|
279
|
-
* provider each accepted packet is delivered with a marked copy of it
|
|
280
|
-
* (`userAgentVerifiedIngress`); this getter never carries the mark.
|
|
271
|
+
* What the live join delivers with every accepted packet (the join's
|
|
272
|
+
* `context`, or the last setContext), or undefined without a live join.
|
|
281
273
|
*/
|
|
282
274
|
get context(): TPacketContext | undefined;
|
|
283
275
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multicast-transport.d.ts","sourceRoot":"","sources":["../src/multicast-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"multicast-transport.d.ts","sourceRoot":"","sources":["../src/multicast-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAE5B,MAAM,0BAA0B,CAAA;AASjC,MAAM,WAAW,wBAAwB;IACvC,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kGAAkG;IAClG,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC7C,qFAAqF;IACrF,KAAK,CAAC,EAAE;QAAE,SAA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O,IAAI,IAAI;CAgMhB"}
|
|
@@ -206,33 +206,11 @@ var AdaptiveBitrateController = class {
|
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
209
|
-
var MMTP_HEADER_SIZE = 12;
|
|
210
209
|
var MPU_HEADER_SIZE = 8;
|
|
211
210
|
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
212
211
|
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
213
212
|
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
214
213
|
var MMTP_PACKET_ID_MAX = 65535;
|
|
215
|
-
function readMMTPPacketId(buffer) {
|
|
216
|
-
if (buffer.length < MMTP_HEADER_SIZE)
|
|
217
|
-
return null;
|
|
218
|
-
const flags = buffer[0];
|
|
219
|
-
if ((flags >> 6 & 3) !== 0)
|
|
220
|
-
return null;
|
|
221
|
-
let offset = MMTP_HEADER_SIZE;
|
|
222
|
-
if ((flags & 32) !== 0) {
|
|
223
|
-
if (offset + 4 > buffer.length)
|
|
224
|
-
return null;
|
|
225
|
-
offset += 4;
|
|
226
|
-
}
|
|
227
|
-
if ((flags & 2) !== 0) {
|
|
228
|
-
if (offset + 4 > buffer.length)
|
|
229
|
-
return null;
|
|
230
|
-
const length = buffer[offset + 2] << 8 | buffer[offset + 3];
|
|
231
|
-
if (offset + 4 + length > buffer.length)
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
return buffer[2] << 8 | buffer[3];
|
|
235
|
-
}
|
|
236
214
|
|
|
237
215
|
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
238
216
|
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
@@ -1218,205 +1196,6 @@ var TransportManager = class {
|
|
|
1218
1196
|
};
|
|
1219
1197
|
var transportManager = new TransportManager();
|
|
1220
1198
|
|
|
1221
|
-
// node_modules/@blockcast/mmt-transport/dist/multicast-receiver-gateway.js
|
|
1222
|
-
var REGISTRY = /* @__PURE__ */ Symbol.for("@blockcast/mmt-transport/native-provider-registry/v1");
|
|
1223
|
-
var USER_AGENT_VERIFIED = /* @__PURE__ */ Symbol.for("@blockcast/mmt-transport/user-agent-verified/v1");
|
|
1224
|
-
var INTEGRITY_SCHEME = "manifest-ed25519-2";
|
|
1225
|
-
var MulticastError = class extends Error {
|
|
1226
|
-
code;
|
|
1227
|
-
constructor(code, message, cause) {
|
|
1228
|
-
super(message, cause === void 0 ? void 0 : { cause });
|
|
1229
|
-
this.name = "MulticastError";
|
|
1230
|
-
this.code = code;
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
function datagramsOf(chunk) {
|
|
1234
|
-
const list = Array.isArray(chunk) ? chunk : chunk?.datagrams ?? [];
|
|
1235
|
-
const out = [];
|
|
1236
|
-
for (const d of list) {
|
|
1237
|
-
const data = d instanceof Uint8Array || d instanceof ArrayBuffer ? d : d?.data;
|
|
1238
|
-
if (data instanceof Uint8Array)
|
|
1239
|
-
out.push(data);
|
|
1240
|
-
else if (data instanceof ArrayBuffer)
|
|
1241
|
-
out.push(new Uint8Array(data));
|
|
1242
|
-
}
|
|
1243
|
-
return out;
|
|
1244
|
-
}
|
|
1245
|
-
function reasonOf(value) {
|
|
1246
|
-
return typeof value === "object" && value !== null && "reason" in value ? value.reason : value;
|
|
1247
|
-
}
|
|
1248
|
-
function registry() {
|
|
1249
|
-
const g = globalThis;
|
|
1250
|
-
if (g[REGISTRY] === void 0) {
|
|
1251
|
-
const providers = /* @__PURE__ */ new WeakSet();
|
|
1252
|
-
const byScope = /* @__PURE__ */ new WeakMap();
|
|
1253
|
-
Object.defineProperty(g, REGISTRY, {
|
|
1254
|
-
value: Object.freeze({
|
|
1255
|
-
isProvider: (x) => typeof x === "object" && x !== null && providers.has(x),
|
|
1256
|
-
providerFor: (scope) => {
|
|
1257
|
-
let provider = byScope.get(scope);
|
|
1258
|
-
if (provider === void 0) {
|
|
1259
|
-
provider = createProvider(scope);
|
|
1260
|
-
providers.add(provider);
|
|
1261
|
-
byScope.set(scope, provider);
|
|
1262
|
-
}
|
|
1263
|
-
return provider;
|
|
1264
|
-
}
|
|
1265
|
-
}),
|
|
1266
|
-
writable: false,
|
|
1267
|
-
configurable: false,
|
|
1268
|
-
enumerable: false
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
return g[REGISTRY];
|
|
1272
|
-
}
|
|
1273
|
-
function resolveMulticastGateway(scope = globalThis) {
|
|
1274
|
-
const s = scope;
|
|
1275
|
-
if (typeof s.MulticastReceiver === "function")
|
|
1276
|
-
return registry().providerFor(scope);
|
|
1277
|
-
if (typeof s.multicast?.subscribe === "function")
|
|
1278
|
-
return s.multicast;
|
|
1279
|
-
return void 0;
|
|
1280
|
-
}
|
|
1281
|
-
function isUserAgentVerifiedGateway(gateway) {
|
|
1282
|
-
return registry().isProvider(gateway);
|
|
1283
|
-
}
|
|
1284
|
-
function userAgentVerifiedIngress(ingress, gateway) {
|
|
1285
|
-
if (isUserAgentVerifiedGateway(gateway))
|
|
1286
|
-
return { ...ingress, admittedBy: USER_AGENT_VERIFIED };
|
|
1287
|
-
if (!("admittedBy" in ingress))
|
|
1288
|
-
return ingress;
|
|
1289
|
-
const { admittedBy: _, ...rest } = ingress;
|
|
1290
|
-
return rest;
|
|
1291
|
-
}
|
|
1292
|
-
function unsupported(message, cause) {
|
|
1293
|
-
return new MulticastError("capability-unsupported", message, cause);
|
|
1294
|
-
}
|
|
1295
|
-
function createProvider(scope) {
|
|
1296
|
-
const Receiver = scope.MulticastReceiver;
|
|
1297
|
-
let gate = null;
|
|
1298
|
-
return {
|
|
1299
|
-
capabilities: () => Promise.resolve({ consumeModes: ["bytes"] }),
|
|
1300
|
-
subscribe: async (config) => {
|
|
1301
|
-
const c = config;
|
|
1302
|
-
if (c.consume !== "bytes")
|
|
1303
|
-
throw unsupported(`consume mode ${String(c.consume)} is not supported`);
|
|
1304
|
-
const origin = c.origin ?? "ip-multicast";
|
|
1305
|
-
if (origin !== "ip-multicast" && !(origin === "amt" && c.discovery === "driad")) {
|
|
1306
|
-
throw unsupported(`origin ${String(origin)} is not supported by MulticastReceiver`);
|
|
1307
|
-
}
|
|
1308
|
-
if (c.relay !== void 0)
|
|
1309
|
-
throw unsupported("MulticastReceiver picks its own AMT relay");
|
|
1310
|
-
if (!c.source)
|
|
1311
|
-
throw unsupported("MulticastReceiver needs an SSM source");
|
|
1312
|
-
if (c.senderAddress !== void 0 && c.senderAddress !== c.source) {
|
|
1313
|
-
throw unsupported("MulticastReceiver filters by source only");
|
|
1314
|
-
}
|
|
1315
|
-
const options = { sourceAddress: c.source, groupAddress: c.group, localPort: c.port };
|
|
1316
|
-
if (gate !== null)
|
|
1317
|
-
await gate;
|
|
1318
|
-
let rx;
|
|
1319
|
-
try {
|
|
1320
|
-
rx = new Receiver(options);
|
|
1321
|
-
} catch (error) {
|
|
1322
|
-
throw unsupported("MulticastReceiver refused the request", error);
|
|
1323
|
-
}
|
|
1324
|
-
const opened = rx.opened;
|
|
1325
|
-
if (gate === null)
|
|
1326
|
-
gate = opened.then(() => void 0, () => void 0);
|
|
1327
|
-
return openSubscription(rx, opened, options, c.packetIds);
|
|
1328
|
-
}
|
|
1329
|
-
};
|
|
1330
|
-
}
|
|
1331
|
-
async function openSubscription(rx, openedPromise, options, packetIds) {
|
|
1332
|
-
let opened;
|
|
1333
|
-
try {
|
|
1334
|
-
opened = await openedPromise;
|
|
1335
|
-
} catch (error) {
|
|
1336
|
-
throw new MulticastError("subscription-failed", "MulticastReceiver did not open", error);
|
|
1337
|
-
}
|
|
1338
|
-
if (rx.integrityScheme !== INTEGRITY_SCHEME) {
|
|
1339
|
-
await rx.close();
|
|
1340
|
-
throw unsupported(`integrity scheme ${String(rx.integrityScheme)} is not ${INTEGRITY_SCHEME}`);
|
|
1341
|
-
}
|
|
1342
|
-
const events = new EventTarget();
|
|
1343
|
-
let state = "connected";
|
|
1344
|
-
let filter = packetIds?.length ? new Set(packetIds) : null;
|
|
1345
|
-
let closing = false;
|
|
1346
|
-
const setState = (next) => {
|
|
1347
|
-
if (state === next)
|
|
1348
|
-
return;
|
|
1349
|
-
state = next;
|
|
1350
|
-
events.dispatchEvent(new CustomEvent("state", { detail: next }));
|
|
1351
|
-
};
|
|
1352
|
-
const sourceAddress = options.sourceAddress;
|
|
1353
|
-
const subscription = {
|
|
1354
|
-
id: `${options.sourceAddress}|${options.groupAddress}|${options.localPort}`,
|
|
1355
|
-
get state() {
|
|
1356
|
-
return state;
|
|
1357
|
-
},
|
|
1358
|
-
delivery: "datagram",
|
|
1359
|
-
eventTypes: Object.freeze(["bytes", "packets", "state", "error"]),
|
|
1360
|
-
setPacketIds(ids) {
|
|
1361
|
-
filter = ids.length ? new Set(ids) : null;
|
|
1362
|
-
},
|
|
1363
|
-
addEventListener: events.addEventListener.bind(events),
|
|
1364
|
-
removeEventListener: events.removeEventListener.bind(events),
|
|
1365
|
-
async unsubscribe() {
|
|
1366
|
-
closing = true;
|
|
1367
|
-
await rx.close();
|
|
1368
|
-
setState("closed");
|
|
1369
|
-
}
|
|
1370
|
-
};
|
|
1371
|
-
void (async () => {
|
|
1372
|
-
const reader = opened.readable.getReader();
|
|
1373
|
-
try {
|
|
1374
|
-
for (; ; ) {
|
|
1375
|
-
const { value, done } = await reader.read();
|
|
1376
|
-
if (done)
|
|
1377
|
-
break;
|
|
1378
|
-
const packets = [];
|
|
1379
|
-
for (const data of datagramsOf(value)) {
|
|
1380
|
-
if (filter !== null) {
|
|
1381
|
-
const id = readMMTPPacketId(data);
|
|
1382
|
-
if (id === null || !filter.has(id))
|
|
1383
|
-
continue;
|
|
1384
|
-
}
|
|
1385
|
-
const copy = data.slice().buffer;
|
|
1386
|
-
packets.push(copy);
|
|
1387
|
-
events.dispatchEvent(Object.assign(new CustomEvent("bytes", { detail: copy }), { sourceAddress }));
|
|
1388
|
-
}
|
|
1389
|
-
if (packets.length > 0)
|
|
1390
|
-
events.dispatchEvent(new CustomEvent("packets", { detail: packets }));
|
|
1391
|
-
}
|
|
1392
|
-
} catch {
|
|
1393
|
-
}
|
|
1394
|
-
})();
|
|
1395
|
-
void rx.closed.then((value) => {
|
|
1396
|
-
const reason = reasonOf(value);
|
|
1397
|
-
if (!closing) {
|
|
1398
|
-
if (reason === "consent-withdrawn") {
|
|
1399
|
-
events.dispatchEvent(new CustomEvent("error", {
|
|
1400
|
-
detail: new MulticastError("origin-not-trusted", "multicast consent withdrawn")
|
|
1401
|
-
}));
|
|
1402
|
-
} else if (reason === "oversubscribed" || reason === "network") {
|
|
1403
|
-
events.dispatchEvent(new CustomEvent("error", {
|
|
1404
|
-
detail: new MulticastError("subscription-failed", `MulticastReceiver closed: ${reason}`)
|
|
1405
|
-
}));
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
setState("closed");
|
|
1409
|
-
}, (error) => {
|
|
1410
|
-
if (!closing) {
|
|
1411
|
-
events.dispatchEvent(new CustomEvent("error", {
|
|
1412
|
-
detail: new MulticastError("subscription-failed", "MulticastReceiver failed", error)
|
|
1413
|
-
}));
|
|
1414
|
-
}
|
|
1415
|
-
setState("closed");
|
|
1416
|
-
});
|
|
1417
|
-
return subscription;
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
1199
|
// node_modules/@blockcast/mmt-transport/dist/moqt-priority.js
|
|
1421
1200
|
var MAX_MOQT_PRIORITY = 255;
|
|
1422
1201
|
function moqtPriority(value, field) {
|
|
@@ -1623,19 +1402,19 @@ var AMTGatewayManager = class {
|
|
|
1623
1402
|
var amtGatewayManager = new AMTGatewayManager();
|
|
1624
1403
|
|
|
1625
1404
|
// ../mmt-base/dist/mmtp.js
|
|
1626
|
-
var
|
|
1405
|
+
var MMTP_HEADER_SIZE = 12;
|
|
1627
1406
|
var MPU_HEADER_SIZE2 = 8;
|
|
1628
1407
|
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
1629
1408
|
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
1630
1409
|
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
1631
1410
|
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
1632
|
-
function
|
|
1633
|
-
if (buffer.length <
|
|
1411
|
+
function readMMTPPacketId(buffer) {
|
|
1412
|
+
if (buffer.length < MMTP_HEADER_SIZE)
|
|
1634
1413
|
return null;
|
|
1635
1414
|
const flags = buffer[0];
|
|
1636
1415
|
if ((flags >> 6 & 3) !== 0)
|
|
1637
1416
|
return null;
|
|
1638
|
-
let offset =
|
|
1417
|
+
let offset = MMTP_HEADER_SIZE;
|
|
1639
1418
|
if ((flags & 32) !== 0) {
|
|
1640
1419
|
if (offset + 4 > buffer.length)
|
|
1641
1420
|
return null;
|
|
@@ -1765,8 +1544,11 @@ function providerErrorOf(error) {
|
|
|
1765
1544
|
return Object.freeze(typeof code === "string" ? { name, message, code } : { name, message });
|
|
1766
1545
|
}
|
|
1767
1546
|
var MAX_TRACKED_DROPPED_PIDS = 16;
|
|
1547
|
+
function getMulticastGlobals() {
|
|
1548
|
+
return globalThis;
|
|
1549
|
+
}
|
|
1768
1550
|
function hasMulticastGateway() {
|
|
1769
|
-
return typeof
|
|
1551
|
+
return typeof getMulticastGlobals().multicast?.subscribe === "function";
|
|
1770
1552
|
}
|
|
1771
1553
|
function senderOf(event) {
|
|
1772
1554
|
const sourceAddress = event.sourceAddress;
|
|
@@ -1858,9 +1640,6 @@ var MulticastTransport = class {
|
|
|
1858
1640
|
// listener closure, so an in-place admission change (setContext) applies
|
|
1859
1641
|
// from the next packet on without rejoining.
|
|
1860
1642
|
#context = void 0;
|
|
1861
|
-
#deliveredContext = void 0;
|
|
1862
|
-
/** The live join's gateway, when it is the user agent's MulticastReceiver provider. */
|
|
1863
|
-
#userAgentGateway = void 0;
|
|
1864
1643
|
// The live join's provider-side filter. An in-place widening must reach it,
|
|
1865
1644
|
// or the provider never delivers the new ID; null without a live join.
|
|
1866
1645
|
#providerFilter = null;
|
|
@@ -1897,7 +1676,7 @@ var MulticastTransport = class {
|
|
|
1897
1676
|
this.#dataPlaneLive = false;
|
|
1898
1677
|
this.#sender = void 0;
|
|
1899
1678
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
1900
|
-
const gateway = this.#gateway ??
|
|
1679
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
1901
1680
|
if (typeof gateway?.subscribe !== "function") {
|
|
1902
1681
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
1903
1682
|
return this.#declined(generation, "unavailable");
|
|
@@ -1913,16 +1692,15 @@ var MulticastTransport = class {
|
|
|
1913
1692
|
console.log(
|
|
1914
1693
|
`[MulticastTransport] window.multicast.subscribe(${config.sourceAddress ?? config.senderAddress ?? "*"}, ${config.groupAddress}, ${config.port})`
|
|
1915
1694
|
);
|
|
1916
|
-
const userAgent = isUserAgentVerifiedGateway(gateway);
|
|
1917
1695
|
const subscribeConfig = toWindowMulticastSubscribeConfig({
|
|
1918
1696
|
source: config.sourceAddress,
|
|
1919
1697
|
senderAddress: config.senderAddress,
|
|
1920
1698
|
group: config.groupAddress,
|
|
1921
1699
|
port: config.port,
|
|
1922
|
-
mode:
|
|
1923
|
-
amtRelay:
|
|
1924
|
-
amtRelayPort:
|
|
1925
|
-
amtDiscovery:
|
|
1700
|
+
mode: config.mode,
|
|
1701
|
+
amtRelay: config.amtRelay,
|
|
1702
|
+
amtRelayPort: config.amtRelayPort,
|
|
1703
|
+
amtDiscovery: config.amtDiscovery,
|
|
1926
1704
|
packetIds: config.packetIds,
|
|
1927
1705
|
tracks: config.tracks,
|
|
1928
1706
|
atsc3: config.atsc3
|
|
@@ -1968,8 +1746,7 @@ var MulticastTransport = class {
|
|
|
1968
1746
|
acknowledgedUpdate: 0,
|
|
1969
1747
|
inFlight: 0
|
|
1970
1748
|
};
|
|
1971
|
-
this.#
|
|
1972
|
-
this.#setContext(context);
|
|
1749
|
+
this.#context = context;
|
|
1973
1750
|
if (packetIds) {
|
|
1974
1751
|
for (const packetId of packetIds) {
|
|
1975
1752
|
if (!this.#acceptedBytesByPacketId.has(packetId)) {
|
|
@@ -1977,7 +1754,7 @@ var MulticastTransport = class {
|
|
|
1977
1754
|
}
|
|
1978
1755
|
}
|
|
1979
1756
|
}
|
|
1980
|
-
this.#resolvedTransport =
|
|
1757
|
+
this.#resolvedTransport = subscribeConfig.origin === "amt" ? "amt" : "native";
|
|
1981
1758
|
const delivery = subscription.delivery ?? "datagram";
|
|
1982
1759
|
if (delivery !== "datagram" && delivery !== "ordered-relay") {
|
|
1983
1760
|
throw new Error(
|
|
@@ -2058,7 +1835,7 @@ var MulticastTransport = class {
|
|
|
2058
1835
|
}
|
|
2059
1836
|
if (!this.#acceptPacket(packet, sourceAddress)) return false;
|
|
2060
1837
|
const liveness = !this.#isRecordCandidate(packet);
|
|
2061
|
-
this.#onPacket(packet, this.#
|
|
1838
|
+
this.#onPacket(packet, this.#context);
|
|
2062
1839
|
return liveness;
|
|
2063
1840
|
}
|
|
2064
1841
|
#isRecordCandidate(packet) {
|
|
@@ -2269,10 +2046,8 @@ var MulticastTransport = class {
|
|
|
2269
2046
|
return this.#subscription !== null;
|
|
2270
2047
|
}
|
|
2271
2048
|
/**
|
|
2272
|
-
*
|
|
2273
|
-
* the last setContext), or undefined without a live join.
|
|
2274
|
-
* provider each accepted packet is delivered with a marked copy of it
|
|
2275
|
-
* (`userAgentVerifiedIngress`); this getter never carries the mark.
|
|
2049
|
+
* What the live join delivers with every accepted packet (the join's
|
|
2050
|
+
* `context`, or the last setContext), or undefined without a live join.
|
|
2276
2051
|
*/
|
|
2277
2052
|
get context() {
|
|
2278
2053
|
return this.#context;
|
|
@@ -2296,16 +2071,7 @@ var MulticastTransport = class {
|
|
|
2296
2071
|
"[MulticastTransport] setContext needs a live join; join() carries the first context"
|
|
2297
2072
|
);
|
|
2298
2073
|
}
|
|
2299
|
-
this.#setContext(context);
|
|
2300
|
-
}
|
|
2301
|
-
/**
|
|
2302
|
-
* The join's context, and what the subscription delivers with each packet:
|
|
2303
|
-
* marked admitted by the user agent when the gateway is its native
|
|
2304
|
-
* MulticastReceiver provider. feedPacket never marks.
|
|
2305
|
-
*/
|
|
2306
|
-
#setContext(context) {
|
|
2307
2074
|
this.#context = context;
|
|
2308
|
-
this.#deliveredContext = this.#userAgentGateway !== void 0 && typeof context === "object" && context !== null ? userAgentVerifiedIngress(context, this.#userAgentGateway) : context;
|
|
2309
2075
|
}
|
|
2310
2076
|
/**
|
|
2311
2077
|
* Replace the live join's packet-ID allow-list in place, without rejoining.
|
|
@@ -2437,8 +2203,6 @@ var MulticastTransport = class {
|
|
|
2437
2203
|
this.#matchedSource = void 0;
|
|
2438
2204
|
this.#providerFilter = null;
|
|
2439
2205
|
this.#context = void 0;
|
|
2440
|
-
this.#deliveredContext = void 0;
|
|
2441
|
-
this.#userAgentGateway = void 0;
|
|
2442
2206
|
this.#withdrawnPacketIds.clear();
|
|
2443
2207
|
}
|
|
2444
2208
|
/** The ingress filter; an accepted packet is counted here, once. */
|
|
@@ -2460,7 +2224,7 @@ var MulticastTransport = class {
|
|
|
2460
2224
|
this.#countAccepted(packet, null, void 0);
|
|
2461
2225
|
return true;
|
|
2462
2226
|
}
|
|
2463
|
-
const packetId =
|
|
2227
|
+
const packetId = readMMTPPacketId(packet);
|
|
2464
2228
|
if (packetId === null) {
|
|
2465
2229
|
if (!this.#packetIds) {
|
|
2466
2230
|
this.#countAccepted(packet, null, sourceAddress);
|