cobalt/api/src/stream/stream.js
wukko aa376d76f6
api/stream/types: huge refactor & simplification of code
- created render() which handles ffmpeg & piping stuff
- merged remux() and merge() into one function
- simplified and cleaned up arguments
- removed headers since they're handled by internal streams now
- removed outdated arguments
2025-06-24 19:55:50 +06:00

32 lines
816 B
JavaScript

import stream from "./types.js";
import { closeResponse } from "./shared.js";
import { internalStream } from "./internal.js";
export default async function(res, streamInfo) {
try {
switch (streamInfo.type) {
case "proxy":
return await stream.proxy(streamInfo, res);
case "internal":
return await internalStream(streamInfo.data, res);
case "merge":
case "remux":
case "mute":
return await stream.remux(streamInfo, res);
case "audio":
return await stream.convertAudio(streamInfo, res);
case "gif":
return await stream.convertGif(streamInfo, res);
}
closeResponse(res);
} catch {
closeResponse(res);
}
}