openvidu-server: log ICE candidates

pull/621/head
pabloFuente 2021-04-13 17:58:16 +02:00
parent 665f3db149
commit 69d7912e58
6 changed files with 48 additions and 12 deletions

View File

@ -506,8 +506,8 @@ export class OpenVidu {
events: publisherExtended.events, events: publisherExtended.events,
localCandidate: publisherExtended.localCandidate, localCandidate: publisherExtended.localCandidate,
remoteCandidate: publisherExtended.remoteCandidate, remoteCandidate: publisherExtended.remoteCandidate,
receivedCandidates: publisherExtended.receivedCandidates, clientIceCandidates: publisherExtended.clientIceCandidates,
gatheredCandidates: publisherExtended.gatheredCandidates, serverIceCandidates: publisherExtended.serverIceCandidates,
webrtcEndpointName: publisherExtended.webrtcEndpointName, webrtcEndpointName: publisherExtended.webrtcEndpointName,
localSdp: publisherExtended.localSdp, localSdp: publisherExtended.localSdp,
remoteSdp: publisherExtended.remoteSdp remoteSdp: publisherExtended.remoteSdp
@ -532,8 +532,8 @@ export class OpenVidu {
events: subscriberExtended.events, events: subscriberExtended.events,
localCandidate: subscriberExtended.localCandidate, localCandidate: subscriberExtended.localCandidate,
remoteCandidate: subscriberExtended.remoteCandidate, remoteCandidate: subscriberExtended.remoteCandidate,
receivedCandidates: subscriberExtended.receivedCandidates, clientIceCandidates: subscriberExtended.clientIceCandidates,
gatheredCandidates: subscriberExtended.gatheredCandidates, serverIceCandidates: subscriberExtended.serverIceCandidates,
webrtcEndpointName: subscriberExtended.webrtcEndpointName, webrtcEndpointName: subscriberExtended.webrtcEndpointName,
localSdp: subscriberExtended.localSdp, localSdp: subscriberExtended.localSdp,
remoteSdp: subscriberExtended.remoteSdp remoteSdp: subscriberExtended.remoteSdp

View File

@ -15,7 +15,7 @@ public class WebrtcDebugEvent {
} }
public enum WebrtcDebugEventType { public enum WebrtcDebugEventType {
sdpOffer, sdpOfferMunged, sdpAnswer sdpOffer, sdpOfferMunged, sdpAnswer, iceCandidate
} }
private Participant participant; private Participant participant;

View File

@ -48,6 +48,7 @@ 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.OpenViduRole; import io.openvidu.java.client.OpenViduRole;
import io.openvidu.server.cdr.WebrtcDebugEvent;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.EndReason; import io.openvidu.server.core.EndReason;
import io.openvidu.server.core.IdentifierPrefixes; import io.openvidu.server.core.IdentifierPrefixes;
@ -726,6 +727,10 @@ public class KurentoParticipant extends Participant {
this.publisherLatch = new CountDownLatch(1); this.publisherLatch = new CountDownLatch(1);
} }
public void logIceCandidate(WebrtcDebugEvent event) {
endpointConfig.getCdr().log(event);
}
@Override @Override
public JsonObject toJson() { public JsonObject toJson() {
return this.sharedJson(MediaEndpoint::toJson); return this.sharedJson(MediaEndpoint::toJson);

View File

@ -55,6 +55,10 @@ import com.google.gson.JsonObject;
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.java.client.KurentoOptions; 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.config.OpenviduConfig;
import io.openvidu.server.core.Participant; import io.openvidu.server.core.Participant;
import io.openvidu.server.kurento.core.KurentoMediaOptions; import io.openvidu.server.kurento.core.KurentoMediaOptions;
@ -106,6 +110,8 @@ public abstract class MediaEndpoint {
public AtomicInteger statsNotFoundErrors = new AtomicInteger(0); public AtomicInteger statsNotFoundErrors = new AtomicInteger(0);
public AtomicBoolean cancelStatsLoop = new AtomicBoolean(false); 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. * Constructor to set the owner, the endpoint's name and the media pipeline.
* *
@ -558,7 +564,12 @@ public abstract class MediaEndpoint {
} }
webEndpoint.addIceCandidateFoundListener(event -> { webEndpoint.addIceCandidateFoundListener(event -> {
final IceCandidate candidate = event.getCandidate(); final IceCandidate candidate = event.getCandidate();
gatheredCandidateList.add(candidate); 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); owner.sendIceCandidate(senderPublicId, endpointName, candidate);
}); });
} }
@ -593,7 +604,12 @@ public abstract class MediaEndpoint {
throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
"Can't add existing ICE candidates to null WebRtcEndpoint (ep: " + endpointName + ")"); "Can't add existing ICE candidates to null WebRtcEndpoint (ep: " + endpointName + ")");
} }
this.receivedCandidateList.add(candidate); 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<Void>() { this.webEndpoint.addIceCandidate(candidate, new Continuation<Void>() {
@Override @Override
public void onSuccess(Void result) throws Exception { public void onSuccess(Void result) throws Exception {
@ -634,19 +650,18 @@ public abstract class MediaEndpoint {
json.add("localSdp", JsonNull.INSTANCE); json.add("localSdp", JsonNull.INSTANCE);
} }
} }
Gson gson = new GsonBuilder().create(); JsonArray clientIceCandidates = new JsonArray();
JsonArray receivedCandidates = new JsonArray();
Iterator<IceCandidate> it1 = this.receivedCandidateList.iterator(); Iterator<IceCandidate> it1 = this.receivedCandidateList.iterator();
while (it1 != null && it1.hasNext()) { while (it1 != null && it1.hasNext()) {
receivedCandidates.add(gson.toJsonTree(it1.next())); clientIceCandidates.add(gson.toJsonTree(it1.next()));
} }
json.add("receivedCandidates", receivedCandidates); json.add("clientIceCandidates", clientIceCandidates);
JsonArray gatheredCandidates = new JsonArray(); JsonArray serverIceCandidates = new JsonArray();
Iterator<IceCandidate> it2 = this.gatheredCandidateList.iterator(); Iterator<IceCandidate> it2 = this.gatheredCandidateList.iterator();
while (it2 != null && it2.hasNext()) { 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("localCandidate", this.selectedLocalIceCandidate);
json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate); json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate);
@ -666,4 +681,7 @@ public abstract class MediaEndpoint {
return json; return json;
} }
protected abstract WebrtcDebugEventOperation getWebrtcDebugOperation();
} }

