@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.
Files changed (148) hide show
  1. package/dist/align.d.ts +6 -2
  2. package/dist/align.d.ts.map +1 -1
  3. package/dist/align.js.map +2 -2
  4. package/dist/audio-ring-buffer.js +23 -36
  5. package/dist/audio-ring-buffer.js.map +1 -1
  6. package/dist/browser-runtime.js +6865 -6485
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +3 -1
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +21 -2
  11. package/dist/carp-catalog.js.map +4 -4
  12. package/dist/catalog-fec-params.js +10 -0
  13. package/dist/catalog-fec-params.js.map +4 -4
  14. package/dist/cmaf-block-assembler.d.ts +42 -0
  15. package/dist/cmaf-block-assembler.d.ts.map +1 -1
  16. package/dist/cmaf-block-assembler.js +542 -535
  17. package/dist/cmaf-block-assembler.js.map +2 -2
  18. package/dist/cmaf-group-batcher.js +27 -46
  19. package/dist/cmaf-group-batcher.js.map +2 -2
  20. package/dist/cmcd-producer.js +45 -66
  21. package/dist/cmcd-producer.js.map +1 -1
  22. package/dist/fec-manager.d.ts +13 -1
  23. package/dist/fec-manager.d.ts.map +1 -1
  24. package/dist/fec-manager.js +1151 -871
  25. package/dist/fec-manager.js.map +2 -2
  26. package/dist/fec-starvation-detector.js +25 -40
  27. package/dist/fec-starvation-detector.js.map +1 -1
  28. package/dist/fec-worker-setup.js +242 -225
  29. package/dist/fec-worker-setup.js.map +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js.map +2 -2
  33. package/dist/iso-bmff-timing.js +63 -88
  34. package/dist/iso-bmff-timing.js.map +1 -1
  35. package/dist/loc.js +7 -4
  36. package/dist/loc.js.map +1 -1
  37. package/dist/manifest-auth-plan.js +292 -311
  38. package/dist/manifest-auth-plan.js.map +1 -1
  39. package/dist/media-router.d.ts +0 -99
  40. package/dist/media-router.d.ts.map +1 -1
  41. package/dist/media-router.js +270 -504
  42. package/dist/media-router.js.map +3 -3
  43. package/dist/mfu-reassembler.js +597 -607
  44. package/dist/mfu-reassembler.js.map +3 -3
  45. package/dist/mmtp-container-parser.d.ts +37 -0
  46. package/dist/mmtp-container-parser.d.ts.map +1 -1
  47. package/dist/mmtp-container-parser.js +1531 -1522
  48. package/dist/mmtp-container-parser.js.map +3 -3
  49. package/dist/mmtp-container-parser.no-modules.js +179 -102
  50. package/dist/mmtp-container-parser.no-modules.js.map +3 -3
  51. package/dist/mmtp-decode-pipeline.js +1641 -1651
  52. package/dist/mmtp-decode-pipeline.js.map +3 -3
  53. package/dist/mmtp-router.d.ts +34 -0
  54. package/dist/mmtp-router.d.ts.map +1 -1
  55. package/dist/mmtp-router.js +3676 -3390
  56. package/dist/mmtp-router.js.map +3 -3
  57. package/dist/mmtp-to-cmaf.d.ts +7 -1
  58. package/dist/mmtp-to-cmaf.d.ts.map +1 -1
  59. package/dist/mmtp-to-cmaf.js +109 -134
  60. package/dist/mmtp-to-cmaf.js.map +2 -2
  61. package/dist/multicast-input.d.ts +7 -35
  62. package/dist/multicast-input.d.ts.map +1 -1
  63. package/dist/multicast-input.js +21 -2
  64. package/dist/multicast-input.js.map +4 -4
  65. package/dist/multicast-manager.d.ts +10 -1
  66. package/dist/multicast-manager.d.ts.map +1 -1
  67. package/dist/multicast-manager.js +5584 -4961
  68. package/dist/multicast-manager.js.map +4 -4
  69. package/dist/multicast-transport.d.ts +7 -0
  70. package/dist/multicast-transport.d.ts.map +1 -1
  71. package/dist/multicast-transport.js +369 -421
  72. package/dist/multicast-transport.js.map +4 -4
  73. package/dist/multicast-unwrap.js +53 -30
  74. package/dist/multicast-unwrap.js.map +2 -2
  75. package/dist/no-modules.js +2096 -2097
  76. package/dist/no-modules.js.map +3 -3
  77. package/dist/sample-combiner.js +118 -139
  78. package/dist/sample-combiner.js.map +1 -1
  79. package/dist/signaling.js.map +2 -2
  80. package/dist/source-auth.js +353 -382
  81. package/dist/source-auth.js.map +1 -1
  82. package/dist/switching-set-alignment.js +14 -29
  83. package/dist/switching-set-alignment.js.map +1 -1
  84. package/dist/timestamp-codec.js +17 -11
  85. package/dist/timestamp-codec.js.map +2 -2
  86. package/dist/track-pipeline-setup.js +105 -125
  87. package/dist/track-pipeline-setup.js.map +1 -1
  88. package/dist/track-pipeline.js +107 -127
  89. package/dist/track-pipeline.js.map +1 -1
  90. package/dist/track-session.d.ts +16 -0
  91. package/dist/track-session.d.ts.map +1 -1
  92. package/dist/track-session.js +230 -243
  93. package/dist/track-session.js.map +2 -2
  94. package/dist/transport-pool.js +24 -38
  95. package/dist/transport-pool.js.map +1 -1
  96. package/dist/wasm-mfu-reassembler.d.ts +6 -1
  97. package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
  98. package/dist/wasm-mfu-reassembler.js +127 -144
  99. package/dist/wasm-mfu-reassembler.js.map +2 -2
  100. package/dist/wasm-mmtp-container-parser.js +1659 -1650
  101. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  102. package/node_modules/@blockcast/fec-worker/README.md +5 -1
  103. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
  104. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
  105. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
  106. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
  107. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
  108. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
  109. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
  110. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
  111. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
  112. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
  113. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
  114. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
  115. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
  116. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
  117. package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
  118. package/node_modules/@blockcast/mmt-base/README.md +1 -0
  119. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  120. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  121. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  122. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  123. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  124. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
  125. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  126. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  127. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  128. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  129. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  130. package/package.json +7 -6
  131. package/schemas/catalog.schema.json +1 -1
  132. package/src/align.ts +6 -2
  133. package/src/carp-catalog.ts +13 -3
  134. package/src/cmaf-block-assembler.ts +90 -81
  135. package/src/fec-manager.ts +530 -146
  136. package/src/index.ts +2 -2
  137. package/src/media-router.ts +0 -397
  138. package/src/mmtp-container-parser.ts +97 -21
  139. package/src/mmtp-router.ts +302 -125
  140. package/src/mmtp-to-cmaf.ts +21 -7
  141. package/src/multicast-input.ts +23 -3
  142. package/src/multicast-manager.ts +83 -11
  143. package/src/multicast-transport.ts +56 -17
  144. package/src/track-session.ts +16 -0
  145. package/src/wasm-mfu-reassembler.ts +40 -24
  146. package/test-vectors/catalog/README.md +2 -0
  147. package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
  148. package/test-vectors/catalog-validation.json +11 -0
