Remove state from mediaDeviceHelper (#3226)

* ref(device-selection): do not override var that is not reference again

* ref(device-selection): do not override var that is not reference again

* ref(device-selection): always update known devices on device list update

* ref(device-selection): replace call to get devices from legacy to redux

* ref(device-selection): remove unused device list state from mediaDeviceHelper

* ref(device-selection): update store before updating UI
This commit is contained in:
virtuacoplenny 2018-07-13 10:31:28 -07:00 committed by GitHub
parent 0dcf8ef2f6
commit 4e4755f91e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 64 deletions

View File

@ -2341,9 +2341,8 @@ export default {
}));
}
mediaDeviceHelper.setCurrentMediaDevices(devices);
APP.UI.onAvailableDevicesChanged(devices);
APP.store.dispatch(updateDeviceList(devices));
APP.UI.onAvailableDevicesChanged(devices);
});
this.deviceChangeListener = devices =>
@ -2362,16 +2361,7 @@ export default {
* @returns {Promise}
*/
_onDeviceListChanged(devices) {
let currentDevices = mediaDeviceHelper.getCurrentMediaDevices();
// Event handler can be fired before direct
// enumerateDevices() call, so handle this situation here.
if (!currentDevices.audioinput
&& !currentDevices.videoinput
&& !currentDevices.audiooutput) {
mediaDeviceHelper.setCurrentMediaDevices(devices);
currentDevices = mediaDeviceHelper.getCurrentMediaDevices();
}
APP.store.dispatch(updateDeviceList(devices));
const newDevices
= mediaDeviceHelper.getNewMediaDevicesAfterDeviceListChanged(
@ -2420,7 +2410,6 @@ export default {
return Promise.all(promises)
.then(() => {
mediaDeviceHelper.setCurrentMediaDevices(devices);
APP.UI.onAvailableDevicesChanged(devices);
});
},
@ -2430,7 +2419,7 @@ export default {
*/
updateAudioIconEnabled() {
const audioMediaDevices
= mediaDeviceHelper.getCurrentMediaDevices().audioinput;
= APP.store.getState()['features/base/devices'].audioInput;
const audioDeviceCount
= audioMediaDevices ? audioMediaDevices.length : 0;
@ -2453,7 +2442,7 @@ export default {
*/
updateVideoIconEnabled() {
const videoMediaDevices
= mediaDeviceHelper.getCurrentMediaDevices().videoinput;
= APP.store.getState()['features/base/devices'].videoInput;
const videoDeviceCount
= videoMediaDevices ? videoMediaDevices.length : 0;

View File

@ -16,7 +16,6 @@ import SharedVideoManager from './shared_video/SharedVideo';
import VideoLayout from './videolayout/VideoLayout';
import Filmstrip from './videolayout/Filmstrip';
import { updateDeviceList } from '../../react/features/base/devices';
import { JitsiTrackErrors } from '../../react/features/base/lib-jitsi-meet';
import {
getLocalParticipant,
@ -803,10 +802,8 @@ UI.onLocalRaiseHandChanged = function(isRaisedHand) {
/**
* Update list of available physical devices.
* @param {object[]} devices new list of available devices
*/
UI.onAvailableDevicesChanged = function(devices) {
APP.store.dispatch(updateDeviceList(devices));
UI.onAvailableDevicesChanged = function() {
APP.conference.updateAudioIconEnabled();
APP.conference.updateVideoIconEnabled();
};

View File

@ -2,10 +2,6 @@
import { getAudioOutputDeviceId } from '../../react/features/base/devices';
let currentAudioInputDevices,
currentAudioOutputDevices,
currentVideoInputDevices;
/**
* Determines if currently selected audio output device should be changed after
* list of available devices has been changed.
@ -105,47 +101,6 @@ function getNewVideoInputDevice(newDevices, localVideo) {
}
export default {
/**
* Returns list of devices of single kind.
* @param {MediaDeviceInfo[]} devices
* @param {'audioinput'|'audiooutput'|'videoinput'} kind
* @returns {MediaDeviceInfo[]}
*/
getDevicesFromListByKind(devices, kind) {
return devices.filter(d => d.kind === kind);
},
/**
* Stores lists of current 'audioinput', 'videoinput' and 'audiooutput'
* devices.
* @param {MediaDeviceInfo[]} devices
*/
setCurrentMediaDevices(devices) {
currentAudioInputDevices
= this.getDevicesFromListByKind(devices, 'audioinput');
currentVideoInputDevices
= this.getDevicesFromListByKind(devices, 'videoinput');
currentAudioOutputDevices
= this.getDevicesFromListByKind(devices, 'audiooutput');
},
/**
* Returns lists of current 'audioinput', 'videoinput' and 'audiooutput'
* devices.
* @returns {{
* audioinput: (MediaDeviceInfo[]|undefined),
* videoinput: (MediaDeviceInfo[]|undefined),
* audiooutput: (MediaDeviceInfo[]|undefined),
* }}
*/
getCurrentMediaDevices() {
return {
audioinput: currentAudioInputDevices,
videoinput: currentVideoInputDevices,
audiooutput: currentAudioOutputDevices
};
},
/**
* Determines if currently selected media devices should be changed after
* list of available devices has been changed.