mirror of https://github.com/OpenVidu/openvidu.git
CDR recording events extended (id, hasAudio, hasVideo, size)
parent
d5eda724c5
commit
9971e6394b
|
@ -4,6 +4,7 @@ import org.json.simple.JSONObject;
|
|||
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
|
||||
public class CDREvent implements Comparable<CDREvent> {
|
||||
|
||||
|
@ -25,6 +26,12 @@ public class CDREvent implements Comparable<CDREvent> {
|
|||
private MediaOptions mediaOptions;
|
||||
private String receivingFrom;
|
||||
private String reason;
|
||||
|
||||
// Recording events
|
||||
private Long size;
|
||||
private String id;
|
||||
private Boolean hasAudio;
|
||||
private Boolean hasVideo;
|
||||
|
||||
public CDREvent(String eventName, CDREvent event) {
|
||||
this(eventName, event.participant, event.sessionId, event.mediaOptions, event.receivingFrom, event.startTime, event.reason);
|
||||
|
@ -46,6 +53,20 @@ public class CDREvent implements Comparable<CDREvent> {
|
|||
this.timeStamp = System.currentTimeMillis();
|
||||
this.startTime = this.timeStamp;
|
||||
}
|
||||
|
||||
public CDREvent(String eventName, String sessionId, Recording recording) {
|
||||
this.eventName = eventName;
|
||||
if ((sessionId.indexOf('/')) != -1) {
|
||||
this.sessionId = sessionId.substring(sessionId.lastIndexOf('/') + 1, sessionId.length());
|
||||
} else {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
this.timeStamp = System.currentTimeMillis();
|
||||
this.id = recording.getId();
|
||||
this.size = recording.getSize();
|
||||
this.hasAudio = recording.hasAudio();
|
||||
this.hasVideo = recording.hasVideo();
|
||||
}
|
||||
|
||||
public CDREvent(String eventName, Participant participant, String sessionId) {
|
||||
this(eventName, sessionId);
|
||||
|
@ -106,6 +127,18 @@ public class CDREvent implements Comparable<CDREvent> {
|
|||
if (this.reason != null) {
|
||||
json.put("reason", this.reason);
|
||||
}
|
||||
if (this.id != null) {
|
||||
json.put("id", this.id);
|
||||
}
|
||||
if (this.size != null) {
|
||||
json.put("size", this.size);
|
||||
}
|
||||
if (this.hasAudio != null) {
|
||||
json.put("hasAudio", this.hasAudio);
|
||||
}
|
||||
if (this.hasVideo != null) {
|
||||
json.put("hasVideo", this.hasVideo);
|
||||
}
|
||||
|
||||
JSONObject root = new JSONObject();
|
||||
root.put(this.eventName, json);
|
||||
|
|
|
@ -11,19 +11,20 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
|
||||
/**
|
||||
* CDR logger to register all information of a Session.
|
||||
* Enabled by property 'openvidu.cdr=true'
|
||||
*
|
||||
* - 'sessionCreated': {sessionId, timestamp}
|
||||
* - 'sessionDestroyed': {sessionId, timestamp, startTime, endTime, duration }
|
||||
* - 'sessionDestroyed': {sessionId, timestamp, startTime, endTime, duration, reason}
|
||||
* - 'participantJoined': {sessionId, timestamp, participantId}
|
||||
* - 'participantLeft': {sessionId, timestamp, participantId, startTime, endTime, duration, reason}
|
||||
* - 'webrtcConnectionCreated' {sessionId, timestamp, participantId, connection, [receivingFrom], audioEnabled, videoEnabled, [videoSource], [videoFramerate] }
|
||||
* - 'webrtcConnectionDestroyed' {sessionId, timestamp, participantId, connection, [receivingFrom], audioEnabled, videoEnabled, [videoSource], [videoFramerate], reason }
|
||||
* - 'recordingStarted' {sessionId, timestamp}
|
||||
* - 'recordingStopped' {sessionId, timestamp}
|
||||
* - 'webrtcConnectionCreated' {sessionId, timestamp, participantId, connection, [receivingFrom], audioEnabled, videoEnabled, [videoSource], [videoFramerate]}
|
||||
* - 'webrtcConnectionDestroyed' {sessionId, timestamp, participantId, startTime, endTime, duration, connection, [receivingFrom], audioEnabled, videoEnabled, [videoSource], [videoFramerate], reason}
|
||||
* - 'recordingStarted' {sessionId, timestamp, id, hasAudio, hasVideo, size}
|
||||
* - 'recordingStopped' {sessionId, timestamp, id, hasAudio, hasVideo, size}
|
||||
*
|
||||
* PROPERTIES VALUES:
|
||||
*
|
||||
|
@ -39,6 +40,10 @@ import io.openvidu.server.core.Participant;
|
|||
* - videoEnabled: boolean
|
||||
* - videoSource: "CAMERA", "SCREEN"
|
||||
* - videoFramerate: number
|
||||
* - id: string
|
||||
* - hasAudio: boolean
|
||||
* - hasVideo: boolean
|
||||
* - size: number
|
||||
* - webrtcConnectionDestroyed.reason: "unsubscribe", "unpublish", "disconnect", "networkDisconnect", "openviduServerDestroyed"
|
||||
* - participantLeft.reason: "unsubscribe", "unpublish", "disconnect", "networkDisconnect", "openviduServerDestroyed"
|
||||
* - sessionDestroyed.reason: "lastParticipantLeft", "openviduServerDestroyed"
|
||||
|
@ -124,14 +129,12 @@ public class CallDetailRecord {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void recordRecordingStarted(String sessionId) {
|
||||
CDREvent recording = new CDREvent(CDREvent.RECORDING_STARTED, sessionId);
|
||||
log.info("{}", recording);
|
||||
public void recordRecordingStarted(String sessionId, Recording recording) {
|
||||
log.info("{}", new CDREvent(CDREvent.RECORDING_STARTED, sessionId, recording));
|
||||
}
|
||||
|
||||
public void recordRecordingStopped(String sessionId) {
|
||||
CDREvent recording = new CDREvent(CDREvent.RECORDING_STOPPED, sessionId);
|
||||
log.info("{}", recording);
|
||||
public void recordRecordingStopped(String sessionId, Recording recording) {
|
||||
log.info("{}", new CDREvent(CDREvent.RECORDING_STOPPED, sessionId, recording));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ public class SessionEventsHandler {
|
|||
public void sendRecordingStartedNotification(Session session, Recording recording) {
|
||||
|
||||
if (openviduConfig.isCdrEnabled()) {
|
||||
CDR.recordRecordingStarted(session.getSessionId());
|
||||
CDR.recordRecordingStarted(session.getSessionId(), recording);
|
||||
}
|
||||
|
||||
// Filter participants by roles according to "openvidu.recording.notification"
|
||||
|
@ -345,7 +345,7 @@ public class SessionEventsHandler {
|
|||
public void sendRecordingStoppedNotification(Session session, Recording recording) {
|
||||
|
||||
if (openviduConfig.isCdrEnabled()) {
|
||||
CDR.recordRecordingStopped(session.getSessionId());
|
||||
CDR.recordRecordingStopped(session.getSessionId(), recording);
|
||||
}
|
||||
|
||||
// Be sure to clean this map (this should return null)
|
||||
|
|
Loading…
Reference in New Issue