From fe7d4974e434d68c6527e48988846f25e5b29a8c Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Thu, 6 Jun 2024 14:39:28 +0000 Subject: [PATCH] stream: move pipe to shared functions --- src/modules/stream/shared.js | 10 ++++++++++ src/modules/stream/types.js | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) 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]]