cobalt/src/modules/stream/stream.js

28 lines
972 B
JavaScript
Raw Normal View History

2022-07-17 12:21:51 +01:00
import { apiJSON } from "../sub/utils.js";
2022-07-08 19:17:56 +01:00
import { verifyStream } from "./manage.js";
import { streamAudioOnly, streamDefault, streamLiveRender } from "./types.js";
export default function(res, ip, id, hmac, exp) {
2022-07-08 19:17:56 +01:00
try {
let streamInfo = verifyStream(ip, id, hmac, exp, process.env.streamSalt);
if (!streamInfo.error) {
if (streamInfo.isAudioOnly && streamInfo.type != "bridge") {
2022-07-08 19:17:56 +01:00
streamAudioOnly(streamInfo, res);
} else {
switch (streamInfo.type) {
case "render":
streamLiveRender(streamInfo, res);
2022-07-08 19:17:56 +01:00
break;
default:
streamDefault(streamInfo, res);
2022-07-08 19:17:56 +01:00
break;
}
}
} else {
res.status(streamInfo.status).json(apiJSON(0, { t: streamInfo.error }).body);
}
} catch (e) {
internalError(res)
}
}