mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: add OpenViduAdvancedConfiguration.rtcConfiguration
parent
86c4abacb1
commit
dfd614a634
|
@ -1240,6 +1240,7 @@ export class Stream {
|
|||
onIceCandidate: this.connection.sendIceCandidate.bind(this.connection),
|
||||
onIceConnectionStateException: this.onIceConnectionStateExceptionHandler.bind(this),
|
||||
iceServers: this.getIceServersConf(),
|
||||
rtcConfiguration: this.session.openvidu.advancedConfiguration.rtcConfiguration,
|
||||
mediaStream: this.mediaStream,
|
||||
mediaServer: this.session.openvidu.mediaServer,
|
||||
typeOfVideo: this.typeOfVideo ? TypeOfVideo[this.typeOfVideo] : undefined
|
||||
|
@ -1412,6 +1413,7 @@ export class Stream {
|
|||
onIceCandidate: this.connection.sendIceCandidate.bind(this.connection),
|
||||
onIceConnectionStateException: this.onIceConnectionStateExceptionHandler.bind(this),
|
||||
iceServers: this.getIceServersConf(),
|
||||
rtcConfiguration: this.session.openvidu.advancedConfiguration.rtcConfiguration,
|
||||
mediaServer: this.session.openvidu.mediaServer,
|
||||
typeOfVideo: this.typeOfVideo ? TypeOfVideo[this.typeOfVideo] : undefined
|
||||
};
|
||||
|
@ -1728,6 +1730,8 @@ export class Stream {
|
|||
this.session.openvidu.advancedConfiguration.iceServers === 'freeice'
|
||||
? undefined
|
||||
: this.session.openvidu.advancedConfiguration.iceServers;
|
||||
} else if (!!this.session.openvidu.advancedConfiguration.rtcConfiguration?.iceServers) {
|
||||
returnValue = this.session.openvidu.advancedConfiguration.rtcConfiguration.iceServers;
|
||||
} else if (this.session.openvidu.iceServers) {
|
||||
returnValue = this.session.openvidu.iceServers;
|
||||
} else {
|
||||
|
|
|
@ -20,11 +20,18 @@
|
|||
*/
|
||||
export interface OpenViduAdvancedConfiguration {
|
||||
/**
|
||||
* Array of [RTCIceServer](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer) to be used by OpenVidu Browser. By default OpenVidu will generate the required credentials to use the COTURN server hosted along OpenVidu Server
|
||||
* Array of [RTCIceServer](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer) to be used by OpenVidu Browser. By default OpenVidu will generate the required credentials to use the COTURN server hosted along OpenVidu Server.
|
||||
* You can also set this property to string 'freeice' to force the use of free STUN servers instead (got thanks to [freeice](https://github.com/DamonOehlman/freeice) library).
|
||||
*
|
||||
* > **WARNING**: this value has priority over the standard `iceServers` property of [[rtcConfiguration]]. It will override any value in `OpenViduAdvancedConfiguration.rtcConfiguration.iceServers`
|
||||
*/
|
||||
iceServers?: RTCIceServer[] | string;
|
||||
|
||||
/**
|
||||
* Custom configuration for all [RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#parameters) objects. This object will be passed as is to all RTCPeerConnection constructor (all Publishers and Subscribers).
|
||||
*/
|
||||
rtcConfiguration?: RTCConfiguration;
|
||||
|
||||
/**
|
||||
* URL to a custom screen share extension for Chrome (always based on ours: [openvidu-screen-sharing-chrome-extension](https://github.com/OpenVidu/openvidu-screen-sharing-chrome-extension)) to be used instead of the default one.
|
||||
* Must be something like this: `https://chrome.google.com/webstore/detail/YOUR_WEBSTORE_EXTENSION_NAME/YOUR_EXTENSION_ID`
|
||||
|
|
|
@ -41,6 +41,7 @@ export interface WebRtcPeerConfiguration {
|
|||
onIceCandidate: (event: RTCIceCandidate) => void;
|
||||
onIceConnectionStateException: (exceptionName: ExceptionEventName, message: string, data?: any) => void;
|
||||
iceServers?: RTCIceServer[];
|
||||
rtcConfiguration?: RTCConfiguration;
|
||||
mediaStream?: MediaStream | null;
|
||||
mode?: 'sendonly' | 'recvonly' | 'sendrecv';
|
||||
id?: string;
|
||||
|
@ -63,6 +64,7 @@ export class WebRtcPeer {
|
|||
this.configuration = {
|
||||
...configuration,
|
||||
iceServers: !!configuration.iceServers && configuration.iceServers.length > 0 ? configuration.iceServers : freeice(),
|
||||
rtcConfiguration: configuration.rtcConfiguration !== undefined ? configuration.rtcConfiguration : {},
|
||||
mediaStream: configuration.mediaStream !== undefined ? configuration.mediaStream : null,
|
||||
mode: !!configuration.mode ? configuration.mode : 'sendrecv',
|
||||
id: !!configuration.id ? configuration.id : this.generateUniqueId()
|
||||
|
@ -70,7 +72,13 @@ export class WebRtcPeer {
|
|||
// prettier-ignore
|
||||
logger.debug(`[WebRtcPeer] configuration:\n${JSON.stringify(this.configuration, null, 2)}`);
|
||||
|
||||
this.pc = new RTCPeerConnection({ iceServers: this.configuration.iceServers });
|
||||
let rtcConfiguration: RTCConfiguration = this.configuration.rtcConfiguration
|
||||
? this.configuration.rtcConfiguration
|
||||
: { iceServers: this.configuration.iceServers };
|
||||
if (!rtcConfiguration.iceServers && this.configuration.iceServers) {
|
||||
rtcConfiguration.iceServers = this.configuration.iceServers;
|
||||
}
|
||||
this.pc = new RTCPeerConnection(rtcConfiguration);
|
||||
|
||||
this.pc.addEventListener('icecandidate', (event: RTCPeerConnectionIceEvent) => {
|
||||
if (event.candidate !== null) {
|
||||
|
|
Loading…
Reference in New Issue