diff --git a/src/CallMediaHandler.js b/src/CallMediaHandler.js index 45ca5dc30d..780df60846 100644 --- a/src/CallMediaHandler.js +++ b/src/CallMediaHandler.js @@ -53,12 +53,36 @@ export default { // }); }, + _findDefault: function(devices) { + return devices.some((device) => device.deviceId === 'default') ? 'default' : undefined; + }, + + setAudioInputDefault: async function() { + const devices = await this.getDevices(); + const audioDefault = this._findDefault(devices.audioinput); + this._setAudioInput(audioDefault); + }, + setAudioInput: function(deviceId) { + this[deviceId === 'default' ? 'setAudioInputDefault' : '_setAudioInput'](deviceId); + }, + + _setAudioInput: function(deviceId) { UserSettingsStore.setLocalSetting('webrtc_audioinput', deviceId); Matrix.setMatrixCallAudioInput(deviceId); }, + setVideoInputDefault: async function() { + const devices = await this.getDevices(); + const videoDefault = this._findDefault(devices.videoinput); + this._setVideoInput(videoDefault); + }, + setVideoInput: function(deviceId) { + this[deviceId === 'default' ? 'setVideoInputDefault' : '_setVideoInput'](); + }, + + _setVideoInput: function(deviceId) { UserSettingsStore.setLocalSetting('webrtc_videoinput', deviceId); Matrix.setMatrixCallVideoInput(deviceId); }, diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index b8567fc180..99b02b59f9 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -952,24 +952,21 @@ module.exports = React.createClass({ let webcamDropdown =
{_t('No Webcams detected')}
; const defaultOption = { - deviceId: undefined, + deviceId: 'default', label: _t('Default Device'), }; const audioInputs = this.state.mediaDevices.audioinput.slice(0); if (audioInputs.length > 0) { - let defaultInput; if (!audioInputs.some((input) => input.deviceId === 'default')) { audioInputs.unshift(defaultOption); - } else { - defaultInput = 'default'; } microphoneDropdown =