@mebius-io/web 0.5.0 → 0.5.2

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/index.cjs CHANGED
@@ -471,6 +471,7 @@ var LIVE_FLV_CONFIG = {
471
471
  var MAX_DRIFT_S = 2;
472
472
  var EDGE_MARGIN_S = 0.4;
473
473
  var AUDIO_RETRY_MS = 2500;
474
+ var ESTIMATED_LATENCY_MS = 3e3;
474
475
  function stalledWithData(video, ms) {
475
476
  if (video.currentTime > 0) return Promise.resolve(false);
476
477
  return new Promise((resolve) => {
@@ -599,6 +600,15 @@ var FlvViewTransport = class {
599
600
  }
600
601
  return { bitrateKbps, framesPerSecond, latencyMs: void 0 };
601
602
  }
603
+ /**
604
+ * Estimate only — see {@link ESTIMATED_LATENCY_MS}. Without this, captions
605
+ * never render on the FLV route at all: {@link MebiusCaptions} withholds
606
+ * every segment until the playhead reaches its `epochMs`, and a transport
607
+ * returning `null` here means the playhead comparison never runs.
608
+ */
609
+ playheadEpochMs() {
610
+ return Date.now() - ESTIMATED_LATENCY_MS;
611
+ }
602
612
  };
603
613
 
604
614
  // src/internal/transport.ts
@@ -1183,10 +1193,17 @@ var SignalingClient = class {
1183
1193
  * Realtime captions SSE URL. Same play token as media — the engine's
1184
1194
  * `PlayVerifier` gates both, so a viewer who can watch the stream can already
1185
1195
  * read its captions with zero extra credential.
1196
+ *
1197
+ * `/api/v1/live/...`, NOT `/live/...`: unlike {@link scalePlaylistUrl}, which
1198
+ * hits the engine's bare `/live/*` media-edge catch-all, captions are mounted
1199
+ * under the versioned control-API group (mebius-stream-engine
1200
+ * internal/api/routes.go) with the play-token middleware, not the proxy.
1201
+ * Copying the media-edge prefix here 401s every request — the catch-all
1202
+ * doesn't recognise the path and never reaches the captions handler at all.
1186
1203
  */
1187
1204
  captionsUrl(streamId, lang) {
1188
1205
  return this.withToken(
1189
- `${this.base()}/live/${encodeURIComponent(streamId)}/captions?lang=${encodeURIComponent(lang)}`
1206
+ `${this.base()}/api/v1/live/${encodeURIComponent(streamId)}/captions?lang=${encodeURIComponent(lang)}`
1190
1207
  );
1191
1208
  }
1192
1209
  // Maps a neutral session kind to the concrete signaling path segment. This