diff --git a/src/CallHandler.js b/src/CallHandler.js index b2ccf65df7..e3fbe9e5e3 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -51,13 +51,14 @@ limitations under the License. * } */ -var MatrixClientPeg = require('./MatrixClientPeg'); -var PlatformPeg = require("./PlatformPeg"); -var Modal = require('./Modal'); -var sdk = require('./index'); +import MatrixClientPeg from './MatrixClientPeg'; +import UserSettingsStore from './UserSettingsStore'; +import PlatformPeg from './PlatformPeg'; +import Modal from './Modal'; +import sdk from './index'; import { _t } from './languageHandler'; -var Matrix = require("matrix-js-sdk"); -var dis = require("./dispatcher"); +import Matrix from 'matrix-js-sdk'; +import dis from './dispatcher'; global.mxCalls = { //room_id: MatrixCall @@ -257,9 +258,9 @@ function _onAction(payload) { } else if (members.length === 2) { console.log("Place %s call in %s", payload.type, payload.room_id); - var call = Matrix.createNewMatrixCall( - MatrixClientPeg.get(), payload.room_id - ); + const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id, { + forceTURN: UserSettingsStore.getLocalSetting('webRtcForceTURN', false), + }); placeCall(call); } else { // > 2 diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index e73f0335f0..5ac2e77256 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -110,6 +110,13 @@ const ANALYTICS_SETTINGS_LABELS = [ }, ]; +const WEBRTC_SETTINGS_LABELS = [ + { + id: 'webRtcForceTURN', + label: 'Disable Peer-to-Peer for 1:1 calls', + }, +]; + // Warning: Each "label" string below must be added to i18n/strings/en_EN.json, // since they will be translated when rendered. const CRYPTO_SETTINGS_LABELS = [ @@ -945,16 +952,13 @@ module.exports = React.createClass({ } }, - _renderWebRtcSettings: function() { + _renderWebRtcDeviceSettings: function() { if (this.state.mediaDevices === false) { - return <div> - <h3>{_t('VoIP')}</h3> - <div className="mx_UserSettings_section"> - <p className="mx_UserSettings_link" onClick={this._requestMediaPermissions}> - {_t('Missing Media Permissions, click here to request.')} - </p> - </div> - </div>; + return ( + <p className="mx_UserSettings_link" onClick={this._requestMediaPermissions}> + {_t('Missing Media Permissions, click here to request.')} + </p> + ); } else if (!this.state.mediaDevices) return; const Dropdown = sdk.getComponent('elements.Dropdown'); @@ -1008,10 +1012,17 @@ module.exports = React.createClass({ } return <div> - <h3>{_t('VoIP')}</h3> - <div className="mx_UserSettings_section"> {microphoneDropdown} {webcamDropdown} + </div>; + }, + + _renderWebRtcSettings: function() { + return <div> + <h3>{_t('VoIP')}</h3> + <div className="mx_UserSettings_section"> + { WEBRTC_SETTINGS_LABELS.map(this._renderLocalSetting) } + { this._renderWebRtcDeviceSettings() } </div> </div>; }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 51d03db0b7..0172115824 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -907,5 +907,6 @@ "If you already have a Matrix account you can <a>log in</a> instead.": "If you already have a Matrix account you can <a>log in</a> instead.", "Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions", "Not a valid Riot keyfile": "Not a valid Riot keyfile", - "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?" + "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", + "Disable Peer-to-Peer for 1:1 calls": "Disable Peer-to-Peer for 1:1 calls" }