@blockcast/mmt-container 2.2.0-main.e1bebe787bc9 → 2.2.0-main.ea9223dc11de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block-policy.d.ts +33 -3
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +60 -24
- package/dist/block-policy.js.map +3 -3
- package/dist/browser-runtime.js +1034 -126
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +40 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +163 -10
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +34 -0
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.js +34 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/datagram-leg-deadline.d.ts +138 -0
- package/dist/datagram-leg-deadline.d.ts.map +1 -0
- package/dist/datagram-leg-deadline.js +229 -0
- package/dist/datagram-leg-deadline.js.map +7 -0
- package/dist/delivery-catalog.js +68 -0
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/delta-fallback-config.js +34 -0
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +117 -13
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +358 -42
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +17 -5
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +36 -0
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.js +34 -0
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/held-layer-admission.js +34 -0
- package/dist/held-layer-admission.js.map +3 -3
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +16 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +62 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +34 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +6 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +34 -0
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +167 -13
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +34 -0
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-fec-session.js +34 -0
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-mode-selection.d.ts +48 -0
- package/dist/mmtp-mode-selection.d.ts.map +1 -0
- package/dist/mmtp-mode-selection.js +79 -0
- package/dist/mmtp-mode-selection.js.map +7 -0
- package/dist/mmtp-router.d.ts +66 -10
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +204 -30
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-auth-catalog.js +42 -2
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.js +42 -2
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +95 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +613 -92
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +68 -0
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +34 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +167 -13
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +2 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +69 -2
- package/dist/phase14-catalog-override.js.map +3 -3
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +50 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layer-subscriptions.js +34 -0
- package/dist/repair-layer-subscriptions.js.map +3 -3
- package/dist/signaling.js +34 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +34 -0
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +34 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +34 -0
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/schemas/catalog.schema.json +2 -2
- package/src/block-policy.ts +108 -31
- package/src/carp-catalog.ts +165 -5
- package/src/datagram-leg-deadline.ts +370 -0
- package/src/fec-manager.ts +345 -33
- package/src/fec-state.ts +21 -5
- package/src/index.ts +37 -0
- package/src/iso-block-locator.ts +34 -0
- package/src/mmtp-container-parser.ts +6 -4
- package/src/mmtp-mode-selection.ts +80 -0
- package/src/mmtp-router.ts +226 -45
- package/src/multicast-manager.ts +126 -0
- package/src/phase14-catalog-override.ts +14 -3
- package/src/repair-fetch.ts +23 -0
- package/test-vectors/catalog/README.md +36 -2
- package/test-vectors/catalog/mmtp-siblings/ambiguous-sibling.json +158 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-bitrate-only.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-four-rungs.json +405 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-other-names.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/mmtp-mode-unknown.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/multicast-endpoint-lists-datagram-track.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/no-sibling.json +79 -0
- package/test-vectors/catalog/mmtp-siblings/rendition-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/stream-delivery-mode.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/timescale-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/valid-pair.json +142 -0
- package/test-vectors/catalog/section-codes.json +3 -3
- package/test-vectors/catalog-timing.json +742 -1
- package/test-vectors/catalog-validation.json +266 -7
- package/test-vectors/moq/mmtp-mode-selection.json +259 -0
package/src/fec-state.ts
CHANGED
|
@@ -18,7 +18,11 @@ import { resolveFecBindings } from '@blockcast/mmt-base'
|
|
|
18
18
|
/** Smallest positive catalog elapsed span; zero/absence means no elapsed deadline. */
|
|
19
19
|
export const MIN_INTERLEAVE_DEPTH_MS = 1
|
|
20
20
|
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Why FEC is not protecting this session. An "mfu-datagram" subscription
|
|
23
|
+
* (draft-ramadan-moq-mmt-02 4.3.1) is a lossy unicast leg: once joined, FEC
|
|
24
|
+
* is active whatever the transport policy or bridge says.
|
|
25
|
+
*/
|
|
22
26
|
export type FecInactiveReason = 'no-catalog-fec' | 'reliable-moq' | 'no-multicast-bridge'
|
|
23
27
|
|
|
24
28
|
/** Every inactive reason, in resolution order. */
|
|
@@ -78,6 +82,12 @@ export interface FecStateEvidence<S extends object> {
|
|
|
78
82
|
* it and it has not been closed. A requested leg is not a joined one.
|
|
79
83
|
*/
|
|
80
84
|
readonly multicastLegJoined: boolean
|
|
85
|
+
/**
|
|
86
|
+
* Whether an "mfu-datagram" subscription is live (SUBSCRIBE_OK received,
|
|
87
|
+
* not ended): a lossy unicast leg that needs no bridge and runs under
|
|
88
|
+
* `moq-only`. Never counted as `multicastLegJoined`. Absent reads false.
|
|
89
|
+
*/
|
|
90
|
+
readonly datagramLegJoined?: boolean
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
const INACTIVE: Readonly<Record<FecInactiveReason, FecInactiveState>> = Object.freeze({
|
|
@@ -115,16 +125,18 @@ function requireBoolean(value: unknown, field: string): boolean {
|
|
|
115
125
|
* 1. The catalog declares no FEC for a selected track: `no-catalog-fec`. FEC
|
|
116
126
|
* geometry comes only from the catalog, so there is nothing to configure on
|
|
117
127
|
* any path.
|
|
118
|
-
* 2.
|
|
128
|
+
* 2. An "mfu-datagram" leg is joined: active. Its datagrams are lossy
|
|
129
|
+
* unicast, whatever the policy or the bridge (mmt-02 4.3.1).
|
|
130
|
+
* 3. The policy is `moq-only`: `reliable-moq`. Media travels only over QUIC,
|
|
119
131
|
* which is reliable, so FEC has no loss to repair, bridge or not.
|
|
120
|
-
*
|
|
132
|
+
* 4. No multicast bridge: `no-multicast-bridge`. No lossy leg can exist, and on
|
|
121
133
|
* `auto` this is the reason the session is on reliable MoQ.
|
|
122
|
-
*
|
|
134
|
+
* 5. The policy is `multicast-only`, or a lossy subscription is live: active.
|
|
123
135
|
* `multicast-only` commits the session to the lossy leg, so FEC is in force
|
|
124
136
|
* before the join completes; whether the join succeeded is the physical
|
|
125
137
|
* attestation's question, not this one. The counters may be absent until
|
|
126
138
|
* the decoder reports.
|
|
127
|
-
*
|
|
139
|
+
* 6. Otherwise (`auto`, a bridge, no live subscription): `reliable-moq`.
|
|
128
140
|
*
|
|
129
141
|
* Throws on malformed evidence rather than picking a reason for it.
|
|
130
142
|
*/
|
|
@@ -134,6 +146,9 @@ export function resolveFecState<S extends object>(evidence: FecStateEvidence<S>)
|
|
|
134
146
|
const catalogFec = requireBoolean(evidence.catalogFec, 'catalogFec')
|
|
135
147
|
const bridgeAvailable = requireBoolean(evidence.bridgeAvailable, 'bridgeAvailable')
|
|
136
148
|
const multicastLegJoined = requireBoolean(evidence.multicastLegJoined, 'multicastLegJoined')
|
|
149
|
+
const datagramLegJoined = evidence.datagramLegJoined === undefined
|
|
150
|
+
? false
|
|
151
|
+
: requireBoolean(evidence.datagramLegJoined, 'datagramLegJoined')
|
|
137
152
|
const { transportPolicy, stats } = evidence
|
|
138
153
|
if (typeof transportPolicy !== 'string' || !TRANSPORT_POLICIES.has(transportPolicy)) {
|
|
139
154
|
throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`)
|
|
@@ -143,6 +158,7 @@ export function resolveFecState<S extends object>(evidence: FecStateEvidence<S>)
|
|
|
143
158
|
}
|
|
144
159
|
|
|
145
160
|
if (!catalogFec) return INACTIVE['no-catalog-fec']
|
|
161
|
+
if (datagramLegJoined) return { ...(stats ?? {}), state: 'active' } as FecActiveState<S | NoFecCounters>
|
|
146
162
|
if (transportPolicy === 'moq-only') return INACTIVE['reliable-moq']
|
|
147
163
|
if (!bridgeAvailable) return INACTIVE['no-multicast-bridge']
|
|
148
164
|
if (transportPolicy === 'multicast-only' || multicastLegJoined) {
|
package/src/index.ts
CHANGED
|
@@ -140,6 +140,9 @@ export {
|
|
|
140
140
|
type CmsfCatalogErrorCode,
|
|
141
141
|
CmsfCatalogValidationError,
|
|
142
142
|
validateCmsfMmtpCatalog,
|
|
143
|
+
type MmtpTrackIssue,
|
|
144
|
+
type MmtpTrackIssueCode,
|
|
145
|
+
mmtpTrackIssues,
|
|
143
146
|
type ArchiveConfig,
|
|
144
147
|
archiveOrigin,
|
|
145
148
|
} from './carp-catalog.js'
|
|
@@ -258,6 +261,10 @@ export {
|
|
|
258
261
|
type FecFallbackDecoder,
|
|
259
262
|
type WasmFecDecoder,
|
|
260
263
|
type FecStats,
|
|
264
|
+
type FecSymbolSource,
|
|
265
|
+
type DeliveryGapPath,
|
|
266
|
+
type UnresolvedRepairOwnerDrops,
|
|
267
|
+
type UnresolvedRepairOwnerReason,
|
|
261
268
|
type MulticastSymbolDelivery,
|
|
262
269
|
type UndelimitedIsoLoss,
|
|
263
270
|
type ExpiredIsoHole,
|
|
@@ -275,6 +282,7 @@ export {
|
|
|
275
282
|
KEYFRAME_LOST_TIMEOUT_SLACK,
|
|
276
283
|
type FrameCallback,
|
|
277
284
|
type FECManagerLike,
|
|
285
|
+
type MmtpIngestSource,
|
|
278
286
|
type MmtpIngressContext,
|
|
279
287
|
type KeyframeOverlayLeg,
|
|
280
288
|
type KeyframeOverlayFec,
|
|
@@ -351,6 +359,8 @@ export {
|
|
|
351
359
|
REPAIR_LIFECYCLE_EVENT_TYPE,
|
|
352
360
|
REPAIR_LIFECYCLE_LOG_PREFIX,
|
|
353
361
|
type MulticastEndpointConfig,
|
|
362
|
+
type DatagramLegDiagnostics,
|
|
363
|
+
type DatagramLegPlayerCounters,
|
|
354
364
|
type MultiTrackCatalog,
|
|
355
365
|
type MultiTrackCatalogTrack,
|
|
356
366
|
type WasmFecDecoderFactory,
|
|
@@ -603,6 +613,33 @@ export {
|
|
|
603
613
|
type NoFecCounters,
|
|
604
614
|
} from "./fec-state.js";
|
|
605
615
|
|
|
616
|
+
// Which mmtp sibling to subscribe (mmt-02 4.3.1), one implementation for every
|
|
617
|
+
// player; vectors in test-vectors/moq/mmtp-mode-selection.json.
|
|
618
|
+
export {
|
|
619
|
+
selectMmtpMode,
|
|
620
|
+
type MmtpModeChoice,
|
|
621
|
+
type MmtpModeOverride,
|
|
622
|
+
type MmtpModeReason,
|
|
623
|
+
type MmtpModeSelection,
|
|
624
|
+
type MmtpModeSelectionInput,
|
|
625
|
+
} from "./mmtp-mode-selection.js";
|
|
626
|
+
|
|
627
|
+
// When an "mfu-datagram" leg is taken and when it is handed back (mmt-02
|
|
628
|
+
// 4.3.1): the delay target and the catalog FEC window, no constant. One
|
|
629
|
+
// implementation for every player; vectors in test-vectors/catalog-timing.json.
|
|
630
|
+
export {
|
|
631
|
+
computeDatagramLegDeadlines,
|
|
632
|
+
DatagramLegWatch,
|
|
633
|
+
datagramLegRetryDelayMs,
|
|
634
|
+
type DatagramLegDeadlineInput,
|
|
635
|
+
type DatagramLegDeadlineReason,
|
|
636
|
+
type DatagramLegDeadlines,
|
|
637
|
+
type DatagramLegFecInstance,
|
|
638
|
+
type DatagramLegLimits,
|
|
639
|
+
type DatagramLegVerdict,
|
|
640
|
+
type DatagramLegWatchOptions,
|
|
641
|
+
} from "./datagram-leg-deadline.js";
|
|
642
|
+
|
|
606
643
|
// In-band AL-FEC for one MMTP asset over a MoQT subscription, for a player
|
|
607
644
|
// that owns its own parser (the Shaka MSF MMTP packaging).
|
|
608
645
|
export {
|
package/src/iso-block-locator.ts
CHANGED
|
@@ -303,6 +303,40 @@ export class IsoBlockLocator<T> {
|
|
|
303
303
|
return this.#held.has(ssId)
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/** The payload held unplaced for `ssId`, if any. */
|
|
307
|
+
heldSource(ssId: number): T | undefined {
|
|
308
|
+
return this.#held.get(ssId)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The SS_IDs strictly between `a` and `b` that no repair has delimited a
|
|
313
|
+
* block of yet: those from the coverage end on, or all of them before the
|
|
314
|
+
* first repair. `missing` is the highest of them no source is held for;
|
|
315
|
+
* absent, every one of them arrived (C.5.2: SS_IDs are consecutive). Null
|
|
316
|
+
* when none lies past coverage. `flagged` is whether a source held among
|
|
317
|
+
* them satisfies `flag` (a RAP fragment, say): the held packets read as
|
|
318
|
+
* fec-multicast-00 Block Classification item 1 reads bounding packets.
|
|
319
|
+
*/
|
|
320
|
+
undelimitedBetween(
|
|
321
|
+
a: number,
|
|
322
|
+
b: number,
|
|
323
|
+
flag?: (payload: T) => boolean,
|
|
324
|
+
): { start: number; missing?: number; flagged: boolean } | null {
|
|
325
|
+
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return null
|
|
326
|
+
const first = (a + 1) >>> 0
|
|
327
|
+
const end = this.#coverageEnd
|
|
328
|
+
const start = end !== undefined && serial32Precedes(first, end) ? end : first
|
|
329
|
+
if (!serial32Precedes(start, b)) return null
|
|
330
|
+
const length = serial32Distance(start, b)
|
|
331
|
+
const missing = this.#highestMissing(start, length)
|
|
332
|
+
let flagged = false
|
|
333
|
+
for (let i = 0; flag !== undefined && !flagged && i < length; i++) {
|
|
334
|
+
const payload = this.#held.get(serial32Add(start, i))
|
|
335
|
+
flagged = payload !== undefined && flag(payload)
|
|
336
|
+
}
|
|
337
|
+
return missing === undefined ? { start, flagged } : { start, missing, flagged }
|
|
338
|
+
}
|
|
339
|
+
|
|
306
340
|
/**
|
|
307
341
|
* Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
|
|
308
342
|
* block states its range and places every held source in it; later repair
|
|
@@ -242,13 +242,15 @@ export interface FecReleaseGate {
|
|
|
242
242
|
* it: the late-symbol allowance when the gap holds no RAP that overlay
|
|
243
243
|
* could rebuild, else as long as its repair may still come. Undefined
|
|
244
244
|
* while another repair may still fill the gap, or the overlay's repair
|
|
245
|
-
* may come at any time.
|
|
246
|
-
*
|
|
247
|
-
*
|
|
245
|
+
* may come at any time. Behind a run no repair has delimited, until the
|
|
246
|
+
* run's FEC deadline, since a repair may delimit it until then.
|
|
247
|
+
* `fromSbn` is the anchor of the frame released before the gap, `toSbn`
|
|
248
|
+
* this frame's, `after.arrivedAtMs` its arrival (performance.now()). Past
|
|
249
|
+
* the wait the frame goes, decided, as it would once those blocks failed.
|
|
248
250
|
*/
|
|
249
251
|
unrepairableWaitMs?(
|
|
250
252
|
before: { data: Uint8Array; meta: FrameMeta },
|
|
251
|
-
after: { data: Uint8Array; meta: FrameMeta },
|
|
253
|
+
after: { data: Uint8Array; meta: FrameMeta; arrivedAtMs?: number },
|
|
252
254
|
fromSbn: number,
|
|
253
255
|
toSbn: number,
|
|
254
256
|
): number | undefined
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Which mmtp sibling a player subscribes (draft-ramadan-moq-mmt-02 4.3.1):
|
|
2
|
+
// the "mfu" track on a reliable path, the "mfu-datagram" track on an
|
|
3
|
+
// unreliable session that can carry its repair objects. One implementation
|
|
4
|
+
// for every player, with shared vectors in
|
|
5
|
+
// test-vectors/moq/mmtp-mode-selection.json, so the A/B knob and the
|
|
6
|
+
// fallback rules cannot drift between them.
|
|
7
|
+
|
|
8
|
+
import { datagramLegObjectMax } from '@blockcast/mmt-base'
|
|
9
|
+
import type { FecTransportPolicy } from './fec-state.js'
|
|
10
|
+
|
|
11
|
+
export type MmtpModeChoice = 'mfu' | 'mfu-datagram'
|
|
12
|
+
|
|
13
|
+
/** The player override: moqtail URL `mmtpMode=`, hang attribute `mmtp-mode`. */
|
|
14
|
+
export type MmtpModeOverride = 'auto' | MmtpModeChoice
|
|
15
|
+
|
|
16
|
+
export type MmtpModeReason =
|
|
17
|
+
/** `multicast-only` subscribes no unicast media; "mfu" for the record. */
|
|
18
|
+
| 'multicast-only'
|
|
19
|
+
/** The override named the mode. */
|
|
20
|
+
| 'override'
|
|
21
|
+
/** The override asked for "mfu-datagram" on a reliable session (HTTP/2 WebTransport, WebSocket): refused, "mfu". */
|
|
22
|
+
| 'override-refused-reliable'
|
|
23
|
+
/** The datagram track binds no FEC instance the player decodes: its leg would lose and never recover. */
|
|
24
|
+
| 'datagram-fec-undecodable'
|
|
25
|
+
/** The catalog pairs no "mfu-datagram" track with the selected rendition: "mfu", the `mfu-datagram` override included. */
|
|
26
|
+
| 'no-datagram-sibling'
|
|
27
|
+
/** The session is reliable: datagrams would be streams, and a lost one blocks everything. */
|
|
28
|
+
| 'reliable-session'
|
|
29
|
+
/** The session's maximum datagram size cannot carry the track's repair objects. */
|
|
30
|
+
| 'repair-object-too-large'
|
|
31
|
+
/** An unreliable session with room: the datagram leg. */
|
|
32
|
+
| 'datagram'
|
|
33
|
+
|
|
34
|
+
export interface MmtpModeSelectionInput {
|
|
35
|
+
/** The catalog pairs an "mfu-datagram" track with the selected "mfu" track (`pairMmtpSiblings`). */
|
|
36
|
+
readonly datagramSibling: boolean
|
|
37
|
+
/** `WebTransport.reliability === 'supports-unreliable'`; false on HTTP/2, WebSocket, or when unknown (fail closed). */
|
|
38
|
+
readonly unreliable: boolean
|
|
39
|
+
/** `WebTransport.datagrams.maxDatagramSize` of the live session, when known. */
|
|
40
|
+
readonly maxDatagramSize?: number
|
|
41
|
+
/** The datagram track's `fec.symbolSize` T, when known: its repair object is the leg's largest. */
|
|
42
|
+
readonly symbolSize?: number
|
|
43
|
+
/**
|
|
44
|
+
* Whether the datagram track's `fec` binds an instance the player decodes,
|
|
45
|
+
* by the player's own resolver (a bound base instance under a block profile
|
|
46
|
+
* it implements). `false` takes "mfu", the override included: FEC and the
|
|
47
|
+
* release gate are the leg's only loss handling (4.3.1), so without them it
|
|
48
|
+
* drops what the "mfu" track delivers. Absent: not stated, never read.
|
|
49
|
+
*/
|
|
50
|
+
readonly datagramFecDecodable?: boolean
|
|
51
|
+
readonly transportPolicy: FecTransportPolicy
|
|
52
|
+
readonly override: MmtpModeOverride
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface MmtpModeSelection {
|
|
56
|
+
readonly mode: MmtpModeChoice
|
|
57
|
+
readonly reason: MmtpModeReason
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** First rule that applies wins; pure, never throws. */
|
|
61
|
+
export function selectMmtpMode(input: MmtpModeSelectionInput): MmtpModeSelection {
|
|
62
|
+
if (input.transportPolicy === 'multicast-only') return { mode: 'mfu', reason: 'multicast-only' }
|
|
63
|
+
if (input.override === 'mfu') return { mode: 'mfu', reason: 'override' }
|
|
64
|
+
// Before the override: it cannot name a track the catalog does not pair.
|
|
65
|
+
if (!input.datagramSibling) return { mode: 'mfu', reason: 'no-datagram-sibling' }
|
|
66
|
+
if (input.datagramFecDecodable === false) return { mode: 'mfu', reason: 'datagram-fec-undecodable' }
|
|
67
|
+
if (input.override === 'mfu-datagram') {
|
|
68
|
+
return input.unreliable
|
|
69
|
+
? { mode: 'mfu-datagram', reason: 'override' }
|
|
70
|
+
: { mode: 'mfu', reason: 'override-refused-reliable' }
|
|
71
|
+
}
|
|
72
|
+
if (!input.unreliable) return { mode: 'mfu', reason: 'reliable-session' }
|
|
73
|
+
if (
|
|
74
|
+
input.maxDatagramSize !== undefined && input.symbolSize !== undefined &&
|
|
75
|
+
input.maxDatagramSize < datagramLegObjectMax(input.symbolSize)
|
|
76
|
+
) {
|
|
77
|
+
return { mode: 'mfu', reason: 'repair-object-too-large' }
|
|
78
|
+
}
|
|
79
|
+
return { mode: 'mfu-datagram', reason: 'datagram' }
|
|
80
|
+
}
|