mirror of https://github.com/OpenVidu/openvidu.git
Merge branch 'master' of github.com:OpenVidu/openvidu
commit
2ed403cae5
|
@ -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;
|
||||||
|
@ -83,7 +85,7 @@ public class OpenviduConfig {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Error [property=" + property + ", value=" + value + ", message=" + message + "]";
|
return "Error [property=" + property + ", value=" + value + ", message=" + message + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(OpenviduConfig.class);
|
private static final Logger log = LoggerFactory.getLogger(OpenviduConfig.class);
|
||||||
|
@ -287,13 +289,13 @@ public class OpenviduConfig {
|
||||||
public int getSessionGarbageThreshold() {
|
public int getSessionGarbageThreshold() {
|
||||||
return openviduSessionsGarbageThreshold;
|
return openviduSessionsGarbageThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDotenvPath() {
|
public String getDotenvPath() {
|
||||||
return dotenvPath;
|
return dotenvPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derived properties methods
|
// Derived properties methods
|
||||||
|
|
||||||
public String getSpringProfile() {
|
public String getSpringProfile() {
|
||||||
return springProfile;
|
return springProfile;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +343,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties management methods
|
// Properties management methods
|
||||||
|
|
||||||
public OpenviduConfig deriveWithAdditionalPropertiesSource(Map<String, ?> propertiesSource) {
|
public OpenviduConfig deriveWithAdditionalPropertiesSource(Map<String, ?> propertiesSource) {
|
||||||
OpenviduConfig config = newOpenviduConfig();
|
OpenviduConfig config = newOpenviduConfig();
|
||||||
config.propertiesSource = propertiesSource;
|
config.propertiesSource = propertiesSource;
|
||||||
|
@ -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");
|
||||||
|
@ -460,7 +460,7 @@ public class OpenviduConfig {
|
||||||
openviduStreamsVideoMinRecvBandwidth = asNonNegativeInteger("openvidu.streams.video.min-recv-bandwidth");
|
openviduStreamsVideoMinRecvBandwidth = asNonNegativeInteger("openvidu.streams.video.min-recv-bandwidth");
|
||||||
openviduStreamsVideoMaxSendBandwidth = asNonNegativeInteger("openvidu.streams.video.max-send-bandwidth");
|
openviduStreamsVideoMaxSendBandwidth = asNonNegativeInteger("openvidu.streams.video.max-send-bandwidth");
|
||||||
openviduStreamsVideoMinSendBandwidth = asNonNegativeInteger("openvidu.streams.video.min-send-bandwidth");
|
openviduStreamsVideoMinSendBandwidth = asNonNegativeInteger("openvidu.streams.video.min-send-bandwidth");
|
||||||
|
|
||||||
openviduSessionsGarbageInterval = asNonNegativeInteger("openvidu.sessions.garbage.interval");
|
openviduSessionsGarbageInterval = asNonNegativeInteger("openvidu.sessions.garbage.interval");
|
||||||
openviduSessionsGarbageThreshold = asNonNegativeInteger("openvidu.sessions.garbage.threshold");
|
openviduSessionsGarbageThreshold = asNonNegativeInteger("openvidu.sessions.garbage.threshold");
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ public class OpenviduConfig {
|
||||||
checkWebhook();
|
checkWebhook();
|
||||||
|
|
||||||
checkCertificateType();
|
checkCertificateType();
|
||||||
|
|
||||||
dotenvPath = getValue("dotenv.path");
|
dotenvPath = getValue("dotenv.path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue