openvidu-server: KMS events small refactoring

pull/255/head
pabloFuente 2019-03-07 12:04:46 +01:00
parent 3641d90292
commit d22b3b0f5e
3 changed files with 29 additions and 29 deletions

View File

@ -43,9 +43,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -56,9 +55,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -68,8 +66,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -80,8 +78,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -94,8 +92,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -106,9 +104,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsMediaEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
event.getMediaType(), endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -121,8 +118,8 @@ public class KurentoParticipantEndpointConfig {
+ 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());
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);
@ -134,8 +131,8 @@ public class KurentoParticipantEndpointConfig {
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());
KmsEvent kmsEvent = new KmsEvent(event, endpoint.getOwner(), endpoint.getEndpointName(),
endpoint.createdAt());
endpoint.kmsEvents.add(kmsEvent);
this.CDR.log(kmsEvent);
this.infoHandler.sendInfo(msg);

View File

@ -22,19 +22,19 @@ import org.kurento.jsonrpc.JsonUtils;
import com.google.gson.JsonObject;
import io.openvidu.server.core.Participant;
public class KmsEvent {
long timestamp;
long msSinceCreation;
String sessionId;
String connectionId;
Participant participant;
String endpoint;
RaiseBaseEvent event;
public KmsEvent(RaiseBaseEvent event, String sessionId, String connectionId, String endpointName, long createdAt) {
public KmsEvent(RaiseBaseEvent event, Participant participant, String endpointName, long createdAt) {
this.event = event;
this.sessionId = sessionId;
this.connectionId = connectionId;
this.participant = participant;
this.endpoint = endpointName;
this.timestamp = System.currentTimeMillis(); // TODO: Change to event.getTimestampMillis()
this.msSinceCreation = this.timestamp - createdAt;
@ -46,8 +46,9 @@ public class KmsEvent {
JsonObject json = JsonUtils.toJsonObject(event);
json.remove("tags");
json.addProperty("timestamp", timestamp);
json.addProperty("session", sessionId);
json.addProperty("connection", connectionId);
json.addProperty("session", participant.getSessionId());
json.addProperty("user", participant.getFinalUserId());
json.addProperty("connection", participant.getParticipantPublicId());
json.addProperty("endpoint", this.endpoint);
json.addProperty("msSinceEndpointCreation", msSinceCreation);
return json;

View File

@ -22,13 +22,15 @@ import org.kurento.client.MediaType;
import com.google.gson.JsonObject;
import io.openvidu.server.core.Participant;
public class KmsMediaEvent extends KmsEvent {
MediaType mediaType;
public KmsMediaEvent(MediaEvent event, String sessionId, String connectionId, String endpointName,
MediaType mediaType, long createdAt) {
super(event, sessionId, connectionId, endpointName, createdAt);
public KmsMediaEvent(MediaEvent event, Participant participant, String endpointName, MediaType mediaType,
long createdAt) {
super(event, participant, endpointName, createdAt);
this.mediaType = mediaType;
}