openvidu-browser: Add cutomIceServers from 'joinRoom' rpc message

pull/698/head
cruizba 2022-02-11 22:38:51 +01:00
parent 0437cc9199
commit 40ed2c5efc
3 changed files with 36 additions and 1 deletions

View File

@ -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 }

View File

@ -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;
}

View File

@ -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[]
}