Skip to content

Commit

Permalink
feat(sipconnector.ts): use default iceServer when undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjammet committed Feb 15, 2024
1 parent 3752caa commit adff14d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/connectors/SIPConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { ConnectParams } from '../utils/Connect';
import { EventEmitter } from '../utils/EventEmitter';
import { NetAddress } from '../utils/NetAddress';
import { SDP } from '../utils/SDP';
import { Util } from '../utils/Util';
import { ConnectionInfos, IConnector } from './IConnector';
Expand Down Expand Up @@ -83,6 +84,7 @@ export abstract class SIPConnector extends EventEmitter implements IConnector {
}

private _streamName: string;
private _host: string;
private _stream?: MediaStream;
private _peerConnection?: RTCPeerConnection;
private _closed: boolean;
Expand All @@ -99,6 +101,7 @@ export abstract class SIPConnector extends EventEmitter implements IConnector {
super();
this._closed = false;
this._streamName = connectParams.streamName;
this._host = connectParams.host;
this._stream = stream;
this._connectionInfosTime = 0;
this._codecs = new Set<string>();
Expand Down Expand Up @@ -207,6 +210,15 @@ export abstract class SIPConnector extends EventEmitter implements IConnector {
* calls the _sip method, then set the answer and calls onOpen
*/
protected _open(iceServer?: RTCIceServer) {
// If iceServer is not provided, use the default one
if (!iceServer) {
const domain = new NetAddress(this._host, 443).domain;
iceServer = {
urls: ['turn:' + domain + ':3478?transport=tcp', 'turn:' + domain + ':3478'],
username: 'csc_demo',
credential: 'UtrAFClFFO'
};
}
// Start the RTCPeerConnection and create an offer
try {
this._peerConnection = new RTCPeerConnection(iceServer ? { iceServers: [iceServer] } : undefined);
Expand Down

0 comments on commit adff14d

Please sign in to comment.