@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/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,34 @@ 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
|
+
/**
|
|
399
|
+
* Which term set a FETCH's deadline (BLO-33597): the multicast wait, the
|
|
400
|
+
* player's presentation delay past the block anchor, the keyframe budget past
|
|
401
|
+
* the anchor (when it granted more than the presentation delay), or the
|
|
402
|
+
* release gate's retention ceiling.
|
|
403
|
+
*/
|
|
404
|
+
export type RepairDeadlineBound = 'wait' | 'presentation' | 'keyframe' | 'retention'
|
|
405
|
+
|
|
406
|
+
/** The admission inputs of a FETCH the scheduler sent (BLO-33597). */
|
|
407
|
+
export interface RepairSendMeasurement {
|
|
408
|
+
/** The reliable-path RTT admission compared against `budgetMs`. */
|
|
409
|
+
readonly rttMs: number
|
|
410
|
+
/** Time left to the entry's deadline when the FETCH was sent. */
|
|
411
|
+
readonly budgetMs: number
|
|
412
|
+
/**
|
|
413
|
+
* Delay past the block anchor the deadline was computed from; null when
|
|
414
|
+
* the block had no anchor (its deadline is then the multicast wait).
|
|
415
|
+
*/
|
|
416
|
+
readonly delayMs: number | null
|
|
417
|
+
/** Time since the block anchor; null when the block had no anchor. */
|
|
418
|
+
readonly blockAgeMs: number | null
|
|
419
|
+
readonly bound: RepairDeadlineBound
|
|
420
|
+
/** True for a range repair FETCH (§7.5 lost SS_ID); absent for a block FETCH. */
|
|
421
|
+
readonly range?: true
|
|
422
|
+
}
|
|
348
423
|
|
|
349
424
|
/** The subset of MulticastManager the scheduler drives. */
|
|
350
425
|
export interface RepairFetchHost {
|
|
@@ -396,6 +471,10 @@ export interface RepairFetchHost {
|
|
|
396
471
|
): void
|
|
397
472
|
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void
|
|
398
473
|
addTrackResetObserver(observer: (packetId: number, catalogTrackName: string) => void): () => void
|
|
474
|
+
/** Register for lost SS_IDs in undelimited spans (required with `rangeTransport`). */
|
|
475
|
+
onUndelimitedLoss?(cb: (loss: UndelimitedIsoLoss) => void): void
|
|
476
|
+
/** A hole's range repair ended, or none is sent: feed what was not stated. */
|
|
477
|
+
closeIsoHoles?(packetId: number, catalogTrackName: string | undefined, start: number, length: number): void
|
|
399
478
|
clearRepairForBlock(sbn: number, packetId: number, catalogTrackName?: string): void
|
|
400
479
|
processRepairFromMoQ(packet: Uint8Array, ownerPacketId?: number, catalogTrackName?: string): void
|
|
401
480
|
noteRepairScheduling(
|
|
@@ -433,7 +512,8 @@ export interface RepairFetchHost {
|
|
|
433
512
|
priority: RepairPriority,
|
|
434
513
|
sbn: number,
|
|
435
514
|
packetId: number,
|
|
436
|
-
catalogTrackName
|
|
515
|
+
catalogTrackName: string | undefined,
|
|
516
|
+
measurement: RepairSendMeasurement,
|
|
437
517
|
): void
|
|
438
518
|
}
|
|
439
519
|
|
|
@@ -462,10 +542,26 @@ interface RepairEntry {
|
|
|
462
542
|
* later: a block reclassified from delta can gain the keyframe budget.
|
|
463
543
|
*/
|
|
464
544
|
deadlineAt: number
|
|
545
|
+
/** Inputs `deadlineAt` was computed from; they move with it. */
|
|
546
|
+
anchorAt: number | null
|
|
547
|
+
delayMs: number | null
|
|
548
|
+
bound: RepairDeadlineBound
|
|
465
549
|
/** Monotonic enqueue order, the EDF tie-break. */
|
|
466
550
|
readonly order: number
|
|
467
551
|
attempts: number
|
|
468
552
|
running: FetchRun | null
|
|
553
|
+
/** A range request for a pending hole `[sbn, sbn + holeLength)`. */
|
|
554
|
+
readonly range?: RepairFetchRange & { readonly lostSsId: number; readonly holeLength: number }
|
|
555
|
+
/** A range request's deadline timer (see the module note). */
|
|
556
|
+
expiry?: ReturnType<typeof setTimeout>
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
interface ResolvedDeadline {
|
|
560
|
+
readonly deadlineAt: number
|
|
561
|
+
readonly extensionMs: number
|
|
562
|
+
readonly anchorAt: number | null
|
|
563
|
+
readonly delayMs: number | null
|
|
564
|
+
readonly bound: RepairDeadlineBound
|
|
469
565
|
}
|
|
470
566
|
|
|
471
567
|
/**
|
|
@@ -490,6 +586,12 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
490
586
|
if (typeof opts.presentationDelayMs !== 'function') {
|
|
491
587
|
throw new Error('[RepairFetch] presentationDelayMs is required: a repair FETCH is due by the block\'s presentation deadline')
|
|
492
588
|
}
|
|
589
|
+
if (
|
|
590
|
+
opts.rangeTransport !== undefined &&
|
|
591
|
+
(typeof opts.repairEpochReference !== 'function' || !mc.onUndelimitedLoss || !mc.closeIsoHoles)
|
|
592
|
+
) {
|
|
593
|
+
throw new Error('[RepairFetch] rangeTransport needs repairEpochReference and a host that reports undelimited losses')
|
|
594
|
+
}
|
|
493
595
|
const entries = new Map<string, RepairEntry>()
|
|
494
596
|
const warnedNoTarget = new Set<string>()
|
|
495
597
|
let disposed = false
|
|
@@ -508,7 +610,15 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
508
610
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
509
611
|
}
|
|
510
612
|
|
|
613
|
+
/** Whatever ends an entry: a block's repair slot, or a hole's pending state. */
|
|
614
|
+
const clearEntry = (entry: RepairEntry): void => {
|
|
615
|
+
if (entry.range) mc.closeIsoHoles!(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength)
|
|
616
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
617
|
+
}
|
|
618
|
+
|
|
511
619
|
const releaseHold = (entry: RepairEntry): void => {
|
|
620
|
+
// A hole is no tracked block: nothing holds it but the hole itself.
|
|
621
|
+
if (entry.range) return
|
|
512
622
|
if (entry.catalogTrackName === undefined) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId)
|
|
513
623
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName)
|
|
514
624
|
}
|
|
@@ -548,15 +658,15 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
548
658
|
/**
|
|
549
659
|
* RTT admission: send only a FETCH the measured round trip says can land
|
|
550
660
|
* before the entry's deadline. A refused entry is released, not queued: the
|
|
551
|
-
* deadline only gets closer.
|
|
661
|
+
* deadline only gets closer. Returns the admitting RTT, or null when refused.
|
|
552
662
|
*/
|
|
553
|
-
const admit = (entry: RepairEntry, now: number):
|
|
663
|
+
const admit = (entry: RepairEntry, now: number): number | null => {
|
|
554
664
|
const budgetMs = entry.deadlineAt - now
|
|
555
665
|
const rttMs = readRtt()
|
|
556
|
-
if (rttMs !== null && rttMs < budgetMs) return
|
|
666
|
+
if (rttMs !== null && rttMs < budgetMs) return rttMs
|
|
557
667
|
retire(entry)
|
|
558
668
|
releaseHold(entry)
|
|
559
|
-
|
|
669
|
+
clearEntry(entry)
|
|
560
670
|
mc.noteRepairSkipped(
|
|
561
671
|
rttMs === null ? 'rtt-unmeasured' : 'rtt-exceeds-budget',
|
|
562
672
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
@@ -564,11 +674,12 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
564
674
|
entry.packetId,
|
|
565
675
|
entry.catalogTrackName,
|
|
566
676
|
)
|
|
567
|
-
return
|
|
677
|
+
return null
|
|
568
678
|
}
|
|
569
679
|
|
|
570
680
|
const retire = (entry: RepairEntry): void => {
|
|
571
681
|
if (entries.get(entry.key) === entry) entries.delete(entry.key)
|
|
682
|
+
if (entry.expiry !== undefined) clearTimeout(entry.expiry)
|
|
572
683
|
}
|
|
573
684
|
|
|
574
685
|
const urgentOutstanding = (): boolean => {
|
|
@@ -609,19 +720,30 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
609
720
|
|
|
610
721
|
/** `counted` is false for a reprioritisation restart, which is no retry. */
|
|
611
722
|
const start = (entry: RepairEntry, counted = true): void => {
|
|
612
|
-
|
|
723
|
+
const now = performance.now()
|
|
724
|
+
const rttMs = admit(entry, now)
|
|
725
|
+
if (rttMs === null) return
|
|
613
726
|
if (counted) entry.attempts++
|
|
614
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
727
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
728
|
+
rttMs,
|
|
729
|
+
budgetMs: entry.deadlineAt - now,
|
|
730
|
+
delayMs: entry.delayMs,
|
|
731
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
732
|
+
bound: entry.bound,
|
|
733
|
+
...(entry.range ? { range: true as const } : {}),
|
|
734
|
+
})
|
|
615
735
|
const run: FetchRun = { controller: new AbortController(), stopped: null }
|
|
616
736
|
entry.running = run
|
|
617
737
|
// Hold the block open to the presentation deadline while this FETCH can
|
|
618
738
|
// still land: the multicast span elapsing must not abort it.
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
739
|
+
if (!entry.range) {
|
|
740
|
+
mc.fecManager.holdBlockForRepair(
|
|
741
|
+
entry.sbn,
|
|
742
|
+
entry.packetId,
|
|
743
|
+
entry.catalogTrackName,
|
|
744
|
+
entry.deadlineAt,
|
|
745
|
+
)
|
|
746
|
+
}
|
|
625
747
|
void execute(entry, run)
|
|
626
748
|
}
|
|
627
749
|
|
|
@@ -638,7 +760,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
638
760
|
if (entry.deadlineAt <= now) {
|
|
639
761
|
stop(entry, 'expired')
|
|
640
762
|
retire(entry)
|
|
641
|
-
|
|
763
|
+
clearEntry(entry)
|
|
642
764
|
}
|
|
643
765
|
continue
|
|
644
766
|
}
|
|
@@ -647,7 +769,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
647
769
|
// no fetch can land in time.
|
|
648
770
|
retire(entry)
|
|
649
771
|
if (entry.priority === 2 && entry.attempts === 0) note('repair-deferred', entry)
|
|
650
|
-
|
|
772
|
+
clearEntry(entry)
|
|
651
773
|
continue
|
|
652
774
|
}
|
|
653
775
|
queued.push(entry)
|
|
@@ -711,9 +833,11 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
711
833
|
// A fetch that ended without feeding anything cannot resolve the block;
|
|
712
834
|
// release the slot and the hold so failure accounting is not wedged. A
|
|
713
835
|
// fetch that fed symbols leaves resolution to the FEC layer.
|
|
714
|
-
|
|
836
|
+
// A range FETCH placed whatever it stated as it arrived; the rest of
|
|
837
|
+
// its hole is now known to have no repair coming.
|
|
838
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
715
839
|
releaseHold(entry)
|
|
716
|
-
|
|
840
|
+
clearEntry(entry)
|
|
717
841
|
}
|
|
718
842
|
dispatch()
|
|
719
843
|
return
|
|
@@ -730,7 +854,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
730
854
|
}
|
|
731
855
|
retire(entry)
|
|
732
856
|
if (fed === 0) releaseHold(entry)
|
|
733
|
-
|
|
857
|
+
clearEntry(entry)
|
|
734
858
|
console.warn(
|
|
735
859
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
736
860
|
error,
|
|
@@ -756,15 +880,23 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
756
880
|
|
|
757
881
|
const execute = async (entry: RepairEntry, run: FetchRun): Promise<void> => {
|
|
758
882
|
let fed = 0
|
|
883
|
+
const common = {
|
|
884
|
+
repairTrack: entry.repairTrack,
|
|
885
|
+
blockProfile: entry.blockProfile,
|
|
886
|
+
packetId: entry.packetId,
|
|
887
|
+
signal: run.controller.signal,
|
|
888
|
+
subscriberPriority: entry.subscriberPriority,
|
|
889
|
+
}
|
|
759
890
|
try {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
891
|
+
const packets = entry.range
|
|
892
|
+
? opts.rangeTransport!({
|
|
893
|
+
...common,
|
|
894
|
+
startGroup: entry.range.startGroup,
|
|
895
|
+
endGroup: entry.range.endGroup,
|
|
896
|
+
lostSsId: entry.range.lostSsId,
|
|
897
|
+
})
|
|
898
|
+
: opts.transport({ ...common, sbn: entry.sbn })
|
|
899
|
+
for await (const packet of packets) {
|
|
768
900
|
if (run.stopped !== null || entry.running !== run) break
|
|
769
901
|
fed++
|
|
770
902
|
if (entry.catalogTrackName === undefined) {
|
|
@@ -784,6 +916,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
784
916
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue
|
|
785
917
|
retire(entry)
|
|
786
918
|
stop(entry, 'reset')
|
|
919
|
+
if (entry.range) clearEntry(entry)
|
|
787
920
|
}
|
|
788
921
|
// A reset is when the packetId -> repair-track mapping can change, so
|
|
789
922
|
// re-arm the once-per-track warn for the new epoch.
|
|
@@ -816,6 +949,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
816
949
|
)
|
|
817
950
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry.deadlineAt) {
|
|
818
951
|
entry.deadlineAt = promotedDeadline.deadlineAt
|
|
952
|
+
entry.anchorAt = promotedDeadline.anchorAt
|
|
953
|
+
entry.delayMs = promotedDeadline.delayMs
|
|
954
|
+
entry.bound = promotedDeadline.bound
|
|
819
955
|
noteBudget(entry, promotedDeadline.extensionMs)
|
|
820
956
|
}
|
|
821
957
|
if (entry.running) {
|
|
@@ -859,14 +995,16 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
859
995
|
catalogTrackName: string | undefined,
|
|
860
996
|
now: number,
|
|
861
997
|
blockClass: BlockClass,
|
|
862
|
-
):
|
|
998
|
+
): ResolvedDeadline | null => {
|
|
863
999
|
// Undefined: the packetId is no longer configured (released), so it has
|
|
864
1000
|
// no repair budget.
|
|
865
1001
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName)
|
|
866
1002
|
if (waitMs === undefined) return null
|
|
867
1003
|
const waitDeadlineAt = now + waitMs
|
|
868
1004
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName)
|
|
869
|
-
if (anchor === undefined)
|
|
1005
|
+
if (anchor === undefined) {
|
|
1006
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: 'wait' }
|
|
1007
|
+
}
|
|
870
1008
|
let delayMs: number
|
|
871
1009
|
try {
|
|
872
1010
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName)
|
|
@@ -877,16 +1015,28 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
877
1015
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId)
|
|
878
1016
|
if (retentionMs === undefined) return null
|
|
879
1017
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs
|
|
880
|
-
const
|
|
881
|
-
|
|
1018
|
+
const at = (
|
|
1019
|
+
delay: number,
|
|
1020
|
+
delayBound: 'presentation' | 'keyframe',
|
|
1021
|
+
): { readonly deadlineAt: number; readonly bound: RepairDeadlineBound } => {
|
|
1022
|
+
const presentAt = Math.min(anchor + delay, ceilingAt)
|
|
1023
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: 'wait' }
|
|
1024
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : 'retention' }
|
|
1025
|
+
}
|
|
1026
|
+
const base = at(delayMs, 'presentation')
|
|
882
1027
|
const budgetMs =
|
|
883
1028
|
keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) &&
|
|
884
1029
|
groupCanComplete(sbn, packetId, catalogTrackName)
|
|
885
1030
|
? readKeyframeBudget(packetId, catalogTrackName)
|
|
886
1031
|
: null
|
|
887
|
-
if (budgetMs === null || budgetMs <= delayMs) return {
|
|
888
|
-
const extended =
|
|
889
|
-
return {
|
|
1032
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs }
|
|
1033
|
+
const extended = at(budgetMs, 'keyframe')
|
|
1034
|
+
return {
|
|
1035
|
+
...extended,
|
|
1036
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
1037
|
+
anchorAt: anchor,
|
|
1038
|
+
delayMs: budgetMs,
|
|
1039
|
+
}
|
|
890
1040
|
}
|
|
891
1041
|
|
|
892
1042
|
const earliestGatedFrameAt = (packetId: number, catalogTrackName: string | undefined): number | undefined => {
|
|
@@ -978,6 +1128,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
978
1128
|
priority,
|
|
979
1129
|
subscriberPriority: wire.subscriberPriority,
|
|
980
1130
|
deadlineAt: deadline.deadlineAt,
|
|
1131
|
+
anchorAt: deadline.anchorAt,
|
|
1132
|
+
delayMs: deadline.delayMs,
|
|
1133
|
+
bound: deadline.bound,
|
|
981
1134
|
order: enqueueOrder++,
|
|
982
1135
|
attempts: 0,
|
|
983
1136
|
running: null,
|
|
@@ -988,14 +1141,105 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
988
1141
|
dispatch()
|
|
989
1142
|
})
|
|
990
1143
|
|
|
1144
|
+
/**
|
|
1145
|
+
* §7.5 range for a lost SS_ID: from ext(S_prev) when a stated block ends
|
|
1146
|
+
* where the hole starts, else from the epoch reference r. Null when there
|
|
1147
|
+
* is no r, or the lost SS_ID cannot be extended from it.
|
|
1148
|
+
*/
|
|
1149
|
+
const rangeFor = (loss: UndelimitedIsoLoss, repairTrack: string): RepairFetchRange | null => {
|
|
1150
|
+
let reference: bigint | undefined
|
|
1151
|
+
try {
|
|
1152
|
+
reference = opts.repairEpochReference!(repairTrack)
|
|
1153
|
+
} catch {
|
|
1154
|
+
return null
|
|
1155
|
+
}
|
|
1156
|
+
if (reference === undefined) return null
|
|
1157
|
+
try {
|
|
1158
|
+
const anchor = loss.previousBlockStart === undefined
|
|
1159
|
+
? { reference }
|
|
1160
|
+
: { previousBlockStart: extendSsId(reference, loss.previousBlockStart) }
|
|
1161
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor)
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
if (error instanceof RangeError) return null
|
|
1164
|
+
throw error
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
if (opts.rangeTransport !== undefined) {
|
|
1169
|
+
mc.onUndelimitedLoss!((loss) => {
|
|
1170
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss
|
|
1171
|
+
const close = (): void => mc.closeIsoHoles!(packetId, catalogTrackName, holeStart, holeLength)
|
|
1172
|
+
if (disposed) return close()
|
|
1173
|
+
const blockProfile = blockProfileOf(packetId)
|
|
1174
|
+
const target = opts.resolveTarget(packetId, catalogTrackName)
|
|
1175
|
+
if (!target) return close()
|
|
1176
|
+
const priority = repairPriorityForClass('unknown')
|
|
1177
|
+
const range = rangeFor(loss, target.repairTrack)
|
|
1178
|
+
if (range === null) {
|
|
1179
|
+
close()
|
|
1180
|
+
mc.noteRepairSkipped('range-no-anchor', { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName)
|
|
1181
|
+
return
|
|
1182
|
+
}
|
|
1183
|
+
const identity = {
|
|
1184
|
+
target,
|
|
1185
|
+
sbn: holeStart,
|
|
1186
|
+
packetId,
|
|
1187
|
+
...(catalogTrackName === undefined ? {} : { catalogTrackName }),
|
|
1188
|
+
}
|
|
1189
|
+
// `unknown` is P0, whose request is never declined (omitted at worst).
|
|
1190
|
+
const wire = wirePriority(identity, 'unknown')!
|
|
1191
|
+
// The hole is no tracked block: no anchor, so this is the multicast
|
|
1192
|
+
// wait (`bound: 'wait'`), by intent. A hole holds the release gate, so it
|
|
1193
|
+
// must not wait out a presentation delay on top.
|
|
1194
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), 'unknown')
|
|
1195
|
+
if (deadline === null) {
|
|
1196
|
+
close()
|
|
1197
|
+
mc.noteRepairSkipped(
|
|
1198
|
+
'presentation-delay-unavailable',
|
|
1199
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
1200
|
+
holeStart,
|
|
1201
|
+
packetId,
|
|
1202
|
+
catalogTrackName,
|
|
1203
|
+
)
|
|
1204
|
+
return
|
|
1205
|
+
}
|
|
1206
|
+
const entry: RepairEntry = {
|
|
1207
|
+
key: JSON.stringify(['range', packetId, catalogTrackName ?? null, holeStart]),
|
|
1208
|
+
...identity,
|
|
1209
|
+
repairTrack: target.repairTrack,
|
|
1210
|
+
blockProfile,
|
|
1211
|
+
priority,
|
|
1212
|
+
subscriberPriority: wire.subscriberPriority,
|
|
1213
|
+
deadlineAt: deadline.deadlineAt,
|
|
1214
|
+
anchorAt: deadline.anchorAt,
|
|
1215
|
+
delayMs: deadline.delayMs,
|
|
1216
|
+
bound: deadline.bound,
|
|
1217
|
+
order: enqueueOrder++,
|
|
1218
|
+
attempts: 0,
|
|
1219
|
+
running: null,
|
|
1220
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength },
|
|
1221
|
+
}
|
|
1222
|
+
const previous = entries.get(entry.key)
|
|
1223
|
+
if (previous) {
|
|
1224
|
+
retire(previous)
|
|
1225
|
+
stop(previous, 'reset')
|
|
1226
|
+
}
|
|
1227
|
+
entries.set(entry.key, entry)
|
|
1228
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1)
|
|
1229
|
+
preemptDeltas()
|
|
1230
|
+
dispatch()
|
|
1231
|
+
})
|
|
1232
|
+
}
|
|
1233
|
+
|
|
991
1234
|
return () => {
|
|
992
1235
|
disposed = true
|
|
993
1236
|
removeResetObserver()
|
|
994
1237
|
removeLifecycleObserver()
|
|
995
1238
|
for (const entry of [...entries.values()]) {
|
|
996
|
-
|
|
1239
|
+
clearEntry(entry)
|
|
997
1240
|
if (entry.running) releaseHold(entry)
|
|
998
1241
|
stop(entry, 'disposed')
|
|
1242
|
+
if (entry.expiry !== undefined) clearTimeout(entry.expiry)
|
|
999
1243
|
}
|
|
1000
1244
|
entries.clear()
|
|
1001
1245
|
}
|
package/src/repair-layers.ts
CHANGED
|
@@ -34,6 +34,8 @@ export const MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
|
|
|
34
34
|
export const MAX_REPAIR_SYMBOLS = 0xffffff;
|
|
35
35
|
/** The 24-bit ESI bounds K + totalP - 1 for one FEC instance. */
|
|
36
36
|
export const MAX_ENCODING_SYMBOL_ID = 0xffffff;
|
|
37
|
+
/** Reed-Solomon block bound: K + P <= 255 (draft-ramadan-moq-fec-01 4.5, 6.3.4 rule 12). */
|
|
38
|
+
export const MAX_REED_SOLOMON_BLOCK_SYMBOLS = 255;
|
|
37
39
|
|
|
38
40
|
export type RepairContractCode =
|
|
39
41
|
| "track_fec"
|
|
@@ -429,11 +431,14 @@ export function assembleRepairLayers(
|
|
|
429
431
|
if (layered && !positiveInteger(source.sourceSymbols)) {
|
|
430
432
|
fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
|
|
431
433
|
}
|
|
432
|
-
|
|
434
|
+
// Rule 7: the two specified schemes. Reed-Solomon layers decode because its
|
|
435
|
+
// Cauchy matrix row for RS_ID is the same whatever the block's total P (fec-01 4.4).
|
|
436
|
+
const reedSolomon = source.algorithm === "reed-solomon";
|
|
437
|
+
if (layered && source.algorithm !== "raptorq" && !reedSolomon) {
|
|
433
438
|
fail(
|
|
434
439
|
"track_fec",
|
|
435
440
|
`${source.path}.algorithm`,
|
|
436
|
-
"repair layers and overlays are defined only for raptorq
|
|
441
|
+
"repair layers and overlays are defined only for raptorq and reed-solomon (draft-ramadan-moq-fec-01 6.3.4 rule 7)",
|
|
437
442
|
);
|
|
438
443
|
}
|
|
439
444
|
|
|
@@ -500,6 +505,13 @@ export function assembleRepairLayers(
|
|
|
500
505
|
`overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`,
|
|
501
506
|
);
|
|
502
507
|
}
|
|
508
|
+
if (reedSolomon && sourceSymbols + repairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
509
|
+
fail(
|
|
510
|
+
"track_fec_bounds",
|
|
511
|
+
`${d.path}.repairSymbols`,
|
|
512
|
+
`reed-solomon overlay sourceSymbols + repairSymbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`,
|
|
513
|
+
);
|
|
514
|
+
}
|
|
503
515
|
overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority as number });
|
|
504
516
|
}
|
|
505
517
|
|
|
@@ -549,5 +561,13 @@ export function assembleRepairLayers(
|
|
|
549
561
|
);
|
|
550
562
|
}
|
|
551
563
|
|
|
564
|
+
if (reedSolomon && k + totalBaseRepairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
565
|
+
fail(
|
|
566
|
+
"track_fec_bounds",
|
|
567
|
+
`${source.path}.sourceSymbols`,
|
|
568
|
+
`reed-solomon sourceSymbols + total base repair symbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`,
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
552
572
|
return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
|
|
553
573
|
}
|
package/src/sample-combiner.ts
CHANGED
|
@@ -286,8 +286,14 @@ export class SampleCombiner {
|
|
|
286
286
|
/**
|
|
287
287
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
288
288
|
* constituent data unit has arrived and totals the authored size.
|
|
289
|
+
*
|
|
290
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
291
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
292
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
293
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
294
|
+
* fragments, or one decoded before its source copy arrived.
|
|
289
295
|
*/
|
|
290
|
-
addMfu(mfu: ReassembledMFU): CombinedSample | null {
|
|
296
|
+
addMfu(mfu: ReassembledMFU, sampleSize?: number): CombinedSample | null {
|
|
291
297
|
if (mfu.movieFragmentSequenceNumber === undefined || mfu.sampleNumber === undefined) {
|
|
292
298
|
// Non-timed (Item) MFU: sample combining does not apply.
|
|
293
299
|
this.#stats.passthroughSamples++
|
|
@@ -311,7 +317,7 @@ export class SampleCombiner {
|
|
|
311
317
|
}
|
|
312
318
|
|
|
313
319
|
const dataLen = mfu.data.byteLength
|
|
314
|
-
const authoredSize = this.#authoredSizes.get(key)
|
|
320
|
+
const authoredSize = this.#authoredSizes.get(key) ?? sampleSize
|
|
315
321
|
|
|
316
322
|
if (offset === 0 && !this.#pending.has(key)) {
|
|
317
323
|
const passesThrough = authoredSize === undefined
|
|
@@ -678,6 +684,13 @@ if (import.meta.vitest) {
|
|
|
678
684
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
|
|
679
685
|
})
|
|
680
686
|
|
|
687
|
+
test('a size handed with the data unit completes a sample no head registered', () => {
|
|
688
|
+
const c = combiner({ requireAuthoredSize: true })
|
|
689
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)
|
|
690
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]))
|
|
691
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull()
|
|
692
|
+
})
|
|
693
|
+
|
|
681
694
|
test('duplicate offset is rejected', () => {
|
|
682
695
|
const c = combiner()
|
|
683
696
|
c.registerAuthoredSize(undefined, 1, 9, 17, 10)
|
package/src/signaling.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import {
|
|
13
13
|
ALFEC_MESSAGE_ID,
|
|
14
14
|
FEC_CODE_RAPTORQ,
|
|
15
|
-
|
|
15
|
+
FEC_CODE_REED_SOLOMON,
|
|
16
16
|
PACKET_TYPE_MPU,
|
|
17
17
|
PACKET_TYPE_REPAIR,
|
|
18
18
|
PACKET_TYPE_SIGNALING,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
export {
|
|
23
23
|
ALFEC_MESSAGE_ID,
|
|
24
24
|
FEC_CODE_RAPTORQ,
|
|
25
|
-
|
|
25
|
+
FEC_CODE_REED_SOLOMON,
|
|
26
26
|
PACKET_TYPE_MPU,
|
|
27
27
|
PACKET_TYPE_REPAIR,
|
|
28
28
|
PACKET_TYPE_SIGNALING,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Phase 14 D-15: log-only on drift (does NOT reject stream, does NOT throw).
|
|
6
6
|
* Phase 14 D-16: tolerance = Math.floor(1_000_000 / framerate / 2) microseconds.
|
|
7
7
|
* Hardcoded tolerance is FORBIDDEN — derives from framerate only.
|
|
8
|
-
* Phase 14 D-17:
|
|
8
|
+
* Phase 14 D-17: tracks with equal altGroup form one switching set; repair legs are in none.
|
|
9
9
|
* Phase 14 T-14-03 mitigation: at most ONE misalignment emit per groupId pair.
|
|
10
10
|
*/
|
|
11
11
|
|