fix(conference) avoid double prompts in Firefox after choosing non-default device.
* fix(conference) avoid double prompts in Firefox after choosing non-default device * addressed linting errors
This commit is contained in:
parent
779d44298b
commit
84f37b1777
|
@ -2642,12 +2642,17 @@ export default {
|
|||
|
||||
APP.store.dispatch(updateDeviceList(devices));
|
||||
|
||||
// Firefox users can choose their preferred device in the gUM prompt. In that case
|
||||
// we should respect that and not attempt to switch to the preferred device from
|
||||
// our settings.
|
||||
const newLabelsOnly = mediaDeviceHelper.newDeviceListAddedLabelsOnly(oldDevices, devices);
|
||||
const newDevices
|
||||
= mediaDeviceHelper.getNewMediaDevicesAfterDeviceListChanged(
|
||||
devices,
|
||||
this.isSharingScreen,
|
||||
localVideo,
|
||||
localAudio);
|
||||
localAudio,
|
||||
newLabelsOnly);
|
||||
const promises = [];
|
||||
const audioWasMuted = this.isLocalAudioMuted();
|
||||
const videoWasMuted = this.isLocalVideoMuted();
|
||||
|
|
|
@ -51,10 +51,11 @@ function getNewAudioOutputDevice(newDevices) {
|
|||
* list of available devices has been changed.
|
||||
* @param {MediaDeviceInfo[]} newDevices
|
||||
* @param {JitsiLocalTrack} localAudio
|
||||
* @param {boolean} newLabel
|
||||
* @returns {string|undefined} - ID of new microphone device to use, undefined
|
||||
* if audio input device should not be changed.
|
||||
*/
|
||||
function getNewAudioInputDevice(newDevices, localAudio) {
|
||||
function getNewAudioInputDevice(newDevices, localAudio, newLabel) {
|
||||
const availableAudioInputDevices = newDevices.filter(
|
||||
d => d.kind === 'audioinput');
|
||||
const selectedAudioInputDeviceId = getUserSelectedMicDeviceId(APP.store.getState());
|
||||
|
@ -75,7 +76,8 @@ function getNewAudioInputDevice(newDevices, localAudio) {
|
|||
return availableAudioInputDevices[0].deviceId;
|
||||
}
|
||||
} else if (selectedAudioInputDevice
|
||||
&& selectedAudioInputDeviceId !== localAudio.getDeviceId()) {
|
||||
&& selectedAudioInputDeviceId !== localAudio.getDeviceId()
|
||||
&& !newLabel) {
|
||||
|
||||
// And here we handle case when we already have some device working,
|
||||
// but we plug-in a "preferred" (previously selected in settings, stored
|
||||
|
@ -89,10 +91,11 @@ function getNewAudioInputDevice(newDevices, localAudio) {
|
|||
* list of available devices has been changed.
|
||||
* @param {MediaDeviceInfo[]} newDevices
|
||||
* @param {JitsiLocalTrack} localVideo
|
||||
* @param {boolean} newLabel
|
||||
* @returns {string|undefined} - ID of new camera device to use, undefined
|
||||
* if video input device should not be changed.
|
||||
*/
|
||||
function getNewVideoInputDevice(newDevices, localVideo) {
|
||||
function getNewVideoInputDevice(newDevices, localVideo, newLabel) {
|
||||
const availableVideoInputDevices = newDevices.filter(
|
||||
d => d.kind === 'videoinput');
|
||||
const selectedVideoInputDeviceId = getUserSelectedCameraDeviceId(APP.store.getState());
|
||||
|
@ -113,7 +116,8 @@ function getNewVideoInputDevice(newDevices, localVideo) {
|
|||
return availableVideoInputDevices[0].deviceId;
|
||||
}
|
||||
} else if (selectedVideoInputDevice
|
||||
&& selectedVideoInputDeviceId !== localVideo.getDeviceId()) {
|
||||
&& selectedVideoInputDeviceId !== localVideo.getDeviceId()
|
||||
&& !newLabel) {
|
||||
// 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.
|
||||
|
@ -139,14 +143,42 @@ export default {
|
|||
newDevices,
|
||||
isSharingScreen,
|
||||
localVideo,
|
||||
localAudio) {
|
||||
localAudio,
|
||||
newLabels) {
|
||||
return {
|
||||
audioinput: getNewAudioInputDevice(newDevices, localAudio),
|
||||
videoinput: isSharingScreen ? undefined : getNewVideoInputDevice(newDevices, localVideo),
|
||||
audioinput: getNewAudioInputDevice(newDevices, localAudio, newLabels),
|
||||
videoinput: isSharingScreen ? undefined : getNewVideoInputDevice(newDevices, localVideo, newLabels),
|
||||
audiooutput: getNewAudioOutputDevice(newDevices)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the only difference between an object of known devices compared
|
||||
* to an array of new devices are only the labels for the devices.
|
||||
* @param {Object} oldDevices
|
||||
* @param {MediaDeviceInfo[]} newDevices
|
||||
* @returns {boolean}
|
||||
*/
|
||||
newDeviceListAddedLabelsOnly(oldDevices, newDevices) {
|
||||
const oldDevicesFlattend = oldDevices.audioInput.concat(oldDevices.audioOutput).concat(oldDevices.videoInput);
|
||||
|
||||
if (oldDevicesFlattend.length !== newDevices.length) {
|
||||
return false;
|
||||
}
|
||||
oldDevicesFlattend.forEach(oldDevice => {
|
||||
if (oldDevice.label !== '') {
|
||||
return false;
|
||||
}
|
||||
const newDevice = newDevices.find(nd => nd.deviceId === oldDevice.deviceId);
|
||||
|
||||
if (!newDevice || newDevice.label === '') {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Tries to create new local tracks for new devices obtained after device
|
||||
* list changed. Shows error dialog in case of failures.
|
||||
|
|
Loading…
Reference in New Issue