@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 0.4.0-main.bbdfdbf39ded
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 +31 -17
- 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 +1192 -375
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +67 -31
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +291 -199
- 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 +24 -2
- 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/delivery-catalog.js +18 -12
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +49 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +176 -23
- package/dist/fec-manager.js.map +3 -3
- 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 +2 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +2 -1
- package/dist/fec-worker-setup.js.map +2 -2
- 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 +29 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +331 -1171
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1014 -289
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +159 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +531 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +17 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +29 -0
- 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 +347 -132
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +28 -6
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +290 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +40 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +293 -54
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +18 -11
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +964 -274
- 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/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/source-auth.js +2710 -7
- package/dist/source-auth.js.map +4 -4
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +131 -52
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +128 -14
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +4 -1
- package/src/index.ts +24 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +57 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +115 -14
- package/src/multicast-transport.ts +3 -0
- package/src/no-modules.ts +7 -1
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -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 +60 -3
- 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-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 +2 -2
- 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 +30 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +6 -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/src/fec-codec.ts +0 -61
package/src/fec-manager.ts
CHANGED
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
ssbg1FitsSymbol,
|
|
28
28
|
type FecBlockProfile,
|
|
29
29
|
} from '@blockcast/mmt-base'
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
IsoBlockLocator,
|
|
32
|
+
type IsoBlockRange,
|
|
33
|
+
type IsoPlacedSource,
|
|
34
|
+
type IsoRepairPlacement,
|
|
35
|
+
} from './iso-block-locator.js'
|
|
31
36
|
import { MIN_INTERLEAVE_DEPTH_MS } from './fec-state.js'
|
|
32
37
|
import {
|
|
33
38
|
BlockClassifier,
|
|
@@ -54,6 +59,9 @@ import type {
|
|
|
54
59
|
// Constants
|
|
55
60
|
// ---------------------------------------------------------------------------
|
|
56
61
|
|
|
62
|
+
/** fec-01 4.5: a GF(2^8) reed-solomon block holds at most 255 symbols. */
|
|
63
|
+
const RS_MAX_BLOCK_SYMBOLS = 255
|
|
64
|
+
|
|
57
65
|
// MIN_INTERLEAVE_DEPTH_MS lives with the catalog FEC predicate that also
|
|
58
66
|
// needs it (fec-state.ts); re-exported here for existing importers.
|
|
59
67
|
export { MIN_INTERLEAVE_DEPTH_MS }
|
|
@@ -156,6 +164,25 @@ export interface IsoHeldSource {
|
|
|
156
164
|
readonly oversized: boolean
|
|
157
165
|
}
|
|
158
166
|
|
|
167
|
+
/**
|
|
168
|
+
* A lost SS_ID in an undelimited span (draft-ramadan-moq-fec §7.5): a repair
|
|
169
|
+
* stated a block past SS_IDs whose every repair symbol was lost and at least
|
|
170
|
+
* one source too. They wait as a pending hole `[holeStart, holeStart +
|
|
171
|
+
* holeLength)` for a range repair FETCH.
|
|
172
|
+
*/
|
|
173
|
+
export interface UndelimitedIsoLoss {
|
|
174
|
+
readonly packetId: number
|
|
175
|
+
readonly catalogTrackName: string | undefined
|
|
176
|
+
readonly holeStart: number
|
|
177
|
+
readonly holeLength: number
|
|
178
|
+
/** The highest SS_ID in the hole no source arrived for: the §7.5 x. */
|
|
179
|
+
readonly lostSsId: number
|
|
180
|
+
/** K: the catalog `sourceSymbols`, the largest SSB_length. */
|
|
181
|
+
readonly kMax: number
|
|
182
|
+
/** 32-bit SS_Start of the stated block that ends where the hole starts (S_prev). */
|
|
183
|
+
readonly previousBlockStart?: number
|
|
184
|
+
}
|
|
185
|
+
|
|
159
186
|
/**
|
|
160
187
|
* How the multicast leg hands its symbols to this manager.
|
|
161
188
|
*
|
|
@@ -224,6 +251,11 @@ export interface FECManagerConfig {
|
|
|
224
251
|
* is refused.
|
|
225
252
|
*/
|
|
226
253
|
blockProfile?: FecBlockProfile
|
|
254
|
+
/**
|
|
255
|
+
* The catalog `fec.algorithm` (`TrackFecParams.fecAlgorithm`). Defaults to
|
|
256
|
+
* RaptorQ. Reed-Solomon bounds every block to 255 symbols (fec-01 4.5).
|
|
257
|
+
*/
|
|
258
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
227
259
|
k?: number
|
|
228
260
|
/** Symbol size in bytes (T). NOT repair count. */
|
|
229
261
|
symbolSize?: number
|
|
@@ -245,6 +277,7 @@ export interface FECManagerConfig {
|
|
|
245
277
|
|
|
246
278
|
interface ResolvedFECTrackConfig {
|
|
247
279
|
blockProfile?: FecBlockProfile
|
|
280
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
248
281
|
k: number
|
|
249
282
|
symbolSize: number
|
|
250
283
|
interleaveDepthMs: number
|
|
@@ -582,6 +615,7 @@ export class FECManager {
|
|
|
582
615
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
583
616
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
584
617
|
#isoLocators = new Map<string, IsoBlockLocator<IsoHeldSource>>()
|
|
618
|
+
#deferIsoGaps = false
|
|
585
619
|
#isoRepairRefusedCount = 0
|
|
586
620
|
#isoSourceOversizeCount = 0
|
|
587
621
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -712,6 +746,14 @@ export class FECManager {
|
|
|
712
746
|
reason: ClassifierReason | null,
|
|
713
747
|
) => void)
|
|
714
748
|
| null = null
|
|
749
|
+
/**
|
|
750
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
751
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
752
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
753
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
754
|
+
* for it, which it must be.
|
|
755
|
+
*/
|
|
756
|
+
#onUndelimitedLoss: ((loss: UndelimitedIsoLoss) => void) | null = null
|
|
715
757
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
716
758
|
onBlockVanished:
|
|
717
759
|
| ((sbn: number, packetId: number, catalogTrackName: string | undefined) => void)
|
|
@@ -2073,8 +2115,10 @@ export class FECManager {
|
|
|
2073
2115
|
)
|
|
2074
2116
|
}
|
|
2075
2117
|
const hasCatalogTiming = FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs })
|
|
2118
|
+
const algorithm = config.algorithm ?? previous.algorithm
|
|
2076
2119
|
const next: ResolvedFECTrackConfig = {
|
|
2077
2120
|
blockProfile,
|
|
2121
|
+
...(algorithm === undefined ? {} : { algorithm }),
|
|
2078
2122
|
k,
|
|
2079
2123
|
symbolSize:
|
|
2080
2124
|
config.symbolSize != null && config.symbolSize > 0
|
|
@@ -3006,6 +3050,7 @@ export class FECManager {
|
|
|
3006
3050
|
let locator = this.#isoLocators.get(streamKey)
|
|
3007
3051
|
if (!locator) {
|
|
3008
3052
|
locator = new IsoBlockLocator<IsoHeldSource>(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId))
|
|
3053
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
3009
3054
|
this.#isoLocators.set(streamKey, locator)
|
|
3010
3055
|
}
|
|
3011
3056
|
return locator
|
|
@@ -3125,23 +3170,74 @@ export class FECManager {
|
|
|
3125
3170
|
}
|
|
3126
3171
|
return placement
|
|
3127
3172
|
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
const
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3173
|
+
if (placement.span !== undefined) this.#openIsoSpan(placement.span, packetId, catalogTrackName)
|
|
3174
|
+
if (placement.hole !== undefined) {
|
|
3175
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName)
|
|
3176
|
+
const hole = placement.hole.block
|
|
3177
|
+
const previous = locator.blockEndingAt(hole.start)
|
|
3178
|
+
const loss: UndelimitedIsoLoss = {
|
|
3179
|
+
packetId,
|
|
3180
|
+
catalogTrackName,
|
|
3181
|
+
holeStart: hole.start,
|
|
3182
|
+
holeLength: hole.length,
|
|
3183
|
+
lostSsId: placement.hole.lostSsId,
|
|
3184
|
+
kMax: this.#trackConfig(packetId).k,
|
|
3185
|
+
...(previous === undefined ? {} : { previousBlockStart: previous.start }),
|
|
3186
|
+
}
|
|
3187
|
+
this.#onUndelimitedLoss!(loss)
|
|
3141
3188
|
}
|
|
3142
3189
|
return placement
|
|
3143
3190
|
}
|
|
3144
3191
|
|
|
3192
|
+
/**
|
|
3193
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
3194
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3195
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
3196
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
3197
|
+
* nobody to close it.
|
|
3198
|
+
*/
|
|
3199
|
+
setUndelimitedLossHandler(handler: ((loss: UndelimitedIsoLoss) => void) | null): void {
|
|
3200
|
+
this.#onUndelimitedLoss = handler
|
|
3201
|
+
this.#deferIsoGaps = handler !== null
|
|
3202
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
/**
|
|
3206
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
3207
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
3208
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
3209
|
+
*/
|
|
3210
|
+
closeIsoHoles(
|
|
3211
|
+
packetId: number,
|
|
3212
|
+
catalogTrackName: string | undefined,
|
|
3213
|
+
start: number,
|
|
3214
|
+
length: number,
|
|
3215
|
+
): { block: IsoBlockRange; placed: IsoPlacedSource<IsoHeldSource>[] }[] {
|
|
3216
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))
|
|
3217
|
+
if (locator === undefined) return []
|
|
3218
|
+
const spans = locator.closeHolesWithin(start, length)
|
|
3219
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName)
|
|
3220
|
+
return spans
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
3225
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
3226
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
3227
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3228
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3229
|
+
* block.
|
|
3230
|
+
*/
|
|
3231
|
+
#openIsoSpan(
|
|
3232
|
+
span: { readonly block: IsoBlockRange; readonly placed: readonly unknown[] },
|
|
3233
|
+
packetId: number,
|
|
3234
|
+
catalogTrackName: string | undefined,
|
|
3235
|
+
): void {
|
|
3236
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName)
|
|
3237
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length)
|
|
3238
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true)
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3145
3241
|
/**
|
|
3146
3242
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3147
3243
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -3869,6 +3965,24 @@ export class FECManager {
|
|
|
3869
3965
|
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
3870
3966
|
* nothing here; its repair is dropped upstream as unreadable.
|
|
3871
3967
|
*/
|
|
3968
|
+
/**
|
|
3969
|
+
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
3970
|
+
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
3971
|
+
* block state unchanged. The router calls this before the repair places a
|
|
3972
|
+
* block or takes any other part in block bookkeeping. A RaptorQ track admits
|
|
3973
|
+
* every header that parsed (its RS_ID < RSB_length check is in the parser).
|
|
3974
|
+
*/
|
|
3975
|
+
admitRepairBlockLength(
|
|
3976
|
+
packetId: number,
|
|
3977
|
+
ssbLength: number,
|
|
3978
|
+
rsbLength: number,
|
|
3979
|
+
rsId: number,
|
|
3980
|
+
): boolean {
|
|
3981
|
+
if (rsId >= rsbLength) return false
|
|
3982
|
+
if (this.#trackConfigs.get(packetId)?.algorithm !== 'reed-solomon') return true
|
|
3983
|
+
return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3872
3986
|
admitRepairSymbolSize(
|
|
3873
3987
|
packetId: number,
|
|
3874
3988
|
ssStart: number,
|
package/src/fec-state.ts
CHANGED
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
// timers or elapsed time. The rules live here so the three players cannot
|
|
14
14
|
// disagree about precedence.
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
18
|
+
fecAlgorithmUnimplemented,
|
|
19
|
+
isFecBlockProfile,
|
|
20
|
+
isoBlockSpanUsable,
|
|
21
|
+
} from '@blockcast/mmt-base'
|
|
17
22
|
|
|
18
23
|
/** The optional elapsed-span rule lives in mmt-base beside the other catalog FEC rules. */
|
|
19
24
|
export { isoBlockSpanUsable }
|
|
@@ -103,7 +108,8 @@ function isPositiveSafeInteger(value: unknown): boolean {
|
|
|
103
108
|
* Whether one catalog `fec` block (a hang rendition's `fec` or an MSF/CMSF
|
|
104
109
|
* track's `fec`) declares an FEC instance a receiver can configure: source
|
|
105
110
|
* symbols per block (K) and a symbol size (T) are both positive integers, the
|
|
106
|
-
* algorithm is
|
|
111
|
+
* algorithm is neither `none` nor a token this receiver does not implement
|
|
112
|
+
* (`fecAlgorithmUnimplemented`, draft-ramadan-moq-fec-01 4), `blockProfile` names the implemented profile
|
|
107
113
|
* `iso-ssbg1-v1` (BLO-35597), and the block carries that profile's usable
|
|
108
114
|
* span field (`isoBlockSpanUsable`); zero/absence still permits in-band FEC. Total: it never throws, and answers false for
|
|
109
115
|
* any other value.
|
|
@@ -141,12 +147,13 @@ function isPositiveSafeInteger(value: unknown): boolean {
|
|
|
141
147
|
*/
|
|
142
148
|
export function catalogDeclaresFec(fec: unknown): boolean {
|
|
143
149
|
const block = recordOf(fec)
|
|
144
|
-
if (block === undefined || block['algorithm'] === 'none') return false
|
|
150
|
+
if (block === undefined || block['algorithm'] === 'none' || fecAlgorithmUnimplemented(block['algorithm'])) return false
|
|
145
151
|
return (
|
|
146
152
|
isPositiveSafeInteger(block['sourceSymbols']) &&
|
|
147
153
|
isPositiveSafeInteger(block['symbolSize']) &&
|
|
148
154
|
isFecBlockProfile(block['blockProfile']) &&
|
|
149
|
-
isoBlockSpanUsable(block)
|
|
155
|
+
isoBlockSpanUsable(block) &&
|
|
156
|
+
!catalogFecDeclaresUnconfigurableInstance(block)
|
|
150
157
|
)
|
|
151
158
|
}
|
|
152
159
|
|
package/src/fec-worker-setup.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface FecWorkerSetupOptions {
|
|
|
48
48
|
* Worker is created. Never defaulted, never inferred.
|
|
49
49
|
*/
|
|
50
50
|
fecBlockProfile: FecBlockProfile
|
|
51
|
+
/** The track's FEC scheme (`TrackFecParams.fecAlgorithm`). Defaults to RaptorQ. */
|
|
52
|
+
fecAlgorithm?: 'raptorq' | 'reed-solomon'
|
|
51
53
|
/**
|
|
52
54
|
* FEC K from catalog: the maximum SSB_length (K_max) of any block. Blocks
|
|
53
55
|
* are variable-length ssbg_mode1 blocks keyed by SS_Start, so K bounds
|
|
@@ -238,7 +240,7 @@ export async function setupFecWorkerForTrack(
|
|
|
238
240
|
trackType: opts.trackType,
|
|
239
241
|
framerate: opts.framerate,
|
|
240
242
|
sampleRate: opts.sampleRate,
|
|
241
|
-
algorithm: '
|
|
243
|
+
algorithm: opts.fecAlgorithm ?? 'raptorq',
|
|
242
244
|
blockProfile,
|
|
243
245
|
k: opts.fecK,
|
|
244
246
|
// P as this receiver joined it, not the catalog total: the worker snapshot
|
|
@@ -256,6 +258,7 @@ export async function setupFecWorkerForTrack(
|
|
|
256
258
|
try {
|
|
257
259
|
opts.multicastManager.setFecWorker(opts.packetId, client, opts.trackType, {
|
|
258
260
|
blockProfile,
|
|
261
|
+
algorithm: opts.fecAlgorithm ?? 'raptorq',
|
|
259
262
|
k: opts.fecK,
|
|
260
263
|
symbolSize: opts.fecSymbolSize,
|
|
261
264
|
interleaveDepthMs: opts.fecInterleaveMs,
|
package/src/index.ts
CHANGED
|
@@ -121,7 +121,7 @@ export {
|
|
|
121
121
|
} from './loc.js'
|
|
122
122
|
|
|
123
123
|
// CARP Catalog Extensions (draft-law-ramadan-moq-carp-reliability §3-4)
|
|
124
|
-
// + Track Timing (draft-ramadan-moq-mmt-
|
|
124
|
+
// + Track Timing (draft-ramadan-moq-mmt-01 §4.4.2)
|
|
125
125
|
export {
|
|
126
126
|
type FecAlgorithm,
|
|
127
127
|
type FecCatalogConfig,
|
|
@@ -173,7 +173,7 @@ export {
|
|
|
173
173
|
} from './delivery-catalog.js'
|
|
174
174
|
|
|
175
175
|
// Multicast input contract — validator + builder for publisher-emitted
|
|
176
|
-
// catalogs (draft-ramadan-moq-multicast-
|
|
176
|
+
// catalogs (draft-ramadan-moq-multicast-01 §4.1, BLO-3323 A.1).
|
|
177
177
|
// `multicastFromEnv` is the env-var helper used by FFmpeg and the
|
|
178
178
|
// cast bridge (BLO-3337).
|
|
179
179
|
export {
|
|
@@ -265,6 +265,7 @@ export {
|
|
|
265
265
|
type WasmFecDecoder,
|
|
266
266
|
type FecStats,
|
|
267
267
|
type MulticastSymbolDelivery,
|
|
268
|
+
type UndelimitedIsoLoss,
|
|
268
269
|
type FecBlockResolution,
|
|
269
270
|
type RepairVia,
|
|
270
271
|
} from './fec-manager.js'
|
|
@@ -325,14 +326,6 @@ export {
|
|
|
325
326
|
type WasmMmtpParserConfig,
|
|
326
327
|
} from './wasm-mmtp-container-parser.js'
|
|
327
328
|
|
|
328
|
-
// FEC Codec (generic, algorithm-pluggable)
|
|
329
|
-
export {
|
|
330
|
-
type FecCodec,
|
|
331
|
-
NoneCodec,
|
|
332
|
-
ReedSolomonCodec,
|
|
333
|
-
createFecCodec,
|
|
334
|
-
} from './fec-codec.js'
|
|
335
|
-
|
|
336
329
|
// Multicast Transport (SSM join/socket/watchdog)
|
|
337
330
|
export {
|
|
338
331
|
MulticastTransport,
|
|
@@ -554,6 +547,7 @@ export {
|
|
|
554
547
|
catalogFecUnavailable,
|
|
555
548
|
catalogFecAvailable,
|
|
556
549
|
catalogFecDeclaresUnconfigurableInstance,
|
|
550
|
+
fecAlgorithmUnimplemented,
|
|
557
551
|
locateCatalogFecSource,
|
|
558
552
|
type CatalogFecRole,
|
|
559
553
|
type CatalogFecSource,
|
|
@@ -616,10 +610,26 @@ export {
|
|
|
616
610
|
type NoFecCounters,
|
|
617
611
|
} from "./fec-state.js";
|
|
618
612
|
|
|
613
|
+
// In-band AL-FEC for one MMTP asset over a MoQT subscription, for a player
|
|
614
|
+
// that owns its own parser (the Shaka MSF MMTP packaging).
|
|
615
|
+
export {
|
|
616
|
+
MmtpFecSession,
|
|
617
|
+
type MmtpFecSessionCatalogFec,
|
|
618
|
+
type MmtpFecSessionConfig,
|
|
619
|
+
type MmtpFecSessionDecoder,
|
|
620
|
+
type MmtpFecSessionDecoderConstructor,
|
|
621
|
+
type MmtpFecSessionMixedPathStats,
|
|
622
|
+
type MmtpFecSessionPath,
|
|
623
|
+
type MmtpFecSessionPathCounts,
|
|
624
|
+
type MmtpFecSessionStats,
|
|
625
|
+
} from "./mmtp-fec-session.js";
|
|
626
|
+
|
|
619
627
|
export {
|
|
620
628
|
catalogAmtNetworkSource,
|
|
629
|
+
catalogAtsc3NetworkSource,
|
|
621
630
|
DEFAULT_AMT_RELAY_PORT,
|
|
622
631
|
type AmtNetworkSource,
|
|
632
|
+
type Atsc3NetworkSource,
|
|
623
633
|
type CatalogNetworkSource,
|
|
624
634
|
} from "./catalog-network-source.js";
|
|
625
635
|
|
|
@@ -634,7 +644,11 @@ export {
|
|
|
634
644
|
type RepairFetchPriority,
|
|
635
645
|
type RepairFetchRequest,
|
|
636
646
|
type RepairFetchTransport,
|
|
647
|
+
type RepairRangeFetchRequest,
|
|
648
|
+
type RepairRangeFetchTransport,
|
|
649
|
+
type RepairDeadlineBound,
|
|
637
650
|
type RepairPriorityReason,
|
|
651
|
+
type RepairSendMeasurement,
|
|
638
652
|
type RepairSkipReason,
|
|
639
653
|
type RepairSubscribeCallback,
|
|
640
654
|
type WireRepairFetchOptions,
|
package/src/iso-block-locator.ts
CHANGED
|
@@ -51,6 +51,12 @@ export type IsoRepairPlacement<T> =
|
|
|
51
51
|
readonly placed: readonly IsoPlacedSource<T>[]
|
|
52
52
|
/** The repair-less span this repair closed in front of `block`, if any. */
|
|
53
53
|
readonly span?: { readonly block: IsoBlockRange; readonly placed: readonly IsoPlacedSource<T>[] }
|
|
54
|
+
/**
|
|
55
|
+
* With `deferIncompleteGaps`: the SS_IDs in front of `block` whose every
|
|
56
|
+
* repair was lost and some source too, kept as a pending hole instead of
|
|
57
|
+
* a span (see `closeHolesWithin`). `lostSsId` is the highest missing one.
|
|
58
|
+
*/
|
|
59
|
+
readonly hole?: { readonly block: IsoBlockRange; readonly lostSsId: number }
|
|
54
60
|
}
|
|
55
61
|
/** Not a block this stream can use; the repair symbol is dropped. */
|
|
56
62
|
| { readonly status: 'conflict' | 'overlap' | 'stale'; readonly reason: string }
|
|
@@ -79,6 +85,15 @@ export class IsoBlockLocator<T> {
|
|
|
79
85
|
#retentionBlocks: number
|
|
80
86
|
#heldEvicted = 0
|
|
81
87
|
#newest: number | undefined
|
|
88
|
+
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
89
|
+
readonly #holes: IsoBlockRange[] = []
|
|
90
|
+
/**
|
|
91
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
92
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
93
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
94
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
95
|
+
*/
|
|
96
|
+
deferIncompleteGaps = false
|
|
82
97
|
|
|
83
98
|
/**
|
|
84
99
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
@@ -168,6 +183,16 @@ export class IsoBlockLocator<T> {
|
|
|
168
183
|
return null
|
|
169
184
|
}
|
|
170
185
|
|
|
186
|
+
/** Number of pending holes. */
|
|
187
|
+
get holeCount(): number {
|
|
188
|
+
return this.#holes.length
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
192
|
+
blockEndingAt(end: number): IsoBlockRange | undefined {
|
|
193
|
+
return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end)
|
|
194
|
+
}
|
|
195
|
+
|
|
171
196
|
/** The known block or span starting exactly at `start`. */
|
|
172
197
|
blockAt(start: number): IsoBlockRange | undefined {
|
|
173
198
|
return this.#blocks.find((block) => block.start === start)
|
|
@@ -192,6 +217,10 @@ export class IsoBlockLocator<T> {
|
|
|
192
217
|
coversBetween(a: number, b: number): boolean {
|
|
193
218
|
if (this.#coverageEnd === undefined) return false
|
|
194
219
|
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true
|
|
220
|
+
// A pending hole may still be stated by a FETCHed repair.
|
|
221
|
+
const first = (a + 1) >>> 0
|
|
222
|
+
const count = serial32Distance(a, b) - 1
|
|
223
|
+
if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false
|
|
195
224
|
// The last SS_ID strictly before b must precede the coverage end.
|
|
196
225
|
return serial32Precedes((b - 1) >>> 0, this.#coverageEnd)
|
|
197
226
|
}
|
|
@@ -243,6 +272,23 @@ export class IsoBlockLocator<T> {
|
|
|
243
272
|
}
|
|
244
273
|
return { status: 'placed', block: known, placed: [] }
|
|
245
274
|
}
|
|
275
|
+
const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start))
|
|
276
|
+
if (pending !== undefined) {
|
|
277
|
+
if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
|
|
278
|
+
return { status: 'overlap', reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` }
|
|
279
|
+
}
|
|
280
|
+
// A FETCHed repair stated a block inside a pending hole: split the hole round it.
|
|
281
|
+
this.#holes.splice(this.#holes.indexOf(pending), 1)
|
|
282
|
+
const before = serial32Distance(pending.start, start)
|
|
283
|
+
const afterStart = isoBlockEnd(start, length)
|
|
284
|
+
const after = pending.length - before - length
|
|
285
|
+
if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false })
|
|
286
|
+
if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false })
|
|
287
|
+
const block: IsoBlockRange = { start, length, span: false }
|
|
288
|
+
const placed = this.#claim(block)
|
|
289
|
+
this.#blocks.push(block)
|
|
290
|
+
return { status: 'placed', block, placed }
|
|
291
|
+
}
|
|
246
292
|
for (const block of this.#blocks) {
|
|
247
293
|
if (
|
|
248
294
|
isoBlockContains(block.start, block.length, start) ||
|
|
@@ -255,6 +301,7 @@ export class IsoBlockLocator<T> {
|
|
|
255
301
|
}
|
|
256
302
|
}
|
|
257
303
|
let span: { block: IsoBlockRange; placed: IsoPlacedSource<T>[] } | undefined
|
|
304
|
+
let hole: { block: IsoBlockRange; lostSsId: number } | undefined
|
|
258
305
|
if (this.#coverageEnd === undefined) {
|
|
259
306
|
// Reception starts at the first stated block. Held sources before it
|
|
260
307
|
// are the tail of blocks that began before the join: their range is
|
|
@@ -266,24 +313,57 @@ export class IsoBlockLocator<T> {
|
|
|
266
313
|
} else if (serial32Precedes(start, this.#coverageEnd)) {
|
|
267
314
|
return { status: 'stale', reason: `repair block ${start}+${length} precedes known coverage` }
|
|
268
315
|
} else if (start !== this.#coverageEnd) {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
span:
|
|
316
|
+
const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) }
|
|
317
|
+
const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : undefined
|
|
318
|
+
if (lostSsId !== undefined) {
|
|
319
|
+
const holeBlock: IsoBlockRange = { ...gap, span: false }
|
|
320
|
+
this.#holes.push(holeBlock)
|
|
321
|
+
hole = { block: holeBlock, lostSsId }
|
|
322
|
+
} else {
|
|
323
|
+
const spanBlock: IsoBlockRange = { ...gap, span: true }
|
|
324
|
+
span = { block: spanBlock, placed: this.#claim(spanBlock) }
|
|
325
|
+
this.#blocks.push(spanBlock)
|
|
273
326
|
}
|
|
274
|
-
span = { block: spanBlock, placed: this.#claim(spanBlock) }
|
|
275
|
-
this.#blocks.push(spanBlock)
|
|
276
327
|
}
|
|
277
328
|
const block: IsoBlockRange = { start, length, span: false }
|
|
278
329
|
const placed = this.#claim(block)
|
|
279
330
|
this.#blocks.push(block)
|
|
280
331
|
this.#coverageEnd = isoBlockEnd(start, length)
|
|
281
332
|
this.retireBehind(start)
|
|
333
|
+
if (hole !== undefined) return { status: 'placed', block, placed, hole }
|
|
282
334
|
return span === undefined
|
|
283
335
|
? { status: 'placed', block, placed }
|
|
284
336
|
: { status: 'placed', block, placed, span }
|
|
285
337
|
}
|
|
286
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
341
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
342
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
343
|
+
*/
|
|
344
|
+
closeHolesWithin(start: number, length: number): { block: IsoBlockRange; placed: IsoPlacedSource<T>[] }[] {
|
|
345
|
+
const closed: { block: IsoBlockRange; placed: IsoPlacedSource<T>[] }[] = []
|
|
346
|
+
for (const hole of [...this.#holes]) {
|
|
347
|
+
if (!isoBlockContains(start, length, hole.start)) continue
|
|
348
|
+
this.#holes.splice(this.#holes.indexOf(hole), 1)
|
|
349
|
+
const spanBlock: IsoBlockRange = { start: hole.start, length: hole.length, span: true }
|
|
350
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) })
|
|
351
|
+
this.#blocks.push(spanBlock)
|
|
352
|
+
}
|
|
353
|
+
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start))
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** The highest SS_ID in the range no source is held for, or undefined when all are. */
|
|
357
|
+
#highestMissing(start: number, length: number): number | undefined {
|
|
358
|
+
// Every position past the held count cannot all be held: bounded scan.
|
|
359
|
+
const steps = Math.min(length, this.#held.size + 1)
|
|
360
|
+
for (let i = 1; i <= steps; i++) {
|
|
361
|
+
const ssId = serial32Add(start, length - i)
|
|
362
|
+
if (!this.#held.has(ssId)) return ssId
|
|
363
|
+
}
|
|
364
|
+
return undefined
|
|
365
|
+
}
|
|
366
|
+
|
|
287
367
|
/**
|
|
288
368
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
289
369
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -302,6 +382,11 @@ export class IsoBlockLocator<T> {
|
|
|
302
382
|
this.#blocks.splice(i, 1)
|
|
303
383
|
}
|
|
304
384
|
}
|
|
385
|
+
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
386
|
+
const hole = this.#holes[i]!
|
|
387
|
+
const last = serial32Add(hole.start, hole.length - 1)
|
|
388
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1)
|
|
389
|
+
}
|
|
305
390
|
for (const ssId of [...this.#held.keys()]) {
|
|
306
391
|
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId)
|
|
307
392
|
}
|
|
@@ -311,6 +396,7 @@ export class IsoBlockLocator<T> {
|
|
|
311
396
|
/** Forget everything (publisher restart, track reset). */
|
|
312
397
|
reset(): void {
|
|
313
398
|
this.#blocks.length = 0
|
|
399
|
+
this.#holes.length = 0
|
|
314
400
|
this.#held.clear()
|
|
315
401
|
this.#coverageEnd = undefined
|
|
316
402
|
this.#newest = undefined
|
|
@@ -327,3 +413,8 @@ export class IsoBlockLocator<T> {
|
|
|
327
413
|
return placed
|
|
328
414
|
}
|
|
329
415
|
}
|
|
416
|
+
|
|
417
|
+
/** Whether `[aStart, aStart + aLength)` and `[bStart, bStart + bLength)` share an SS_ID. */
|
|
418
|
+
function isoRangesOverlap(aStart: number, aLength: number, bStart: number, bLength: number): boolean {
|
|
419
|
+
return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength
|
|
420
|
+
}
|