@blockcast/mmt-container 2.1.0 → 2.2.0-main.51d1358fdf4c
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 +446 -58
- package/dist/browser-runtime.js.map +4 -4
- package/dist/cmcd-producer.d.ts +5 -0
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +121 -15
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-fec-session.d.ts +41 -3
- package/dist/mmtp-fec-session.d.ts.map +1 -1
- package/dist/mmtp-fec-session.js +118 -13
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-router.d.ts +9 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +1456 -14
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-manager.d.ts +15 -2
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +15235 -14951
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +11 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +255 -19
- package/dist/multicast-transport.js.map +4 -4
- package/dist/no-modules.js +118 -14
- package/dist/no-modules.js.map +3 -3
- package/dist/signaling.js.map +2 -2
- package/package.json +5 -5
- package/src/cmcd-producer.ts +5 -0
- package/src/index.ts +2 -0
- package/src/mmtp-fec-session.ts +115 -15
- package/src/mmtp-router.ts +81 -16
- package/src/multicast-manager.ts +26 -5
- package/src/multicast-transport.ts +44 -20
|
@@ -42,7 +42,13 @@ export interface MulticastTransportConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
protected?: boolean;
|
|
44
44
|
}
|
|
45
|
-
|
|
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';
|
|
46
52
|
/**
|
|
47
53
|
* Why a joined transport handed control back to MoQ.
|
|
48
54
|
*
|
|
@@ -268,8 +274,10 @@ export declare class MulticastTransport<TPacketContext = never> {
|
|
|
268
274
|
/** Whether a subscription is live: joined, and not yet released or replaced. */
|
|
269
275
|
get joined(): boolean;
|
|
270
276
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
277
|
+
* The live join's context as the caller gave it (the join's `context`, or
|
|
278
|
+
* the last setContext), or undefined without a live join. On a native
|
|
279
|
+
* provider each accepted packet is delivered with a marked copy of it
|
|
280
|
+
* (`userAgentVerifiedIngress`); this getter never carries the mark.
|
|
273
281
|
*/
|
|
274
282
|
get context(): TPacketContext | undefined;
|
|
275
283
|
/**
|
|
@@ -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,EAOL,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,Q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,IAAI,cAAc,GAAG,SAAS,CAExC;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAE1C;IAED;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAqBzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyEzD,IAAI,iBAAiB,IAAI,0BAA0B,GAAG,SAAS,CAE9D;IAED,OAAO,IAAI,IAAI;CAkMhB"}
|
|
@@ -206,11 +206,33 @@ var AdaptiveBitrateController = class {
|
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
209
|
+
var MMTP_HEADER_SIZE = 12;
|
|
209
210
|
var MPU_HEADER_SIZE = 8;
|
|
210
211
|
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
211
212
|
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
212
213
|
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
213
214
|
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
|
+
}
|
|
214
236
|
|
|
215
237
|
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
216
238
|
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
@@ -1196,6 +1218,205 @@ var TransportManager = class {
|
|
|
1196
1218
|
};
|
|
1197
1219
|
var transportManager = new TransportManager();
|
|
1198
1220
|
|
|
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
|
+
|
|
1199
1420
|
// node_modules/@blockcast/mmt-transport/dist/moqt-priority.js
|
|
1200
1421
|
var MAX_MOQT_PRIORITY = 255;
|
|
1201
1422
|
function moqtPriority(value, field) {
|
|
@@ -1402,19 +1623,19 @@ var AMTGatewayManager = class {
|
|
|
1402
1623
|
var amtGatewayManager = new AMTGatewayManager();
|
|
1403
1624
|
|
|
1404
1625
|
// ../mmt-base/dist/mmtp.js
|
|
1405
|
-
var
|
|
1626
|
+
var MMTP_HEADER_SIZE2 = 12;
|
|
1406
1627
|
var MPU_HEADER_SIZE2 = 8;
|
|
1407
1628
|
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
1408
1629
|
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
1409
1630
|
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
1410
1631
|
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
1411
|
-
function
|
|
1412
|
-
if (buffer.length <
|
|
1632
|
+
function readMMTPPacketId2(buffer) {
|
|
1633
|
+
if (buffer.length < MMTP_HEADER_SIZE2)
|
|
1413
1634
|
return null;
|
|
1414
1635
|
const flags = buffer[0];
|
|
1415
1636
|
if ((flags >> 6 & 3) !== 0)
|
|
1416
1637
|
return null;
|
|
1417
|
-
let offset =
|
|
1638
|
+
let offset = MMTP_HEADER_SIZE2;
|
|
1418
1639
|
if ((flags & 32) !== 0) {
|
|
1419
1640
|
if (offset + 4 > buffer.length)
|
|
1420
1641
|
return null;
|
|
@@ -1544,11 +1765,8 @@ function providerErrorOf(error) {
|
|
|
1544
1765
|
return Object.freeze(typeof code === "string" ? { name, message, code } : { name, message });
|
|
1545
1766
|
}
|
|
1546
1767
|
var MAX_TRACKED_DROPPED_PIDS = 16;
|
|
1547
|
-
function getMulticastGlobals() {
|
|
1548
|
-
return globalThis;
|
|
1549
|
-
}
|
|
1550
1768
|
function hasMulticastGateway() {
|
|
1551
|
-
return typeof
|
|
1769
|
+
return typeof resolveMulticastGateway()?.subscribe === "function";
|
|
1552
1770
|
}
|
|
1553
1771
|
function senderOf(event) {
|
|
1554
1772
|
const sourceAddress = event.sourceAddress;
|
|
@@ -1640,6 +1858,9 @@ var MulticastTransport = class {
|
|
|
1640
1858
|
// listener closure, so an in-place admission change (setContext) applies
|
|
1641
1859
|
// from the next packet on without rejoining.
|
|
1642
1860
|
#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;
|
|
1643
1864
|
// The live join's provider-side filter. An in-place widening must reach it,
|
|
1644
1865
|
// or the provider never delivers the new ID; null without a live join.
|
|
1645
1866
|
#providerFilter = null;
|
|
@@ -1676,7 +1897,7 @@ var MulticastTransport = class {
|
|
|
1676
1897
|
this.#dataPlaneLive = false;
|
|
1677
1898
|
this.#sender = void 0;
|
|
1678
1899
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
1679
|
-
const gateway = this.#gateway ??
|
|
1900
|
+
const gateway = this.#gateway ?? resolveMulticastGateway();
|
|
1680
1901
|
if (typeof gateway?.subscribe !== "function") {
|
|
1681
1902
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
1682
1903
|
return this.#declined(generation, "unavailable");
|
|
@@ -1692,15 +1913,16 @@ var MulticastTransport = class {
|
|
|
1692
1913
|
console.log(
|
|
1693
1914
|
`[MulticastTransport] window.multicast.subscribe(${config.sourceAddress ?? config.senderAddress ?? "*"}, ${config.groupAddress}, ${config.port})`
|
|
1694
1915
|
);
|
|
1916
|
+
const userAgent = isUserAgentVerifiedGateway(gateway);
|
|
1695
1917
|
const subscribeConfig = toWindowMulticastSubscribeConfig({
|
|
1696
1918
|
source: config.sourceAddress,
|
|
1697
1919
|
senderAddress: config.senderAddress,
|
|
1698
1920
|
group: config.groupAddress,
|
|
1699
1921
|
port: config.port,
|
|
1700
|
-
mode: config.mode,
|
|
1701
|
-
amtRelay: config.amtRelay,
|
|
1702
|
-
amtRelayPort: config.amtRelayPort,
|
|
1703
|
-
amtDiscovery: config.amtDiscovery,
|
|
1922
|
+
mode: userAgent ? "native" : config.mode,
|
|
1923
|
+
amtRelay: userAgent ? void 0 : config.amtRelay,
|
|
1924
|
+
amtRelayPort: userAgent ? void 0 : config.amtRelayPort,
|
|
1925
|
+
amtDiscovery: userAgent ? void 0 : config.amtDiscovery,
|
|
1704
1926
|
packetIds: config.packetIds,
|
|
1705
1927
|
tracks: config.tracks,
|
|
1706
1928
|
atsc3: config.atsc3
|
|
@@ -1746,7 +1968,8 @@ var MulticastTransport = class {
|
|
|
1746
1968
|
acknowledgedUpdate: 0,
|
|
1747
1969
|
inFlight: 0
|
|
1748
1970
|
};
|
|
1749
|
-
this.#
|
|
1971
|
+
this.#userAgentGateway = userAgent ? gateway : void 0;
|
|
1972
|
+
this.#setContext(context);
|
|
1750
1973
|
if (packetIds) {
|
|
1751
1974
|
for (const packetId of packetIds) {
|
|
1752
1975
|
if (!this.#acceptedBytesByPacketId.has(packetId)) {
|
|
@@ -1754,7 +1977,7 @@ var MulticastTransport = class {
|
|
|
1754
1977
|
}
|
|
1755
1978
|
}
|
|
1756
1979
|
}
|
|
1757
|
-
this.#resolvedTransport = subscribeConfig.origin === "amt" ? "amt" : "native";
|
|
1980
|
+
this.#resolvedTransport = userAgent ? "user-agent" : subscribeConfig.origin === "amt" ? "amt" : "native";
|
|
1758
1981
|
const delivery = subscription.delivery ?? "datagram";
|
|
1759
1982
|
if (delivery !== "datagram" && delivery !== "ordered-relay") {
|
|
1760
1983
|
throw new Error(
|
|
@@ -1835,7 +2058,7 @@ var MulticastTransport = class {
|
|
|
1835
2058
|
}
|
|
1836
2059
|
if (!this.#acceptPacket(packet, sourceAddress)) return false;
|
|
1837
2060
|
const liveness = !this.#isRecordCandidate(packet);
|
|
1838
|
-
this.#onPacket(packet, this.#
|
|
2061
|
+
this.#onPacket(packet, this.#deliveredContext);
|
|
1839
2062
|
return liveness;
|
|
1840
2063
|
}
|
|
1841
2064
|
#isRecordCandidate(packet) {
|
|
@@ -2046,8 +2269,10 @@ var MulticastTransport = class {
|
|
|
2046
2269
|
return this.#subscription !== null;
|
|
2047
2270
|
}
|
|
2048
2271
|
/**
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2272
|
+
* The live join's context as the caller gave it (the join's `context`, or
|
|
2273
|
+
* the last setContext), or undefined without a live join. On a native
|
|
2274
|
+
* provider each accepted packet is delivered with a marked copy of it
|
|
2275
|
+
* (`userAgentVerifiedIngress`); this getter never carries the mark.
|
|
2051
2276
|
*/
|
|
2052
2277
|
get context() {
|
|
2053
2278
|
return this.#context;
|
|
@@ -2071,7 +2296,16 @@ var MulticastTransport = class {
|
|
|
2071
2296
|
"[MulticastTransport] setContext needs a live join; join() carries the first context"
|
|
2072
2297
|
);
|
|
2073
2298
|
}
|
|
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) {
|
|
2074
2307
|
this.#context = context;
|
|
2308
|
+
this.#deliveredContext = this.#userAgentGateway !== void 0 && typeof context === "object" && context !== null ? userAgentVerifiedIngress(context, this.#userAgentGateway) : context;
|
|
2075
2309
|
}
|
|
2076
2310
|
/**
|
|
2077
2311
|
* Replace the live join's packet-ID allow-list in place, without rejoining.
|
|
@@ -2203,6 +2437,8 @@ var MulticastTransport = class {
|
|
|
2203
2437
|
this.#matchedSource = void 0;
|
|
2204
2438
|
this.#providerFilter = null;
|
|
2205
2439
|
this.#context = void 0;
|
|
2440
|
+
this.#deliveredContext = void 0;
|
|
2441
|
+
this.#userAgentGateway = void 0;
|
|
2206
2442
|
this.#withdrawnPacketIds.clear();
|
|
2207
2443
|
}
|
|
2208
2444
|
/** The ingress filter; an accepted packet is counted here, once. */
|
|
@@ -2224,7 +2460,7 @@ var MulticastTransport = class {
|
|
|
2224
2460
|
this.#countAccepted(packet, null, void 0);
|
|
2225
2461
|
return true;
|
|
2226
2462
|
}
|
|
2227
|
-
const packetId =
|
|
2463
|
+
const packetId = readMMTPPacketId2(packet);
|
|
2228
2464
|
if (packetId === null) {
|
|
2229
2465
|
if (!this.#packetIds) {
|
|
2230
2466
|
this.#countAccepted(packet, null, sourceAddress);
|