diff --git a/src/matrix/Session.js b/src/matrix/Session.js index aa7dbf7b..bd361434 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -96,6 +96,10 @@ export class Session { ownDeviceId: sessionInfo.deviceId, ownUserId: sessionInfo.userId, logger: this._platform.logger, + turnServers: [{ + urls: ["stun:turn.matrix.org"], + }], + forceTURN: false, }); this._deviceMessageHandler = new DeviceMessageHandler({storage, callHandler: this._callHandler}); this._olm = olm; diff --git a/src/matrix/calls/PeerCall.ts b/src/matrix/calls/PeerCall.ts index fa1063ec..8559982c 100644 --- a/src/matrix/calls/PeerCall.ts +++ b/src/matrix/calls/PeerCall.ts @@ -45,6 +45,8 @@ import type { export type Options = { webRTC: WebRTC, + forceTURN: boolean, + turnServers: RTCIceServer[], createTimeout: TimeoutCreator, emitUpdate: (peerCall: PeerCall, params: any) => void; sendSignallingMessage: (message: SignallingMessage, log: ILogItem) => Promise; @@ -132,7 +134,7 @@ export class PeerCall implements IDisposable { getPurposeForStreamId(streamId: string): SDPStreamMetadataPurpose { return outer.remoteSDPStreamMetadata?.[streamId]?.purpose ?? SDPStreamMetadataPurpose.Usermedia; } - }); + }, this.options.forceTURN, this.options.turnServers, 0); } get dataChannel(): any | undefined { return this._dataChannel; } diff --git a/src/platform/types/WebRTC.ts b/src/platform/types/WebRTC.ts index 130cb7cb..a1a7b7cd 100644 --- a/src/platform/types/WebRTC.ts +++ b/src/platform/types/WebRTC.ts @@ -18,7 +18,7 @@ import {Track, TrackType} from "./MediaDevices"; import {SDPStreamMetadataPurpose} from "../../matrix/calls/callEventTypes"; export interface WebRTC { - createPeerConnection(handler: PeerConnectionHandler): PeerConnection; + createPeerConnection(handler: PeerConnectionHandler, forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection; } export interface PeerConnectionHandler { diff --git a/src/platform/web/dom/WebRTC.ts b/src/platform/web/dom/WebRTC.ts index 78977eb8..861a91f1 100644 --- a/src/platform/web/dom/WebRTC.ts +++ b/src/platform/web/dom/WebRTC.ts @@ -24,8 +24,8 @@ export const SPEAKING_THRESHOLD = -60; // dB const SPEAKING_SAMPLE_COUNT = 8; // samples export class DOMWebRTC implements WebRTC { - createPeerConnection(handler: PeerConnectionHandler): PeerConnection { - return new DOMPeerConnection(handler, false, []); + createPeerConnection(handler: PeerConnectionHandler, forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection { + return new DOMPeerConnection(handler, forceTURN, turnServers, iceCandidatePoolSize); } } @@ -35,7 +35,7 @@ class DOMPeerConnection implements PeerConnection { //private dataChannelWrapper?: DOMDataChannel; private _remoteTracks: TrackWrapper[] = []; - constructor(handler: PeerConnectionHandler, forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize = 0) { + constructor(handler: PeerConnectionHandler, forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize) { this.handler = handler; this.peerConnection = new RTCPeerConnection({ iceTransportPolicy: forceTURN ? 'relay' : undefined,