@torrent-tv/proxy 2.85.0 → 2.86.0
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 +12 -0
- package/package.json +1 -1
- package/routes/api/transcode-sessions/net-report/post.js +22 -12
- package/server.js +7 -1
- package/services/hls-session-manager.js +30 -181
- package/services/viewer/Viewer.js +28 -0
- package/services/viewer/active-output.js +54 -0
- package/services/viewer/audio-start.js +45 -0
- package/services/viewer/link-readings.js +56 -0
- package/services/viewer/report-intake.js +45 -63
- package/test/auto-quality-step.test.js +515 -514
- package/test/viewer-states.test.js +75 -24
|
@@ -1,63 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file A viewer's statement about itself, taken in.
|
|
3
|
-
*
|
|
4
|
-
* The VIEWER layer's own entry point, and the whole of what happens when a page
|
|
5
|
-
* says where it is: the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param {object} params
|
|
25
|
-
* @param {string} params.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {number} params.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
export function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* what stopped a soundtrack's encoder on 2026-09-05, seconds after it started
|
|
47
|
-
* and before it had made the `init.mp4` the picture could not be played
|
|
48
|
-
* without.
|
|
49
|
-
*
|
|
50
|
-
* @param {object} params
|
|
51
|
-
* @param {object} params.session
|
|
52
|
-
* @param {number} params.now
|
|
53
|
-
* @param {number} params.linkFreshMs
|
|
54
|
-
* @returns {void}
|
|
55
|
-
*/
|
|
56
|
-
export function forgetStaleLinkReadings({ session, now, linkFreshMs }) {
|
|
57
|
-
for (const viewer of viewersOf(session).values()) {
|
|
58
|
-
const reading = viewer.netReport;
|
|
59
|
-
if (reading !== null && now - reading.at > linkFreshMs) {
|
|
60
|
-
viewer.netReport = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file A viewer's statement about itself, taken in.
|
|
3
|
+
*
|
|
4
|
+
* The VIEWER layer's own entry point, and the whole of what happens when a page
|
|
5
|
+
* says where it is: the output the reporter has on screen is resolved, and the
|
|
6
|
+
* statement reaches the person it is about. Nothing expires here — a link
|
|
7
|
+
* reading is the last thing known about that link, and whether it is still
|
|
8
|
+
* somebody's is presence's answer (`Viewer.linkReading`).
|
|
9
|
+
*
|
|
10
|
+
* It lived in the session manager, which is a description of an OUTPUT, and the
|
|
11
|
+
* two questions were tangled there: whether this is a measurement of a LINK,
|
|
12
|
+
* and whether this is a statement by a VIEWER. Required to be both, a page that
|
|
13
|
+
* had measured nothing could say nothing — see `Viewer.report`.
|
|
14
|
+
*
|
|
15
|
+
* Given the sessions and the registry as plain values, so nothing here knows
|
|
16
|
+
* how a session is found, what a variant is, or that there is an encoder.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { activeOutputFor } from "./active-output.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Take one report from one viewer.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} params
|
|
25
|
+
* @param {{ get: (id: string) => object | undefined }} params.sessions - Every live session, by id.
|
|
26
|
+
* @param {{ of: (session: object, consumerId: string) => import("./Viewer.js").Viewer }} params.viewers
|
|
27
|
+
* @param {string} params.sessionId - The session the page addresses, which is
|
|
28
|
+
* always the picture's: the browser is not told which rung it is on.
|
|
29
|
+
* @param {object} params.report - What they said about themselves.
|
|
30
|
+
* @param {number} [params.now]
|
|
31
|
+
* @returns {boolean} False when no such session is live, which is the page
|
|
32
|
+
* reporting into one that has been disposed.
|
|
33
|
+
*/
|
|
34
|
+
export function recordViewerReport({ sessions, viewers, sessionId, report, now = Date.now() }) {
|
|
35
|
+
const named = sessions.get(sessionId);
|
|
36
|
+
if (!named || named.state === "disposed") {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const consumerId = typeof report?.consumerId === "string" ? report.consumerId : "";
|
|
40
|
+
// The stream on screen is the reporter's own: with two viewers on two rungs,
|
|
41
|
+
// one report says nothing about the other's encoder.
|
|
42
|
+
const session = activeOutputFor({ base: named, consumerId, sessions, viewers });
|
|
43
|
+
viewers.of(session, consumerId).report(report, now);
|
|
44
|
+
return true;
|
|
45
|
+
}
|