diff --git a/src/modules/stream/shared.js b/src/modules/stream/shared.js index 4dbd59d3..1e2f2e25 100644 --- a/src/modules/stream/shared.js +++ b/src/modules/stream/shared.js @@ -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); } \ No newline at end of file diff --git a/src/modules/stream/types.js b/src/modules/stream/types.js index 2036b360..2372d6c1 100644 --- a/src/modules/stream/types.js +++ b/src/modules/stream/types.js @@ -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]]