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";
|
2022-12-17 11:09:49 +00:00
|
|
|
import { streamAudioOnly, streamDefault, streamLiveRender, streamVideoOnly } from "./types.js";
|
2022-07-08 19:17:56 +01:00
|
|
|
|
2022-08-14 18:09:06 +01:00
|
|
|
export default function(res, ip, id, hmac, exp) {
|
2022-07-08 19:17:56 +01:00
|
|
|
try {
|
2022-11-12 16:40:11 +00:00
|
|
|
let streamInfo = verifyStream(ip, id, hmac, exp);
|
2022-07-08 19:17:56 +01:00
|
|
|
if (!streamInfo.error) {
|
2022-10-24 14:03:11 +01:00
|
|
|
if (streamInfo.isAudioOnly && streamInfo.type !== "bridge") {
|
2022-07-08 19:17:56 +01:00
|
|
|
streamAudioOnly(streamInfo, res);
|
|
|
|
} else {
|
|
|
|
switch (streamInfo.type) {
|
|
|
|
case "render":
|
2022-08-14 18:09:06 +01:00
|
|
|
streamLiveRender(streamInfo, res);
|
2022-07-08 19:17:56 +01:00
|
|
|
break;
|
2022-12-17 11:09:49 +00:00
|
|
|
case "mute":
|
|
|
|
streamVideoOnly(streamInfo, res);
|
|
|
|
break;
|
2022-07-08 19:17:56 +01:00
|
|
|
default:
|
2022-08-14 18:09:06 +01:00
|
|
|
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) {
|
2022-09-01 14:51:18 +01:00
|
|
|
res.status(500).json({ status: "error", text: "Internal Server Error" });
|
2022-07-08 19:17:56 +01:00
|
|
|
}
|
|
|
|
}
|