openvidu-recording: Change getActiveEgressesByRoom function to getActiveRecordingByRoom
This commit is contained in:
parent
ea89874179
commit
b5bd0f0412
@ -66,10 +66,10 @@ app.post("/recordings/start", async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeEgresses = await getActiveEgressesByRoom(roomName);
|
const activeRecording = await getActiveRecordingByRoom(roomName);
|
||||||
|
|
||||||
// Check if there is already an active egress for this room
|
// Check if there is already an active recording for this room
|
||||||
if (activeEgresses.length > 0) {
|
if (activeRecording) {
|
||||||
res.status(409).json({ errorMessage: "Recording already started for this room" });
|
res.status(409).json({ errorMessage: "Recording already started for this room" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -102,19 +102,17 @@ app.post("/recordings/stop", async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeEgresses = await getActiveEgressesByRoom(roomName);
|
const activeRecording = await getActiveRecordingByRoom(roomName);
|
||||||
|
|
||||||
// Check if there is an active egress for this room
|
// Check if there is an active recording for this room
|
||||||
if (activeEgresses.length === 0) {
|
if (!activeRecording) {
|
||||||
res.status(409).json({ errorMessage: "Recording not started for this room" });
|
res.status(409).json({ errorMessage: "Recording not started for this room" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const egressId = activeEgresses[0].egressId;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Stop the Egress to finish the recording
|
// Stop the Egress to finish the recording
|
||||||
const egressInfo = await egressClient.stopEgress(egressId);
|
const egressInfo = await egressClient.stopEgress(activeRecording);
|
||||||
const file = egressInfo.fileResults[0];
|
const file = egressInfo.fileResults[0];
|
||||||
const recording = {
|
const recording = {
|
||||||
name: file.filename.split("/").pop(),
|
name: file.filename.split("/").pop(),
|
||||||
@ -128,13 +126,14 @@ app.post("/recordings/stop", async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const getActiveEgressesByRoom = async (roomName) => {
|
const getActiveRecordingByRoom = async (roomName) => {
|
||||||
try {
|
try {
|
||||||
// List all active egresses for the room
|
// List all active egresses for the room
|
||||||
return await egressClient.listEgress({ roomName, active: true });
|
const egresses = await egressClient.listEgress({ roomName, active: true });
|
||||||
|
return egresses.length > 0 ? egresses[0].egressId : null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error listing egresses.", error);
|
console.error("Error listing egresses.", error);
|
||||||
return [];
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user