You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Fix the force TURN option
Option needed to be passed in when creating a webrtc call, but for incoming calls the js-sdk creates the call itself, so the app never gets a chance to set the option.
This commit is contained in:
@@ -175,6 +175,8 @@ function MatrixClient(opts) {
|
|||||||
this._cryptoStore = opts.cryptoStore;
|
this._cryptoStore = opts.cryptoStore;
|
||||||
this._sessionStore = opts.sessionStore;
|
this._sessionStore = opts.sessionStore;
|
||||||
|
|
||||||
|
this._forceTURN = opts.forceTURN || false;
|
||||||
|
|
||||||
if (CRYPTO_ENABLED) {
|
if (CRYPTO_ENABLED) {
|
||||||
this.olmVersion = Crypto.getOlmVersion();
|
this.olmVersion = Crypto.getOlmVersion();
|
||||||
}
|
}
|
||||||
@@ -252,6 +254,15 @@ MatrixClient.prototype.supportsVoip = function() {
|
|||||||
return this._supportsVoip;
|
return this._supportsVoip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether VoIP calls are forced to use only TURN
|
||||||
|
* candidates. This is the same as the forceTURN option
|
||||||
|
* when creating the client.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.setForceTURN = function(forceTURN) {
|
||||||
|
return this._forceTURN = forceTURN;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current sync state.
|
* Get the current sync state.
|
||||||
* @return {?string} the sync state, which may be null.
|
* @return {?string} the sync state, which may be null.
|
||||||
@@ -3153,7 +3164,9 @@ function setupCallEventHandler(client) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
call = webRtcCall.createNewMatrixCall(client, event.getRoomId());
|
call = webRtcCall.createNewMatrixCall(client, event.getRoomId(), {
|
||||||
|
forceTURN: client._forceTURN,
|
||||||
|
});
|
||||||
if (!call) {
|
if (!call) {
|
||||||
console.log(
|
console.log(
|
||||||
"Incoming call ID " + content.call_id + " but this client " +
|
"Incoming call ID " + content.call_id + " but this client " +
|
||||||
|
|||||||
@@ -1300,7 +1300,7 @@ module.exports.setVideoInput = function(deviceId) { videoInput = deviceId; };
|
|||||||
* @param {boolean} options.forceTURN whether relay through TURN should be forced.
|
* @param {boolean} options.forceTURN whether relay through TURN should be forced.
|
||||||
* @return {MatrixCall} the call or null if the browser doesn't support calling.
|
* @return {MatrixCall} the call or null if the browser doesn't support calling.
|
||||||
*/
|
*/
|
||||||
module.exports.createNewMatrixCall = function(client, roomId, options) {
|
module.exports.createNewMatrixCall = function(client, roomId) {
|
||||||
const w = global.window;
|
const w = global.window;
|
||||||
const doc = global.document;
|
const doc = global.document;
|
||||||
if (!w || !doc) {
|
if (!w || !doc) {
|
||||||
@@ -1357,7 +1357,7 @@ module.exports.createNewMatrixCall = function(client, roomId, options) {
|
|||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
turnServers: client.getTurnServers(),
|
turnServers: client.getTurnServers(),
|
||||||
// call level options
|
// call level options
|
||||||
forceTURN: options ? options.forceTURN : false,
|
forceTURN: client._forceTURN,
|
||||||
};
|
};
|
||||||
return new MatrixCall(opts);
|
return new MatrixCall(opts);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user