@torrent-tv/proxy 2.105.9 → 2.105.10
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
CHANGED
|
@@ -109,11 +109,12 @@ export async function admitInput({ sources, reserve, readRanges }) {
|
|
|
109
109
|
* the download a second time through it (Home Assistant 2026-10-12,
|
|
110
110
|
* torrent-tv/meta#178).
|
|
111
111
|
*/
|
|
112
|
-
export async function writeAdmittedInput(input, stdin, { next = null, waiting = null } = {}) {
|
|
112
|
+
export async function writeAdmittedInput(input, stdin, { next = null, waiting = null, onFirstInputBytes = null } = {}) {
|
|
113
113
|
if (input?.kind !== "result") throw new TypeError("Only complete input may be written to an encoder.");
|
|
114
114
|
const originSeconds = input.originSeconds;
|
|
115
115
|
const declarations = JSON.stringify(input.tracks.map(input => matroskaTrackIdentity(input.track)));
|
|
116
116
|
const seen = new Map();
|
|
117
|
+
let firstInputBytesNoted = false;
|
|
117
118
|
let current = input, includeHeader = true;
|
|
118
119
|
try {
|
|
119
120
|
while (current) {
|
|
@@ -132,6 +133,10 @@ export async function writeAdmittedInput(input, stdin, { next = null, waiting =
|
|
|
132
133
|
batch = Buffer.allocUnsafe(INPUT_WRITE_BATCH_BYTES);
|
|
133
134
|
used = 0;
|
|
134
135
|
await writeChunk(stdin, chunk);
|
|
136
|
+
if (!firstInputBytesNoted) {
|
|
137
|
+
firstInputBytesNoted = true;
|
|
138
|
+
onFirstInputBytes?.(chunk.length);
|
|
139
|
+
}
|
|
135
140
|
};
|
|
136
141
|
for await (const chunk of current.stream({ originSeconds, includeHeader, seen })) {
|
|
137
142
|
if (!Buffer.isBuffer(chunk)) throw new TypeError("Admitted input stream yielded a non-buffer chunk.");
|
|
@@ -1341,11 +1341,14 @@ export class EncodeRuns {
|
|
|
1341
1341
|
// begun at once (`next-packet-input.js`).
|
|
1342
1342
|
const following = nextPacketInputs({ take: index => this.#host.encodeInputs.take(session, index, index),
|
|
1343
1343
|
canAppend, first: nextIndex, last: ordered?.to ?? startIndex });
|
|
1344
|
-
void writeAdmittedInput(admittedInput, run.process.stdin, {
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1344
|
+
void writeAdmittedInput(admittedInput, run.process.stdin, {
|
|
1345
|
+
onFirstInputBytes: bytes => this.noteFirstInputBytes(inputToken, session.file.fileIndex, bytes),
|
|
1346
|
+
next: async () => {
|
|
1347
|
+
const next = following.next(index => { run.to = index; });
|
|
1348
|
+
if (next) run.admittedInputKeys.set(run.to, this.#inputFailures.key(next, inputParameters));
|
|
1349
|
+
return next;
|
|
1350
|
+
}
|
|
1351
|
+
}).catch(error => {
|
|
1349
1352
|
this.#host.logger.warn(`encode input output=${session.outputKey} segment=${safeIndex} write failed: ${error.message}`);
|
|
1350
1353
|
run.process?.stdin?.destroy();
|
|
1351
1354
|
}).finally(() => following.release());
|