diff --git a/openvidu-node-client/src/OpenVidu.ts b/openvidu-node-client/src/OpenVidu.ts index b852142d..28d59d32 100644 --- a/openvidu-node-client/src/OpenVidu.ts +++ b/openvidu-node-client/src/OpenVidu.ts @@ -506,8 +506,8 @@ export class OpenVidu { events: publisherExtended.events, localCandidate: publisherExtended.localCandidate, remoteCandidate: publisherExtended.remoteCandidate, - receivedCandidates: publisherExtended.receivedCandidates, - gatheredCandidates: publisherExtended.gatheredCandidates, + clientIceCandidates: publisherExtended.clientIceCandidates, + serverIceCandidates: publisherExtended.serverIceCandidates, webrtcEndpointName: publisherExtended.webrtcEndpointName, localSdp: publisherExtended.localSdp, remoteSdp: publisherExtended.remoteSdp @@ -532,8 +532,8 @@ export class OpenVidu { events: subscriberExtended.events, localCandidate: subscriberExtended.localCandidate, remoteCandidate: subscriberExtended.remoteCandidate, - receivedCandidates: subscriberExtended.receivedCandidates, - gatheredCandidates: subscriberExtended.gatheredCandidates, + clientIceCandidates: subscriberExtended.clientIceCandidates, + serverIceCandidates: subscriberExtended.serverIceCandidates, webrtcEndpointName: subscriberExtended.webrtcEndpointName, localSdp: subscriberExtended.localSdp, remoteSdp: subscriberExtended.remoteSdp diff --git a/openvidu-server/src/main/java/io/openvidu/server/cdr/WebrtcDebugEvent.java b/openvidu-server/src/main/java/io/openvidu/server/cdr/WebrtcDebugEvent.java index d0b5512d..8a0aeb25 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/cdr/WebrtcDebugEvent.java +++ b/openvidu-server/src/main/java/io/openvidu/server/cdr/WebrtcDebugEvent.java @@ -15,7 +15,7 @@ public class WebrtcDebugEvent { } public enum WebrtcDebugEventType { - sdpOffer, sdpOfferMunged, sdpAnswer + sdpOffer, sdpOfferMunged, sdpAnswer, iceCandidate } private Participant participant; diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java index a4f33168..7a9b45e1 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java @@ -48,6 +48,7 @@ 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.WebrtcDebugEvent; import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.core.EndReason; import io.openvidu.server.core.IdentifierPrefixes; @@ -726,6 +727,10 @@ public class KurentoParticipant extends Participant { this.publisherLatch = new CountDownLatch(1); } + public void logIceCandidate(WebrtcDebugEvent event) { + endpointConfig.getCdr().log(event); + } + @Override public JsonObject toJson() { return this.sharedJson(MediaEndpoint::toJson); diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java index 0cb62a7a..edb3312d 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java @@ -55,6 +55,10 @@ import com.google.gson.JsonObject; import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException.Code; import io.openvidu.java.client.KurentoOptions; +import io.openvidu.server.cdr.WebrtcDebugEvent; +import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventIssuer; +import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventOperation; +import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventType; import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.core.Participant; import io.openvidu.server.kurento.core.KurentoMediaOptions; @@ -106,6 +110,8 @@ public abstract class MediaEndpoint { public AtomicInteger statsNotFoundErrors = new AtomicInteger(0); public AtomicBoolean cancelStatsLoop = new AtomicBoolean(false); + private Gson gson = new GsonBuilder().create(); + /** * Constructor to set the owner, the endpoint's name and the media pipeline. * @@ -558,7 +564,12 @@ public abstract class MediaEndpoint { } webEndpoint.addIceCandidateFoundListener(event -> { final IceCandidate candidate = event.getCandidate(); + gatheredCandidateList.add(candidate); + this.owner.logIceCandidate(new WebrtcDebugEvent(this.owner, this.streamId, WebrtcDebugEventIssuer.server, + this.getWebrtcDebugOperation(), WebrtcDebugEventType.iceCandidate, + gson.toJsonTree(candidate).toString())); + owner.sendIceCandidate(senderPublicId, endpointName, candidate); }); } @@ -593,7 +604,12 @@ public abstract class MediaEndpoint { throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Can't add existing ICE candidates to null WebRtcEndpoint (ep: " + endpointName + ")"); } + this.receivedCandidateList.add(candidate); + this.owner.logIceCandidate(new WebrtcDebugEvent(this.owner, this.streamId, WebrtcDebugEventIssuer.client, + this.getWebrtcDebugOperation(), WebrtcDebugEventType.iceCandidate, + gson.toJsonTree(candidate).toString())); + this.webEndpoint.addIceCandidate(candidate, new Continuation() { @Override public void onSuccess(Void result) throws Exception { @@ -634,19 +650,18 @@ public abstract class MediaEndpoint { json.add("localSdp", JsonNull.INSTANCE); } } - Gson gson = new GsonBuilder().create(); - JsonArray receivedCandidates = new JsonArray(); + JsonArray clientIceCandidates = new JsonArray(); Iterator it1 = this.receivedCandidateList.iterator(); while (it1 != null && it1.hasNext()) { - receivedCandidates.add(gson.toJsonTree(it1.next())); + clientIceCandidates.add(gson.toJsonTree(it1.next())); } - json.add("receivedCandidates", receivedCandidates); - JsonArray gatheredCandidates = new JsonArray(); + json.add("clientIceCandidates", clientIceCandidates); + JsonArray serverIceCandidates = new JsonArray(); Iterator it2 = this.gatheredCandidateList.iterator(); while (it2 != null && it2.hasNext()) { - gatheredCandidates.add(gson.toJsonTree(it2.next())); + serverIceCandidates.add(gson.toJsonTree(it2.next())); } - json.add("gatheredCandidates", gatheredCandidates); + json.add("serverIceCandidates", serverIceCandidates); json.addProperty("localCandidate", this.selectedLocalIceCandidate); json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate); @@ -666,4 +681,7 @@ public abstract class MediaEndpoint { return json; } + + protected abstract WebrtcDebugEventOperation getWebrtcDebugOperation(); + } diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java index e1281815..7b5ab029 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java @@ -46,6 +46,7 @@ import com.google.gson.JsonObject; import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException.Code; +import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventOperation; import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.core.MediaOptions; import io.openvidu.server.kurento.core.KurentoMediaOptions; @@ -592,4 +593,9 @@ public class PublisherEndpoint extends MediaEndpoint { + this.filterListeners.toString() + ", subscribers: " + this.subscribersToFilterEvents.toString() + "}"; } + @Override + protected WebrtcDebugEventOperation getWebrtcDebugOperation() { + return WebrtcDebugEventOperation.publish; + } + } diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java index da559339..1a159ada 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java @@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventOperation; import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.kurento.core.KurentoParticipant; @@ -103,4 +104,10 @@ public class SubscriberEndpoint extends MediaEndpoint { } return json; } + + @Override + protected WebrtcDebugEventOperation getWebrtcDebugOperation() { + return WebrtcDebugEventOperation.subscribe; + } + }