View File

@ -46,6 +46,7 @@ import com.google.gson.JsonObject;
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.server.cdr.WebrtcDebugEvent.WebrtcDebugEventOperation;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.MediaOptions; import io.openvidu.server.core.MediaOptions;
import io.openvidu.server.kurento.core.KurentoMediaOptions; import io.openvidu.server.kurento.core.KurentoMediaOptions;
@ -592,4 +593,9 @@ public class PublisherEndpoint extends MediaEndpoint {
+ this.filterListeners.toString() + ", subscribers: " + this.subscribersToFilterEvents.toString() + "}"; + this.filterListeners.toString() + ", subscribers: " + this.subscribersToFilterEvents.toString() + "}";
} }
@Override
protected WebrtcDebugEventOperation getWebrtcDebugOperation() {
return WebrtcDebugEventOperation.publish;
}
} }

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.openvidu.server.cdr.WebrtcDebugEvent.WebrtcDebugEventOperation;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.kurento.core.KurentoParticipant; import io.openvidu.server.kurento.core.KurentoParticipant;
@ -103,4 +104,10 @@ public class SubscriberEndpoint extends MediaEndpoint {
} }
return json; return json;
} }
@Override
protected WebrtcDebugEventOperation getWebrtcDebugOperation() {
return WebrtcDebugEventOperation.subscribe;
}
} }