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(device-selection): use device kind when getting current devices (#4059)

virtuacoplennyb731459ea464
diff --git a/react/features/device-selection/functions.js b/react/features/device-selection/functions.js
index 21b537e030..02571a9685 100644
--- a/react/features/device-selection/functions.js
+++ b/react/features/device-selection/functions.js
@@ -82,31 +82,36 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
case 'getCurrentDevices':
dispatch(getAvailableDevices()).then(devices => {
if (areDeviceLabelsInitialized(state)) {
- let audioInput, audioOutput, videoInput;
- const audioOutputDeviceId = getAudioOutputDeviceId();
- const { cameraDeviceId, micDeviceId } = settings;
+ const deviceDescriptions = {
+ audioInput: undefined,
+ audioOutput: undefined,
+ videoInput: undefined
+ };
+ const currentlyUsedDeviceIds = new Set([
+ getAudioOutputDeviceId(),
+ settings.micDeviceId,
+ settings.cameraDeviceId
+ ]);
devices.forEach(device => {
- const { deviceId } = device;
-
- switch (deviceId) {
- case micDeviceId:
- audioInput = device;
- break;
- case audioOutputDeviceId:
- audioOutput = device;
- break;
- case cameraDeviceId:
- videoInput = device;
- break;
+ const { deviceId, kind } = device;
+
+ if (currentlyUsedDeviceIds.has(deviceId)) {
+ switch (kind) {
+ case 'audioinput':
+ deviceDescriptions.audioInput = device;
+ break;
+ case 'audiooutput':
+ deviceDescriptions.audioOutput = device;
+ break;
+ case 'videoinput':
+ deviceDescriptions.videoInput = device;
+ break;
+ }
}
});
- responseCallback({
- audioInput,
- audioOutput,
- videoInput
- });
+ responseCallback(deviceDescriptions);
} else {
// The labels are not available if the A/V permissions are
// not yet granted.