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,
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

View File

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

View File

@ -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);

View File

@ -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<Void>() {
@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<IceCandidate> 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<IceCandidate> 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();
}

View File

@ -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;
}
}

View File

@ -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;
}
}