mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: CDR recordingStopped event now has reason property
parent
248710591f
commit
062f43d4f4
|
@ -65,7 +65,7 @@ public class CDREvent implements Comparable<CDREvent> {
|
|||
this.startTime = this.timeStamp;
|
||||
}
|
||||
|
||||
public CDREvent(CDREventName eventName, String sessionId, Recording recording) {
|
||||
public CDREvent(CDREventName eventName, String sessionId, Recording recording, String reason) {
|
||||
this.eventName = eventName;
|
||||
if ((sessionId.indexOf('/')) != -1) {
|
||||
this.sessionId = sessionId.substring(sessionId.lastIndexOf('/') + 1, sessionId.length());
|
||||
|
@ -80,6 +80,7 @@ public class CDREvent implements Comparable<CDREvent> {
|
|||
this.hasAudio = recording.hasAudio();
|
||||
this.hasVideo = recording.hasVideo();
|
||||
this.recordingLayout = recording.getRecordingLayout();
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public CDREvent(CDREventName eventName, Participant participant, String sessionId) {
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
package io.openvidu.server.cdr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -86,6 +88,8 @@ public class CallDetailRecord {
|
|||
private Map<String, CDREvent> publications = new ConcurrentHashMap<>();
|
||||
private Map<String, Set<CDREvent>> subscriptions = new ConcurrentHashMap<>();
|
||||
|
||||
private final List<String> lastParticipantLeftReasons = Arrays.asList(new String[] {"disconnect", "forceDisconnectByUser", "forceDisconnectByServer", "networkDisconnect"});
|
||||
|
||||
public CallDetailRecord(CDRLogger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
@ -98,7 +102,7 @@ public class CallDetailRecord {
|
|||
|
||||
public void recordSessionDestroyed(String sessionId, String reason) {
|
||||
CDREvent e = this.sessions.remove(sessionId);
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.sessionDestroyed, e, reason));
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.sessionDestroyed, e, this.finalReason(reason)));
|
||||
}
|
||||
|
||||
public void recordParticipantJoined(Participant participant, String sessionId) {
|
||||
|
@ -156,11 +160,19 @@ public class CallDetailRecord {
|
|||
}
|
||||
|
||||
public void recordRecordingStarted(String sessionId, Recording recording) {
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStarted, sessionId, recording));
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStarted, sessionId, recording, null));
|
||||
}
|
||||
|
||||
public void recordRecordingStopped(String sessionId, Recording recording) {
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStopped, sessionId, recording));
|
||||
public void recordRecordingStopped(String sessionId, Recording recording, String reason) {
|
||||
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStopped, sessionId, recording, this.finalReason(reason)));
|
||||
}
|
||||
|
||||
private String finalReason(String reason) {
|
||||
if (lastParticipantLeftReasons.contains(reason)) {
|
||||
return "lastParticipantLeft";
|
||||
} else {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -410,9 +410,9 @@ public class SessionEventsHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendRecordingStoppedNotification(Session session, Recording recording) {
|
||||
public void sendRecordingStoppedNotification(Session session, Recording recording, String reason) {
|
||||
|
||||
CDR.recordRecordingStopped(session.getSessionId(), recording);
|
||||
CDR.recordRecordingStopped(session.getSessionId(), recording, reason);
|
||||
|
||||
// Be sure to clean this map (this should return null)
|
||||
this.recordingsStarted.remove(session.getSessionId());
|
||||
|
|
|
@ -424,7 +424,7 @@ public abstract class SessionManager {
|
|||
this.closeSessionAndEmptyCollections(session, reason);
|
||||
|
||||
if (recordingService.sessionIsBeingRecorded(session.getSessionId())) {
|
||||
recordingService.stopRecording(session);
|
||||
recordingService.stopRecording(session, reason);
|
||||
}
|
||||
|
||||
return participants;
|
||||
|
|
|
@ -173,7 +173,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
.equals(remainingParticipants.iterator().next().getParticipantPublicId())) {
|
||||
|
||||
log.info("Last participant left. Stopping recording for session {}", sessionId);
|
||||
recordingService.stopRecording(session);
|
||||
recordingService.stopRecording(session, reason);
|
||||
evictParticipant(session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null,
|
||||
null, "EVICT_RECORDER");
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public class ComposedRecordingService {
|
|||
return recording;
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session) {
|
||||
public Recording stopRecording(Session session, String reason) {
|
||||
Recording recording = this.sessionsRecordings.remove(session.getSessionId());
|
||||
String containerId = this.sessionsContainers.remove(session.getSessionId());
|
||||
this.startedRecordings.remove(recording.getId());
|
||||
|
@ -217,7 +217,7 @@ public class ComposedRecordingService {
|
|||
"There was an error generating the metadata report file for the recording");
|
||||
}
|
||||
|
||||
this.sessionHandler.sendRecordingStoppedNotification(session, recording);
|
||||
this.sessionHandler.sendRecordingStoppedNotification(session, recording, reason);
|
||||
|
||||
return recording;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ public class SessionRestController {
|
|||
|
||||
Session session = sessionManager.getSession(recording.getSessionId());
|
||||
|
||||
Recording stoppedRecording = this.recordingService.stopRecording(session);
|
||||
Recording stoppedRecording = this.recordingService.stopRecording(session, "recordingStoppedByServer");
|
||||
|
||||
sessionManager.evictParticipant(
|
||||
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
||||
|
|
Loading…
Reference in New Issue