openvidu-server: Set default coturnIp and coturnPort in customIceServers at joinRoom RPC response, ONLY if customIceServers are not defined

pull/731/head
cruizba 2022-05-30 18:02:06 +02:00
parent e505cd6c8d
commit 789ff26cfc
2 changed files with 10 additions and 8 deletions

View File

@ -1544,13 +1544,6 @@ export class Session extends EventDispatcher {
}
this.openvidu.iceServers.push(rtcIceServer);
}
} else if (opts.coturnIp != null && opts.coturnPort != null && opts.turnUsername != null && opts.turnCredential != null) {
const turnUrl1 = 'turn:' + opts.coturnIp + ':' + opts.coturnPort;
this.openvidu.iceServers = [
{ urls: [turnUrl1], username: opts.turnUsername, credential: opts.turnCredential }
];
logger.log("STUN/TURN server IP: " + opts.coturnIp);
logger.log('TURN temp credentials [' + opts.turnUsername + ':' + opts.turnCredential + ']');
}
this.openvidu.role = opts.role;
this.openvidu.finalUserId = opts.finalUserId;

View File

@ -190,7 +190,16 @@ public class SessionEventsHandler {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, coturnIp);
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNPORT_PARAM, openviduConfig.getCoturnPort());
List<IceServerProperties> customIceServers = participant.getToken().getCustomIceServers();
if (customIceServers != null && !customIceServers.isEmpty()) {
if (customIceServers == null || customIceServers.isEmpty()) {
JsonArray defaultCustomIceServers = new JsonArray();
IceServerProperties defaultIceServer = new IceServerProperties.Builder()
.url("turn:" + coturnIp + ":" + openviduConfig.getCoturnPort())
.username(participant.getToken().getTurnCredentials().getUsername())
.credential(participant.getToken().getTurnCredentials().getCredential())
.build();
defaultCustomIceServers.add(defaultIceServer.toJson());
} else {
result.add(ProtocolElements.PARTICIPANTJOINED_CUSTOM_ICE_SERVERS,
participant.getToken().getCustomIceServersAsJson());
}