@blockcast/mmt-container 0.4.0 → 0.4.1-main.22841c1f0a2d
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 +2037 -881
- 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 +98 -234
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +108 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +452 -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 +3677 -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 +69 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +296 -192
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +313 -124
- package/dist/multicast-auth-catalog.js.map +3 -3
- 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 +97 -11
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1022 -527
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +108 -238
- 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 +3625 -1194
- 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 +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- 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 +366 -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 +301 -240
- package/src/multicast-auth-catalog.ts +134 -238
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +271 -40
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- 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
package/src/multicast-manager.ts
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
type FecFallbackDecoder,
|
|
19
19
|
type MulticastSymbolDelivery,
|
|
20
20
|
type RepairVia,
|
|
21
|
+
type UndelimitedIsoLoss,
|
|
22
|
+
type FecFailClosedEvent,
|
|
21
23
|
} from "./fec-manager.js";
|
|
22
24
|
import {
|
|
23
25
|
deriveBlockClassifierGeometry,
|
|
@@ -31,22 +33,23 @@ import {
|
|
|
31
33
|
type TrackKind,
|
|
32
34
|
} from "./block-policy.js";
|
|
33
35
|
import type {
|
|
36
|
+
RepairDeadlineBound,
|
|
34
37
|
RepairFetchHost,
|
|
35
38
|
RepairPriorityReason,
|
|
39
|
+
RepairSendMeasurement,
|
|
36
40
|
RepairSkipReason,
|
|
37
41
|
RepairSubscribeCallback,
|
|
38
42
|
} from "./repair-fetch.js";
|
|
39
43
|
import {
|
|
40
44
|
MmtpRouter,
|
|
41
45
|
type FrameCallback,
|
|
42
|
-
type ManifestIdentityResolver,
|
|
43
46
|
type MmtpIngressContext,
|
|
44
47
|
type MmtpStreamIdentity,
|
|
45
48
|
type StagedStreamSwitch,
|
|
46
49
|
type StreamSwitchCommit,
|
|
47
50
|
type TrackPacketCallback,
|
|
48
51
|
} from "./mmtp-router.js";
|
|
49
|
-
import { isMulticastTrackPacketId } from "@blockcast/mmt-transport";
|
|
52
|
+
import { isMulticastTrackPacketId, type WindowMulticastGateway } from "@blockcast/mmt-transport";
|
|
50
53
|
import {
|
|
51
54
|
MulticastTransport,
|
|
52
55
|
type MulticastFailbackReason,
|
|
@@ -64,10 +67,6 @@ import type {
|
|
|
64
67
|
} from "@blockcast/fec-worker";
|
|
65
68
|
import type { MfuReassemblerBackend } from "./mfu-reassembler.js";
|
|
66
69
|
import type { MfuReassemblyPolicy } from "./mfu-reassembly-policy.js";
|
|
67
|
-
import type {
|
|
68
|
-
ManifestObjectIdentity,
|
|
69
|
-
ManifestVerifier,
|
|
70
|
-
} from "@blockcast/mmt-manifest-verify";
|
|
71
70
|
import type {
|
|
72
71
|
BlockAssemblerConfig,
|
|
73
72
|
CmafBlockSample,
|
|
@@ -83,6 +82,37 @@ import {
|
|
|
83
82
|
} from "./carp-catalog.js";
|
|
84
83
|
import { catalogFecUnavailable, type TrackFecUnavailable } from "./catalog-fec-params.js";
|
|
85
84
|
|
|
85
|
+
/**
|
|
86
|
+
* One dedicated repair group to join beside the media join: the shape
|
|
87
|
+
* `selectRepairEndpointsForTracks` (`@blockcast/mmt-transport`) returns.
|
|
88
|
+
*/
|
|
89
|
+
export interface MulticastRepairEndpoint {
|
|
90
|
+
group: string;
|
|
91
|
+
source: string;
|
|
92
|
+
port: number;
|
|
93
|
+
mode?: string;
|
|
94
|
+
amtRelay?: string;
|
|
95
|
+
amtRelayPort?: number;
|
|
96
|
+
/** The repair packet IDs this group carries. */
|
|
97
|
+
packetIds: number[];
|
|
98
|
+
/** Each repair packet ID bound to the media packet ID it repairs. */
|
|
99
|
+
repairOwners: ReadonlyArray<{ packetId: number; ownerPacketId: number }>;
|
|
100
|
+
/** Ingress tracks: the owners' source tracks and the repair tracks. */
|
|
101
|
+
tracks: MmtpIngressContext["tracks"];
|
|
102
|
+
/** The protected flow (`MmtpRouter.registerProvenanceFlow`) this group's datagrams belong to. */
|
|
103
|
+
flow?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Opens one repair-group subscription through the caller's own provider (a
|
|
108
|
+
* hang bridge, for one): delivers each packet to `onPacket` and returns (or
|
|
109
|
+
* resolves to) the call that releases it.
|
|
110
|
+
*/
|
|
111
|
+
export type MulticastRepairSubscribe = (
|
|
112
|
+
endpoint: MulticastRepairEndpoint,
|
|
113
|
+
onPacket: (packet: Uint8Array) => void,
|
|
114
|
+
) => (() => void) | Promise<() => void>;
|
|
115
|
+
|
|
86
116
|
export interface MulticastEndpointConfig {
|
|
87
117
|
sourceAddress: string;
|
|
88
118
|
groupAddress: string;
|
|
@@ -95,6 +125,12 @@ export interface MulticastEndpointConfig {
|
|
|
95
125
|
amtRelay?: string;
|
|
96
126
|
/** AMT relay port from player/UI overrides. Wins over `relayPort`. */
|
|
97
127
|
amtRelayPort?: number;
|
|
128
|
+
/**
|
|
129
|
+
* `'driad'`: no relay is pinned; the window.multicast gateway runs RFC 8777
|
|
130
|
+
* DRIAD on `sourceAddress` and fails over across the relays it offers.
|
|
131
|
+
* Ignored when `amtRelay` is set.
|
|
132
|
+
*/
|
|
133
|
+
amtDiscovery?: 'driad';
|
|
98
134
|
/** MMTP packet IDs to forward before data enters the page transport queue. */
|
|
99
135
|
packetIds?: number[];
|
|
100
136
|
/** Exact catalog tracks carried by this physical multicast endpoint. */
|
|
@@ -151,15 +187,6 @@ export interface MulticastManagerOptions {
|
|
|
151
187
|
reassemblyPolicy?: MfuReassemblyPolicy;
|
|
152
188
|
reassembler?: MfuReassemblerBackend;
|
|
153
189
|
maxBufferedMfus?: number;
|
|
154
|
-
manifestVerifier?: ManifestVerifier;
|
|
155
|
-
manifestVerifierOwnership?: "caller" | "router";
|
|
156
|
-
resolveManifestIdentity?: (
|
|
157
|
-
packetId: number,
|
|
158
|
-
sbn: number,
|
|
159
|
-
esi: number,
|
|
160
|
-
catalogTrackName?: string,
|
|
161
|
-
) => ManifestObjectIdentity | null;
|
|
162
|
-
resolveManifestIdentityForRoute?: ManifestIdentityResolver;
|
|
163
190
|
/**
|
|
164
191
|
* Also write every repair lifecycle event to the console as one
|
|
165
192
|
* `REPAIR_LIFECYCLE_LOG_PREFIX` JSON line. Off unless asked for: the lines
|
|
@@ -297,6 +324,9 @@ interface RepairSymbolCounts {
|
|
|
297
324
|
* class.
|
|
298
325
|
* - `recovered` / `failed`: every block that could not complete from its
|
|
299
326
|
* first-arrival source symbols resolves with exactly one of these.
|
|
327
|
+
* - `repair-sent`: the scheduler admitted and sent a repair FETCH; carries
|
|
328
|
+
* the admission inputs (RTT, time left to the deadline, which term set
|
|
329
|
+
* the deadline) so a harness reads the budget instead of inferring it.
|
|
300
330
|
* - `repair-preempted` / `repair-deferred`: the scheduler aborted a delta
|
|
301
331
|
* repair for keyframe work, or never ran it before its block resolved.
|
|
302
332
|
* - `repair-priority`: the catalog could not supply the SUBSCRIBER_PRIORITY a
|
|
@@ -344,6 +374,23 @@ export type RepairLifecycleEvent =
|
|
|
344
374
|
readonly type: "repair-preempted" | "repair-deferred";
|
|
345
375
|
readonly block: RepairBlockIdentity;
|
|
346
376
|
}
|
|
377
|
+
| {
|
|
378
|
+
readonly version: 2;
|
|
379
|
+
/**
|
|
380
|
+
* The scheduler sent a FETCH (BLO-33597): every attempt, a retry or a
|
|
381
|
+
* reprioritised restart included. `budgetMs` is the time left to the
|
|
382
|
+
* deadline at send, `bound` which term set that deadline; `delayMs` and
|
|
383
|
+
* `blockAgeMs` are null for a block with no anchor.
|
|
384
|
+
*/
|
|
385
|
+
readonly type: "repair-sent";
|
|
386
|
+
readonly block: RepairBlockIdentity;
|
|
387
|
+
readonly priority: RepairPriority;
|
|
388
|
+
readonly rttMs: number;
|
|
389
|
+
readonly budgetMs: number;
|
|
390
|
+
readonly delayMs: number | null;
|
|
391
|
+
readonly blockAgeMs: number | null;
|
|
392
|
+
readonly bound: RepairDeadlineBound;
|
|
393
|
+
}
|
|
347
394
|
| {
|
|
348
395
|
readonly version: 2;
|
|
349
396
|
/**
|
|
@@ -424,6 +471,11 @@ export interface BlockPolicyStats {
|
|
|
424
471
|
repairsSkippedRttExceedsBudget: number;
|
|
425
472
|
/** `repairsSkipped` by reason: the player gave no presentation delay. */
|
|
426
473
|
repairsSkippedPresentationDelayUnavailable: number;
|
|
474
|
+
/**
|
|
475
|
+
* `repairsSkipped` by reason: a lost SS_ID in an undelimited span had no
|
|
476
|
+
* §7.5 anchor (no epoch reference, or none it could be extended from).
|
|
477
|
+
*/
|
|
478
|
+
repairsSkippedRangeNoAnchor: number;
|
|
427
479
|
/**
|
|
428
480
|
* The most recent skip: its reason, the measured RTT (null when
|
|
429
481
|
* unmeasured), the time that was left to the deadline, and the request's
|
|
@@ -438,6 +490,8 @@ export interface BlockPolicyStats {
|
|
|
438
490
|
} | null;
|
|
439
491
|
/** Repair FETCHes sent for keyframe/unknown (P0) blocks, every attempt counted. */
|
|
440
492
|
keyframeRepairFetchesSent: number;
|
|
493
|
+
/** Range repair FETCHes (draft-ramadan-moq-fec §7.5 lost SS_ID) sent, every attempt counted. */
|
|
494
|
+
rangeRepairFetchesSent: number;
|
|
441
495
|
/**
|
|
442
496
|
* Requests the keyframe late-repair budget extended past the presentation
|
|
443
497
|
* deadline (each one can hold the stream behind its block that long).
|
|
@@ -482,8 +536,10 @@ function newBlockPolicyStats(
|
|
|
482
536
|
repairsSkippedRttUnmeasured: 0,
|
|
483
537
|
repairsSkippedRttExceedsBudget: 0,
|
|
484
538
|
repairsSkippedPresentationDelayUnavailable: 0,
|
|
539
|
+
repairsSkippedRangeNoAnchor: 0,
|
|
485
540
|
lastRepairSkip: null,
|
|
486
541
|
keyframeRepairFetchesSent: 0,
|
|
542
|
+
rangeRepairFetchesSent: 0,
|
|
487
543
|
keyframeBudgetHolds: 0,
|
|
488
544
|
keyframeBudgetHoldMs: 0,
|
|
489
545
|
deltaBlocksFailed: 0,
|
|
@@ -629,6 +685,12 @@ const REPAIR_PRIORITY_REASONS: ReadonlySet<unknown> = new Set([
|
|
|
629
685
|
"repair-priority-absent",
|
|
630
686
|
"repair-priority-invalid",
|
|
631
687
|
]);
|
|
688
|
+
const REPAIR_SKIP_REASONS: ReadonlySet<unknown> = new Set([
|
|
689
|
+
"rtt-unmeasured",
|
|
690
|
+
"rtt-exceeds-budget",
|
|
691
|
+
"presentation-delay-unavailable",
|
|
692
|
+
]);
|
|
693
|
+
const REPAIR_DEADLINE_BOUNDS: ReadonlySet<unknown> = new Set(["wait", "presentation", "keyframe", "retention"]);
|
|
632
694
|
const GAP_REASONS: Readonly<Record<string, "stall" | "conceal">> = {
|
|
633
695
|
"rap-lost": "stall",
|
|
634
696
|
"rap-unknown": "stall",
|
|
@@ -661,6 +723,10 @@ function isNullableNonNegative(value: unknown): boolean {
|
|
|
661
723
|
return value === null || (typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
662
724
|
}
|
|
663
725
|
|
|
726
|
+
function isFiniteNumber(value: unknown): boolean {
|
|
727
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
728
|
+
}
|
|
729
|
+
|
|
664
730
|
/** Runtime guard for observer, DOM-event, and cross-realm consumers. */
|
|
665
731
|
export function isRepairLifecycleEvent(
|
|
666
732
|
value: unknown,
|
|
@@ -703,6 +769,40 @@ export function isRepairLifecycleEvent(
|
|
|
703
769
|
case "repair-preempted":
|
|
704
770
|
case "repair-deferred":
|
|
705
771
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
772
|
+
case "repair-sent":
|
|
773
|
+
// Admission sends only when 0 < rttMs < budgetMs.
|
|
774
|
+
return (
|
|
775
|
+
hasExactKeys(value, [
|
|
776
|
+
"version",
|
|
777
|
+
"type",
|
|
778
|
+
"block",
|
|
779
|
+
"priority",
|
|
780
|
+
"rttMs",
|
|
781
|
+
"budgetMs",
|
|
782
|
+
"delayMs",
|
|
783
|
+
"blockAgeMs",
|
|
784
|
+
"bound",
|
|
785
|
+
]) &&
|
|
786
|
+
isRepairBlockIdentity(block) &&
|
|
787
|
+
(value["priority"] === 0 || value["priority"] === 1 || value["priority"] === 2) &&
|
|
788
|
+
isFiniteNumber(value["rttMs"]) &&
|
|
789
|
+
(value["rttMs"] as number) > 0 &&
|
|
790
|
+
isFiniteNumber(value["budgetMs"]) &&
|
|
791
|
+
(value["budgetMs"] as number) > (value["rttMs"] as number) &&
|
|
792
|
+
isNullableNonNegative(value["delayMs"]) &&
|
|
793
|
+
isNullableNonNegative(value["blockAgeMs"]) &&
|
|
794
|
+
(value["delayMs"] === null) === (value["blockAgeMs"] === null) &&
|
|
795
|
+
REPAIR_DEADLINE_BOUNDS.has(value["bound"])
|
|
796
|
+
);
|
|
797
|
+
case "repair-skipped":
|
|
798
|
+
// budgetMs may be negative: the deadline can already have passed.
|
|
799
|
+
return (
|
|
800
|
+
hasExactKeys(value, ["version", "type", "block", "reason", "rttMs", "budgetMs"]) &&
|
|
801
|
+
isRepairBlockIdentity(block) &&
|
|
802
|
+
REPAIR_SKIP_REASONS.has(value["reason"]) &&
|
|
803
|
+
isNullableNonNegative(value["rttMs"]) &&
|
|
804
|
+
isFiniteNumber(value["budgetMs"])
|
|
805
|
+
);
|
|
706
806
|
case "repair-priority": {
|
|
707
807
|
const blockClass = value["blockClass"];
|
|
708
808
|
const action = value["action"];
|
|
@@ -1099,6 +1199,9 @@ export class MulticastManager {
|
|
|
1099
1199
|
readonly #router: MmtpRouter;
|
|
1100
1200
|
#hostMfuTimeoutMs: number | null;
|
|
1101
1201
|
readonly #transport: MulticastTransport<MmtpIngressContext>;
|
|
1202
|
+
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
1203
|
+
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
1204
|
+
readonly #repairReleases = new Map<() => void, MulticastRepairEndpoint["repairOwners"]>();
|
|
1102
1205
|
#reportedFecDiagnosticsFailure = false;
|
|
1103
1206
|
|
|
1104
1207
|
// ── Stream-global FEC timing reduction ──
|
|
@@ -1161,10 +1264,6 @@ export class MulticastManager {
|
|
|
1161
1264
|
reassemblyPolicy: options?.reassemblyPolicy,
|
|
1162
1265
|
reassembler: options?.reassembler,
|
|
1163
1266
|
maxBufferedMfus: options?.maxBufferedMfus,
|
|
1164
|
-
manifestVerifier: options?.manifestVerifier,
|
|
1165
|
-
manifestVerifierOwnership: options?.manifestVerifierOwnership,
|
|
1166
|
-
resolveManifestIdentity: options?.resolveManifestIdentity,
|
|
1167
|
-
resolveManifestIdentityForRoute: options?.resolveManifestIdentityForRoute,
|
|
1168
1267
|
// The router has reset its own state for the stream; reset the rest.
|
|
1169
1268
|
onPublisherRestart: (packetId, catalogTrackName) => {
|
|
1170
1269
|
this.#resetStreamOutsideRouter(packetId, catalogTrackName);
|
|
@@ -1211,7 +1310,7 @@ export class MulticastManager {
|
|
|
1211
1310
|
});
|
|
1212
1311
|
this.#hostMfuTimeoutMs = this.#router.reassembler.timeoutMs;
|
|
1213
1312
|
this.#transport = new MulticastTransport<MmtpIngressContext>((packet, ingress) => {
|
|
1214
|
-
this.#router.feedPacket(packet, "multicast",
|
|
1313
|
+
this.#router.feedPacket(packet, "multicast", ingress);
|
|
1215
1314
|
});
|
|
1216
1315
|
// Each joined subscription declares how it delivers packets. An ordered
|
|
1217
1316
|
// relay decides FEC block fate by stream order instead of the datagram
|
|
@@ -1416,7 +1515,12 @@ export class MulticastManager {
|
|
|
1416
1515
|
catalogTrackName,
|
|
1417
1516
|
);
|
|
1418
1517
|
this.#configureTrackMapper(packetId, config);
|
|
1419
|
-
|
|
1518
|
+
// A Worker for an already registered track swaps the decoder mid-stream.
|
|
1519
|
+
// Re-registering the track would reset the parser's MPU timing and drop
|
|
1520
|
+
// the rest of the GOP in flight.
|
|
1521
|
+
if (this.#router.trackKindFor(packetId) !== trackType) {
|
|
1522
|
+
this.#router.setPacketIdType(packetId, trackType);
|
|
1523
|
+
}
|
|
1420
1524
|
}
|
|
1421
1525
|
|
|
1422
1526
|
/**
|
|
@@ -1510,6 +1614,18 @@ export class MulticastManager {
|
|
|
1510
1614
|
}
|
|
1511
1615
|
}
|
|
1512
1616
|
|
|
1617
|
+
// A data unit must outlive every FEC block that can still complete it: the
|
|
1618
|
+
// release gate waits for them up to terminal retention, and a fragment
|
|
1619
|
+
// recovered after its data unit was evicted is lost.
|
|
1620
|
+
for (const [packetId, c] of this.#trackFecTiming) {
|
|
1621
|
+
if (c.deliveryWindowMs === undefined) continue;
|
|
1622
|
+
mfuTimeoutMs = Math.max(
|
|
1623
|
+
mfuTimeoutMs ?? 0,
|
|
1624
|
+
this.#fec.terminalRetentionMsForPacket(packetId) ?? 0,
|
|
1625
|
+
this.#hostMfuTimeoutMs ?? 0,
|
|
1626
|
+
);
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1513
1629
|
const failbackWindowMs =
|
|
1514
1630
|
deliveryWindowMs === undefined
|
|
1515
1631
|
? minimumFailbackWindowMs
|
|
@@ -1810,6 +1926,8 @@ export class MulticastManager {
|
|
|
1810
1926
|
setMfuTimeoutMs(ms: number): void {
|
|
1811
1927
|
this.#router.setMfuTimeoutMs(ms);
|
|
1812
1928
|
this.#hostMfuTimeoutMs = this.#router.reassembler.timeoutMs;
|
|
1929
|
+
// A FEC track's data units must still outlive its terminal retention.
|
|
1930
|
+
if (this.#trackFecTiming.size > 0) this.#applyStreamGlobalFecTiming();
|
|
1813
1931
|
}
|
|
1814
1932
|
|
|
1815
1933
|
setTrackCodec(packetId: number, codec: string) {
|
|
@@ -1978,6 +2096,7 @@ export class MulticastManager {
|
|
|
1978
2096
|
config.amtRelayPort ??
|
|
1979
2097
|
config.relayPort ??
|
|
1980
2098
|
(amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
|
|
2099
|
+
amtDiscovery: config.amtDiscovery,
|
|
1981
2100
|
packetIds: config.packetIds,
|
|
1982
2101
|
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId })),
|
|
1983
2102
|
};
|
|
@@ -1986,6 +2105,83 @@ export class MulticastManager {
|
|
|
1986
2105
|
: this.#transport.join(transportConfig, ingress);
|
|
1987
2106
|
}
|
|
1988
2107
|
|
|
2108
|
+
/**
|
|
2109
|
+
* Join the selected rung's dedicated repair groups beside the media join
|
|
2110
|
+
* (pim #3898): one subscription per endpoint, through `provider` when given
|
|
2111
|
+
* (a `window.multicast`-shaped gateway or a subscribe callback), otherwise a
|
|
2112
|
+
* new MulticastTransport on `window.multicast`. Returns the call that
|
|
2113
|
+
* releases every one of them; dispose() releases them too.
|
|
2114
|
+
*
|
|
2115
|
+
* Packets go straight to the router with the endpoint's ingress, never
|
|
2116
|
+
* through feedPacket(): repair arriving on its own group is not media
|
|
2117
|
+
* liveness, so it must not hold off the media leg's failback watchdog. The
|
|
2118
|
+
* repair roles and owners are registered here; in-band owners stay the
|
|
2119
|
+
* caller's. Joining is best effort: a group that fails to join is logged
|
|
2120
|
+
* and leaves the media join as it was.
|
|
2121
|
+
*/
|
|
2122
|
+
joinRepairEndpoints(
|
|
2123
|
+
endpoints: readonly MulticastRepairEndpoint[],
|
|
2124
|
+
provider?: WindowMulticastGateway | MulticastRepairSubscribe,
|
|
2125
|
+
): () => void {
|
|
2126
|
+
const releases: Array<() => void> = [];
|
|
2127
|
+
let released = false;
|
|
2128
|
+
const safely = (each: () => void) => {
|
|
2129
|
+
try {
|
|
2130
|
+
each();
|
|
2131
|
+
} catch (error) {
|
|
2132
|
+
console.warn("[MulticastManager] repair group release failed", error);
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners);
|
|
2136
|
+
this.#applyRepairOwners(repairOwners);
|
|
2137
|
+
for (const endpoint of endpoints) {
|
|
2138
|
+
const ingress: MmtpIngressContext = {
|
|
2139
|
+
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId }))),
|
|
2140
|
+
...(endpoint.flow === undefined ? {} : { flow: endpoint.flow }),
|
|
2141
|
+
};
|
|
2142
|
+
const onPacket = (packet: Uint8Array) => {
|
|
2143
|
+
if (!released) this.#router.feedPacket(packet, "multicast", ingress);
|
|
2144
|
+
};
|
|
2145
|
+
const fail = (error: unknown) =>
|
|
2146
|
+
console.warn(`[MulticastManager] repair group ${endpoint.group}:${endpoint.port} not joined`, error);
|
|
2147
|
+
if (typeof provider === "function") {
|
|
2148
|
+
Promise.resolve()
|
|
2149
|
+
.then(() => provider(endpoint, onPacket))
|
|
2150
|
+
.then((release) => (released ? safely(release) : releases.push(release)), fail);
|
|
2151
|
+
continue;
|
|
2152
|
+
}
|
|
2153
|
+
const transport = new MulticastTransport((packet) => onPacket(packet), { gateway: provider });
|
|
2154
|
+
releases.push(() => transport.dispose());
|
|
2155
|
+
void transport.join({
|
|
2156
|
+
sourceAddress: endpoint.source,
|
|
2157
|
+
groupAddress: endpoint.group,
|
|
2158
|
+
port: endpoint.port,
|
|
2159
|
+
mode: endpoint.mode as MulticastEndpointConfig["mode"],
|
|
2160
|
+
amtRelay: endpoint.amtRelay,
|
|
2161
|
+
amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
|
|
2162
|
+
packetIds: endpoint.packetIds,
|
|
2163
|
+
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
|
|
2164
|
+
}).then((joined) => {
|
|
2165
|
+
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
const release = () => {
|
|
2169
|
+
if (released) return;
|
|
2170
|
+
released = true;
|
|
2171
|
+
this.#repairReleases.delete(release);
|
|
2172
|
+
for (const each of releases.splice(0)) safely(each);
|
|
2173
|
+
};
|
|
2174
|
+
this.#repairReleases.set(release, repairOwners);
|
|
2175
|
+
return release;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
#applyRepairOwners(owners: MulticastRepairEndpoint["repairOwners"]): void {
|
|
2179
|
+
for (const { packetId, ownerPacketId } of owners) {
|
|
2180
|
+
this.#router.setPacketIdRole(packetId, "repair");
|
|
2181
|
+
this.#router.setRepairPacketIdOwner(packetId, ownerPacketId);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
1989
2185
|
// ---------------------------------------------------------------------------
|
|
1990
2186
|
// In-place rendition switch
|
|
1991
2187
|
// ---------------------------------------------------------------------------
|
|
@@ -2331,7 +2527,7 @@ export class MulticastManager {
|
|
|
2331
2527
|
*
|
|
2332
2528
|
* D-04: Validates completeness via validateSwitchingSet — throws if incomplete.
|
|
2333
2529
|
* D-07: Applies per-track FEC configs (base+delta get decoders; repair does not).
|
|
2334
|
-
* D-17: Builds altGroup → track-name index for getSwitchingSet().
|
|
2530
|
+
* D-17: Builds altGroup → track-name index for getSwitchingSet() (repair legs excluded).
|
|
2335
2531
|
* D-26: Registers packetId → TrackRole on MmtpRouter for block-complete fanout.
|
|
2336
2532
|
*
|
|
2337
2533
|
* FEC availability is per track (draft-ramadan-moq-fec §5.1). A media track
|
|
@@ -2411,11 +2607,9 @@ export class MulticastManager {
|
|
|
2411
2607
|
}
|
|
2412
2608
|
}
|
|
2413
2609
|
const repairOwnerGroup = new Map<string, string>();
|
|
2414
|
-
const repairOwnerAltGroup = new Map<string, number | undefined>();
|
|
2415
2610
|
for (const track of catalog.tracks) {
|
|
2416
2611
|
for (const repairName of repairNamesBySource.get(track.name) ?? []) {
|
|
2417
2612
|
repairOwnerGroup.set(repairName, altGroupKey(track));
|
|
2418
|
-
repairOwnerAltGroup.set(repairName, track.altGroup);
|
|
2419
2613
|
}
|
|
2420
2614
|
}
|
|
2421
2615
|
const groupKeyFor = (track: MultiTrackCatalogTrack): string =>
|
|
@@ -2458,11 +2652,9 @@ export class MulticastManager {
|
|
|
2458
2652
|
if (!(hasSwitchingSetByGroup.get(groupKey) ?? false)) continue;
|
|
2459
2653
|
|
|
2460
2654
|
const presentRoles = new Set(roles.filter((r) => r !== "single"));
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
"repair",
|
|
2465
|
-
];
|
|
2655
|
+
// Delta is optional (BLO-49199): base is the self-decodable leg and a
|
|
2656
|
+
// base-only group plays in base-only mode; delta without base cannot.
|
|
2657
|
+
const required: Array<"base" | "repair"> = ["base", "repair"];
|
|
2466
2658
|
const missing = required.filter((r) => !presentRoles.has(r));
|
|
2467
2659
|
if (missing.length > 0) {
|
|
2468
2660
|
throw new Error(
|
|
@@ -2517,6 +2709,9 @@ export class MulticastManager {
|
|
|
2517
2709
|
this.#switchingSets.clear();
|
|
2518
2710
|
this.#repairPacketIds.clear();
|
|
2519
2711
|
this.#router.clearRepairPacketIdOwners();
|
|
2712
|
+
// Dedicated repair groups joined beside the media join outlive a catalog
|
|
2713
|
+
// refresh; their owners are not this catalog's to drop.
|
|
2714
|
+
for (const owners of this.#repairReleases.values()) this.#applyRepairOwners(owners);
|
|
2520
2715
|
// FEC a previous call configured that this one does not (the source is
|
|
2521
2716
|
// gone, lost its `fec`, or its FEC is now unavailable) must not stay
|
|
2522
2717
|
// installed: its symbols would still be read as block coordinates and
|
|
@@ -2547,15 +2742,13 @@ export class MulticastManager {
|
|
|
2547
2742
|
const track = catalog.tracks[i]!;
|
|
2548
2743
|
const role = resolvedRoles[i]!;
|
|
2549
2744
|
|
|
2550
|
-
// D-17: Build altGroup → track-name index.
|
|
2551
|
-
//
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
if (altGroup !== undefined) {
|
|
2556
|
-
const existing = this.#switchingSets.get(altGroup) ?? [];
|
|
2745
|
+
// D-17: Build altGroup → track-name index. Members are the tracks that
|
|
2746
|
+
// carry equal altGroup; a repair leg is in no switching set, whatever it
|
|
2747
|
+
// declares (draft-ramadan-moq-mmt-01 Switching Sets).
|
|
2748
|
+
if (role !== "repair" && track.altGroup !== undefined) {
|
|
2749
|
+
const existing = this.#switchingSets.get(track.altGroup) ?? [];
|
|
2557
2750
|
existing.push(track.name);
|
|
2558
|
-
this.#switchingSets.set(altGroup, existing);
|
|
2751
|
+
this.#switchingSets.set(track.altGroup, existing);
|
|
2559
2752
|
}
|
|
2560
2753
|
|
|
2561
2754
|
// D-26: Register packetId → role on MmtpRouter (if packetId provided at ingest time).
|
|
@@ -2649,7 +2842,7 @@ export class MulticastManager {
|
|
|
2649
2842
|
|
|
2650
2843
|
/**
|
|
2651
2844
|
* Return the track names belonging to the given altGroup switching set.
|
|
2652
|
-
* D-17:
|
|
2845
|
+
* D-17: tracks with equal altGroup form one switching set; repair legs are in none.
|
|
2653
2846
|
*
|
|
2654
2847
|
* @param altGroup - The altGroup number to look up.
|
|
2655
2848
|
* @returns Array of track names in that switching set (empty if none).
|
|
@@ -2679,6 +2872,29 @@ export class MulticastManager {
|
|
|
2679
2872
|
};
|
|
2680
2873
|
}
|
|
2681
2874
|
|
|
2875
|
+
/**
|
|
2876
|
+
* Register the range repair scheduler (draft-ramadan-moq-fec §7.5): from now
|
|
2877
|
+
* on an iso-ssbg1-v1 gap missing a source and every repair is kept as a
|
|
2878
|
+
* pending hole and reported here, and `closeIsoHoles` must be called for it
|
|
2879
|
+
* once its range FETCH ends (or none is sent).
|
|
2880
|
+
*/
|
|
2881
|
+
onUndelimitedLoss(cb: (loss: UndelimitedIsoLoss) => void): void {
|
|
2882
|
+
this.#fec.setUndelimitedLossHandler(cb);
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2885
|
+
/**
|
|
2886
|
+
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), e.g.
|
|
2887
|
+
* to CmcdProducer.updateFecFailClosed.
|
|
2888
|
+
*/
|
|
2889
|
+
onFecFailClosed(cb: (event: FecFailClosedEvent) => void): void {
|
|
2890
|
+
this.#fec.setFecFailClosedHandler(cb);
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
/** End a pending hole's range repair: feed what no repair stated as spans. */
|
|
2894
|
+
closeIsoHoles(packetId: number, catalogTrackName: string | undefined, start: number, length: number): void {
|
|
2895
|
+
this.#router.closeIsoHoles(packetId, catalogTrackName, start, length);
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2682
2898
|
/**
|
|
2683
2899
|
* Record a repair request whose SUBSCRIBER_PRIORITY the catalog could not
|
|
2684
2900
|
* supply (draft-ramadan-moq-fec §11.4.5): sent without the parameter, or
|
|
@@ -2714,6 +2930,7 @@ export class MulticastManager {
|
|
|
2714
2930
|
stats.repairsSkipped++;
|
|
2715
2931
|
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
2716
2932
|
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
2933
|
+
else if (reason === "range-no-anchor") stats.repairsSkippedRangeNoAnchor++;
|
|
2717
2934
|
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
2718
2935
|
stats.lastRepairSkip = {
|
|
2719
2936
|
reason,
|
|
@@ -2755,11 +2972,24 @@ export class MulticastManager {
|
|
|
2755
2972
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
2756
2973
|
noteRepairFetchSent(
|
|
2757
2974
|
priority: RepairPriority,
|
|
2758
|
-
|
|
2975
|
+
sbn: number,
|
|
2759
2976
|
packetId: number,
|
|
2760
|
-
catalogTrackName
|
|
2977
|
+
catalogTrackName: string | undefined,
|
|
2978
|
+
measurement: RepairSendMeasurement,
|
|
2761
2979
|
): void {
|
|
2762
2980
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
2981
|
+
if (measurement.range) this.#statsFor(packetId, catalogTrackName).rangeRepairFetchesSent++;
|
|
2982
|
+
this.#emitRepairLifecycle({
|
|
2983
|
+
version: 2,
|
|
2984
|
+
type: "repair-sent",
|
|
2985
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
2986
|
+
priority,
|
|
2987
|
+
rttMs: measurement.rttMs,
|
|
2988
|
+
budgetMs: measurement.budgetMs,
|
|
2989
|
+
delayMs: measurement.delayMs,
|
|
2990
|
+
blockAgeMs: measurement.blockAgeMs,
|
|
2991
|
+
bound: measurement.bound,
|
|
2992
|
+
});
|
|
2763
2993
|
}
|
|
2764
2994
|
|
|
2765
2995
|
/**
|
|
@@ -2951,6 +3181,7 @@ export class MulticastManager {
|
|
|
2951
3181
|
this.#trackResetObservers.clear();
|
|
2952
3182
|
this.#repairLifecycleObservers.clear();
|
|
2953
3183
|
this.#transport.dispose();
|
|
3184
|
+
for (const release of [...this.#repairReleases.keys()]) release();
|
|
2954
3185
|
this.#router.dispose();
|
|
2955
3186
|
this.#fec.dispose();
|
|
2956
3187
|
}
|
|
@@ -25,8 +25,12 @@ export interface MulticastTransportConfig {
|
|
|
25
25
|
mode?: 'auto' | 'native' | 'tunnel'
|
|
26
26
|
amtRelay?: string
|
|
27
27
|
amtRelayPort?: number
|
|
28
|
+
/** `'driad'`: with no relay, the gateway discovers one per RFC 8777. */
|
|
29
|
+
amtDiscovery?: 'driad'
|
|
28
30
|
packetIds?: number[]
|
|
29
31
|
tracks?: { name: string; packetId: number }[]
|
|
32
|
+
/** ATSC 3.0 tuning (`catalogAtsc3NetworkSource`); when set the join is the tuner. */
|
|
33
|
+
atsc3?: { frequency: number; plpId?: number; serviceId?: number }
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export type ResolvedMulticastTransport = 'native' | 'amt'
|
|
@@ -330,8 +334,15 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
330
334
|
readonly #unadvertisedPacketIds = new Set<number>()
|
|
331
335
|
#joinGeneration = 0
|
|
332
336
|
|
|
333
|
-
|
|
337
|
+
// The provider to subscribe through; window.multicast when unset.
|
|
338
|
+
readonly #gateway: WindowMulticastGateway | undefined
|
|
339
|
+
|
|
340
|
+
constructor(
|
|
341
|
+
onPacket: (packet: Uint8Array, context?: TPacketContext) => void,
|
|
342
|
+
options: { gateway?: WindowMulticastGateway } = {},
|
|
343
|
+
) {
|
|
334
344
|
this.#onPacket = onPacket
|
|
345
|
+
this.#gateway = options.gateway
|
|
335
346
|
}
|
|
336
347
|
|
|
337
348
|
static isAvailable(): boolean {
|
|
@@ -344,7 +355,8 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
344
355
|
this.#dataPlaneLive = false
|
|
345
356
|
|
|
346
357
|
if (this.#disposed) return this.#declined(generation, 'disposed')
|
|
347
|
-
|
|
358
|
+
const gateway = this.#gateway ?? getMulticastGlobals().multicast
|
|
359
|
+
if (typeof gateway?.subscribe !== 'function') {
|
|
348
360
|
console.warn('[MulticastTransport] Multicast API not available')
|
|
349
361
|
return this.#declined(generation, 'unavailable')
|
|
350
362
|
}
|
|
@@ -365,11 +377,13 @@ export class MulticastTransport<TPacketContext = never> {
|
|
|
365
377
|
mode: config.mode,
|
|
366
378
|
amtRelay: config.amtRelay,
|
|
367
379
|
amtRelayPort: config.amtRelayPort,
|
|
380
|
+
amtDiscovery: config.amtDiscovery,
|
|
368
381
|
packetIds: config.packetIds,
|
|
369
382
|
tracks: config.tracks,
|
|
383
|
+
atsc3: config.atsc3,
|
|
370
384
|
})
|
|
371
385
|
failure = 'provider-rejected'
|
|
372
|
-
const subscription = await
|
|
386
|
+
const subscription = await gateway.subscribe(subscribeConfig)
|
|
373
387
|
failure = 'invalid-subscription'
|
|
374
388
|
console.log(`[MulticastTransport] window.multicast.subscribe returned:`, !!subscription)
|
|
375
389
|
|
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
|
);
|