diff --git a/CHANGELOG.md b/CHANGELOG.md index c90bf35f0..3bd035f27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Changes in [0.9.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.9.1) (2017-11-17) +================================================================================================ +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.9.0...v0.9.1) + + * Fix the force TURN option + [\#577](https://github.com/matrix-org/matrix-js-sdk/pull/577) + Changes in [0.9.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.9.0) (2017-11-15) ================================================================================================ [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.9.0-rc.1...v0.9.0) diff --git a/package.json b/package.json index d13469c13..0e8597b05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-js-sdk", - "version": "0.9.0", + "version": "0.9.1", "description": "Matrix Client-Server SDK for Javascript", "main": "index.js", "scripts": { diff --git a/src/client.js b/src/client.js index 37bca7ba5..6fb280582 100644 --- a/src/client.js +++ b/src/client.js @@ -175,6 +175,8 @@ function MatrixClient(opts) { this._cryptoStore = opts.cryptoStore; this._sessionStore = opts.sessionStore; + this._forceTURN = opts.forceTURN || false; + if (CRYPTO_ENABLED) { this.olmVersion = Crypto.getOlmVersion(); } @@ -252,6 +254,16 @@ MatrixClient.prototype.supportsVoip = function() { 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. + * @param {bool} forceTURN True to force use of TURN servers + */ +MatrixClient.prototype.setForceTURN = function(forceTURN) { + this._forceTURN = forceTURN; +}; + /** * Get the current sync state. * @return {?string} the sync state, which may be null. @@ -3154,7 +3166,9 @@ function setupCallEventHandler(client) { ); } - call = webRtcCall.createNewMatrixCall(client, event.getRoomId()); + call = webRtcCall.createNewMatrixCall(client, event.getRoomId(), { + forceTURN: client._forceTURN, + }); if (!call) { console.log( "Incoming call ID " + content.call_id + " but this client " + diff --git a/src/webrtc/call.js b/src/webrtc/call.js index a44e18ad6..9cbee4e8b 100644 --- a/src/webrtc/call.js +++ b/src/webrtc/call.js @@ -1296,8 +1296,8 @@ module.exports.setVideoInput = function(deviceId) { videoInput = deviceId; }; * Create a new Matrix call for the browser. * @param {MatrixClient} client The client instance to use. * @param {string} roomId The room the call is in. - * @param {Object?} options optional options map. - * @param {boolean} options.forceTURN whether relay through TURN should be forced. + * @param {Object?} options DEPRECATED optional options map. + * @param {boolean} options.forceTURN DEPRECATED whether relay through TURN should be forced. This option is deprecated - use opts.forceTURN when creating the matrix client since it's only possible to set this option on outbound calls. * @return {MatrixCall} the call or null if the browser doesn't support calling. */ module.exports.createNewMatrixCall = function(client, roomId, options) { @@ -1350,6 +1350,9 @@ module.exports.createNewMatrixCall = function(client, roomId, options) { !webRtc.RtcPeerConnection || !webRtc.getUserMedia) { return null; // WebRTC is not supported. } + + const optionsForceTURN = options ? options.forceTURN : false; + const opts = { webRtc: webRtc, client: client, @@ -1357,7 +1360,7 @@ module.exports.createNewMatrixCall = function(client, roomId, options) { roomId: roomId, turnServers: client.getTurnServers(), // call level options - forceTURN: options ? options.forceTURN : false, + forceTURN: client._forceTURN || optionsForceTURN, }; return new MatrixCall(opts); };