@blockcast/mmt-container 2.2.0-main.5da4e39e7fb8 → 2.2.0-main.5e3e277b4606
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/__tests__/test-utils.d.ts +1 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -1
- package/dist/block-policy.d.ts +12 -4
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +148 -19
- package/dist/block-policy.js.map +2 -2
- package/dist/browser-runtime.js +202 -45
- package/dist/browser-runtime.js.map +3 -3
- package/dist/carp-catalog.js.map +1 -1
- package/dist/catalog-network-source.d.ts +1 -17
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +25 -19
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/fec-manager.js +148 -19
- package/dist/fec-manager.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +2 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +1 -0
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +26 -19
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +1 -0
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +3 -1
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.js.map +1 -1
- package/dist/multicast-input.js.map +1 -1
- package/dist/multicast-manager.d.ts +9 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +154 -21
- package/dist/multicast-manager.js.map +2 -2
- package/dist/no-modules.js +26 -19
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +3 -1
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +31 -5
- package/dist/repair-fetch.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +1 -0
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/block-policy.ts +206 -29
- package/src/catalog-network-source.ts +3 -37
- package/src/mmtp-container-parser.ts +3 -0
- package/src/mmtp-router.ts +1 -0
- package/src/multicast-manager.ts +10 -0
- package/src/repair-fetch.ts +46 -6
- package/test-vectors/repair-policy-v1.json +36 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockcast/mmt-container",
|
|
3
|
-
"version": "2.2.0-main.
|
|
3
|
+
"version": "2.2.0-main.5e3e277b4606",
|
|
4
4
|
"description": "MMTP/LOC container parsing for MMT over MoQ and SSM",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -169,10 +169,10 @@
|
|
|
169
169
|
"test:watch": "vitest"
|
|
170
170
|
},
|
|
171
171
|
"dependencies": {
|
|
172
|
-
"@blockcast/fec-worker": "2.2.0-main.
|
|
173
|
-
"@blockcast/mmt-base": "2.2.0-main.
|
|
174
|
-
"@blockcast/mmt-fec": "2.2.0-main.
|
|
175
|
-
"@blockcast/mmt-manifest-verify": "2.2.0-main.
|
|
172
|
+
"@blockcast/fec-worker": "2.2.0-main.5e3e277b4606",
|
|
173
|
+
"@blockcast/mmt-base": "2.2.0-main.5e3e277b4606",
|
|
174
|
+
"@blockcast/mmt-fec": "2.2.0-main.5e3e277b4606",
|
|
175
|
+
"@blockcast/mmt-manifest-verify": "2.2.0-main.5e3e277b4606",
|
|
176
176
|
"@noble/curves": "^1.9.7",
|
|
177
177
|
"@noble/hashes": "^1.8.0",
|
|
178
178
|
"ajv": "^8.17.1",
|
package/src/block-policy.ts
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* Everything here is derived from catalog-authored timing and in-band MMTP
|
|
16
16
|
* evidence. There are no timers, no cadence heuristics, and no defaults: a
|
|
17
17
|
* track whose geometry cannot be derived exactly runs in the defined
|
|
18
|
-
* fail-closed mode `all-protected`, where
|
|
19
|
-
* keyframe-bearing
|
|
18
|
+
* fail-closed mode `all-protected`, where the window rule is off: a block is
|
|
19
|
+
* treated as possibly keyframe-bearing unless a publisher-stated dependent
|
|
20
|
+
* run shows otherwise (the run rule, which needs no catalog geometry).
|
|
20
21
|
*
|
|
21
22
|
* All three players (moqtail, hang, Shaka) consume this one implementation.
|
|
22
23
|
*/
|
|
@@ -164,7 +165,8 @@ function isPositiveFinite(value: number | undefined): value is number {
|
|
|
164
165
|
* Derive the per-track classifier geometry from raw catalog fields.
|
|
165
166
|
*
|
|
166
167
|
* `all-protected` is the policy's defined fail-closed state, not a default:
|
|
167
|
-
* it is returned with the exact reason.
|
|
168
|
+
* it is returned with the exact reason. It turns the window rule off; the
|
|
169
|
+
* run rule can still class a block `delta`. The only throw is for a value the
|
|
168
170
|
* catalog validator already rejects (a non-positive block span).
|
|
169
171
|
*/
|
|
170
172
|
export function deriveBlockClassifierGeometry(
|
|
@@ -286,9 +288,15 @@ export interface SourceSymbolEvidence {
|
|
|
286
288
|
* never mistaken for a source restart.
|
|
287
289
|
*/
|
|
288
290
|
readonly packetSequenceNumber?: number
|
|
291
|
+
/**
|
|
292
|
+
* DU-header `dep_counter`, the sample's dependent run: N above 0 states
|
|
293
|
+
* that the N samples after this one are not RAPs and need it
|
|
294
|
+
* (draft-ramadan-moq-mmt-02 5.3.4). 0 or absent states nothing.
|
|
295
|
+
*/
|
|
296
|
+
readonly depCounter?: number
|
|
289
297
|
}
|
|
290
298
|
|
|
291
|
-
export type ReclassificationEvidence = 'rap' | 'mpu-span' | 'window' | 'classifier-disabled'
|
|
299
|
+
export type ReclassificationEvidence = 'rap' | 'mpu-span' | 'window' | 'dependent-run' | 'classifier-disabled'
|
|
292
300
|
|
|
293
301
|
export type ClassifierChange =
|
|
294
302
|
| {
|
|
@@ -321,6 +329,15 @@ interface DataUnitStart {
|
|
|
321
329
|
readonly sbn: number
|
|
322
330
|
}
|
|
323
331
|
|
|
332
|
+
/** A held DU header as the run rule reads it (fec-multicast-01 6.1). */
|
|
333
|
+
interface RunStart extends DataUnitStart {
|
|
334
|
+
readonly rap: boolean
|
|
335
|
+
/** Its dependent run; 0 states nothing. */
|
|
336
|
+
readonly dep: number
|
|
337
|
+
/** Its MPU position, where the wire proved one when it arrived (P3). */
|
|
338
|
+
readonly position?: number
|
|
339
|
+
}
|
|
340
|
+
|
|
324
341
|
/**
|
|
325
342
|
* Authored order of two data-unit starts of one MPU. Fragment numbers wrap
|
|
326
343
|
* at 2^32, so they compare in RFC 1982 serial order.
|
|
@@ -332,6 +349,18 @@ function compareDataUnitStarts(
|
|
|
332
349
|
return ((a.movieFragment - b.movieFragment) | 0) || a.idx - b.idx || a.offset - b.offset
|
|
333
350
|
}
|
|
334
351
|
|
|
352
|
+
/** The first index of an SBN-ordered list whose block is `sbn` or later. */
|
|
353
|
+
function firstStartAtOrAfter(starts: readonly RunStart[], sbn: number): number {
|
|
354
|
+
let lo = 0
|
|
355
|
+
let hi = starts.length
|
|
356
|
+
while (lo < hi) {
|
|
357
|
+
const mid = (lo + hi) >>> 1
|
|
358
|
+
if (starts[mid]!.sbn < sbn) lo = mid + 1
|
|
359
|
+
else hi = mid
|
|
360
|
+
}
|
|
361
|
+
return lo
|
|
362
|
+
}
|
|
363
|
+
|
|
335
364
|
/**
|
|
336
365
|
* How many MPUs behind the newest released RAP a stale release can be. The
|
|
337
366
|
* release gate holds a frame for seconds at most, so a late copy is a few
|
|
@@ -440,6 +469,15 @@ export class BlockClassifier {
|
|
|
440
469
|
#mpuSbnSpans = new Map<number, { min: number; max: number }>()
|
|
441
470
|
#dataUnitStarts = new Map<number, DataUnitStart[]>()
|
|
442
471
|
#highestMpu: number | null = null
|
|
472
|
+
/**
|
|
473
|
+
* The DU headers held, per MPU in authored order, for the run rule. Kept in
|
|
474
|
+
* every mode (the rule needs no catalog cadence) for the same horizon and
|
|
475
|
+
* the same continuous SBN sequence as the P1 ledger.
|
|
476
|
+
*/
|
|
477
|
+
#runStarts = new Map<number, RunStart[]>()
|
|
478
|
+
#runHighestMpu: number | null = null
|
|
479
|
+
/** Two DU headers of this sequence lay in blocks against their authored order: no run is read. */
|
|
480
|
+
#runOrderRefuted = false
|
|
443
481
|
/**
|
|
444
482
|
* P3 layout, kept for the MPUs within the classification horizon and valid
|
|
445
483
|
* within one continuous SBN sequence (`noteSourceDiscontinuity`).
|
|
@@ -561,6 +599,7 @@ export class BlockClassifier {
|
|
|
561
599
|
if (this.#geometry.trackKind === 'audio') return []
|
|
562
600
|
const changes: ClassifierChange[] = []
|
|
563
601
|
const block = this.#blockFor(sbn)
|
|
602
|
+
const fragmentsCountedSamples = !this.#multiSampleFragment
|
|
564
603
|
const placement = this.#place(evidence)
|
|
565
604
|
|
|
566
605
|
if (evidence.rap) block.rapSeen = true
|
|
@@ -580,20 +619,41 @@ export class BlockClassifier {
|
|
|
580
619
|
const violation = this.#checkInvariants(sbn, block, evidence, placement)
|
|
581
620
|
if (violation !== null) changes.push(...this.#disable(violation))
|
|
582
621
|
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
622
|
+
const orderHeld = !this.#runOrderRefuted
|
|
623
|
+
const bounded = this.#noteRunStart(sbn, evidence, position)
|
|
624
|
+
if (
|
|
625
|
+
(orderHeld && this.#runOrderRefuted) ||
|
|
626
|
+
(fragmentsCountedSamples && this.#multiSampleFragment)
|
|
627
|
+
) {
|
|
628
|
+
// Every class the run rule gave rested on that order, or may have
|
|
629
|
+
// counted fragments as samples: withdraw them; what still holds is
|
|
630
|
+
// classed again as its blocks are seen.
|
|
631
|
+
for (const [other, classed] of this.#blocks) {
|
|
632
|
+
if (classed.cls !== 'delta') continue
|
|
633
|
+
classed.cls = 'unknown'
|
|
634
|
+
changes.push({ kind: 'reclassified', sbn: other, from: 'delta', to: 'unknown', evidence: 'classifier-disabled' })
|
|
635
|
+
}
|
|
593
636
|
}
|
|
637
|
+
this.#reclassify(sbn, block, changes)
|
|
638
|
+
// A DU header bounds the blocks between it and its neighbours: they may
|
|
639
|
+
// have had their last symbol already.
|
|
640
|
+
for (const other of bounded) this.#reclassify(other, this.#blocks.get(other)!, changes)
|
|
594
641
|
return changes
|
|
595
642
|
}
|
|
596
643
|
|
|
644
|
+
#reclassify(sbn: number, block: BlockEvidence, changes: ClassifierChange[]): void {
|
|
645
|
+
const next = this.#classify(block, sbn)
|
|
646
|
+
if (next === block.cls || !this.#allowed(block.cls, next)) return
|
|
647
|
+
changes.push({
|
|
648
|
+
kind: 'reclassified',
|
|
649
|
+
sbn,
|
|
650
|
+
from: block.cls,
|
|
651
|
+
to: next,
|
|
652
|
+
evidence: this.#evidenceFor(block, next),
|
|
653
|
+
})
|
|
654
|
+
block.cls = next
|
|
655
|
+
}
|
|
656
|
+
|
|
597
657
|
/**
|
|
598
658
|
* Record a RAP frame released in order. Released MPU-start RAPs of MPUs m
|
|
599
659
|
* and m+n must be exactly n keyframe intervals apart in the media
|
|
@@ -828,6 +888,9 @@ export class BlockClassifier {
|
|
|
828
888
|
this.#mpuSbnSpans.clear()
|
|
829
889
|
this.#dataUnitStarts.clear()
|
|
830
890
|
this.#highestMpu = null
|
|
891
|
+
this.#runStarts.clear()
|
|
892
|
+
this.#runHighestMpu = null
|
|
893
|
+
this.#runOrderRefuted = false
|
|
831
894
|
}
|
|
832
895
|
|
|
833
896
|
/**
|
|
@@ -924,28 +987,142 @@ export class BlockClassifier {
|
|
|
924
987
|
return changes
|
|
925
988
|
}
|
|
926
989
|
|
|
927
|
-
#classify(block: BlockEvidence): BlockClass {
|
|
990
|
+
#classify(block: BlockEvidence, sbn: number): BlockClass {
|
|
928
991
|
if (block.rapSeen || block.mpus.size >= 2) return 'keyframe'
|
|
929
|
-
|
|
992
|
+
// Only a keyframe or a withdrawal moves a delta block: no symbol re-proves it.
|
|
993
|
+
if (block.cls === 'delta') return 'delta'
|
|
994
|
+
if (this.#windowHolds(block) || this.#runHolds(block, sbn)) return 'delta'
|
|
995
|
+
return 'unknown'
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
#windowHolds(block: BlockEvidence): boolean {
|
|
999
|
+
if (this.#mode === 'all-protected') return false
|
|
930
1000
|
const geometry = this.#geometry
|
|
931
|
-
if (geometry.trackKind !== 'video' || geometry.mode !== 'classifying') return
|
|
1001
|
+
if (geometry.trackKind !== 'video' || geometry.mode !== 'classifying') return false
|
|
932
1002
|
if (
|
|
933
|
-
block.mpus.size
|
|
934
|
-
block.positionMin
|
|
935
|
-
block.positionMax
|
|
1003
|
+
block.mpus.size !== 1 ||
|
|
1004
|
+
block.positionMin === undefined ||
|
|
1005
|
+
block.positionMax === undefined
|
|
936
1006
|
) {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1007
|
+
return false
|
|
1008
|
+
}
|
|
1009
|
+
// A block closes every D media units, so its frames are contiguous and
|
|
1010
|
+
// lie in [positionMax − D + 1, positionMin + D − 1] of MPU m. Position
|
|
1011
|
+
// 0 is the only RAP of an MPU and G bounds its length.
|
|
1012
|
+
const span = geometry.interleaveUnits - 1
|
|
1013
|
+
return block.positionMax - span >= 1 && block.positionMin + span <= geometry.gopFrames - 1
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Record a DU header for the run rule. Returns the other blocks it now
|
|
1018
|
+
* bounds: those between it and the DU headers next to it in authored order.
|
|
1019
|
+
*/
|
|
1020
|
+
#noteRunStart(sbn: number, evidence: SourceSymbolEvidence, position: number | undefined): number[] {
|
|
1021
|
+
const { mpu, idx, movieFragment } = evidence
|
|
1022
|
+
if (
|
|
1023
|
+
this.#geometry.trackKind !== 'video' ||
|
|
1024
|
+
mpu === undefined ||
|
|
1025
|
+
idx === undefined ||
|
|
1026
|
+
movieFragment === undefined
|
|
1027
|
+
) {
|
|
1028
|
+
return []
|
|
1029
|
+
}
|
|
1030
|
+
const start: RunStart = {
|
|
1031
|
+
movieFragment,
|
|
1032
|
+
idx,
|
|
1033
|
+
offset: evidence.offset ?? 0,
|
|
1034
|
+
sbn,
|
|
1035
|
+
rap: evidence.rap,
|
|
1036
|
+
dep: evidence.depCounter ?? 0,
|
|
1037
|
+
...(position === undefined ? {} : { position }),
|
|
1038
|
+
}
|
|
1039
|
+
let starts = this.#runStarts.get(mpu)
|
|
1040
|
+
if (starts === undefined) {
|
|
1041
|
+
starts = []
|
|
1042
|
+
this.#runStarts.set(mpu, starts)
|
|
1043
|
+
}
|
|
1044
|
+
let at = 0
|
|
1045
|
+
let end = starts.length
|
|
1046
|
+
while (at < end) {
|
|
1047
|
+
const mid = (at + end) >>> 1
|
|
1048
|
+
if (compareDataUnitStarts(starts[mid]!, start) < 0) at = mid + 1
|
|
1049
|
+
else end = mid
|
|
1050
|
+
}
|
|
1051
|
+
if (at < starts.length && compareDataUnitStarts(starts[at]!, start) === 0) return []
|
|
1052
|
+
starts.splice(at, 0, start)
|
|
1053
|
+
if (this.#runHighestMpu === null || mpu > this.#runHighestMpu) {
|
|
1054
|
+
this.#runHighestMpu = mpu
|
|
1055
|
+
for (const other of [...this.#runStarts.keys()]) {
|
|
1056
|
+
if (other + 1 < mpu) this.#runStarts.delete(other)
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
const before = starts[at - 1]?.sbn
|
|
1060
|
+
const after = starts[at + 1]?.sbn
|
|
1061
|
+
// Blocks follow authored order (P1); a stream that breaks it has no "before" and "after".
|
|
1062
|
+
if ((before !== undefined && before > sbn) || (after !== undefined && after < sbn)) {
|
|
1063
|
+
this.#runOrderRefuted = true
|
|
1064
|
+
return []
|
|
1065
|
+
}
|
|
1066
|
+
const bounded: number[] = []
|
|
1067
|
+
for (const other of this.#blocks.keys()) {
|
|
941
1068
|
if (
|
|
942
|
-
|
|
943
|
-
|
|
1069
|
+
(before !== undefined && other > before && other < sbn) ||
|
|
1070
|
+
(after !== undefined && other > sbn && other < after)
|
|
944
1071
|
) {
|
|
945
|
-
|
|
1072
|
+
bounded.push(other)
|
|
946
1073
|
}
|
|
947
1074
|
}
|
|
948
|
-
return
|
|
1075
|
+
return bounded
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* The run rule of fec-multicast-01 6.1: the DU header held last before the
|
|
1080
|
+
* block and the one held first after it are in one MPU, the lower one is a
|
|
1081
|
+
* non-RAP sample start, and its dependent run reaches the upper one's
|
|
1082
|
+
* sample. No sample the block can carry is then a RAP.
|
|
1083
|
+
*/
|
|
1084
|
+
#runHolds(block: BlockEvidence, sbn: number): boolean {
|
|
1085
|
+
// shortcut: reads the DU headers of the blocks around this one, not the nearest inside it, so it classes fewer blocks than the draft allows; upgrade when observe() is given symbol positions.
|
|
1086
|
+
if (this.#runOrderRefuted) return false
|
|
1087
|
+
let lower: RunStart | undefined
|
|
1088
|
+
let upper: RunStart | undefined
|
|
1089
|
+
let lowerMpu = 0
|
|
1090
|
+
let upperMpu = 0
|
|
1091
|
+
for (const [mpu, starts] of this.#runStarts) {
|
|
1092
|
+
// While the order holds, sbn never decreases along a list: split it at this block.
|
|
1093
|
+
const before = firstStartAtOrAfter(starts, sbn)
|
|
1094
|
+
const after = firstStartAtOrAfter(starts, sbn + 1)
|
|
1095
|
+
if (before > 0 && (lower === undefined || mpu >= lowerMpu)) {
|
|
1096
|
+
lower = starts[before - 1]!
|
|
1097
|
+
lowerMpu = mpu
|
|
1098
|
+
}
|
|
1099
|
+
if (after < starts.length && (upper === undefined || mpu < upperMpu)) {
|
|
1100
|
+
upper = starts[after]!
|
|
1101
|
+
upperMpu = mpu
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
if (lower === undefined || upper === undefined || lowerMpu !== upperMpu) return false
|
|
1105
|
+
if (block.mpus.size === 1 && !block.mpus.has(lowerMpu)) return false
|
|
1106
|
+
if (lower.offset !== 0 || lower.rap || lower.dep < 1) return false
|
|
1107
|
+
let samples: number
|
|
1108
|
+
if (lower.movieFragment === upper.movieFragment) samples = upper.idx - lower.idx
|
|
1109
|
+
else if (!this.#multiSampleFragment) {
|
|
1110
|
+
// Every header so far stated sample_number 1: fragment numbers count samples.
|
|
1111
|
+
samples = (upper.movieFragment - lower.movieFragment) >>> 0
|
|
1112
|
+
} else return false
|
|
1113
|
+
if (samples < 0 || samples > lower.dep) return false
|
|
1114
|
+
// The catalog interval wins where it places a keyframe between the two (6.1 item 3).
|
|
1115
|
+
const geometry = this.#geometry
|
|
1116
|
+
if (
|
|
1117
|
+
geometry.trackKind === 'video' &&
|
|
1118
|
+
geometry.mode === 'classifying' &&
|
|
1119
|
+
lower.position !== undefined &&
|
|
1120
|
+
upper.position !== undefined &&
|
|
1121
|
+
Math.floor(upper.position / geometry.gopFrames) > Math.floor(lower.position / geometry.gopFrames)
|
|
1122
|
+
) {
|
|
1123
|
+
return false
|
|
1124
|
+
}
|
|
1125
|
+
return true
|
|
949
1126
|
}
|
|
950
1127
|
|
|
951
1128
|
#allowed(from: BlockClass, to: BlockClass): boolean {
|
|
@@ -956,7 +1133,7 @@ export class BlockClassifier {
|
|
|
956
1133
|
}
|
|
957
1134
|
|
|
958
1135
|
#evidenceFor(block: BlockEvidence, to: BlockClass): ReclassificationEvidence {
|
|
959
|
-
if (to === 'delta') return 'window'
|
|
1136
|
+
if (to === 'delta') return this.#windowHolds(block) ? 'window' : 'dependent-run'
|
|
960
1137
|
return block.rapSeen ? 'rap' : 'mpu-span'
|
|
961
1138
|
}
|
|
962
1139
|
}
|
|
@@ -77,40 +77,6 @@ export function catalogAmtNetworkSource(networkSource: unknown): AmtNetworkSourc
|
|
|
77
77
|
return undefined;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
frequency: number;
|
|
84
|
-
plpId?: number;
|
|
85
|
-
serviceId?: number;
|
|
86
|
-
/** SLS of the MMTP service; libmmt does not fetch it. */
|
|
87
|
-
slsUri?: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
function intIn(value: unknown, min: number, max: number): value is number {
|
|
91
|
-
return Number.isInteger(value) && (value as number) >= min && (value as number) <= max;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Resolve ATSC 3.0 tuning from a catalog `networkSource` (array or bare-object
|
|
96
|
-
* form): the first `type: "atsc3"` entry with a positive integer `frequency`
|
|
97
|
-
* (kHz). Optional fields are carried only when in range; an entry with no
|
|
98
|
-
* usable frequency is skipped, since it names nothing a tuner can lock to.
|
|
99
|
-
* Draft -01 3 puts the tuner first, so callers prefer this over AMT.
|
|
100
|
-
*/
|
|
101
|
-
export function catalogAtsc3NetworkSource(networkSource: unknown): Atsc3NetworkSource | undefined {
|
|
102
|
-
const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
|
|
103
|
-
for (const raw of entries) {
|
|
104
|
-
if (!raw || typeof raw !== "object") continue;
|
|
105
|
-
const ns = raw as CatalogNetworkSource;
|
|
106
|
-
if (ns.type !== "atsc3" || !intIn(ns.frequency, 1, Number.MAX_SAFE_INTEGER)) continue;
|
|
107
|
-
const slsUri = typeof ns.slsUri === "string" ? ns.slsUri.trim() : "";
|
|
108
|
-
return {
|
|
109
|
-
frequency: ns.frequency,
|
|
110
|
-
...(intIn(ns.plpId, 0, 63) ? { plpId: ns.plpId } : {}),
|
|
111
|
-
...(intIn(ns.serviceId, 0, 65535) ? { serviceId: ns.serviceId } : {}),
|
|
112
|
-
...(slsUri ? { slsUri } : {}),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
80
|
+
// ATSC 3.0 tuning (draft -01 4.2.2/4.2.3) is read in `@blockcast/mmt-base`, so
|
|
81
|
+
// the transport's `endpointToMulticastConfig` shares this one reader.
|
|
82
|
+
export { catalogAtsc3NetworkSource, type Atsc3NetworkSource } from "@blockcast/mmt-base";
|
|
@@ -201,6 +201,8 @@ export interface SourcePacketIdentity {
|
|
|
201
201
|
movieFragmentSequenceNumber?: number
|
|
202
202
|
/** DU-header offset: the data unit's authored byte position in its sample. */
|
|
203
203
|
offset?: number
|
|
204
|
+
/** DU-header dep_counter, when this packet carries a DU header. */
|
|
205
|
+
dependencyCounter?: number
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
/**
|
|
@@ -1706,6 +1708,7 @@ export class MmtpContainerParser {
|
|
|
1706
1708
|
identity.sampleNumber = extraction.mfuDuHeader.sampleNumber
|
|
1707
1709
|
identity.movieFragmentSequenceNumber = extraction.mfuDuHeader.movieFragmentSequenceNumber
|
|
1708
1710
|
identity.offset = extraction.mfuDuHeader.offset
|
|
1711
|
+
identity.dependencyCounter = extraction.mfuDuHeader.dependencyCounter
|
|
1709
1712
|
}
|
|
1710
1713
|
return identity
|
|
1711
1714
|
} catch {
|
package/src/mmtp-router.ts
CHANGED
|
@@ -1111,6 +1111,7 @@ function sourceSymbolEvidence(
|
|
|
1111
1111
|
? { movieFragment: identity.movieFragmentSequenceNumber }
|
|
1112
1112
|
: {}),
|
|
1113
1113
|
...(identity?.offset !== undefined ? { offset: identity.offset } : {}),
|
|
1114
|
+
...(identity?.dependencyCounter ? { depCounter: identity.dependencyCounter } : {}),
|
|
1114
1115
|
};
|
|
1115
1116
|
}
|
|
1116
1117
|
|
package/src/multicast-manager.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface MulticastRepairEndpoint {
|
|
|
102
102
|
amtRelayPort?: number;
|
|
103
103
|
/** The media join's `'driad'` discovery (no relay pinned), carried so the repair group rides the same relay. */
|
|
104
104
|
amtDiscovery?: 'driad';
|
|
105
|
+
/** The media join's ATSC 3.0 tuning, carried so the repair group rides the same RF channel. */
|
|
106
|
+
atsc3?: MulticastTransportConfig["atsc3"];
|
|
105
107
|
/** The repair packet IDs this group carries. */
|
|
106
108
|
packetIds: number[];
|
|
107
109
|
/** Each repair packet ID bound to the media packet ID it repairs. */
|
|
@@ -174,6 +176,12 @@ export interface MulticastEndpointConfig {
|
|
|
174
176
|
* Ignored when `amtRelay` is set.
|
|
175
177
|
*/
|
|
176
178
|
amtDiscovery?: 'driad';
|
|
179
|
+
/**
|
|
180
|
+
* ATSC 3.0 tuning from the catalog's `atsc3` networkSource
|
|
181
|
+
* (`endpointToMulticastConfig` → `PlayerMulticastConfig.atsc3`). Set, the
|
|
182
|
+
* join is the tuner member (draft -01 3) and relay/mode are not consulted.
|
|
183
|
+
*/
|
|
184
|
+
atsc3?: MulticastTransportConfig["atsc3"];
|
|
177
185
|
/** MMTP packet IDs to forward before data enters the page transport queue. */
|
|
178
186
|
packetIds?: number[];
|
|
179
187
|
/** Exact catalog tracks carried by this physical multicast endpoint. */
|
|
@@ -2401,6 +2409,7 @@ export class MulticastManager {
|
|
|
2401
2409
|
config.relayPort ??
|
|
2402
2410
|
(amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
|
|
2403
2411
|
amtDiscovery: config.amtDiscovery,
|
|
2412
|
+
atsc3: config.atsc3,
|
|
2404
2413
|
packetIds: config.packetIds,
|
|
2405
2414
|
tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId })),
|
|
2406
2415
|
...(provenance === undefined ? {} : { protected: true }),
|
|
@@ -2586,6 +2595,7 @@ export class MulticastManager {
|
|
|
2586
2595
|
amtRelay: endpoint.amtRelay,
|
|
2587
2596
|
amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
|
|
2588
2597
|
amtDiscovery: endpoint.amtDiscovery,
|
|
2598
|
+
atsc3: endpoint.atsc3,
|
|
2589
2599
|
packetIds: endpoint.packetIds,
|
|
2590
2600
|
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
|
|
2591
2601
|
// A protected repair group's records ride in band on its port (7.2.3).
|
package/src/repair-fetch.ts
CHANGED
|
@@ -103,7 +103,9 @@
|
|
|
103
103
|
* A FETCH landing after the gate forced that frame out would recover media
|
|
104
104
|
* the gate then drops as stale.
|
|
105
105
|
*
|
|
106
|
-
* The scheduler arms no timers for block requests
|
|
106
|
+
* The scheduler arms no timers for block requests but one: a running P0
|
|
107
|
+
* FETCH below a RAP held complete gets a timer at its playout deadline, when
|
|
108
|
+
* it turns moot (§6.2.1). A fetch ends when its
|
|
107
109
|
* transport completes or throws, when it is preempted, when any later
|
|
108
110
|
* scheduling event finds it past its presentation deadline, when its block
|
|
109
111
|
* resolves (recovered, or failed at that deadline), on track reset, or on
|
|
@@ -638,6 +640,8 @@ interface FetchRun {
|
|
|
638
640
|
/** When this FETCH went out: it lands around `sentAt + rtt`. */
|
|
639
641
|
readonly sentAt: number
|
|
640
642
|
stopped: StopReason | null
|
|
643
|
+
/** Set while a RAP above the block is held complete: fires at the playout deadline (mootAtPlayout). */
|
|
644
|
+
mootTimer?: ReturnType<typeof setTimeout>
|
|
641
645
|
}
|
|
642
646
|
|
|
643
647
|
interface RepairEntry {
|
|
@@ -785,6 +789,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
785
789
|
const run = entry.running
|
|
786
790
|
if (!run) return
|
|
787
791
|
entry.running = null
|
|
792
|
+
if (run.mootTimer !== undefined) clearTimeout(run.mootTimer)
|
|
788
793
|
run.stopped = reason
|
|
789
794
|
run.controller.abort(reason)
|
|
790
795
|
// A preempted request returns to the queue; until it runs again nothing is
|
|
@@ -825,6 +830,41 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
825
830
|
}
|
|
826
831
|
}
|
|
827
832
|
|
|
833
|
+
/** Cancel a running FETCH that turned moot. */
|
|
834
|
+
const dropMoot = (entry: RepairEntry): void => {
|
|
835
|
+
stop(entry, 'moot')
|
|
836
|
+
retire(entry)
|
|
837
|
+
releaseHold(entry)
|
|
838
|
+
clearEntry(entry)
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Moot is a state (§6.2.1 condition 1: a RAP already admitted complete), so
|
|
843
|
+
* a running keyframe FETCH kept only because it could land by playout turns
|
|
844
|
+
* moot when that deadline passes, with no newer RAP: arm one timer for it
|
|
845
|
+
* then. None is armed while no RAP above the block is held complete.
|
|
846
|
+
*/
|
|
847
|
+
const mootAtPlayout = (entry: RepairEntry): void => {
|
|
848
|
+
const run = entry.running
|
|
849
|
+
if (run === null || run.mootTimer !== undefined || entry.priority !== 0) return
|
|
850
|
+
const last = lastSsId(entry)
|
|
851
|
+
if (last === undefined) return
|
|
852
|
+
try {
|
|
853
|
+
if (mc.rapCompleteAbove?.(entry.packetId, entry.catalogTrackName, last) !== true) return
|
|
854
|
+
} catch {
|
|
855
|
+
return
|
|
856
|
+
}
|
|
857
|
+
run.mootTimer = setTimeout(() => {
|
|
858
|
+
run.mootTimer = undefined
|
|
859
|
+
if (disposed || entry.running !== run) return
|
|
860
|
+
// The deadline moved later (a reclassified block), or the timer ran early.
|
|
861
|
+
if (performance.now() < entry.playoutDeadlineAt) return mootAtPlayout(entry)
|
|
862
|
+
if (!moot(entry)) return
|
|
863
|
+
dropMoot(entry)
|
|
864
|
+
dispatch()
|
|
865
|
+
}, Math.max(0, entry.playoutDeadlineAt - performance.now()))
|
|
866
|
+
}
|
|
867
|
+
|
|
828
868
|
/** Drop a request no FETCH will be sent for, and say why. */
|
|
829
869
|
const skip = (entry: RepairEntry, reason: RepairSkipReason, rttMs: number | null, budgetMs: number): void => {
|
|
830
870
|
retire(entry)
|
|
@@ -1000,6 +1040,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
1000
1040
|
})
|
|
1001
1041
|
const run: FetchRun = { controller: new AbortController(), sentAt: now, stopped: null }
|
|
1002
1042
|
entry.running = run
|
|
1043
|
+
mootAtPlayout(entry)
|
|
1003
1044
|
// Hold the block open to the presentation deadline while this FETCH can
|
|
1004
1045
|
// still land: the multicast span elapsing must not abort it.
|
|
1005
1046
|
if (!entry.range) {
|
|
@@ -1132,6 +1173,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
1132
1173
|
return
|
|
1133
1174
|
}
|
|
1134
1175
|
entry.running = null
|
|
1176
|
+
if (run.mootTimer !== undefined) clearTimeout(run.mootTimer)
|
|
1135
1177
|
if (error === undefined) {
|
|
1136
1178
|
retire(entry)
|
|
1137
1179
|
// A fetch that ended without feeding anything cannot resolve the block;
|
|
@@ -1718,11 +1760,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
|
|
|
1718
1760
|
queueMicrotask(() => {
|
|
1719
1761
|
if (disposed) return
|
|
1720
1762
|
for (const entry of [...entries.values()]) {
|
|
1721
|
-
if (entry.packetId !== packetId || !entry.running
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
releaseHold(entry)
|
|
1725
|
-
clearEntry(entry)
|
|
1763
|
+
if (entry.packetId !== packetId || !entry.running) continue
|
|
1764
|
+
if (moot(entry)) dropMoot(entry)
|
|
1765
|
+
else mootAtPlayout(entry)
|
|
1726
1766
|
}
|
|
1727
1767
|
dispatch()
|
|
1728
1768
|
})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
3
|
-
"description": "Receiver repair policy (draft-ramadan-moq-fec-multicast-01 Section 6.2.1 at Blockcast/moqcast-draft main 6293fff (PR #29), which narrows fec-01 Section 11.4.2, and fec-01 Section 11.4.5 item 3, Blockcast/moqcast-draft PR #2 @ 3162ef93). Which repair FETCHes a receiver sends, which it cancels, and which it never sends. Hand-authored from the specification, NOT generated by any implementation (BLO-49776; version 2: BLO-51662).",
|
|
2
|
+
"version": 3,
|
|
3
|
+
"description": "Receiver repair policy (draft-ramadan-moq-fec-multicast-01 Section 6.2.1 at Blockcast/moqcast-draft main 6293fff (PR #29), which narrows fec-01 Section 11.4.2, and fec-01 Section 11.4.5 item 3, Blockcast/moqcast-draft PR #2 @ 3162ef93). Which repair FETCHes a receiver sends, which it cancels, and which it never sends. Hand-authored from the specification, NOT generated by any implementation (BLO-49776; version 2: BLO-51662; version 3: BLO-56030).",
|
|
4
4
|
"scope": [
|
|
5
5
|
"Section 11.4 applies only to a multicast or AMT leg with a MoQ session (fec-01 11.4). These cases describe that leg; a receiver with no repair FETCH path records ABSENT, not a pass.",
|
|
6
6
|
"schedulerCases drive a repair scheduler. Every block spans K' = 4 SS_IDs, so block B covers SS_IDs B..B+3. Track video is a source track (packetId 1, keyframe or delta blocks); track audio is packetId 2 (audio blocks). A block is named track/SS_Start.",
|
|
7
7
|
"Best-effort (delta and audio) requests in schedulerCases are presumed covered by unexpired credit under fec-01 11.4.5 item 2; that credit is a precondition of each case, not something the case exercises.",
|
|
8
8
|
"A RAP 'held complete at ssId' is a keyframe access unit at SS_ID ssId that the receiver has admitted complete (fec-multicast-01 6.2.1 condition 1). A block lies below it when the block's last SS_ID is less than ssId; a RAP at or inside the block does not make the block moot.",
|
|
9
9
|
"fec-multicast-01 6.2.1 condition 2: a keyframe repair is moot only when it also cannot arrive by the block's playout deadline, which is the later of the block's FEC deadline and the presentation time of the earliest media the block would repair, and excludes the keyframe-budget hold (the time a receiver holds video presentation for the repair). It cannot arrive when the current time is not earlier than that deadline, or T + RTT is not earlier than it (T: the FETCH's send time, or now for a repair not yet requested; RTT: the receiver's current round-trip estimate for the repair connection), or the receiver has no RTT estimate.",
|
|
10
|
-
"Every schedulerCase names its regime, which fixes RTT and deadlines; the clock starts at 0 when the case starts and every block's media is anchored at the time its request is made. 'playout': RTT 1 ms, playout deadline 1 s after the request, keyframe-budget hold to 5 s, so every repair lands by playout. 'budget': RTT 2 s and the same 1 s playout deadline and 5 s hold for blocks below SS_ID 16, so a repair of such a block can only land within the hold; blocks from SS_ID 16 up are anchored 2 s later and land by playout. 'rtt-unmeasured': the 'playout' regime with no RTT estimate. Op 'clock' moves the clock: at 'arrival-cutoff' (999.5 ms) a repair sent at 0 still lands by its playout deadline but one requested now would not; at 'playout-deadline' (1 s) the playout deadline of a block requested at 0 has passed.",
|
|
10
|
+
"Every schedulerCase names its regime, which fixes RTT and deadlines; the clock starts at 0 when the case starts and every block's media is anchored at the time its request is made. 'playout': RTT 1 ms, playout deadline 1 s after the request, keyframe-budget hold to 5 s, so every repair lands by playout. 'budget': RTT 2 s and the same 1 s playout deadline and 5 s hold for blocks below SS_ID 16, so a repair of such a block can only land within the hold; blocks from SS_ID 16 up are anchored 2 s later and land by playout. 'rtt-unmeasured': the 'playout' regime with no RTT estimate. Op 'clock' moves the clock, and the receiver acts on whatever falls due by then: at 'arrival-cutoff' (999.5 ms) a repair sent at 0 still lands by its playout deadline but one requested now would not; at 'playout-deadline' (1 s) the playout deadline of a block requested at 0 has passed.",
|
|
11
11
|
"fetched lists every FETCH the receiver sends, in order. cancelled lists every sent FETCH it then cancels (FETCH_CANCEL on the wire). skipped names requests made but not sent, with the receiver's reason; stopped names sent FETCHes stopped, with the stop reason. A list not given is expected empty.",
|
|
12
12
|
"assistedCases drive one block of a protected flow (multicast-01 7.2.7) that is one symbol short of SSB_length, with unlisted repair symbols pooled for it. Each unlisted symbol triggers one unlisted-assisted decode in a scratch decoder; outcome 'fail' is a failed decode, 'recover' a decode whose recovered data unit admission accepts, 'recover-unadmitted' a decode whose recovered data unit admission refuses.",
|
|
13
13
|
"status names where a case's rule comes from: 'fec-01' is a -01 requirement; 'fec-multicast-01' is the 6.2.1 narrowing (moqcast-draft main 6293fff); 'libmmt interpretation' is our reading where the draft is silent; 'regression' rows were already required at moqcast-draft main 615a9a8 and are kept to pin standing behaviour.",
|
|
@@ -118,6 +118,39 @@
|
|
|
118
118
|
"stopped": [{ "block": "video/0", "reason": "moot" }]
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
|
+
{
|
|
122
|
+
"name": "outstanding-repair-moot-at-playout-deadline",
|
|
123
|
+
"status": "fec-multicast-01",
|
|
124
|
+
"regime": "playout",
|
|
125
|
+
"rule": "fec-multicast-01 6.2.1 defines moot as a state (condition 1: a RAP already admitted complete), not as the event of a RAP being admitted. A RAP admitted complete at 999.5 ms keeps a repair sent at 0 that lands by playout; when the playout deadline passes with that RAP still held complete, the repair is moot from then on, with no newer RAP, and the receiver cancels it at that deadline.",
|
|
126
|
+
"ops": [
|
|
127
|
+
{ "op": "fire", "track": "video", "block": 0, "class": "keyframe" },
|
|
128
|
+
{ "op": "clock", "at": "arrival-cutoff" },
|
|
129
|
+
{ "op": "rapComplete", "ssId": 5 },
|
|
130
|
+
{ "op": "clock", "at": "playout-deadline" }
|
|
131
|
+
],
|
|
132
|
+
"expect": {
|
|
133
|
+
"fetched": ["video/0"],
|
|
134
|
+
"cancelled": ["video/0"],
|
|
135
|
+
"stopped": [{ "block": "video/0", "reason": "moot" }]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "repair-below-held-rap-moot-at-playout-deadline",
|
|
140
|
+
"status": "fec-multicast-01",
|
|
141
|
+
"regime": "playout",
|
|
142
|
+
"rule": "fec-multicast-01 6.2.1: a keyframe repair requested below a RAP already held complete is sent while it can land by playout, and is moot once that deadline passes with the RAP still held, so the receiver cancels it at that deadline.",
|
|
143
|
+
"ops": [
|
|
144
|
+
{ "op": "rapHeld", "ssId": 4 },
|
|
145
|
+
{ "op": "fire", "track": "video", "block": 0, "class": "keyframe" },
|
|
146
|
+
{ "op": "clock", "at": "playout-deadline" }
|
|
147
|
+
],
|
|
148
|
+
"expect": {
|
|
149
|
+
"fetched": ["video/0"],
|
|
150
|
+
"cancelled": ["video/0"],
|
|
151
|
+
"stopped": [{ "block": "video/0", "reason": "moot" }]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
121
154
|
{
|
|
122
155
|
"name": "rtt-unmeasured-keyframe-below-complete-rap-is-moot",
|
|
123
156
|
"status": "fec-multicast-01",
|