@blockcast/mmt-container 0.1.0-main.c71423b8a4e4 → 0.1.0-main.ce3c8aeb7f68
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/align.d.ts +6 -2
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js.map +2 -2
- package/dist/audio-ring-buffer.js +23 -36
- package/dist/audio-ring-buffer.js.map +1 -1
- package/dist/browser-runtime.js +6865 -6485
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +3 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +21 -2
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +10 -0
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/cmaf-block-assembler.d.ts +42 -0
- package/dist/cmaf-block-assembler.d.ts.map +1 -1
- package/dist/cmaf-block-assembler.js +542 -535
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/cmaf-group-batcher.js +27 -46
- package/dist/cmaf-group-batcher.js.map +2 -2
- package/dist/cmcd-producer.js +45 -66
- package/dist/cmcd-producer.js.map +1 -1
- package/dist/fec-manager.d.ts +13 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +1151 -871
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-starvation-detector.js +25 -40
- package/dist/fec-starvation-detector.js.map +1 -1
- package/dist/fec-worker-setup.js +242 -225
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-bmff-timing.js +63 -88
- package/dist/iso-bmff-timing.js.map +1 -1
- package/dist/loc.js +7 -4
- package/dist/loc.js.map +1 -1
- package/dist/manifest-auth-plan.js +292 -311
- package/dist/manifest-auth-plan.js.map +1 -1
- package/dist/media-router.d.ts +0 -99
- package/dist/media-router.d.ts.map +1 -1
- package/dist/media-router.js +270 -504
- package/dist/media-router.js.map +3 -3
- package/dist/mfu-reassembler.js +597 -607
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +37 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +1531 -1522
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +179 -102
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +1641 -1651
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +34 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +3676 -3390
- package/dist/mmtp-router.js.map +3 -3
- package/dist/mmtp-to-cmaf.d.ts +7 -1
- package/dist/mmtp-to-cmaf.d.ts.map +1 -1
- package/dist/mmtp-to-cmaf.js +109 -134
- package/dist/mmtp-to-cmaf.js.map +2 -2
- package/dist/multicast-input.d.ts +7 -35
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +21 -2
- package/dist/multicast-input.js.map +4 -4
- package/dist/multicast-manager.d.ts +10 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +5584 -4961
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +7 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +369 -421
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +53 -30
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.js +2096 -2097
- package/dist/no-modules.js.map +3 -3
- package/dist/sample-combiner.js +118 -139
- package/dist/sample-combiner.js.map +1 -1
- package/dist/signaling.js.map +2 -2
- package/dist/source-auth.js +353 -382
- package/dist/source-auth.js.map +1 -1
- package/dist/switching-set-alignment.js +14 -29
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +17 -11
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/track-pipeline-setup.js +105 -125
- package/dist/track-pipeline-setup.js.map +1 -1
- package/dist/track-pipeline.js +107 -127
- package/dist/track-pipeline.js.map +1 -1
- package/dist/track-session.d.ts +16 -0
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +230 -243
- package/dist/track-session.js.map +2 -2
- package/dist/transport-pool.js +24 -38
- package/dist/transport-pool.js.map +1 -1
- package/dist/wasm-mfu-reassembler.d.ts +6 -1
- package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
- package/dist/wasm-mfu-reassembler.js +127 -144
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +1659 -1650
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/node_modules/@blockcast/fec-worker/README.md +5 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
- package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
- package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
- package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
- package/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/package.json +7 -6
- package/schemas/catalog.schema.json +1 -1
- package/src/align.ts +6 -2
- package/src/carp-catalog.ts +13 -3
- package/src/cmaf-block-assembler.ts +90 -81
- package/src/fec-manager.ts +530 -146
- package/src/index.ts +2 -2
- package/src/media-router.ts +0 -397
- package/src/mmtp-container-parser.ts +97 -21
- package/src/mmtp-router.ts +302 -125
- package/src/mmtp-to-cmaf.ts +21 -7
- package/src/multicast-input.ts +23 -3
- package/src/multicast-manager.ts +83 -11
- package/src/multicast-transport.ts +56 -17
- package/src/track-session.ts +16 -0
- package/src/wasm-mfu-reassembler.ts +40 -24
- package/test-vectors/catalog/README.md +2 -0
- package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
- package/test-vectors/catalog-validation.json +11 -0
package/src/align.ts
CHANGED
|
@@ -132,8 +132,12 @@ export function groupIdForTicks(ticks: number, groupDurationTicks: number): numb
|
|
|
132
132
|
* the quantized duration under-counts and `expected` slips a whole group.
|
|
133
133
|
* See the divergence fixture in `__tests__/align.test.ts`.
|
|
134
134
|
*
|
|
135
|
-
* No non-test caller remains in this package: `MediaRouter`
|
|
136
|
-
*
|
|
135
|
+
* No non-test caller remains in this package: `MediaRouter` took tick-space
|
|
136
|
+
* inputs from PCL-2211, and its group-alignment observer was then removed
|
|
137
|
+
* outright as unwired telemetry (BLO-34141). Removal of this wrapper is
|
|
138
|
+
* tracked by BLO-21176; the exported `groupIdForTicks` / `driftCheck` stay
|
|
139
|
+
* regardless — they are the formula shared with the Go sender and the Rust
|
|
140
|
+
* relay, not internals of the deleted observer.
|
|
137
141
|
*/
|
|
138
142
|
export function groupIdFor(
|
|
139
143
|
mediaTimeSec: Seconds | number,
|
package/src/carp-catalog.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* should derive from these via z.infer<> to avoid duplication.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { MMTP_PACKET_ID_MAX, MMTP_SIGNALING_PACKET_ID } from "@blockcast/mmt-base";
|
|
11
12
|
import { resolveMulticastAuthCatalog, type MulticastAuthConfig } from "./multicast-auth-catalog.js";
|
|
12
13
|
import {
|
|
13
14
|
assembleRepairLayers,
|
|
@@ -250,7 +251,9 @@ export type MulticastProtocol = "ssm" | "asm" | "amt" | "atsc3";
|
|
|
250
251
|
* Per-track endpoint membership, per draft-ramadan-moq-multicast-00 §4.1.
|
|
251
252
|
*
|
|
252
253
|
* `packetId` is the MMTP packet_id used for packet-level demux on the
|
|
253
|
-
* multicast wire
|
|
254
|
+
* multicast wire, in 1..65535: packet_id 0 (`MMTP_SIGNALING_PACKET_ID`) is
|
|
255
|
+
* the MMTP signaling flow and is never a track's. New emitters MUST use this
|
|
256
|
+
* object form; the legacy
|
|
254
257
|
* `string` form is accepted by parsers for one release for backward
|
|
255
258
|
* compatibility (BLO-3323 migration).
|
|
256
259
|
*/
|
|
@@ -737,8 +740,15 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
737
740
|
catalogError("multicast_track", `${refPath}.name`, `unknown catalog track ${JSON.stringify(name)}`);
|
|
738
741
|
}
|
|
739
742
|
const packetId = trackRef["packetId"];
|
|
740
|
-
if (
|
|
741
|
-
catalogError(
|
|
743
|
+
if (packetId === MMTP_SIGNALING_PACKET_ID) {
|
|
744
|
+
catalogError(
|
|
745
|
+
"multicast_packet_id",
|
|
746
|
+
`${refPath}.packetId`,
|
|
747
|
+
`packetId ${packetId} is the MMTP signaling flow and must not be advertised for a track; packetId must be an integer from 1 to ${MMTP_PACKET_ID_MAX}`,
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
if (!Number.isSafeInteger(packetId) || (packetId as number) < 1 || (packetId as number) > MMTP_PACKET_ID_MAX) {
|
|
751
|
+
catalogError("multicast_packet_id", `${refPath}.packetId`, `packetId must be an integer from 1 to ${MMTP_PACKET_ID_MAX}`);
|
|
742
752
|
}
|
|
743
753
|
const previous = packetIds.get(packetId as number);
|
|
744
754
|
if (previous !== undefined) {
|
|
@@ -124,6 +124,29 @@ export interface CmafSampleOrderStats {
|
|
|
124
124
|
preRapDeadlineDrops: number
|
|
125
125
|
noRapFlushDrops: number
|
|
126
126
|
forcedReleases: number
|
|
127
|
+
/**
|
|
128
|
+
* Samples refused because they carried `authoredTiming` while this track's
|
|
129
|
+
* `admitAuthoredTiming` was false. Non-zero means the contract rollback
|
|
130
|
+
* switch is engaged AND the producer is still sending authored batches —
|
|
131
|
+
* a rollback is meant to be paired with that producer reverting to raw.
|
|
132
|
+
*/
|
|
133
|
+
unadmittedAuthoredSamples: number
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Cumulative counters of what the assembler emitted and which block events
|
|
138
|
+
* it saw. `emits` counts emit calls (one per direct frame, recovered block,
|
|
139
|
+
* recovered drain or block flush); `samples` and `keyframes` count the
|
|
140
|
+
* samples those calls carried.
|
|
141
|
+
*/
|
|
142
|
+
export interface CmafEmitStats {
|
|
143
|
+
emits: number
|
|
144
|
+
samples: number
|
|
145
|
+
keyframes: number
|
|
146
|
+
addedFrames: number
|
|
147
|
+
recoveredBlocks: number
|
|
148
|
+
completedBlocks: number
|
|
149
|
+
failedBlocks: number
|
|
127
150
|
}
|
|
128
151
|
|
|
129
152
|
export interface BlockAssemblerConfig {
|
|
@@ -167,6 +190,24 @@ export interface BlockAssemblerConfig {
|
|
|
167
190
|
* @deprecated Use sampleOrder with an explicit policy.
|
|
168
191
|
*/
|
|
169
192
|
sampleReorderWindow?: number
|
|
193
|
+
/**
|
|
194
|
+
* Authored-timing admission for this track (default `true` — admitted).
|
|
195
|
+
*
|
|
196
|
+
* This is the rollback switch named by the authored-audio-CTS contract's
|
|
197
|
+
* removal gate (BLO-30397). Assemblers are keyed on
|
|
198
|
+
* `(packetId, catalogTrackName)` (`mmtp-router.ts` `#mseAssemblerKey`), so
|
|
199
|
+
* this switch is per **track**. A producer feeding several tracks must be
|
|
200
|
+
* de-admitted on each of them: nothing applies it across a track set
|
|
201
|
+
* (BLO-34821).
|
|
202
|
+
*
|
|
203
|
+
* Set `false` and a sample carrying `authoredTiming` is **rejected**, not
|
|
204
|
+
* zeroed: the contract forbids rolling back "by zeroing already-authored
|
|
205
|
+
* offsets", because a zeroed offset is byte-indistinguishable from a feed
|
|
206
|
+
* that authored nothing (BLO-30401 measured both as 0 A/V skew). Raw samples
|
|
207
|
+
* — those with no `authoredTiming` at all — are unaffected and keep emitting
|
|
208
|
+
* a v0 trun with no composition-offset field.
|
|
209
|
+
*/
|
|
210
|
+
admitAuthoredTiming?: boolean
|
|
170
211
|
}
|
|
171
212
|
|
|
172
213
|
interface OrderedSample extends CmafBlockSample {
|
|
@@ -174,7 +215,12 @@ interface OrderedSample extends CmafBlockSample {
|
|
|
174
215
|
}
|
|
175
216
|
|
|
176
217
|
export class CmafBlockAssembler {
|
|
177
|
-
#config: Required<
|
|
218
|
+
#config: Required<
|
|
219
|
+
Pick<
|
|
220
|
+
BlockAssemblerConfig,
|
|
221
|
+
'k' | 'timescale' | 'trackId' | 'trackType' | 'admitAuthoredTiming'
|
|
222
|
+
>
|
|
223
|
+
>
|
|
178
224
|
#blocks = new Map<number, Map<number, BlockFrame>>()
|
|
179
225
|
#pendingFlush = new Set<number>()
|
|
180
226
|
#pendingRecovered = new Map<number, BlockFrame>()
|
|
@@ -196,6 +242,7 @@ export class CmafBlockAssembler {
|
|
|
196
242
|
preRapDeadlineDrops: 0,
|
|
197
243
|
noRapFlushDrops: 0,
|
|
198
244
|
forcedReleases: 0,
|
|
245
|
+
unadmittedAuthoredSamples: 0,
|
|
199
246
|
}
|
|
200
247
|
#validateH264Keyframes = false
|
|
201
248
|
#keyframeRejectDumpCount = 0
|
|
@@ -338,6 +385,18 @@ export class CmafBlockAssembler {
|
|
|
338
385
|
/** True only for locally generated concealment samples. */
|
|
339
386
|
synthetic: boolean | undefined,
|
|
340
387
|
): void {
|
|
388
|
+
// Authored-timing admission — the rollback switch the BLO-30397 removal
|
|
389
|
+
// gate names. Refuse the sample outright rather than stripping its offset:
|
|
390
|
+
// the contract forbids rolling back "by zeroing already-authored offsets",
|
|
391
|
+
// and BLO-30401 measured why — a zeroed offset and a never-authored one are
|
|
392
|
+
// behaviourally identical downstream (same buffered ranges, same duration,
|
|
393
|
+
// no diagnostic), so a silent strip would look exactly like success while
|
|
394
|
+
// audio ran early forever. A de-admitted producer is expected to revert to
|
|
395
|
+
// raw batches, which are untouched by this branch.
|
|
396
|
+
if (authoredTiming !== undefined && !this.#config.admitAuthoredTiming) {
|
|
397
|
+
this.#sampleOrderStats.unadmittedAuthoredSamples++
|
|
398
|
+
return
|
|
399
|
+
}
|
|
341
400
|
const scaledTiming = authoredTiming === undefined
|
|
342
401
|
? null
|
|
343
402
|
: scaleAuthoredTiming(authoredTiming, this.#config.timescale)
|
|
@@ -602,70 +661,23 @@ export class CmafBlockAssembler {
|
|
|
602
661
|
}
|
|
603
662
|
}
|
|
604
663
|
|
|
605
|
-
//
|
|
606
|
-
//
|
|
607
|
-
//
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
#completeBlockCount = 0
|
|
617
|
-
#failBlockCount = 0
|
|
618
|
-
#aggregateTimer: ReturnType<typeof setInterval> | null = null
|
|
619
|
-
#startAggregateTimer(): void {
|
|
620
|
-
if (this.#aggregateTimer) return
|
|
621
|
-
this.#aggregateTimer = setInterval(() => {
|
|
622
|
-
// Sample-order counters are cumulative, not per-second: stale drops are
|
|
623
|
-
// otherwise silent, and this line is the only view a live run has of them.
|
|
624
|
-
const order = this.#sampleOrderStats
|
|
625
|
-
console.log(
|
|
626
|
-
`[L4-AGG-${this.#config.trackType}] emits=${this.#emitCount} samples=${this.#sampleCount} ` +
|
|
627
|
-
`kf=${this.#keyframeCount} addFrame=${this.#addFrameCount} ` +
|
|
628
|
-
`recovered=${this.#recoveredBlockCount} complete=${this.#completeBlockCount} ` +
|
|
629
|
-
`fail=${this.#failBlockCount} pendingBlocks=${this.#blocks.size} ` +
|
|
630
|
-
`pendingFlushes=${this.#pendingFlush.size} armedVideo=${this.#armedVideo} ` +
|
|
631
|
-
`forced=${order.forcedReleases} stale=${order.staleSamples} dup=${order.duplicateSamples} ` +
|
|
632
|
-
`preRap=${order.preRapDeadlineDrops} noRap=${order.noRapFlushDrops}`,
|
|
633
|
-
)
|
|
634
|
-
this.#emitCount = 0
|
|
635
|
-
this.#sampleCount = 0
|
|
636
|
-
this.#keyframeCount = 0
|
|
637
|
-
this.#addFrameCount = 0
|
|
638
|
-
this.#recoveredBlockCount = 0
|
|
639
|
-
this.#completeBlockCount = 0
|
|
640
|
-
this.#failBlockCount = 0
|
|
641
|
-
}, 1000)
|
|
664
|
+
// Cumulative emit counters (see emitStats). They replace the BLO-3035 L4
|
|
665
|
+
// diagnostics, which hashed and hex-dumped every video keyframe and ran a
|
|
666
|
+
// 1 s setInterval console aggregate on the MSE path (BLO-36599).
|
|
667
|
+
#emitStats: CmafEmitStats = {
|
|
668
|
+
emits: 0,
|
|
669
|
+
samples: 0,
|
|
670
|
+
keyframes: 0,
|
|
671
|
+
addedFrames: 0,
|
|
672
|
+
recoveredBlocks: 0,
|
|
673
|
+
completedBlocks: 0,
|
|
674
|
+
failedBlocks: 0,
|
|
642
675
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
this.#
|
|
646
|
-
this.#
|
|
647
|
-
|
|
648
|
-
// including the t=5s one that Chrome's decoder rejected (BLO-3035 L4).
|
|
649
|
-
const anyKf = this.#config.trackType === 'video' && samples.some(s => s.keyframe)
|
|
650
|
-
if (this.#config.trackType !== 'video' || (this.#dumpCount >= 6 && !anyKf)) return
|
|
651
|
-
this.#dumpCount++
|
|
652
|
-
const s0 = samples[0]
|
|
653
|
-
if (!s0) return
|
|
654
|
-
const d = s0.data
|
|
655
|
-
const hex = Array.from(d.subarray(0, Math.min(48, d.length)))
|
|
656
|
-
.map(b => (b as number).toString(16).padStart(2, '0'))
|
|
657
|
-
.join(' ')
|
|
658
|
-
// djb2 hash of full s0 buffer — used to compare clean vs FEC-recovered emit bytes.
|
|
659
|
-
let h = 5381
|
|
660
|
-
for (let i = 0; i < d.length; i++) h = (h * 33 + (d[i] as number)) | 0
|
|
661
|
-
const hash = (h >>> 0).toString(16).padStart(8, '0')
|
|
662
|
-
const ts0 = s0.timestamp ?? -1
|
|
663
|
-
const tsN = samples[samples.length - 1]?.timestamp ?? -1
|
|
664
|
-
console.log(
|
|
665
|
-
`[L4-DIAG] EMIT#${this.#dumpCount} path=${path}${sbn !== undefined ? ` sbn=${sbn}` : ''} ` +
|
|
666
|
-
`samples=${samples.length} s0.kf=${s0.keyframe} s0.len=${d.length} ` +
|
|
667
|
-
`ts0=${ts0} tsN=${tsN} dur=${tsN - ts0} hash=${hash} first48=[${hex}]`,
|
|
668
|
-
)
|
|
676
|
+
|
|
677
|
+
#countEmit(samples: ReadonlyArray<{ keyframe: boolean }>): void {
|
|
678
|
+
this.#emitStats.emits++
|
|
679
|
+
this.#emitStats.samples += samples.length
|
|
680
|
+
for (const sample of samples) if (sample.keyframe) this.#emitStats.keyframes++
|
|
669
681
|
}
|
|
670
682
|
|
|
671
683
|
constructor(config: BlockAssemblerConfig) {
|
|
@@ -674,6 +686,7 @@ export class CmafBlockAssembler {
|
|
|
674
686
|
timescale: config.timescale ?? 1_000_000,
|
|
675
687
|
trackId: config.trackId ?? 1,
|
|
676
688
|
trackType: config.trackType,
|
|
689
|
+
admitAuthoredTiming: config.admitAuthoredTiming ?? true,
|
|
677
690
|
}
|
|
678
691
|
|
|
679
692
|
// Compute default frame duration from fps (updated from timestamp deltas at runtime)
|
|
@@ -754,6 +767,11 @@ export class CmafBlockAssembler {
|
|
|
754
767
|
return { ...this.#sampleOrderStats }
|
|
755
768
|
}
|
|
756
769
|
|
|
770
|
+
/** Cumulative emit and block-event counters since construction. */
|
|
771
|
+
get emitStats(): Readonly<CmafEmitStats> {
|
|
772
|
+
return { ...this.#emitStats }
|
|
773
|
+
}
|
|
774
|
+
|
|
757
775
|
/** Emit a single frame immediately as a one-sample moof+mdat segment.
|
|
758
776
|
*
|
|
759
777
|
* BLO-3035 layer 4 (4b): the prior SBN-grouped buffering scheme stranded
|
|
@@ -788,8 +806,7 @@ export class CmafBlockAssembler {
|
|
|
788
806
|
sampleNumber?: number,
|
|
789
807
|
): void {
|
|
790
808
|
void sbn; void esi
|
|
791
|
-
this.#
|
|
792
|
-
this.#startAggregateTimer()
|
|
809
|
+
this.#emitStats.addedFrames++
|
|
793
810
|
|
|
794
811
|
if (!this.#ordersSamples()) this.#drainRecoveredUpTo(timestamp)
|
|
795
812
|
|
|
@@ -815,16 +832,14 @@ export class CmafBlockAssembler {
|
|
|
815
832
|
undefined,
|
|
816
833
|
)
|
|
817
834
|
|
|
818
|
-
|
|
819
|
-
this.#dumpEmit('addFrame-direct', [{ data, timestamp, keyframe }])
|
|
835
|
+
this.#countEmit([{ keyframe }])
|
|
820
836
|
}
|
|
821
837
|
|
|
822
838
|
/** Mark a block as complete (all K source symbols received or FEC recovery succeeded).
|
|
823
839
|
* If all frames are already buffered, flushes immediately. Otherwise sets pending-flush. */
|
|
824
840
|
completeBlock(sbn: number): void {
|
|
825
841
|
void sbn
|
|
826
|
-
this.#
|
|
827
|
-
this.#startAggregateTimer()
|
|
842
|
+
this.#emitStats.completedBlocks++
|
|
828
843
|
// Source samples are emitted directly from addFrame(). A clean FEC block
|
|
829
844
|
// completion is still useful for stats, but it must not enqueue stale
|
|
830
845
|
// pending flushes from the retired block-buffered path.
|
|
@@ -832,8 +847,7 @@ export class CmafBlockAssembler {
|
|
|
832
847
|
|
|
833
848
|
/** Handle block timeout — emit whatever frames we have + fill for missing slots. */
|
|
834
849
|
failBlock(sbn: number): void {
|
|
835
|
-
this.#
|
|
836
|
-
this.#startAggregateTimer()
|
|
850
|
+
this.#emitStats.failedBlocks++
|
|
837
851
|
this.#pendingFlush.delete(sbn)
|
|
838
852
|
const block = this.#blocks.get(sbn)
|
|
839
853
|
if (!block || block.size === 0) {
|
|
@@ -846,15 +860,14 @@ export class CmafBlockAssembler {
|
|
|
846
860
|
/** Add all frames from a FEC-recovered block at once and emit immediately. */
|
|
847
861
|
addRecoveredBlock(sbn: number, frames: BlockFrame[]): void {
|
|
848
862
|
void sbn
|
|
849
|
-
this.#
|
|
850
|
-
this.#startAggregateTimer()
|
|
863
|
+
this.#emitStats.recoveredBlocks++
|
|
851
864
|
// Build samples directly — recovered frames are already sorted
|
|
852
865
|
this.#pendingFlush.delete(sbn)
|
|
853
866
|
this.#blocks.delete(sbn)
|
|
854
867
|
|
|
855
868
|
if (frames.length === 0) return
|
|
856
869
|
const normalized = this.#normalizeVideoKeyframes(frames)
|
|
857
|
-
this.#
|
|
870
|
+
this.#countEmit(normalized)
|
|
858
871
|
if (this.#ordersSamples()) {
|
|
859
872
|
this.#emitPerSample(normalized, undefined, false)
|
|
860
873
|
return
|
|
@@ -969,10 +982,6 @@ export class CmafBlockAssembler {
|
|
|
969
982
|
this.onSegment = null
|
|
970
983
|
this.onSample = null
|
|
971
984
|
this.onInitSegment = null
|
|
972
|
-
if (this.#aggregateTimer) {
|
|
973
|
-
clearInterval(this.#aggregateTimer)
|
|
974
|
-
this.#aggregateTimer = null
|
|
975
|
-
}
|
|
976
985
|
}
|
|
977
986
|
|
|
978
987
|
// ── Private ──
|
|
@@ -1027,7 +1036,7 @@ export class CmafBlockAssembler {
|
|
|
1027
1036
|
frame.sampleNumber,
|
|
1028
1037
|
frame.synthetic,
|
|
1029
1038
|
)
|
|
1030
|
-
this.#
|
|
1039
|
+
this.#countEmit([frame])
|
|
1031
1040
|
}
|
|
1032
1041
|
}
|
|
1033
1042
|
|
|
@@ -1048,7 +1057,7 @@ export class CmafBlockAssembler {
|
|
|
1048
1057
|
const frames = this.#applyVideoKeyframeGate(sortedFrames)
|
|
1049
1058
|
if (!frames) return
|
|
1050
1059
|
|
|
1051
|
-
this.#
|
|
1060
|
+
this.#countEmit(frames)
|
|
1052
1061
|
this.#emitPerSample(frames)
|
|
1053
1062
|
}
|
|
1054
1063
|
|