@blockcast/mmt-transport 0.2.2-main.c71423b8a4e4 → 0.2.2-main.ce3c8aeb7f68
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/endpoint-config.d.ts +8 -0
- package/dist/endpoint-config.d.ts.map +1 -1
- package/dist/endpoint-config.js +25 -0
- package/dist/endpoint-config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mmt-transport.no-modules.js +34 -4
- package/dist/mmt-transport.no-modules.js.map +4 -4
- package/dist/multicast-catalog-policy.d.ts +2 -2
- package/dist/multicast-catalog-policy.d.ts.map +1 -1
- package/dist/multicast-catalog-policy.js +22 -4
- package/dist/multicast-catalog-policy.js.map +1 -1
- package/dist/multicast-signaling-reconciler.js +5 -2
- package/dist/multicast-signaling-reconciler.js.map +1 -1
- package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
- package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
- package/node_modules/@blockcast/mmt-base/README.md +121 -0
- package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +328 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +750 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/package.json +49 -0
- package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +1020 -0
- package/package.json +7 -1
- package/src/endpoint-config.ts +30 -0
- package/src/index.ts +1 -0
- package/src/multicast-catalog-policy.ts +23 -5
- package/src/multicast-signaling-reconciler.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockcast/mmt-transport",
|
|
3
|
-
"version": "0.2.2-main.
|
|
3
|
+
"version": "0.2.2-main.ce3c8aeb7f68",
|
|
4
4
|
"description": "Unified transport manager for MoQ with WebTransport, SSM multicast, AMT, DRIAD, and FEC support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,6 +35,12 @@
|
|
|
35
35
|
"test": "vitest run",
|
|
36
36
|
"test:watch": "vitest"
|
|
37
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@blockcast/mmt-base": "0.1.0-main.ce3c8aeb7f68"
|
|
40
|
+
},
|
|
41
|
+
"bundledDependencies": [
|
|
42
|
+
"@blockcast/mmt-base"
|
|
43
|
+
],
|
|
38
44
|
"devDependencies": {
|
|
39
45
|
"esbuild": "^0.21.5",
|
|
40
46
|
"typescript": "^5.9.3",
|
package/src/endpoint-config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MMTP_PACKET_ID_MAX, MMTP_SIGNALING_PACKET_ID } from "@blockcast/mmt-base";
|
|
1
2
|
import type {
|
|
2
3
|
WindowMulticastSubscribeConfig,
|
|
3
4
|
WindowMulticastSubscribeConfigBytes,
|
|
@@ -46,6 +47,22 @@ export function toWindowMulticastSubscribeConfig(
|
|
|
46
47
|
if (input.mode !== undefined && !["auto", "native", "tunnel"].includes(input.mode)) {
|
|
47
48
|
throw new TypeError(`Unsupported multicast mode: ${String(input.mode)}`);
|
|
48
49
|
}
|
|
50
|
+
// An explicit non-array (the null "endpoint unusable" sentinel from
|
|
51
|
+
// selectEndpointPacketIdsForTracks) must not degrade into "no filter".
|
|
52
|
+
if (input.packetIds !== undefined && !Array.isArray(input.packetIds)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`multicast packetIds must be an array, got ${input.packetIds === null ? "null" : typeof input.packetIds}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
// Every join request passes through here, so the track packet_id range is
|
|
58
|
+
// enforced here rather than trusted from each caller.
|
|
59
|
+
if (input.packetIds?.some(id => !isMulticastTrackPacketId(id)) ||
|
|
60
|
+
input.tracks?.some(track => !isMulticastTrackPacketId(track.packetId))) {
|
|
61
|
+
throw new RangeError(
|
|
62
|
+
`multicast packetId must be an integer from 1 to ${MMTP_PACKET_ID_MAX}; ` +
|
|
63
|
+
"packetId 0 is the MMTP signaling flow and is never a track's",
|
|
64
|
+
);
|
|
65
|
+
}
|
|
49
66
|
|
|
50
67
|
const base = {
|
|
51
68
|
group: input.group,
|
|
@@ -128,6 +145,19 @@ export function multicastEndpointKey(endpoint: MulticastEndpointConfig): string
|
|
|
128
145
|
]);
|
|
129
146
|
}
|
|
130
147
|
|
|
148
|
+
/**
|
|
149
|
+
* True when `value` may be advertised as a multicast track's MMTP `packet_id`:
|
|
150
|
+
* an integer in 1..MMTP_PACKET_ID_MAX. packet_id 0 (MMTP_SIGNALING_PACKET_ID)
|
|
151
|
+
* is the MMTP signaling flow -- the FFmpeg `moq_mmt` muxer sends the AL-FEC
|
|
152
|
+
* message (0x0203) on it into the same group as the media -- so it is never a
|
|
153
|
+
* track's. Only a number qualifies: a string, boolean or null is not coerced.
|
|
154
|
+
*/
|
|
155
|
+
export function isMulticastTrackPacketId(value: unknown): value is number {
|
|
156
|
+
return Number.isInteger(value) &&
|
|
157
|
+
(value as number) > MMTP_SIGNALING_PACKET_ID &&
|
|
158
|
+
(value as number) <= MMTP_PACKET_ID_MAX;
|
|
159
|
+
}
|
|
160
|
+
|
|
131
161
|
export function isUsableMulticastEndpoint(
|
|
132
162
|
endpoint: { groupAddress?: string; port?: unknown } | undefined,
|
|
133
163
|
): boolean {
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type MulticastSignalingEndpoint,
|
|
4
4
|
} from "./multicast-signaling-reconciler.js";
|
|
5
5
|
import {
|
|
6
|
+
isMulticastTrackPacketId,
|
|
6
7
|
isUsableMulticastEndpoint,
|
|
7
8
|
isValidMulticastGroupAddress,
|
|
8
9
|
} from "./endpoint-config.js";
|
|
@@ -107,7 +108,7 @@ export function endpointToMulticastConfig(
|
|
|
107
108
|
catalog: Catalog,
|
|
108
109
|
selection?: MulticastTrackSelection,
|
|
109
110
|
): PlayerMulticastConfig | null {
|
|
110
|
-
if (!endpoint || !isUsableMulticastEndpoint(endpoint)) return null;
|
|
111
|
+
if (!endpoint || !isUsableMulticastEndpoint(endpoint) || advertisesInvalidPacketId(endpoint)) return null;
|
|
111
112
|
const config: PlayerMulticastConfig = {
|
|
112
113
|
group: endpoint.groupAddress,
|
|
113
114
|
source: endpoint.sourceAddress || "",
|
|
@@ -125,6 +126,7 @@ export function endpointToMulticastConfig(
|
|
|
125
126
|
const packetIds = selection === undefined ?
|
|
126
127
|
selectEndpointPacketIds(endpoint, catalog) :
|
|
127
128
|
selectEndpointPacketIdsForTracks(endpoint, catalog, selection);
|
|
129
|
+
if (packetIds === null) return null;
|
|
128
130
|
if (packetIds.length > 0) config.packetIds = packetIds;
|
|
129
131
|
return config;
|
|
130
132
|
}
|
|
@@ -133,7 +135,7 @@ export function selectEndpointPacketIds(
|
|
|
133
135
|
endpoint: MulticastSignalingEndpoint | Record<string, any> | null | undefined,
|
|
134
136
|
catalog: Catalog,
|
|
135
137
|
search: string | URLSearchParams = currentSearchParams(),
|
|
136
|
-
): number[] {
|
|
138
|
+
): number[] | null {
|
|
137
139
|
const params = search instanceof URLSearchParams ? search : new URLSearchParams(search);
|
|
138
140
|
return selectEndpointPacketIdsForTracks(endpoint, catalog, {
|
|
139
141
|
containerKind: params.get("packaging") || params.get("container") || "mmtp",
|
|
@@ -145,8 +147,14 @@ export function selectEndpointPacketIdsForTracks(
|
|
|
145
147
|
endpoint: MulticastSignalingEndpoint | Record<string, any> | null | undefined,
|
|
146
148
|
catalog: Catalog,
|
|
147
149
|
selection: MulticastTrackSelection = {},
|
|
148
|
-
): number[] {
|
|
150
|
+
): number[] | null {
|
|
149
151
|
if (!endpoint || !Array.isArray(endpoint.tracks)) return [];
|
|
152
|
+
// An empty result means "no packet_id filter" to the join, so an invalid
|
|
153
|
+
// packet_id must fail here rather than be dropped: dropping the only track
|
|
154
|
+
// would widen the filter to every packet_id, the signaling flow included.
|
|
155
|
+
// null ("this endpoint is unusable") matches endpointToMulticastConfig on
|
|
156
|
+
// the same input, and the widened return type is the signal to callers.
|
|
157
|
+
if (advertisesInvalidPacketId(endpoint)) return null;
|
|
150
158
|
const tracks = endpoint.tracks
|
|
151
159
|
.map((track: any) => ({
|
|
152
160
|
name: typeof track?.name === "string" ? track.name : "",
|
|
@@ -212,6 +220,9 @@ export function normalizeMulticastConfig(
|
|
|
212
220
|
config: Partial<PlayerMulticastConfig> | null | undefined,
|
|
213
221
|
): PlayerMulticastConfig | null {
|
|
214
222
|
if (!config?.group) return null;
|
|
223
|
+
// A join list naming an invalid packet_id is refused whole: dropping the
|
|
224
|
+
// entry could leave the list empty, which the join reads as "no filter".
|
|
225
|
+
if (Array.isArray(config.packetIds) && !config.packetIds.every(isMulticastTrackPacketId)) return null;
|
|
215
226
|
const amt = findAmtRelay(config.amtNetworkSource);
|
|
216
227
|
const amtRelay = config.amtRelay || amt?.relay || "";
|
|
217
228
|
const amtRelayPort = config.amtRelayPort ?? amt?.port;
|
|
@@ -306,8 +317,15 @@ function findAmtRelay(networkSource: unknown): { relay: string; port?: number }
|
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
function validPacketId(value: unknown): number | undefined {
|
|
309
|
-
|
|
310
|
-
|
|
320
|
+
return isMulticastTrackPacketId(value) ? value : undefined;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** True when some endpoint track advertises a `packetId` that is present but
|
|
324
|
+
* not a valid track packet_id. A track that omits `packetId` (the legacy
|
|
325
|
+
* string form) advertises none and is not invalid. */
|
|
326
|
+
function advertisesInvalidPacketId(endpoint: { tracks?: unknown }): boolean {
|
|
327
|
+
return Array.isArray(endpoint.tracks) && endpoint.tracks.some((track: any) =>
|
|
328
|
+
track?.packetId !== undefined && !isMulticastTrackPacketId(track.packetId));
|
|
311
329
|
}
|
|
312
330
|
|
|
313
331
|
function normalizePacketIds(packetIds: unknown): number[] {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isValidMulticastGroupAddress } from "./endpoint-config.js";
|
|
1
|
+
import { isMulticastTrackPacketId, isValidMulticastGroupAddress } from "./endpoint-config.js";
|
|
2
2
|
|
|
3
3
|
export interface MulticastSignalingEndpoint {
|
|
4
4
|
endpointId: string;
|
|
@@ -137,7 +137,10 @@ function isValidEndpoint(endpoint: MulticastSignalingEndpoint, catalog?: Catalog
|
|
|
137
137
|
if (endpoint.protocol === "ssm" && (typeof endpoint.sourceAddress !== "string" || endpoint.sourceAddress.trim().length === 0)) return false;
|
|
138
138
|
if (!isValidMulticastGroupAddress(endpoint.groupAddress) || !Number.isInteger(Number(endpoint.port)) || endpoint.port <= 0 || endpoint.port > 65535 || !endpoint.tracks.length) return false;
|
|
139
139
|
const catalogTracks = new Set([...Object.keys(catalog?.video?.renditions ?? {}), ...Object.keys(catalog?.audio?.renditions ?? {})]);
|
|
140
|
-
|
|
140
|
+
// Every track must carry a valid packet_id (isMulticastTrackPacketId); one
|
|
141
|
+
// that does not -- including packet_id 0, the MMTP signaling flow --
|
|
142
|
+
// rejects the whole endpoint rather than silently dropping that track.
|
|
143
|
+
return endpoint.tracks.every(track => !!track.name && isMulticastTrackPacketId(track.packetId) && (catalogTracks.size === 0 || catalogTracks.has(track.name) || catalogTracks.has(track.name.replace(/\/repair$/, ""))));
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
function copyEndpoint(endpoint: MulticastSignalingEndpoint): MulticastSignalingEndpoint {
|