fix(conference): store user selected device from Firefox prompt

When Firefox users choose a new device via the gUM prompt store
these as the new user selected devices, so they show up in the
settings menu.
This commit is contained in:
Nils Ohlmeier 2021-10-25 21:35:42 -07:00 committed by Hristo Terezov
parent af01072827
commit 41f5872f70
1 changed files with 39 additions and 13 deletions

View File

@ -8,7 +8,8 @@ import {
import { import {
getUserSelectedCameraDeviceId, getUserSelectedCameraDeviceId,
getUserSelectedMicDeviceId, getUserSelectedMicDeviceId,
getUserSelectedOutputDeviceId getUserSelectedOutputDeviceId,
updateSettings
} from '../../react/features/base/settings'; } from '../../react/features/base/settings';
/** /**
@ -61,6 +62,9 @@ function getNewAudioInputDevice(newDevices, localAudio, newLabel) {
const selectedAudioInputDeviceId = getUserSelectedMicDeviceId(APP.store.getState()); const selectedAudioInputDeviceId = getUserSelectedMicDeviceId(APP.store.getState());
const selectedAudioInputDevice = availableAudioInputDevices.find( const selectedAudioInputDevice = availableAudioInputDevices.find(
d => d.deviceId === selectedAudioInputDeviceId); d => d.deviceId === selectedAudioInputDeviceId);
const localAudioDeviceId = localAudio.getDeviceId();
const localAudioDevice = availableAudioInputDevices.find(
d => d.deviceId === localAudioDeviceId);
// Here we handle case when no device was initially plugged, but // Here we handle case when no device was initially plugged, but
// then it's connected OR new device was connected when previous // then it's connected OR new device was connected when previous
@ -76,13 +80,22 @@ function getNewAudioInputDevice(newDevices, localAudio, newLabel) {
return availableAudioInputDevices[0].deviceId; return availableAudioInputDevices[0].deviceId;
} }
} else if (selectedAudioInputDevice } else if (selectedAudioInputDevice
&& selectedAudioInputDeviceId !== localAudio.getDeviceId() && selectedAudioInputDeviceId !== localAudio.getDeviceId()) {
&& !newLabel) {
// And here we handle case when we already have some device working, if (newLabel) {
// but we plug-in a "preferred" (previously selected in settings, stored // If a Firefox user with manual permission prompt chose a different
// in local storage) device. // device from what we have stored as the preferred device we accept
return selectedAudioInputDeviceId; // and store that as the new preferred device.
APP.store.dispatch(updateSettings({
userSelectedMicDeviceId: localAudioDeviceId,
userSelectedMicDeviceLabel: localAudioDevice.label
}));
} else {
// And here we handle case when we already have some device working,
// but we plug-in a "preferred" (previously selected in settings, stored
// in local storage) device.
return selectedAudioInputDeviceId;
}
} }
} }
@ -101,6 +114,9 @@ function getNewVideoInputDevice(newDevices, localVideo, newLabel) {
const selectedVideoInputDeviceId = getUserSelectedCameraDeviceId(APP.store.getState()); const selectedVideoInputDeviceId = getUserSelectedCameraDeviceId(APP.store.getState());
const selectedVideoInputDevice = availableVideoInputDevices.find( const selectedVideoInputDevice = availableVideoInputDevices.find(
d => d.deviceId === selectedVideoInputDeviceId); d => d.deviceId === selectedVideoInputDeviceId);
const localVideoDeviceId = localVideo.getDeviceId();
const localVideoDevice = availableVideoInputDevices.find(
d => d.deviceId === localVideoDeviceId);
// Here we handle case when no video input device was initially plugged, // Here we handle case when no video input device was initially plugged,
// but then device is connected OR new device was connected when // but then device is connected OR new device was connected when
@ -116,12 +132,22 @@ function getNewVideoInputDevice(newDevices, localVideo, newLabel) {
return availableVideoInputDevices[0].deviceId; return availableVideoInputDevices[0].deviceId;
} }
} else if (selectedVideoInputDevice } else if (selectedVideoInputDevice
&& selectedVideoInputDeviceId !== localVideo.getDeviceId() && selectedVideoInputDeviceId !== localVideo.getDeviceId()) {
&& !newLabel) {
// And here we handle case when we already have some device working, if (newLabel) {
// but we plug-in a "preferred" (previously selected in settings, stored // If a Firefox user with manual permission prompt chose a different
// in local storage) device. // device from what we have stored as the preferred device we accept
return selectedVideoInputDeviceId; // and store that as the new preferred device.
APP.store.dispatch(updateSettings({
userSelectedCameraDeviceId: localVideoDeviceId,
userSelectedCameraDeviceLabel: localVideoDevice.label
}));
} else {
// And here we handle case when we already have some device working,
// but we plug-in a "preferred" (previously selected in settings, stored
// in local storage) device.
return selectedVideoInputDeviceId;
}
} }
} }