@torrent-tv/proxy 2.9.48 → 2.9.49

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.9.49
2
+
3
+ - **New**: `getSessionProgress` (the transcode-session progress endpoint) now also reports `outputMbps` — the observed produced bitrate from recently completed segment files (already computed internally for the viewer-link budget check, `#checkLinkBudget`), so the browser can turn its OWN measured link throughput into a delivery-speed multiplier for the unified download/transcode/delivery playback-start ETA, the same way the transcode's own `speed` already is one.
4
+
1
5
  ## 2.9.48
2
6
 
3
7
  - **Fix**: The "bytes still needed to resume" figure shown while buffering could jump UP mid-poll even though nothing regressed, which read as confusing/broken. Root cause: the resume-window progress (`resumeNeededBytes`/`resumeDownloadedBytes`) was always computed against the LIVE read position, which slides forward as the file is read/transcoded further — so when the window moved past an already-downloaded piece into a fresh, never-touched one, "bytes needed" jumped up (a moving reference frame, not a real setback). `getFileStats` now accepts an optional `resumeAnchorByteStart` and always returns the byte offset the window was computed against; the browser client captures that offset on the FIRST poll of a buffering episode and sends it back on every subsequent poll of the SAME episode, so the window stays pinned to a fixed target and the figure only ever decreases as real download progress happens. Verified: with the anchor pinned, repeated polls report the same "needed" while the live read position moves with no new data, and a real download of a piece inside the frozen window correctly decreases it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.9.48",
3
+ "version": "2.9.49",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -14,7 +14,7 @@ export async function handleApiTranscodeSessionsProgressGet(req, reply, { hlsSes
14
14
  return reply.code(400).send({ error: "sessionId is required." });
15
15
  }
16
16
 
17
- const progress = hlsSessionManager.getSessionProgress(sessionId);
17
+ const progress = await hlsSessionManager.getSessionProgress(sessionId);
18
18
  if (!progress) {
19
19
  return reply.code(404).send({ error: "Transcode session was not found." });
20
20
  }
@@ -1970,9 +1970,9 @@ export class HlsSessionManager {
1970
1970
  * Also refreshes `lastAccessedAt` to prevent the session from expiring.
1971
1971
  *
1972
1972
  * @param {string} sessionId
1973
- * @returns {object | null}
1973
+ * @returns {Promise<object | null>}
1974
1974
  */
1975
- getSessionProgress(sessionId) {
1975
+ async getSessionProgress(sessionId) {
1976
1976
  if (!isSafeSessionId(sessionId)) {
1977
1977
  return null;
1978
1978
  }
@@ -1990,6 +1990,13 @@ export class HlsSessionManager {
1990
1990
  const warmupRemainingSeconds = isWarmupPhase
1991
1991
  ? Math.max(0, warmupTotalSeconds - warmupElapsedSeconds)
1992
1992
  : null;
1993
+ // Observed OUTPUT bitrate (Mbit/s) from recently completed segment sizes —
1994
+ // already computed for the viewer-link budget check (#checkLinkBudget); also
1995
+ // exposed here so the browser can turn its OWN measured link throughput into
1996
+ // a "content-seconds delivered per wall-clock second" rate for the unified
1997
+ // three-stage ETA (download / transcode / delivery), the same way the
1998
+ // transcode's own `speed` already is one. Null when not enough segments yet.
1999
+ const outputMbps = await this.#observedStreamMbps(session);
1993
2000
  return {
1994
2001
  sessionId: session.id,
1995
2002
  state: session.progress.state,
@@ -2005,6 +2012,7 @@ export class HlsSessionManager {
2005
2012
  // of a percentage of the whole-file transcode.
2006
2013
  segmentDurationSec: this.segmentDurationSec,
2007
2014
  speed: session.progress.speed,
2015
+ outputMbps,
2008
2016
  updatedAt: session.progress.updatedAt,
2009
2017
  error: session.state === "failed" ? session.lastError : ""
2010
2018
  };