openvidu-server: Check nulls before setting default ICE servers in customIceServers

pull/731/head
cruizba 2022-05-30 20:40:10 +02:00
parent 789ff26cfc
commit 958eaee41d
1 changed files with 11 additions and 11 deletions

View File

@ -189,9 +189,18 @@ public class SessionEventsHandler {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, coturnIp); result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, coturnIp);
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNPORT_PARAM, openviduConfig.getCoturnPort()); result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNPORT_PARAM, openviduConfig.getCoturnPort());
List<IceServerProperties> customIceServers = participant.getToken().getCustomIceServers(); if (participant.getToken().getTurnCredentials() != null) {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM,
participant.getToken().getTurnCredentials().getUsername());
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNCREDENTIAL_PARAM,
participant.getToken().getTurnCredentials().getCredential());
}
if (customIceServers == null || customIceServers.isEmpty()) { List<IceServerProperties> customIceServers = participant.getToken().getCustomIceServers();
if (customIceServers != null && !customIceServers.isEmpty()) {
result.add(ProtocolElements.PARTICIPANTJOINED_CUSTOM_ICE_SERVERS,
participant.getToken().getCustomIceServersAsJson());
} else if (coturnIp != null && participant.getToken().getTurnCredentials() != null) {
JsonArray defaultCustomIceServers = new JsonArray(); JsonArray defaultCustomIceServers = new JsonArray();
IceServerProperties defaultIceServer = new IceServerProperties.Builder() IceServerProperties defaultIceServer = new IceServerProperties.Builder()
.url("turn:" + coturnIp + ":" + openviduConfig.getCoturnPort()) .url("turn:" + coturnIp + ":" + openviduConfig.getCoturnPort())
@ -199,15 +208,6 @@ public class SessionEventsHandler {
.credential(participant.getToken().getTurnCredentials().getCredential()) .credential(participant.getToken().getTurnCredentials().getCredential())
.build(); .build();
defaultCustomIceServers.add(defaultIceServer.toJson()); defaultCustomIceServers.add(defaultIceServer.toJson());
} else {
result.add(ProtocolElements.PARTICIPANTJOINED_CUSTOM_ICE_SERVERS,
participant.getToken().getCustomIceServersAsJson());
}
if (participant.getToken().getTurnCredentials() != null) {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM,
participant.getToken().getTurnCredentials().getUsername());
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNCREDENTIAL_PARAM,
participant.getToken().getTurnCredentials().getCredential());
} }
if (recording != null) { if (recording != null) {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_RECORDINGID_PARAM, recording.getId()); result.addProperty(ProtocolElements.PARTICIPANTJOINED_RECORDINGID_PARAM, recording.getId());