@torrent-tv/proxy 2.74.1 → 2.76.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 +1504 -1453
- package/CLAUDE.md +19 -6
- package/biome.json +182 -1
- package/docs/container-architecture.md +27 -6
- package/docs/encode-run-state.md +1 -1
- package/knip.json +14 -0
- package/package.json +1 -1
- package/routes/api/sources/warm/post.js +1 -1
- package/routes/api/transcode-sessions/post.js +185 -185
- package/routes/api/transcode-sessions/progress/get.js +5 -1
- package/routes/transcode/audio-file/get.js +11 -1
- package/routes/transcode/audio-warm/get.js +11 -1
- package/routes/transcode/session-file/get.js +1 -1
- package/routes/transcode/variant-file/get.js +10 -1
- package/scripts/render-run-graph.js +2 -2
- package/server.js +25 -0
- package/services/audio-inventory.js +9 -214
- package/services/container/AviContainer.js +266 -81
- package/services/container/Container.js +281 -80
- package/services/container/ContainerFactory.js +67 -0
- package/services/container/MatroskaContainer.js +327 -8
- package/services/container/Mp4Container.js +373 -27
- package/services/container/SubtitleFileContainer.js +0 -1
- package/services/controllers/SubtitleController.js +128 -128
- package/services/demand/index.js +7 -10
- package/services/download/registry.js +0 -14
- package/services/encode/CoverageMap.js +281 -0
- package/services/encode/EncodePlan.js +255 -0
- package/services/encode/EncodeRun.js +587 -0
- package/services/encode/Encoder.js +84 -0
- package/services/encode/NvencEncoder.js +45 -0
- package/services/encode/QsvEncoder.js +47 -0
- package/services/encode/SegmentDemand.js +0 -0
- package/services/encode/SegmentStore.js +529 -0
- package/services/encode/SoftwareEncoder.js +111 -0
- package/services/encode/V4l2m2mEncoder.js +53 -0
- package/services/encode/VaapiEncoder.js +53 -0
- package/services/encode/args.js +200 -0
- package/services/{encode-exit.js → encode/encode-exit.js} +17 -0
- package/services/encode/index.js +9 -0
- package/services/encode/run-command.js +647 -0
- package/services/hls-session-manager.js +11073 -10711
- package/services/hwaccel.js +1688 -1992
- package/services/orchestrators/EncodeOrchestrator.js +359 -0
- package/services/output/LiveOutputs.js +213 -0
- package/services/output/Output.js +94 -0
- package/services/output/OutputSpec.js +195 -0
- package/services/output/Timeline.js +220 -0
- package/services/output/index.js +1 -0
- package/services/output/ladder.js +26 -0
- package/services/playback-planner.js +806 -747
- package/services/produced-index.js +222 -300
- package/services/source/SourceFile.js +346 -0
- package/services/{sidecar-files.js → torrent/files.js} +107 -11
- package/services/torrent/naming.js +619 -0
- package/services/torrent-worker/client.js +10 -0
- package/services/torrent-worker/container-tracks.js +71 -43
- package/services/torrent-worker/pool-adapter.js +370 -333
- package/services/torrent-worker/protocol.js +7 -0
- package/services/torrent-worker/subtitle-cues.js +549 -549
- package/services/torrent-worker/worker.js +18 -0
- package/services/tracks/AudioTrack.js +131 -40
- package/services/tracks/TextSubtitleTrack.js +287 -287
- package/services/tracks/index.js +15 -14
- package/services/viewer/Viewer.js +145 -0
- package/services/viewer/Viewers.js +124 -0
- package/test/audio-inventory.test.js +176 -177
- package/test/auto-quality-step.test.js +508 -506
- package/test/behind-head-repair.test.js +17 -7
- package/test/coverage-map.test.js +153 -0
- package/test/cut-times-timeline.test.js +6 -5
- package/test/cuts-follow-published-grid.test.js +4 -4
- package/test/decode-cost.test.js +31 -12
- package/test/encode-exit.test.js +1 -1
- package/test/encode-orchestrator.test.js +196 -0
- package/test/encode-plan.test.js +245 -0
- package/test/encode-run-state.test.js +2 -2
- package/test/encode-run.test.js +168 -0
- package/test/encoder-kinds.test.js +122 -0
- package/test/held-request-width.test.js +9 -3
- package/test/helpers/encode-run.js +128 -0
- package/test/keyframe-index-accuracy.test.js +19 -12
- package/test/keyframes-belong-to-the-file.test.js +132 -0
- package/test/matroska-cues-track.test.js +192 -192
- package/test/mp4-composition-times.test.js +0 -0
- package/test/orchestrator-wired.test.js +164 -0
- package/test/output-shape.test.js +68 -0
- package/test/output-spec.test.js +157 -0
- package/test/produced-copy-choice.test.js +58 -92
- package/test/produced-index.test.js +142 -188
- package/test/quality-variants.test.js +1079 -1075
- package/test/run-graph-drift.test.js +1 -1
- package/test/run-intervals.test.js +329 -0
- package/test/run-position-follows-published-grid.test.js +4 -4
- package/test/seek-landing.test.js +8 -8
- package/test/seek-target-not-superseded.test.js +21 -9
- package/test/segment-demand.test.js +82 -0
- package/test/segment-serve-wiring.test.js +47 -52
- package/test/segment-store.test.js +187 -0
- package/test/segments-are-shared.test.js +175 -0
- package/test/sidecar-naming.test.js +142 -0
- package/test/source-file.test.js +133 -0
- package/test/stale-request-after-seek.test.js +18 -12
- package/test/subtitle-language.test.js +252 -252
- package/test/timeline.test.js +95 -0
- package/test/{sidecar-files.test.js → torrent-files.test.js} +44 -1
- package/test/torrent-naming.test.js +255 -0
- package/test/tracks-begin-together.test.js +44 -32
- package/test/two-viewers-one-picture.test.js +347 -0
- package/test/video-facts.test.js +102 -0
- package/test/viewer-outputs.test.js +273 -0
- package/test/viewer.test.js +91 -0
- package/utils/perf.js +1 -63
- package/services/container/index.js +0 -6
- package/services/container-index/avi.js +0 -167
- package/services/container-index/index.js +0 -118
- package/services/container-index/matroska.js +0 -336
- package/services/container-index/mp4.js +0 -358
- package/services/controllers/index.js +0 -2
- package/services/download/index.js +0 -8
- package/services/orchestrators/index.js +0 -2
- /package/services/{container-index → container}/ebml-reader.js +0 -0
- /package/services/{encode-run-state.js → encode/encode-run-state.js} +0 -0
- /package/services/{language-detect.js → tracks/language-detect.js} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What a torrent's own names say about a track shipped as its own file.
|
|
3
|
+
*
|
|
4
|
+
* The rule worth pinning is the releaser one, because getting it wrong invents
|
|
5
|
+
* an author. In the field case — `[HorribleSubs] Drifters - 02 [1080p].mka` in
|
|
6
|
+
* `Rus Sound/`, beside `[HorribleSubs] Drifters - 02 [1080p].mkv` — the dub
|
|
7
|
+
* carries the picture's own brackets and nothing else, so there is nothing
|
|
8
|
+
* truthful to say about who made it. The subtitles of the same release sit in
|
|
9
|
+
* `Sub/[Stan WarHammer & Nesitach]/`, a bracket the picture does not carry, and
|
|
10
|
+
* that one IS their author.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import test from "node:test";
|
|
14
|
+
import assert from "node:assert/strict";
|
|
15
|
+
import {
|
|
16
|
+
languageFromFolderNames,
|
|
17
|
+
releaserFrom,
|
|
18
|
+
sidecarNaming
|
|
19
|
+
} from "../services/torrent/naming.js";
|
|
20
|
+
/**
|
|
21
|
+
* Read a whole path, the way the pairing does. `code` is `"und"` where nothing
|
|
22
|
+
* was read, and `group` is what the browser calls the releaser.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} relativePath
|
|
25
|
+
* @param {string} [videoName]
|
|
26
|
+
* @returns {{ code: string, group: string | null }}
|
|
27
|
+
*/
|
|
28
|
+
function readPath(relativePath, videoName = "") {
|
|
29
|
+
const parts = String(relativePath).split("/");
|
|
30
|
+
const naming = sidecarNaming({
|
|
31
|
+
folders: parts.slice(0, -1),
|
|
32
|
+
fileName: parts[parts.length - 1],
|
|
33
|
+
videoName
|
|
34
|
+
});
|
|
35
|
+
return { ...naming, code: naming.code ?? "und", group: naming.releaser };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const VIDEO_NAME = "[HorribleSubs] Drifters - 02 [1080p].mkv";
|
|
40
|
+
|
|
41
|
+
test("a folder naming a language is read, whole segment or word", () => {
|
|
42
|
+
assert.equal(languageFromFolderNames(["ENG"])?.code, "en");
|
|
43
|
+
assert.equal(languageFromFolderNames(["Rus Sound"])?.code, "ru");
|
|
44
|
+
assert.equal(languageFromFolderNames(["Sub", "Russian"])?.code, "ru");
|
|
45
|
+
assert.equal(languageFromFolderNames([])?.code, undefined);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("the innermost folder answers first", () => {
|
|
49
|
+
assert.equal(languageFromFolderNames(["Russian", "English Dub"])?.code, "en");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("a two-letter word inside a longer folder name is not taken for a language", () => {
|
|
53
|
+
// "No" is Norwegian as a whole segment, but a word in `No Subs` is a word.
|
|
54
|
+
assert.equal(languageFromFolderNames(["No Subs"]), null);
|
|
55
|
+
assert.equal(languageFromFolderNames(["no"])?.code, "no");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("a bracket the picture also carries is not the sidecar's author", () => {
|
|
59
|
+
assert.equal(
|
|
60
|
+
releaserFrom({
|
|
61
|
+
folders: ["Rus Sound"],
|
|
62
|
+
fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
|
|
63
|
+
videoName: VIDEO_NAME
|
|
64
|
+
}),
|
|
65
|
+
null
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("a bracket only the sidecar carries is its author", () => {
|
|
70
|
+
assert.equal(
|
|
71
|
+
releaserFrom({
|
|
72
|
+
folders: ["Sub", "[Stan WarHammer & Nesitach]"],
|
|
73
|
+
fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
|
|
74
|
+
videoName: VIDEO_NAME
|
|
75
|
+
}),
|
|
76
|
+
"Stan WarHammer & Nesitach"
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("a bracket describing the encode is never an author", () => {
|
|
81
|
+
for (const token of ["1080p", "x264", "HEVC", "WEB-DL", "AAC", "5.1", "10bit", "78EFD746", "RUS"]) {
|
|
82
|
+
assert.equal(
|
|
83
|
+
releaserFrom({ folders: [], fileName: `Film [${token}].mka`, videoName: "Other.mkv" }),
|
|
84
|
+
null,
|
|
85
|
+
`[${token}] should not be read as a releaser`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("the innermost folder is preferred to the file name", () => {
|
|
91
|
+
assert.equal(
|
|
92
|
+
releaserFrom({ folders: ["[TeamA]"], fileName: "[TeamB] ep.ass", videoName: "ep.mkv" }),
|
|
93
|
+
"TeamA"
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("language and author together, for the field case", () => {
|
|
98
|
+
assert.deepEqual(
|
|
99
|
+
sidecarNaming({
|
|
100
|
+
folders: ["Rus Sound"],
|
|
101
|
+
fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
|
|
102
|
+
videoName: VIDEO_NAME
|
|
103
|
+
}),
|
|
104
|
+
{ code: "ru", name: "Russian", releaser: null, isForced: false, isHearingImpaired: false, isDefault: false }
|
|
105
|
+
);
|
|
106
|
+
assert.deepEqual(
|
|
107
|
+
sidecarNaming({
|
|
108
|
+
folders: ["Sub", "[Stan WarHammer & Nesitach]"],
|
|
109
|
+
fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
|
|
110
|
+
videoName: VIDEO_NAME
|
|
111
|
+
}),
|
|
112
|
+
{
|
|
113
|
+
code: null,
|
|
114
|
+
name: null,
|
|
115
|
+
releaser: "Stan WarHammer & Nesitach",
|
|
116
|
+
isForced: false,
|
|
117
|
+
isHearingImpaired: false,
|
|
118
|
+
isDefault: false
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("a subtitle file takes its author from the folder the release put it in", () => {
|
|
124
|
+
const info = readPath("Sub/[Stan WarHammer & Nesitach]/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
|
|
125
|
+
assert.equal(info.group, "Stan WarHammer & Nesitach");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("the picture's own release group is never reported as the translator", () => {
|
|
129
|
+
const info = readPath("Sub/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
|
|
130
|
+
assert.equal(info.group, null);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("the language of a subtitle folder is read where the whole segment is not a language", () => {
|
|
134
|
+
const info = readPath("Rus Sub/ep.srt", "ep.mkv");
|
|
135
|
+
assert.equal(info.code, "ru");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("what the rules answer with nothing to go on", () => {
|
|
139
|
+
const info = readPath("ep.srt");
|
|
140
|
+
assert.equal(info.code, "und");
|
|
141
|
+
assert.equal(info.group, null);
|
|
142
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The file as a handle: its key, its name, what a probe said about it,
|
|
3
|
+
* and the address this proxy serves it at.
|
|
4
|
+
*
|
|
5
|
+
* The reason this object exists is the key. Twenty places in the session
|
|
6
|
+
* manager assembled `${sourceKey}:${fileIndex}` by hand, through five different
|
|
7
|
+
* spellings, to reach caches that are keyed by a file. These checks pin the
|
|
8
|
+
* shape those call sites now depend on, and the one property the registry has
|
|
9
|
+
* to have: the same file asked for twice is the same object, or a fact learned
|
|
10
|
+
* through one reference would be invisible through the other.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import test from "node:test";
|
|
14
|
+
import assert from "node:assert/strict";
|
|
15
|
+
import { SourceFile, SourceFiles, sourceDecodeCharacteristics } from "../services/source/SourceFile.js";
|
|
16
|
+
|
|
17
|
+
test("a file's key is the pair that identifies it, spelled in one place", () => {
|
|
18
|
+
const file = new SourceFile({ sourceKey: "abc123", fileIndex: 4 });
|
|
19
|
+
assert.equal(file.key, "abc123:4");
|
|
20
|
+
assert.equal(SourceFiles.keyFor("abc123", 4), file.key);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("a file with no name is named by its index, so no log line is about a nameless thing", () => {
|
|
24
|
+
assert.equal(new SourceFile({ sourceKey: "s", fileIndex: 7 }).name, "file#7");
|
|
25
|
+
assert.equal(new SourceFile({ sourceKey: "s", fileIndex: 7, name: " Film.mkv " }).name, "Film.mkv");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("facts are absent until a probe answers, and 'absent' is not 'zero'", () => {
|
|
29
|
+
const file = new SourceFile({ sourceKey: "s", fileIndex: 0 });
|
|
30
|
+
assert.equal(file.width, null, "an unread frame size is unknown, not 0x0");
|
|
31
|
+
assert.equal(file.height, null);
|
|
32
|
+
assert.equal(file.fps, null);
|
|
33
|
+
assert.equal(file.durationSeconds, null);
|
|
34
|
+
assert.equal(file.hasDuration, false);
|
|
35
|
+
assert.equal(file.isHdr, false, "a file nobody has read is not claimed to be HDR");
|
|
36
|
+
assert.equal(file.startTime, 0, "no stated start time means the timeline begins at zero");
|
|
37
|
+
assert.equal(file.decode, null, "and nothing is priced from facts that were never read");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("readings are merged, because two readers answer about different things", () => {
|
|
41
|
+
const file = new SourceFile({ sourceKey: "s", fileIndex: 0 });
|
|
42
|
+
// ffmpeg's banner: the frame size and rate, and no start time.
|
|
43
|
+
file.learn({ width: 1920, height: 1080, fps: 24 });
|
|
44
|
+
// The container's own header, read for one field — a sidecar soundtrack is
|
|
45
|
+
// read for exactly this and nothing else.
|
|
46
|
+
file.learn({ startTime: 0.083 });
|
|
47
|
+
assert.equal(file.startTime, 0.083);
|
|
48
|
+
assert.equal(file.width, 1920, "the second reader must not erase what the first found");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("a fresher reading replaces the first, because a cold torrent answers incompletely", () => {
|
|
52
|
+
const file = new SourceFile({ sourceKey: "s", fileIndex: 0 });
|
|
53
|
+
file.learn({ width: 1920, height: 1080, fps: 24, durationSeconds: 0, startTime: 1.5 });
|
|
54
|
+
assert.equal(file.width, 1920);
|
|
55
|
+
assert.equal(file.hasDuration, false, "a duration of zero is no duration");
|
|
56
|
+
assert.equal(file.startTime, 1.5);
|
|
57
|
+
|
|
58
|
+
file.learn({ width: 1920, height: 1080, fps: 24, durationSeconds: 5400, startTime: 1.5 });
|
|
59
|
+
assert.equal(file.durationSeconds, 5400);
|
|
60
|
+
assert.equal(file.hasDuration, true);
|
|
61
|
+
|
|
62
|
+
file.learn(null);
|
|
63
|
+
assert.equal(file.durationSeconds, 5400, "nothing is unlearned by an answer that did not come");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("what decoding costs is derived from the file's own facts, per codec family", () => {
|
|
67
|
+
const file = new SourceFile({ sourceKey: "s", fileIndex: 0 });
|
|
68
|
+
file.learn({ width: 1920, height: 1080, fps: 24, bitrateKbps: 8000, codec: "hevc", bitDepth: 10 });
|
|
69
|
+
assert.deepEqual(file.decode, {
|
|
70
|
+
megapixelsPerSecond: (1920 * 1080 * 24) / 1e6,
|
|
71
|
+
megabitsPerSecond: 8,
|
|
72
|
+
codec: "hevc",
|
|
73
|
+
bitDepth: 10
|
|
74
|
+
});
|
|
75
|
+
// The same arithmetic, still callable on a plain reading — the offer prices a
|
|
76
|
+
// file it has not made a session for.
|
|
77
|
+
assert.deepEqual(sourceDecodeCharacteristics({ width: 1920, height: 1080, fps: 24, bitrateKbps: 8000 }), {
|
|
78
|
+
megapixelsPerSecond: (1920 * 1080 * 24) / 1e6,
|
|
79
|
+
megabitsPerSecond: 8,
|
|
80
|
+
codec: "",
|
|
81
|
+
bitDepth: null
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("the address carries the file and the session, and the proxy's own base is a parameter", () => {
|
|
86
|
+
const file = new SourceFile({ sourceKey: "abc", fileIndex: 2 });
|
|
87
|
+
const url = file.streamUrl("http://127.0.0.1:9090", { sessionId: "sess-1" });
|
|
88
|
+
assert.equal(url.pathname, "/stream");
|
|
89
|
+
assert.equal(url.searchParams.get("sourceKey"), "abc");
|
|
90
|
+
assert.equal(url.searchParams.get("fileIndex"), "2");
|
|
91
|
+
assert.equal(url.searchParams.get("session"), "sess-1");
|
|
92
|
+
|
|
93
|
+
const noSession = file.streamUrl("http://127.0.0.1:9090");
|
|
94
|
+
assert.equal(noSession.searchParams.has("session"), false, "a read nobody is accounting for says so");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("the same file asked for twice is the same object, or a fact learned once is lost", () => {
|
|
98
|
+
const files = new SourceFiles();
|
|
99
|
+
const first = files.get("abc", 1, "Film.mkv");
|
|
100
|
+
first.learn({ width: 1280, height: 720, fps: 25, durationSeconds: 60 });
|
|
101
|
+
|
|
102
|
+
const second = files.get("abc", 1);
|
|
103
|
+
assert.equal(second, first, "two viewers of one file must not hold two copies of its facts");
|
|
104
|
+
assert.equal(second.width, 1280);
|
|
105
|
+
assert.equal(second.name, "Film.mkv");
|
|
106
|
+
|
|
107
|
+
const other = files.get("abc", 2);
|
|
108
|
+
assert.notEqual(other, first, "and a different file in the same torrent is a different file");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("a name learned later is kept, since the first caller often has only an index", () => {
|
|
112
|
+
const files = new SourceFiles();
|
|
113
|
+
const bare = files.get("abc", 1);
|
|
114
|
+
assert.equal(bare.name, "file#1");
|
|
115
|
+
files.get("abc", 1, "Film.mkv");
|
|
116
|
+
assert.equal(bare.name, "Film.mkv");
|
|
117
|
+
files.get("abc", 1, "Something.else.mkv");
|
|
118
|
+
assert.equal(bare.name, "Film.mkv", "and it is not renamed underneath a log line already written");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("files nobody names are dropped, and a file still named survives the sweep", () => {
|
|
122
|
+
const files = new SourceFiles();
|
|
123
|
+
const kept = files.get("abc", 1);
|
|
124
|
+
files.get("abc", 2);
|
|
125
|
+
files.get("def", 9);
|
|
126
|
+
assert.equal(files.size, 3);
|
|
127
|
+
|
|
128
|
+
const dropped = files.forgetUnused(new Set([kept]));
|
|
129
|
+
assert.equal(dropped, 2);
|
|
130
|
+
assert.equal(files.size, 1);
|
|
131
|
+
assert.equal(files.peek(kept.key), kept);
|
|
132
|
+
assert.equal(files.peek("abc:2"), null);
|
|
133
|
+
});
|
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import assert from "node:assert/strict";
|
|
20
|
+
import { SourceFile } from "../services/source/SourceFile.js";
|
|
21
|
+
import { Timeline } from "../services/output/Timeline.js";
|
|
20
22
|
import test from "node:test";
|
|
21
23
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
22
24
|
import os from "node:os";
|
|
23
25
|
import path from "node:path";
|
|
24
26
|
|
|
25
27
|
import { HlsSessionManager } from "../services/hls-session-manager.js";
|
|
26
|
-
import {
|
|
28
|
+
import { startRunOn } from "./helpers/encode-run.js";
|
|
27
29
|
import { fmp4Format } from "../services/segment-formats/fmp4.js";
|
|
28
30
|
|
|
29
31
|
const SEGMENT_SECONDS = 4;
|
|
@@ -52,23 +54,26 @@ async function sessionWithRunAt373() {
|
|
|
52
54
|
const session = {
|
|
53
55
|
id: SESSION_ID,
|
|
54
56
|
dirPath,
|
|
57
|
+
// Where this file is cut, held by the file. A fixture that stated it
|
|
58
|
+
// on the session was describing what production no longer does.
|
|
59
|
+
timeline: new Timeline({
|
|
60
|
+
boundaries: boundaries,
|
|
61
|
+
cutGrid: "uniform"
|
|
62
|
+
}),
|
|
55
63
|
state: "ready",
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
file: new SourceFile({ sourceKey: "source-1", fileIndex: 0, name: "film.mkv" }),
|
|
65
|
+
// An ordinary session reads its own file, and its sound is inside it. The
|
|
66
|
+
// three differ only for a soundtrack shipped as a file of its own.
|
|
67
|
+
get inputFile() { return this.file; },
|
|
68
|
+
get audioFile() { return this.file; },
|
|
58
69
|
createEntryMs: Date.now(),
|
|
59
70
|
lastAccessedAt: Date.now(),
|
|
60
71
|
consumers: new Set(),
|
|
61
72
|
segmentFormat: fmp4Format,
|
|
62
|
-
usesExplicitCuts: true,
|
|
63
73
|
useSyntheticPlaylist: true,
|
|
64
74
|
playlistText: "#EXTM3U\n",
|
|
65
|
-
segmentBoundaries: boundaries,
|
|
66
75
|
segmentCount: boundaries.length - 1,
|
|
67
|
-
|
|
68
|
-
// A live process: the repair refuses outright when nothing is encoding.
|
|
69
|
-
ffmpeg: { pid: 1234, killed: false, exitCode: null, signalCode: null, kill() { this.killed = true; } },
|
|
70
|
-
encodeRunGeneration: 0,
|
|
71
|
-
runSerial: 1,
|
|
76
|
+
runs: new Set(),
|
|
72
77
|
behindHeadAsks: new Map(),
|
|
73
78
|
firstWantedAt: new Map(),
|
|
74
79
|
holdExplainedAt: new Map(),
|
|
@@ -81,6 +86,8 @@ async function sessionWithRunAt373() {
|
|
|
81
86
|
progress: { processedSeconds: RUN_STARTS_AT * SEGMENT_SECONDS, speed: "1.0x", startPositionSeconds: RUN_STARTS_AT * SEGMENT_SECONDS }
|
|
82
87
|
};
|
|
83
88
|
manager.sessionsById.set(SESSION_ID, session);
|
|
89
|
+
// A live run: the repair refuses outright when nothing is encoding.
|
|
90
|
+
startRunOn(session, { from: RUN_STARTS_AT, usesExplicitCuts: true });
|
|
84
91
|
return { manager, session, dirPath };
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -125,7 +132,6 @@ test("a request behind where the viewer said they are does not move the encoder"
|
|
|
125
132
|
|
|
126
133
|
// The viewer stated their position: 2083.4 s, which is segment #520 here.
|
|
127
134
|
manager.requestSeek(SESSION_ID, 2083.4);
|
|
128
|
-
session.encodeStartIndex = RUN_STARTS_AT;
|
|
129
135
|
askedTwiceLongEnough(session);
|
|
130
136
|
|
|
131
137
|
const answer = await manager.getFileStream(
|
|
@@ -176,7 +182,7 @@ test("a request cannot move the viewer's position backwards", async (t) => {
|
|
|
176
182
|
await manager.getFileStream(SESSION_ID, fmp4Format.segmentFileName(BEHIND_INDEX), { requestSeq: 1 });
|
|
177
183
|
|
|
178
184
|
assert.equal(
|
|
179
|
-
session.
|
|
185
|
+
session.furthestViewerSeconds,
|
|
180
186
|
2083.4,
|
|
181
187
|
"a stale request must not rewrite what the viewer reported — that is how the repair came to believe it"
|
|
182
188
|
);
|