@@ -1,88 +1,73 @@
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
-
10
1
  // src/transport-pool.ts
11
- var _subs, _options, _failedCb, _stats;
12
2
  var TransportPool = class {
3
+ #subs = /* @__PURE__ */ new Map();
4
+ #options;
5
+ #failedCb = null;
6
+ #stats = { activeSubscriptions: 0, totalAcquires: 0, totalReleases: 0 };
13
7
  constructor(options) {
14
- __privateAdd(this, _subs, /* @__PURE__ */ new Map());
15
- __privateAdd(this, _options);
16
- __privateAdd(this, _failedCb, null);
17
- __privateAdd(this, _stats, { activeSubscriptions: 0, totalAcquires: 0, totalReleases: 0 });
18
- __privateSet(this, _options, options ?? {});
8
+ this.#options = options ?? {};
19
9
  }
20
10
  /** Register callback for subscription failures. */
21
11
  onSubscriptionFailed(cb) {
22
- __privateSet(this, _failedCb, cb);
12
+ this.#failedCb = cb;
23
13
  }
24
14
  acquireSubscription(keyOrOpts, consumer) {
25
15
  const key = typeof keyOrOpts === "string" ? keyOrOpts : keyOrOpts.key;
26
16
  const cons = typeof keyOrOpts === "string" ? consumer : keyOrOpts.consumer;
27
17
  const mode = typeof keyOrOpts === "object" ? keyOrOpts.mode : "moq";
28
- let sub = __privateGet(this, _subs).get(key);
18
+ let sub = this.#subs.get(key);
29
19
  if (!sub) {
30
20
  sub = { key, mode, consumers: /* @__PURE__ */ new Set() };
31
- __privateGet(this, _subs).set(key, sub);
32
- __privateGet(this, _stats).activeSubscriptions++;
21
+ this.#subs.set(key, sub);
22
+ this.#stats.activeSubscriptions++;
33
23
  }
34
24
  ;
35
25
  sub.consumers.add(cons);
36
- __privateGet(this, _stats).totalAcquires++;
26
+ this.#stats.totalAcquires++;
37
27
  return sub;
38
28
  }
39
29
  /** Release a subscription for a consumer. Closes if last consumer. */
40
30
  releaseSubscription(key, consumer) {
41
- const sub = __privateGet(this, _subs).get(key);
31
+ const sub = this.#subs.get(key);
42
32
  if (!sub) return;
43
33
  sub.consumers.delete(consumer);
44
- __privateGet(this, _stats).totalReleases++;
34
+ this.#stats.totalReleases++;
45
35
  if (sub.consumers.size === 0) {
46
- __privateGet(this, _subs).delete(key);
47
- __privateGet(this, _stats).activeSubscriptions--;
36
+ this.#subs.delete(key);
37
+ this.#stats.activeSubscriptions--;
48
38
  }
49
39
  }
50
40
  /** Release all subscriptions held by a consumer. */
51
41
  releaseAllForConsumer(consumer) {
52
- for (const [key, sub] of __privateGet(this, _subs)) {
42
+ for (const [key, sub] of this.#subs) {
53
43
  ;
54
44
  sub.consumers.delete(consumer);
55
45
  if (sub.consumers.size === 0) {
56
- __privateGet(this, _subs).delete(key);
57
- __privateGet(this, _stats).activeSubscriptions--;
46
+ this.#subs.delete(key);
47
+ this.#stats.activeSubscriptions--;
58
48
  }
59
49
  }
60
50
  }
61
51
  /** Report a subscription failure. */
62
52
  reportFailure(key, error) {
63
- var _a;
64
- const sub = __privateGet(this, _subs).get(key);
65
- if (sub) (_a = __privateGet(this, _failedCb)) == null ? void 0 : _a.call(this, { key, consumers: sub.consumers, error });
53
+ const sub = this.#subs.get(key);
54
+ if (sub) this.#failedCb?.({ key, consumers: sub.consumers, error });
66
55
  }
67
56
  /** Get stats. */
68
57
  get stats() {
69
- return __privateGet(this, _stats);
58
+ return this.#stats;
70
59
  }
71
60
  /** Clean up all subscriptions. */
72
61
  dispose() {
73
- __privateGet(this, _subs).clear();
74
- __privateSet(this, _failedCb, null);
75
- __privateGet(this, _stats).activeSubscriptions = 0;
62
+ this.#subs.clear();
63
+ this.#failedCb = null;
64
+ this.#stats.activeSubscriptions = 0;
76
65
  }
77
66
  /** Number of active subscriptions. */
78
67
  get size() {
79
- return __privateGet(this, _subs).size;
68
+ return this.#subs.size;
80
69
  }
81
70
  };
82
- _subs = new WeakMap();
83
- _options = new WeakMap();
84
- _failedCb = new WeakMap();
85
- _stats = new WeakMap();
86
71
 
87
72
  // src/track-session.ts
88
73
  import { fecBlockBudgetMs } from "@blockcast/mmt-fec";
@@ -123,49 +108,47 @@ function computeFecDeliveryWindowMediaUnits(config, timestampTimescale) {
123
108
  }
124
109
  return deliveryWindow;
125
110
  }
