@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbd83cb48eff
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 +5 -3
- package/dist/browser-runtime.js +532 -333
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +5 -3
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +18 -5
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +5 -2
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +100 -36
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.js +3 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/delivery-catalog.js +84 -220
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +15 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +99 -39
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +3 -2
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +16 -9
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +13 -2
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js +3 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +24 -13
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +96 -22
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +124 -36
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +96 -22
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +14 -4
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +139 -22
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-input.js +3 -0
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +49 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +437 -302
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +93 -224
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +24 -13
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +123 -35
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.js +3 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.js +3 -0
- package/dist/repair-layers.js.map +3 -3
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.js +3 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +24 -13
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +96 -22
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/carp-catalog.ts +33 -10
- package/src/catalog-fec-params.ts +38 -17
- package/src/fec-manager.ts +111 -49
- package/src/fec-state.ts +4 -9
- package/src/fec-worker-setup.ts +16 -1
- package/src/index.ts +5 -0
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-router.ts +76 -5
- package/src/multicast-manager.ts +143 -7
- package/src/multicast-transport.ts +14 -3
- package/src/sample-combiner.ts +15 -2
- package/test-vectors/catalog/README.md +5 -1
- package/test-vectors/catalog-validation.json +95 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* takeover/failback. Delegates raw packets to a callback (MmtpRouter
|
|
4
4
|
* or any direct consumer).
|
|
5
5
|
*/
|
|
6
|
-
import { type WindowMulticastDelivery } from '@blockcast/mmt-transport';
|
|
6
|
+
import { type WindowMulticastDelivery, type WindowMulticastGateway } from '@blockcast/mmt-transport';
|
|
7
7
|
export interface MulticastTransportConfig {
|
|
8
8
|
sourceAddress: string;
|
|
9
9
|
groupAddress: string;
|
|
@@ -11,6 +11,8 @@ export interface MulticastTransportConfig {
|
|
|
11
11
|
mode?: 'auto' | 'native' | 'tunnel';
|
|
12
12
|
amtRelay?: string;
|
|
13
13
|
amtRelayPort?: number;
|
|
14
|
+
/** `'driad'`: with no relay, the gateway discovers one per RFC 8777. */
|
|
15
|
+
amtDiscovery?: 'driad';
|
|
14
16
|
packetIds?: number[];
|
|
15
17
|
tracks?: {
|
|
16
18
|
name: string;
|
|
@@ -122,7 +124,9 @@ export interface MulticastJoinStats {
|
|
|
122
124
|
}
|
|
123
125
|
export declare class MulticastTransport<TPacketContext = never> {
|
|
124
126
|
#private;
|
|
125
|
-
constructor(onPacket: (packet: Uint8Array, context?: TPacketContext) => void
|
|
127
|
+
constructor(onPacket: (packet: Uint8Array, context?: TPacketContext) => void, options?: {
|
|
128
|
+
gateway?: WindowMulticastGateway;
|
|
129
|
+
});
|
|
126
130
|
static isAvailable(): boolean;
|
|
127
131
|
join(config: MulticastTransportConfig, context?: TPacketContext): Promise<boolean>;
|
|
128
132
|
/** Feed a raw packet from an external source (e.g., AMT tunnel or ASM subscription). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multicast-transport.d.ts","sourceRoot":"","sources":["../src/multicast-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"multicast-transport.d.ts","sourceRoot":"","sources":["../src/multicast-transport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AI;IASzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CAgKhB"}
|
|
@@ -6,178 +6,6 @@ var MoqFecAlgorithm;
|
|
|
6
6
|
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
7
7
|
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
8
8
|
|
|
9
|
-
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
10
|
-
var MPU_HEADER_SIZE = 8;
|
|
11
|
-
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
12
|
-
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
13
|
-
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
14
|
-
var MMTP_PACKET_ID_MAX = 65535;
|
|
15
|
-
|
|
16
|
-
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
17
|
-
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
18
|
-
|
|
19
|
-
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
20
|
-
var NTP_SHORT_BITS = 32;
|
|
21
|
-
var NTP_SHORT_MODULUS = 2 ** NTP_SHORT_BITS;
|
|
22
|
-
var NTP_SHORT_HALF_RANGE = 2 ** (NTP_SHORT_BITS - 1);
|
|
23
|
-
function isNtpShort(value) {
|
|
24
|
-
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS;
|
|
25
|
-
}
|
|
26
|
-
function compareNtpShort(a, b) {
|
|
27
|
-
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
28
|
-
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS}), got ${String(a)} and ${String(b)}`);
|
|
29
|
-
}
|
|
30
|
-
if (a === b)
|
|
31
|
-
return "equal";
|
|
32
|
-
const forward = (a - b + NTP_SHORT_MODULUS) % NTP_SHORT_MODULUS;
|
|
33
|
-
if (forward < NTP_SHORT_HALF_RANGE)
|
|
34
|
-
return "after";
|
|
35
|
-
if (forward > NTP_SHORT_HALF_RANGE)
|
|
36
|
-
return "before";
|
|
37
|
-
return "unordered";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
41
|
-
var FEC_BLOCK_PROFILES = Object.freeze([
|
|
42
|
-
"iso-ssbg1-v1"
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
46
|
-
var DRIADDiscovery = class {
|
|
47
|
-
cache = /* @__PURE__ */ new Map();
|
|
48
|
-
cacheExpiry = 3e5;
|
|
49
|
-
// 5 minutes
|
|
50
|
-
/**
|
|
51
|
-
* Discover AMT relays for a multicast source address (RFC 8777)
|
|
52
|
-
*
|
|
53
|
-
* @param source - The multicast source IP address (NOT the group!)
|
|
54
|
-
* @returns Array of discovered AMT relays that can tunnel traffic from this source
|
|
55
|
-
*/
|
|
56
|
-
async discoverRelays(source) {
|
|
57
|
-
const cached = this.cache.get(source);
|
|
58
|
-
if (cached) {
|
|
59
|
-
return cached;
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
63
|
-
const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
|
|
64
|
-
console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
|
|
65
|
-
const relays = await this.queryDRIADProxy(source);
|
|
66
|
-
if (relays.length > 0) {
|
|
67
|
-
this.cache.set(source, relays);
|
|
68
|
-
setTimeout(() => this.cache.delete(source), this.cacheExpiry);
|
|
69
|
-
}
|
|
70
|
-
return relays;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Query DRIAD proxy service (browser-compatible)
|
|
78
|
-
*/
|
|
79
|
-
async queryDRIADProxy(source) {
|
|
80
|
-
const proxyEndpoints = [
|
|
81
|
-
"https://driad.amt.net/api/v1/relays",
|
|
82
|
-
"https://multicast-gateway.cloudflare.com/driad"
|
|
83
|
-
];
|
|
84
|
-
for (const endpoint of proxyEndpoints) {
|
|
85
|
-
try {
|
|
86
|
-
const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
|
|
87
|
-
method: "GET",
|
|
88
|
-
headers: { Accept: "application/json" },
|
|
89
|
-
signal: AbortSignal.timeout(5e3)
|
|
90
|
-
});
|
|
91
|
-
if (response.ok) {
|
|
92
|
-
const data = await response.json();
|
|
93
|
-
return data.relays || [];
|
|
94
|
-
}
|
|
95
|
-
} catch {
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const dohRelay = await this.queryDNSOverHTTPS(source);
|
|
99
|
-
if (dohRelay) {
|
|
100
|
-
return [dohRelay];
|
|
101
|
-
}
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
|
|
106
|
-
*/
|
|
107
|
-
async queryDNSOverHTTPS(source) {
|
|
108
|
-
try {
|
|
109
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
110
|
-
const queryName = `${reversedSource}.amt.in-addr.arpa`;
|
|
111
|
-
const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
|
|
112
|
-
const response = await fetch(dohUrl, {
|
|
113
|
-
headers: { Accept: "application/dns-json" },
|
|
114
|
-
signal: AbortSignal.timeout(3e3)
|
|
115
|
-
});
|
|
116
|
-
if (!response.ok) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
const result = await response.json();
|
|
120
|
-
if (result.Answer && result.Answer.length > 0) {
|
|
121
|
-
return {
|
|
122
|
-
host: result.Answer[0].data,
|
|
123
|
-
port: DEFAULT_AMT_RELAY_PORT,
|
|
124
|
-
priority: 10,
|
|
125
|
-
weight: 100,
|
|
126
|
-
asn: 0
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Select best relay based on RTT measurements
|
|
137
|
-
*/
|
|
138
|
-
async selectBestRelay(relays) {
|
|
139
|
-
if (relays.length === 0)
|
|
140
|
-
return null;
|
|
141
|
-
const measured = await Promise.all(relays.map(async (relay) => {
|
|
142
|
-
const rtt = await this.measureRTT(relay.host, relay.port);
|
|
143
|
-
return { ...relay, rtt };
|
|
144
|
-
}));
|
|
145
|
-
measured.sort((a, b) => {
|
|
146
|
-
if (a.priority !== b.priority)
|
|
147
|
-
return a.priority - b.priority;
|
|
148
|
-
return (a.rtt || Infinity) - (b.rtt || Infinity);
|
|
149
|
-
});
|
|
150
|
-
console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
|
|
151
|
-
return measured[0];
|
|
152
|
-
}
|
|
153
|
-
async measureRTT(host, _port) {
|
|
154
|
-
const start = performance.now();
|
|
155
|
-
try {
|
|
156
|
-
await fetch(`https://${host}/health`, {
|
|
157
|
-
method: "HEAD",
|
|
158
|
-
signal: AbortSignal.timeout(2e3),
|
|
159
|
-
mode: "no-cors"
|
|
160
|
-
});
|
|
161
|
-
return performance.now() - start;
|
|
162
|
-
} catch {
|
|
163
|
-
return Infinity;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Clear the relay cache
|
|
168
|
-
*/
|
|
169
|
-
clearCache() {
|
|
170
|
-
this.cache.clear();
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Get cached relays for a source address
|
|
174
|
-
*/
|
|
175
|
-
getCached(source) {
|
|
176
|
-
return this.cache.get(source);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
var driadDiscovery = new DRIADDiscovery();
|
|
180
|
-
|
|
181
9
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
182
10
|
function endpointKey(endpoint) {
|
|
183
11
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -385,6 +213,45 @@ var AdaptiveBitrateController = class {
|
|
|
385
213
|
}
|
|
386
214
|
};
|
|
387
215
|
|
|
216
|
+
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
217
|
+
var MPU_HEADER_SIZE = 8;
|
|
218
|
+
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
219
|
+
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
220
|
+
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
221
|
+
var MMTP_PACKET_ID_MAX = 65535;
|
|
222
|
+
|
|
223
|
+
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
224
|
+
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
225
|
+
|
|
226
|
+
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
227
|
+
var NTP_SHORT_BITS = 32;
|
|
228
|
+
var NTP_SHORT_MODULUS = 2 ** NTP_SHORT_BITS;
|
|
229
|
+
var NTP_SHORT_HALF_RANGE = 2 ** (NTP_SHORT_BITS - 1);
|
|
230
|
+
function isNtpShort(value) {
|
|
231
|
+
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS;
|
|
232
|
+
}
|
|
233
|
+
function compareNtpShort(a, b) {
|
|
234
|
+
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
235
|
+
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS}), got ${String(a)} and ${String(b)}`);
|
|
236
|
+
}
|
|
237
|
+
if (a === b)
|
|
238
|
+
return "equal";
|
|
239
|
+
const forward = (a - b + NTP_SHORT_MODULUS) % NTP_SHORT_MODULUS;
|
|
240
|
+
if (forward < NTP_SHORT_HALF_RANGE)
|
|
241
|
+
return "after";
|
|
242
|
+
if (forward > NTP_SHORT_HALF_RANGE)
|
|
243
|
+
return "before";
|
|
244
|
+
return "unordered";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
248
|
+
var FEC_BLOCK_PROFILES = Object.freeze([
|
|
249
|
+
"iso-ssbg1-v1"
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
253
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
254
|
+
|
|
388
255
|
// node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
|
|
389
256
|
var DEFAULT_DWELL_MS = 3e3;
|
|
390
257
|
var DEFAULT_JOIN_DEADLINE_MS = 5e3;
|
|
@@ -623,7 +490,8 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
623
490
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
624
491
|
};
|
|
625
492
|
const relay = input.amtRelay?.trim();
|
|
626
|
-
const
|
|
493
|
+
const driad = !relay && input.amtDiscovery === "driad";
|
|
494
|
+
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
627
495
|
if (!wantsAmt) {
|
|
628
496
|
const native = {
|
|
629
497
|
...base,
|
|
@@ -633,6 +501,20 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
633
501
|
return native;
|
|
634
502
|
}
|
|
635
503
|
const relayPort = input.amtRelayPort;
|
|
504
|
+
if (driad) {
|
|
505
|
+
if (!base.source)
|
|
506
|
+
throw new TypeError("AMT DRIAD discovery requires a source address");
|
|
507
|
+
if (relayPort !== void 0 && !isPositivePort(relayPort)) {
|
|
508
|
+
throw new TypeError("AMT DRIAD discovery requires a valid relay port when one is given");
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
...base,
|
|
512
|
+
source: base.source,
|
|
513
|
+
origin: "amt",
|
|
514
|
+
discovery: "driad",
|
|
515
|
+
...relayPort !== void 0 ? { relayPort } : {}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
636
518
|
if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
|
|
637
519
|
throw new TypeError("AMT requires a resolved relay and a valid relay port");
|
|
638
520
|
}
|
|
@@ -676,7 +558,8 @@ function normalizeMulticastEndpoint(endpoint) {
|
|
|
676
558
|
port: endpoint.port,
|
|
677
559
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
678
560
|
...amtRelay ? { amtRelay } : {},
|
|
679
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
561
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
562
|
+
...endpoint.amtDiscovery === "driad" ? { amtDiscovery: "driad" } : {}
|
|
680
563
|
};
|
|
681
564
|
}
|
|
682
565
|
function multicastEndpointKey(endpoint) {
|
|
@@ -689,7 +572,9 @@ function multicastEndpointKey(endpoint) {
|
|
|
689
572
|
normalized.port,
|
|
690
573
|
normalized.mode ?? "auto",
|
|
691
574
|
normalized.amtRelay ?? "",
|
|
692
|
-
normalized.amtRelayPort ?? ""
|
|
575
|
+
normalized.amtRelayPort ?? "",
|
|
576
|
+
// A DRIAD join is a different gateway subscription from a native one.
|
|
577
|
+
...normalized.amtDiscovery ? [normalized.amtDiscovery] : []
|
|
693
578
|
]);
|
|
694
579
|
}
|
|
695
580
|
function isMulticastTrackPacketId(value) {
|
|
@@ -729,7 +614,8 @@ var MulticastSubscriptionPool = class {
|
|
|
729
614
|
port: config.port,
|
|
730
615
|
mode: config.mode,
|
|
731
616
|
amtRelay: config.amtRelay,
|
|
732
|
-
amtRelayPort: config.amtRelayPort
|
|
617
|
+
amtRelayPort: config.amtRelayPort,
|
|
618
|
+
amtDiscovery: config.amtDiscovery
|
|
733
619
|
});
|
|
734
620
|
if (!endpoint)
|
|
735
621
|
throw new Error("Invalid multicast endpoint");
|
|
@@ -795,7 +681,8 @@ var MulticastSubscriptionPool = class {
|
|
|
795
681
|
port: endpoint.port,
|
|
796
682
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
797
683
|
...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
|
|
798
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
684
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
685
|
+
...endpoint.amtDiscovery ? { amtDiscovery: endpoint.amtDiscovery } : {}
|
|
799
686
|
}));
|
|
800
687
|
const consumers = /* @__PURE__ */ new Map();
|
|
801
688
|
let entry;
|
|
@@ -875,7 +762,6 @@ var TransportManager = class {
|
|
|
875
762
|
};
|
|
876
763
|
capabilities = null;
|
|
877
764
|
subscription = null;
|
|
878
|
-
driad = new DRIADDiscovery();
|
|
879
765
|
/** Built by `connect()` from the caller's ladder; there is no built-in one. */
|
|
880
766
|
abr = null;
|
|
881
767
|
multicastOrchestrator = null;
|
|
@@ -925,8 +811,8 @@ var TransportManager = class {
|
|
|
925
811
|
nativeIGMP: hasGatewayBytes,
|
|
926
812
|
directSockets: typeof win?.UDPSocket !== "undefined",
|
|
927
813
|
amt: false,
|
|
928
|
-
driad:
|
|
929
|
-
//
|
|
814
|
+
driad: hasGatewayBytes,
|
|
815
|
+
// the gateway runs RFC 8777 discovery
|
|
930
816
|
fecDecode: false
|
|
931
817
|
};
|
|
932
818
|
console.log("[Transport] Capabilities:", this.capabilities);
|
|
@@ -937,7 +823,7 @@ var TransportManager = class {
|
|
|
937
823
|
*
|
|
938
824
|
* Promotion hierarchy:
|
|
939
825
|
* 1. window.multicast gateway bytes
|
|
940
|
-
* 2. AMT
|
|
826
|
+
* 2. AMT: a configured relay via the AMT proxy, else gateway DRIAD discovery
|
|
941
827
|
* 3. MOQ WebTransport (final fallback)
|
|
942
828
|
*
|
|
943
829
|
* The ABR ladder (`abrLadder`) and initial rendition (`initialQuality`)
|
|
@@ -1031,7 +917,7 @@ var TransportManager = class {
|
|
|
1031
917
|
/**
|
|
1032
918
|
* Connect via the lowercase window.multicast bytes gateway.
|
|
1033
919
|
*/
|
|
1034
|
-
async connectWindowMulticast(config, generation) {
|
|
920
|
+
async connectWindowMulticast(config, generation, mode = "multicast") {
|
|
1035
921
|
try {
|
|
1036
922
|
const gateway = this.getWindowMulticastGateway();
|
|
1037
923
|
if (typeof gateway?.subscribe !== "function")
|
|
@@ -1066,7 +952,7 @@ var TransportManager = class {
|
|
|
1066
952
|
}
|
|
1067
953
|
};
|
|
1068
954
|
this.state = {
|
|
1069
|
-
mode
|
|
955
|
+
mode,
|
|
1070
956
|
connected: true,
|
|
1071
957
|
group: config.group,
|
|
1072
958
|
source: config.source,
|
|
@@ -1084,29 +970,19 @@ var TransportManager = class {
|
|
|
1084
970
|
}
|
|
1085
971
|
}
|
|
1086
972
|
/**
|
|
1087
|
-
* Connect via AMT proxy
|
|
973
|
+
* Connect via AMT: a configured relay goes through the AMT proxy; with no
|
|
974
|
+
* relay, the window.multicast gateway discovers one per RFC 8777 (DRIAD).
|
|
1088
975
|
*/
|
|
1089
976
|
async connectAmt(config, generation) {
|
|
1090
977
|
try {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const relays = await this.driad.discoverRelays(config.source);
|
|
1095
|
-
if (generation !== this.connectionGeneration)
|
|
1096
|
-
return false;
|
|
1097
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
1098
|
-
if (generation !== this.connectionGeneration)
|
|
1099
|
-
return false;
|
|
1100
|
-
if (bestRelay) {
|
|
1101
|
-
amtRelay = bestRelay.host;
|
|
1102
|
-
this.state.amtRelay = amtRelay;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
if (!amtRelay) {
|
|
978
|
+
if (config.amtRelay)
|
|
979
|
+
return await this.connectAmtProxy(config, config.amtRelay, generation);
|
|
980
|
+
if (config.driadEnabled === false || !config.source || config.mode === "native") {
|
|
1106
981
|
console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
|
|
1107
982
|
return false;
|
|
1108
983
|
}
|
|
1109
|
-
|
|
984
|
+
console.log(`[Transport] Asking the gateway for a DRIAD relay for source ${config.source}...`);
|
|
985
|
+
return await this.connectWindowMulticast({ ...config, amtDiscovery: "driad" }, generation, "amt");
|
|
1110
986
|
} catch (error) {
|
|
1111
987
|
console.warn("[Transport] AMT connection failed:", error);
|
|
1112
988
|
return false;
|
|
@@ -1337,7 +1213,6 @@ var AMTGatewayManager = class {
|
|
|
1337
1213
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1338
1214
|
messageHandler;
|
|
1339
1215
|
pendingPackets = /* @__PURE__ */ new Map();
|
|
1340
|
-
driad = new DRIADDiscovery();
|
|
1341
1216
|
constructor() {
|
|
1342
1217
|
this.messageHandler = (event) => {
|
|
1343
1218
|
const data = event.data;
|
|
@@ -1368,26 +1243,12 @@ var AMTGatewayManager = class {
|
|
|
1368
1243
|
return keyStr;
|
|
1369
1244
|
}
|
|
1370
1245
|
try {
|
|
1371
|
-
|
|
1372
|
-
let discoveryMethod;
|
|
1246
|
+
const relayAddress = config.relayAddress;
|
|
1373
1247
|
const relayPort = config.relayPort || DEFAULT_AMT_RELAY_PORT;
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1376
|
-
discoveryMethod = "manual";
|
|
1377
|
-
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
1378
|
-
} else if (key.source) {
|
|
1379
|
-
console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
|
|
1380
|
-
const relays = await this.driad.discoverRelays(key.source);
|
|
1381
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
1382
|
-
if (!bestRelay) {
|
|
1383
|
-
throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
|
|
1384
|
-
}
|
|
1385
|
-
relayAddress = bestRelay.host;
|
|
1386
|
-
discoveryMethod = "driad";
|
|
1387
|
-
console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
|
|
1388
|
-
} else {
|
|
1389
|
-
throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
|
|
1248
|
+
if (!relayAddress) {
|
|
1249
|
+
throw new Error(`AMT relay address required: this manager does no relay discovery. For RFC 8777 DRIAD discovery, join through window.multicast with amtDiscovery: "driad".`);
|
|
1390
1250
|
}
|
|
1251
|
+
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
1391
1252
|
const subscriptionId = keyStr;
|
|
1392
1253
|
this.pendingPackets.set(subscriptionId, []);
|
|
1393
1254
|
const subscription = {
|
|
@@ -1398,7 +1259,7 @@ var AMTGatewayManager = class {
|
|
|
1398
1259
|
relay: {
|
|
1399
1260
|
address: relayAddress,
|
|
1400
1261
|
port: relayPort,
|
|
1401
|
-
discoveryMethod,
|
|
1262
|
+
discoveryMethod: "manual",
|
|
1402
1263
|
discoveredAt: Date.now()
|
|
1403
1264
|
}
|
|
1404
1265
|
};
|
|
@@ -1550,6 +1411,9 @@ var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
|
1550
1411
|
"iso-ssbg1-v1"
|
|
1551
1412
|
]);
|
|
1552
1413
|
|
|
1414
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
1415
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
1416
|
+
|
|
1553
1417
|
// src/multicast-transport.ts
|
|
1554
1418
|
var JOIN_SUCCEEDED = Object.freeze({ ok: true });
|
|
1555
1419
|
function providerErrorOf(error) {
|
|
@@ -1593,7 +1457,7 @@ function sameIds(a, b) {
|
|
|
1593
1457
|
for (const id of a) if (!b.has(id)) return false;
|
|
1594
1458
|
return true;
|
|
1595
1459
|
}
|
|
1596
|
-
var MulticastTransport = class
|
|
1460
|
+
var MulticastTransport = class {
|
|
1597
1461
|
#onPacket;
|
|
1598
1462
|
#subscription = null;
|
|
1599
1463
|
#packetListener = null;
|
|
@@ -1665,8 +1529,11 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
1665
1529
|
// droppedPacketIds.
|
|
1666
1530
|
#unadvertisedPacketIds = /* @__PURE__ */ new Set();
|
|
1667
1531
|
#joinGeneration = 0;
|
|
1668
|
-
|
|
1532
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
1533
|
+
#gateway;
|
|
1534
|
+
constructor(onPacket, options = {}) {
|
|
1669
1535
|
this.#onPacket = onPacket;
|
|
1536
|
+
this.#gateway = options.gateway;
|
|
1670
1537
|
}
|
|
1671
1538
|
static isAvailable() {
|
|
1672
1539
|
return hasMulticastGateway();
|
|
@@ -1676,7 +1543,8 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
1676
1543
|
this.#releaseSubscription();
|
|
1677
1544
|
this.#dataPlaneLive = false;
|
|
1678
1545
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
1679
|
-
|
|
1546
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
1547
|
+
if (typeof gateway?.subscribe !== "function") {
|
|
1680
1548
|
console.warn("[MulticastTransport] Multicast API not available");
|
|
1681
1549
|
return this.#declined(generation, "unavailable");
|
|
1682
1550
|
}
|
|
@@ -1693,11 +1561,12 @@ var MulticastTransport = class _MulticastTransport {
|
|
|
1693
1561
|
mode: config.mode,
|
|
1694
1562
|
amtRelay: config.amtRelay,
|
|
1695
1563
|
amtRelayPort: config.amtRelayPort,
|
|
1564
|
+
amtDiscovery: config.amtDiscovery,
|
|
1696
1565
|
packetIds: config.packetIds,
|
|
1697
1566
|
tracks: config.tracks
|
|
1698
1567
|
});
|
|
1699
1568
|
failure = "provider-rejected";
|
|
1700
|
-
const subscription = await
|
|
1569
|
+
const subscription = await gateway.subscribe(subscribeConfig);
|
|
1701
1570
|
failure = "invalid-subscription";
|
|
1702
1571
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription);
|
|
1703
1572
|
if (this.#disposed || generation !== this.#joinGeneration) {
|