@torrent-tv/proxy 2.107.52 → 2.107.54
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/package.json +1 -1
- package/routes/api/sources/files/get.js +6 -4
- package/routes/api/sources/stats/get.js +8 -6
- package/routes/api/transcode-sessions/net-report/post.js +18 -0
- package/routes/api/transcode-sessions/progress/get.js +9 -1
- package/services/encode/EncodeRun.js +13 -3
- package/services/encode/RunProgress.js +11 -2
- package/services/encode/SpeedReadings.js +10 -2
- package/services/encode/quality/HostLoad.js +1 -1
- package/services/server/ForecastDiagnostics.js +23 -0
- package/services/server/OutputLifecycle.js +7 -1
- package/services/server/ViewerRequests.js +235 -317
- package/services/server/wire-outputs.js +17 -0
- package/services/torrent/worker/worker.js +27 -3
- package/services/viewer/OutputForecastGeometry.js +87 -0
- package/services/viewer/Viewer.js +117 -17
- package/services/viewer/ViewerPlaybackState.js +233 -0
- package/services/viewer/playback-readiness.js +25 -3
|
@@ -149,14 +149,16 @@ export class SessionRate {
|
|
|
149
149
|
#inverseSum = 0;
|
|
150
150
|
#zero = false;
|
|
151
151
|
#weighted = 0;
|
|
152
|
+
#capture = null;
|
|
152
153
|
|
|
153
|
-
add(at, value) {
|
|
154
|
+
add(at, value, capture = null) {
|
|
154
155
|
if (!Number.isFinite(at) || !Number.isFinite(value) || value < 0 || at <= (this.#last?.at ?? Number.NEGATIVE_INFINITY)) {
|
|
155
156
|
return false;
|
|
156
157
|
}
|
|
157
158
|
if (this.#last) this.#weighted += this.#last.value * (at - this.#last.at);
|
|
158
159
|
this.#first ??= { at, value };
|
|
159
160
|
this.#last = { at, value };
|
|
161
|
+
this.#capture = mergeCaptureSummary(this.#capture, capture);
|
|
160
162
|
this.#count += 1;
|
|
161
163
|
this.#sum += value;
|
|
162
164
|
if (value > 0) this.#inverseSum += 1 / value;
|
|
@@ -177,6 +179,10 @@ export class SessionRate {
|
|
|
177
179
|
spanSeconds: spanMs / 1000
|
|
178
180
|
};
|
|
179
181
|
}
|
|
182
|
+
|
|
183
|
+
captureSnapshot() {
|
|
184
|
+
return this.#capture ? { ...this.#capture } : null;
|
|
185
|
+
}
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
/**
|
|
@@ -192,12 +198,12 @@ export class RateTrend {
|
|
|
192
198
|
this.#horizonMs = Math.max(0, horizonSeconds) * 1000;
|
|
193
199
|
}
|
|
194
200
|
|
|
195
|
-
add(at, value) {
|
|
201
|
+
add(at, value, capture = null) {
|
|
196
202
|
if (!Number.isFinite(at) || !Number.isFinite(value) || value < 0 ||
|
|
197
203
|
at <= (this.#readings.at(-1)?.at ?? Number.NEGATIVE_INFINITY)) {
|
|
198
204
|
return false;
|
|
199
205
|
}
|
|
200
|
-
this.#readings.push({ at, value });
|
|
206
|
+
this.#readings.push({ at, value, capture: capture ? { ...capture } : null });
|
|
201
207
|
const cutoff = at - this.#horizonMs;
|
|
202
208
|
while (this.#readings.length > 1 && this.#readings[1].at <= cutoff) {
|
|
203
209
|
this.#readings.shift();
|
|
@@ -211,6 +217,22 @@ export class RateTrend {
|
|
|
211
217
|
}
|
|
212
218
|
return summarizeRate(this.#readings);
|
|
213
219
|
}
|
|
220
|
+
|
|
221
|
+
captureSnapshot() {
|
|
222
|
+
return this.#readings.map(reading => reading.capture ? { ...reading.capture } : null);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function mergeCaptureSummary(previous, capture) {
|
|
227
|
+
if (!capture || capture.validity !== "valid" || !Number.isFinite(capture.clockEpoch) ||
|
|
228
|
+
!Number.isFinite(capture.startedAt) || !Number.isFinite(capture.completedAt) ||
|
|
229
|
+
capture.completedAt < capture.startedAt) return { validity: "unknown", unknownReason: "missing-rate-capture" };
|
|
230
|
+
if (!previous) return { ...capture };
|
|
231
|
+
if (previous.validity !== "valid" || previous.clockEpoch !== capture.clockEpoch) {
|
|
232
|
+
return { validity: "invalid", unknownReason: "rate-capture-epoch-mismatch" };
|
|
233
|
+
}
|
|
234
|
+
return { ...previous, startedAt: Math.min(previous.startedAt, capture.startedAt),
|
|
235
|
+
completedAt: Math.max(previous.completedAt, capture.completedAt), revision: capture.revision };
|
|
214
236
|
}
|
|
215
237
|
|
|
216
238
|
/**
|