@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/dist/media-router.js
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
10
|
-
set _(value) {
|
|
11
|
-
__privateSet(obj, member, value, setter);
|
|
12
|
-
},
|
|
13
|
-
get _() {
|
|
14
|
-
return __privateGet(obj, member, getter);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// src/align.ts
|
|
19
|
-
function groupIdForTicks(ticks, groupDurationTicks) {
|
|
20
|
-
if (!Number.isInteger(ticks)) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
`[align] groupIdForTicks: ticks must be an integer, got ${ticks}`
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
if (!Number.isInteger(groupDurationTicks) || groupDurationTicks <= 0) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
if (ticks < 0) return 0;
|
|
31
|
-
return Math.floor(ticks / groupDurationTicks);
|
|
32
|
-
}
|
|
33
|
-
function driftCheck(expected, actual) {
|
|
34
|
-
if (!Number.isInteger(expected) || !Number.isInteger(actual)) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`[align] driftCheck: both arguments must be integer groupIds, got expected=${expected} actual=${actual}`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const deltaGroups = actual - expected;
|
|
40
|
-
if (deltaGroups === 0) return { kind: "aligned", deltaGroups: 0 };
|
|
41
|
-
return { kind: "drifted", deltaGroups };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
1
|
// src/track-session.ts
|
|
45
2
|
import { fecBlockBudgetMs } from "@blockcast/mmt-fec";
|
|
46
3
|
function computeFecDeliveryWindowMs(config) {
|
|
@@ -61,15 +18,6 @@ function computeFecDeliveryWindowMs(config) {
|
|
|
61
18
|
}
|
|
62
19
|
|
|
63
20
|
// src/media-router.ts
|
|
64
|
-
var GROUP_ALIGN_WARN_BUDGET = {
|
|
65
|
-
"invalid-tick-inputs": 1,
|
|
66
|
-
"ticks-formula-threw": 1,
|
|
67
|
-
"invalid-seconds-inputs": 1,
|
|
68
|
-
"sub-nanosecond-duration": 1,
|
|
69
|
-
"media-time-overflow": 1,
|
|
70
|
-
"seconds-formula-threw": 1,
|
|
71
|
-
"callback-threw": 3
|
|
72
|
-
};
|
|
73
21
|
var TrackSourceConflictError = class extends Error {
|
|
74
22
|
constructor(trackName) {
|
|
75
23
|
super(`Track source already assigned for '${trackName}'; call clearTrackSource first`);
|
|
@@ -79,136 +27,90 @@ var TrackSourceConflictError = class extends Error {
|
|
|
79
27
|
};
|
|
80
28
|
var DEFAULT_CROSSFADE_FRAMES = 10;
|
|
81
29
|
var DEFAULT_MAX_OVERLAY_BUFFER = 128;
|
|
82
|
-
var _active, _multicastVideoKeyed, _multicastAudioReceived, _moqVideoKeyframeEmitted, _requireAudio, _suppressed, _audioFallbackTimer, _audioFallbackMs, _crossfadeFrames, _maxOverlayBuffer, _allowDeltaMulticastTakeoverAfterMoqKeyframe, _repairInFlight, _maxRepairInFlight, _onRepairRequest, _onVideoFrame, _onAudioFrame, _onOverlayFrame, _onSourceSwitch, _sourceSwitchReady, _sourceSwitchToken, _pendingMulticastToken, _pendingMulticastVideo, _pendingMulticastAudio, _trackSources, _trackTypes, _crossfadeCounters, _overlayBoundaryReached, _overlayBuffer, _deltaConfigured, _deltaActive, _deltaWindow, _deltaWindowSize, _deltaFailThresholdRatio, _deltaRecoverThresholdRatio, _deltaProbeIntervalMs, _lastProbeAt, _onDeltaFallbackCb, _onDeltaRecoverCb, _onGroupDrift, _groupAlignWarnCounts, _MediaRouter_instances, skipWithWarning_fn, resolveTicks_fn, resolveSeconds_fn, _moqAudioWarmed, tryActivateMulticast_fn, commitMulticastActivation_fn, rejectMulticastActivation_fn, emitForTrack_fn, handleOverlayFrame_fn;
|
|
83
30
|
var MediaRouter = class {
|
|
31
|
+
#active = "moq";
|
|
32
|
+
#multicastVideoKeyed = false;
|
|
33
|
+
#multicastAudioReceived = false;
|
|
34
|
+
#moqVideoKeyframeEmitted = false;
|
|
35
|
+
#requireAudio;
|
|
36
|
+
#suppressed = false;
|
|
37
|
+
// true after multicast confirmed — suppresses MoQ
|
|
38
|
+
#audioFallbackTimer = null;
|
|
39
|
+
// Configurable constants (from catalog/FEC config, not magic numbers)
|
|
40
|
+
#audioFallbackMs;
|
|
41
|
+
#crossfadeFrames;
|
|
42
|
+
#maxOverlayBuffer;
|
|
43
|
+
#allowDeltaMulticastTakeoverAfterMoqKeyframe;
|
|
44
|
+
// ── Keyframe repair state ────────────────────────────────────────
|
|
45
|
+
/** Groups currently being repaired — idempotent guard per Pitfall 2 (T-13-01 mitigation) */
|
|
46
|
+
#repairInFlight = /* @__PURE__ */ new Set();
|
|
47
|
+
/** Max concurrent repairs — prevents relay SUBSCRIBE flood (T-13-01 mitigation) */
|
|
48
|
+
#maxRepairInFlight;
|
|
49
|
+
/** Callback to request MoQ subscribe for a specific group (wired by player) */
|
|
50
|
+
#onRepairRequest = null;
|
|
51
|
+
#onVideoFrame = null;
|
|
52
|
+
#onAudioFrame = null;
|
|
53
|
+
#onOverlayFrame = null;
|
|
54
|
+
#onSourceSwitch = null;
|
|
55
|
+
#sourceSwitchReady = null;
|
|
56
|
+
#sourceSwitchToken = 0;
|
|
57
|
+
#pendingMulticastToken = null;
|
|
58
|
+
#pendingMulticastVideo = null;
|
|
59
|
+
#pendingMulticastAudio = null;
|
|
60
|
+
// Per-track source state
|
|
61
|
+
#trackSources = /* @__PURE__ */ new Map();
|
|
62
|
+
// Track type registry: trackName → { type, source }.
|
|
63
|
+
// Init data / inline signaling is authoritative until catalog updates.
|
|
64
|
+
// Priority: 'init' > 'catalog' > 'name' (backward compat fallback).
|
|
65
|
+
#trackTypes = /* @__PURE__ */ new Map();
|
|
66
|
+
// Crossfade state: maps trackName → remaining binary-path frames allowed during window
|
|
67
|
+
#crossfadeCounters = /* @__PURE__ */ new Map();
|
|
68
|
+
// Overlay alignment state
|
|
69
|
+
#overlayBoundaryReached = false;
|
|
70
|
+
#overlayBuffer = [];
|
|
71
|
+
// ── Phase 14: deltaActive state machine (D-11..D-14) ─────────────
|
|
72
|
+
// No timers — state transitions driven entirely by notifyDeltaBlock() callbacks.
|
|
73
|
+
// All thresholds derived from catalog fields or throw at configureDelta() time.
|
|
74
|
+
#deltaConfigured = false;
|
|
75
|
+
#deltaActive = true;
|
|
76
|
+
#deltaWindow = [];
|
|
77
|
+
// ring buffer: true = block failed
|
|
78
|
+
#deltaWindowSize = 0;
|
|
79
|
+
#deltaFailThresholdRatio = 0;
|
|
80
|
+
// P/K
|
|
81
|
+
#deltaRecoverThresholdRatio = 0;
|
|
82
|
+
// (P/K)/2 — hysteresis (D-13)
|
|
83
|
+
#deltaProbeIntervalMs = 0;
|
|
84
|
+
#lastProbeAt = 0;
|
|
85
|
+
#onDeltaFallbackCb = null;
|
|
86
|
+
#onDeltaRecoverCb = null;
|
|
84
87
|
constructor(options) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
__privateAdd(this, _suppressed, false);
|
|
92
|
-
// true after multicast confirmed — suppresses MoQ
|
|
93
|
-
__privateAdd(this, _audioFallbackTimer, null);
|
|
94
|
-
// Configurable constants (from catalog/FEC config, not magic numbers)
|
|
95
|
-
__privateAdd(this, _audioFallbackMs);
|
|
96
|
-
__privateAdd(this, _crossfadeFrames);
|
|
97
|
-
__privateAdd(this, _maxOverlayBuffer);
|
|
98
|
-
__privateAdd(this, _allowDeltaMulticastTakeoverAfterMoqKeyframe);
|
|
99
|
-
// ── Keyframe repair state ────────────────────────────────────────
|
|
100
|
-
/** Groups currently being repaired — idempotent guard per Pitfall 2 (T-13-01 mitigation) */
|
|
101
|
-
__privateAdd(this, _repairInFlight, /* @__PURE__ */ new Set());
|
|
102
|
-
/** Max concurrent repairs — prevents relay SUBSCRIBE flood (T-13-01 mitigation) */
|
|
103
|
-
__privateAdd(this, _maxRepairInFlight);
|
|
104
|
-
/** Callback to request MoQ subscribe for a specific group (wired by player) */
|
|
105
|
-
__privateAdd(this, _onRepairRequest, null);
|
|
106
|
-
__privateAdd(this, _onVideoFrame, null);
|
|
107
|
-
__privateAdd(this, _onAudioFrame, null);
|
|
108
|
-
__privateAdd(this, _onOverlayFrame, null);
|
|
109
|
-
__privateAdd(this, _onSourceSwitch, null);
|
|
110
|
-
__privateAdd(this, _sourceSwitchReady, null);
|
|
111
|
-
__privateAdd(this, _sourceSwitchToken, 0);
|
|
112
|
-
__privateAdd(this, _pendingMulticastToken, null);
|
|
113
|
-
__privateAdd(this, _pendingMulticastVideo, null);
|
|
114
|
-
__privateAdd(this, _pendingMulticastAudio, null);
|
|
115
|
-
// Per-track source state
|
|
116
|
-
__privateAdd(this, _trackSources, /* @__PURE__ */ new Map());
|
|
117
|
-
// Track type registry: trackName → { type, source }.
|
|
118
|
-
// Init data / inline signaling is authoritative until catalog updates.
|
|
119
|
-
// Priority: 'init' > 'catalog' > 'name' (backward compat fallback).
|
|
120
|
-
__privateAdd(this, _trackTypes, /* @__PURE__ */ new Map());
|
|
121
|
-
// Crossfade state: maps trackName → remaining binary-path frames allowed during window
|
|
122
|
-
__privateAdd(this, _crossfadeCounters, /* @__PURE__ */ new Map());
|
|
123
|
-
// Overlay alignment state
|
|
124
|
-
__privateAdd(this, _overlayBoundaryReached, false);
|
|
125
|
-
__privateAdd(this, _overlayBuffer, []);
|
|
126
|
-
// ── Phase 14: deltaActive state machine (D-11..D-14) ─────────────
|
|
127
|
-
// No timers — state transitions driven entirely by notifyDeltaBlock() callbacks.
|
|
128
|
-
// All thresholds derived from catalog fields or throw at configureDelta() time.
|
|
129
|
-
__privateAdd(this, _deltaConfigured, false);
|
|
130
|
-
__privateAdd(this, _deltaActive, true);
|
|
131
|
-
__privateAdd(this, _deltaWindow, []);
|
|
132
|
-
// ring buffer: true = block failed
|
|
133
|
-
__privateAdd(this, _deltaWindowSize, 0);
|
|
134
|
-
__privateAdd(this, _deltaFailThresholdRatio, 0);
|
|
135
|
-
// P/K
|
|
136
|
-
__privateAdd(this, _deltaRecoverThresholdRatio, 0);
|
|
137
|
-
// (P/K)/2 — hysteresis (D-13)
|
|
138
|
-
__privateAdd(this, _deltaProbeIntervalMs, 0);
|
|
139
|
-
__privateAdd(this, _lastProbeAt, 0);
|
|
140
|
-
__privateAdd(this, _onDeltaFallbackCb, null);
|
|
141
|
-
__privateAdd(this, _onDeltaRecoverCb, null);
|
|
142
|
-
// ── Group-alignment observer (align.ts formula) ──────────────────
|
|
143
|
-
// Observation only — does NOT alter routing. Producers are wired in
|
|
144
|
-
// follow-up PRs; when they land they will call
|
|
145
|
-
// CmcdProducer.incrementSwitchMiscount() + emitSwitchDrift() from the
|
|
146
|
-
// onGroupDrift callback so divergence between packet-stamped groupIds
|
|
147
|
-
// and the shared formula surfaces on `x-bc-switch-drift-us` /
|
|
148
|
-
// `x-bc-switch-miscount`. Canonical Go impl: Blockcast/multicast
|
|
149
|
-
// cmd/caddy/sender/group_align.go (commit 104eeff). Canonical Rust impl:
|
|
150
|
-
// moqtail/moqtail apps/relay/src/server/abr.rs (branch
|
|
151
|
-
// experimental/server-side-abr, commit 39accbf).
|
|
152
|
-
__privateAdd(this, _onGroupDrift, null);
|
|
153
|
-
__privateAdd(this, _groupAlignWarnCounts, /* @__PURE__ */ new Map());
|
|
154
|
-
/**
|
|
155
|
-
* MoQ unicast audio warmup gate. When audio is required, multicast takeover
|
|
156
|
-
* waits until the MoQ unicast audio decoder has emitted at least one frame
|
|
157
|
-
* (so downstream samples-before-takeover counters observe nonzero) or until
|
|
158
|
-
* the existing audio-fallback timer forces the flag true.
|
|
159
|
-
*/
|
|
160
|
-
__privateAdd(this, _moqAudioWarmed, false);
|
|
161
|
-
__privateSet(this, _requireAudio, options?.requireAudio ?? true);
|
|
162
|
-
__privateSet(this, _audioFallbackMs, options?.audioFallbackMs ?? 0);
|
|
163
|
-
__privateSet(this, _crossfadeFrames, options?.crossfadeFrames ?? DEFAULT_CROSSFADE_FRAMES);
|
|
164
|
-
__privateSet(this, _maxOverlayBuffer, options?.maxOverlayBuffer ?? DEFAULT_MAX_OVERLAY_BUFFER);
|
|
165
|
-
__privateSet(this, _maxRepairInFlight, options?.maxRepairInFlight ?? 2);
|
|
166
|
-
__privateSet(this, _allowDeltaMulticastTakeoverAfterMoqKeyframe, options?.allowDeltaMulticastTakeoverAfterMoqKeyframe ?? false);
|
|
88
|
+
this.#requireAudio = options?.requireAudio ?? true;
|
|
89
|
+
this.#audioFallbackMs = options?.audioFallbackMs ?? 0;
|
|
90
|
+
this.#crossfadeFrames = options?.crossfadeFrames ?? DEFAULT_CROSSFADE_FRAMES;
|
|
91
|
+
this.#maxOverlayBuffer = options?.maxOverlayBuffer ?? DEFAULT_MAX_OVERLAY_BUFFER;
|
|
92
|
+
this.#maxRepairInFlight = options?.maxRepairInFlight ?? 2;
|
|
93
|
+
this.#allowDeltaMulticastTakeoverAfterMoqKeyframe = options?.allowDeltaMulticastTakeoverAfterMoqKeyframe ?? false;
|
|
167
94
|
}
|
|
168
95
|
onVideoFrame(cb) {
|
|
169
|
-
|
|
96
|
+
this.#onVideoFrame = cb;
|
|
170
97
|
}
|
|
171
98
|
onAudioFrame(cb) {
|
|
172
|
-
|
|
99
|
+
this.#onAudioFrame = cb;
|
|
173
100
|
}
|
|
174
101
|
onOverlayFrame(cb) {
|
|
175
|
-
|
|
102
|
+
this.#onOverlayFrame = cb;
|
|
176
103
|
}
|
|
177
104
|
onSourceSwitch(cb) {
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
onGroupDrift(cb) {
|
|
181
|
-
__privateSet(this, _onGroupDrift, cb);
|
|
182
|
-
}
|
|
183
|
-
notifyGroupBoundary(trackName, packetGroupId, timingOrMediaTimeSec, groupDurationSec) {
|
|
184
|
-
if (!__privateGet(this, _onGroupDrift)) return;
|
|
185
|
-
const resolved = typeof timingOrMediaTimeSec === "object" && timingOrMediaTimeSec !== null ? __privateMethod(this, _MediaRouter_instances, resolveTicks_fn).call(this, trackName, timingOrMediaTimeSec) : __privateMethod(this, _MediaRouter_instances, resolveSeconds_fn).call(this, trackName, timingOrMediaTimeSec, groupDurationSec);
|
|
186
|
-
if (!resolved) return;
|
|
187
|
-
if (resolved.mediaTimeSec === 0 && packetGroupId !== 0) return;
|
|
188
|
-
const expected = resolved.expected;
|
|
189
|
-
const result = driftCheck(expected, packetGroupId);
|
|
190
|
-
if (result.kind === "aligned") return;
|
|
191
|
-
try {
|
|
192
|
-
__privateGet(this, _onGroupDrift).call(this, {
|
|
193
|
-
trackName,
|
|
194
|
-
expectedGroupId: expected,
|
|
195
|
-
actualGroupId: packetGroupId,
|
|
196
|
-
deltaGroups: result.deltaGroups,
|
|
197
|
-
mediaTimeSec: resolved.mediaTimeSec,
|
|
198
|
-
groupDurationSec: resolved.groupDurationSec,
|
|
199
|
-
...resolved.timing ? { timing: resolved.timing } : {}
|
|
200
|
-
});
|
|
201
|
-
} catch (err) {
|
|
202
|
-
__privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "callback-threw", `[MediaRouter] onGroupDrift callback threw (track=${trackName} expected=${expected} actual=${packetGroupId}); continuing: ${err?.message ?? err}`);
|
|
203
|
-
}
|
|
105
|
+
this.#onSourceSwitch = cb;
|
|
204
106
|
}
|
|
205
107
|
get activeSource() {
|
|
206
|
-
return
|
|
108
|
+
return this.#active;
|
|
207
109
|
}
|
|
208
110
|
// ── Keyframe repair API ──────────────────────────────────────────
|
|
209
111
|
/** Register callback for keyframe repair requests. Player wires this to issue MoQ SUBSCRIBE. */
|
|
210
112
|
onRepairRequest(cb) {
|
|
211
|
-
|
|
113
|
+
this.#onRepairRequest = cb;
|
|
212
114
|
}
|
|
213
115
|
/**
|
|
214
116
|
* Request repair for a lost keyframe group. Only fires when activeSource is 'multicast'.
|
|
@@ -217,17 +119,16 @@ var MediaRouter = class {
|
|
|
217
119
|
* @param trackName - Track name for the SUBSCRIBE (e.g. 'video'). Default: 'video'.
|
|
218
120
|
*/
|
|
219
121
|
repairLostGroup(expectedGroupId, trackName = "video") {
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
if (
|
|
223
|
-
if (__privateGet(this, _repairInFlight).size >= __privateGet(this, _maxRepairInFlight)) {
|
|
122
|
+
if (this.#active !== "multicast") return;
|
|
123
|
+
if (this.#repairInFlight.has(expectedGroupId)) return;
|
|
124
|
+
if (this.#repairInFlight.size >= this.#maxRepairInFlight) {
|
|
224
125
|
console.warn(
|
|
225
|
-
`[MediaRouter] max repair in flight (${
|
|
126
|
+
`[MediaRouter] max repair in flight (${this.#maxRepairInFlight}), dropping repair for group ${expectedGroupId}`
|
|
226
127
|
);
|
|
227
128
|
return;
|
|
228
129
|
}
|
|
229
|
-
|
|
230
|
-
|
|
130
|
+
this.#repairInFlight.add(expectedGroupId);
|
|
131
|
+
this.#onRepairRequest?.(expectedGroupId, trackName);
|
|
231
132
|
}
|
|
232
133
|
/**
|
|
233
134
|
* Feed a recovered keyframe frame from the repair path.
|
|
@@ -235,17 +136,16 @@ var MediaRouter = class {
|
|
|
235
136
|
* Does NOT change activeSource. Does NOT trigger failbackToMoq.
|
|
236
137
|
*/
|
|
237
138
|
feedRepair(data, meta, kind) {
|
|
238
|
-
|
|
239
|
-
if (__privateGet(this, _active) !== "multicast") return;
|
|
139
|
+
if (this.#active !== "multicast") return;
|
|
240
140
|
const routedMeta = { ...meta, source: "repair", recovered: true };
|
|
241
|
-
if (kind === "video")
|
|
242
|
-
else
|
|
141
|
+
if (kind === "video") this.#onVideoFrame?.(data, routedMeta);
|
|
142
|
+
else this.#onAudioFrame?.(data, routedMeta);
|
|
243
143
|
}
|
|
244
144
|
/**
|
|
245
145
|
* Clear repair-in-flight state for a group (called after repair completes or times out).
|
|
246
146
|
*/
|
|
247
147
|
clearRepairInFlight(groupId) {
|
|
248
|
-
|
|
148
|
+
this.#repairInFlight.delete(groupId);
|
|
249
149
|
}
|
|
250
150
|
// ── Phase 14: deltaActive state machine API ──────────────────────
|
|
251
151
|
/**
|
|
@@ -272,17 +172,17 @@ var MediaRouter = class {
|
|
|
272
172
|
"[MediaRouter] configureDelta: either deltaProbeIntervalMs or interleaveDepthMs required for probe interval derivation"
|
|
273
173
|
);
|
|
274
174
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
175
|
+
this.#deltaWindowSize = cfg.deltaFailWindowBlocks ?? Math.ceil(cfg.framerate);
|
|
176
|
+
this.#deltaFailThresholdRatio = cfg.repairSymbols / cfg.sourceSymbols;
|
|
177
|
+
this.#deltaRecoverThresholdRatio = this.#deltaFailThresholdRatio / 2;
|
|
178
|
+
this.#deltaProbeIntervalMs = cfg.deltaProbeIntervalMs ?? computeFecDeliveryWindowMs({
|
|
279
179
|
interleaveDepthMs: cfg.interleaveDepthMs,
|
|
280
180
|
sourceSymbols: cfg.sourceSymbols
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
181
|
+
});
|
|
182
|
+
this.#deltaActive = true;
|
|
183
|
+
this.#deltaWindow = [];
|
|
184
|
+
this.#lastProbeAt = 0;
|
|
185
|
+
this.#deltaConfigured = true;
|
|
286
186
|
}
|
|
287
187
|
/**
|
|
288
188
|
* Notify the state machine of a completed FEC block for the delta track.
|
|
@@ -293,59 +193,58 @@ var MediaRouter = class {
|
|
|
293
193
|
* If configureDelta() has not been called, this is a silent no-op (pre-catalog state).
|
|
294
194
|
*/
|
|
295
195
|
notifyDeltaBlock(failed, nowMs) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
__privateGet(this, _deltaWindow).shift();
|
|
196
|
+
if (!this.#deltaConfigured) return;
|
|
197
|
+
this.#deltaWindow.push(failed);
|
|
198
|
+
if (this.#deltaWindow.length > this.#deltaWindowSize) {
|
|
199
|
+
this.#deltaWindow.shift();
|
|
301
200
|
}
|
|
302
|
-
if (
|
|
303
|
-
const failedCount =
|
|
304
|
-
const ratio = failedCount /
|
|
305
|
-
if (
|
|
306
|
-
if (ratio >
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
201
|
+
if (this.#deltaWindow.length < this.#deltaWindowSize) return;
|
|
202
|
+
const failedCount = this.#deltaWindow.filter((x) => x).length;
|
|
203
|
+
const ratio = failedCount / this.#deltaWindowSize;
|
|
204
|
+
if (this.#deltaActive) {
|
|
205
|
+
if (ratio > this.#deltaFailThresholdRatio) {
|
|
206
|
+
this.#deltaActive = false;
|
|
207
|
+
this.#lastProbeAt = nowMs;
|
|
208
|
+
this.#onDeltaFallbackCb?.();
|
|
310
209
|
}
|
|
311
210
|
} else {
|
|
312
|
-
if (nowMs -
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
211
|
+
if (nowMs - this.#lastProbeAt >= this.#deltaProbeIntervalMs && ratio < this.#deltaRecoverThresholdRatio) {
|
|
212
|
+
this.#deltaActive = true;
|
|
213
|
+
this.#lastProbeAt = nowMs;
|
|
214
|
+
this.#onDeltaRecoverCb?.();
|
|
316
215
|
}
|
|
317
216
|
}
|
|
318
217
|
}
|
|
319
218
|
/** Register callback fired when delta track degrades past threshold (D-12). */
|
|
320
219
|
onDeltaFallback(cb) {
|
|
321
|
-
|
|
220
|
+
this.#onDeltaFallbackCb = cb;
|
|
322
221
|
}
|
|
323
222
|
/** Register callback fired when delta track recovers below recovery threshold (D-13). */
|
|
324
223
|
onDeltaRecover(cb) {
|
|
325
|
-
|
|
224
|
+
this.#onDeltaRecoverCb = cb;
|
|
326
225
|
}
|
|
327
226
|
/** Whether the delta track is currently considered healthy (true = active). */
|
|
328
227
|
get deltaActive() {
|
|
329
|
-
return
|
|
228
|
+
return this.#deltaActive;
|
|
330
229
|
}
|
|
331
230
|
// ── Test-visible accessors for threshold verification ────────────
|
|
332
231
|
// These expose internal derived values for test assertions (Tests 3,4,5,6,7).
|
|
333
232
|
// Prefixed with 'delta' to namespace clearly within the public API surface.
|
|
334
233
|
/** Derived window size — exposed for test assertions (Test 3, 4). */
|
|
335
234
|
get deltaWindowSize() {
|
|
336
|
-
return
|
|
235
|
+
return this.#deltaWindowSize;
|
|
337
236
|
}
|
|
338
237
|
/** Derived fail threshold ratio (P/K) — exposed for test assertions (Test 6). */
|
|
339
238
|
get deltaFailThresholdRatio() {
|
|
340
|
-
return
|
|
239
|
+
return this.#deltaFailThresholdRatio;
|
|
341
240
|
}
|
|
342
241
|
/** Derived recovery threshold ratio ((P/K)/2) — exposed for test assertions (Test 7). */
|
|
343
242
|
get deltaRecoverThresholdRatio() {
|
|
344
|
-
return
|
|
243
|
+
return this.#deltaRecoverThresholdRatio;
|
|
345
244
|
}
|
|
346
245
|
/** Derived probe interval ms — exposed for test assertions (Test 5a). */
|
|
347
246
|
get deltaProbeIntervalMs() {
|
|
348
|
-
return
|
|
247
|
+
return this.#deltaProbeIntervalMs;
|
|
349
248
|
}
|
|
350
249
|
/**
|
|
351
250
|
* Register a track name → type mapping from catalog.
|
|
@@ -353,7 +252,7 @@ var MediaRouter = class {
|
|
|
353
252
|
* takes precedence until the next catalog update.
|
|
354
253
|
*/
|
|
355
254
|
registerTrackType(trackName, type) {
|
|
356
|
-
|
|
255
|
+
this.#trackTypes.set(trackName, { type, source: "catalog" });
|
|
357
256
|
}
|
|
358
257
|
/**
|
|
359
258
|
* Register a track name → type from init data / inline signaling (MMTP FT=0).
|
|
@@ -361,9 +260,9 @@ var MediaRouter = class {
|
|
|
361
260
|
* Does NOT overwrite an existing catalog registration.
|
|
362
261
|
*/
|
|
363
262
|
registerTrackTypeFromInit(trackName, type) {
|
|
364
|
-
const existing =
|
|
263
|
+
const existing = this.#trackTypes.get(trackName);
|
|
365
264
|
if (existing?.source === "catalog") return;
|
|
366
|
-
|
|
265
|
+
this.#trackTypes.set(trackName, { type, source: "init" });
|
|
367
266
|
}
|
|
368
267
|
/**
|
|
369
268
|
* Assign a per-track source. Frames from this source bypass the binary
|
|
@@ -373,12 +272,12 @@ var MediaRouter = class {
|
|
|
373
272
|
* track without a clearTrackSource() in between.
|
|
374
273
|
*/
|
|
375
274
|
setTrackSource(trackName, source, opts) {
|
|
376
|
-
if (
|
|
275
|
+
if (this.#trackSources.has(trackName)) {
|
|
377
276
|
throw new TrackSourceConflictError(trackName);
|
|
378
277
|
}
|
|
379
278
|
const effectivePolicy = opts?.policy ?? (opts?.overlay ? "wait" : void 0);
|
|
380
279
|
if (effectivePolicy === "crossfade") {
|
|
381
|
-
|
|
280
|
+
this.#crossfadeCounters.set(trackName, this.#crossfadeFrames);
|
|
382
281
|
}
|
|
383
282
|
const record = {
|
|
384
283
|
source,
|
|
@@ -389,9 +288,9 @@ var MediaRouter = class {
|
|
|
389
288
|
record.unsubscribeFrame = source.onFrame((data, meta) => {
|
|
390
289
|
record.emitCount++;
|
|
391
290
|
if (effectivePolicy === "wait") {
|
|
392
|
-
|
|
291
|
+
this.#handleOverlayFrame(data, meta);
|
|
393
292
|
} else {
|
|
394
|
-
|
|
293
|
+
this.#emitForTrack(trackName, data, meta);
|
|
395
294
|
}
|
|
396
295
|
});
|
|
397
296
|
if (source.onError) {
|
|
@@ -399,25 +298,25 @@ var MediaRouter = class {
|
|
|
399
298
|
this.clearTrackSource(trackName);
|
|
400
299
|
});
|
|
401
300
|
}
|
|
402
|
-
|
|
301
|
+
this.#trackSources.set(trackName, record);
|
|
403
302
|
}
|
|
404
303
|
/**
|
|
405
304
|
* Remove the per-track source for the given track.
|
|
406
305
|
* Binary switching resumes for this track after this call.
|
|
407
306
|
*/
|
|
408
307
|
clearTrackSource(trackName) {
|
|
409
|
-
const record =
|
|
308
|
+
const record = this.#trackSources.get(trackName);
|
|
410
309
|
if (!record) return;
|
|
411
310
|
record.unsubscribeFrame();
|
|
412
311
|
record.unsubscribeError?.();
|
|
413
312
|
record.source.dispose?.();
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const reg =
|
|
313
|
+
this.#trackSources.delete(trackName);
|
|
314
|
+
this.#crossfadeCounters.delete(trackName);
|
|
315
|
+
const reg = this.#trackTypes.get(trackName);
|
|
417
316
|
const isMedia = reg?.type === "video" || reg?.type === "audio" || reg === void 0 && (trackName === "video" || trackName === "audio");
|
|
418
317
|
if (!isMedia) {
|
|
419
|
-
|
|
420
|
-
|
|
318
|
+
this.#overlayBoundaryReached = false;
|
|
319
|
+
this.#overlayBuffer = [];
|
|
421
320
|
}
|
|
422
321
|
}
|
|
423
322
|
/**
|
|
@@ -425,12 +324,11 @@ var MediaRouter = class {
|
|
|
425
324
|
* Overlay tracks waiting for alignment flush their buffered frames now.
|
|
426
325
|
*/
|
|
427
326
|
notifyFecBlockBoundary() {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const buffered = __privateGet(this, _overlayBuffer).splice(0);
|
|
327
|
+
if (this.#overlayBoundaryReached) return;
|
|
328
|
+
this.#overlayBoundaryReached = true;
|
|
329
|
+
const buffered = this.#overlayBuffer.splice(0);
|
|
432
330
|
for (const { data, meta } of buffered) {
|
|
433
|
-
|
|
331
|
+
this.#onOverlayFrame?.(data, meta);
|
|
434
332
|
}
|
|
435
333
|
}
|
|
436
334
|
/**
|
|
@@ -439,97 +337,102 @@ var MediaRouter = class {
|
|
|
439
337
|
* Returns 0 if no per-track source is active for the track.
|
|
440
338
|
*/
|
|
441
339
|
trackSourceEmitCount(trackName) {
|
|
442
|
-
return
|
|
340
|
+
return this.#trackSources.get(trackName)?.emitCount ?? 0;
|
|
443
341
|
}
|
|
444
342
|
/** Feed a frame from the MoQ path. Suppressed when multicast is active OR a per-track source owns this track. */
|
|
445
343
|
feedMoq(data, meta, kind) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const remaining = __privateGet(this, _crossfadeCounters).get(kind);
|
|
344
|
+
if (this.#trackSources.has(kind)) {
|
|
345
|
+
const remaining = this.#crossfadeCounters.get(kind);
|
|
449
346
|
if (remaining && remaining > 0) {
|
|
450
347
|
const next = remaining - 1;
|
|
451
348
|
if (next === 0) {
|
|
452
|
-
|
|
349
|
+
this.#crossfadeCounters.delete(kind);
|
|
453
350
|
} else {
|
|
454
|
-
|
|
351
|
+
this.#crossfadeCounters.set(kind, next);
|
|
455
352
|
}
|
|
456
353
|
} else {
|
|
457
354
|
return;
|
|
458
355
|
}
|
|
459
356
|
}
|
|
460
|
-
if (
|
|
357
|
+
if (this.#suppressed) return;
|
|
461
358
|
const routedMeta = { ...meta, source: "moq" };
|
|
462
|
-
if (kind === "video")
|
|
463
|
-
else
|
|
359
|
+
if (kind === "video") this.#onVideoFrame?.(data, routedMeta);
|
|
360
|
+
else this.#onAudioFrame?.(data, routedMeta);
|
|
464
361
|
}
|
|
465
362
|
/** Feed a frame from the multicast path. Video waits for keyframe before activating. */
|
|
466
363
|
feedMulticast(data, meta, kind) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const remaining = __privateGet(this, _crossfadeCounters).get(kind);
|
|
364
|
+
if (this.#trackSources.has(kind)) {
|
|
365
|
+
const remaining = this.#crossfadeCounters.get(kind);
|
|
470
366
|
if (remaining && remaining > 0) {
|
|
471
367
|
const next = remaining - 1;
|
|
472
368
|
if (next === 0) {
|
|
473
|
-
|
|
369
|
+
this.#crossfadeCounters.delete(kind);
|
|
474
370
|
} else {
|
|
475
|
-
|
|
371
|
+
this.#crossfadeCounters.set(kind, next);
|
|
476
372
|
}
|
|
477
373
|
} else {
|
|
478
374
|
return;
|
|
479
375
|
}
|
|
480
376
|
}
|
|
481
377
|
if (kind === "video") {
|
|
482
|
-
if (!
|
|
483
|
-
const moqSeededDelta = !meta.keyframe &&
|
|
378
|
+
if (!this.#multicastVideoKeyed) {
|
|
379
|
+
const moqSeededDelta = !meta.keyframe && this.#allowDeltaMulticastTakeoverAfterMoqKeyframe && this.#moqVideoKeyframeEmitted;
|
|
484
380
|
if (!meta.keyframe && !moqSeededDelta) return;
|
|
485
|
-
|
|
381
|
+
this.#multicastVideoKeyed = true;
|
|
486
382
|
const pendingMeta = { ...meta, source: "multicast" };
|
|
487
383
|
if (!moqSeededDelta) pendingMeta.sourceDiscontinuity = true;
|
|
488
|
-
|
|
384
|
+
this.#pendingMulticastVideo = {
|
|
489
385
|
data: data.slice(),
|
|
490
386
|
meta: pendingMeta
|
|
491
|
-
}
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
if (!
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
387
|
+
};
|
|
388
|
+
if (this.#requireAudio && this.#audioFallbackMs > 0 && !this.#multicastAudioReceived && !this.#audioFallbackTimer) {
|
|
389
|
+
this.#audioFallbackTimer = setTimeout(() => {
|
|
390
|
+
if (!this.#multicastAudioReceived && this.#active !== "multicast") {
|
|
391
|
+
this.#multicastAudioReceived = true;
|
|
392
|
+
this.#moqAudioWarmed = true;
|
|
393
|
+
this.#tryActivateMulticast();
|
|
498
394
|
}
|
|
499
|
-
},
|
|
395
|
+
}, this.#audioFallbackMs);
|
|
500
396
|
}
|
|
501
|
-
} else if (
|
|
397
|
+
} else if (this.#active !== "multicast") {
|
|
502
398
|
if (meta.keyframe) {
|
|
503
|
-
|
|
399
|
+
this.#pendingMulticastVideo = {
|
|
504
400
|
data: data.slice(),
|
|
505
401
|
meta: { ...meta, source: "multicast", sourceDiscontinuity: true }
|
|
506
|
-
}
|
|
402
|
+
};
|
|
507
403
|
}
|
|
508
|
-
|
|
404
|
+
this.#tryActivateMulticast();
|
|
509
405
|
return;
|
|
510
406
|
}
|
|
511
|
-
if (
|
|
512
|
-
|
|
407
|
+
if (this.#active === "multicast") this.#onVideoFrame?.(data, { ...meta, source: "multicast" });
|
|
408
|
+
this.#tryActivateMulticast();
|
|
513
409
|
} else {
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
clearTimeout(
|
|
517
|
-
|
|
410
|
+
this.#multicastAudioReceived = true;
|
|
411
|
+
if (this.#audioFallbackTimer) {
|
|
412
|
+
clearTimeout(this.#audioFallbackTimer);
|
|
413
|
+
this.#audioFallbackTimer = null;
|
|
518
414
|
}
|
|
519
|
-
if (!
|
|
520
|
-
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
} else if (
|
|
524
|
-
|
|
415
|
+
if (!this.#moqAudioWarmed) this.#moqAudioWarmed = true;
|
|
416
|
+
this.#tryActivateMulticast();
|
|
417
|
+
if (this.#active === "multicast") {
|
|
418
|
+
this.#onAudioFrame?.(data, { ...meta, source: "multicast" });
|
|
419
|
+
} else if (this.#pendingMulticastToken !== null) {
|
|
420
|
+
this.#pendingMulticastAudio = { data: data.slice(), meta: { ...meta, source: "multicast" } };
|
|
525
421
|
}
|
|
526
422
|
}
|
|
527
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* MoQ unicast audio warmup gate. When audio is required, multicast takeover
|
|
426
|
+
* waits until the MoQ unicast audio decoder has emitted at least one frame
|
|
427
|
+
* (so downstream samples-before-takeover counters observe nonzero) or until
|
|
428
|
+
* the existing audio-fallback timer forces the flag true.
|
|
429
|
+
*/
|
|
430
|
+
#moqAudioWarmed = false;
|
|
528
431
|
/** Called by the player when the MoQ unicast audio decoder emits first frame. */
|
|
529
432
|
notifyMoqAudioEmit() {
|
|
530
|
-
if (
|
|
531
|
-
|
|
532
|
-
|
|
433
|
+
if (this.#moqAudioWarmed) return;
|
|
434
|
+
this.#moqAudioWarmed = true;
|
|
435
|
+
this.#tryActivateMulticast();
|
|
533
436
|
}
|
|
534
437
|
/**
|
|
535
438
|
* Called by the player after a MoQ video keyframe has reached the active
|
|
@@ -537,249 +440,112 @@ var MediaRouter = class {
|
|
|
537
440
|
* paths leave allowDeltaMulticastTakeoverAfterMoqKeyframe disabled.
|
|
538
441
|
*/
|
|
539
442
|
notifyMoqVideoKeyframeEmit() {
|
|
540
|
-
|
|
541
|
-
|
|
443
|
+
this.#moqVideoKeyframeEmitted = true;
|
|
444
|
+
this.#tryActivateMulticast();
|
|
445
|
+
}
|
|
446
|
+
#tryActivateMulticast() {
|
|
447
|
+
if (this.#active === "multicast") return;
|
|
448
|
+
if (this.#pendingMulticastToken !== null) return;
|
|
449
|
+
if (!this.#multicastVideoKeyed) return;
|
|
450
|
+
if (this.#requireAudio && !this.#multicastAudioReceived) return;
|
|
451
|
+
if (this.#requireAudio && !this.#moqAudioWarmed) return;
|
|
452
|
+
const token = ++this.#sourceSwitchToken;
|
|
453
|
+
const maybeReady = this.#onSourceSwitch?.("multicast");
|
|
454
|
+
if (!maybeReady || typeof maybeReady.then !== "function") {
|
|
455
|
+
this.#commitMulticastActivation(token);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const ready = Promise.resolve(maybeReady);
|
|
459
|
+
this.#pendingMulticastToken = token;
|
|
460
|
+
this.#sourceSwitchReady = ready;
|
|
461
|
+
void ready.then(
|
|
462
|
+
() => this.#commitMulticastActivation(token),
|
|
463
|
+
(err) => this.#rejectMulticastActivation(token, err)
|
|
464
|
+
).finally(() => {
|
|
465
|
+
if (this.#sourceSwitchReady === ready) this.#sourceSwitchReady = null;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
#commitMulticastActivation(token) {
|
|
469
|
+
if (token !== this.#sourceSwitchToken) return;
|
|
470
|
+
this.#active = "multicast";
|
|
471
|
+
this.#suppressed = true;
|
|
472
|
+
this.#pendingMulticastToken = null;
|
|
473
|
+
const video = this.#pendingMulticastVideo;
|
|
474
|
+
this.#pendingMulticastVideo = null;
|
|
475
|
+
const audio = this.#pendingMulticastAudio;
|
|
476
|
+
this.#pendingMulticastAudio = null;
|
|
477
|
+
if (video) this.#onVideoFrame?.(video.data, video.meta);
|
|
478
|
+
if (audio) this.#onAudioFrame?.(audio.data, audio.meta);
|
|
479
|
+
}
|
|
480
|
+
#rejectMulticastActivation(token, err) {
|
|
481
|
+
if (token !== this.#sourceSwitchToken) return;
|
|
482
|
+
if (this.#pendingMulticastToken === token) this.#pendingMulticastToken = null;
|
|
483
|
+
this.#pendingMulticastVideo = null;
|
|
484
|
+
this.#pendingMulticastAudio = null;
|
|
485
|
+
console.warn("[MediaRouter] onSourceSwitch(multicast) failed", err);
|
|
542
486
|
}
|
|
543
487
|
/** Switch back to MoQ immediately (called on multicast failback). */
|
|
544
488
|
failbackToMoq() {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
__privateSet(this, _audioFallbackTimer, null);
|
|
489
|
+
const hadPendingMulticast = this.#pendingMulticastToken !== null;
|
|
490
|
+
if (this.#active === "moq" && !hadPendingMulticast) return;
|
|
491
|
+
++this.#sourceSwitchToken;
|
|
492
|
+
this.#active = "moq";
|
|
493
|
+
this.#suppressed = false;
|
|
494
|
+
this.#pendingMulticastToken = null;
|
|
495
|
+
this.#pendingMulticastVideo = null;
|
|
496
|
+
this.#pendingMulticastAudio = null;
|
|
497
|
+
this.#sourceSwitchReady = null;
|
|
498
|
+
this.#multicastVideoKeyed = false;
|
|
499
|
+
this.#multicastAudioReceived = false;
|
|
500
|
+
this.#moqVideoKeyframeEmitted = false;
|
|
501
|
+
if (this.#audioFallbackTimer) {
|
|
502
|
+
clearTimeout(this.#audioFallbackTimer);
|
|
503
|
+
this.#audioFallbackTimer = null;
|
|
561
504
|
}
|
|
562
|
-
|
|
505
|
+
this.#onSourceSwitch?.("moq");
|
|
563
506
|
}
|
|
564
507
|
/** Dispose timers and per-track sources. Call on teardown to prevent
|
|
565
508
|
* stale timer callbacks firing into garbage-collected closures (WR-03). */
|
|
566
509
|
dispose() {
|
|
567
|
-
if (
|
|
568
|
-
clearTimeout(
|
|
569
|
-
|
|
510
|
+
if (this.#audioFallbackTimer) {
|
|
511
|
+
clearTimeout(this.#audioFallbackTimer);
|
|
512
|
+
this.#audioFallbackTimer = null;
|
|
570
513
|
}
|
|
571
|
-
for (const [name] of
|
|
514
|
+
for (const [name] of this.#trackSources) {
|
|
572
515
|
this.clearTrackSource(name);
|
|
573
516
|
}
|
|
574
517
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
_onAudioFrame = new WeakMap();
|
|
592
|
-
_onOverlayFrame = new WeakMap();
|
|
593
|
-
_onSourceSwitch = new WeakMap();
|
|
594
|
-
_sourceSwitchReady = new WeakMap();
|
|
595
|
-
_sourceSwitchToken = new WeakMap();
|
|
596
|
-
_pendingMulticastToken = new WeakMap();
|
|
597
|
-
_pendingMulticastVideo = new WeakMap();
|
|
598
|
-
_pendingMulticastAudio = new WeakMap();
|
|
599
|
-
_trackSources = new WeakMap();
|
|
600
|
-
_trackTypes = new WeakMap();
|
|
601
|
-
_crossfadeCounters = new WeakMap();
|
|
602
|
-
_overlayBoundaryReached = new WeakMap();
|
|
603
|
-
_overlayBuffer = new WeakMap();
|
|
604
|
-
_deltaConfigured = new WeakMap();
|
|
605
|
-
_deltaActive = new WeakMap();
|
|
606
|
-
_deltaWindow = new WeakMap();
|
|
607
|
-
_deltaWindowSize = new WeakMap();
|
|
608
|
-
_deltaFailThresholdRatio = new WeakMap();
|
|
609
|
-
_deltaRecoverThresholdRatio = new WeakMap();
|
|
610
|
-
_deltaProbeIntervalMs = new WeakMap();
|
|
611
|
-
_lastProbeAt = new WeakMap();
|
|
612
|
-
_onDeltaFallbackCb = new WeakMap();
|
|
613
|
-
_onDeltaRecoverCb = new WeakMap();
|
|
614
|
-
_onGroupDrift = new WeakMap();
|
|
615
|
-
_groupAlignWarnCounts = new WeakMap();
|
|
616
|
-
_MediaRouter_instances = new WeakSet();
|
|
617
|
-
/**
|
|
618
|
-
* Warn at most `GROUP_ALIGN_WARN_BUDGET[reason]` times **per reason**, across
|
|
619
|
-
* every skip and post-emit failure on the drift path.
|
|
620
|
-
*
|
|
621
|
-
* Note the two call shapes: the resolvers call this *instead of* computing a
|
|
622
|
-
* groupId, and return its `null` to skip the drift check; the `onGroupDrift`
|
|
623
|
-
* catch calls it after the check already ran and the event was already
|
|
624
|
-
* emitted, so there only the warn is coalesced and the `null` is discarded.
|
|
625
|
-
*
|
|
626
|
-
* Keyed on a short stable `reason` tag, NOT on the formatted message: the
|
|
627
|
-
* messages interpolate track name and operand values, so message-keying
|
|
628
|
-
* would hand a malformed stream a fresh warn slot on every boundary — the
|
|
629
|
-
* log flood this coalescing exists to prevent.
|
|
630
|
-
*
|
|
631
|
-
* Per-reason rather than one shared boolean (PCL-2211, #329 review): the
|
|
632
|
-
* budget is never reset — not by `dispose()`, not on source switch — so a
|
|
633
|
-
* single flag means the FIRST malformed boundary of a long-running stream
|
|
634
|
-
* permanently silences every later, genuinely different failure mode. The
|
|
635
|
-
* throw/overflow diagnostics carry the operand values (`ticks=`, `durTicks=`,
|
|
636
|
-
* `err.message`) an incident responder actually needs, and under one shared
|
|
637
|
-
* flag those are precisely the ones most likely to be already spent by an
|
|
638
|
-
* unrelated NaN at catalog load.
|
|
639
|
-
*
|
|
640
|
-
* A closed, bounded set of reasons times a small per-reason budget is still
|
|
641
|
-
* bounded, so this cannot flood. See `GROUP_ALIGN_WARN_BUDGET` for why the
|
|
642
|
-
* budget is not uniform.
|
|
643
|
-
*/
|
|
644
|
-
skipWithWarning_fn = function(reason, message) {
|
|
645
|
-
const seen = __privateGet(this, _groupAlignWarnCounts).get(reason) ?? 0;
|
|
646
|
-
if (seen < GROUP_ALIGN_WARN_BUDGET[reason]) {
|
|
647
|
-
__privateGet(this, _groupAlignWarnCounts).set(reason, seen + 1);
|
|
648
|
-
console.warn(message);
|
|
649
|
-
}
|
|
650
|
-
return null;
|
|
651
|
-
};
|
|
652
|
-
/**
|
|
653
|
-
* Exact path: integers straight from the catalog, no rounding. `mediaTimeSec`
|
|
654
|
-
* / `groupDurationSec` are derived for reporting only and never feed the
|
|
655
|
-
* groupId computation.
|
|
656
|
-
*/
|
|
657
|
-
resolveTicks_fn = function(trackName, timing) {
|
|
658
|
-
const { mediaTimeTicks, groupDurationTicks, timescale } = timing;
|
|
659
|
-
if (!Number.isInteger(mediaTimeTicks) || !Number.isInteger(groupDurationTicks) || groupDurationTicks <= 0 || !Number.isInteger(timescale) || timescale <= 0) {
|
|
660
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "invalid-tick-inputs", `[MediaRouter] notifyGroupBoundary invalid tick inputs (track=${trackName} mediaTimeTicks=${mediaTimeTicks} groupDurationTicks=${groupDurationTicks} timescale=${timescale}); skipping drift check. Pre-validate at catalog load time.`);
|
|
661
|
-
}
|
|
662
|
-
try {
|
|
663
|
-
return {
|
|
664
|
-
expected: groupIdForTicks(mediaTimeTicks, groupDurationTicks),
|
|
665
|
-
mediaTimeSec: mediaTimeTicks / timescale,
|
|
666
|
-
groupDurationSec: groupDurationTicks / timescale,
|
|
667
|
-
// Snapshot, not the caller's reference: a producer that reuses one
|
|
668
|
-
// scratch object per boundary would otherwise retroactively mutate
|
|
669
|
-
// every GroupDriftEvent it has already emitted. Three integers.
|
|
670
|
-
timing: { mediaTimeTicks, groupDurationTicks, timescale }
|
|
671
|
-
};
|
|
672
|
-
} catch (err) {
|
|
673
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "ticks-formula-threw", `[MediaRouter] notifyGroupBoundary: groupIdForTicks threw (track=${trackName} mediaTimeTicks=${mediaTimeTicks} groupDurationTicks=${groupDurationTicks}); skipping drift check: ${err?.message ?? err}`);
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* Legacy seconds path. Quantizes to a synthetic 1e9 Hz timescale — the exact
|
|
678
|
-
* behaviour the deprecated `align.groupIdFor` wrapper had, reproduced here so
|
|
679
|
-
* that wrapper has no non-test callers left and can be deleted (BLO-21176).
|
|
680
|
-
*
|
|
681
|
-
* Inherits that wrapper's ns-rounding error; see the `@deprecated` overload.
|
|
682
|
-
* Delete this branch once every caller passes ticks.
|
|
683
|
-
*/
|
|
684
|
-
resolveSeconds_fn = function(trackName, mediaTimeSec, groupDurationSec) {
|
|
685
|
-
if (!Number.isFinite(groupDurationSec) || groupDurationSec <= 0 || !Number.isFinite(mediaTimeSec)) {
|
|
686
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "invalid-seconds-inputs", `[MediaRouter] notifyGroupBoundary invalid inputs (track=${trackName} mediaTimeSec=${mediaTimeSec} groupDurationSec=${groupDurationSec}); skipping drift check. Pre-validate at catalog load time.`);
|
|
687
|
-
}
|
|
688
|
-
const TS = 1e9;
|
|
689
|
-
const ticks = mediaTimeSec < 0 ? 0 : Math.round(mediaTimeSec * TS);
|
|
690
|
-
const durTicks = Math.round(groupDurationSec * TS);
|
|
691
|
-
if (durTicks <= 0) {
|
|
692
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "sub-nanosecond-duration", `[MediaRouter] notifyGroupBoundary: groupDurationSec=${groupDurationSec} rounds to <1 tick at 1e9 Hz (track=${trackName}); skipping drift check. Pass GroupBoundaryTicks for sub-nanosecond durations.`);
|
|
693
|
-
}
|
|
694
|
-
if (!Number.isSafeInteger(ticks)) {
|
|
695
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "media-time-overflow", `[MediaRouter] notifyGroupBoundary: mediaTimeSec=${mediaTimeSec} overflows safe-integer ticks at 1e9 Hz (>~104 days, track=${trackName}); skipping drift check. Pass GroupBoundaryTicks with the catalog timescale.`);
|
|
696
|
-
}
|
|
697
|
-
try {
|
|
698
|
-
return {
|
|
699
|
-
expected: groupIdForTicks(ticks, durTicks),
|
|
700
|
-
mediaTimeSec,
|
|
701
|
-
groupDurationSec
|
|
702
|
-
};
|
|
703
|
-
} catch (err) {
|
|
704
|
-
return __privateMethod(this, _MediaRouter_instances, skipWithWarning_fn).call(this, "seconds-formula-threw", `[MediaRouter] notifyGroupBoundary: groupIdForTicks threw (track=${trackName} mediaTimeSec=${mediaTimeSec} groupDurationSec=${groupDurationSec} ticks=${ticks} durTicks=${durTicks}); skipping drift check: ${err?.message ?? err}`);
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
_moqAudioWarmed = new WeakMap();
|
|
708
|
-
tryActivateMulticast_fn = function() {
|
|
709
|
-
var _a;
|
|
710
|
-
if (__privateGet(this, _active) === "multicast") return;
|
|
711
|
-
if (__privateGet(this, _pendingMulticastToken) !== null) return;
|
|
712
|
-
if (!__privateGet(this, _multicastVideoKeyed)) return;
|
|
713
|
-
if (__privateGet(this, _requireAudio) && !__privateGet(this, _multicastAudioReceived)) return;
|
|
714
|
-
if (__privateGet(this, _requireAudio) && !__privateGet(this, _moqAudioWarmed)) return;
|
|
715
|
-
const token = ++__privateWrapper(this, _sourceSwitchToken)._;
|
|
716
|
-
const maybeReady = (_a = __privateGet(this, _onSourceSwitch)) == null ? void 0 : _a.call(this, "multicast");
|
|
717
|
-
if (!maybeReady || typeof maybeReady.then !== "function") {
|
|
718
|
-
__privateMethod(this, _MediaRouter_instances, commitMulticastActivation_fn).call(this, token);
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
const ready = Promise.resolve(maybeReady);
|
|
722
|
-
__privateSet(this, _pendingMulticastToken, token);
|
|
723
|
-
__privateSet(this, _sourceSwitchReady, ready);
|
|
724
|
-
void ready.then(
|
|
725
|
-
() => __privateMethod(this, _MediaRouter_instances, commitMulticastActivation_fn).call(this, token),
|
|
726
|
-
(err) => __privateMethod(this, _MediaRouter_instances, rejectMulticastActivation_fn).call(this, token, err)
|
|
727
|
-
).finally(() => {
|
|
728
|
-
if (__privateGet(this, _sourceSwitchReady) === ready) __privateSet(this, _sourceSwitchReady, null);
|
|
729
|
-
});
|
|
730
|
-
};
|
|
731
|
-
commitMulticastActivation_fn = function(token) {
|
|
732
|
-
var _a, _b;
|
|
733
|
-
if (token !== __privateGet(this, _sourceSwitchToken)) return;
|
|
734
|
-
__privateSet(this, _active, "multicast");
|
|
735
|
-
__privateSet(this, _suppressed, true);
|
|
736
|
-
__privateSet(this, _pendingMulticastToken, null);
|
|
737
|
-
const video = __privateGet(this, _pendingMulticastVideo);
|
|
738
|
-
__privateSet(this, _pendingMulticastVideo, null);
|
|
739
|
-
const audio = __privateGet(this, _pendingMulticastAudio);
|
|
740
|
-
__privateSet(this, _pendingMulticastAudio, null);
|
|
741
|
-
if (video) (_a = __privateGet(this, _onVideoFrame)) == null ? void 0 : _a.call(this, video.data, video.meta);
|
|
742
|
-
if (audio) (_b = __privateGet(this, _onAudioFrame)) == null ? void 0 : _b.call(this, audio.data, audio.meta);
|
|
743
|
-
};
|
|
744
|
-
rejectMulticastActivation_fn = function(token, err) {
|
|
745
|
-
if (token !== __privateGet(this, _sourceSwitchToken)) return;
|
|
746
|
-
if (__privateGet(this, _pendingMulticastToken) === token) __privateSet(this, _pendingMulticastToken, null);
|
|
747
|
-
__privateSet(this, _pendingMulticastVideo, null);
|
|
748
|
-
__privateSet(this, _pendingMulticastAudio, null);
|
|
749
|
-
console.warn("[MediaRouter] onSourceSwitch(multicast) failed", err);
|
|
750
|
-
};
|
|
751
|
-
// ── Private helpers ──────────────────────────────────────────────────────
|
|
752
|
-
/** Emit a frame on the correct per-track callback using the type registry.
|
|
753
|
-
* Falls back to name match if no type registered (backward compat). */
|
|
754
|
-
emitForTrack_fn = function(trackName, data, meta) {
|
|
755
|
-
var _a, _b, _c, _d, _e, _f;
|
|
756
|
-
const reg = __privateGet(this, _trackTypes).get(trackName);
|
|
757
|
-
if (reg?.type === "video") {
|
|
758
|
-
(_a = __privateGet(this, _onVideoFrame)) == null ? void 0 : _a.call(this, data, meta);
|
|
759
|
-
} else if (reg?.type === "audio") {
|
|
760
|
-
(_b = __privateGet(this, _onAudioFrame)) == null ? void 0 : _b.call(this, data, meta);
|
|
761
|
-
} else if (reg !== void 0) {
|
|
762
|
-
(_c = __privateGet(this, _onOverlayFrame)) == null ? void 0 : _c.call(this, data, meta);
|
|
763
|
-
} else {
|
|
764
|
-
if (trackName === "video") (_d = __privateGet(this, _onVideoFrame)) == null ? void 0 : _d.call(this, data, meta);
|
|
765
|
-
else if (trackName === "audio") (_e = __privateGet(this, _onAudioFrame)) == null ? void 0 : _e.call(this, data, meta);
|
|
766
|
-
else (_f = __privateGet(this, _onOverlayFrame)) == null ? void 0 : _f.call(this, data, meta);
|
|
518
|
+
// ── Private helpers ──────────────────────────────────────────────────────
|
|
519
|
+
/** Emit a frame on the correct per-track callback using the type registry.
|
|
520
|
+
* Falls back to name match if no type registered (backward compat). */
|
|
521
|
+
#emitForTrack(trackName, data, meta) {
|
|
522
|
+
const reg = this.#trackTypes.get(trackName);
|
|
523
|
+
if (reg?.type === "video") {
|
|
524
|
+
this.#onVideoFrame?.(data, meta);
|
|
525
|
+
} else if (reg?.type === "audio") {
|
|
526
|
+
this.#onAudioFrame?.(data, meta);
|
|
527
|
+
} else if (reg !== void 0) {
|
|
528
|
+
this.#onOverlayFrame?.(data, meta);
|
|
529
|
+
} else {
|
|
530
|
+
if (trackName === "video") this.#onVideoFrame?.(data, meta);
|
|
531
|
+
else if (trackName === "audio") this.#onAudioFrame?.(data, meta);
|
|
532
|
+
else this.#onOverlayFrame?.(data, meta);
|
|
533
|
+
}
|
|
767
534
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
535
|
+
/** Handle an overlay frame: buffer until first FEC block boundary, then pass through. */
|
|
536
|
+
#handleOverlayFrame(data, meta) {
|
|
537
|
+
if (this.#overlayBoundaryReached) {
|
|
538
|
+
this.#onOverlayFrame?.(data, meta);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (this.#overlayBuffer.length >= this.#maxOverlayBuffer) {
|
|
542
|
+
console.warn(
|
|
543
|
+
`[MediaRouter] overlay buffer full (${this.#maxOverlayBuffer} frames); dropping frame ts=${meta.timestamp}`
|
|
544
|
+
);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
this.#overlayBuffer.push({ data, meta });
|
|
781
548
|
}
|
|
782
|
-
__privateGet(this, _overlayBuffer).push({ data, meta });
|
|
783
549
|
};
|
|
784
550
|
export {
|
|
785
551
|
MediaRouter,
|