diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index 94bef3fb..cdd4da7c 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -1510,7 +1510,19 @@ export class Session extends EventDispatcher { private processJoinRoomResponse(opts: LocalConnectionOptions) { this.sessionId = opts.session; - if (opts.coturnIp != null && opts.coturnPort != null && opts.turnUsername != null && opts.turnCredential != null) { + if (opts.customIceServers != null && opts.customIceServers.length > 0) { + this.openvidu.iceServers = []; + for(const iceServer of opts.customIceServers) { + let rtcIceServer: RTCIceServer = { + urls: [ iceServer.url ] + } + if (iceServer.username != null && iceServer.credential != null) { + rtcIceServer.username = iceServer.username; + rtcIceServer.credential = iceServer.credential; + } + 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 } diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/IceServerProperties.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/IceServerProperties.ts new file mode 100644 index 00000000..38402e51 --- /dev/null +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/IceServerProperties.ts @@ -0,0 +1,21 @@ +/* + * (C) Copyright 2017-2022 OpenVidu (https://openvidu.io) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +export interface IceServerProperties { + url: string; + username?: string; + credential?: string; +} \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/LocalConnectionOptions.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/LocalConnectionOptions.ts index ad057f42..9f52796c 100644 --- a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/LocalConnectionOptions.ts +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/LocalConnectionOptions.ts @@ -16,6 +16,7 @@ */ import { RemoteConnectionOptions } from './RemoteConnectionOptions'; +import { IceServerProperties } from './IceServerProperties'; export interface LocalConnectionOptions { id: string; @@ -35,4 +36,5 @@ export interface LocalConnectionOptions { mediaServer: string; videoSimulcast: boolean; life: number; + customIceServers?: IceServerProperties[] }