@blockcast/mmt-base 2.1.0 → 2.2.0-main.01db56d91e37
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 +1 -1
- package/dist/datagram-leg-size.d.ts +30 -0
- package/dist/datagram-leg-size.d.ts.map +1 -0
- package/dist/datagram-leg-size.js +42 -0
- package/dist/datagram-leg-size.js.map +1 -0
- package/dist/fec-bindings.d.ts +13 -1
- package/dist/fec-bindings.d.ts.map +1 -1
- package/dist/fec-bindings.js +29 -6
- package/dist/fec-bindings.js.map +1 -1
- package/dist/fec-catalog.d.ts +4 -1
- package/dist/fec-catalog.d.ts.map +1 -1
- package/dist/fec-catalog.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mmtp-siblings.d.ts +49 -0
- package/dist/mmtp-siblings.d.ts.map +1 -0
- package/dist/mmtp-siblings.js +141 -0
- package/dist/mmtp-siblings.js.map +1 -0
- package/dist/mmtp.d.ts +0 -13
- package/dist/mmtp.d.ts.map +1 -1
- package/dist/mmtp.js +13 -21
- package/dist/mmtp.js.map +1 -1
- package/dist/multicast-catalog.d.ts.map +1 -1
- package/dist/multicast-catalog.js +11 -2
- package/dist/multicast-catalog.js.map +1 -1
- package/dist/signalling.d.ts +8 -6
- package/dist/signalling.d.ts.map +1 -1
- package/dist/signalling.js +7 -5
- package/dist/signalling.js.map +1 -1
- package/package.json +1 -1
- package/src/datagram-leg-size.ts +46 -0
- package/src/fec-bindings.ts +43 -7
- package/src/fec-catalog.ts +4 -1
- package/src/index.ts +2 -0
- package/src/mmtp-siblings.ts +160 -0
- package/src/mmtp.ts +15 -37
- package/src/multicast-catalog.ts +10 -1
- package/src/signalling.ts +9 -7
package/src/fec-bindings.ts
CHANGED
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
* track anything. A draft-01 object `fec` is `fec_member` at that track's
|
|
22
22
|
* `fec`: the track plays without FEC.
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
validateFecCatalog,
|
|
26
|
+
type FecCatalogCode,
|
|
27
|
+
type FecCatalogIssue,
|
|
28
|
+
type FecCatalogReceiver,
|
|
29
|
+
type FecCatalogReport,
|
|
30
|
+
} from './fec-catalog.js'
|
|
25
31
|
|
|
26
32
|
/** The receiver this runtime is: it decodes `iso-ssbg1-v1` only. */
|
|
27
33
|
export const RUNTIME_FEC_RECEIVER: FecCatalogReceiver = Object.freeze({
|
|
@@ -163,6 +169,41 @@ export function fecCatalogTracks(catalog: unknown): { tracks: unknown[]; pointer
|
|
|
163
169
|
return { tracks, pointers }
|
|
164
170
|
}
|
|
165
171
|
|
|
172
|
+
function runtimeView(catalog: unknown, receiver: FecCatalogReceiver) {
|
|
173
|
+
const { tracks, pointers } = fecCatalogTracks(catalog)
|
|
174
|
+
const report = validateFecCatalog({ tracks }, receiver)
|
|
175
|
+
const at = (path: string) => {
|
|
176
|
+
const m = /^\/tracks\/(\d+)(.*)$/.exec(path)
|
|
177
|
+
return m ? pointers[Number(m[1])] + m[2] : path
|
|
178
|
+
}
|
|
179
|
+
return { tracks, pointers, report, at }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The `validateFecCatalog` report `resolveFecBindings` acts on (BLO-55242):
|
|
184
|
+
* the same `tracks[]` view and the same receiver, so a host publishing it
|
|
185
|
+
* cannot disagree with what the runtime does. Paths are JSON Pointers into
|
|
186
|
+
* the original catalog (a hang path starts `/video`, `/audio` or `/repair`).
|
|
187
|
+
* One kind does not resolve: a hang layer 0 repair track with no
|
|
188
|
+
* `repair.renditions` entry stands at the `repairTrack` string that names it
|
|
189
|
+
* (`.../fec/<j>/repairTrack`), so a path below that track names nothing in
|
|
190
|
+
* the catalog. The track indices (`trackIndex`, `repairTrack`,
|
|
191
|
+
* `boundRepairTracks`, `symbolTrack`) index `fecCatalogTracks(catalog).tracks`.
|
|
192
|
+
*/
|
|
193
|
+
export function runtimeFecCatalogReport(
|
|
194
|
+
catalog: unknown,
|
|
195
|
+
receiver: FecCatalogReceiver = RUNTIME_FEC_RECEIVER,
|
|
196
|
+
): FecCatalogReport {
|
|
197
|
+
const { report, at } = runtimeView(catalog, receiver)
|
|
198
|
+
const issue = (i: FecCatalogIssue) => Object.freeze({ code: i.code, path: at(i.path) })
|
|
199
|
+
return Object.freeze({
|
|
200
|
+
instances: Object.freeze(
|
|
201
|
+
report.instances.map((i) => Object.freeze({ ...i, path: at(i.path), issues: Object.freeze(i.issues.map(issue)) })),
|
|
202
|
+
),
|
|
203
|
+
issues: Object.freeze(report.issues.map(issue)),
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
166
207
|
/**
|
|
167
208
|
* Every source track's runtime FEC binding, by track name. A track with no
|
|
168
209
|
* `fec`, or an empty `fec` array, declares no FEC and has no entry.
|
|
@@ -171,12 +212,7 @@ export function resolveFecBindings(
|
|
|
171
212
|
catalog: unknown,
|
|
172
213
|
receiver: FecCatalogReceiver = RUNTIME_FEC_RECEIVER,
|
|
173
214
|
): ReadonlyMap<string, FecSourceBinding> {
|
|
174
|
-
const { tracks, pointers } =
|
|
175
|
-
const report = validateFecCatalog({ tracks }, receiver)
|
|
176
|
-
const at = (path: string) => {
|
|
177
|
-
const m = /^\/tracks\/(\d+)(.*)$/.exec(path)
|
|
178
|
-
return m ? pointers[Number(m[1])] + m[2] : path
|
|
179
|
-
}
|
|
215
|
+
const { tracks, pointers, report, at } = runtimeView(catalog, receiver)
|
|
180
216
|
const trackAt = (i: number) => recordOf(tracks[i]) ?? {}
|
|
181
217
|
const nameAt = (i: number | null) => (i === null ? undefined : (trackAt(i)['name'] as string))
|
|
182
218
|
const why = (i: { outcome: string; issues: readonly { code: FecCatalogCode; path: string }[]; path: string }) =>
|
package/src/fec-catalog.ts
CHANGED
|
@@ -51,7 +51,10 @@ export interface FecCatalogIssue {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface FecCatalogInstance {
|
|
54
|
-
/** JSON Pointer of the instance object
|
|
54
|
+
/** JSON Pointer of the instance object. `validateFecCatalog` gives
|
|
55
|
+
* `/tracks/<i>/fec/<j>`; `runtimeFecCatalogReport` gives the pointer in the
|
|
56
|
+
* original catalog, which for hang is `/video/renditions/<name>/fec/<j>`
|
|
57
|
+
* (or under `/audio`). Read the track from `trackIndex`, not from the path. */
|
|
55
58
|
readonly path: string;
|
|
56
59
|
readonly track: string | null;
|
|
57
60
|
/** Resolved Instance ID; null when `instanceId` is malformed. */
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// The mmtp track modes of draft-ramadan-moq-mmt-02 13.1 and the pairing of
|
|
2
|
+
// an "mfu-datagram" track with the "mfu" track it mirrors (4.3.1).
|
|
3
|
+
//
|
|
4
|
+
// A publisher MUST NOT publish an "mfu-datagram" track without an "mfu" track
|
|
5
|
+
// of the same namespace whose objects are identical in Group ID, Object ID
|
|
6
|
+
// and payload. The catalog carries no sibling pointer, so the pair is read
|
|
7
|
+
// from what the two entries state: they are siblings when their whole
|
|
8
|
+
// identity set is equal, field by field or absent on both. The identity set
|
|
9
|
+
// is the hard set (what the Group and Object IDs are derived from) and the
|
|
10
|
+
// rendition fields of mmt-02 13.1 (one payload has one codec, size, bitrate
|
|
11
|
+
// and language; the rungs of a ladder share the hard set, so nothing else
|
|
12
|
+
// tells them apart). A datagram track with no sibling, or more than one, is
|
|
13
|
+
// rejected and the player plays "mfu". The soft set is reported, never a
|
|
14
|
+
// fault. Names, roles and labels are not read: fec-catalog-00 makes names
|
|
15
|
+
// non-normative. Known limit: two "mfu" tracks with one description cannot
|
|
16
|
+
// carry datagram siblings until the draft defines a pointer.
|
|
17
|
+
//
|
|
18
|
+
// The rule is a per-pair predicate: it answers the same over the whole
|
|
19
|
+
// catalog and over any subset of it a consumer kept.
|
|
20
|
+
|
|
21
|
+
/** Every mmtpMode this library accepts (mmt-02 13.1). Anything else rejects the track. */
|
|
22
|
+
export const MMTP_MODES = Object.freeze(['mfu', 'mfu-datagram'] as const)
|
|
23
|
+
|
|
24
|
+
export type MmtpMode = (typeof MMTP_MODES)[number]
|
|
25
|
+
|
|
26
|
+
export function isMmtpMode(value: unknown): value is MmtpMode {
|
|
27
|
+
return typeof value === 'string' && (MMTP_MODES as readonly string[]).includes(value)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fields the Group and Object IDs of an mmtp track are derived from: two
|
|
32
|
+
* tracks whose values differ cannot carry identical ids (mmt-02 4.4.2, 4.6).
|
|
33
|
+
* Compared equal-or-both-absent, group duration as resolved ticks.
|
|
34
|
+
*/
|
|
35
|
+
export const MMTP_SIBLING_HARD_FIELDS = Object.freeze([
|
|
36
|
+
'namespace',
|
|
37
|
+
'timescale',
|
|
38
|
+
'presentationAnchorTicks',
|
|
39
|
+
'groupDuration',
|
|
40
|
+
] as const)
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Fields that describe the media a track carries. The pair carries one
|
|
44
|
+
* payload (mmt-02 4.3.1), so it has one description: an "mfu" track whose
|
|
45
|
+
* description differs is another rendition. The rungs of a ladder share the
|
|
46
|
+
* hard set and nothing else in the catalog tells them apart. Compared
|
|
47
|
+
* equal-or-both-absent, like the hard set.
|
|
48
|
+
*/
|
|
49
|
+
export const MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([
|
|
50
|
+
'codec',
|
|
51
|
+
'width',
|
|
52
|
+
'height',
|
|
53
|
+
'framerate',
|
|
54
|
+
'bitrate',
|
|
55
|
+
'samplerate',
|
|
56
|
+
'channelConfig',
|
|
57
|
+
'lang',
|
|
58
|
+
] as const)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Fields the pair SHOULD share; a mismatch is reported, not a fault. A soft
|
|
62
|
+
* field is read from the entry of the track subscribed, never borrowed from
|
|
63
|
+
* its sibling: a leg takes the keyframe interval its "mfu-datagram" entry
|
|
64
|
+
* states, and none when that entry states none (mmt-02 4.4.3).
|
|
65
|
+
*/
|
|
66
|
+
export const MMTP_SIBLING_SOFT_FIELDS = Object.freeze([
|
|
67
|
+
'initRef',
|
|
68
|
+
'keyframeIntervalMs',
|
|
69
|
+
'keyframeIntervalTicks',
|
|
70
|
+
'isLive',
|
|
71
|
+
'altGroup',
|
|
72
|
+
] as const)
|
|
73
|
+
|
|
74
|
+
export interface MmtpSiblingPair<T> {
|
|
75
|
+
/** The "mfu" track. */
|
|
76
|
+
readonly stream: T
|
|
77
|
+
/** Its "mfu-datagram" sibling, when the catalog carries exactly one. */
|
|
78
|
+
readonly datagram?: T
|
|
79
|
+
/** Soft-set fields on which the two differ (empty without a datagram sibling). */
|
|
80
|
+
readonly softMismatches: readonly string[]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type Fields = Record<string, unknown>
|
|
84
|
+
|
|
85
|
+
function fields(track: object): Fields {
|
|
86
|
+
return track as Fields
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function groupDurationTicks(track: Fields): bigint | undefined {
|
|
90
|
+
const ticks = track['groupDurationTicks']
|
|
91
|
+
if (Number.isSafeInteger(ticks)) return BigInt(ticks as number)
|
|
92
|
+
const ms = track['groupDurationMs']
|
|
93
|
+
const timescale = track['timescale']
|
|
94
|
+
if (!Number.isSafeInteger(ms) || !Number.isSafeInteger(timescale)) return undefined
|
|
95
|
+
return (BigInt(ms as number) * BigInt(timescale as number)) / 1000n
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function identityEqual(a: Fields, b: Fields): boolean {
|
|
99
|
+
return (
|
|
100
|
+
a['namespace'] === b['namespace'] &&
|
|
101
|
+
a['timescale'] === b['timescale'] &&
|
|
102
|
+
a['presentationAnchorTicks'] === b['presentationAnchorTicks'] &&
|
|
103
|
+
groupDurationTicks(a) === groupDurationTicks(b) &&
|
|
104
|
+
MMTP_SIBLING_RENDITION_FIELDS.every((field) => a[field] === b[field])
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isMmtpTrack(track: unknown, mode: MmtpMode): track is object {
|
|
109
|
+
return (
|
|
110
|
+
typeof track === 'object' && track !== null && !Array.isArray(track) &&
|
|
111
|
+
fields(track)['packaging'] === 'mmtp' && fields(track)['mmtpMode'] === mode
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The "mfu" tracks of `tracks` an "mfu-datagram" track could be the sibling
|
|
117
|
+
* of: the ones whose identity set (hard set and rendition fields) equals its own. Exactly one
|
|
118
|
+
* pairs it; zero or more than one rejects the datagram track (mmt-02 4.3.1).
|
|
119
|
+
*/
|
|
120
|
+
export function mmtpSiblingCandidates<T extends object>(tracks: readonly T[], datagram: T): T[] {
|
|
121
|
+
const own = fields(datagram)
|
|
122
|
+
return tracks.filter((track) => isMmtpTrack(track, 'mfu') && identityEqual(fields(track), own))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Every "mfu" track of `tracks` by name, each with its "mfu-datagram" sibling
|
|
127
|
+
* when exactly one matches its identity set. A datagram track that matches no
|
|
128
|
+
* "mfu" track or more than one pairs with none, and two datagram tracks that
|
|
129
|
+
* match the same "mfu" track pair with neither (each is rejected by
|
|
130
|
+
* `mmtpTrackIssues` in the container validator); the "mfu" tracks are listed
|
|
131
|
+
* whatever happens to their siblings. Never throws.
|
|
132
|
+
*/
|
|
133
|
+
export function pairMmtpSiblings<T extends object>(tracks: readonly T[]): ReadonlyMap<string, MmtpSiblingPair<T>> {
|
|
134
|
+
const pairs = new Map<string, MmtpSiblingPair<T>>()
|
|
135
|
+
for (const track of tracks) {
|
|
136
|
+
if (!isMmtpTrack(track, 'mfu')) continue
|
|
137
|
+
const name = fields(track)['name']
|
|
138
|
+
if (typeof name === 'string' && !pairs.has(name)) pairs.set(name, { stream: track, softMismatches: [] })
|
|
139
|
+
}
|
|
140
|
+
// Two datagram tracks matching one "mfu" track pair with neither: the
|
|
141
|
+
// catalog says nothing about which mirrors it.
|
|
142
|
+
const datagrams = new Map<string, T[]>()
|
|
143
|
+
for (const datagram of tracks) {
|
|
144
|
+
if (!isMmtpTrack(datagram, 'mfu-datagram')) continue
|
|
145
|
+
const candidates = mmtpSiblingCandidates(tracks, datagram)
|
|
146
|
+
if (candidates.length !== 1) continue
|
|
147
|
+
const name = fields(candidates[0]!)['name']
|
|
148
|
+
if (typeof name !== 'string' || pairs.get(name)?.stream !== candidates[0]) continue
|
|
149
|
+
datagrams.set(name, [...(datagrams.get(name) ?? []), datagram])
|
|
150
|
+
}
|
|
151
|
+
for (const [name, matched] of datagrams) {
|
|
152
|
+
if (matched.length !== 1) continue
|
|
153
|
+
const { stream } = pairs.get(name)!
|
|
154
|
+
const a = fields(stream)
|
|
155
|
+
const b = fields(matched[0]!)
|
|
156
|
+
const softMismatches = MMTP_SIBLING_SOFT_FIELDS.filter((field) => a[field] !== b[field])
|
|
157
|
+
pairs.set(name, { stream, datagram: matched[0]!, softMismatches })
|
|
158
|
+
}
|
|
159
|
+
return pairs
|
|
160
|
+
}
|
package/src/mmtp.ts
CHANGED
|
@@ -374,7 +374,6 @@ function isEmptyOrExactLegacyTrailer(payload: Uint8Array, start: number, end: nu
|
|
|
374
374
|
|
|
375
375
|
interface DeclaredTrailerLayout {
|
|
376
376
|
hasFecId: boolean
|
|
377
|
-
hasOverlayFecId: boolean
|
|
378
377
|
}
|
|
379
378
|
|
|
380
379
|
/** Options for extractMFUPayload and explainMFURejection. */
|
|
@@ -385,15 +384,6 @@ export interface MFUExtractOptions {
|
|
|
385
384
|
* was already stripped before WASM decoding.
|
|
386
385
|
*/
|
|
387
386
|
skipFecId?: boolean
|
|
388
|
-
/**
|
|
389
|
-
* The catalog declares a keyframe overlay (`scope: "keyframe"` repair track)
|
|
390
|
-
* for this packet's source. A RAP packet then carries two Source FEC Payload
|
|
391
|
-
* IDs, base first and overlay last (BLO-32719 Clarification 7). This is a
|
|
392
|
-
* catalog fact, never inferred: the header has no overlay bit, and a payload
|
|
393
|
-
* four bytes shorter is byte-identical to a missing overlay. Mirrors
|
|
394
|
-
* mmt-core `split_payload_and_source_fec_trailers(overlay_declared)`.
|
|
395
|
-
*/
|
|
396
|
-
overlayDeclared?: boolean
|
|
397
387
|
}
|
|
398
388
|
|
|
399
389
|
function resolveDeclaredTrailers(
|
|
@@ -401,38 +391,31 @@ function resolveDeclaredTrailers(
|
|
|
401
391
|
declaredEnd: number,
|
|
402
392
|
fecType: number,
|
|
403
393
|
options?: MFUExtractOptions,
|
|
404
|
-
rapFlag = false,
|
|
405
394
|
): DeclaredTrailerLayout | null {
|
|
406
395
|
if (declaredEnd > payload.length) return null
|
|
407
396
|
|
|
408
397
|
if (options?.skipFecId) {
|
|
409
398
|
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)
|
|
410
|
-
? { hasFecId: false
|
|
399
|
+
? { hasFecId: false }
|
|
411
400
|
: null
|
|
412
401
|
}
|
|
413
402
|
|
|
414
|
-
const overlay = options?.overlayDeclared === true && rapFlag
|
|
415
403
|
if (fecType === 1) {
|
|
416
|
-
const fecStart = payload.length -
|
|
404
|
+
const fecStart = payload.length - SOURCE_FEC_PAYLOAD_ID_SIZE
|
|
417
405
|
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
418
406
|
return null
|
|
419
407
|
}
|
|
420
|
-
return { hasFecId: true
|
|
408
|
+
return { hasFecId: true }
|
|
421
409
|
}
|
|
422
|
-
|
|
423
|
-
if (fecType !== 0 || overlay) return null
|
|
410
|
+
if (fecType !== 0) return null
|
|
424
411
|
|
|
425
412
|
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
426
|
-
return { hasFecId: false
|
|
413
|
+
return { hasFecId: false }
|
|
427
414
|
}
|
|
428
415
|
|
|
429
416
|
return null
|
|
430
417
|
}
|
|
431
418
|
|
|
432
|
-
function sourceFecTrailerSize(overlay: boolean): number {
|
|
433
|
-
return overlay ? 2 * SOURCE_FEC_PAYLOAD_ID_SIZE : SOURCE_FEC_PAYLOAD_ID_SIZE
|
|
434
|
-
}
|
|
435
|
-
|
|
436
419
|
/**
|
|
437
420
|
* Extract NAL unit payload from MMTP packet
|
|
438
421
|
*/
|
|
@@ -458,8 +441,6 @@ export interface MFUExtraction {
|
|
|
458
441
|
itemId: number | null
|
|
459
442
|
/** Source FEC Payload ID if present (`FEC_type == 1`), or null */
|
|
460
443
|
fecPayloadId: { ssId: number } | null
|
|
461
|
-
/** Keyframe-overlay Source FEC Payload ID: RAP packets with `overlayDeclared` only. */
|
|
462
|
-
overlayFecPayloadId: { ssId: number } | null
|
|
463
444
|
}
|
|
464
445
|
|
|
465
446
|
/**
|
|
@@ -481,8 +462,6 @@ export interface MFUExtraction {
|
|
|
481
462
|
* FEC-recovered symbols where the FEC PID was already stripped before WASM decoding
|
|
482
463
|
* but the fecType bits in byte 0 still reflect the original packet (FEC Type=1 per
|
|
483
464
|
* draft-ramadan-moq-mmt-01 §3.1).
|
|
484
|
-
* @param options.overlayDeclared The catalog declares a keyframe overlay for this
|
|
485
|
-
* source, so a RAP packet carries an 8-byte trailer (see MFUExtractOptions).
|
|
486
465
|
* @returns Extracted MFU data + metadata, or null if packet is too small
|
|
487
466
|
*/
|
|
488
467
|
interface MfuPlan {
|
|
@@ -568,7 +547,6 @@ function planMfuExtraction(
|
|
|
568
547
|
layout.dataEnd,
|
|
569
548
|
header.fecType,
|
|
570
549
|
options,
|
|
571
|
-
header.rapFlag,
|
|
572
550
|
)
|
|
573
551
|
if (!trailerLayout) {
|
|
574
552
|
// The most common cause is a producer whose Source FEC Payload ID width
|
|
@@ -576,7 +554,7 @@ function planMfuExtraction(
|
|
|
576
554
|
// leaving operators to infer it from a generic trailer error.
|
|
577
555
|
if (!options?.skipFecId && header.fecType === 1) {
|
|
578
556
|
const observed = payload.length - layout.dataEnd
|
|
579
|
-
const expected =
|
|
557
|
+
const expected = SOURCE_FEC_PAYLOAD_ID_SIZE
|
|
580
558
|
if (observed !== expected) {
|
|
581
559
|
return {
|
|
582
560
|
rejection: {
|
|
@@ -664,17 +642,17 @@ function extractPlannedMfu(
|
|
|
664
642
|
|
|
665
643
|
const data = payload.subarray(mfuOffset, dataEnd)
|
|
666
644
|
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
645
|
+
const fecPayloadId = trailerLayout.hasFecId
|
|
646
|
+
? {
|
|
647
|
+
ssId: new DataView(
|
|
648
|
+
mmtpPacket.buffer,
|
|
649
|
+
mmtpPacket.byteOffset + mmtpPacket.length - SOURCE_FEC_PAYLOAD_ID_SIZE,
|
|
650
|
+
4,
|
|
651
|
+
).getUint32(0, false),
|
|
652
|
+
}
|
|
675
653
|
: null
|
|
676
654
|
|
|
677
|
-
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId
|
|
655
|
+
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId }
|
|
678
656
|
}
|
|
679
657
|
|
|
680
658
|
/**
|
package/src/multicast-catalog.ts
CHANGED
|
@@ -255,8 +255,11 @@ export function multicastCatalogIssues(
|
|
|
255
255
|
|
|
256
256
|
const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
|
|
257
257
|
const namespaceOf = new Map<string, unknown>();
|
|
258
|
+
const modeOf = new Map<string, unknown>();
|
|
258
259
|
for (const track of tracks) {
|
|
259
|
-
if (isObject(track)
|
|
260
|
+
if (!isObject(track) || typeof track["name"] !== "string") continue;
|
|
261
|
+
namespaceOf.set(track["name"], track["namespace"]);
|
|
262
|
+
modeOf.set(track["name"], track["mmtpMode"]);
|
|
260
263
|
}
|
|
261
264
|
const tagged = (catalog as { [CATALOG_NAMESPACE]?: unknown })[CATALOG_NAMESPACE];
|
|
262
265
|
let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : undefined);
|
|
@@ -337,6 +340,12 @@ export function multicastCatalogIssues(
|
|
|
337
340
|
const ref = refs[refIndex];
|
|
338
341
|
const name = isObject(ref) ? ref["name"] : ref;
|
|
339
342
|
if (typeof name !== "string") continue;
|
|
343
|
+
// mmt-02 4.3.1: the "mfu" and "mfu-datagram" tracks carry the same
|
|
344
|
+
// MMTP sub-flow, so an endpoint lists the "mfu" track and never the
|
|
345
|
+
// datagram one; a receiver ignores an endpoint that does.
|
|
346
|
+
if (modeOf.get(name) === "mfu-datagram") {
|
|
347
|
+
fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} is an "mfu-datagram" track, which rides no multicast endpoint; list its "mfu" sibling (draft-ramadan-moq-mmt-02 4.3.1)`);
|
|
348
|
+
}
|
|
340
349
|
const namespace = namespaceOf.get(name);
|
|
341
350
|
if (typeof namespace !== "string") continue;
|
|
342
351
|
referenceNamespace ??= namespace;
|
package/src/signalling.ts
CHANGED
|
@@ -456,9 +456,9 @@ export function parseAlFecMessage(mmtpPacket: Uint8Array): AlFecMessage | null {
|
|
|
456
456
|
|
|
457
457
|
/**
|
|
458
458
|
* Decoder geometry of one FEC flow's AL-FEC message entry under
|
|
459
|
-
* draft-ramadan-moq-mmt-
|
|
459
|
+
* draft-ramadan-moq-mmt-02 Section 8.3 ("iso-ssbg1-v1"): one Asset, coding
|
|
460
460
|
* byte 0x14, fec_code_id_for_repair_flow 3 (RaptorQ) or 1 (Reed-Solomon),
|
|
461
|
-
* and no OTI (draft-ramadan-moq-mmt-
|
|
461
|
+
* and no OTI (draft-ramadan-moq-mmt-02 Section 7.1). K, T and P come from
|
|
462
462
|
* the entry's own fields; a private field, if present, is ignored.
|
|
463
463
|
*/
|
|
464
464
|
export interface AlFecRaptorQFlowConfig {
|
|
@@ -483,18 +483,18 @@ export interface AlFecRaptorQFlowConfig {
|
|
|
483
483
|
|
|
484
484
|
const RAPTORQ_MAX_SOURCE_SYMBOLS = 56_403
|
|
485
485
|
const REPAIR_SYMBOL_ID_MAX = 0x00ff_ffff
|
|
486
|
-
/** The 12-octet MMTP header plus the 2-octet length of the T - 2 construction (moq-
|
|
486
|
+
/** The 12-octet MMTP header plus the 2-octet length of the T - 2 construction (draft-ramadan-moq-mmt-02 Section 7.1). */
|
|
487
487
|
const MIN_REPAIR_SYMBOL_SIZE = 14
|
|
488
488
|
const REED_SOLOMON_MAX_BLOCK = 255
|
|
489
489
|
|
|
490
490
|
/**
|
|
491
|
-
* Validate one parsed FEC flow against draft-ramadan-moq-mmt-
|
|
492
|
-
* and
|
|
491
|
+
* Validate one parsed FEC flow against draft-ramadan-moq-mmt-02 Sections 8.3
|
|
492
|
+
* and 13.2 and return its decoder geometry, or null when the entry is
|
|
493
493
|
* outside them. Fail closed on everything else:
|
|
494
494
|
*
|
|
495
495
|
* - coding byte other than 0x14 (one-stage, ssbg_mode1, ffsrpts_flag 0,
|
|
496
496
|
* fec_payload_id_mode 0). 0x15 is fec_payload_id_mode 1 under Amd 1:2025,
|
|
497
|
-
* which "iso-ssbg1-v1" does not describe (moq-
|
|
497
|
+
* which "iso-ssbg1-v1" does not describe (draft-ramadan-moq-mmt-02 Section 7.1);
|
|
498
498
|
* - number_of_assets other than 1;
|
|
499
499
|
* - fec_code_id_for_repair_flow other than 3 or 1, the retired Blockcast
|
|
500
500
|
* code 2 included (ISO/IEC 23008-10 Table 1);
|
|
@@ -538,9 +538,11 @@ export function alFecRaptorQFlowConfig(flow: AlFecFlow): AlFecRaptorQFlowConfig
|
|
|
538
538
|
|
|
539
539
|
/**
|
|
540
540
|
* `alFecRaptorQFlowConfig` for every entry of a message, index for index,
|
|
541
|
-
* plus the draft-ramadan-moq-mmt-
|
|
541
|
+
* plus the draft-ramadan-moq-mmt-02 Section 13.2 checks that span entries: an
|
|
542
542
|
* entry whose repair_flow_id is another entry's Asset packet_id, and every
|
|
543
543
|
* entry of two that name one repair_flow_id or list one Asset, is null.
|
|
544
|
+
* A repair_flow_id equal to a packet_id this message does not list (another
|
|
545
|
+
* track in the MP table) is the caller's check: it holds the MP table.
|
|
544
546
|
*/
|
|
545
547
|
export function alFecMessageFlowConfigs(message: AlFecMessageBody): (AlFecRaptorQFlowConfig | null)[] {
|
|
546
548
|
const assetCount = new Map<number, number>()
|