Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(api): store passed in devices as user selected

Leonard Kim149485905c37
diff --git a/react/features/base/devices/actions.js b/react/features/base/devices/actions.js
index 48903bcf24..20b8dec0dd 100644
--- a/react/features/base/devices/actions.js
+++ b/react/features/base/devices/actions.js
@@ -21,6 +21,28 @@ import {
const logger = require('jitsi-meet-logger').getLogger(__filename);
+/**
+ * Maps the WebRTC string for device type to the keys used to store configure,
+ * within redux, which devices should be used by default.
+ */
+const DEVICE_TYPE_TO_SETTINGS_KEYS = {
+ audioInput: {
+ currentDeviceId: 'micDeviceId',
+ userSelectedDeviceId: 'userSelectedMicDeviceId',
+ userSelectedDeviceLabel: 'userSelectedMicDeviceLabel'
+ },
+ audioOutput: {
+ currentDeviceId: 'audioOutputDeviceId',
+ userSelectedDeviceId: 'userSelectedAudioOutputDeviceId',
+ userSelectedDeviceLabel: 'userSelectedAudioOutputDeviceLabel'
+ },
+ videoInput: {
+ currentDeviceId: 'audioOutputDeviceId',
+ userSelectedDeviceId: 'userSelectedCameraDeviceId',
+ userSelectedDeviceLabel: 'userSelectedCameraDeviceLabel'
+ }
+};
+
/**
* Adds a pending device request.
*
@@ -70,19 +92,19 @@ export function configureInitialDevices() {
return;
}
+
const newSettings = {};
- const devicesKeysToSettingsKeys = {
- audioInput: 'micDeviceId',
- audioOutput: 'audioOutputDeviceId',
- videoInput: 'cameraDeviceId'
- };
Object.keys(deviceLabels).forEach(key => {
const label = deviceLabels[key];
const deviceId = getDeviceIdByLabel(state, label, key);
if (deviceId) {
- newSettings[devicesKeysToSettingsKeys[key]] = deviceId;
+ const settingsTranslationMap = DEVICE_TYPE_TO_SETTINGS_KEYS[key];
+
+ newSettings[settingsTranslationMap.currentDeviceId] = deviceId;
+ newSettings[settingsTranslationMap.userSelectedDeviceId] = deviceId;
+ newSettings[settingsTranslationMap.userSelectedDeviceLabel] = label;
}
});