126
- var _state, _subscription, _hysteresisTimer, _joinDeadlineTimer, _previousPrimary, _manager, _suppressFired, _fecArmed, _TrackSession_instances, transition_fn, clearHysteresis_fn, armJoinDeadline_fn, clearJoinDeadline_fn, armFec_fn, disarmFec_fn, suppress_fn, unsuppress_fn;
127
111
  var TrackSession = class {
112
+ #state = "idle";
113
+ #subscription = null;
114
+ #hysteresisTimer = null;
115
+ #joinDeadlineTimer = null;
116
+ #previousPrimary = null;
117
+ #manager;
118
+ // Single suppression authority flag (BLO-9413 failback coherence): every
119
+ // suppress this session fires is recorded here, and every path that leaves
120
+ // a suppressed state unwinds through #unsuppress(). Before this flag,
121
+ // unsubscribe() only un-suppressed from multicast/amt — a session torn down
122
+ // from `failing` (exactly where a starving track sits) was re-subscribed to
123
+ // unicast with the host's media still muted: MoQ playing into a dead sink.
124
+ #suppressFired = false;
125
+ // Single FEC authority flag: set by the fec-setup edges (joinStarted,
126
+ // enterUnicastFallback), cleared by the fec-teardown edge in #transition.
127
+ // Setup and teardown are paired by construction, so a takeover timeout that
128
+ // parks the session in `unicast` keeps the decoder the still-joined
129
+ // transport is feeding, and the later unsubscribe still tears it down.
130
+ #fecArmed = false;
128
131
  constructor(config, manager) {
129
- __privateAdd(this, _TrackSession_instances);
130
- __privateAdd(this, _state, "idle");
131
- __privateAdd(this, _subscription, null);
132
- __privateAdd(this, _hysteresisTimer, null);
133
- __privateAdd(this, _joinDeadlineTimer, null);
134
- __privateAdd(this, _previousPrimary, null);
135
- __privateAdd(this, _manager);
136
- // Single suppression authority flag (BLO-9413 failback coherence): every
137
- // suppress this session fires is recorded here, and every path that leaves
138
- // a suppressed state unwinds through #unsuppress(). Before this flag,
139
- // unsubscribe() only un-suppressed from multicast/amt — a session torn down
140
- // from `failing` (exactly where a starving track sits) was re-subscribed to
141
- // unicast with the host's media still muted: MoQ playing into a dead sink.
142
- __privateAdd(this, _suppressFired, false);
143
- // Single FEC authority flag: set by the fec-setup edges (joinStarted,
144
- // enterUnicastFallback), cleared by the fec-teardown edge in #transition.
145
- // Setup and teardown are paired by construction, so a takeover timeout that
146
- // parks the session in `unicast` keeps the decoder the still-joined
147
- // transport is feeding, and the later unsubscribe still tears it down.
148
- __privateAdd(this, _fecArmed, false);
149
132
  this.config = config;
150
- __privateSet(this, _manager, manager);
133
+ this.#manager = manager;
151
134
  }
152
135
  // -----------------------------------------------------------------------
153
136
  // State
154
137
  // -----------------------------------------------------------------------
155
138
  get state() {
156
- return __privateGet(this, _state);
139
+ return this.#state;
157
140
  }
158
141
  get subscription() {
159
- return __privateGet(this, _subscription);
142
+ return this.#subscription;
160
143
  }
161
144
  /** True while this session's onSuppress(true) is outstanding (no matching
162
145
  * onSuppress(false) yet). Test/assertion surface for failback coherence. */
163
146
  get isSuppressed() {
164
- return __privateGet(this, _suppressFired);
147
+ return this.#suppressFired;
165
148
  }
166
149
  /** Current active transport mode, or null if idle. */
167
150
  get transport() {
168
- switch (__privateGet(this, _state)) {
151
+ switch (this.#state) {
169
152
  case "multicast":
170
153
  return "multicast";
171
154
  case "amt":
@@ -179,7 +162,7 @@ var TrackSession = class {
179
162
  return "moq";
180
163
  // MoQ still primary during join
181
164
  case "failing":
182
- return __privateGet(this, _previousPrimary);
165
+ return this.#previousPrimary;
183
166
  default:
184
167
  return null;
185
168
  }
@@ -207,20 +190,20 @@ var TrackSession = class {
207
190
  // -----------------------------------------------------------------------
208
191
  /** idle → unicast: player subscribes to this track. */
209
192
  subscribe() {
210
- if (__privateGet(this, _state) !== "idle") return;
211
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
193
+ if (this.#state !== "idle") return;
194
+ this.#transition("unicast");
212
195
  if (this.config.trackType === "audio") {
213
196
  const latency = this.audioLatencyMs;
214
197
  if (latency !== void 0) {
215
- __privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "latency", latencyMs: latency }, this.config);
198
+ this.#manager.mmtp?.onTrackEvent?.(this.config.trackName, { type: "latency", latencyMs: latency }, this.config);
216
199
  }
217
200
  }
218
201
  }
219
202
  /** unicast → joining: multicast/AMT capability detected, join in progress. */
220
203
  joinStarted() {
221
- if (__privateGet(this, _state) !== "unicast") return;
222
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "joining");
223
- __privateMethod(this, _TrackSession_instances, armFec_fn).call(this);
204
+ if (this.#state !== "unicast") return;
205
+ this.#transition("joining");
206
+ this.#armFec();
224
207
  }
225
208
  /**
226
209
  * any non-fallback state → unicast-fallback. Used when the SSM bridge is
@@ -237,11 +220,11 @@ var TrackSession = class {
237
220
  * reached from a non-idle state (SessionManager skips idle sessions).
238
221
  */
239
222
  enterUnicastFallback() {
240
- if (__privateGet(this, _state) === "unicast-fallback") return;
241
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
242
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast-fallback");
243
- __privateMethod(this, _TrackSession_instances, suppress_fn).call(this);
244
- __privateMethod(this, _TrackSession_instances, armFec_fn).call(this);
223
+ if (this.#state === "unicast-fallback") return;
224
+ this.#clearHysteresis();
225
+ this.#transition("unicast-fallback");
226
+ this.#suppress();
227
+ this.#armFec();
245
228
  }
246
229
  /**
247
230
  * unicast-fallback → unicast. Called when the SSM bridge appears mid-session
@@ -250,43 +233,43 @@ var TrackSession = class {
250
233
  * multicast/AMT preference chain can take over via joinStarted().
251
234
  */
252
235
  exitUnicastFallback() {
253
- if (__privateGet(this, _state) !== "unicast-fallback") return;
254
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
255
- __privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
236
+ if (this.#state !== "unicast-fallback") return;
237
+ this.#transition("unicast");
238
+ this.#unsuppress();
256
239
  }
257
240
  /**
258
241
  * joining → multicast or amt: RAP received on the joined transport (Claim 9d).
259
242
  * Resets audio worklet, then suppresses MoQ.
260
243
  */
261
244
  rapReceived(mode) {
262
- if (__privateGet(this, _state) !== "joining") return;
263
- __privateSet(this, _previousPrimary, mode);
264
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, mode);
245
+ if (this.#state !== "joining") return;
246
+ this.#previousPrimary = mode;
247
+ this.#transition(mode);
265
248
  if (this.config.trackType === "audio") {
266
- __privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
249
+ this.#manager.mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
267
250
  }
268
- __privateMethod(this, _TrackSession_instances, suppress_fn).call(this);
251
+ this.#suppress();
269
252
  }
270
253
  /** multicast/amt → failing: loss detected, start hysteresis timer (Claim 9f). */
271
254
  lossDetected() {
272
- if (__privateGet(this, _state) !== "multicast" && __privateGet(this, _state) !== "amt") return;
273
- __privateSet(this, _previousPrimary, __privateGet(this, _state));
274
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "failing");
255
+ if (this.#state !== "multicast" && this.#state !== "amt") return;
256
+ this.#previousPrimary = this.#state;
257
+ this.#transition("failing");
275
258
  const hysteresisMs = computeFecLossWindowMs(
276
259
  this.config.fecInterleaveMs,
277
260
  this.config.fecK,
278
261
  this.config.fecReorderToleranceMs
279
262
  );
280
- __privateSet(this, _hysteresisTimer, setTimeout(() => {
263
+ this.#hysteresisTimer = setTimeout(() => {
281
264
  this.hysteresisExpired();
282
- }, hysteresisMs));
265
+ }, hysteresisMs);
283
266
  }
284
267
  /** failing → previous primary: loss recovered within hysteresis window. */
285
268
  lossRecovered() {
286
- if (__privateGet(this, _state) !== "failing") return;
287
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
288
- if (__privateGet(this, _previousPrimary)) {
289
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, __privateGet(this, _previousPrimary));
269
+ if (this.#state !== "failing") return;
270
+ this.#clearHysteresis();
271
+ if (this.#previousPrimary) {
272
+ this.#transition(this.#previousPrimary);
290
273
  }
291
274
  }
292
275
  /**
@@ -294,39 +277,39 @@ var TrackSession = class {
294
277
  * Try next transport in preference chain.
295
278
  */
296
279
  transportFailed() {
297
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
298
- if (__privateGet(this, _state) === "unicast-fallback") return;
299
- const current = __privateGet(this, _previousPrimary) ?? this.transport;
280
+ this.#clearHysteresis();
281
+ if (this.#state === "unicast-fallback") return;
282
+ const current = this.#previousPrimary ?? this.transport;
300
283
  const prefs = this.config.preferredTransports;
301
284
  const currentIdx = current ? prefs.indexOf(current) : -1;
302
285
  const nextMode = prefs[currentIdx + 1];
303
286
  if (nextMode !== void 0 && nextMode !== "moq") {
304
- __privateSet(this, _previousPrimary, nextMode);
305
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "joining");
306
- __privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
287
+ this.#previousPrimary = nextMode;
288
+ this.#transition("joining");
289
+ this.#unsuppress();
307
290
  return;
308
291
  }
309
- const from = __privateGet(this, _state);
310
- __privateSet(this, _previousPrimary, null);
311
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast");
312
- __privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
313
- __privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
292
+ const from = this.#state;
293
+ this.#previousPrimary = null;
294
+ this.#transition("unicast");
295
+ this.#disarmFec();
296
+ this.#unsuppress();
314
297
  if (from !== "unicast" && this.config.trackType === "audio") {
315
- __privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
298
+ this.#manager.mmtp?.onTrackEvent?.(this.config.trackName, { type: "reset" }, this.config);
316
299
  }
317
300
  }
318
301
  /** Hysteresis expired → failback to next transport (Claim 9g). */
319
302
  hysteresisExpired() {
320
- if (__privateGet(this, _state) !== "failing") return;
321
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
303
+ if (this.#state !== "failing") return;
304
+ this.#clearHysteresis();
322
305
  this.transportFailed();
323
306
  }
324
307
  /** → idle: player unsubscribes / tab close / cleanup. */
325
308
  unsubscribe() {
326
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
327
- if (__privateGet(this, _state) !== "idle") {
328
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "idle");
329
- __privateMethod(this, _TrackSession_instances, unsuppress_fn).call(this);
309
+ this.#clearHysteresis();
310
+ if (this.#state !== "idle") {
311
+ this.#transition("idle");
312
+ this.#unsuppress();
330
313
  }
331
314
  }
332
315
  /** True when SessionManager.enterUnicastFallback put this track into the
@@ -334,7 +317,7 @@ var TrackSession = class {
334
317
  * decide whether to keep its fallback drainer alive across MediaRouter
335
318
  * arbitration events. */
336
319
  get isUnicastFallback() {
337
- return __privateGet(this, _state) === "unicast-fallback";
320
+ return this.#state === "unicast-fallback";
338
321
  }
339
322
  /**
340
323
  * True while this track owns a FEC decoder (fec-setup fired, fec-teardown
@@ -342,7 +325,7 @@ var TrackSession = class {
342
325
  * `unicast`; SessionManager.failbackAll uses it to release such sessions.
343
326
  */
344
327
  get isFecArmed() {
345
- return __privateGet(this, _fecArmed);
328
+ return this.#fecArmed;
346
329
  }
347
330
  /**
348
331
  * Start the deadline a `joining` entry deferred while the join was inactive
@@ -358,100 +341,89 @@ var TrackSession = class {
358
341
  * `#joinActive = true` before iterating the sessions.
359
342
  */
360
343
  armDeferredJoinDeadline() {
361
- if (__privateGet(this, _state) !== "joining" || __privateGet(this, _joinDeadlineTimer) !== null) return;
362
- if (!__privateGet(this, _manager).joinActive) return;
363
- __privateMethod(this, _TrackSession_instances, armJoinDeadline_fn).call(this, __privateGet(this, _manager).takeoverDeadlineMs);
344
+ if (this.#state !== "joining" || this.#joinDeadlineTimer !== null) return;
345
+ if (!this.#manager.joinActive) return;
346
+ this.#armJoinDeadline(this.#manager.takeoverDeadlineMs);
364
347
  }
365
348
  dispose() {
366
- __privateMethod(this, _TrackSession_instances, clearHysteresis_fn).call(this);
367
- __privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
368
- __privateSet(this, _state, "idle");
369
- __privateSet(this, _subscription, null);
370
- __privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
349
+ this.#clearHysteresis();
350
+ this.#clearJoinDeadline();
351
+ this.#state = "idle";
352
+ this.#subscription = null;
353
+ this.#disarmFec();
371
354
  }
372
- };
373
- _state = new WeakMap();
374
- _subscription = new WeakMap();
375
- _hysteresisTimer = new WeakMap();
376
- _joinDeadlineTimer = new WeakMap();
377
- _previousPrimary = new WeakMap();
378
- _manager = new WeakMap();
379
- _suppressFired = new WeakMap();
380
- _fecArmed = new WeakMap();
381
- _TrackSession_instances = new WeakSet();
382
- // -----------------------------------------------------------------------
383
- // Internal
384
- // -----------------------------------------------------------------------
385
- transition_fn = function(to, opts) {
386
- const from = __privateGet(this, _state);
387
- if (from === to) return;
388
- const joinDeadlineMs = to === "joining" ? __privateGet(this, _manager).takeoverDeadlineMs : void 0;
389
- __privateSet(this, _state, to);
390
- if (from === "joining") __privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
391
- if (joinDeadlineMs !== void 0 && __privateGet(this, _manager).joinActive) {
392
- __privateMethod(this, _TrackSession_instances, armJoinDeadline_fn).call(this, joinDeadlineMs);
393
- }
394
- const fecActive = (s) => s === "joining" || s === "multicast" || s === "amt" || s === "failing" || s === "unicast-fallback";
395
- if (!fecActive(to) && !opts?.retainFec) __privateMethod(this, _TrackSession_instances, disarmFec_fn).call(this);
396
- __privateGet(this, _manager).callbacks?.onStateChange?.(this.config.trackName, from, to);
397
- };
398
- clearHysteresis_fn = function() {
399
- if (__privateGet(this, _hysteresisTimer) !== null) {
400
- clearTimeout(__privateGet(this, _hysteresisTimer));
401
- __privateSet(this, _hysteresisTimer, null);
355
+ // -----------------------------------------------------------------------
356
+ // Internal
357
+ // -----------------------------------------------------------------------
358
+ #transition(to, opts) {
359
+ const from = this.#state;
360
+ if (from === to) return;
361
+ const joinDeadlineMs = to === "joining" ? this.#manager.takeoverDeadlineMs : void 0;
362
+ this.#state = to;
363
+ if (from === "joining") this.#clearJoinDeadline();
364
+ if (joinDeadlineMs !== void 0 && this.#manager.joinActive) {
365
+ this.#armJoinDeadline(joinDeadlineMs);
366
+ }
367
+ const fecActive = (s) => s === "joining" || s === "multicast" || s === "amt" || s === "failing" || s === "unicast-fallback";
368
+ if (!fecActive(to) && !opts?.retainFec) this.#disarmFec();
369
+ this.#manager.callbacks?.onStateChange?.(this.config.trackName, from, to);
370
+ }
371
+ #clearHysteresis() {
372
+ if (this.#hysteresisTimer !== null) {
373
+ clearTimeout(this.#hysteresisTimer);
374
+ this.#hysteresisTimer = null;
375
+ }
402
376
  }
403
- };
404
- armJoinDeadline_fn = function(deadlineMs) {
405
- __privateMethod(this, _TrackSession_instances, clearJoinDeadline_fn).call(this);
406
- if (deadlineMs === 0) return;
407
- __privateSet(this, _joinDeadlineTimer, setTimeout(() => {
408
- __privateSet(this, _joinDeadlineTimer, null);
409
- if (__privateGet(this, _state) !== "joining") return;
410
- __privateMethod(this, _TrackSession_instances, transition_fn).call(this, "unicast", { retainFec: true });
411
- __privateGet(this, _manager).callbacks?.onTakeoverTimeout?.(this.config.trackName);
412
- }, deadlineMs));
413
- };
414
- clearJoinDeadline_fn = function() {
415
- if (__privateGet(this, _joinDeadlineTimer) !== null) {
416
- clearTimeout(__privateGet(this, _joinDeadlineTimer));
417
- __privateSet(this, _joinDeadlineTimer, null);
377
+ #armJoinDeadline(deadlineMs) {
378
+ this.#clearJoinDeadline();
379
+ if (deadlineMs === 0) return;
380
+ this.#joinDeadlineTimer = setTimeout(() => {
381
+ this.#joinDeadlineTimer = null;
382
+ if (this.#state !== "joining") return;
383
+ this.#transition("unicast", { retainFec: true });
384
+ this.#manager.callbacks?.onTakeoverTimeout?.(this.config.trackName);
385
+ }, deadlineMs);
386
+ }
387
+ #clearJoinDeadline() {
388
+ if (this.#joinDeadlineTimer !== null) {
389
+ clearTimeout(this.#joinDeadlineTimer);
390
+ this.#joinDeadlineTimer = null;
391
+ }
392
+ }
393
+ /** Fire fec-setup exactly once per FEC epoch. */
394
+ #armFec() {
395
+ if (this.#fecArmed) return;
396
+ this.#fecArmed = true;
397
+ this.#manager.mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-setup" }, this.config);
398
+ }
399
+ /** Fire fec-teardown for an armed decoder; no-op when none is armed. */
400
+ #disarmFec() {
401
+ if (!this.#fecArmed) return;
402
+ this.#fecArmed = false;
403
+ this.#manager.mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-teardown" }, this.config);
404
+ }
405
+ /** Fire onSuppress(true) exactly once per suppression epoch. */
406
+ #suppress() {
407
+ if (this.#suppressFired) return;
408
+ this.#suppressFired = true;
409
+ this.#manager.callbacks?.onSuppress?.(this.config.trackName, true);
410
+ }
411
+ /** Unwind an outstanding suppression; no-op when none is outstanding. */
412
+ #unsuppress() {
413
+ if (!this.#suppressFired) return;
414
+ this.#suppressFired = false;
415
+ this.#manager.callbacks?.onSuppress?.(this.config.trackName, false);
418
416
  }
419
- };
420
- /** Fire fec-setup exactly once per FEC epoch. */
421
- armFec_fn = function() {
422
- if (__privateGet(this, _fecArmed)) return;
423
- __privateSet(this, _fecArmed, true);
424
- __privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-setup" }, this.config);
425
- };
426
- /** Fire fec-teardown for an armed decoder; no-op when none is armed. */
427
- disarmFec_fn = function() {
428
- if (!__privateGet(this, _fecArmed)) return;
429
- __privateSet(this, _fecArmed, false);
430
- __privateGet(this, _manager).mmtp?.onTrackEvent?.(this.config.trackName, { type: "fec-teardown" }, this.config);
431
- };
432
- /** Fire onSuppress(true) exactly once per suppression epoch. */
433
- suppress_fn = function() {
434
- if (__privateGet(this, _suppressFired)) return;
435
- __privateSet(this, _suppressFired, true);
436
- __privateGet(this, _manager).callbacks?.onSuppress?.(this.config.trackName, true);
437
- };
438
- /** Unwind an outstanding suppression; no-op when none is outstanding. */
439
- unsuppress_fn = function() {
440
- if (!__privateGet(this, _suppressFired)) return;
441
- __privateSet(this, _suppressFired, false);
442
- __privateGet(this, _manager).callbacks?.onSuppress?.(this.config.trackName, false);
443
417
  };
444
418
  var MAX_TAKEOVER_DEADLINE_MS = 2147483647;
445
419
  var JOIN_DEFER_WARN_MS = 3e4;
446
- var _takeoverDeadlineMs, _joinActive, _joinDeferWarnTimer, _SessionManager_instances, armJoinDeferWarn_fn, clearJoinDeferWarn_fn, requireTakeoverDeadlineMs_fn;
447
420
  var SessionManager = class {
448
421
  constructor(poolOptions) {
449
- __privateAdd(this, _SessionManager_instances);
450
422
  this.sessions = /* @__PURE__ */ new Map();
451
423
  this.callbacks = null;
452
- __privateAdd(this, _takeoverDeadlineMs);
453
- __privateAdd(this, _joinActive, true);
454
- __privateAdd(this, _joinDeferWarnTimer, null);
424
+ this.#takeoverDeadlineMs = void 0;
425
+ this.#joinActive = true;
426
+ this.#joinDeferWarnTimer = null;
455
427
  this.pool = new TransportPool(poolOptions);
456
428
  this.pool.onSubscriptionFailed((sub) => {
457
429
  for (const trackName of sub.consumers) {
@@ -460,6 +432,9 @@ var SessionManager = class {
460
432
  }
461
433
  });
462
434
  }
435
+ #takeoverDeadlineMs;
436
+ #joinActive;
437
+ #joinDeferWarnTimer;
463
438
  /**
464
439
  * Takeover deadline (BLO-9413/D9): the time a session may sit in `joining`
465
440
  * without a RAP before returning to `unicast` and firing onTakeoverTimeout.
@@ -486,7 +461,7 @@ var SessionManager = class {
486
461
  * throw out of a transport edge.
487
462
  */
488
463
  get takeoverDeadlineMs() {
489
- return __privateMethod(this, _SessionManager_instances, requireTakeoverDeadlineMs_fn).call(this);
464
+ return this.#requireTakeoverDeadlineMs();
490
465
  }
491
466
  set takeoverDeadlineMs(value) {
492
467
  if (!Number.isInteger(value) || value < 0 || value > MAX_TAKEOVER_DEADLINE_MS) {
@@ -494,11 +469,11 @@ var SessionManager = class {
494
469
  `[SessionManager] takeoverDeadlineMs must be an integer from 0 to ${MAX_TAKEOVER_DEADLINE_MS} (0 disables it, larger values overflow setTimeout); got ${String(value)}`
495
470
  );
496
471
  }
497
- __privateSet(this, _takeoverDeadlineMs, value);
472
+ this.#takeoverDeadlineMs = value;
498
473
  }
499
474
  /** True once the host has admitted a deadline; a declared 0 counts. */
500
475
  get hasTakeoverDeadline() {
501
- return __privateGet(this, _takeoverDeadlineMs) !== void 0;
476
+ return this.#takeoverDeadlineMs !== void 0;
502
477
  }
503
478
  /**
504
479
  * Whether the transport the joining tracks are waiting on is actually
@@ -524,32 +499,81 @@ var SessionManager = class {
524
499
  * Under the documented usage -- false once at setup, true once the subscribe
525
500
  * settles -- the two coincide.
526
501
  *
502
+ * The gate is on the ENTRY into `joining`, and false cannot take back a
503
+ * deadline already running: the `true -> false` edge arms the warn below and
504
+ * clears nothing. So set it false BEFORE the `joining` entry it is meant to
505
+ * gate. A host that instead flipped it false after a `transportFailed()`
506
+ * failover had already entered `joining` would leave the full deadline
507
+ * counting against a subscribe that had not begun -- BLO-34289 again, on the
508
+ * failover edge. Clearing running deadlines on that edge is deliberately NOT
509
+ * done: this flag is manager-wide, so one transport's brief false would
510
+ * cancel an unrelated track's live deadline and then re-arm it at FULL length
511
+ * on the next activation (armDeferredJoinDeadline sees `joining` + a null
512
+ * timer and cannot tell a cleared deadline from a deferred one). Every
513
+ * unrelated transport blip would restart the whole budget, so under repeated
514
+ * failover a track that should have timed out is extended indefinitely and
515
+ * never advances. Only a false that never returns true loses the timer
516
+ * outright, and JOIN_DEFER_WARN_MS already covers that.
517
+ *
527
518
  * Leaving this false is not free: see JOIN_DEFER_WARN_MS.
528
519
  */
529
520
  get joinActive() {
530
- return __privateGet(this, _joinActive);
521
+ return this.#joinActive;
531
522
  }
532
523
  set joinActive(active) {
533
- const wasActive = __privateGet(this, _joinActive);
534
- __privateSet(this, _joinActive, active);
524
+ const wasActive = this.#joinActive;
525
+ this.#joinActive = active;
535
526
  if (!active) {
536
- if (wasActive) __privateMethod(this, _SessionManager_instances, armJoinDeferWarn_fn).call(this);
527
+ if (wasActive) this.#armJoinDeferWarn();
537
528
  return;
538
529
  }
539
- __privateMethod(this, _SessionManager_instances, clearJoinDeferWarn_fn).call(this);
530
+ this.#clearJoinDeferWarn();
540
531
  if (wasActive) return;
541
532
  for (const [, session] of this.sessions) session.armDeferredJoinDeadline();
542
533
  }
534
+ #armJoinDeferWarn() {
535
+ this.#joinDeferWarnTimer = setTimeout(() => {
536
+ this.#joinDeferWarnTimer = null;
537
+ const deferred = [...this.sessions.values()].filter((s) => s.state === "joining").length;
538
+ console.warn(
539
+ `[SessionManager] joinActive has been false for ${JOIN_DEFER_WARN_MS} ms and ${deferred} track(s) sit in 'joining' with no takeover deadline. Set joinActive = true when the subscribe settles, on every exit path including failures, or these tracks never time out, never release their FEC decoders, and never advance to the next transport.`
540
+ );
541
+ }, JOIN_DEFER_WARN_MS);
542
+ }
543
+ #clearJoinDeferWarn() {
544
+ if (this.#joinDeferWarnTimer === null) return;
545
+ clearTimeout(this.#joinDeferWarnTimer);
546
+ this.#joinDeferWarnTimer = null;
547
+ }
543
548
  /** Narrow to MMTP callbacks (onTrackEvent). Safe — optional chaining handles PIM-only consumers. */
544
549
  get mmtp() {
545
550
  return this.callbacks;
546
551
  }
552
+ // -----------------------------------------------------------------------
553
+ // Track management
554
+ // -----------------------------------------------------------------------
555
+ /**
556
+ * The admitted takeover deadline. Throws only when the host never set one,
557
+ * every other invalid value being refused by the setter, and returns a
558
+ * declared 0 as 0. The getter and addTrack() both route through it, so a
559
+ * session cannot exist without an admitted deadline, which is what makes
560
+ * the #transition() read unable to throw on an already-admitted session.
561
+ */
562
+ #requireTakeoverDeadlineMs() {
563
+ const value = this.#takeoverDeadlineMs;
564
+ if (value === void 0) {
565
+ throw new Error(
566
+ "[SessionManager] takeoverDeadlineMs is unset; set a catalog-derived takeover deadline (0 disables it) before adding tracks"
567
+ );
568
+ }
569
+ return value;
570
+ }
547
571
  /** Add a track session from catalog config. */
548
572
  addTrack(config) {
549
573
  if (this.sessions.has(config.trackName)) {
550
574
  throw new Error(`[SessionManager] Track "${config.trackName}" already exists`);
551
575
  }
552
- __privateMethod(this, _SessionManager_instances, requireTakeoverDeadlineMs_fn).call(this);
576
+ this.#requireTakeoverDeadlineMs();
553
577
  const session = new TrackSession(config, this);
554
578
  this.sessions.set(config.trackName, session);
555
579
  return session;
@@ -693,7 +717,7 @@ var SessionManager = class {
693
717
  // Cleanup
694
718
  // -----------------------------------------------------------------------
695
719
  dispose() {
696
- __privateMethod(this, _SessionManager_instances, clearJoinDeferWarn_fn).call(this);
720
+ this.#clearJoinDeferWarn();
697
721
  for (const [, session] of this.sessions) {
698
722
  session.dispose();
699
723
  }
@@ -702,43 +726,6 @@ var SessionManager = class {
702
726
  this.callbacks = null;
703
727
  }
704
728
  };
705
- _takeoverDeadlineMs = new WeakMap();
706
- _joinActive = new WeakMap();
707
- _joinDeferWarnTimer = new WeakMap();
708
- _SessionManager_instances = new WeakSet();
709
- armJoinDeferWarn_fn = function() {
710
- __privateSet(this, _joinDeferWarnTimer, setTimeout(() => {
711
- __privateSet(this, _joinDeferWarnTimer, null);
712
- const deferred = [...this.sessions.values()].filter((s) => s.state === "joining").length;
713
- console.warn(
714
- `[SessionManager] joinActive has been false for ${JOIN_DEFER_WARN_MS} ms and ${deferred} track(s) sit in 'joining' with no takeover deadline. Set joinActive = true when the subscribe settles, on every exit path including failures, or these tracks never time out, never release their FEC decoders, and never advance to the next transport.`
715
- );
716
- }, JOIN_DEFER_WARN_MS));
717
- };
718
- clearJoinDeferWarn_fn = function() {
719
- if (__privateGet(this, _joinDeferWarnTimer) === null) return;
720
- clearTimeout(__privateGet(this, _joinDeferWarnTimer));
721
- __privateSet(this, _joinDeferWarnTimer, null);
722
- };
723
- // -----------------------------------------------------------------------
724
- // Track management
725
- // -----------------------------------------------------------------------
726
- /**
727
- * The admitted takeover deadline. Throws only when the host never set one,
728
- * every other invalid value being refused by the setter, and returns a
729
- * declared 0 as 0. The getter and addTrack() both route through it, so a
730
- * session cannot exist without an admitted deadline, which is what makes
731
- * the #transition() read unable to throw on an already-admitted session.
732
- */
733
- requireTakeoverDeadlineMs_fn = function() {
734
- const value = __privateGet(this, _takeoverDeadlineMs);
735
- if (value === void 0) {
736
- throw new Error(
737
- "[SessionManager] takeoverDeadlineMs is unset; set a catalog-derived takeover deadline (0 disables it) before adding tracks"
738
- );
739
- }
740
- return value;
741
- };
742
729
  export {
743
730
  JOIN_DEFER_WARN_MS,
744
731
  MAX_TAKEOVER_DEADLINE_MS,