Browse Source

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
master
virtuacoplenny 6 years ago
parent
commit
4e4755f91e
No account linked to committer's email address
3 changed files with 5 additions and 64 deletions
  1. 4
    15
      conference.js
  2. 1
    4
      modules/UI/UI.js
  3. 0
    45
      modules/devices/mediaDeviceHelper.js

+ 4
- 15
conference.js View File

@@ -2341,9 +2341,8 @@ export default {
2341 2341
                     }));
2342 2342
                 }
2343 2343
 
2344
-                mediaDeviceHelper.setCurrentMediaDevices(devices);
2345
-                APP.UI.onAvailableDevicesChanged(devices);
2346 2344
                 APP.store.dispatch(updateDeviceList(devices));
2345
+                APP.UI.onAvailableDevicesChanged(devices);
2347 2346
             });
2348 2347
 
2349 2348
             this.deviceChangeListener = devices =>
@@ -2362,16 +2361,7 @@ export default {
2362 2361
      * @returns {Promise}
2363 2362
      */
2364 2363
     _onDeviceListChanged(devices) {
2365
-        let currentDevices = mediaDeviceHelper.getCurrentMediaDevices();
2366
-
2367
-        // Event handler can be fired before direct
2368
-        // enumerateDevices() call, so handle this situation here.
2369
-        if (!currentDevices.audioinput
2370
-            && !currentDevices.videoinput
2371
-            && !currentDevices.audiooutput) {
2372
-            mediaDeviceHelper.setCurrentMediaDevices(devices);
2373
-            currentDevices = mediaDeviceHelper.getCurrentMediaDevices();
2374
-        }
2364
+        APP.store.dispatch(updateDeviceList(devices));
2375 2365
 
2376 2366
         const newDevices
2377 2367
             = mediaDeviceHelper.getNewMediaDevicesAfterDeviceListChanged(
@@ -2420,7 +2410,6 @@ export default {
2420 2410
 
2421 2411
         return Promise.all(promises)
2422 2412
             .then(() => {
2423
-                mediaDeviceHelper.setCurrentMediaDevices(devices);
2424 2413
                 APP.UI.onAvailableDevicesChanged(devices);
2425 2414
             });
2426 2415
     },
@@ -2430,7 +2419,7 @@ export default {
2430 2419
      */
2431 2420
     updateAudioIconEnabled() {
2432 2421
         const audioMediaDevices
2433
-            = mediaDeviceHelper.getCurrentMediaDevices().audioinput;
2422
+            = APP.store.getState()['features/base/devices'].audioInput;
2434 2423
         const audioDeviceCount
2435 2424
             = audioMediaDevices ? audioMediaDevices.length : 0;
2436 2425
 
@@ -2453,7 +2442,7 @@ export default {
2453 2442
      */
2454 2443
     updateVideoIconEnabled() {
2455 2444
         const videoMediaDevices
2456
-            = mediaDeviceHelper.getCurrentMediaDevices().videoinput;
2445
+            = APP.store.getState()['features/base/devices'].videoInput;
2457 2446
         const videoDeviceCount
2458 2447
             = videoMediaDevices ? videoMediaDevices.length : 0;
2459 2448
 

+ 1
- 4
modules/UI/UI.js View File

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

+ 0
- 45
modules/devices/mediaDeviceHelper.js View File

@@ -2,10 +2,6 @@
2 2
 
3 3
 import { getAudioOutputDeviceId } from '../../react/features/base/devices';
4 4
 
5
-let currentAudioInputDevices,
6
-    currentAudioOutputDevices,
7
-    currentVideoInputDevices;
8
-
9 5
 /**
10 6
  * Determines if currently selected audio output device should be changed after
11 7
  * list of available devices has been changed.
@@ -105,47 +101,6 @@ function getNewVideoInputDevice(newDevices, localVideo) {
105 101
 }
106 102
 
107 103
 export default {
108
-    /**
109
-     * Returns list of devices of single kind.
110
-     * @param {MediaDeviceInfo[]} devices
111
-     * @param {'audioinput'|'audiooutput'|'videoinput'} kind
112
-     * @returns {MediaDeviceInfo[]}
113
-     */
114
-    getDevicesFromListByKind(devices, kind) {
115
-        return devices.filter(d => d.kind === kind);
116
-    },
117
-
118
-    /**
119
-     * Stores lists of current 'audioinput', 'videoinput' and 'audiooutput'
120
-     * devices.
121
-     * @param {MediaDeviceInfo[]} devices
122
-     */
123
-    setCurrentMediaDevices(devices) {
124
-        currentAudioInputDevices
125
-            = this.getDevicesFromListByKind(devices, 'audioinput');
126
-        currentVideoInputDevices
127
-            = this.getDevicesFromListByKind(devices, 'videoinput');
128
-        currentAudioOutputDevices
129
-            = this.getDevicesFromListByKind(devices, 'audiooutput');
130
-    },
131
-
132
-    /**
133
-     * Returns lists of current 'audioinput', 'videoinput' and 'audiooutput'
134
-     * devices.
135
-     * @returns {{
136
-     *  audioinput: (MediaDeviceInfo[]|undefined),
137
-     *  videoinput: (MediaDeviceInfo[]|undefined),
138
-     *  audiooutput: (MediaDeviceInfo[]|undefined),
139
-     *  }}
140
-     */
141
-    getCurrentMediaDevices() {
142
-        return {
143
-            audioinput: currentAudioInputDevices,
144
-            videoinput: currentVideoInputDevices,
145
-            audiooutput: currentAudioOutputDevices
146
-        };
147
-    },
148
-
149 104
     /**
150 105
      * Determines if currently selected media devices should be changed after
151 106
      * list of available devices has been changed.

Loading…
Cancel
Save