瀏覽代碼

Always uses the id for the device extrackted from the track.

When updating the currently used devices always uses the id that is used by the local track instance.
master
damencho 6 年之前
父節點
當前提交
deaf5ba612
共有 1 個檔案被更改,包括 35 行新增23 行删除
  1. 35
    23
      conference.js

+ 35
- 23
conference.js 查看文件

@@ -2094,9 +2094,7 @@ export default {
2094 2094
                 })
2095 2095
                 .then(() => {
2096 2096
                     logger.log('switched local video device');
2097
-                    APP.store.dispatch(updateSettings({
2098
-                        cameraDeviceId
2099
-                    }));
2097
+                    this._updateVideoDeviceId();
2100 2098
                 })
2101 2099
                 .catch(err => {
2102 2100
                     APP.UI.showCameraErrorNotification(err);
@@ -2128,9 +2126,8 @@ export default {
2128 2126
                 .then(stream => {
2129 2127
                     this.useAudioStream(stream);
2130 2128
                     logger.log('switched local audio device');
2131
-                    APP.store.dispatch(updateSettings({
2132
-                        micDeviceId
2133
-                    }));
2129
+
2130
+                    this._updateAudioDeviceId();
2134 2131
                 })
2135 2132
                 .catch(err => {
2136 2133
                     APP.UI.showMicErrorNotification(err);
@@ -2301,18 +2298,9 @@ export default {
2301 2298
                     // Ugly way to synchronize real device IDs with local
2302 2299
                     // storage and settings menu. This is a workaround until
2303 2300
                     // getConstraints() method will be implemented in browsers.
2304
-                    if (this.localAudio) {
2305
-                        dispatch(updateSettings({
2306
-                            micDeviceId: this.localAudio.getDeviceId()
2307
-                        }));
2308
-                    }
2301
+                    this._updateAudioDeviceId();
2309 2302
 
2310
-                    if (this.localVideo
2311
-                        && this.localVideo.videoType === 'camera') {
2312
-                        dispatch(updateSettings({
2313
-                            cameraDeviceId: this.localVideo.getDeviceId()
2314
-                        }));
2315
-                    }
2303
+                    this._updateVideoDeviceId();
2316 2304
 
2317 2305
                     APP.UI.onAvailableDevicesChanged(devices);
2318 2306
                 });
@@ -2321,6 +2309,33 @@ export default {
2321 2309
         return Promise.resolve();
2322 2310
     },
2323 2311
 
2312
+    /**
2313
+     * Updates the settings for the currently used video device, extracting
2314
+     * the device id from the used track.
2315
+     * @private
2316
+     */
2317
+    _updateVideoDeviceId() {
2318
+        if (this.localVideo
2319
+            && this.localVideo.videoType === 'camera') {
2320
+            APP.store.dispatch(updateSettings({
2321
+                cameraDeviceId: this.localVideo.getDeviceId()
2322
+            }));
2323
+        }
2324
+    },
2325
+
2326
+    /**
2327
+     * Updates the settings for the currently used audio device, extracting
2328
+     * the device id from the used track.
2329
+     * @private
2330
+     */
2331
+    _updateAudioDeviceId() {
2332
+        if (this.localAudio) {
2333
+            APP.store.dispatch(updateSettings({
2334
+                micDeviceId: this.localAudio.getDeviceId()
2335
+            }));
2336
+        }
2337
+    },
2338
+
2324 2339
     /**
2325 2340
      * Event listener for JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED to
2326 2341
      * handle change of available media devices.
@@ -2396,12 +2411,9 @@ export default {
2396 2411
                                     // Use the new stream or null if we failed to obtain it.
2397 2412
                                     return useStream(tracks.find(track => track.getType() === mediaType) || null)
2398 2413
                                         .then(() => {
2399
-                                            const settings
2400
-                                                = mediaType === 'audio'
2401
-                                                    ? { micDeviceId: newDevices.audioinput }
2402
-                                                    : { cameraDeviceId: newDevices.videoinput };
2403
-
2404
-                                            APP.store.dispatch(updateSettings(settings));
2414
+                                            mediaType === 'audio'
2415
+                                                ? this._updateAudioDeviceId()
2416
+                                                : this._updateVideoDeviceId();
2405 2417
                                         });
2406 2418
                                 }
2407 2419
 

Loading…
取消
儲存