@blockcast/mmt-container 0.4.0-main.d6f2737828fc → 0.4.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/README.md +12 -9
- package/dist/browser-runtime.js +14219 -13716
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +1 -12
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +14 -6
- package/dist/carp-catalog.js.map +4 -4
- 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 +101 -42
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.js +4 -6
- package/dist/catalog-network-source.js.map +4 -4
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +0 -4
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.d.ts +124 -0
- package/dist/delivery-catalog.d.ts.map +1 -0
- package/dist/delivery-catalog.js +1867 -0
- package/dist/delivery-catalog.js.map +7 -0
- package/dist/fec-manager.d.ts +17 -4
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +41 -20
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +3 -2
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +17 -15
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.d.ts +2 -8
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +12 -62
- package/dist/fec-worker-setup.js.map +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js +4 -6
- package/dist/iso-block-locator.js.map +4 -4
- package/dist/mfu-reassembler.js +27 -29
- package/dist/mfu-reassembler.js.map +4 -4
- package/dist/mmtp-container-parser.d.ts +9 -11
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +107 -98
- package/dist/mmtp-container-parser.js.map +4 -4
- package/dist/mmtp-container-parser.no-modules.js +133 -108
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +107 -98
- package/dist/mmtp-decode-pipeline.js.map +4 -4
- package/dist/mmtp-router.d.ts +34 -14
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +143 -113
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-input.js +4 -6
- package/dist/multicast-input.js.map +4 -4
- package/dist/multicast-manager.d.ts +39 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +264 -156
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +14 -14
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +32 -34
- package/dist/multicast-unwrap.js.map +4 -4
- package/dist/no-modules.js +130 -107
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +86 -2
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +86 -17
- package/dist/repair-fetch.js.map +4 -4
- package/dist/repair-layers.js +4 -6
- package/dist/repair-layers.js.map +4 -4
- package/dist/signaling.js +5 -7
- package/dist/signaling.js.map +4 -4
- package/dist/timestamp-codec.js +27 -29
- package/dist/timestamp-codec.js.map +4 -4
- package/dist/wasm-mfu-reassembler.js +4 -6
- package/dist/wasm-mfu-reassembler.js.map +4 -4
- package/dist/wasm-mmtp-container-parser.js +107 -98
- package/dist/wasm-mmtp-container-parser.js.map +4 -4
- package/package.json +5 -6
- package/src/carp-catalog.ts +16 -11
- package/src/catalog-fec-params.ts +38 -17
- package/src/cmcd-producer.ts +0 -6
- package/src/delivery-catalog.ts +498 -0
- package/src/fec-manager.ts +44 -17
- package/src/fec-state.ts +4 -9
- package/src/fec-worker-setup.ts +4 -35
- package/src/index.ts +27 -0
- package/src/mmtp-container-parser.ts +80 -20
- package/src/mmtp-router.ts +71 -29
- package/src/multicast-manager.ts +93 -26
- package/src/repair-fetch.ts +228 -17
- package/test-vectors/catalog/README.md +10 -1
- package/test-vectors/catalog/negative/multicast-endpoint-relay-address.json +39 -0
- package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +1 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +38 -0
- package/test-vectors/catalog/section-codes.json +33 -0
- package/test-vectors/delivery-catalog/README.md +11 -0
- package/test-vectors/delivery-catalog/negative/missing-block-profile.json +58 -0
- package/test-vectors/delivery-catalog/negative/packet-id-signaling.json +59 -0
- package/test-vectors/delivery-catalog/negative/retired-k-padded-block-profile.json +59 -0
- package/test-vectors/delivery-catalog/positive/dash.json +56 -0
- package/test-vectors/delivery-catalog/positive/mmtp-source-only.json +43 -0
|
@@ -1,78 +1,17 @@
|
|
|
1
|
-
// ../mmt-
|
|
1
|
+
// ../mmt-base/dist/mmtp.js
|
|
2
2
|
var MMTP_HEADER_SIZE = 12;
|
|
3
3
|
var MPU_HEADER_SIZE = 8;
|
|
4
|
-
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
5
|
-
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
6
|
-
var TIMED_MFU_DU_HEADER_SIZE = 14;
|
|
7
|
-
var NONTIMED_MFU_DU_HEADER_SIZE = 4;
|
|
8
|
-
var PACKET_TYPE_MPU = 0;
|
|
9
|
-
var MMTP_EXT_TYPE_ALTA_AUTH = 61601;
|
|
10
|
-
var MMTP_EXT_TRAILER_HEADER_SIZE = 4;
|
|
11
|
-
function extractAltaTrailer(mmtpPacket, options) {
|
|
12
|
-
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
13
|
-
return null;
|
|
14
|
-
const packetType = mmtpPacket[1] & 63;
|
|
15
|
-
if (packetType !== PACKET_TYPE_MPU)
|
|
16
|
-
return null;
|
|
17
|
-
const fecType = mmtpPacket[0] >> 3 & 3;
|
|
18
|
-
let headerLength = MMTP_HEADER_SIZE;
|
|
19
|
-
if (fecType < 2 && (mmtpPacket[0] & 32) !== 0)
|
|
20
|
-
headerLength += 4;
|
|
21
|
-
if (fecType < 2 && (mmtpPacket[0] & 2) !== 0) {
|
|
22
|
-
if (headerLength + 4 > mmtpPacket.length)
|
|
23
|
-
return null;
|
|
24
|
-
const extensionLength = new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + headerLength + 2, 2).getUint16(0, false);
|
|
25
|
-
headerLength += 4 + extensionLength;
|
|
26
|
-
}
|
|
27
|
-
if (headerLength + MPU_HEADER_SIZE > mmtpPacket.length)
|
|
28
|
-
return null;
|
|
29
|
-
const payload = mmtpPacket.subarray(headerLength);
|
|
30
|
-
const payloadLength = payload[0] << 8 | payload[1];
|
|
31
|
-
const flagsByte = payload[2];
|
|
32
|
-
const fragmentType = flagsByte >> 4 & 15;
|
|
33
|
-
const timed = (flagsByte >> 3 & 1) === 1;
|
|
34
|
-
const fragmentationIndicator = flagsByte >> 1 & 3;
|
|
35
|
-
if (fragmentType !== 2)
|
|
36
|
-
return null;
|
|
37
|
-
const dataUnitHeaderSize = fragmentationIndicator <= 1 ? timed ? TIMED_MFU_DU_HEADER_SIZE : NONTIMED_MFU_DU_HEADER_SIZE : 0;
|
|
38
|
-
if (payloadLength <= MPU_HEADER_REMAINDER_SIZE + dataUnitHeaderSize)
|
|
39
|
-
return null;
|
|
40
|
-
if (fecType > 1)
|
|
41
|
-
return null;
|
|
42
|
-
const hasFecId = !options?.skipFecId && fecType === 1;
|
|
43
|
-
const payloadEnd = hasFecId ? payload.length - 4 : payload.length;
|
|
44
|
-
const declaredEnd = MPU_LENGTH_FIELD_SIZE + payloadLength;
|
|
45
|
-
if (declaredEnd > payloadEnd)
|
|
46
|
-
return null;
|
|
47
|
-
if (declaredEnd + MMTP_EXT_TRAILER_HEADER_SIZE > payloadEnd)
|
|
48
|
-
return null;
|
|
49
|
-
const extType = payload[declaredEnd] << 8 | payload[declaredEnd + 1];
|
|
50
|
-
if (extType !== MMTP_EXT_TYPE_ALTA_AUTH)
|
|
51
|
-
return null;
|
|
52
|
-
const extLen = payload[declaredEnd + 2] << 8 | payload[declaredEnd + 3];
|
|
53
|
-
const authStart = declaredEnd + MMTP_EXT_TRAILER_HEADER_SIZE;
|
|
54
|
-
if (authStart + extLen !== payloadEnd)
|
|
55
|
-
return null;
|
|
56
|
-
return {
|
|
57
|
-
auth: payload.subarray(authStart, payloadEnd),
|
|
58
|
-
signedEnd: headerLength + declaredEnd
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ../mmt-base/dist/mmtp.js
|
|
63
|
-
var MMTP_HEADER_SIZE2 = 12;
|
|
64
|
-
var MPU_HEADER_SIZE2 = 8;
|
|
65
4
|
var MFU_DU_HEADER_SIZE_TIMED = 14;
|
|
66
5
|
var MFU_DU_HEADER_SIZE_NONTIMED = 4;
|
|
67
|
-
var
|
|
68
|
-
var
|
|
6
|
+
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
7
|
+
var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
|
|
69
8
|
var SOURCE_FEC_PAYLOAD_ID_SIZE = 4;
|
|
70
|
-
var
|
|
9
|
+
var PACKET_TYPE_MPU = 0;
|
|
71
10
|
var PACKET_TYPE_REPAIR = 3;
|
|
72
11
|
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
73
12
|
var MMTP_PACKET_ID_MAX = 65535;
|
|
74
13
|
function parseMMTPHeader(buffer) {
|
|
75
|
-
if (buffer.length <
|
|
14
|
+
if (buffer.length < MMTP_HEADER_SIZE) {
|
|
76
15
|
throw new Error(`MMTP packet too small: ${buffer.length} bytes`);
|
|
77
16
|
}
|
|
78
17
|
const view2 = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -128,12 +67,12 @@ function parseMMTPHeader(buffer) {
|
|
|
128
67
|
};
|
|
129
68
|
}
|
|
130
69
|
function readMMTPPacketId(buffer) {
|
|
131
|
-
if (buffer.length <
|
|
70
|
+
if (buffer.length < MMTP_HEADER_SIZE)
|
|
132
71
|
return null;
|
|
133
72
|
const flags = buffer[0];
|
|
134
73
|
if ((flags >> 6 & 3) !== 0)
|
|
135
74
|
return null;
|
|
136
|
-
let offset =
|
|
75
|
+
let offset = MMTP_HEADER_SIZE;
|
|
137
76
|
if ((flags & 32) !== 0) {
|
|
138
77
|
if (offset + 4 > buffer.length)
|
|
139
78
|
return null;
|
|
@@ -149,7 +88,7 @@ function readMMTPPacketId(buffer) {
|
|
|
149
88
|
return buffer[2] << 8 | buffer[3];
|
|
150
89
|
}
|
|
151
90
|
function parseMPUHeader(payload) {
|
|
152
|
-
if (payload.length <
|
|
91
|
+
if (payload.length < MPU_HEADER_SIZE) {
|
|
153
92
|
throw new Error(`Payload too small for MPU header: ${payload.length} bytes`);
|
|
154
93
|
}
|
|
155
94
|
const view2 = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
@@ -182,15 +121,15 @@ function parseTimedMfuDuHeader(payload, offset) {
|
|
|
182
121
|
};
|
|
183
122
|
}
|
|
184
123
|
function resolveMfuPayloadLayout(mpu, fragmentType, payload) {
|
|
185
|
-
if (mpu.payloadLength <
|
|
124
|
+
if (mpu.payloadLength < MPU_HEADER_REMAINDER_SIZE) {
|
|
186
125
|
return {
|
|
187
126
|
rejection: {
|
|
188
127
|
gate: "mpu-payload-length-below-header-remainder",
|
|
189
|
-
detail: `payload_length=${mpu.payloadLength} < ${
|
|
128
|
+
detail: `payload_length=${mpu.payloadLength} < ${MPU_HEADER_REMAINDER_SIZE}`
|
|
190
129
|
}
|
|
191
130
|
};
|
|
192
131
|
}
|
|
193
|
-
const declaredEnd =
|
|
132
|
+
const declaredEnd = MPU_LENGTH_FIELD_SIZE + mpu.payloadLength;
|
|
194
133
|
if (declaredEnd > payload.length) {
|
|
195
134
|
return {
|
|
196
135
|
rejection: {
|
|
@@ -201,7 +140,7 @@ function resolveMfuPayloadLayout(mpu, fragmentType, payload) {
|
|
|
201
140
|
}
|
|
202
141
|
const hasHeader = fragmentType === 2 && mpu.fragmentationIndicator <= 1;
|
|
203
142
|
const mfuHeaderSize = mpu.timedFlag ? MFU_DU_HEADER_SIZE_TIMED : MFU_DU_HEADER_SIZE_NONTIMED;
|
|
204
|
-
const mfuOffset =
|
|
143
|
+
const mfuOffset = MPU_HEADER_SIZE + (hasHeader ? mfuHeaderSize : 0);
|
|
205
144
|
if (mfuOffset >= declaredEnd) {
|
|
206
145
|
return {
|
|
207
146
|
rejection: {
|
|
@@ -218,44 +157,46 @@ function resolveMfuPayloadLayout(mpu, fragmentType, payload) {
|
|
|
218
157
|
}
|
|
219
158
|
};
|
|
220
159
|
}
|
|
221
|
-
|
|
160
|
+
var LEGACY_TRAILER_EXT_TYPE = 61601;
|
|
161
|
+
var LEGACY_TRAILER_HEADER_SIZE = 4;
|
|
162
|
+
function isEmptyOrExactLegacyTrailer(payload, start, end) {
|
|
222
163
|
if (start === end)
|
|
223
164
|
return true;
|
|
224
|
-
if (start < 0 || end > payload.length || start +
|
|
165
|
+
if (start < 0 || end > payload.length || start + LEGACY_TRAILER_HEADER_SIZE > end) {
|
|
225
166
|
return false;
|
|
226
167
|
}
|
|
227
168
|
const view2 = new DataView(payload.buffer, payload.byteOffset + start, end - start);
|
|
228
|
-
if (view2.getUint16(0, false) !==
|
|
169
|
+
if (view2.getUint16(0, false) !== LEGACY_TRAILER_EXT_TYPE)
|
|
229
170
|
return false;
|
|
230
171
|
const authLength = view2.getUint16(2, false);
|
|
231
|
-
return start +
|
|
172
|
+
return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end;
|
|
232
173
|
}
|
|
233
174
|
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options) {
|
|
234
175
|
if (declaredEnd > payload.length)
|
|
235
176
|
return null;
|
|
236
177
|
if (options?.skipFecId) {
|
|
237
|
-
return
|
|
178
|
+
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false } : null;
|
|
238
179
|
}
|
|
239
180
|
if (fecType === 1) {
|
|
240
181
|
const fecStart = payload.length - SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
241
|
-
if (fecStart < declaredEnd || !
|
|
182
|
+
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
242
183
|
return null;
|
|
243
184
|
}
|
|
244
185
|
return { hasFecId: true };
|
|
245
186
|
}
|
|
246
187
|
if (fecType !== 0)
|
|
247
188
|
return null;
|
|
248
|
-
if (
|
|
189
|
+
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
249
190
|
return { hasFecId: false };
|
|
250
191
|
}
|
|
251
192
|
return null;
|
|
252
193
|
}
|
|
253
194
|
function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
254
|
-
if (mmtpPacket.length <
|
|
195
|
+
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) {
|
|
255
196
|
return {
|
|
256
197
|
rejection: {
|
|
257
198
|
gate: "packet-shorter-than-mmtp-plus-mpu-header",
|
|
258
|
-
detail: `${mmtpPacket.length} bytes < ${
|
|
199
|
+
detail: `${mmtpPacket.length} bytes < ${MMTP_HEADER_SIZE + MPU_HEADER_SIZE}`
|
|
259
200
|
}
|
|
260
201
|
};
|
|
261
202
|
}
|
|
@@ -274,7 +215,7 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
274
215
|
};
|
|
275
216
|
}
|
|
276
217
|
}
|
|
277
|
-
if (header.packetType !==
|
|
218
|
+
if (header.packetType !== PACKET_TYPE_MPU) {
|
|
278
219
|
return {
|
|
279
220
|
rejection: {
|
|
280
221
|
gate: "not-an-mpu-packet",
|
|
@@ -283,11 +224,11 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
283
224
|
};
|
|
284
225
|
}
|
|
285
226
|
const payload = mmtpPacket.subarray(header.headerLength);
|
|
286
|
-
if (payload.length <
|
|
227
|
+
if (payload.length < MPU_HEADER_SIZE) {
|
|
287
228
|
return {
|
|
288
229
|
rejection: {
|
|
289
230
|
gate: "payload-shorter-than-mpu-header",
|
|
290
|
-
detail: `${payload.length} bytes < ${
|
|
231
|
+
detail: `${payload.length} bytes < ${MPU_HEADER_SIZE}`
|
|
291
232
|
}
|
|
292
233
|
};
|
|
293
234
|
}
|
|
@@ -318,7 +259,7 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
318
259
|
return {
|
|
319
260
|
rejection: {
|
|
320
261
|
gate: "declared-trailers-unresolved",
|
|
321
|
-
detail: `trailer bytes [${layout.dataEnd}, ${payload.length}) are neither empty nor an exact
|
|
262
|
+
detail: `trailer bytes [${layout.dataEnd}, ${payload.length}) are neither empty nor an exact legacy authenticator trailer (fecType=${header.fecType})`
|
|
322
263
|
}
|
|
323
264
|
};
|
|
324
265
|
}
|
|
@@ -334,8 +275,8 @@ function extractPlannedMfu(mmtpPacket, result) {
|
|
|
334
275
|
const mfuDuHeaderPresent = layout.hasMfuDuHeader;
|
|
335
276
|
const mfuOffset = layout.mfuOffset;
|
|
336
277
|
const dataEnd = layout.dataEnd;
|
|
337
|
-
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload,
|
|
338
|
-
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset +
|
|
278
|
+
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE) : null;
|
|
279
|
+
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false) : null;
|
|
339
280
|
const data = payload.subarray(mfuOffset, dataEnd);
|
|
340
281
|
const fecPayloadId = trailerLayout.hasFecId ? {
|
|
341
282
|
ssId: new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + mmtpPacket.length - SOURCE_FEC_PAYLOAD_ID_SIZE, SOURCE_FEC_PAYLOAD_ID_SIZE).getUint32(0, false)
|
|
@@ -343,17 +284,17 @@ function extractPlannedMfu(mmtpPacket, result) {
|
|
|
343
284
|
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId };
|
|
344
285
|
}
|
|
345
286
|
function sourceFecPayloadIdOf(mmtpPacket, header) {
|
|
346
|
-
if (mmtpPacket.length <
|
|
287
|
+
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
347
288
|
return null;
|
|
348
|
-
if (header.packetType !==
|
|
289
|
+
if (header.packetType !== PACKET_TYPE_MPU)
|
|
349
290
|
return null;
|
|
350
291
|
const payload = mmtpPacket.subarray(header.headerLength);
|
|
351
|
-
if (payload.length <
|
|
292
|
+
if (payload.length < MPU_HEADER_SIZE)
|
|
352
293
|
return null;
|
|
353
294
|
const payloadLength = payload[0] << 8 | payload[1];
|
|
354
|
-
if (payloadLength <
|
|
295
|
+
if (payloadLength < MPU_HEADER_REMAINDER_SIZE)
|
|
355
296
|
return null;
|
|
356
|
-
const declaredEnd =
|
|
297
|
+
const declaredEnd = MPU_LENGTH_FIELD_SIZE + payloadLength;
|
|
357
298
|
if (!resolveDeclaredTrailers(payload, declaredEnd, header.fecType)?.hasFecId)
|
|
358
299
|
return null;
|
|
359
300
|
const off = mmtpPacket.length - SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
@@ -361,7 +302,6 @@ function sourceFecPayloadIdOf(mmtpPacket, header) {
|
|
|
361
302
|
ssId: (mmtpPacket[off] << 24 | mmtpPacket[off + 1] << 16 | mmtpPacket[off + 2] << 8 | mmtpPacket[off + 3]) >>> 0
|
|
362
303
|
};
|
|
363
304
|
}
|
|
364
|
-
var extractAltaTrailer2 = extractAltaTrailer;
|
|
365
305
|
var REPAIR_FEC_PID_SIZE = 13;
|
|
366
306
|
function readRepairFecPayloadIdFields(mmtpPacket, parsedHeader) {
|
|
367
307
|
let header;
|
|
@@ -477,6 +417,28 @@ function isoBlocksBehindLowerBound(a, b, kMax) {
|
|
|
477
417
|
return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
|
|
478
418
|
}
|
|
479
419
|
|
|
420
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
421
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
422
|
+
function recordOf(value) {
|
|
423
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
424
|
+
}
|
|
425
|
+
function isoBlockSpanUsable(fec) {
|
|
426
|
+
const block = recordOf(fec);
|
|
427
|
+
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
|
|
428
|
+
return true;
|
|
429
|
+
const ms = block["interleaveDepthMs"];
|
|
430
|
+
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
431
|
+
}
|
|
432
|
+
function catalogFecAvailable(fec) {
|
|
433
|
+
const block = recordOf(fec);
|
|
434
|
+
if (block === void 0)
|
|
435
|
+
return true;
|
|
436
|
+
const declaresFecInstance = block["algorithm"] !== "none";
|
|
437
|
+
const profile = block["blockProfile"];
|
|
438
|
+
const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
|
|
439
|
+
return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
|
|
440
|
+
}
|
|
441
|
+
|
|
480
442
|
// src/track-session.ts
|
|
481
443
|
import { fecBlockBudgetMs } from "@blockcast/mmt-fec";
|
|
482
444
|
function computeFecDeliveryWindowMs(config) {
|
|
@@ -834,15 +796,6 @@ var INACTIVE = Object.freeze({
|
|
|
834
796
|
"reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
|
|
835
797
|
"no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
|
|
836
798
|
});
|
|
837
|
-
function recordOf(value) {
|
|
838
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
839
|
-
}
|
|
840
|
-
function isoBlockSpanUsable(fec) {
|
|
841
|
-
const block = recordOf(fec);
|
|
842
|
-
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
|
|
843
|
-
const ms = block["interleaveDepthMs"];
|
|
844
|
-
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
845
|
-
}
|
|
846
799
|
|
|
847
800
|
// src/block-policy.ts
|
|
848
801
|
import { deriveFecInterleaveDepth } from "@blockcast/mmt-fec";
|
|
@@ -1415,6 +1368,9 @@ var FECManager = class _FECManager {
|
|
|
1415
1368
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
1416
1369
|
this.#ssbLengthConflictCount = 0;
|
|
1417
1370
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
1371
|
+
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
1372
|
+
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
1373
|
+
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
1418
1374
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
1419
1375
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
1420
1376
|
// which would falsely start new timeouts without this guard.
|
|
@@ -1655,6 +1611,7 @@ var FECManager = class _FECManager {
|
|
|
1655
1611
|
#blockAuthoredLengths;
|
|
1656
1612
|
#ssbLengthConflictCount;
|
|
1657
1613
|
#blockRepairRsIds;
|
|
1614
|
+
#blockRsbLengths;
|
|
1658
1615
|
#completedBlocks;
|
|
1659
1616
|
#terminalExpiryMs;
|
|
1660
1617
|
#terminalQueues;
|
|
@@ -2820,7 +2777,6 @@ var FECManager = class _FECManager {
|
|
|
2820
2777
|
},
|
|
2821
2778
|
blocks: stats.blocks.map((block) => ({ ...block })),
|
|
2822
2779
|
decoder: stats.decoder ? { ...stats.decoder } : void 0,
|
|
2823
|
-
altaFailedDetails: stats.altaFailedDetails?.map((detail) => ({ ...detail })),
|
|
2824
2780
|
packetId
|
|
2825
2781
|
})),
|
|
2826
2782
|
repairSymbolSizeMismatches: this.#repairSymbolSizeMismatchCount,
|
|
@@ -2927,6 +2883,7 @@ var FECManager = class _FECManager {
|
|
|
2927
2883
|
resetMap(this.#blockSourceEsis);
|
|
2928
2884
|
resetMap(this.#blockAuthoredLengths);
|
|
2929
2885
|
resetMap(this.#blockRepairRsIds);
|
|
2886
|
+
resetMap(this.#blockRsbLengths);
|
|
2930
2887
|
resetMap(this.#blockPathCounts);
|
|
2931
2888
|
resetMap(this.#blockAnchorsMs);
|
|
2932
2889
|
resetMap(this.#blockCatalogTrackNames);
|
|
@@ -3044,6 +3001,7 @@ var FECManager = class _FECManager {
|
|
|
3044
3001
|
dropMap(this.#blockSourceEsis);
|
|
3045
3002
|
dropMap(this.#blockAuthoredLengths);
|
|
3046
3003
|
dropMap(this.#blockRepairRsIds);
|
|
3004
|
+
dropMap(this.#blockRsbLengths);
|
|
3047
3005
|
dropMap(this.#blockPathCounts);
|
|
3048
3006
|
dropMap(this.#blockAnchorsMs);
|
|
3049
3007
|
dropMap(this.#blockCatalogTrackNames);
|
|
@@ -3298,6 +3256,31 @@ var FECManager = class _FECManager {
|
|
|
3298
3256
|
windowMs: this.#deliveryGaps.windowMs
|
|
3299
3257
|
};
|
|
3300
3258
|
}
|
|
3259
|
+
/**
|
|
3260
|
+
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
3261
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it).
|
|
3262
|
+
* Undefined for a block that is not open.
|
|
3263
|
+
*/
|
|
3264
|
+
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
3265
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
3266
|
+
if (!this.#activeBlocks.has(key)) return void 0;
|
|
3267
|
+
return {
|
|
3268
|
+
sources: this.#blockSourceCounts.get(key) ?? 0,
|
|
3269
|
+
repairs: this.#blockRepairRsIds.get(key)?.size ?? 0,
|
|
3270
|
+
authoredLength: this.#blockAuthoredLengths.get(key),
|
|
3271
|
+
repairGroupLength: this.#blockRsbLengths.get(key)
|
|
3272
|
+
};
|
|
3273
|
+
}
|
|
3274
|
+
/**
|
|
3275
|
+
* Record a block's RSB_length from one of its repair symbols (the router
|
|
3276
|
+
* parses it from the Repair FEC Payload ID). The largest stated value wins.
|
|
3277
|
+
*/
|
|
3278
|
+
noteRepairGroupLength(sbn, packetId, rsbLength, catalogTrackName) {
|
|
3279
|
+
if (!Number.isSafeInteger(rsbLength) || rsbLength <= 0) return;
|
|
3280
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
3281
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
3282
|
+
if ((this.#blockRsbLengths.get(key) ?? 0) < rsbLength) this.#blockRsbLengths.set(key, rsbLength);
|
|
3283
|
+
}
|
|
3301
3284
|
/**
|
|
3302
3285
|
* Receiver-local time of a block's first accepted symbol, or undefined for
|
|
3303
3286
|
* a block no symbol reached (one materialized because a later SBN arrived).
|
|
@@ -3974,7 +3957,7 @@ var FECManager = class _FECManager {
|
|
|
3974
3957
|
* Caller is responsible for routing recovered data and updating
|
|
3975
3958
|
* block completion state via `markBlockCompleted()`.
|
|
3976
3959
|
*/
|
|
3977
|
-
feedSourceSymbol(packetId, ssId, symbolData,
|
|
3960
|
+
feedSourceSymbol(packetId, ssId, symbolData, catalogTrackName) {
|
|
3978
3961
|
this.#fecStats.sourcePackets++;
|
|
3979
3962
|
this.#statsForPacket(packetId).sourcePackets++;
|
|
3980
3963
|
if (!this.#hasBlockProfile(packetId)) return null;
|
|
@@ -4000,18 +3983,7 @@ var FECManager = class _FECManager {
|
|
|
4000
3983
|
symbolData.byteOffset,
|
|
4001
3984
|
symbolData.byteOffset + symbolData.byteLength
|
|
4002
3985
|
);
|
|
4003
|
-
|
|
4004
|
-
const authBuf = alta.auth.buffer.slice(
|
|
4005
|
-
alta.auth.byteOffset,
|
|
4006
|
-
alta.auth.byteOffset + alta.auth.byteLength
|
|
4007
|
-
);
|
|
4008
|
-
workerClient.feedSource(ssId, buf, performance.now(), {
|
|
4009
|
-
auth: authBuf,
|
|
4010
|
-
payloadEnd: alta.payloadEnd
|
|
4011
|
-
});
|
|
4012
|
-
} else {
|
|
4013
|
-
workerClient.feedSource(ssId, buf, performance.now());
|
|
4014
|
-
}
|
|
3986
|
+
workerClient.feedSource(ssId, buf, performance.now());
|
|
4015
3987
|
return null;
|
|
4016
3988
|
}
|
|
4017
3989
|
const entry = this.#decoderForPacket(packetId, catalogTrackName);
|
|
@@ -4248,6 +4220,7 @@ var FECManager = class _FECManager {
|
|
|
4248
4220
|
this.#blockSourceEsis.delete(key);
|
|
4249
4221
|
this.#blockAuthoredLengths.delete(key);
|
|
4250
4222
|
this.#blockRepairRsIds.delete(key);
|
|
4223
|
+
this.#blockRsbLengths.delete(key);
|
|
4251
4224
|
this.#markTerminal(key, sbn, packetId, true);
|
|
4252
4225
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
4253
4226
|
if (catalogTrackName === void 0) {
|
|
@@ -4299,6 +4272,7 @@ var FECManager = class _FECManager {
|
|
|
4299
4272
|
this.#blockSourceEsis.delete(key);
|
|
4300
4273
|
this.#blockAuthoredLengths.delete(key);
|
|
4301
4274
|
this.#blockRepairRsIds.delete(key);
|
|
4275
|
+
this.#blockRsbLengths.delete(key);
|
|
4302
4276
|
this.#syncDecoderBlockOwners.delete(key);
|
|
4303
4277
|
this.#markTerminal(key, sbn, packetId, false);
|
|
4304
4278
|
this.#failedBlocks.add(key);
|
|
@@ -4336,6 +4310,7 @@ var FECManager = class _FECManager {
|
|
|
4336
4310
|
this.#blockSourceEsis.delete(key);
|
|
4337
4311
|
this.#blockAuthoredLengths.delete(key);
|
|
4338
4312
|
this.#blockRepairRsIds.delete(key);
|
|
4313
|
+
this.#blockRsbLengths.delete(key);
|
|
4339
4314
|
this.#clearBlockTimer(key);
|
|
4340
4315
|
this.onBlockResolved?.(block.sbn, block.packetId, block.catalogTrackName);
|
|
4341
4316
|
}
|
|
@@ -4426,6 +4401,7 @@ var FECManager = class _FECManager {
|
|
|
4426
4401
|
this.#blockSourceEsis.clear();
|
|
4427
4402
|
this.#blockAuthoredLengths.clear();
|
|
4428
4403
|
this.#blockRepairRsIds.clear();
|
|
4404
|
+
this.#blockRsbLengths.clear();
|
|
4429
4405
|
this.#completedBlocks.clear();
|
|
4430
4406
|
this.#cleanlyCompletedBlocks.clear();
|
|
4431
4407
|
this.#repairRequestedBlocks.clear();
|
|
@@ -10662,6 +10638,42 @@ var FecReleaseSequencer = class {
|
|
|
10662
10638
|
for (const stream of this.#streams.values()) total += stream.buf.length;
|
|
10663
10639
|
return total;
|
|
10664
10640
|
}
|
|
10641
|
+
#deferDepth = 0;
|
|
10642
|
+
#deferredStreams = /* @__PURE__ */ new Set();
|
|
10643
|
+
/**
|
|
10644
|
+
* Run `work` with the drains its pushes would run deferred to its end. A
|
|
10645
|
+
* recovered FEC block is routed one frame at a time, and its block is
|
|
10646
|
+
* already resolved when the first frame is pushed: draining on that push
|
|
10647
|
+
* would release past the gap before the block's other recovered frames
|
|
10648
|
+
* arrive (deciding a conceal or stall for media that is about to land),
|
|
10649
|
+
* and those frames would then be dropped as stale. Nests.
|
|
10650
|
+
*/
|
|
10651
|
+
defer(work) {
|
|
10652
|
+
this.#deferDepth++;
|
|
10653
|
+
let threw = true;
|
|
10654
|
+
try {
|
|
10655
|
+
work();
|
|
10656
|
+
threw = false;
|
|
10657
|
+
} finally {
|
|
10658
|
+
this.#deferDepth--;
|
|
10659
|
+
if (this.#deferDepth === 0 && this.#deferredStreams.size > 0) {
|
|
10660
|
+
const streams = [...this.#deferredStreams];
|
|
10661
|
+
this.#deferredStreams.clear();
|
|
10662
|
+
if (!threw) {
|
|
10663
|
+
for (const stream of streams) this.#drain(stream);
|
|
10664
|
+
} else {
|
|
10665
|
+
try {
|
|
10666
|
+
for (const stream of streams) this.#drain(stream);
|
|
10667
|
+
} catch {
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10670
|
+
}
|
|
10671
|
+
}
|
|
10672
|
+
}
|
|
10673
|
+
#drainUnlessDeferred(stream) {
|
|
10674
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
10675
|
+
else this.#drain(stream);
|
|
10676
|
+
}
|
|
10665
10677
|
push(streamKey, data, meta, seq) {
|
|
10666
10678
|
const frame = { data, meta: { ...meta }, seq, arrivedAtMs: performance.now() };
|
|
10667
10679
|
const stream = this.#streamFor(streamKey, meta);
|
|
@@ -10683,7 +10695,7 @@ var FecReleaseSequencer = class {
|
|
|
10683
10695
|
return;
|
|
10684
10696
|
}
|
|
10685
10697
|
this.#release(stream, frame, void 0);
|
|
10686
|
-
this.#
|
|
10698
|
+
this.#drainUnlessDeferred(stream);
|
|
10687
10699
|
return;
|
|
10688
10700
|
}
|
|
10689
10701
|
let lo = 0;
|
|
@@ -10694,7 +10706,23 @@ var FecReleaseSequencer = class {
|
|
|
10694
10706
|
else hi = mid;
|
|
10695
10707
|
}
|
|
10696
10708
|
stream.buf.splice(lo, 0, frame);
|
|
10697
|
-
this.#
|
|
10709
|
+
this.#drainUnlessDeferred(stream);
|
|
10710
|
+
}
|
|
10711
|
+
/**
|
|
10712
|
+
* Arrival time of the earliest frame a stream of `packetId` holds behind a
|
|
10713
|
+
* gap (the gate forces it out `holdLimitMs` after that), or undefined when
|
|
10714
|
+
* none is held. Without `catalogTrackName`, every stream of the packetId.
|
|
10715
|
+
*/
|
|
10716
|
+
earliestHeldArrivalMs(packetId, catalogTrackName) {
|
|
10717
|
+
let earliest;
|
|
10718
|
+
for (const stream of this.#streams.values()) {
|
|
10719
|
+
if (stream.packetId !== packetId) continue;
|
|
10720
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
10721
|
+
for (const frame of stream.buf) {
|
|
10722
|
+
if (earliest === void 0 || frame.arrivedAtMs < earliest) earliest = frame.arrivedAtMs;
|
|
10723
|
+
}
|
|
10724
|
+
}
|
|
10725
|
+
return earliest;
|
|
10698
10726
|
}
|
|
10699
10727
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
10700
10728
|
poke(streamKey) {
|
|
@@ -11130,6 +11158,22 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
11130
11158
|
}
|
|
11131
11159
|
) : null;
|
|
11132
11160
|
}
|
|
11161
|
+
/**
|
|
11162
|
+
* Run `work` with the FEC release gate's drains deferred to its end, so
|
|
11163
|
+
* every frame it pushes is in place before any held gap is decided (see
|
|
11164
|
+
* FecReleaseSequencer.defer).
|
|
11165
|
+
*/
|
|
11166
|
+
deferFecRelease(work) {
|
|
11167
|
+
if (!this.#fecSequencer) {
|
|
11168
|
+
work();
|
|
11169
|
+
return;
|
|
11170
|
+
}
|
|
11171
|
+
this.#fecSequencer.defer(work);
|
|
11172
|
+
}
|
|
11173
|
+
/** See FecReleaseSequencer.earliestHeldArrivalMs. */
|
|
11174
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
11175
|
+
return this.#fecSequencer?.earliestHeldArrivalMs(packetId, catalogTrackName);
|
|
11176
|
+
}
|
|
11133
11177
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
11134
11178
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
11135
11179
|
if (!this.#fecSequencer) return;
|
|
@@ -11331,7 +11375,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
11331
11375
|
const parsed = preParsed !== void 0 && preParsed.skipFecPayloadId === (options?.skipFecPayloadId === true) ? preParsed : this.parsePacket(packet, options);
|
|
11332
11376
|
if (!parsed) return this.#drop("header-parse-failed");
|
|
11333
11377
|
const info = parsed.info;
|
|
11334
|
-
if (info.packetType !==
|
|
11378
|
+
if (info.packetType !== PACKET_TYPE_MPU) {
|
|
11335
11379
|
return {
|
|
11336
11380
|
kind: info.isRepair ? "repair" : "non-media",
|
|
11337
11381
|
packet: info,
|
|
@@ -11340,10 +11384,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
11340
11384
|
}
|
|
11341
11385
|
if (info.fecPayloadId !== null && this.#sourceSymbolCb) {
|
|
11342
11386
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
11343
|
-
const altaTrailer = extractAltaTrailer2(packet);
|
|
11344
|
-
const alta = altaTrailer ? { auth: altaTrailer.auth, payloadEnd: altaTrailer.signedEnd } : void 0;
|
|
11345
11387
|
try {
|
|
11346
|
-
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol
|
|
11388
|
+
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
11347
11389
|
} catch {
|
|
11348
11390
|
}
|
|
11349
11391
|
}
|
|
@@ -12468,6 +12510,8 @@ var MmtpRouter = class {
|
|
|
12468
12510
|
// ── Keyframe loss detection state ───────────────────────────────
|
|
12469
12511
|
/** Catalog-derived keyframe loss timeout (ms), or a reader evaluated at each arm. null = not configured (warns on video track registration; Phase-13 keyframe repair stays off). */
|
|
12470
12512
|
#keyframeLostTimeoutMs;
|
|
12513
|
+
/** packetIds already warned for running without Phase 13 (non-FEC video only). */
|
|
12514
|
+
#warnedNoKeyframeLostTimeout = /* @__PURE__ */ new Set();
|
|
12471
12515
|
/** Why the last reader evaluation left the timer unarmed; null while arming. Dedups the warning. */
|
|
12472
12516
|
#keyframeLostUnarmedReason = null;
|
|
12473
12517
|
/** Active keyframe loss timer handle. Single timer per video track — cleared on each rapFlag and on dispose(). */
|
|
@@ -12797,15 +12841,14 @@ var MmtpRouter = class {
|
|
|
12797
12841
|
}
|
|
12798
12842
|
/** Register MMTP packetId → track type mapping.
|
|
12799
12843
|
* Call BEFORE packets arrive to ensure correct routing from the first packet.
|
|
12800
|
-
*
|
|
12801
|
-
*
|
|
12802
|
-
*
|
|
12844
|
+
* Without keyframeLostTimeoutMs a track WITHOUT FEC has no Phase 13
|
|
12845
|
+
* keyframe repair (video still routes/decodes normally); that is warned at
|
|
12846
|
+
* its first keyframe, once the FEC configuration is known (see
|
|
12847
|
+
* #noteEmittedKeyframe). Nothing is warned here: an FEC track never uses
|
|
12848
|
+
* the timer, and at registration the FEC configuration may not be applied
|
|
12849
|
+
* yet. framerate is OPTIONAL per draft-ietf-moq-catalogformat-01 §3.2.23,
|
|
12850
|
+
* so we can't require the timeout. */
|
|
12803
12851
|
setPacketIdType(packetId, trackType) {
|
|
12804
|
-
if (trackType === "video" && this.#keyframeLostTimeoutMs === null) {
|
|
12805
|
-
console.warn(
|
|
12806
|
-
"[MmtpRouter] keyframeLostTimeoutMs not configured \u2014 Phase 13 keyframe repair disabled for this track. Set it via setKeyframeLostTimeoutMs() or provide in constructor config to enable: Math.ceil(groupDurationMs * KEYFRAME_LOST_TIMEOUT_SLACK)."
|
|
12807
|
-
);
|
|
12808
|
-
}
|
|
12809
12852
|
if (trackType === "video") this.#videoPacketIds.add(packetId);
|
|
12810
12853
|
else this.#audioPacketIds.add(packetId);
|
|
12811
12854
|
const codec = this.#trackCodecs.get(packetId) ?? "";
|
|
@@ -13236,6 +13279,7 @@ var MmtpRouter = class {
|
|
|
13236
13279
|
catalogTrackName
|
|
13237
13280
|
)) return;
|
|
13238
13281
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
13282
|
+
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
13239
13283
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
13240
13284
|
const recovered = fec.feedRepairSymbol(
|
|
13241
13285
|
ownerPacketId,
|
|
@@ -13277,7 +13321,7 @@ var MmtpRouter = class {
|
|
|
13277
13321
|
}
|
|
13278
13322
|
if (payload.oversized) continue;
|
|
13279
13323
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
13280
|
-
const recovered = fec.feedSourceSymbol(ownerPacketId, ssId, payload.symbolData,
|
|
13324
|
+
const recovered = fec.feedSourceSymbol(ownerPacketId, ssId, payload.symbolData, catalogTrackName);
|
|
13281
13325
|
if (!recovered || alreadyCompleted) continue;
|
|
13282
13326
|
fec.cancelBlockTimeout(blockStart, ownerPacketId, catalogTrackName);
|
|
13283
13327
|
fec.countRecovery(ownerPacketId, blockStart, catalogTrackName);
|
|
@@ -13305,7 +13349,7 @@ var MmtpRouter = class {
|
|
|
13305
13349
|
* Sync WASM decoders return the block's K' = SSB_length fixed-width
|
|
13306
13350
|
* ssbg_mode1 source symbols concatenated. */
|
|
13307
13351
|
routeRecoveredBlock(blockId, data, packetId, catalogTrackName) {
|
|
13308
|
-
this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName);
|
|
13352
|
+
this.#withDeferredFecPokes(() => this.#routeRecoveredBlock(blockId, data, packetId, catalogTrackName));
|
|
13309
13353
|
}
|
|
13310
13354
|
/** Route a single recovered source symbol through the parser + dedup pipeline.
|
|
13311
13355
|
* Worker-backed decoders emit one padded source symbol per frame event. */
|
|
@@ -13719,8 +13763,16 @@ var MmtpRouter = class {
|
|
|
13719
13763
|
#noteEmittedKeyframe(packetId, keyframe) {
|
|
13720
13764
|
if (!keyframe) return;
|
|
13721
13765
|
if (!this.#videoPacketIds.has(packetId)) return;
|
|
13722
|
-
if (this.#keyframeLostTimeoutMs === null) return;
|
|
13723
13766
|
if (this.#isFecTrack(packetId)) return;
|
|
13767
|
+
if (this.#keyframeLostTimeoutMs === null) {
|
|
13768
|
+
if (!this.#warnedNoKeyframeLostTimeout.has(packetId)) {
|
|
13769
|
+
this.#warnedNoKeyframeLostTimeout.add(packetId);
|
|
13770
|
+
console.warn(
|
|
13771
|
+
`[MmtpRouter] keyframeLostTimeoutMs not configured \u2014 Phase 13 keyframe repair disabled for packetId=${packetId}, a video track without FEC. Set it via setKeyframeLostTimeoutMs() or provide in constructor config to enable.`
|
|
13772
|
+
);
|
|
13773
|
+
}
|
|
13774
|
+
return;
|
|
13775
|
+
}
|
|
13724
13776
|
this.#lastKeyframeGroupId++;
|
|
13725
13777
|
this.#armKeyframeLostTimer();
|
|
13726
13778
|
}
|
|
@@ -13732,7 +13784,7 @@ var MmtpRouter = class {
|
|
|
13732
13784
|
#withDeferredFecPokes(work) {
|
|
13733
13785
|
this.#fecPokeDepth++;
|
|
13734
13786
|
try {
|
|
13735
|
-
work
|
|
13787
|
+
this.#parser.deferFecRelease(work);
|
|
13736
13788
|
} finally {
|
|
13737
13789
|
this.#fecPokeDepth--;
|
|
13738
13790
|
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
@@ -13744,6 +13796,13 @@ var MmtpRouter = class {
|
|
|
13744
13796
|
}
|
|
13745
13797
|
}
|
|
13746
13798
|
}
|
|
13799
|
+
/**
|
|
13800
|
+
* Arrival time of the earliest frame the FEC release gate holds for this
|
|
13801
|
+
* stream (see FecReleaseSequencer.earliestHeldArrivalMs), or undefined.
|
|
13802
|
+
*/
|
|
13803
|
+
fecReleaseEarliestHeldAtMs(packetId, catalogTrackName) {
|
|
13804
|
+
return this.#parser.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
13805
|
+
}
|
|
13747
13806
|
#requestFecPoke(packetId, catalogTrackName) {
|
|
13748
13807
|
if (this.#disposed) return;
|
|
13749
13808
|
if (this.#fecPokeDepth > 0) {
|
|
@@ -14112,6 +14171,8 @@ var MmtpRouter = class {
|
|
|
14112
14171
|
catalogTrackName
|
|
14113
14172
|
);
|
|
14114
14173
|
this.#routeTrackPacket(packet, info.packetId, info.sequenceNumber, {
|
|
14174
|
+
mmtpTimestamp: parsed.header.timestamp,
|
|
14175
|
+
rap: info.rapFlag,
|
|
14115
14176
|
recovered: false,
|
|
14116
14177
|
skipFecPayloadId: false,
|
|
14117
14178
|
catalogTrackName
|
|
@@ -14146,13 +14207,11 @@ var MmtpRouter = class {
|
|
|
14146
14207
|
const recovered = catalogTrackName === void 0 ? this.#fecManager.feedSourceSymbol(
|
|
14147
14208
|
info.packetId,
|
|
14148
14209
|
sourceFec.ssId,
|
|
14149
|
-
sourceFec.symbolData
|
|
14150
|
-
void 0
|
|
14210
|
+
sourceFec.symbolData
|
|
14151
14211
|
) : this.#fecManager.feedSourceSymbol(
|
|
14152
14212
|
info.packetId,
|
|
14153
14213
|
sourceFec.ssId,
|
|
14154
14214
|
sourceFec.symbolData,
|
|
14155
|
-
void 0,
|
|
14156
14215
|
catalogTrackName
|
|
14157
14216
|
);
|
|
14158
14217
|
if (recovered) {
|
|
@@ -14301,6 +14360,8 @@ var MmtpRouter = class {
|
|
|
14301
14360
|
callback(packet, {
|
|
14302
14361
|
packetId,
|
|
14303
14362
|
packetSequenceNumber,
|
|
14363
|
+
mmtpTimestamp: meta.mmtpTimestamp,
|
|
14364
|
+
rap: meta.rap,
|
|
14304
14365
|
recovered: meta.recovered,
|
|
14305
14366
|
skipFecPayloadId: meta.skipFecPayloadId,
|
|
14306
14367
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName },
|
|
@@ -14684,6 +14745,8 @@ var MmtpRouter = class {
|
|
|
14684
14745
|
) ?? "unknown";
|
|
14685
14746
|
for (const sym of result.symbols) {
|
|
14686
14747
|
this.#routeTrackPacket(sym.rawSymbol, ownerPacketId, sym.packetSequenceNumber, {
|
|
14748
|
+
mmtpTimestamp: sym.fragment.timestamp,
|
|
14749
|
+
rap: sym.fragment.rapFlag,
|
|
14687
14750
|
recovered: true,
|
|
14688
14751
|
skipFecPayloadId: true,
|
|
14689
14752
|
catalogTrackName,
|
|
@@ -15167,15 +15230,10 @@ var MoqFecAlgorithm;
|
|
|
15167
15230
|
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
15168
15231
|
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
15169
15232
|
|
|
15170
|
-
// node_modules/@blockcast/mmt-alta-parse/dist/index.js
|
|
15171
|
-
var MPU_HEADER_SIZE3 = 8;
|
|
15172
|
-
var MPU_LENGTH_FIELD_SIZE3 = 2;
|
|
15173
|
-
var MPU_HEADER_REMAINDER_SIZE3 = MPU_HEADER_SIZE3 - MPU_LENGTH_FIELD_SIZE3;
|
|
15174
|
-
|
|
15175
15233
|
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
15176
|
-
var
|
|
15177
|
-
var
|
|
15178
|
-
var
|
|
15234
|
+
var MPU_HEADER_SIZE2 = 8;
|
|
15235
|
+
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
15236
|
+
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
15179
15237
|
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
15180
15238
|
var MMTP_PACKET_ID_MAX2 = 65535;
|
|
15181
15239
|
|
|
@@ -15208,6 +15266,9 @@ var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
|
15208
15266
|
"iso-ssbg1-v1"
|
|
15209
15267
|
]);
|
|
15210
15268
|
|
|
15269
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
15270
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
15271
|
+
|
|
15211
15272
|
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
15212
15273
|
var DRIADDiscovery = class {
|
|
15213
15274
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -16410,6 +16471,10 @@ var TransportManager = class {
|
|
|
16410
16471
|
pollMulticastTierSwitch() {
|
|
16411
16472
|
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
|
|
16412
16473
|
}
|
|
16474
|
+
/** Abandon the in-flight tier join, e.g. because the host could not join the target. */
|
|
16475
|
+
cancelMulticastTierJoin() {
|
|
16476
|
+
return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
|
|
16477
|
+
}
|
|
16413
16478
|
/**
|
|
16414
16479
|
* Set packet callback
|
|
16415
16480
|
*/
|
|
@@ -17524,10 +17589,14 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
17524
17589
|
});
|
|
17525
17590
|
}
|
|
17526
17591
|
function catalogFecUnavailable(fec, fecPath) {
|
|
17592
|
+
if (catalogFecAvailable(fec)) return void 0;
|
|
17527
17593
|
const block = recordOf2(fec);
|
|
17528
|
-
if (block === void 0) return void 0;
|
|
17529
17594
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
17530
|
-
|
|
17595
|
+
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
17596
|
+
if (reason === void 0) {
|
|
17597
|
+
throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
|
|
17598
|
+
}
|
|
17599
|
+
return reason;
|
|
17531
17600
|
}
|
|
17532
17601
|
|
|
17533
17602
|
// src/multicast-manager.ts
|
|
@@ -17561,6 +17630,13 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
17561
17630
|
deltaRepairsPreempted: 0,
|
|
17562
17631
|
deltaRepairsDeferred: 0,
|
|
17563
17632
|
repairsSkipped: 0,
|
|
17633
|
+
repairsSkippedRttUnmeasured: 0,
|
|
17634
|
+
repairsSkippedRttExceedsBudget: 0,
|
|
17635
|
+
repairsSkippedPresentationDelayUnavailable: 0,
|
|
17636
|
+
lastRepairSkip: null,
|
|
17637
|
+
keyframeRepairFetchesSent: 0,
|
|
17638
|
+
keyframeBudgetHolds: 0,
|
|
17639
|
+
keyframeBudgetHoldMs: 0,
|
|
17564
17640
|
deltaBlocksFailed: 0,
|
|
17565
17641
|
audioBlocksRecoveredInband: 0,
|
|
17566
17642
|
audioBlocksRecoveredQuic: 0,
|
|
@@ -17773,7 +17849,10 @@ function projectFecDiagnosticBlock(block) {
|
|
|
17773
17849
|
lastSymbolTs: block.lastSymbolTs,
|
|
17774
17850
|
...block.completedTs === void 0 ? {} : { completedTs: block.completedTs },
|
|
17775
17851
|
deadlineTs: block.deadlineTs,
|
|
17776
|
-
|
|
17852
|
+
// ponytail: the per-packet authenticator is gone, so this is always 0. It
|
|
17853
|
+
// stays only because pim-multicast-gateway's normalizeSubscriptionDiagnostics
|
|
17854
|
+
// still requires a number here; drop it once that validator stops asking.
|
|
17855
|
+
altaVerified: 0,
|
|
17777
17856
|
relayBlockSigValid: block.relayBlockSigValid
|
|
17778
17857
|
};
|
|
17779
17858
|
}
|
|
@@ -17793,7 +17872,6 @@ function projectFecDiagnosticConfig(config) {
|
|
|
17793
17872
|
interleaveMs: config.interleaveMs,
|
|
17794
17873
|
fecMode: config.fecMode,
|
|
17795
17874
|
...config.repairTrack === void 0 ? {} : { repairTrack: config.repairTrack },
|
|
17796
|
-
altaEnabled: config.altaEnabled,
|
|
17797
17875
|
relayBlockSigEnabled: config.relayBlockSigEnabled
|
|
17798
17876
|
};
|
|
17799
17877
|
}
|
|
@@ -18475,7 +18553,7 @@ var MulticastManager = class {
|
|
|
18475
18553
|
)
|
|
18476
18554
|
)
|
|
18477
18555
|
};
|
|
18478
|
-
const amtRelay = config.amtRelay
|
|
18556
|
+
const amtRelay = config.amtRelay;
|
|
18479
18557
|
const transportConfig = {
|
|
18480
18558
|
sourceAddress: config.sourceAddress,
|
|
18481
18559
|
groupAddress: config.groupAddress,
|
|
@@ -18488,9 +18566,8 @@ var MulticastManager = class {
|
|
|
18488
18566
|
// endpoint-config.ts) deliberately has no implicit relay port — it throws
|
|
18489
18567
|
// and `MulticastTransport.join` resolves false — so the default is
|
|
18490
18568
|
// resolved HERE and arrives there explicit, exactly as the two catalog
|
|
18491
|
-
// readers do it. This is the last of the three readers:
|
|
18492
|
-
//
|
|
18493
|
-
// port field), and `resolveNetworkSource` emits the same port-less shape.
|
|
18569
|
+
// readers do it. This is the last of the three readers: `resolveNetworkSource`
|
|
18570
|
+
// emits a port-less relay shape.
|
|
18494
18571
|
// Keyed on the resolved relay, so a DRIAD entry — which pins no relay —
|
|
18495
18572
|
// never has a port manufactured for it. Blank counts as no relay, the
|
|
18496
18573
|
// same test `catalogAmtNetworkSource` applies (it trims, then skips) and
|
|
@@ -19062,7 +19139,17 @@ var MulticastManager = class {
|
|
|
19062
19139
|
}
|
|
19063
19140
|
/** Record a repair request the scheduler sent no FETCH for. */
|
|
19064
19141
|
noteRepairSkipped(reason, measurement, sbn, packetId, catalogTrackName) {
|
|
19065
|
-
this.#statsFor(packetId, catalogTrackName)
|
|
19142
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
19143
|
+
stats.repairsSkipped++;
|
|
19144
|
+
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
19145
|
+
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
19146
|
+
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
19147
|
+
stats.lastRepairSkip = {
|
|
19148
|
+
reason,
|
|
19149
|
+
rttMs: measurement.rttMs,
|
|
19150
|
+
budgetMs: measurement.budgetMs,
|
|
19151
|
+
priority: measurement.priority ?? null
|
|
19152
|
+
};
|
|
19066
19153
|
this.#emitRepairLifecycle({
|
|
19067
19154
|
version: 2,
|
|
19068
19155
|
type: "repair-skipped",
|
|
@@ -19072,6 +19159,24 @@ var MulticastManager = class {
|
|
|
19072
19159
|
budgetMs: measurement.budgetMs
|
|
19073
19160
|
});
|
|
19074
19161
|
}
|
|
19162
|
+
/**
|
|
19163
|
+
* Arrival time of the earliest frame the in-order release gate holds for
|
|
19164
|
+
* the stream: the gate releases it as a discontinuity once
|
|
19165
|
+
* `terminalRetentionMsForPacket` has passed since then.
|
|
19166
|
+
*/
|
|
19167
|
+
earliestGatedFrameAtMs(packetId, catalogTrackName) {
|
|
19168
|
+
return this.#router.fecReleaseEarliestHeldAtMs(packetId, catalogTrackName);
|
|
19169
|
+
}
|
|
19170
|
+
/** Record a keyframe late-repair budget the scheduler granted a block. */
|
|
19171
|
+
noteKeyframeBudgetGranted(extensionMs, _sbn, packetId, catalogTrackName) {
|
|
19172
|
+
const stats = this.#statsFor(packetId, catalogTrackName);
|
|
19173
|
+
stats.keyframeBudgetHolds++;
|
|
19174
|
+
stats.keyframeBudgetHoldMs += extensionMs;
|
|
19175
|
+
}
|
|
19176
|
+
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
19177
|
+
noteRepairFetchSent(priority, _sbn, packetId, catalogTrackName) {
|
|
19178
|
+
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
19179
|
+
}
|
|
19075
19180
|
/**
|
|
19076
19181
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
19077
19182
|
* keyframe/audio work, or never dispatched before its block resolved.
|
|
@@ -19099,7 +19204,10 @@ var MulticastManager = class {
|
|
|
19099
19204
|
const out = {};
|
|
19100
19205
|
for (const [key, stats] of this.#blockPolicyStats) {
|
|
19101
19206
|
if (stats.epoch !== this.#fec.epochFor(stats.packetId)) continue;
|
|
19102
|
-
out[key] = {
|
|
19207
|
+
out[key] = {
|
|
19208
|
+
...stats,
|
|
19209
|
+
lastRepairSkip: stats.lastRepairSkip === null ? null : { ...stats.lastRepairSkip }
|
|
19210
|
+
};
|
|
19103
19211
|
}
|
|
19104
19212
|
return out;
|
|
19105
19213
|
}
|