mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: Add customIceServers to REST post of connection
parent
d7eae78372
commit
ad778ff0d3
|
@ -26,6 +26,7 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.openvidu.java.client.*;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -51,17 +52,7 @@ import com.google.gson.JsonParser;
|
|||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.ConnectionProperties;
|
||||
import io.openvidu.java.client.ConnectionType;
|
||||
import io.openvidu.java.client.KurentoOptions;
|
||||
import io.openvidu.java.client.MediaMode;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording.OutputMode;
|
||||
import io.openvidu.java.client.RecordingLayout;
|
||||
import io.openvidu.java.client.RecordingMode;
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.java.client.VideoCodec;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.IdentifierPrefixes;
|
||||
|
@ -914,6 +905,36 @@ public class SessionRestController {
|
|||
}
|
||||
}
|
||||
|
||||
// Custom Ice Servers
|
||||
JsonArray customIceServersJsonArray = null;
|
||||
if (params.get("customIceServers") != null) {
|
||||
try {
|
||||
customIceServersJsonArray = new Gson().toJsonTree(params.get("customIceServers"), Map.class)
|
||||
.getAsJsonArray();
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Error in parameter 'customIceServersJson'. It is not a valid JSON object");
|
||||
}
|
||||
}
|
||||
if (customIceServersJsonArray != null) {
|
||||
try {
|
||||
for (int i = 0; i < customIceServersJsonArray.size(); i++) {
|
||||
JsonObject customIceServerJson = customIceServersJsonArray.get(i).getAsJsonObject();
|
||||
IceServerProperties.Builder iceServerPropertiesBuilder = new IceServerProperties.Builder();
|
||||
iceServerPropertiesBuilder.url(customIceServerJson.get("urls").getAsString());
|
||||
if (customIceServerJson.has("username")) {
|
||||
iceServerPropertiesBuilder.username(customIceServerJson.get("username").getAsString());
|
||||
}
|
||||
if (customIceServerJson.has("credential")) {
|
||||
iceServerPropertiesBuilder.credential(customIceServerJson.get("credential").getAsString());
|
||||
}
|
||||
IceServerProperties iceServerProperties = iceServerPropertiesBuilder.build();
|
||||
builder.addCustomIceServer(iceServerProperties);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Type error in some parameter of 'kurentoOptions': " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Build WEBRTC options
|
||||
builder.role(role).kurentoOptions(kurentoOptions);
|
||||
|
||||
|
@ -939,6 +960,8 @@ public class SessionRestController {
|
|||
.onlyPlayWithSubscribers(onlyPlayWithSubscribers).networkCache(networkCache).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue