openvidu-server: KurentoParticipantEndpointConfig abstraction

pull/255/head
pabloFuente 2019-03-07 10:51:33 +01:00
parent 57796e38be
commit 3641d90292
9 changed files with 198 additions and 149 deletions

View File

@ -59,6 +59,7 @@ import io.openvidu.server.coturn.CoturnCredentialsService;
import io.openvidu.server.coturn.CoturnCredentialsServiceFactory;
import io.openvidu.server.kurento.AutodiscoveryKurentoClientProvider;
import io.openvidu.server.kurento.KurentoClientProvider;
import io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig;
import io.openvidu.server.kurento.core.KurentoSessionEventsHandler;
import io.openvidu.server.kurento.core.KurentoSessionManager;
import io.openvidu.server.kurento.kms.FixedOneKmsManager;
@ -144,6 +145,12 @@ public class OpenViduServer implements JsonRpcConfigurer {
return new CallDetailRecord(Arrays.asList(new CDRLoggerFile()));
}
@Bean
@ConditionalOnMissingBean
public KurentoParticipantEndpointConfig kurentoEndpointConfig() {
return new KurentoParticipantEndpointConfig();
}
@Bean
@ConditionalOnMissingBean
public TokenGenerator tokenGenerator() {

View File

@ -24,6 +24,7 @@ public class Participant {
protected String finalUserId; // ID to match this connection with a final user (HttpSession id)
protected String participantPrivatetId; // ID to identify the user on server (org.kurento.jsonrpc.Session.id)
protected String participantPublicId; // ID to identify the user on clients
private String sessionId; // ID of the session to which the participant belongs
protected Long createdAt; // Timestamp when this connection was established
protected String clientMetadata = ""; // Metadata provided on client side
protected String serverMetadata = ""; // Metadata provided on server side
@ -36,11 +37,12 @@ public class Participant {
private final String METADATA_SEPARATOR = "%/%";
public Participant(String finalUserId, String participantPrivatetId, String participantPublicId, Token token,
String clientMetadata, String location, String platform, Long createdAt) {
public Participant(String finalUserId, String participantPrivatetId, String participantPublicId, String sessionId,
Token token, String clientMetadata, String location, String platform, Long createdAt) {
this.finalUserId = finalUserId;
this.participantPrivatetId = participantPrivatetId;
this.participantPublicId = participantPublicId;
this.sessionId = sessionId;
if (createdAt != null) {
this.createdAt = createdAt;
} else {
@ -74,6 +76,10 @@ public class Participant {
this.participantPublicId = participantPublicId;
}
public String getSessionId() {
return sessionId;
}
public Long getCreatedAt() {
return this.createdAt;
}

View File

@ -34,7 +34,6 @@ import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.Recording;
import io.openvidu.java.client.RecordingLayout;
import io.openvidu.java.client.SessionProperties;
import io.openvidu.server.cdr.CallDetailRecord;
import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.kurento.core.KurentoParticipant;
import io.openvidu.server.recording.service.RecordingManager;
@ -43,7 +42,6 @@ public class Session implements SessionInterface {
protected OpenviduConfig openviduConfig;
protected RecordingManager recordingManager;
protected CallDetailRecord CDR;
protected final ConcurrentMap<String, Participant> participants = new ConcurrentHashMap<>();
protected String sessionId;
@ -59,17 +57,15 @@ public class Session implements SessionInterface {
this.sessionId = previousSession.getSessionId();
this.startTime = previousSession.getStartTime();
this.sessionProperties = previousSession.getSessionProperties();
this.CDR = previousSession.CDR;
this.openviduConfig = previousSession.openviduConfig;
this.recordingManager = previousSession.recordingManager;
}
public Session(String sessionId, SessionProperties sessionProperties, CallDetailRecord CDR,
OpenviduConfig openviduConfig, RecordingManager recordingManager) {
public Session(String sessionId, SessionProperties sessionProperties, OpenviduConfig openviduConfig,
RecordingManager recordingManager) {
this.sessionId = sessionId;
this.startTime = System.currentTimeMillis();
this.sessionProperties = sessionProperties;
this.CDR = CDR;
this.openviduConfig = openviduConfig;
this.recordingManager = recordingManager;
}

View File

@ -554,10 +554,6 @@ public class SessionEventsHandler {
this.recordingsStarted.put(sessionId, recording);
}
public InfoHandler getInfoHandler() {
return this.infoHandler;
}
private Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
return participants.stream().filter(part -> {
if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) {

View File

@ -42,7 +42,6 @@ import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.OpenViduRole;
import io.openvidu.java.client.SessionProperties;
import io.openvidu.server.cdr.CDREventRecording;
import io.openvidu.server.cdr.CallDetailRecord;
import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.coturn.CoturnCredentialsService;
import io.openvidu.server.kurento.core.KurentoTokenOptions;
@ -60,9 +59,6 @@ public abstract class SessionManager {
@Autowired
protected RecordingManager recordingManager;
@Autowired
protected CallDetailRecord CDR;
@Autowired
protected OpenviduConfig openviduConfig;
@ -241,7 +237,7 @@ public abstract class SessionManager {
}
public Session storeSessionNotActive(String sessionId, SessionProperties sessionProperties) {
Session sessionNotActive = new Session(sessionId, sessionProperties, CDR, openviduConfig, recordingManager);
Session sessionNotActive = new Session(sessionId, sessionProperties, openviduConfig, recordingManager);
this.sessionsNotActive.put(sessionId, sessionNotActive);
this.sessionidParticipantpublicidParticipant.putIfAbsent(sessionId, new ConcurrentHashMap<>());
this.sessionidFinalUsers.putIfAbsent(sessionId, new ConcurrentHashMap<>());
@ -342,7 +338,7 @@ public abstract class SessionManager {
String clientMetadata, String location, String platform, String finalUserId) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
String participantPublicId = RandomStringGenerator.generateRandomChain();
Participant p = new Participant(finalUserId, participantPrivatetId, participantPublicId, token,
Participant p = new Participant(finalUserId, participantPrivatetId, participantPublicId, sessionId, token,
clientMetadata, location, platform, null);
while (this.sessionidParticipantpublicidParticipant.get(sessionId).putIfAbsent(participantPublicId,
p) != null) {
@ -373,7 +369,7 @@ public abstract class SessionManager {
String clientMetadata) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
Participant p = new Participant(null, participantPrivatetId, ProtocolElements.RECORDER_PARTICIPANT_PUBLICID,
token, clientMetadata, null, null, null);
sessionId, token, clientMetadata, null, null, null);
this.sessionidParticipantpublicidParticipant.get(sessionId)
.put(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, p);
return p;

View File

@ -43,13 +43,9 @@ import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code;
import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.java.client.OpenViduRole;
import io.openvidu.server.cdr.CallDetailRecord;
import io.openvidu.server.config.InfoHandler;
import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.MediaOptions;
import io.openvidu.server.core.Participant;
import io.openvidu.server.kurento.endpoint.KmsEvent;
import io.openvidu.server.kurento.endpoint.KmsMediaEvent;
import io.openvidu.server.kurento.endpoint.MediaEndpoint;
import io.openvidu.server.kurento.endpoint.PublisherEndpoint;
import io.openvidu.server.kurento.endpoint.SdpType;
@ -60,14 +56,13 @@ public class KurentoParticipant extends Participant {
private static final Logger log = LoggerFactory.getLogger(KurentoParticipant.class);
private InfoHandler infoHandler;
private CallDetailRecord CDR;
private OpenviduConfig openviduConfig;
private RecordingManager recordingManager;
private boolean webParticipant = true;
private final KurentoSession session;
private KurentoParticipantEndpointConfig endpointConfig;
private PublisherEndpoint publisher;
private CountDownLatch endPointLatch = new CountDownLatch(1);
@ -75,13 +70,13 @@ public class KurentoParticipant extends Participant {
private final ConcurrentMap<String, Filter> filters = new ConcurrentHashMap<>();
private final ConcurrentMap<String, SubscriberEndpoint> subscribers = new ConcurrentHashMap<String, SubscriberEndpoint>();
public KurentoParticipant(Participant participant, KurentoSession kurentoSession, InfoHandler infoHandler,
CallDetailRecord CDR, OpenviduConfig openviduConfig, RecordingManager recordingManager) {
public KurentoParticipant(Participant participant, KurentoSession kurentoSession,
KurentoParticipantEndpointConfig endpointConfig, OpenviduConfig openviduConfig,
RecordingManager recordingManager) {
super(participant.getFinalUserId(), participant.getParticipantPrivateId(), participant.getParticipantPublicId(),
participant.getToken(), participant.getClientMetadata(), participant.getLocation(),
participant.getPlatform(), participant.getCreatedAt());
this.infoHandler = infoHandler;
this.CDR = CDR;
kurentoSession.getSessionId(), participant.getToken(), participant.getClientMetadata(),
participant.getLocation(), participant.getPlatform(), participant.getCreatedAt());
this.endpointConfig = endpointConfig;
this.openviduConfig = openviduConfig;
this.recordingManager = recordingManager;
this.session = kurentoSession;
@ -114,7 +109,7 @@ public class KurentoParticipant extends Participant {
this.publisher.getEndpoint().setName(publisherStreamId);
this.publisher.setStreamId(publisherStreamId);
addEndpointListeners(this.publisher, "publisher");
endpointConfig.addEndpointListeners(this.publisher, "publisher");
// Remove streamId from publisher's map
this.session.publishedStreamIds.putIfAbsent(this.getPublisherStreamId(), this.getParticipantPrivateId());
@ -185,8 +180,8 @@ public class KurentoParticipant extends Participant {
this.recordingManager.startOneIndividualStreamRecording(session, null, null, this);
}
CDR.recordNewPublisher(this, session.getSessionId(), publisher.getStreamId(), publisher.getMediaOptions(),
publisher.createdAt());
endpointConfig.getCdr().recordNewPublisher(this, session.getSessionId(), publisher.getStreamId(),
publisher.getMediaOptions(), publisher.createdAt());
return sdpResponse;
}
@ -255,7 +250,7 @@ public class KurentoParticipant extends Participant {
subscriber.getEndpoint().setName(subscriberEndpointName);
subscriber.setStreamId(kSender.getPublisherStreamId());
addEndpointListeners(subscriber, "subscriber");
endpointConfig.addEndpointListeners(subscriber, "subscriber");
} catch (OpenViduException e) {
this.subscribers.remove(senderName);
@ -270,8 +265,8 @@ public class KurentoParticipant extends Participant {
senderName, this.session.getSessionId());
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
CDR.recordNewSubscriber(this, this.session.getSessionId(), sender.getPublisherStreamId(),
sender.getParticipantPublicId(), subscriber.createdAt());
endpointConfig.getCdr().recordNewSubscriber(this, this.session.getSessionId(),
sender.getPublisherStreamId(), sender.getParticipantPublicId(), subscriber.createdAt());
}
return sdpAnswer;
@ -388,7 +383,7 @@ public class KurentoParticipant extends Participant {
this.streaming = false;
this.session.deregisterPublisher();
CDR.stopPublisher(this.getParticipantPublicId(), publisher.getStreamId(), reason);
endpointConfig.getCdr().stopPublisher(this.getParticipantPublicId(), publisher.getStreamId(), reason);
publisher = null;
} else {
@ -402,7 +397,8 @@ public class KurentoParticipant extends Participant {
releaseElement(senderName, subscriber.getEndpoint());
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
CDR.stopSubscriber(this.getParticipantPublicId(), senderName, subscriber.getStreamId(), reason);
endpointConfig.getCdr().stopSubscriber(this.getParticipantPublicId(), senderName,
subscriber.getStreamId(), reason);
}
} else {
@ -433,110 +429,6 @@ public class KurentoParticipant extends Participant {
}
}
private void addEndpointListeners(MediaEndpoint endpoint, String typeOfEndpoint) {
endpoint.getWebEndpoint().addMediaFlowInStateChangeListener(event -> {
String msg = "KMS event [MediaFlowInStateChange] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState() + " | pad: " + event.getPadName()
+ " | mediaType: " + event.getMediaType() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addMediaFlowOutStateChangeListener(event -> {
String msg = "KMS event [MediaFlowOutStateChange] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState() + " | pad: " + event.getPadName()
+ " | mediaType: " + event.getMediaType() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addIceGatheringDoneListener(event -> {
String msg = "KMS event [IceGatheringDone] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addConnectionStateChangedListener(event -> {
String msg = "KMS event [ConnectionStateChanged]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | oldState: " + event.getOldState() + " | newState: " + event.getNewState()
+ " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addNewCandidatePairSelectedListener(event -> {
endpoint.selectedLocalIceCandidate = event.getCandidatePair().getLocalCandidate();
endpoint.selectedRemoteIceCandidate = event.getCandidatePair().getRemoteCandidate();
String msg = "KMS event [NewCandidatePairSelected]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | local: " + endpoint.selectedLocalIceCandidate + " | remote: "
+ endpoint.selectedRemoteIceCandidate + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getEndpoint().addMediaTranscodingStateChangeListener(event -> {
String msg = "KMS event [MediaTranscodingStateChange]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState().name() + " | mediaType: " + event.getMediaType()
+ " | binName: " + event.getBinName() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addIceComponentStateChangeListener(event -> {
// if (!event.getState().equals(IceComponentState.READY)) {
String msg = "KMS event [IceComponentStateChange]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState().name() + " | componentId: "
+ event.getComponentId() + " | streamId: " + event.getStreamId() + " | timestamp: "
+ event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
// }
});
endpoint.getWebEndpoint().addErrorListener(event -> {
String msg = "KMS event [ERROR]: -> endpoint: " + endpoint.getEndpointName() + " (" + typeOfEndpoint
+ ") | errorCode: " + event.getErrorCode() + " | description: " + event.getDescription()
+ " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, this.session.getSessionId(), participantPublicId,
endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.error(msg);
});
}
public MediaPipeline getPipeline() {
return this.session.getPipeline();
}

View File

@ -0,0 +1,150 @@
/*
* (C) Copyright 2017-2019 OpenVidu (https://openvidu.io/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.openvidu.server.kurento.core;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import io.openvidu.server.cdr.CallDetailRecord;
import io.openvidu.server.config.InfoHandler;
import io.openvidu.server.kurento.endpoint.KmsEvent;
import io.openvidu.server.kurento.endpoint.KmsMediaEvent;
import io.openvidu.server.kurento.endpoint.MediaEndpoint;
public class KurentoParticipantEndpointConfig {
protected static final Logger log = LoggerFactory.getLogger(KurentoParticipantEndpointConfig.class);
@Autowired
protected InfoHandler infoHandler;
@Autowired
protected CallDetailRecord CDR;
public void addEndpointListeners(MediaEndpoint endpoint, String typeOfEndpoint) {
endpoint.getWebEndpoint().addMediaFlowInStateChangeListener(event -> {
String msg = "KMS event [MediaFlowInStateChange] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState() + " | pad: " + event.getPadName()
+ " | mediaType: " + event.getMediaType() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), event.getMediaType(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addMediaFlowOutStateChangeListener(event -> {
String msg = "KMS event [MediaFlowOutStateChange] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState() + " | pad: " + event.getPadName()
+ " | mediaType: " + event.getMediaType() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), event.getMediaType(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addIceGatheringDoneListener(event -> {
String msg = "KMS event [IceGatheringDone] -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addConnectionStateChangedListener(event -> {
String msg = "KMS event [ConnectionStateChanged]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | oldState: " + event.getOldState() + " | newState: " + event.getNewState()
+ " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addNewCandidatePairSelectedListener(event -> {
endpoint.selectedLocalIceCandidate = event.getCandidatePair().getLocalCandidate();
endpoint.selectedRemoteIceCandidate = event.getCandidatePair().getRemoteCandidate();
String msg = "KMS event [NewCandidatePairSelected]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | local: " + endpoint.selectedLocalIceCandidate + " | remote: "
+ endpoint.selectedRemoteIceCandidate + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getEndpoint().addMediaTranscodingStateChangeListener(event -> {
String msg = "KMS event [MediaTranscodingStateChange]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState().name() + " | mediaType: " + event.getMediaType()
+ " | binName: " + event.getBinName() + " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), event.getMediaType(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
});
endpoint.getWebEndpoint().addIceComponentStateChangeListener(event -> {
// if (!event.getState().equals(IceComponentState.READY)) {
String msg = "KMS event [IceComponentStateChange]: -> endpoint: " + endpoint.getEndpointName() + " ("
+ typeOfEndpoint + ") | state: " + event.getState().name() + " | componentId: "
+ event.getComponentId() + " | streamId: " + event.getStreamId() + " | timestamp: "
+ event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.info(msg);
// }
});
endpoint.getWebEndpoint().addErrorListener(event -> {
String msg = "KMS event [ERROR]: -> endpoint: " + endpoint.getEndpointName() + " (" + typeOfEndpoint
+ ") | errorCode: " + event.getErrorCode() + " | description: " + event.getDescription()
+ " | timestamp: " + event.getTimestamp();
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner().getSessionId(),
endpoint.getOwner().getParticipantPublicId(), endpoint.getEndpointName(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
log.error(msg);
});
}
public CallDetailRecord getCdr() {
return this.CDR;
}
}

View File

@ -52,6 +52,7 @@ public class KurentoSession extends Session {
private KurentoClient kurentoClient;
private KurentoSessionEventsHandler kurentoSessionHandler;
private KurentoParticipantEndpointConfig kurentoEndpointConfig;
private final ConcurrentHashMap<String, String> filterStates = new ConcurrentHashMap<>();
@ -62,11 +63,13 @@ public class KurentoSession extends Session {
public final ConcurrentHashMap<String, String> publishedStreamIds = new ConcurrentHashMap<>();
public KurentoSession(Session sessionNotActive, KurentoClient kurentoClient,
KurentoSessionEventsHandler kurentoSessionHandler, boolean destroyKurentoClient) {
KurentoSessionEventsHandler kurentoSessionHandler, KurentoParticipantEndpointConfig kurentoEndpointConfig,
boolean destroyKurentoClient) {
super(sessionNotActive);
this.kurentoClient = kurentoClient;
this.destroyKurentoClient = destroyKurentoClient;
this.kurentoSessionHandler = kurentoSessionHandler;
this.kurentoEndpointConfig = kurentoEndpointConfig;
log.debug("New SESSION instance with id '{}'", sessionId);
}
@ -75,8 +78,8 @@ public class KurentoSession extends Session {
checkClosed();
createPipeline();
KurentoParticipant kurentoParticipant = new KurentoParticipant(participant, this,
kurentoSessionHandler.getInfoHandler(), this.CDR, this.openviduConfig, this.recordingManager);
KurentoParticipant kurentoParticipant = new KurentoParticipant(participant, this, this.kurentoEndpointConfig,
this.openviduConfig, this.recordingManager);
participants.put(participant.getParticipantPrivateId(), kurentoParticipant);
filterStates.forEach((filterId, state) -> {
@ -87,7 +90,7 @@ public class KurentoSession extends Session {
log.info("SESSION {}: Added participant {}", sessionId, participant);
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(participant.getParticipantPublicId())) {
CDR.recordParticipantJoined(participant, sessionId);
kurentoEndpointConfig.getCdr().recordParticipantJoined(participant, sessionId);
}
}

View File

@ -68,6 +68,9 @@ public class KurentoSessionManager extends SessionManager {
@Autowired
private KurentoSessionEventsHandler kurentoSessionEventsHandler;
@Autowired
private KurentoParticipantEndpointConfig kurentoEndpointConfig;
private KurentoClient kurentoClient;
@Override
@ -89,7 +92,7 @@ public class KurentoSessionManager extends SessionManager {
new SessionProperties.Builder().mediaMode(MediaMode.ROUTED)
.recordingMode(RecordingMode.ALWAYS)
.defaultRecordingLayout(RecordingLayout.BEST_FIT).build(),
CDR, openviduConfig, recordingManager);
openviduConfig, recordingManager);
}
createSession(sessionNotActive, kcSessionInfo);
@ -505,7 +508,7 @@ public class KurentoSessionManager extends SessionManager {
}
this.kurentoClient = kcProvider.getKurentoClient(kcSessionInfo);
session = new KurentoSession(sessionNotActive, kurentoClient, kurentoSessionEventsHandler,
kcProvider.destroyWhenUnused());
kurentoEndpointConfig, kcProvider.destroyWhenUnused());
KurentoSession oldSession = (KurentoSession) sessions.putIfAbsent(sessionId, session);
if (oldSession != null) {