mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: common KmsEvent toJson
parent
16ccaae268
commit
a2a7828c9d
|
@ -17,9 +17,8 @@
|
||||||
|
|
||||||
package io.openvidu.server.kurento.endpoint;
|
package io.openvidu.server.kurento.endpoint;
|
||||||
|
|
||||||
import org.kurento.client.ErrorEvent;
|
|
||||||
import org.kurento.client.MediaEvent;
|
|
||||||
import org.kurento.client.RaiseBaseEvent;
|
import org.kurento.client.RaiseBaseEvent;
|
||||||
|
import org.kurento.jsonrpc.JsonUtils;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
@ -44,22 +43,12 @@ public class KmsEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonObject toJson() {
|
public JsonObject toJson() {
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = JsonUtils.toJsonObject(event);
|
||||||
|
json.remove("tags");
|
||||||
if (event instanceof ErrorEvent) {
|
json.addProperty("timestamp", timestamp);
|
||||||
ErrorEvent errorEvent = (ErrorEvent) event;
|
|
||||||
json.addProperty("eventType", errorEvent.getType());
|
|
||||||
json.addProperty("errorCode", errorEvent.getErrorCode());
|
|
||||||
json.addProperty("description", errorEvent.getDescription());
|
|
||||||
} else {
|
|
||||||
MediaEvent mediaEvent = (MediaEvent) event;
|
|
||||||
json.addProperty("eventType", mediaEvent.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
json.addProperty("session", sessionId);
|
json.addProperty("session", sessionId);
|
||||||
json.addProperty("connection", connectionId);
|
json.addProperty("connection", connectionId);
|
||||||
json.addProperty("endpoint", this.endpoint);
|
json.addProperty("endpoint", this.endpoint);
|
||||||
json.addProperty("timestamp", timestamp);
|
|
||||||
json.addProperty("msSinceEndpointCreation", msSinceCreation);
|
json.addProperty("msSinceEndpointCreation", msSinceCreation);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.kurento.client.OnIceCandidateEvent;
|
||||||
import org.kurento.client.RtpEndpoint;
|
import org.kurento.client.RtpEndpoint;
|
||||||
import org.kurento.client.SdpEndpoint;
|
import org.kurento.client.SdpEndpoint;
|
||||||
import org.kurento.client.WebRtcEndpoint;
|
import org.kurento.client.WebRtcEndpoint;
|
||||||
import org.kurento.jsonrpc.JsonUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -501,14 +500,13 @@ public abstract class MediaEndpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray jsonArray = new JsonArray();
|
JsonArray jsonArray = new JsonArray();
|
||||||
for (KmsEvent event : this.kmsEvents) {
|
this.kmsEvents.forEach(ev -> {
|
||||||
JsonObject jsonKmsEvent = JsonUtils.toJsonObject(event.event);
|
JsonObject j = ev.toJson();
|
||||||
// Set custom more precise timestamp
|
j.remove("session");
|
||||||
jsonKmsEvent.addProperty("timestamp", event.timestamp);
|
j.remove("connection");
|
||||||
// Set milliseconds since the Publisher or Subscriber started transmitting media
|
j.remove("endpoint");
|
||||||
jsonKmsEvent.addProperty("msSinceCreation", event.msSinceCreation);
|
jsonArray.add(j);
|
||||||
jsonArray.add(jsonKmsEvent);
|
});
|
||||||
}
|
|
||||||
json.add("events", jsonArray);
|
json.add("events", jsonArray);
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
|
|
Loading…
Reference in New Issue