mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: protect LocalSDP retrieval from KMS. Gathered candidates
parent
f870cbdfa9
commit
d58201d550
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package io.openvidu.server.kurento.endpoint;
|
package io.openvidu.server.kurento.endpoint;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -42,6 +43,7 @@ import org.kurento.client.internal.server.KurentoServerException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonNull;
|
import com.google.gson.JsonNull;
|
||||||
|
@ -90,6 +92,7 @@ public abstract class MediaEndpoint {
|
||||||
private ListenerSubscription endpointSubscription = null;
|
private ListenerSubscription endpointSubscription = null;
|
||||||
|
|
||||||
private final List<IceCandidate> receivedCandidateList = new LinkedList<IceCandidate>();
|
private final List<IceCandidate> receivedCandidateList = new LinkedList<IceCandidate>();
|
||||||
|
private final List<IceCandidate> generatedCandidateList = new LinkedList<IceCandidate>();
|
||||||
private LinkedList<IceCandidate> candidates = new LinkedList<IceCandidate>();
|
private LinkedList<IceCandidate> candidates = new LinkedList<IceCandidate>();
|
||||||
|
|
||||||
public String selectedLocalIceCandidate;
|
public String selectedLocalIceCandidate;
|
||||||
|
@ -529,8 +532,10 @@ public abstract class MediaEndpoint {
|
||||||
throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
|
throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
|
||||||
"Can't register event listener for null WebRtcEndpoint (ep: " + endpointName + ")");
|
"Can't register event listener for null WebRtcEndpoint (ep: " + endpointName + ")");
|
||||||
}
|
}
|
||||||
webEndpoint.addOnIceCandidateListener(event -> {
|
webEndpoint.addIceCandidateFoundListener(event -> {
|
||||||
owner.sendIceCandidate(senderPublicId, endpointName, event.getCandidate());
|
final IceCandidate candidate = event.getCandidate();
|
||||||
|
generatedCandidateList.add(candidate);
|
||||||
|
owner.sendIceCandidate(senderPublicId, endpointName, candidate);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,9 +602,27 @@ public abstract class MediaEndpoint {
|
||||||
this.streamId, e.getMessage());
|
this.streamId, e.getMessage());
|
||||||
json.add("remoteSdp", JsonNull.INSTANCE);
|
json.add("remoteSdp", JsonNull.INSTANCE);
|
||||||
}
|
}
|
||||||
json.addProperty("localSdp", ((SdpEndpoint) this.getEndpoint()).getLocalSessionDescriptor());
|
try {
|
||||||
|
json.addProperty("localSdp", ((SdpEndpoint) this.getEndpoint()).getLocalSessionDescriptor());
|
||||||
|
} catch (KurentoServerException e) {
|
||||||
|
log.error("Error retrieving local SDP for endpoint {} of stream {}: {}", this.endpointName,
|
||||||
|
this.streamId, e.getMessage());
|
||||||
|
json.add("localSdp", JsonNull.INSTANCE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
json.add("receivedCandidates", new GsonBuilder().create().toJsonTree(this.receivedCandidateList));
|
Gson gson = new GsonBuilder().create();
|
||||||
|
JsonArray receivedCandidates = new JsonArray();
|
||||||
|
Iterator<IceCandidate> it = this.receivedCandidateList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
receivedCandidates.add(gson.toJsonTree(it.next()));
|
||||||
|
}
|
||||||
|
json.add("receivedCandidates", receivedCandidates);
|
||||||
|
JsonArray generatedCandidates = new JsonArray();
|
||||||
|
it = this.receivedCandidateList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
generatedCandidates.add(gson.toJsonTree(it.next()));
|
||||||
|
}
|
||||||
|
json.add("generatedCandidates", generatedCandidates);
|
||||||
json.addProperty("localCandidate", this.selectedLocalIceCandidate);
|
json.addProperty("localCandidate", this.selectedLocalIceCandidate);
|
||||||
json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate);
|
json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue