@blockcast/mmt-container 0.4.0 → 0.4.1-main.2e0aa69d293d
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 +37 -21
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +5070 -908
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +115 -235
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +113 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +464 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3692 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +101 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +422 -189
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +94 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +746 -131
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +140 -12
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +4104 -605
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +16 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +127 -240
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3643 -1197
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +90 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +160 -32
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- 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.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +378 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +453 -236
- package/src/multicast-auth-catalog.ts +196 -231
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +447 -53
- package/src/multicast-transport.ts +23 -5
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +306 -42
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
|
@@ -19,14 +19,21 @@ import {
|
|
|
19
19
|
} from '@blockcast/mmt-base'
|
|
20
20
|
|
|
21
21
|
export interface MulticastTransportConfig {
|
|
22
|
-
|
|
22
|
+
/** SSM source; omitted on ASM. */
|
|
23
|
+
sourceAddress?: string
|
|
24
|
+
/** ASM sender filter (multicast-contract 1.1.0 `senderAddress`); never beside `sourceAddress`. */
|
|
25
|
+
senderAddress?: string
|
|
23
26
|
groupAddress: string
|
|
24
27
|
port: number
|
|
25
28
|
mode?: 'auto' | 'native' | 'tunnel'
|
|
26
29
|
amtRelay?: string
|
|
27
30
|
amtRelayPort?: number
|
|
31
|
+
/** `'driad'`: with no relay, the gateway discovers one per RFC 8777. */
|
|
32
|
+
amtDiscovery?: 'driad'
|
|
28
33
|
packetIds?: number[]
|
|
29
34
|
tracks?: { name: string; packetId: number }[]
|
|
35
|
+
/** ATSC 3.0 tuning (`catalogAtsc3NetworkSource`); when set the join is the tuner. */
|
|
36
|
+
atsc3?: { frequency: number; plpId?: number; serviceId?: number }
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
export type ResolvedMulticastTransport = 'native' | 'amt'
|
|
@@ -330,8 +337,15 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
330
337
|
readonly #unadvertisedPacketIds = new Set<number>()
|
|
331
338
|
#joinGeneration = 0
|
|
332
339
|
|
|
333
|
-
|
|
340
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
341
|
+
readonly #gateway: WindowMulticastGateway | undefined
|
|
342
|
+
|
|
343
|
+
constructor(
|
|
344
|
+
onPacket: (packet: Uint8Array, context?: TPacketContext) => void,
|
|
345
|
+
options: { gateway?: WindowMulticastGateway } = {},
|
|
346
|
+
) {
|
|
334
347
|
this.#onPacket = onPacket
|
|
348
|
+
this.#gateway = options.gateway
|
|
335
349
|
}
|
|
336
350
|
|
|
337
351
|
static isAvailable(): boolean {
|
|
@@ -344,7 +358,8 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
344
358
|
this.#dataPlaneLive = false
|
|
345
359
|
|
|
346
360
|
if (this.#disposed) return this.#declined(generation, 'disposed')
|
|
347
|
-
|
|
361
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast
|
|
362
|
+
if (typeof gateway?.subscribe !== 'function') {
|
|
348
363
|
console.warn('[MulticastTransport] Multicast API not available')
|
|
349
364
|
return this.#declined(generation, 'unavailable')
|
|
350
365
|
}
|
|
@@ -356,20 +371,23 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
356
371
|
try {
|
|
357
372
|
const packetIds = config.packetIds?.length ? new Set(config.packetIds) : null
|
|
358
373
|
console.log(
|
|
359
|
-
`[MulticastTransport] window.multicast.subscribe(${config.sourceAddress}, ${config.groupAddress}, ${config.port})`,
|
|
374
|
+
`[MulticastTransport] window.multicast.subscribe(${config.sourceAddress ?? config.senderAddress ?? '*'}, ${config.groupAddress}, ${config.port})`,
|
|
360
375
|
)
|
|
361
376
|
const subscribeConfig = toWindowMulticastSubscribeConfig({
|
|
362
377
|
source: config.sourceAddress,
|
|
378
|
+
senderAddress: config.senderAddress,
|
|
363
379
|
group: config.groupAddress,
|
|
364
380
|
port: config.port,
|
|
365
381
|
mode: config.mode,
|
|
366
382
|
amtRelay: config.amtRelay,
|
|
367
383
|
amtRelayPort: config.amtRelayPort,
|
|
384
|
+
amtDiscovery: config.amtDiscovery,
|
|
368
385
|
packetIds: config.packetIds,
|
|
369
386
|
tracks: config.tracks,
|
|
387
|
+
atsc3: config.atsc3,
|
|
370
388
|
})
|
|
371
389
|
failure = 'provider-rejected'
|
|
372
|
-
const subscription = await
|
|
390
|
+
const subscription = await gateway.subscribe(subscribeConfig)
|
|
373
391
|
failure = 'invalid-subscription'
|
|
374
392
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription)
|
|
375
393
|
|
package/src/no-modules.ts
CHANGED
|
@@ -10,12 +10,13 @@ export {
|
|
|
10
10
|
CmsfCatalogValidationError,
|
|
11
11
|
resolveGroupDurationMs,
|
|
12
12
|
} from './carp-catalog.js'
|
|
13
|
-
export { catalogFecInterleaveMs,
|
|
13
|
+
export { catalogFecInterleaveMs, fecBlockBudgetMs, fecBlockDeadlineMs } from '@blockcast/mmt-fec'
|
|
14
14
|
export { FEC_INACTIVE_REASONS, catalogDeclaresFec, resolveFecState } from './fec-state.js'
|
|
15
|
+
export { MmtpFecSession } from './mmtp-fec-session.js'
|
|
16
|
+
export { catalogAmtNetworkSource, catalogAtsc3NetworkSource } from './catalog-network-source.js'
|
|
15
17
|
export { MmtpToCmaf } from './mmtp-to-cmaf.js'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from '@blockcast/mmt-manifest-verify'
|
|
18
|
+
// Catalog initData contract check (mmt-01 4.5). Shaka's Closure build can
|
|
19
|
+
// reach only this classic-script surface, so it has to be exported here as
|
|
20
|
+
// well as from the barrel (BLO-49943).
|
|
21
|
+
export { isFmp4InitSegment } from './codec-utils.js'
|
|
22
|
+
export { BcProvenanceV2Receiver } from '@blockcast/mmt-manifest-verify'
|
|
@@ -50,7 +50,7 @@ export interface Phase14OverrideTrack {
|
|
|
50
50
|
* derives it from the override's top-level `streamingFormat`. */
|
|
51
51
|
packaging?: "mmtp" | "cmaf" | "loc" | "timeline";
|
|
52
52
|
/** Required when packaging is `mmtp`; the current publisher emits MFU mode. */
|
|
53
|
-
mmtpMode?: "
|
|
53
|
+
mmtpMode?: "mfu";
|
|
54
54
|
/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */
|
|
55
55
|
timescale?: number;
|
|
56
56
|
/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */
|
|
@@ -262,7 +262,7 @@ export function mergeOverrideIntoCmsfTracks(
|
|
|
262
262
|
if (ot.role !== undefined && existing.role === undefined) existing.role = ot.role;
|
|
263
263
|
if (existing.packaging === "mmtp") {
|
|
264
264
|
const mode = existing.mmtpMode ?? ot.mmtpMode;
|
|
265
|
-
if (mode !== "
|
|
265
|
+
if (mode !== "mfu") {
|
|
266
266
|
throw new Error(
|
|
267
267
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`,
|
|
268
268
|
);
|
|
@@ -302,7 +302,7 @@ export function mergeOverrideIntoCmsfTracks(
|
|
|
302
302
|
);
|
|
303
303
|
}
|
|
304
304
|
const mmtpMode = ot.mmtpMode;
|
|
305
|
-
if (packaging === "mmtp" && mmtpMode !== "
|
|
305
|
+
if (packaging === "mmtp" && mmtpMode !== "mfu") {
|
|
306
306
|
throw new Error(
|
|
307
307
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`,
|
|
308
308
|
);
|
package/src/repair-fetch.ts
CHANGED
|
@@ -80,19 +80,25 @@
|
|
|
80
80
|
* A FETCH landing after the gate forced that frame out would recover media
|
|
81
81
|
* the gate then drops as stale.
|
|
82
82
|
*
|
|
83
|
-
* The scheduler arms no timers. A fetch ends when its
|
|
84
|
-
* throws, when it is preempted, when any later
|
|
85
|
-
* its presentation deadline, when its block
|
|
86
|
-
* that deadline), on track reset, or on
|
|
83
|
+
* The scheduler arms no timers for block requests. A fetch ends when its
|
|
84
|
+
* transport completes or throws, when it is preempted, when any later
|
|
85
|
+
* scheduling event finds it past its presentation deadline, when its block
|
|
86
|
+
* resolves (recovered, or failed at that deadline), on track reset, or on
|
|
87
|
+
* dispose. A range request (§7.5) is for a hole, not a tracked block, so no
|
|
88
|
+
* FEC deadline resolves it: it arms one timer at its deadline, cleared when
|
|
89
|
+
* it retires, so a hung range FETCH cannot hold the hole (and the release
|
|
90
|
+
* gate behind it) past that deadline.
|
|
87
91
|
*/
|
|
88
92
|
|
|
89
93
|
import { parseFecBlockProfile, type FecBlockProfile } from '@blockcast/mmt-base'
|
|
94
|
+
import { extendSsId, repairFetchRange, type RepairFetchRange } from '@blockcast/mmt-fec'
|
|
90
95
|
import {
|
|
91
96
|
repairPriorityForClass,
|
|
92
97
|
type BlockClass,
|
|
93
98
|
type ClassifierMode,
|
|
94
99
|
type RepairPriority,
|
|
95
100
|
} from './block-policy.js'
|
|
101
|
+
import type { UndelimitedIsoLoss } from './fec-manager.js'
|
|
96
102
|
import type { RepairLifecycleObserver } from './multicast-manager.js'
|
|
97
103
|
import { REPAIR_PRIORITY_MIN } from './repair-layers.js'
|
|
98
104
|
|
|
@@ -205,6 +211,31 @@ export interface RepairFetchRequest {
|
|
|
205
211
|
* is not known yet is cancelled as soon as FETCH_OK assigns it. */
|
|
206
212
|
export type RepairFetchTransport = (request: RepairFetchRequest) => AsyncIterable<Uint8Array>
|
|
207
213
|
|
|
214
|
+
/**
|
|
215
|
+
* One range repair FETCH for a lost SS_ID in an undelimited span
|
|
216
|
+
* (draft-ramadan-moq-fec §7.5): the absolute, inclusive repair-track Group
|
|
217
|
+
* range `repairFetchRange` gives. The last Group returned is the block holding
|
|
218
|
+
* `lostSsId`; earlier ones are other blocks, admitted like any repair object.
|
|
219
|
+
*/
|
|
220
|
+
export interface RepairRangeFetchRequest extends RepairFetchRange {
|
|
221
|
+
readonly repairTrack: string
|
|
222
|
+
/** The lost SS_ID x the range was computed for. */
|
|
223
|
+
readonly lostSsId: number
|
|
224
|
+
readonly blockProfile: FecBlockProfile
|
|
225
|
+
readonly packetId: number
|
|
226
|
+
/** Same contract as `RepairFetchRequest.signal`: cancel on the wire. */
|
|
227
|
+
readonly signal: AbortSignal
|
|
228
|
+
/** Same contract as `RepairFetchRequest.subscriberPriority`. */
|
|
229
|
+
readonly subscriberPriority: number | undefined
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Protocol-specific range FETCH (e.g. MoQT LOCATION_FILTER 0x03 Group range).
|
|
234
|
+
* Yield each repair object payload; return when the range ends. The abort
|
|
235
|
+
* rules of {@link RepairFetchTransport} apply unchanged.
|
|
236
|
+
*/
|
|
237
|
+
export type RepairRangeFetchTransport = (request: RepairRangeFetchRequest) => AsyncIterable<Uint8Array>
|
|
238
|
+
|
|
208
239
|
/** Why a request could not carry a catalog-derived priority. */
|
|
209
240
|
export type RepairPriorityReason =
|
|
210
241
|
| 'source-priority-absent'
|
|
@@ -327,6 +358,22 @@ export interface WireRepairFetchOptions {
|
|
|
327
358
|
* `all-protected` stream.
|
|
328
359
|
*/
|
|
329
360
|
keyframeRepairBudgetMs?: (packetId: number, catalogTrackName?: string) => number
|
|
361
|
+
/**
|
|
362
|
+
* Range repair for a lost SS_ID whose block no repair delimited
|
|
363
|
+
* (draft-ramadan-moq-fec §7.5), optional. Given, the host keeps such a gap
|
|
364
|
+
* as a pending hole and the scheduler FETCHes `repairFetchRange(x, K,
|
|
365
|
+
* anchor)` for it under the same admission, priority and abort rules as a
|
|
366
|
+
* block request (class `unknown`, P0). Requires `repairEpochReference`.
|
|
367
|
+
*/
|
|
368
|
+
rangeTransport?: RepairRangeFetchTransport
|
|
369
|
+
/**
|
|
370
|
+
* The epoch reference r of `repairTrack` on the live session
|
|
371
|
+
* (`RepairEpochReferences.reference`), or undefined while none is held.
|
|
372
|
+
* The §7.5 anchor is ext(S_prev) extended from it when a stated block ends
|
|
373
|
+
* where the hole starts, else r itself; without r no range request is sent
|
|
374
|
+
* (`range-no-anchor`).
|
|
375
|
+
*/
|
|
376
|
+
repairEpochReference?: (repairTrack: string) => bigint | undefined
|
|
330
377
|
}
|
|
331
378
|
|
|
332
379
|
/** Why the D-28 layer asked for a repair: the block's class at its deadline. */
|
|
@@ -345,6 +392,41 @@ export type RepairSkipReason =
|
|
|
345
392
|
| 'rtt-exceeds-budget'
|
|
346
393
|
/** The player gave no usable presentation delay for the block's stream. */
|
|
347
394
|
| 'presentation-delay-unavailable'
|
|
395
|
+
/** A lost SS_ID in an undelimited span had no §7.5 anchor to extend it from. */
|
|
396
|
+
| 'range-no-anchor'
|
|
397
|
+
/**
|
|
398
|
+
* The block lost more sources than its repair group carries symbols
|
|
399
|
+
* (sources + RSB_length < K'): no FETCH of the group can complete it, and
|
|
400
|
+
* when multicast already delivered the whole group the relay could serve
|
|
401
|
+
* only duplicates (BLO-50082).
|
|
402
|
+
*/
|
|
403
|
+
| 'group-cannot-complete'
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Which term set a FETCH's deadline (BLO-33597): the multicast wait, the
|
|
407
|
+
* player's presentation delay past the block anchor, the keyframe budget past
|
|
408
|
+
* the anchor (when it granted more than the presentation delay), or the
|
|
409
|
+
* release gate's retention ceiling.
|
|
410
|
+
*/
|
|
411
|
+
export type RepairDeadlineBound = 'wait' | 'presentation' | 'keyframe' | 'retention'
|
|
412
|
+
|
|
413
|
+
/** The admission inputs of a FETCH the scheduler sent (BLO-33597). */
|
|
414
|
+
export interface RepairSendMeasurement {
|
|
415
|
+
/** The reliable-path RTT admission compared against `budgetMs`. */
|
|
416
|
+
readonly rttMs: number
|
|
417
|
+
/** Time left to the entry's deadline when the FETCH was sent. */
|
|
418
|
+
readonly budgetMs: number
|
|
419
|
+
/**
|
|
420
|
+
* Delay past the block anchor the deadline was computed from; null when
|
|
421
|
+
* the block had no anchor (its deadline is then the multicast wait).
|
|
422
|
+
*/
|
|
423
|
+
readonly delayMs: number | null
|
|
424
|
+
/** Time since the block anchor; null when the block had no anchor. */
|
|
425
|
+
readonly blockAgeMs: number | null
|
|
426
|
+
readonly bound: RepairDeadlineBound
|
|
427
|
+
/** True for a range repair FETCH (§7.5 lost SS_ID); absent for a block FETCH. */
|
|
428
|
+
readonly range?: true
|
|
429
|
+
}
|
|
348
430
|
|
|
349
431
|
/** The subset of MulticastManager the scheduler drives. */
|
|
350
432
|
export interface RepairFetchHost {
|
|
@@ -396,8 +478,14 @@ export interface RepairFetchHost {
|
|
|
396
478
|
): void
|
|
397
479
|
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void
|
|
398
480
|
addTrackResetObserver(observer: (packetId: number, catalogTrackName: string) => void): () => void
|
|
481
|
+
/** Register for lost SS_IDs in undelimited spans (required with `rangeTransport`). */
|
|
482
|
+
onUndelimitedLoss?(cb: (loss: UndelimitedIsoLoss) => void): void
|
|
483
|
+
/** A hole's range repair ended, or none is sent: feed what was not stated. */
|
|
484
|
+
closeIsoHoles?(packetId: number, catalogTrackName: string | undefined, start: number, length: number): void
|
|
399
485
|
clearRepairForBlock(sbn: number, packetId: number, catalogTrackName?: string): void
|
|
400
486
|
processRepairFromMoQ(packet: Uint8Array, ownerPacketId?: number, catalogTrackName?: string): void
|
|
487
|
+
/** This scheduler can request unicast repair: protected flows keep pending entries for it (optional). */
|
|
488
|
+
setUnicastRepair?(enabled: boolean): void
|
|
401
489
|
noteRepairScheduling(
|
|
402
490
|
type: 'repair-preempted' | 'repair-deferred',
|
|
403
491
|
sbn: number,
|
|
@@ -433,7 +521,8 @@ export interface RepairFetchHost {
|
|
|
433
521
|
priority: RepairPriority,
|
|
434
522
|
sbn: number,
|
|
435
523
|
packetId: number,
|
|
436
|
-
catalogTrackName
|
|
524
|
+
catalogTrackName: string | undefined,
|
|
525
|
+
measurement: RepairSendMeasurement,
|
|
437
526
|
): void
|
|
438
527
|
}
|
|
439
528
|
|
|
@@ -462,10 +551,26 @@ interface RepairEntry {
|
|
|
462
551
|
* later: a block reclassified from delta can gain the keyframe budget.
|
|
463
552
|
*/
|
|
464
553
|
deadlineAt: number
|
|
554
|
+
/** Inputs `deadlineAt` was computed from; they move with it. */
|
|
555
|
+
anchorAt: number | null
|
|
556
|
+
delayMs: number | null
|
|
557
|
+
bound: RepairDeadlineBound
|
|
465
558
|
/** Monotonic enqueue order, the EDF tie-break. */
|
|
466
559
|
readonly order: number
|
|
467
560
|
attempts: number
|
|
468
561
|
running: FetchRun | null
|
|
562
|
+
/** A range request for a pending hole `[sbn, sbn + holeLength)`. */
|
|
563
|
+
readonly range?: RepairFetchRange & { readonly lostSsId: number; readonly holeLength: number }
|
|
564
|
+
/** A range request's deadline timer (see the module note). */
|
|
565
|
+
expiry?: ReturnType<typeof setTimeout>
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
interface ResolvedDeadline {
|
|
569
|
+
readonly deadlineAt: number
|
|
570
|
+
readonly extensionMs: number
|
|
571
|
+
readonly anchorAt: number | null
|
|
572
|
+
readonly delayMs: number | null
|
|
573
|
+
readonly bound: RepairDeadlineBound
|
|
469
574
|
}
|
|
470
575
|
|
|
471
576
|
/**
|
|
@@ -490,6 +595,13 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
490
595
|
if (typeof opts.presentationDelayMs !== 'function') {
|
|
491
596
|
throw new Error('[RepairFetch] presentationDelayMs is required: a repair FETCH is due by the block\'s presentation deadline')
|
|
492
597
|
}
|
|
598
|
+
if (
|
|
599
|
+
opts.rangeTransport !== undefined &&
|
|
600
|
+
(typeof opts.repairEpochReference !== 'function' || !mc.onUndelimitedLoss || !mc.closeIsoHoles)
|
|
601
|
+
) {
|
|
602
|
+
throw new Error('[RepairFetch] rangeTransport needs repairEpochReference and a host that reports undelimited losses')
|
|
603
|
+
}
|
|
604
|
+
mc.setUnicastRepair?.(true)
|
|
493
605
|
const entries = new Map<string, RepairEntry>()
|
|
494
606
|
const warnedNoTarget = new Set<string>()
|
|
495
607
|
let disposed = false
|
|
@@ -508,7 +620,15 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
508
620
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
509
621
|
}
|
|
510
622
|
|
|
623
|
+
/** Whatever ends an entry: a block's repair slot, or a hole's pending state. */
|
|
624
|
+
const clearEntry = (entry: RepairEntry): void => {
|
|
625
|
+
if (entry.range) mc.closeIsoHoles!(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength)
|
|
626
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
627
|
+
}
|
|
628
|
+
|
|
511
629
|
const releaseHold = (entry: RepairEntry): void => {
|
|
630
|
+
// A hole is no tracked block: nothing holds it but the hole itself.
|
|
631
|
+
if (entry.range) return
|
|
512
632
|
if (entry.catalogTrackName === undefined) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId)
|
|
513
633
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
514
634
|
}
|
|
@@ -546,29 +666,39 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
546
666
|
}
|
|
547
667
|
|
|
548
668
|
/**
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* deadline
|
|
669
|
+
* Admission: send only a FETCH whose repair group can complete the block
|
|
670
|
+
* and that the measured round trip says can land before the entry's
|
|
671
|
+
* deadline. A refused entry is released, not queued: the
|
|
672
|
+
* deadline only gets closer. Returns the admitting RTT, or null when refused.
|
|
552
673
|
*/
|
|
553
|
-
const admit = (entry: RepairEntry, now: number):
|
|
674
|
+
const admit = (entry: RepairEntry, now: number): number | null => {
|
|
554
675
|
const budgetMs = entry.deadlineAt - now
|
|
555
676
|
const rttMs = readRtt()
|
|
556
|
-
|
|
677
|
+
const reason: RepairSkipReason | null =
|
|
678
|
+
!entry.range && !groupCanComplete(entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
679
|
+
? 'group-cannot-complete'
|
|
680
|
+
: rttMs === null
|
|
681
|
+
? 'rtt-unmeasured'
|
|
682
|
+
: rttMs < budgetMs
|
|
683
|
+
? null
|
|
684
|
+
: 'rtt-exceeds-budget'
|
|
685
|
+
if (reason === null) return rttMs
|
|
557
686
|
retire(entry)
|
|
558
687
|
releaseHold(entry)
|
|
559
|
-
|
|
688
|
+
clearEntry(entry)
|
|
560
689
|
mc.noteRepairSkipped(
|
|
561
|
-
|
|
690
|
+
reason,
|
|
562
691
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
563
692
|
entry.sbn,
|
|
564
693
|
entry.packetId,
|
|
565
694
|
entry.catalogTrackName,
|
|
566
695
|
)
|
|
567
|
-
return
|
|
696
|
+
return null
|
|
568
697
|
}
|
|
569
698
|
|
|
570
699
|
const retire = (entry: RepairEntry): void => {
|
|
571
700
|
if (entries.get(entry.key) === entry) entries.delete(entry.key)
|
|
701
|
+
if (entry.expiry !== undefined) clearTimeout(entry.expiry)
|
|
572
702
|
}
|
|
573
703
|
|
|
574
704
|
const urgentOutstanding = (): boolean => {
|
|
@@ -609,19 +739,30 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
609
739
|
|
|
610
740
|
/** `counted` is false for a reprioritisation restart, which is no retry. */
|
|
611
741
|
const start = (entry: RepairEntry, counted = true): void => {
|
|
612
|
-
|
|
742
|
+
const now = performance.now()
|
|
743
|
+
const rttMs = admit(entry, now)
|
|
744
|
+
if (rttMs === null) return
|
|
613
745
|
if (counted) entry.attempts++
|
|
614
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
746
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
747
|
+
rttMs,
|
|
748
|
+
budgetMs: entry.deadlineAt - now,
|
|
749
|
+
delayMs: entry.delayMs,
|
|
750
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
751
|
+
bound: entry.bound,
|
|
752
|
+
...(entry.range ? { range: true as const } : {}),
|
|
753
|
+
})
|
|
615
754
|
const run: FetchRun = { controller: new AbortController(), stopped: null }
|
|
616
755
|
entry.running = run
|
|
617
756
|
// Hold the block open to the presentation deadline while this FETCH can
|
|
618
757
|
// still land: the multicast span elapsing must not abort it.
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
758
|
+
if (!entry.range) {
|
|
759
|
+
mc.fecManager.holdBlockForRepair(
|
|
760
|
+
entry.sbn,
|
|
761
|
+
entry.packetId,
|
|
762
|
+
entry.catalogTrackName,
|
|
763
|
+
entry.deadlineAt,
|
|
764
|
+
)
|
|
765
|
+
}
|
|
625
766
|
void execute(entry, run)
|
|
626
767
|
}
|
|
627
768
|
|
|
@@ -638,7 +779,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
638
779
|
if (entry.deadlineAt <= now) {
|
|
639
780
|
stop(entry, 'expired')
|
|
640
781
|
retire(entry)
|
|
641
|
-
|
|
782
|
+
clearEntry(entry)
|
|
642
783
|
}
|
|
643
784
|
continue
|
|
644
785
|
}
|
|
@@ -647,7 +788,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
647
788
|
// no fetch can land in time.
|
|
648
789
|
retire(entry)
|
|
649
790
|
if (entry.priority === 2 && entry.attempts === 0) note('repair-deferred', entry)
|
|
650
|
-
|
|
791
|
+
clearEntry(entry)
|
|
651
792
|
continue
|
|
652
793
|
}
|
|
653
794
|
queued.push(entry)
|
|
@@ -711,9 +852,11 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
711
852
|
// A fetch that ended without feeding anything cannot resolve the block;
|
|
712
853
|
// release the slot and the hold so failure accounting is not wedged. A
|
|
713
854
|
// fetch that fed symbols leaves resolution to the FEC layer.
|
|
714
|
-
|
|
855
|
+
// A range FETCH placed whatever it stated as it arrived; the rest of
|
|
856
|
+
// its hole is now known to have no repair coming.
|
|
857
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
715
858
|
releaseHold(entry)
|
|
716
|
-
|
|
859
|
+
clearEntry(entry)
|
|
717
860
|
}
|
|
718
861
|
dispatch()
|
|
719
862
|
return
|
|
@@ -730,7 +873,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
730
873
|
}
|
|
731
874
|
retire(entry)
|
|
732
875
|
if (fed === 0) releaseHold(entry)
|
|
733
|
-
|
|
876
|
+
clearEntry(entry)
|
|
734
877
|
console.warn(
|
|
735
878
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
736
879
|
error,
|
|
@@ -756,15 +899,23 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
756
899
|
|
|
757
900
|
const execute = async (entry: RepairEntry, run: FetchRun): Promise<void> => {
|
|
758
901
|
let fed = 0
|
|
902
|
+
const common = {
|
|
903
|
+
repairTrack: entry.repairTrack,
|
|
904
|
+
blockProfile: entry.blockProfile,
|
|
905
|
+
packetId: entry.packetId,
|
|
906
|
+
signal: run.controller.signal,
|
|
907
|
+
subscriberPriority: entry.subscriberPriority,
|
|
908
|
+
}
|
|
759
909
|
try {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
910
|
+
const packets = entry.range
|
|
911
|
+
? opts.rangeTransport!({
|
|
912
|
+
...common,
|
|
913
|
+
startGroup: entry.range.startGroup,
|
|
914
|
+
endGroup: entry.range.endGroup,
|
|
915
|
+
lostSsId: entry.range.lostSsId,
|
|
916
|
+
})
|
|
917
|
+
: opts.transport({ ...common, sbn: entry.sbn })
|
|
918
|
+
for await (const packet of packets) {
|
|
768
919
|
if (run.stopped !== null || entry.running !== run) break
|
|
769
920
|
fed++
|
|
770
921
|
if (entry.catalogTrackName === undefined) {
|
|
@@ -784,6 +935,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
784
935
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue
|
|
785
936
|
retire(entry)
|
|
786
937
|
stop(entry, 'reset')
|
|
938
|
+
if (entry.range) clearEntry(entry)
|
|
787
939
|
}
|
|
788
940
|
// A reset is when the packetId -> repair-track mapping can change, so
|
|
789
941
|
// re-arm the once-per-track warn for the new epoch.
|
|
@@ -816,6 +968,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
816
968
|
)
|
|
817
969
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry.deadlineAt) {
|
|
818
970
|
entry.deadlineAt = promotedDeadline.deadlineAt
|
|
971
|
+
entry.anchorAt = promotedDeadline.anchorAt
|
|
972
|
+
entry.delayMs = promotedDeadline.delayMs
|
|
973
|
+
entry.bound = promotedDeadline.bound
|
|
819
974
|
noteBudget(entry, promotedDeadline.extensionMs)
|
|
820
975
|
}
|
|
821
976
|
if (entry.running) {
|
|
@@ -859,14 +1014,16 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
859
1014
|
catalogTrackName: string | undefined,
|
|
860
1015
|
now: number,
|
|
861
1016
|
blockClass: BlockClass,
|
|
862
|
-
):
|
|
1017
|
+
): ResolvedDeadline | null => {
|
|
863
1018
|
// Undefined: the packetId is no longer configured (released), so it has
|
|
864
1019
|
// no repair budget.
|
|
865
1020
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName)
|
|
866
1021
|
if (waitMs === undefined) return null
|
|
867
1022
|
const waitDeadlineAt = now + waitMs
|
|
868
1023
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName)
|
|
869
|
-
if (anchor === undefined)
|
|
1024
|
+
if (anchor === undefined) {
|
|
1025
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: 'wait' }
|
|
1026
|
+
}
|
|
870
1027
|
let delayMs: number
|
|
871
1028
|
try {
|
|
872
1029
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName)
|
|
@@ -877,16 +1034,28 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
877
1034
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId)
|
|
878
1035
|
if (retentionMs === undefined) return null
|
|
879
1036
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs
|
|
880
|
-
const
|
|
881
|
-
|
|
1037
|
+
const at = (
|
|
1038
|
+
delay: number,
|
|
1039
|
+
delayBound: 'presentation' | 'keyframe',
|
|
1040
|
+
): { readonly deadlineAt: number; readonly bound: RepairDeadlineBound } => {
|
|
1041
|
+
const presentAt = Math.min(anchor + delay, ceilingAt)
|
|
1042
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: 'wait' }
|
|
1043
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : 'retention' }
|
|
1044
|
+
}
|
|
1045
|
+
const base = at(delayMs, 'presentation')
|
|
882
1046
|
const budgetMs =
|
|
883
1047
|
keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) &&
|
|
884
1048
|
groupCanComplete(sbn, packetId, catalogTrackName)
|
|
885
1049
|
? readKeyframeBudget(packetId, catalogTrackName)
|
|
886
1050
|
: null
|
|
887
|
-
if (budgetMs === null || budgetMs <= delayMs) return {
|
|
888
|
-
const extended =
|
|
889
|
-
return {
|
|
1051
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs }
|
|
1052
|
+
const extended = at(budgetMs, 'keyframe')
|
|
1053
|
+
return {
|
|
1054
|
+
...extended,
|
|
1055
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
1056
|
+
anchorAt: anchor,
|
|
1057
|
+
delayMs: budgetMs,
|
|
1058
|
+
}
|
|
890
1059
|
}
|
|
891
1060
|
|
|
892
1061
|
const earliestGatedFrameAt = (packetId: number, catalogTrackName: string | undefined): number | undefined => {
|
|
@@ -978,6 +1147,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
978
1147
|
priority,
|
|
979
1148
|
subscriberPriority: wire.subscriberPriority,
|
|
980
1149
|
deadlineAt: deadline.deadlineAt,
|
|
1150
|
+
anchorAt: deadline.anchorAt,
|
|
1151
|
+
delayMs: deadline.delayMs,
|
|
1152
|
+
bound: deadline.bound,
|
|
981
1153
|
order: enqueueOrder++,
|
|
982
1154
|
attempts: 0,
|
|
983
1155
|
running: null,
|
|
@@ -988,14 +1160,106 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
988
1160
|
dispatch()
|
|
989
1161
|
})
|
|
990
1162
|
|
|
1163
|
+
/**
|
|
1164
|
+
* §7.5 range for a lost SS_ID: from ext(S_prev) when a stated block ends
|
|
1165
|
+
* where the hole starts, else from the epoch reference r. Null when there
|
|
1166
|
+
* is no r, or the lost SS_ID cannot be extended from it.
|
|
1167
|
+
*/
|
|
1168
|
+
const rangeFor = (loss: UndelimitedIsoLoss, repairTrack: string): RepairFetchRange | null => {
|
|
1169
|
+
let reference: bigint | undefined
|
|
1170
|
+
try {
|
|
1171
|
+
reference = opts.repairEpochReference!(repairTrack)
|
|
1172
|
+
} catch {
|
|
1173
|
+
return null
|
|
1174
|
+
}
|
|
1175
|
+
if (reference === undefined) return null
|
|
1176
|
+
try {
|
|
1177
|
+
const anchor = loss.previousBlockStart === undefined
|
|
1178
|
+
? { reference }
|
|
1179
|
+
: { previousBlockStart: extendSsId(reference, loss.previousBlockStart) }
|
|
1180
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor)
|
|
1181
|
+
} catch (error) {
|
|
1182
|
+
if (error instanceof RangeError) return null
|
|
1183
|
+
throw error
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
if (opts.rangeTransport !== undefined) {
|
|
1188
|
+
mc.onUndelimitedLoss!((loss) => {
|
|
1189
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss
|
|
1190
|
+
const close = (): void => mc.closeIsoHoles!(packetId, catalogTrackName, holeStart, holeLength)
|
|
1191
|
+
if (disposed) return close()
|
|
1192
|
+
const blockProfile = blockProfileOf(packetId)
|
|
1193
|
+
const target = opts.resolveTarget(packetId, catalogTrackName)
|
|
1194
|
+
if (!target) return close()
|
|
1195
|
+
const priority = repairPriorityForClass('unknown')
|
|
1196
|
+
const range = rangeFor(loss, target.repairTrack)
|
|
1197
|
+
if (range === null) {
|
|
1198
|
+
close()
|
|
1199
|
+
mc.noteRepairSkipped('range-no-anchor', { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName)
|
|
1200
|
+
return
|
|
1201
|
+
}
|
|
1202
|
+
const identity = {
|
|
1203
|
+
target,
|
|
1204
|
+
sbn: holeStart,
|
|
1205
|
+
packetId,
|
|
1206
|
+
...(catalogTrackName === undefined ? {} : { catalogTrackName }),
|
|
1207
|
+
}
|
|
1208
|
+
// `unknown` is P0, whose request is never declined (omitted at worst).
|
|
1209
|
+
const wire = wirePriority(identity, 'unknown')!
|
|
1210
|
+
// The hole is no tracked block: no anchor, so this is the multicast
|
|
1211
|
+
// wait (`bound: 'wait'`), by intent. A hole holds the release gate, so it
|
|
1212
|
+
// must not wait out a presentation delay on top.
|
|
1213
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), 'unknown')
|
|
1214
|
+
if (deadline === null) {
|
|
1215
|
+
close()
|
|
1216
|
+
mc.noteRepairSkipped(
|
|
1217
|
+
'presentation-delay-unavailable',
|
|
1218
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
1219
|
+
holeStart,
|
|
1220
|
+
packetId,
|
|
1221
|
+
catalogTrackName,
|
|
1222
|
+
)
|
|
1223
|
+
return
|
|
1224
|
+
}
|
|
1225
|
+
const entry: RepairEntry = {
|
|
1226
|
+
key: JSON.stringify(['range', packetId, catalogTrackName ?? null, holeStart]),
|
|
1227
|
+
...identity,
|
|
1228
|
+
repairTrack: target.repairTrack,
|
|
1229
|
+
blockProfile,
|
|
1230
|
+
priority,
|
|
1231
|
+
subscriberPriority: wire.subscriberPriority,
|
|
1232
|
+
deadlineAt: deadline.deadlineAt,
|
|
1233
|
+
anchorAt: deadline.anchorAt,
|
|
1234
|
+
delayMs: deadline.delayMs,
|
|
1235
|
+
bound: deadline.bound,
|
|
1236
|
+
order: enqueueOrder++,
|
|
1237
|
+
attempts: 0,
|
|
1238
|
+
running: null,
|
|
1239
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength },
|
|
1240
|
+
}
|
|
1241
|
+
const previous = entries.get(entry.key)
|
|
1242
|
+
if (previous) {
|
|
1243
|
+
retire(previous)
|
|
1244
|
+
stop(previous, 'reset')
|
|
1245
|
+
}
|
|
1246
|
+
entries.set(entry.key, entry)
|
|
1247
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1)
|
|
1248
|
+
preemptDeltas()
|
|
1249
|
+
dispatch()
|
|
1250
|
+
})
|
|
1251
|
+
}
|
|
1252
|
+
|
|
991
1253
|
return () => {
|
|
992
1254
|
disposed = true
|
|
1255
|
+
mc.setUnicastRepair?.(false)
|
|
993
1256
|
removeResetObserver()
|
|
994
1257
|
removeLifecycleObserver()
|
|
995
1258
|
for (const entry of [...entries.values()]) {
|
|
996
|
-
|
|
1259
|
+
clearEntry(entry)
|
|
997
1260
|
if (entry.running) releaseHold(entry)
|
|
998
1261
|
stop(entry, 'disposed')
|
|
1262
|
+
if (entry.expiry !== undefined) clearTimeout(entry.expiry)
|
|
999
1263
|
}
|
|
1000
1264
|
entries.clear()
|
|
1001
1265
|
}
|