mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: cdr enabled condition checked in CallDetailRecord class
parent
a8495a6f54
commit
2a35293e18
|
@ -23,6 +23,9 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import io.openvidu.server.config.OpenviduConfig;
|
||||||
import io.openvidu.server.core.MediaOptions;
|
import io.openvidu.server.core.MediaOptions;
|
||||||
import io.openvidu.server.core.Participant;
|
import io.openvidu.server.core.Participant;
|
||||||
import io.openvidu.server.recording.Recording;
|
import io.openvidu.server.recording.Recording;
|
||||||
|
@ -73,6 +76,9 @@ import io.openvidu.server.recording.Recording;
|
||||||
*/
|
*/
|
||||||
public class CallDetailRecord {
|
public class CallDetailRecord {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected OpenviduConfig openviduConfig;
|
||||||
|
|
||||||
private CDRLogger logger;
|
private CDRLogger logger;
|
||||||
|
|
||||||
private Map<String, CDREvent> sessions = new ConcurrentHashMap<>();
|
private Map<String, CDREvent> sessions = new ConcurrentHashMap<>();
|
||||||
|
@ -87,37 +93,37 @@ public class CallDetailRecord {
|
||||||
public void recordSessionCreated(String sessionId) {
|
public void recordSessionCreated(String sessionId) {
|
||||||
CDREvent e = new CDREvent(CDREventName.sessionCreated, sessionId);
|
CDREvent e = new CDREvent(CDREventName.sessionCreated, sessionId);
|
||||||
this.sessions.put(sessionId, e);
|
this.sessions.put(sessionId, e);
|
||||||
this.logger.log(e);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordSessionDestroyed(String sessionId, String reason) {
|
public void recordSessionDestroyed(String sessionId, String reason) {
|
||||||
CDREvent e = this.sessions.remove(sessionId);
|
CDREvent e = this.sessions.remove(sessionId);
|
||||||
this.logger.log(new CDREvent(CDREventName.sessionDestroyed, e, reason));
|
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.sessionDestroyed, e, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordParticipantJoined(Participant participant, String sessionId) {
|
public void recordParticipantJoined(Participant participant, String sessionId) {
|
||||||
CDREvent e = new CDREvent(CDREventName.participantJoined, participant, sessionId);
|
CDREvent e = new CDREvent(CDREventName.participantJoined, participant, sessionId);
|
||||||
this.participants.put(participant.getParticipantPublicId(), e);
|
this.participants.put(participant.getParticipantPublicId(), e);
|
||||||
this.logger.log(e);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordParticipantLeft(Participant participant, String sessionId, String reason) {
|
public void recordParticipantLeft(Participant participant, String sessionId, String reason) {
|
||||||
CDREvent e = this.participants.remove(participant.getParticipantPublicId());
|
CDREvent e = this.participants.remove(participant.getParticipantPublicId());
|
||||||
this.logger.log(new CDREvent(CDREventName.participantLeft, e, reason));
|
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.participantLeft, e, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordNewPublisher(Participant participant, String sessionId, MediaOptions mediaOptions) {
|
public void recordNewPublisher(Participant participant, String sessionId, MediaOptions mediaOptions) {
|
||||||
CDREvent publisher = new CDREvent(CDREventName.webrtcConnectionCreated, participant, sessionId, mediaOptions,
|
CDREvent publisher = new CDREvent(CDREventName.webrtcConnectionCreated, participant, sessionId, mediaOptions,
|
||||||
null, System.currentTimeMillis(), null);
|
null, System.currentTimeMillis(), null);
|
||||||
this.publications.put(participant.getParticipantPublicId(), publisher);
|
this.publications.put(participant.getParticipantPublicId(), publisher);
|
||||||
this.logger.log(publisher);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(publisher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean stopPublisher(String participantPublicId, String reason) {
|
public boolean stopPublisher(String participantPublicId, String reason) {
|
||||||
CDREvent publisher = this.publications.remove(participantPublicId);
|
CDREvent publisher = this.publications.remove(participantPublicId);
|
||||||
if (publisher != null) {
|
if (publisher != null) {
|
||||||
publisher = new CDREvent(CDREventName.webrtcConnectionDestroyed, publisher, reason);
|
publisher = new CDREvent(CDREventName.webrtcConnectionDestroyed, publisher, reason);
|
||||||
this.logger.log(publisher);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(publisher);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -129,7 +135,7 @@ public class CallDetailRecord {
|
||||||
publisher.getMediaOptions(), publisher.getParticipantPublicId(), System.currentTimeMillis(), null);
|
publisher.getMediaOptions(), publisher.getParticipantPublicId(), System.currentTimeMillis(), null);
|
||||||
this.subscriptions.putIfAbsent(participant.getParticipantPublicId(), new ConcurrentSkipListSet<>());
|
this.subscriptions.putIfAbsent(participant.getParticipantPublicId(), new ConcurrentSkipListSet<>());
|
||||||
this.subscriptions.get(participant.getParticipantPublicId()).add(subscriber);
|
this.subscriptions.get(participant.getParticipantPublicId()).add(subscriber);
|
||||||
this.logger.log(subscriber);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean stopSubscriber(String participantPublicId, String senderPublicId, String reason) {
|
public boolean stopSubscriber(String participantPublicId, String senderPublicId, String reason) {
|
||||||
|
@ -141,7 +147,7 @@ public class CallDetailRecord {
|
||||||
if (subscription.getReceivingFrom().equals(senderPublicId)) {
|
if (subscription.getReceivingFrom().equals(senderPublicId)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
subscription = new CDREvent(CDREventName.webrtcConnectionDestroyed, subscription, reason);
|
subscription = new CDREvent(CDREventName.webrtcConnectionDestroyed, subscription, reason);
|
||||||
this.logger.log(subscription);
|
if (openviduConfig.isCdrEnabled()) this.logger.log(subscription);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,11 +156,11 @@ public class CallDetailRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordRecordingStarted(String sessionId, Recording recording) {
|
public void recordRecordingStarted(String sessionId, Recording recording) {
|
||||||
this.logger.log(new CDREvent(CDREventName.recordingStarted, sessionId, recording));
|
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStarted, sessionId, recording));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordRecordingStopped(String sessionId, Recording recording) {
|
public void recordRecordingStopped(String sessionId, Recording recording) {
|
||||||
this.logger.log(new CDREvent(CDREventName.recordingStopped, sessionId, recording));
|
if (openviduConfig.isCdrEnabled()) this.logger.log(new CDREvent(CDREventName.recordingStopped, sessionId, recording));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,16 +64,12 @@ public class SessionEventsHandler {
|
||||||
ReentrantLock lock = new ReentrantLock();
|
ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
public void onSessionCreated(String sessionId) {
|
public void onSessionCreated(String sessionId) {
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.recordSessionCreated(sessionId);
|
CDR.recordSessionCreated(sessionId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void onSessionClosed(String sessionId, String reason) {
|
public void onSessionClosed(String sessionId, String reason) {
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.recordSessionDestroyed(sessionId, reason);
|
CDR.recordSessionDestroyed(sessionId, reason);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void onParticipantJoined(Participant participant, String sessionId, Set<Participant> existingParticipants,
|
public void onParticipantJoined(Participant participant, String sessionId, Set<Participant> existingParticipants,
|
||||||
Integer transactionId, OpenViduException error) {
|
Integer transactionId, OpenViduException error) {
|
||||||
|
@ -327,9 +323,7 @@ public class SessionEventsHandler {
|
||||||
|
|
||||||
public void sendRecordingStartedNotification(Session session, Recording recording) {
|
public void sendRecordingStartedNotification(Session session, Recording recording) {
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.recordRecordingStarted(session.getSessionId(), recording);
|
CDR.recordRecordingStarted(session.getSessionId(), recording);
|
||||||
}
|
|
||||||
|
|
||||||
// Filter participants by roles according to "openvidu.recording.notification"
|
// Filter participants by roles according to "openvidu.recording.notification"
|
||||||
Set<Participant> filteredParticipants = this.filterParticipantsByRole(
|
Set<Participant> filteredParticipants = this.filterParticipantsByRole(
|
||||||
|
@ -347,9 +341,7 @@ public class SessionEventsHandler {
|
||||||
|
|
||||||
public void sendRecordingStoppedNotification(Session session, Recording recording) {
|
public void sendRecordingStoppedNotification(Session session, Recording recording) {
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.recordRecordingStopped(session.getSessionId(), recording);
|
CDR.recordRecordingStopped(session.getSessionId(), recording);
|
||||||
}
|
|
||||||
|
|
||||||
// Be sure to clean this map (this should return null)
|
// Be sure to clean this map (this should return null)
|
||||||
this.recordingsStarted.remove(session.getSessionId());
|
this.recordingsStarted.remove(session.getSessionId());
|
||||||
|
|
|
@ -107,9 +107,7 @@ public class KurentoParticipant extends Participant {
|
||||||
this.publisher.getEndpoint().addTag("name", publisherStreamId);
|
this.publisher.getEndpoint().addTag("name", publisherStreamId);
|
||||||
addEndpointListeners(this.publisher);
|
addEndpointListeners(this.publisher);
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.recordNewPublisher(this, this.session.getSessionId(), mediaOptions);
|
CDR.recordNewPublisher(this, this.session.getSessionId(), mediaOptions);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +312,7 @@ public class KurentoParticipant extends Participant {
|
||||||
log.info("PARTICIPANT {}: Is now receiving video from {} in room {}", this.getParticipantPublicId(),
|
log.info("PARTICIPANT {}: Is now receiving video from {} in room {}", this.getParticipantPublicId(),
|
||||||
senderName, this.session.getSessionId());
|
senderName, this.session.getSessionId());
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled() && !ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
|
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
|
||||||
CDR.recordNewSubscriber(this, this.session.getSessionId(), sender.getParticipantPublicId());
|
CDR.recordNewSubscriber(this, this.session.getSessionId(), sender.getParticipantPublicId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,9 +473,7 @@ public class KurentoParticipant extends Participant {
|
||||||
this.streaming = false;
|
this.streaming = false;
|
||||||
publisher = null;
|
publisher = null;
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled()) {
|
|
||||||
CDR.stopPublisher(this.getParticipantPublicId(), reason);
|
CDR.stopPublisher(this.getParticipantPublicId(), reason);
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.warn("PARTICIPANT {}: Trying to release publisher endpoint but is null", getParticipantPublicId());
|
log.warn("PARTICIPANT {}: Trying to release publisher endpoint but is null", getParticipantPublicId());
|
||||||
|
@ -489,7 +485,7 @@ public class KurentoParticipant extends Participant {
|
||||||
subscriber.unregisterErrorListeners();
|
subscriber.unregisterErrorListeners();
|
||||||
releaseElement(senderName, subscriber.getEndpoint());
|
releaseElement(senderName, subscriber.getEndpoint());
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled() && !ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
|
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
|
||||||
CDR.stopSubscriber(this.getParticipantPublicId(), senderName, reason);
|
CDR.stopSubscriber(this.getParticipantPublicId(), senderName, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,12 @@ import org.kurento.client.KurentoClient;
|
||||||
import org.kurento.client.MediaPipeline;
|
import org.kurento.client.MediaPipeline;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import io.openvidu.client.OpenViduException;
|
import io.openvidu.client.OpenViduException;
|
||||||
import io.openvidu.client.OpenViduException.Code;
|
import io.openvidu.client.OpenViduException.Code;
|
||||||
import io.openvidu.client.internal.ProtocolElements;
|
import io.openvidu.client.internal.ProtocolElements;
|
||||||
import io.openvidu.java.client.SessionProperties;
|
import io.openvidu.java.client.SessionProperties;
|
||||||
import io.openvidu.server.cdr.CallDetailRecord;
|
import io.openvidu.server.cdr.CallDetailRecord;
|
||||||
import io.openvidu.server.config.OpenviduConfig;
|
|
||||||
import io.openvidu.server.core.Participant;
|
import io.openvidu.server.core.Participant;
|
||||||
import io.openvidu.server.core.Session;
|
import io.openvidu.server.core.Session;
|
||||||
|
|
||||||
|
@ -54,9 +52,6 @@ public class KurentoSession implements Session {
|
||||||
private final static Logger log = LoggerFactory.getLogger(Session.class);
|
private final static Logger log = LoggerFactory.getLogger(Session.class);
|
||||||
public static final int ASYNC_LATCH_TIMEOUT = 30;
|
public static final int ASYNC_LATCH_TIMEOUT = 30;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected OpenviduConfig openviduConfig;
|
|
||||||
|
|
||||||
private final ConcurrentMap<String, KurentoParticipant> participants = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, KurentoParticipant> participants = new ConcurrentHashMap<>();
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
private SessionProperties sessionProperties;
|
private SessionProperties sessionProperties;
|
||||||
|
@ -115,7 +110,7 @@ public class KurentoSession implements Session {
|
||||||
|
|
||||||
log.info("SESSION {}: Added participant {}", sessionId, participant);
|
log.info("SESSION {}: Added participant {}", sessionId, participant);
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled() && !ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(participant.getParticipantPublicId())) {
|
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(participant.getParticipantPublicId())) {
|
||||||
CDR.recordParticipantJoined(participant, sessionId);
|
CDR.recordParticipantJoined(participant, sessionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +166,7 @@ public class KurentoSession implements Session {
|
||||||
this.removeParticipant(participant, reason);
|
this.removeParticipant(participant, reason);
|
||||||
participant.close(reason);
|
participant.close(reason);
|
||||||
|
|
||||||
if (openviduConfig.isCdrEnabled() && !ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(participant.getParticipantPublicId())) {
|
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(participant.getParticipantPublicId())) {
|
||||||
CDR.recordParticipantLeft(participant, participant.getSession().getSessionId(), reason);
|
CDR.recordParticipantLeft(participant, participant.getSession().getSessionId(), reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue