From 0d426feb22c8ea0ab82f55447306e6fac3e83416 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 15 Apr 2020 19:32:29 +0200 Subject: [PATCH] openvidu-server: configure stun server for each MediaEndpoint --- .../kurento/endpoint/MediaEndpoint.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) 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 eab45ca5..e3fcf8f8 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 @@ -284,14 +284,61 @@ public abstract class MediaEndpoint { public void onSuccess(WebRtcEndpoint result) throws Exception { webEndpoint = result; - webEndpoint.setMaxVideoRecvBandwidth(maxRecvKbps); - webEndpoint.setMinVideoRecvBandwidth(minRecvKbps); - webEndpoint.setMaxVideoSendBandwidth(maxSendKbps); - webEndpoint.setMinVideoSendBandwidth(minSendKbps); + if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty() + && !openviduConfig.getCoturnIp().equals("localhost")) { + webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp()); + webEndpoint.setStunServerPort(3478); + } endpointLatch.countDown(); log.trace("EP {}: Created a new WebRtcEndpoint", endpointName); endpointSubscription = registerElemErrListener(webEndpoint); + + // This can be done after unlocking latch. Not necessary to wait + webEndpoint.setMaxVideoRecvBandwidth(maxRecvKbps, new Continuation() { + @Override + public void onSuccess(Void result) throws Exception { + } + + @Override + public void onError(Throwable cause) throws Exception { + log.error("Error setting max video receive bandwidth for endpoint {}: {}", endpointName, + cause.getMessage()); + } + }); + webEndpoint.setMinVideoRecvBandwidth(minRecvKbps, new Continuation() { + @Override + public void onSuccess(Void result) throws Exception { + } + + @Override + public void onError(Throwable cause) throws Exception { + log.error("Error setting min video receive bandwidth for endpoint {}: {}", endpointName, + cause.getMessage()); + } + }); + webEndpoint.setMaxVideoSendBandwidth(maxSendKbps, new Continuation() { + @Override + public void onSuccess(Void result) throws Exception { + } + + @Override + public void onError(Throwable cause) throws Exception { + log.error("Error setting max video send bandwidth for endpoint {}: {}", endpointName, + cause.getMessage()); + } + }); + webEndpoint.setMinVideoSendBandwidth(minSendKbps, new Continuation() { + @Override + public void onSuccess(Void result) throws Exception { + } + + @Override + public void onError(Throwable cause) throws Exception { + log.error("Error setting min video send bandwidth for endpoint {}: {}", endpointName, + cause.getMessage()); + } + }); } @Override