mirror of https://github.com/OpenVidu/openvidu.git
openvidus-server: stop recording even when not recorded participant joined
parent
422a4a7cd0
commit
12579d5c0f
|
@ -451,7 +451,7 @@ public abstract class SessionManager {
|
||||||
this.closeSessionAndEmptyCollections(session, reason);
|
this.closeSessionAndEmptyCollections(session, reason);
|
||||||
|
|
||||||
if (recordingService.sessionIsBeingRecorded(session.getSessionId())) {
|
if (recordingService.sessionIsBeingRecorded(session.getSessionId())) {
|
||||||
recordingService.stopRecording(session, reason);
|
recordingService.stopRecording(session, null, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return participants;
|
return participants;
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
.equals(remainingParticipants.iterator().next().getParticipantPublicId())) {
|
.equals(remainingParticipants.iterator().next().getParticipantPublicId())) {
|
||||||
|
|
||||||
log.info("Last participant left. Stopping recording for session {}", sessionId);
|
log.info("Last participant left. Stopping recording for session {}", sessionId);
|
||||||
recordingService.stopRecording(session, reason);
|
recordingService.stopRecording(session, null, reason);
|
||||||
evictParticipant(session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null,
|
evictParticipant(session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null,
|
||||||
null, "EVICT_RECORDER");
|
null, "EVICT_RECORDER");
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,10 +155,24 @@ public class ComposedRecordingService {
|
||||||
return recording;
|
return recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recording stopRecording(Session session, String reason) {
|
public Recording stopRecording(Session session, String recordingId, String reason) {
|
||||||
Recording recording = this.sessionsRecordings.remove(session.getSessionId());
|
Recording recording;
|
||||||
String containerId = this.sessionsContainers.remove(session.getSessionId());
|
String containerId;
|
||||||
|
|
||||||
|
if (session == null) {
|
||||||
|
log.warn(
|
||||||
|
"Existing recording {} does not have an active session associated. This usually means the recording"
|
||||||
|
+ " layout did not join a recorded participant and therefore the session closed before"
|
||||||
|
+ " stopping the recording container",
|
||||||
|
recordingId);
|
||||||
|
recording = this.startedRecordings.remove(recordingId);
|
||||||
|
containerId = this.sessionsContainers.remove(recording.getSessionId());
|
||||||
|
this.sessionsRecordings.remove(recording.getSessionId());
|
||||||
|
} else {
|
||||||
|
recording = this.sessionsRecordings.remove(session.getSessionId());
|
||||||
|
containerId = this.sessionsContainers.remove(session.getSessionId());
|
||||||
this.startedRecordings.remove(recording.getId());
|
this.startedRecordings.remove(recording.getId());
|
||||||
|
}
|
||||||
|
|
||||||
if (containerId == null) {
|
if (containerId == null) {
|
||||||
|
|
||||||
|
@ -250,8 +264,10 @@ public class ComposedRecordingService {
|
||||||
throw new OpenViduException(Code.RECORDING_REPORT_ERROR_CODE,
|
throw new OpenViduException(Code.RECORDING_REPORT_ERROR_CODE,
|
||||||
"There was an error generating the metadata report file for the recording");
|
"There was an error generating the metadata report file for the recording");
|
||||||
}
|
}
|
||||||
|
if (session != null) {
|
||||||
this.sessionHandler.sendRecordingStoppedNotification(session, recording, reason);
|
this.sessionHandler.sendRecordingStoppedNotification(session, recording, reason);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return recording;
|
return recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,8 +481,7 @@ public class ComposedRecordingService {
|
||||||
private boolean isFileFromRecording(File file, String recordingId, String recordingName) {
|
private boolean isFileFromRecording(File file, String recordingId, String recordingName) {
|
||||||
return (((recordingId + ".info").equals(file.getName()))
|
return (((recordingId + ".info").equals(file.getName()))
|
||||||
|| ((RECORDING_ENTITY_FILE + recordingId).equals(file.getName()))
|
|| ((RECORDING_ENTITY_FILE + recordingId).equals(file.getName()))
|
||||||
|| (recordingName + ".mp4").equals(file.getName())
|
|| (recordingName + ".mp4").equals(file.getName()) || (recordingId + ".jpg").equals(file.getName()));
|
||||||
|| (recordingId + ".jpg").equals(file.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFreeRecordingId(String sessionId, String shortSessionId) {
|
private String getFreeRecordingId(String sessionId, String shortSessionId) {
|
||||||
|
|
|
@ -336,7 +336,9 @@ public class SessionRestController {
|
||||||
recordingLayout = RecordingLayout.valueOf(recordingLayoutString);
|
recordingLayout = RecordingLayout.valueOf(recordingLayoutString);
|
||||||
}
|
}
|
||||||
|
|
||||||
customLayout = (customLayout == null) ? session.getSessionProperties().defaultCustomLayout() : customLayout;
|
customLayout = (customLayout == null || customLayout.isEmpty())
|
||||||
|
? session.getSessionProperties().defaultCustomLayout()
|
||||||
|
: customLayout;
|
||||||
|
|
||||||
Recording startedRecording = this.recordingService.startRecording(session, new RecordingProperties.Builder()
|
Recording startedRecording = this.recordingService.startRecording(session, new RecordingProperties.Builder()
|
||||||
.name(name).recordingLayout(recordingLayout).customLayout(customLayout).build());
|
.name(name).recordingLayout(recordingLayout).customLayout(customLayout).build());
|
||||||
|
@ -368,11 +370,14 @@ public class SessionRestController {
|
||||||
|
|
||||||
Session session = sessionManager.getSession(recording.getSessionId());
|
Session session = sessionManager.getSession(recording.getSessionId());
|
||||||
|
|
||||||
Recording stoppedRecording = this.recordingService.stopRecording(session, "recordingStoppedByServer");
|
Recording stoppedRecording = this.recordingService.stopRecording(session, recording.getId(),
|
||||||
|
"recordingStoppedByServer");
|
||||||
|
|
||||||
|
if (session != null) {
|
||||||
sessionManager.evictParticipant(
|
sessionManager.evictParticipant(
|
||||||
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
||||||
"EVICT_RECORDER");
|
"EVICT_RECORDER");
|
||||||
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(stoppedRecording.toJson().toString(), getResponseHeaders(), HttpStatus.OK);
|
return new ResponseEntity<>(stoppedRecording.toJson().toString(), getResponseHeaders(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue