Merge branch 'master' of github.com:OpenVidu/openvidu

pull/437/head
OscarSotoSanchez 2020-04-16 10:41:36 +02:00
commit 2ed403cae5
2 changed files with 81 additions and 13 deletions

View File

@ -18,7 +18,9 @@
package io.openvidu.server.config; package io.openvidu.server.config;
import java.io.File; import java.io.File;
import java.net.Inet4Address;
import java.net.Inet6Address; import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -429,8 +431,6 @@ public class OpenviduConfig {
protected void checkConfigurationProperties() { protected void checkConfigurationProperties() {
serverPort = getValue("server.port"); serverPort = getValue("server.port");
coturnRedisDbname = getValue("coturn.redis.dbname"); coturnRedisDbname = getValue("coturn.redis.dbname");
@ -490,7 +490,8 @@ public class OpenviduConfig {
} }
private void checkCoturnIp() { private void checkCoturnIp() {
coturnIp = getValue("coturn.ip"); String property = "coturn.ip";
coturnIp = asOptionalIPv4OrIPv6(property);
if (coturnIp == null || this.coturnIp.isEmpty()) { if (coturnIp == null || this.coturnIp.isEmpty()) {
try { try {
@ -741,6 +742,26 @@ public class OpenviduConfig {
return inetAddress; return inetAddress;
} }
protected String asOptionalIPv4OrIPv6(String property) {
String ip = getValue(property);
if (ip != null && !ip.isEmpty()) {
boolean isIP;
try {
final InetAddress inet = InetAddress.getByName(ip);
isIP = inet instanceof Inet4Address || inet instanceof Inet6Address;
if (isIP) {
ip = inet.getHostAddress();
}
} catch (final UnknownHostException e) {
isIP = false;
}
if (!isIP) {
addError(property, "Is not a valid IP Address (IPv4 or IPv6)");
}
}
return ip;
}
protected String asFileSystemPath(String property) { protected String asFileSystemPath(String property) {
try { try {
String stringPath = this.asNonEmptyString(property); String stringPath = this.asNonEmptyString(property);

View File

@ -284,14 +284,61 @@ public abstract class MediaEndpoint {
public void onSuccess(WebRtcEndpoint result) throws Exception { public void onSuccess(WebRtcEndpoint result) throws Exception {
webEndpoint = result; webEndpoint = result;
webEndpoint.setMaxVideoRecvBandwidth(maxRecvKbps); if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty()
webEndpoint.setMinVideoRecvBandwidth(minRecvKbps); && !openviduConfig.getCoturnIp().equals("localhost")) {
webEndpoint.setMaxVideoSendBandwidth(maxSendKbps); webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp());
webEndpoint.setMinVideoSendBandwidth(minSendKbps); webEndpoint.setStunServerPort(3478);
}
endpointLatch.countDown(); endpointLatch.countDown();
log.trace("EP {}: Created a new WebRtcEndpoint", endpointName); log.trace("EP {}: Created a new WebRtcEndpoint", endpointName);
endpointSubscription = registerElemErrListener(webEndpoint); endpointSubscription = registerElemErrListener(webEndpoint);
// This can be done after unlocking latch. Not necessary to wait
webEndpoint.setMaxVideoRecvBandwidth(maxRecvKbps, new Continuation<Void>() {
@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<Void>() {
@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<Void>() {
@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<Void>() {
@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 @Override