mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: Fix OPENVIDU_WEBRTC_ICE_SERVERS not being used when customIceServer is an empty list but not null
parent
90d13cedc4
commit
72b95741ca
|
@ -21,6 +21,7 @@ import java.net.MalformedURLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -844,18 +845,29 @@ public class SessionRestController {
|
|||
|
||||
ConnectionType type = ConnectionProperties.fromJson(params).build().getType();
|
||||
|
||||
// Check if custom ice servers are defined in params
|
||||
boolean definedCustomIceServers = false;
|
||||
|
||||
if (ConnectionType.WEBRTC.equals(type)) {
|
||||
if (params != null && params.get("customIceServers") == null
|
||||
&& !openviduConfig.getWebrtcIceServersBuilders().isEmpty()) {
|
||||
// If not defined in Connection, check if defined in OpenVidu global config
|
||||
for (IceServerProperties.Builder iceServerPropertiesBuilder : openviduConfig
|
||||
.getWebrtcIceServersBuilders()) {
|
||||
IceServerProperties.Builder configIceBuilder = iceServerPropertiesBuilder.clone();
|
||||
builder.addCustomIceServer(configIceBuilder.build());
|
||||
if (params != null) {
|
||||
JsonArray customIceServersJsonArray = null;
|
||||
if (params.get("customIceServers") != null) {
|
||||
customIceServersJsonArray = new Gson().toJsonTree(params.get("customIceServers"), List.class)
|
||||
.getAsJsonArray();
|
||||
definedCustomIceServers = customIceServersJsonArray.size() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!definedCustomIceServers && !openviduConfig.getWebrtcIceServersBuilders().isEmpty()) {
|
||||
// If not defined in Connection, check if defined in OpenVidu global config
|
||||
for (IceServerProperties.Builder iceServerPropertiesBuilder : openviduConfig
|
||||
.getWebrtcIceServersBuilders()) {
|
||||
IceServerProperties.Builder configIceBuilder = iceServerPropertiesBuilder.clone();
|
||||
builder.addCustomIceServer(configIceBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue