stream: move pipe to shared functions
This commit is contained in:
parent
7ebd9bc0ff
commit
fe7d4974e4
2 changed files with 11 additions and 11 deletions
|
@ -28,4 +28,14 @@ export function getHeaders(service) {
|
|||
// Converting all header values to strings
|
||||
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
||||
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
||||
}
|
||||
|
||||
export function pipe(from, to, done) {
|
||||
from.on('error', done)
|
||||
.on('close', done);
|
||||
|
||||
to.on('error', done)
|
||||
.on('close', done);
|
||||
|
||||
from.pipe(to);
|
||||
}
|
|
@ -6,7 +6,7 @@ import { create as contentDisposition } from "content-disposition-header";
|
|||
import { metadataManager } from "../sub/utils.js";
|
||||
import { destroyInternalStream } from "./manage.js";
|
||||
import { env, ffmpegArgs, hlsExceptions } from "../config.js";
|
||||
import { getHeaders, closeResponse } from "./shared.js";
|
||||
import { getHeaders, closeResponse, pipe } from "./shared.js";
|
||||
|
||||
function toRawHeaders(headers) {
|
||||
return Object.entries(headers)
|
||||
|
@ -28,16 +28,6 @@ function killProcess(p) {
|
|||
}, 5000);
|
||||
}
|
||||
|
||||
function pipe(from, to, done) {
|
||||
from.on('error', done)
|
||||
.on('close', done);
|
||||
|
||||
to.on('error', done)
|
||||
.on('close', done);
|
||||
|
||||
from.pipe(to);
|
||||
}
|
||||
|
||||
function getCommand(args) {
|
||||
if (!isNaN(env.processingPriority)) {
|
||||
return ['nice', ['-n', env.processingPriority.toString(), ffmpeg, ...args]]
|
||||
|
|
Loading…
Reference in a new issue