@blockcast/mmt-container 0.5.0 → 1.0.0-main.215b8665a0eb
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 +1 -1
- package/dist/browser-runtime.js +367 -52
- package/dist/browser-runtime.js.map +4 -4
- package/dist/fec-catalog.d.ts +33 -0
- package/dist/fec-catalog.d.ts.map +1 -0
- package/dist/fec-catalog.js +296 -0
- package/dist/fec-catalog.js.map +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +2 -2
- package/dist/mmtp-router.d.ts +7 -16
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +13 -27
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +5 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +69 -48
- package/dist/multicast-manager.js.map +2 -2
- package/dist/multicast-transport.d.ts +23 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +45 -12
- package/dist/multicast-transport.js.map +2 -2
- package/package.json +9 -5
- package/src/fec-catalog.ts +428 -0
- package/src/index.ts +11 -0
- package/src/mmtp-router.ts +14 -29
- package/src/multicast-manager.ts +17 -11
- package/src/multicast-transport.ts +65 -12
|
@@ -117,6 +117,15 @@ export interface MulticastTransportStats {
|
|
|
117
117
|
* `droppedPacketIds` slot.
|
|
118
118
|
*/
|
|
119
119
|
packetsDroppedSignaling: number;
|
|
120
|
+
/**
|
|
121
|
+
* From a sender other than the one this join locked to (BLO-50098). An
|
|
122
|
+
* unprotected ASM subscription admits any source, so two senders can share
|
|
123
|
+
* one (G, port, packet_id); the first sender whose packet is accepted owns
|
|
124
|
+
* the sub-flow until the next join, and every other sender is dropped here,
|
|
125
|
+
* before any gap, duplicate or FEC ledger sees it. A join or a silence
|
|
126
|
+
* failback releases the lock.
|
|
127
|
+
*/
|
|
128
|
+
packetsDroppedForeignSender: number;
|
|
120
129
|
}
|
|
121
130
|
/**
|
|
122
131
|
* join() calls by how they resolved, cumulative for the life of the transport:
|
|
@@ -133,13 +142,23 @@ export interface MulticastJoinStats {
|
|
|
133
142
|
}
|
|
134
143
|
export declare class MulticastTransport<TPacketContext = never> {
|
|
135
144
|
#private;
|
|
145
|
+
/**
|
|
146
|
+
* `lockedTo` reads the sender another transport is locked to (a repair
|
|
147
|
+
* group follows its media join, whose publisher sends both). While it reads
|
|
148
|
+
* a sender, this join admits only that one; until then its own lock applies.
|
|
149
|
+
*/
|
|
136
150
|
constructor(onPacket: (packet: Uint8Array, context?: TPacketContext) => void, options?: {
|
|
137
151
|
gateway?: WindowMulticastGateway;
|
|
152
|
+
lockedTo?: () => string | undefined;
|
|
138
153
|
});
|
|
139
154
|
static isAvailable(): boolean;
|
|
140
155
|
join(config: MulticastTransportConfig, context?: TPacketContext): Promise<boolean>;
|
|
141
|
-
/**
|
|
142
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Feed a raw packet from an external source (e.g., AMT tunnel or ASM
|
|
158
|
+
* subscription). `sourceAddress` is the datagram's sender when the source
|
|
159
|
+
* knows it; see packetsDroppedForeignSender.
|
|
160
|
+
*/
|
|
161
|
+
feedPacket(data: ArrayBuffer | Uint8Array, context?: TPacketContext, sourceAddress?: string): void;
|
|
143
162
|
confirmVideo(): void;
|
|
144
163
|
confirmAudio(): void;
|
|
145
164
|
onTakeover(cb: () => void): void;
|
|
@@ -229,6 +248,8 @@ export declare class MulticastTransport<TPacketContext = never> {
|
|
|
229
248
|
* cumulative across rejoins.
|
|
230
249
|
*/
|
|
231
250
|
get withdrawnPacketIdDrops(): number;
|
|
251
|
+
/** The sender this join is locked to; undefined until one is known. */
|
|
252
|
+
get sender(): string | undefined;
|
|
232
253
|
/** Whether a subscription is live: joined, and not yet released or replaced. */
|
|
233
254
|
get joined(): boolean;
|
|
234
255
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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E1C;IAED;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;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;CA0KhB"}
|
|
@@ -1461,6 +1461,10 @@ function getMulticastGlobals() {
|
|
|
1461
1461
|
function hasMulticastGateway() {
|
|
1462
1462
|
return typeof getMulticastGlobals().multicast?.subscribe === "function";
|
|
1463
1463
|
}
|
|
1464
|
+
function senderOf(event) {
|
|
1465
|
+
const sourceAddress = event.sourceAddress;
|
|
1466
|
+
return typeof sourceAddress === "string" ? sourceAddress : void 0;
|
|
1467
|
+
}
|
|
1464
1468
|
function normalizeBytesEventDetail(detail) {
|
|
1465
1469
|
const value = detail && typeof detail === "object" && "data" in detail ? detail.data : detail;
|
|
1466
1470
|
if (value instanceof Uint8Array) return value;
|
|
@@ -1507,7 +1511,8 @@ var MulticastTransport = class {
|
|
|
1507
1511
|
bytesReceived: 0,
|
|
1508
1512
|
packetsDroppedUnregisteredPid: 0,
|
|
1509
1513
|
packetsDroppedUnparseable: 0,
|
|
1510
|
-
packetsDroppedSignaling: 0
|
|
1514
|
+
packetsDroppedSignaling: 0,
|
|
1515
|
+
packetsDroppedForeignSender: 0
|
|
1511
1516
|
};
|
|
1512
1517
|
// join() calls by how they resolved; see joinStats.
|
|
1513
1518
|
#joinsSucceeded = 0;
|
|
@@ -1532,6 +1537,11 @@ var MulticastTransport = class {
|
|
|
1532
1537
|
// per packet once a count outgrows the small-integer range.
|
|
1533
1538
|
#acceptedBytesByPacketId = /* @__PURE__ */ new Map();
|
|
1534
1539
|
#packetIds = null;
|
|
1540
|
+
// The sender S this join's accepted packets came from, once known; see
|
|
1541
|
+
// packetsDroppedForeignSender. Cleared by every join and by a silence
|
|
1542
|
+
// failback, so a replacement publisher is not locked out.
|
|
1543
|
+
#sender = void 0;
|
|
1544
|
+
#lockedTo;
|
|
1535
1545
|
// What the live join delivers with each accepted packet. A field, not a
|
|
1536
1546
|
// listener closure, so an in-place admission change (setContext) applies
|
|
1537
1547
|
// from the next packet on without rejoining.
|
|
@@ -1553,9 +1563,15 @@ var MulticastTransport = class {
|
|
|
1553
1563
|
#joinGeneration = 0;
|
|
1554
1564
|
// The provider to subscribe through; window.multicast when unset.
|
|
1555
1565
|
#gateway;
|
|
1566
|
+
/**
|
|
1567
|
+
* `lockedTo` reads the sender another transport is locked to (a repair
|
|
1568
|
+
* group follows its media join, whose publisher sends both). While it reads
|
|
1569
|
+
* a sender, this join admits only that one; until then its own lock applies.
|
|
1570
|
+
*/
|
|
1556
1571
|
constructor(onPacket, options = {}) {
|
|
1557
1572
|
this.#onPacket = onPacket;
|
|
1558
1573
|
this.#gateway = options.gateway;
|
|
1574
|
+
this.#lockedTo = options.lockedTo;
|
|
1559
1575
|
}
|
|
1560
1576
|
static isAvailable() {
|
|
1561
1577
|
return hasMulticastGateway();
|
|
@@ -1564,6 +1580,7 @@ var MulticastTransport = class {
|
|
|
1564
1580
|
const generation = ++this.#joinGeneration;
|
|
1565
1581
|
this.#releaseSubscription();
|
|
1566
1582
|
this.#dataPlaneLive = false;
|
|
1583
|
+
this.#sender = void 0;
|
|
1567
1584
|
if (this.#disposed) return this.#declined(generation, "disposed");
|
|
1568
1585
|
const gateway = this.#gateway ?? getMulticastGlobals().multicast;
|
|
1569
1586
|
if (typeof gateway?.subscribe !== "function") {
|
|
@@ -1605,7 +1622,8 @@ var MulticastTransport = class {
|
|
|
1605
1622
|
}
|
|
1606
1623
|
this.#subscription = subscription;
|
|
1607
1624
|
const live = () => !this.#disposed && generation === this.#joinGeneration;
|
|
1608
|
-
const
|
|
1625
|
+
const anySource = !config.sourceAddress && !config.senderAddress && !config.atsc3;
|
|
1626
|
+
const packetListener = !anySource && subscriptionDeliversPacketBatches(subscription) ? {
|
|
1609
1627
|
type: "packets",
|
|
1610
1628
|
listener: (event) => {
|
|
1611
1629
|
if (!live()) return;
|
|
@@ -1615,7 +1633,7 @@ var MulticastTransport = class {
|
|
|
1615
1633
|
type: "bytes",
|
|
1616
1634
|
listener: (event) => {
|
|
1617
1635
|
if (!live()) return;
|
|
1618
|
-
if (this.#deliver(event.detail)) this.#resetWatchdog();
|
|
1636
|
+
if (this.#deliver(event.detail, senderOf(event))) this.#resetWatchdog();
|
|
1619
1637
|
}
|
|
1620
1638
|
};
|
|
1621
1639
|
this.#packetListener = packetListener;
|
|
@@ -1706,13 +1724,13 @@ var MulticastTransport = class {
|
|
|
1706
1724
|
* One packet from the subscription: filter, count, and hand it to the
|
|
1707
1725
|
* callback. Returns whether it was delivered; the caller notes liveness.
|
|
1708
1726
|
*/
|
|
1709
|
-
#deliver(detail) {
|
|
1727
|
+
#deliver(detail, sourceAddress) {
|
|
1710
1728
|
const packet = normalizeBytesEventDetail(detail);
|
|
1711
1729
|
if (!packet) {
|
|
1712
1730
|
this.#stats.packetsDroppedUnparseable++;
|
|
1713
1731
|
return false;
|
|
1714
1732
|
}
|
|
1715
|
-
if (!this.#acceptPacket(packet)) return false;
|
|
1733
|
+
if (!this.#acceptPacket(packet, sourceAddress)) return false;
|
|
1716
1734
|
this.#onPacket(packet, this.#context);
|
|
1717
1735
|
return true;
|
|
1718
1736
|
}
|
|
@@ -1753,11 +1771,15 @@ var MulticastTransport = class {
|
|
|
1753
1771
|
throw failures[0];
|
|
1754
1772
|
}
|
|
1755
1773
|
}
|
|
1756
|
-
/**
|
|
1757
|
-
|
|
1774
|
+
/**
|
|
1775
|
+
* Feed a raw packet from an external source (e.g., AMT tunnel or ASM
|
|
1776
|
+
* subscription). `sourceAddress` is the datagram's sender when the source
|
|
1777
|
+
* knows it; see packetsDroppedForeignSender.
|
|
1778
|
+
*/
|
|
1779
|
+
feedPacket(data, context, sourceAddress) {
|
|
1758
1780
|
if (this.#disposed) return;
|
|
1759
1781
|
const packet = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1760
|
-
if (!this.#acceptPacket(packet)) return;
|
|
1782
|
+
if (!this.#acceptPacket(packet, sourceAddress)) return;
|
|
1761
1783
|
this.#onPacket(packet, context);
|
|
1762
1784
|
this.#resetWatchdog();
|
|
1763
1785
|
}
|
|
@@ -1907,6 +1929,10 @@ var MulticastTransport = class {
|
|
|
1907
1929
|
get withdrawnPacketIdDrops() {
|
|
1908
1930
|
return this.#withdrawnPacketIdDrops;
|
|
1909
1931
|
}
|
|
1932
|
+
/** The sender this join is locked to; undefined until one is known. */
|
|
1933
|
+
get sender() {
|
|
1934
|
+
return this.#sender;
|
|
1935
|
+
}
|
|
1910
1936
|
/** Whether a subscription is live: joined, and not yet released or replaced. */
|
|
1911
1937
|
get joined() {
|
|
1912
1938
|
return this.#subscription !== null;
|
|
@@ -2069,11 +2095,16 @@ var MulticastTransport = class {
|
|
|
2069
2095
|
this.#withdrawnPacketIds.clear();
|
|
2070
2096
|
}
|
|
2071
2097
|
/** The ingress filter; an accepted packet is counted here, once. */
|
|
2072
|
-
#acceptPacket(packet) {
|
|
2098
|
+
#acceptPacket(packet, sourceAddress) {
|
|
2099
|
+
const owner = this.#lockedTo?.() ?? this.#sender;
|
|
2100
|
+
if (sourceAddress !== void 0 && owner !== void 0 && sourceAddress !== owner) {
|
|
2101
|
+
this.#stats.packetsDroppedForeignSender++;
|
|
2102
|
+
return false;
|
|
2103
|
+
}
|
|
2073
2104
|
const packetId = readMMTPPacketId(packet);
|
|
2074
2105
|
if (packetId === null) {
|
|
2075
2106
|
if (!this.#packetIds) {
|
|
2076
|
-
this.#countAccepted(packet, null);
|
|
2107
|
+
this.#countAccepted(packet, null, sourceAddress);
|
|
2077
2108
|
return true;
|
|
2078
2109
|
}
|
|
2079
2110
|
this.#stats.packetsDroppedUnparseable++;
|
|
@@ -2084,14 +2115,15 @@ var MulticastTransport = class {
|
|
|
2084
2115
|
return false;
|
|
2085
2116
|
}
|
|
2086
2117
|
if (!this.#packetIds || this.#packetIds.has(packetId)) {
|
|
2087
|
-
this.#countAccepted(packet, packetId);
|
|
2118
|
+
this.#countAccepted(packet, packetId, sourceAddress);
|
|
2088
2119
|
return true;
|
|
2089
2120
|
}
|
|
2090
2121
|
this.#recordUnregisteredPidDrop(packetId);
|
|
2091
2122
|
return false;
|
|
2092
2123
|
}
|
|
2093
2124
|
/** Receive counters for one accepted packet; `packetId` is null when it has none. */
|
|
2094
|
-
#countAccepted(packet, packetId) {
|
|
2125
|
+
#countAccepted(packet, packetId, sourceAddress) {
|
|
2126
|
+
this.#sender ??= sourceAddress;
|
|
2095
2127
|
this.#stats.packetsReceived++;
|
|
2096
2128
|
this.#stats.bytesReceived += packet.byteLength;
|
|
2097
2129
|
if (packetId === null) return;
|
|
@@ -2162,6 +2194,7 @@ var MulticastTransport = class {
|
|
|
2162
2194
|
console.warn(
|
|
2163
2195
|
`[MulticastTransport] No packets for ${this.#failbackWindowMs}ms; failing back to MoQ`
|
|
2164
2196
|
);
|
|
2197
|
+
this.#sender = void 0;
|
|
2165
2198
|
this.#onFailback({ kind: "silence", windowMs: this.#failbackWindowMs });
|
|
2166
2199
|
}, delayMs);
|
|
2167
2200
|
}
|