api/stream: standardize stream types & clean up related functions

This commit is contained in:
wukko
2024-08-22 17:37:31 +06:00
parent 1064be6a7a
commit facf7741ce
11 changed files with 134 additions and 126 deletions

View File

@@ -1,31 +1,33 @@
import { streamAudioOnly, streamDefault, streamLiveRender, streamVideoOnly, convertToGif } from "./types.js";
import { internalStream } from './internal.js';
import stream from "./types.js";
import { closeResponse } from "./shared.js";
import { internalStream } from "./internal.js";
export default async function(res, streamInfo) {
try {
if (streamInfo.isAudioOnly && streamInfo.type !== "proxy") {
streamAudioOnly(streamInfo, res);
return;
}
switch (streamInfo.type) {
case "proxy":
return await stream.proxy(streamInfo, res);
case "internal":
return await internalStream(streamInfo, res);
case "render":
await streamLiveRender(streamInfo, res);
break;
case "gif":
convertToGif(streamInfo, res);
break;
return internalStream(streamInfo, res);
case "merge":
return stream.merge(streamInfo, res);
case "remux":
case "mute":
streamVideoOnly(streamInfo, res);
break;
default:
await streamDefault(streamInfo, res);
break;
return stream.remux(streamInfo, res);
case "audio":
return stream.convertAudio(streamInfo, res);
case "gif":
return stream.convertGif(streamInfo, res);
}
closeResponse(res);
} catch {
closeResponse(res)
closeResponse(res);
}
}