From 7ce9ceb530cb5f9cc68cf9b8cee358e00c63ea38 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 16 Jan 2018 11:02:45 +0100 Subject: [PATCH] CDR extended (session, participant and webrtc events) --- openvidu-server/pom.xml | 10 +- .../java/io/openvidu/server/cdr/CDREvent.java | 122 ++++++++++++++++++ .../openvidu/server/cdr/CDRTransmission.java | 96 -------------- .../openvidu/server/cdr/CallDetailRecord.java | 85 ++++++------ .../server/config/OpenviduConfig.java | 8 +- .../java/io/openvidu/server/core/Session.java | 2 +- .../server/core/SessionEventsHandler.java | 37 ++++-- .../openvidu/server/core/SessionManager.java | 57 ++++---- .../server/kurento/core/KurentoSession.java | 4 +- .../kurento/core/KurentoSessionManager.java | 16 ++- .../src/main/resources/log4j.properties | 10 -- .../src/main/resources/logback.xml | 28 ++++ 12 files changed, 264 insertions(+), 211 deletions(-) create mode 100644 openvidu-server/src/main/java/io/openvidu/server/cdr/CDREvent.java delete mode 100644 openvidu-server/src/main/java/io/openvidu/server/cdr/CDRTransmission.java delete mode 100644 openvidu-server/src/main/resources/log4j.properties create mode 100644 openvidu-server/src/main/resources/logback.xml diff --git a/openvidu-server/pom.xml b/openvidu-server/pom.xml index 2704ec75..0cd2e90a 100644 --- a/openvidu-server/pom.xml +++ b/openvidu-server/pom.xml @@ -106,10 +106,6 @@ kurento-jsonrpc-server ${version.kurento} - - org.springframework.boot - spring-boot-starter-logging - org.springframework.boot spring-boot-starter-tomcat @@ -201,9 +197,9 @@ 2.2.2 - org.slf4j - slf4j-log4j12 - 1.7.25 + org.springframework.boot + spring-boot-starter-logging + ${version.spring-boot} diff --git a/openvidu-server/src/main/java/io/openvidu/server/cdr/CDREvent.java b/openvidu-server/src/main/java/io/openvidu/server/cdr/CDREvent.java new file mode 100644 index 00000000..6b6093e8 --- /dev/null +++ b/openvidu-server/src/main/java/io/openvidu/server/cdr/CDREvent.java @@ -0,0 +1,122 @@ +package io.openvidu.server.cdr; + +import org.json.simple.JSONObject; + +import io.openvidu.server.core.MediaOptions; +import io.openvidu.server.core.Participant; + +public class CDREvent implements Comparable { + + static final String SESSION_CREATED = "sessionCreated"; + static final String SESSION_DESTROYED = "sessionDestroyed"; + static final String PARTICIPANT_JOINED = "participantJoined"; + static final String PARTICIPANT_LEFT = "participantLeft"; + static final String CONNECTION_CREATED = "webrtcConnectionCreated"; + static final String CONNECTION_DESTROYED = "webrtcConnectionDestroyed"; + + protected String eventName; + protected String sessionId; + private Participant participant; + private MediaOptions mediaOptions; + private String receivingFrom; + private Long startTime; + private Integer duration; + protected Long timeStamp; + + public CDREvent(String eventName, CDREvent event) { + this(eventName, event.participant, event.sessionId, event.mediaOptions, event.receivingFrom, event.startTime); + this.duration = (int) (this.timeStamp - this.startTime / 1000); + } + + public CDREvent(String eventName, String sessionId) { + 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.startTime = this.timeStamp; + } + + public CDREvent(String eventName, Participant participant, String sessionId) { + this(eventName, sessionId); + this.participant = participant; + this.startTime = this.timeStamp; + } + + public CDREvent(String eventName, Participant participant, String sessionId, MediaOptions mediaOptions, + String receivingFrom, Long startTime) { + this(eventName, sessionId); + this.participant = participant; + this.mediaOptions = mediaOptions; + this.receivingFrom = receivingFrom; + this.startTime = startTime; + } + + public MediaOptions getMediaOptions() { + return mediaOptions; + } + + public String getParticipantPublicId() { + return this.participant.getParticipantPublicId(); + } + + public String getReceivingFrom() { + return this.receivingFrom; + } + + @Override + @SuppressWarnings("unchecked") + public String toString() { + JSONObject json = new JSONObject(); + json.put("sessionId", this.sessionId); + json.put("timestamp", this.timeStamp); + + if (this.participant != null) { + json.put("participantId", this.participant.getParticipantPublicId()); + } + if (this.mediaOptions != null) { + json.put("connection", this.receivingFrom != null ? "INBOUND" : "OUTBOUND"); + json.put("audioEnabled", this.mediaOptions.audioActive); + json.put("videoEnabled", this.mediaOptions.videoActive); + if (this.mediaOptions.videoActive) { + json.put("videoSource", this.mediaOptions.typeOfVideo); + } + if (this.receivingFrom != null) { + json.put("receivingFrom", this.receivingFrom); + } + } + if (this.duration != null) { + json.put("startTime", this.startTime); + json.put("endTime", this.timeStamp); + json.put("duration", (this.timeStamp - this.startTime) / 1000); + } + + JSONObject root = new JSONObject(); + root.put(this.eventName, json); + + return root.toString(); + } + + @Override + public int compareTo(CDREvent other) { + if (this.participant.equals(other.participant)) { + if (this.receivingFrom != null && other.receivingFrom != null) { + if (this.receivingFrom.equals(other.receivingFrom)) { + return 0; + } else { + return 1; + } + } else { + if (this.receivingFrom == null && other.receivingFrom == null) { + return 0; + } else { + return 1; + } + } + } + return 1; + } + +} diff --git a/openvidu-server/src/main/java/io/openvidu/server/cdr/CDRTransmission.java b/openvidu-server/src/main/java/io/openvidu/server/cdr/CDRTransmission.java deleted file mode 100644 index 412957e5..00000000 --- a/openvidu-server/src/main/java/io/openvidu/server/cdr/CDRTransmission.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.openvidu.server.cdr; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import io.openvidu.server.core.MediaOptions; -import io.openvidu.server.core.Participant; - -public class CDRTransmission implements Comparable { - - private Participant participant; - private String sessionId; - private MediaOptions mediaOptions; - private Long timeOfStart; - private Long timeOfEnd; - private CDRTransmission receivingFrom; - - private SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy, HH:mm:ss"); - - public CDRTransmission(Participant participant, String sessionId, MediaOptions mediaOptions, CDRTransmission receivingFrom) { - this.participant = participant; - this.sessionId = sessionId; - this.mediaOptions = mediaOptions; - this.receivingFrom = receivingFrom; - this.timeOfStart = System.currentTimeMillis(); - } - - public Participant getParticipant() { - return this.participant; - } - - public String getSessionId() { - return this.sessionId; - } - - public MediaOptions getMediaOptions() { - return this.mediaOptions; - } - - public void endCall() { - this.timeOfEnd = System.currentTimeMillis(); - } - - public String getDateOfStart() { - return this.dateFormat.format(new Date(this.timeOfStart)); - } - - public String getDateOfEnd() { - return this.dateFormat.format(new Date(this.timeOfEnd)); - } - - public int totalCallDuration() { - return (int) ((this.timeOfEnd - this.timeOfStart) / 1000); - } - - public boolean getAudioEnabled() { - return this.mediaOptions.audioActive; - } - - public boolean getVideoEnabled() { - return this.mediaOptions.videoActive; - } - - public String typeOfVideo() { - if (!this.mediaOptions.videoActive) { - return "VIDEO_NOT_ENABLED"; - } else { - return this.mediaOptions.typeOfVideo; - } - } - - public CDRTransmission getReceivingFrom() { - return this.receivingFrom; - } - - @Override - public int compareTo(CDRTransmission other) { - if (this.participant.equals(other.participant)) { - if (this.receivingFrom != null && other.receivingFrom != null) { - if (this.receivingFrom.getParticipant().equals(other.receivingFrom.getParticipant())) { - return 0; - } else { - return 1; - } - } else { - if (this.receivingFrom == null && other.receivingFrom == null) { - return 0; - } else { - return 1; - } - } - } - return 1; - } - -} diff --git a/openvidu-server/src/main/java/io/openvidu/server/cdr/CallDetailRecord.java b/openvidu-server/src/main/java/io/openvidu/server/cdr/CallDetailRecord.java index da5edc81..a82f8791 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/cdr/CallDetailRecord.java +++ b/openvidu-server/src/main/java/io/openvidu/server/cdr/CallDetailRecord.java @@ -31,42 +31,68 @@ import io.openvidu.server.core.Participant; public class CallDetailRecord { private Logger log = LoggerFactory.getLogger(CallDetailRecord.class); - - private Map publications = new ConcurrentHashMap<>(); - private Map> subscriptions = new ConcurrentHashMap<>(); + + private Map sessions = new ConcurrentHashMap<>(); + private Map participants = new ConcurrentHashMap<>(); + private Map publications = new ConcurrentHashMap<>(); + private Map> subscriptions = new ConcurrentHashMap<>(); + + public void recordSessionCreated(String sessionId) { + CDREvent e = new CDREvent(CDREvent.SESSION_CREATED, sessionId); + this.sessions.put(sessionId, e); + log.info("{}", e); + } + + public void recordSessionDestroyed(String sessionId) { + CDREvent e = this.sessions.remove(sessionId); + log.info("{}", new CDREvent(CDREvent.SESSION_DESTROYED, e)); + } + + public void recordParticipantJoined(Participant participant, String sessionId) { + CDREvent e = new CDREvent(CDREvent.PARTICIPANT_JOINED, participant, sessionId); + this.participants.put(participant.getParticipantPublicId(), e); + log.info("{}", e); + } + + public void recordParticipantLeft(Participant participant, String sessionId) { + CDREvent e = this.participants.remove(participant.getParticipantPublicId()); + log.info("{}", new CDREvent(CDREvent.PARTICIPANT_LEFT, e)); + } public void recordNewPublisher(Participant participant, String sessionId, MediaOptions mediaOptions) { - CDRTransmission publisher = new CDRTransmission(participant, sessionId, mediaOptions, null); + CDREvent publisher = new CDREvent(CDREvent.CONNECTION_CREATED, participant, sessionId, mediaOptions, null, System.currentTimeMillis()); this.publications.put(participant.getParticipantPublicId(), publisher); + log.info("{}", publisher); } public void recordNewSubscriber(Participant participant, String sessionId, String senderPublicId) { - CDRTransmission publisher = this.publications.get(senderPublicId); - CDRTransmission subscriber = new CDRTransmission(participant, sessionId, publisher.getMediaOptions(), publisher); + CDREvent publisher = this.publications.get(senderPublicId); + CDREvent subscriber = new CDREvent(CDREvent.CONNECTION_CREATED, participant, sessionId, publisher.getMediaOptions(), publisher.getParticipantPublicId(), System.currentTimeMillis()); this.subscriptions.putIfAbsent(participant.getParticipantPublicId(), new ConcurrentSkipListSet<>()); this.subscriptions.get(participant.getParticipantPublicId()).add(subscriber); + log.info("{}", subscriber); } public boolean stopPublisher(String participantPublicId) { - CDRTransmission publisher = this.publications.remove(participantPublicId); + CDREvent publisher = this.publications.remove(participantPublicId); if (publisher != null) { - publisher.endCall(); - log.info("{}", getTransmissionMessage(publisher)); + publisher = new CDREvent(CDREvent.CONNECTION_DESTROYED, publisher); + log.info("{}", publisher); return true; } return false; } public boolean stopSubscriber(String participantPublicId, String senderPublicId) { - Set participantSubscriptions = this.subscriptions.get(participantPublicId); + Set participantSubscriptions = this.subscriptions.get(participantPublicId); if (participantSubscriptions != null) { - CDRTransmission subscription; - for (Iterator it = participantSubscriptions.iterator(); it.hasNext();) { + CDREvent subscription; + for (Iterator it = participantSubscriptions.iterator(); it.hasNext();) { subscription = it.next(); - if (subscription.getReceivingFrom().getParticipant().getParticipantPublicId().equals(senderPublicId)) { + if (subscription.getReceivingFrom().equals(senderPublicId)) { it.remove(); - subscription.endCall(); - log.info("{}", getTransmissionMessage(subscription)); + subscription = new CDREvent(CDREvent.CONNECTION_DESTROYED, subscription); + log.info("{}", subscription); return true; } } @@ -75,35 +101,16 @@ public class CallDetailRecord { } public void stopAllSubscriptions(String participantPublicId) { - Set participantSubscriptions = this.subscriptions.get(participantPublicId); + Set participantSubscriptions = this.subscriptions.get(participantPublicId); if (participantSubscriptions != null) { - CDRTransmission subscription; - for (Iterator it = participantSubscriptions.iterator(); it.hasNext();) { + CDREvent subscription; + for (Iterator it = participantSubscriptions.iterator(); it.hasNext();) { subscription = it.next(); - subscription.endCall(); - log.info("{}", getTransmissionMessage(subscription)); + subscription = new CDREvent(CDREvent.CONNECTION_DESTROYED, subscription); + log.info("{}", subscription); } this.subscriptions.remove(participantPublicId).clear(); } } - private String getTransmissionMessage(CDRTransmission cdr) { - StringBuffer sb = new StringBuffer(); - sb.append("\n"); - sb.append("\t").append(cdr.getParticipant().getParticipantPublicId()).append("\n"); - sb.append("\t").append(cdr.getSessionId()).append("\n"); - sb.append("\t").append((cdr.getReceivingFrom() != null) ? "INBOUND" : "OUTBOUND").append("\n"); - if (cdr.getReceivingFrom() != null) sb.append("\t").append((cdr.getReceivingFrom() != null) - ? cdr.getReceivingFrom().getParticipant().getParticipantPublicId() - : "").append("\n"); - sb.append("\t").append(cdr.getAudioEnabled()).append("\n"); - sb.append("\t").append(cdr.getVideoEnabled()).append("\n"); - if (cdr.getVideoEnabled()) sb.append("\t").append(cdr.typeOfVideo()).append("\n"); - sb.append("\t").append(cdr.getDateOfStart()).append("\n"); - sb.append("\t").append(cdr.getDateOfEnd()).append("\n"); - sb.append("\t").append(cdr.totalCallDuration()).append("\n"); - sb.append("\n"); - return sb.toString(); - } - } diff --git a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java index f75fb3b3..46366399 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java +++ b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java @@ -7,14 +7,14 @@ import org.springframework.stereotype.Component; public class OpenviduConfig { @Value("${openvidu.publicurl}") - private String openviduPublicUrl; //local, ngrok, docker, [FINAL_URL] + private String openviduPublicUrl; // local, ngrok, docker, [FINAL_URL] @Value("${server.port}") private String serverPort; @Value("${openvidu.secret}") private String openviduSecret; - + @Value("${openvidu.cdr}") private boolean openviduCdr; @@ -29,11 +29,11 @@ public class OpenviduConfig { public String getOpenViduSecret() { return this.openviduSecret; } - + public boolean isOpenViduSecret(String secret) { return secret.equals(this.getOpenViduSecret()); } - + public boolean isCdrEnabled() { return this.openviduCdr; } diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/Session.java b/openvidu-server/src/main/java/io/openvidu/server/core/Session.java index ac4d00f9..893c0ae4 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/Session.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/Session.java @@ -10,7 +10,7 @@ public interface Session { void leave(String participantPrivateId); - void close(); + boolean close(); boolean isClosed(); diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java index e1f0c2e6..123226d4 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java @@ -32,18 +32,21 @@ public class SessionEventsHandler { @Autowired protected OpenviduConfig openviduConfig; - - public void onSessionClosed(String sessionId, Set participants) { - JsonObject notifParams = new JsonObject(); - notifParams.addProperty(ProtocolElements.ROOMCLOSED_ROOM_PARAM, sessionId); - for (Participant participant : participants) { - rpcNotificationService.sendNotification(participant.getParticipantPrivateId(), - ProtocolElements.ROOMCLOSED_METHOD, notifParams); + + public void onSessionCreated(String sessionId) { + if (openviduConfig.isCdrEnabled()) { + CDR.recordSessionCreated(sessionId); } } - public void onParticipantJoined(Participant participant, Integer transactionId, - Set existingParticipants, OpenViduException error) { + public void onSessionClosed(String sessionId) { + if (openviduConfig.isCdrEnabled()) { + CDR.recordSessionDestroyed(sessionId); + } + } + + public void onParticipantJoined(Participant participant, String sessionId, + Set existingParticipants, Integer transactionId, OpenViduException error) { if (error != null) { rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error); return; @@ -97,10 +100,14 @@ public class SessionEventsHandler { result.add("value", resultArray); rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, result); + + if (openviduConfig.isCdrEnabled()) { + CDR.recordParticipantJoined(participant, sessionId); + } } - public void onParticipantLeft(Participant participant, Integer transactionId, - Set remainingParticipants, OpenViduException error) { + public void onParticipantLeft(Participant participant, String sessionId, + Set remainingParticipants, Integer transactionId, OpenViduException error) { if (error != null) { rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error); return; @@ -129,11 +136,15 @@ public class SessionEventsHandler { rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, new JsonObject()); } rpcNotificationService.closeRpcSession(participant.getParticipantPrivateId()); + + if (openviduConfig.isCdrEnabled()) { + CDR.recordParticipantLeft(participant, sessionId); + } } - public void onPublishMedia(Participant participant, String sessionId, Integer transactionId, MediaOptions mediaOptions, - String sdpAnswer, Set participants, OpenViduException error) { + public void onPublishMedia(Participant participant, String sessionId, MediaOptions mediaOptions, + String sdpAnswer, Set participants, Integer transactionId, OpenViduException error) { if (error != null) { rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error); return; diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java index b17ca46e..68449bd1 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java @@ -31,30 +31,22 @@ public abstract class SessionManager { private volatile boolean closed = false; - public void joinRoom(Participant participant, String sessionId, Integer transactionId) { - } + public abstract void joinRoom(Participant participant, String sessionId, Integer transactionId); - public void leaveRoom(Participant participant, Integer transactionId) { - } + public abstract void leaveRoom(Participant participant, Integer transactionId); - public void publishVideo(Participant participant, MediaOptions mediaOptions, Integer transactionId) { - } - - public void unpublishVideo(Participant participant, Integer transactionId) { - } - - public void subscribe(Participant participant, String senderName, String sdpOffer, Integer transactionId) { - } + public abstract void publishVideo(Participant participant, MediaOptions mediaOptions, Integer transactionId); - public void unsubscribe(Participant participant, String senderName, Integer transactionId) { - } - - public void sendMessage(Participant participant, String message, Integer transactionId) { - } + public abstract void unpublishVideo(Participant participant, Integer transactionId); - public void onIceCandidate(Participant participant, String endpointName, String candidate, int sdpMLineIndex, - String sdpMid, Integer transactionId) { - } + public abstract void subscribe(Participant participant, String senderName, String sdpOffer, Integer transactionId); + + public abstract void unsubscribe(Participant participant, String senderName, Integer transactionId); + + public abstract void sendMessage(Participant participant, String message, Integer transactionId); + + public abstract void onIceCandidate(Participant participant, String endpointName, String candidate, + int sdpMLineIndex, String sdpMid, Integer transactionId); /** * Application-originated request to remove a participant from a session.
@@ -200,7 +192,8 @@ public abstract class SessionManager { public boolean isPublisherInSession(String sessionId, Participant participant) { if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) { if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) { - return ParticipantRole.PUBLISHER.equals(participant.getToken().getRole()); + return (ParticipantRole.PUBLISHER.equals(participant.getToken().getRole()) + || ParticipantRole.MODERATOR.equals(participant.getToken().getRole())); } else { return false; } @@ -263,17 +256,15 @@ public abstract class SessionManager { public void showTokens() { log.info(": {}", this.sessionidTokenTokenobj.toString()); } - + public void showInsecureParticipants() { log.info(": {}", this.insecureUsers.toString()); } - + public void showAllParticipants() { log.info(": {}", this.sessionidParticipantpublicidParticipant.toString()); } - - /** * Closes all resources. This method has been annotated with the @PreDestroy * directive (javax.annotation package) so that it will be automatically called @@ -298,15 +289,15 @@ public abstract class SessionManager { /** * Closes an existing session by releasing all resources that were allocated for - * it. Once closed, the session can be reopened (will be empty and it will - * use another Media Pipeline). Existing participants will be evicted.
- * Dev advice: The session event handler should send notifications - * to the existing participants in the session to inform that it was forcibly - * closed. + * it. Once closed, the session can be reopened (will be empty and it will use + * another Media Pipeline). Existing participants will be evicted.
+ * Dev advice: The session event handler should send + * notifications to the existing participants in the session to inform that it + * was forcibly closed. * * @param sessionId * identifier of the session - * @return + * @return * @return set of {@link Participant} POJOS representing the session's * participants * @throws OpenViduException @@ -322,9 +313,7 @@ public abstract class SessionManager { } Set participants = getParticipants(sessionId); // copy the ids as they will be removed from the map - Set pids = participants.stream() - .map(Participant::getParticipantPrivateId) - .collect(Collectors.toSet()); + Set pids = participants.stream().map(Participant::getParticipantPrivateId).collect(Collectors.toSet()); for (String pid : pids) { try { session.leave(pid); diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSession.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSession.java index e8cdb725..ded9a21c 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSession.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSession.java @@ -155,7 +155,7 @@ public class KurentoSession implements Session { } @Override - public void close() { + public boolean close() { if (!closed) { for (KurentoParticipant participant : participants.values()) { @@ -174,8 +174,10 @@ public class KurentoSession implements Session { } this.closed = true; + return true; } else { log.warn("Closing an already closed session '{}'", this.sessionId); + return false; } } diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java index 0b3bc12b..0ac0ecf3 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java @@ -68,10 +68,10 @@ public class KurentoSessionManager extends SessionManager { } catch (OpenViduException e) { log.warn("PARTICIPANT {}: Error joining/creating session {}", participant.getParticipantPublicId(), sessionId, e); - sessionHandler.onParticipantJoined(participant, transactionId, null, e); + sessionHandler.onParticipantJoined(participant, sessionId, null, transactionId, e); } if (existingParticipants != null) { - sessionHandler.onParticipantJoined(participant, transactionId, existingParticipants, null); + sessionHandler.onParticipantJoined(participant, sessionId, existingParticipants, transactionId, null); } } @@ -119,7 +119,9 @@ public class KurentoSessionManager extends SessionManager { } if (remainingParticipants.isEmpty()) { log.debug("No more participants in session '{}', removing it and closing it", sessionId); - session.close(); + if (session.close()) { + sessionHandler.onSessionClosed(sessionId); + } sessions.remove(sessionId); sessionidParticipantpublicidParticipant.remove(sessionId); @@ -130,7 +132,7 @@ public class KurentoSessionManager extends SessionManager { log.warn("Session '{}' removed and closed", sessionId); } - sessionHandler.onParticipantLeft(participant, transactionId, remainingParticipants, null); + sessionHandler.onParticipantLeft(participant, sessionId, remainingParticipants, transactionId, null); } /** @@ -190,7 +192,7 @@ public class KurentoSessionManager extends SessionManager { OpenViduException e = new OpenViduException(Code.MEDIA_SDP_ERROR_CODE, "Error generating SDP response for publishing user " + participant.getParticipantPublicId()); log.error("PARTICIPANT {}: Error publishing media", participant.getParticipantPublicId(), e); - sessionHandler.onPublishMedia(participant, session.getSessionId(), transactionId, mediaOptions, sdpAnswer, participants, e); + sessionHandler.onPublishMedia(participant, session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e); } session.newPublisher(participant); @@ -202,7 +204,7 @@ public class KurentoSessionManager extends SessionManager { participants = kurentoParticipant.getSession().getParticipants(); if (sdpAnswer != null) { - sessionHandler.onPublishMedia(participant, session.getSessionId(), transactionId, mediaOptions, sdpAnswer, participants, null); + sessionHandler.onPublishMedia(participant, session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, null); } } @@ -357,6 +359,8 @@ public class KurentoSessionManager extends SessionManager { kcName = kurentoClient.getServerManager().getName(); } log.warn("No session '{}' exists yet. Created one using KurentoClient '{}'.", sessionId, kcName); + + sessionHandler.onSessionCreated(sessionId); } /** diff --git a/openvidu-server/src/main/resources/log4j.properties b/openvidu-server/src/main/resources/log4j.properties deleted file mode 100644 index fd7ef3b4..00000000 --- a/openvidu-server/src/main/resources/log4j.properties +++ /dev/null @@ -1,10 +0,0 @@ -log4j.rootLogger=INFO, stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%p] %d [%.12t] %c (%M) - %m%n - -log4j.logger.io.openvidu.server.cdr.CallDetailRecord=INFO, cdr -log4j.appender.cdr=org.apache.log4j.DailyRollingFileAppender -log4j.appender.cdr.File=log/CDR.log -log4j.appender.cdr.layout=org.apache.log4j.PatternLayout -log4j.appender.cdr.layout.ConversionPattern=%m\n \ No newline at end of file diff --git a/openvidu-server/src/main/resources/logback.xml b/openvidu-server/src/main/resources/logback.xml new file mode 100644 index 00000000..fe567bba --- /dev/null +++ b/openvidu-server/src/main/resources/logback.xml @@ -0,0 +1,28 @@ + + + + + + [%p] %d [%.12t] %c \(%M\) - %msg%n + + + + + log/CDR.%d{yyyy-MM-dd}_${myTimestamp}.log + 30 + 20GB + + + %m\n + + + + + + + + + + + \ No newline at end of file