Преглед на файлове

fix(device-selection): Default device change.

master
Hristo Terezov преди 6 години
родител
ревизия
4abc2db24a
променени са 4 файла, в които са добавени 54 реда и са изтрити 42 реда
  1. 30
    2
      conference.js
  2. 9
    6
      modules/devices/mediaDeviceHelper.js
  3. 14
    33
      package-lock.json
  4. 1
    1
      package.json

+ 30
- 2
conference.js Целия файл

@@ -2340,6 +2340,10 @@ export default {
2340 2340
         const promises = [];
2341 2341
         const audioWasMuted = this.isLocalAudioMuted();
2342 2342
         const videoWasMuted = this.isLocalVideoMuted();
2343
+        const requestedInput = {
2344
+            audio: Boolean(newDevices.audioinput),
2345
+            video: Boolean(newDevices.videoinput)
2346
+        };
2343 2347
 
2344 2348
         if (typeof newDevices.audiooutput !== 'undefined') {
2345 2349
             const { dispatch } = APP.store;
@@ -2351,6 +2355,18 @@ export default {
2351 2355
             promises.push(setAudioOutputPromise);
2352 2356
         }
2353 2357
 
2358
+        // Handles the use case when the default device is changed (we are always stopping the streams because it's
2359
+        // simpler):
2360
+        // If the default device is changed we need to first stop the local streams and then call GUM. Otherwise GUM
2361
+        // will return a stream using the old default device.
2362
+        if (requestedInput.audio && this.localAudio) {
2363
+            this.localAudio.stopStream();
2364
+        }
2365
+
2366
+        if (requestedInput.video && this.localVideo) {
2367
+            this.localVideo.stopStream();
2368
+        }
2369
+
2354 2370
         promises.push(
2355 2371
             mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
2356 2372
                     createLocalTracksF,
@@ -2369,8 +2385,20 @@ export default {
2369 2385
                     });
2370 2386
 
2371 2387
                     return Promise.all(muteSyncPromises)
2372
-                        .then(() => Promise.all(
2373
-                            this._setLocalAudioVideoStreams(tracks)));
2388
+                        .then(() =>
2389
+                            Promise.all(Object.keys(requestedInput).map(mediaType => {
2390
+                                if (requestedInput[mediaType]) {
2391
+                                    const useStream
2392
+                                        = mediaType === 'audio'
2393
+                                            ? this.useAudioStream.bind(this)
2394
+                                            : this.useVideoStream.bind(this);
2395
+
2396
+                                    // Use the new stream or null if we failed to obtain it.
2397
+                                    return useStream(tracks.find(track => track.getType() === mediaType) || null);
2398
+                                }
2399
+
2400
+                                return Promise.resolve();
2401
+                            })));
2374 2402
                 })
2375 2403
                 .then(() => {
2376 2404
                     // Log and sync known mute state.

+ 9
- 6
modules/devices/mediaDeviceHelper.js Целия файл

@@ -50,7 +50,9 @@ function getNewAudioInputDevice(newDevices, localAudio) {
50 50
         // If we have new audio device and permission to use it was granted
51 51
         // (label is not an empty string), then we will try to use the first
52 52
         // available device.
53
-        if (availableAudioInputDevices.length
53
+        if (selectedAudioInputDevice && selectedAudioInputDeviceId) {
54
+            return selectedAudioInputDeviceId;
55
+        } else if (availableAudioInputDevices.length
54 56
             && availableAudioInputDevices[0].label !== '') {
55 57
             return availableAudioInputDevices[0].deviceId;
56 58
         }
@@ -87,7 +89,9 @@ function getNewVideoInputDevice(newDevices, localVideo) {
87 89
         // If we have new video device and permission to use it was granted
88 90
         // (label is not an empty string), then we will try to use the first
89 91
         // available device.
90
-        if (availableVideoInputDevices.length
92
+        if (selectedVideoInputDevice && selectedVideoInputDeviceId) {
93
+            return selectedVideoInputDeviceId;
94
+        } else if (availableVideoInputDevices.length
91 95
             && availableVideoInputDevices[0].label !== '') {
92 96
             return availableVideoInputDevices[0].deviceId;
93 97
         }
@@ -121,8 +125,7 @@ export default {
121 125
             localAudio) {
122 126
         return {
123 127
             audioinput: getNewAudioInputDevice(newDevices, localAudio),
124
-            videoinput: !isSharingScreen
125
-                && getNewVideoInputDevice(newDevices, localVideo),
128
+            videoinput: isSharingScreen ? undefined : getNewVideoInputDevice(newDevices, localVideo),
126 129
             audiooutput: getNewAudioOutputDevice(newDevices)
127 130
         };
128 131
     },
@@ -180,7 +183,7 @@ export default {
180 183
         /**
181 184
          *
182 185
          */
183
-        function createAudioTrack(showError) {
186
+        function createAudioTrack(showError = true) {
184 187
             return (
185 188
                 createLocalTracks({
186 189
                     devices: [ 'audio' ],
@@ -198,7 +201,7 @@ export default {
198 201
         /**
199 202
          *
200 203
          */
201
-        function createVideoTrack(showError) {
204
+        function createVideoTrack(showError = true) {
202 205
             return (
203 206
                 createLocalTracks({
204 207
                     devices: [ 'video' ],

+ 14
- 33
package-lock.json Целия файл

@@ -2662,7 +2662,7 @@
2662 2662
         "blueimp-md5": "^2.10.0",
2663 2663
         "json3": "^3.3.2",
2664 2664
         "lodash": "^4.17.4",
2665
-        "ua-parser-js": "github:amplitude/ua-parser-js#ed538f1"
2665
+        "ua-parser-js": "github:amplitude/ua-parser-js#ed538f16f5c6ecd8357da989b617d4f156dcf35d"
2666 2666
       },
2667 2667
       "dependencies": {
2668 2668
         "ua-parser-js": {
@@ -6433,8 +6433,7 @@
6433 6433
         },
6434 6434
         "ansi-regex": {
6435 6435
           "version": "2.1.1",
6436
-          "bundled": true,
6437
-          "optional": true
6436
+          "bundled": true
6438 6437
         },
6439 6438
         "aproba": {
6440 6439
           "version": "1.2.0",
@@ -6452,13 +6451,11 @@
6452 6451
         },
6453 6452
         "balanced-match": {
6454 6453
           "version": "1.0.0",
6455
-          "bundled": true,
6456
-          "optional": true
6454
+          "bundled": true
6457 6455
         },
6458 6456
         "brace-expansion": {
6459 6457
           "version": "1.1.11",
6460 6458
           "bundled": true,
6461
-          "optional": true,
6462 6459
           "requires": {
6463 6460
             "balanced-match": "^1.0.0",
6464 6461
             "concat-map": "0.0.1"
@@ -6471,18 +6468,15 @@
6471 6468
         },
6472 6469
         "code-point-at": {
6473 6470
           "version": "1.1.0",
6474
-          "bundled": true,
6475
-          "optional": true
6471
+          "bundled": true
6476 6472
         },
6477 6473
         "concat-map": {
6478 6474
           "version": "0.0.1",
6479
-          "bundled": true,
6480
-          "optional": true
6475
+          "bundled": true
6481 6476
         },
6482 6477
         "console-control-strings": {
6483 6478
           "version": "1.1.0",
6484
-          "bundled": true,
6485
-          "optional": true
6479
+          "bundled": true
6486 6480
         },
6487 6481
         "core-util-is": {
6488 6482
           "version": "1.0.2",
@@ -6585,8 +6579,7 @@
6585 6579
         },
6586 6580
         "inherits": {
6587 6581
           "version": "2.0.3",
6588
-          "bundled": true,
6589
-          "optional": true
6582
+          "bundled": true
6590 6583
         },
6591 6584
         "ini": {
6592 6585
           "version": "1.3.5",
@@ -6596,7 +6589,6 @@
6596 6589
         "is-fullwidth-code-point": {
6597 6590
           "version": "1.0.0",
6598 6591
           "bundled": true,
6599
-          "optional": true,
6600 6592
           "requires": {
6601 6593
             "number-is-nan": "^1.0.0"
6602 6594
           }
@@ -6609,20 +6601,17 @@
6609 6601
         "minimatch": {
6610 6602
           "version": "3.0.4",
6611 6603
           "bundled": true,
6612
-          "optional": true,
6613 6604
           "requires": {
6614 6605
             "brace-expansion": "^1.1.7"
6615 6606
           }
6616 6607
         },
6617 6608
         "minimist": {
6618 6609
           "version": "0.0.8",
6619
-          "bundled": true,
6620
-          "optional": true
6610
+          "bundled": true
6621 6611
         },
6622 6612
         "minipass": {
6623 6613
           "version": "2.2.4",
6624 6614
           "bundled": true,
6625
-          "optional": true,
6626 6615
           "requires": {
6627 6616
             "safe-buffer": "^5.1.1",
6628 6617
             "yallist": "^3.0.0"
@@ -6639,7 +6628,6 @@
6639 6628
         "mkdirp": {
6640 6629
           "version": "0.5.1",
6641 6630
           "bundled": true,
6642
-          "optional": true,
6643 6631
           "requires": {
6644 6632
             "minimist": "0.0.8"
6645 6633
           }
@@ -6712,8 +6700,7 @@
6712 6700
         },
6713 6701
         "number-is-nan": {
6714 6702
           "version": "1.0.1",
6715
-          "bundled": true,
6716
-          "optional": true
6703
+          "bundled": true
6717 6704
         },
6718 6705
         "object-assign": {
6719 6706
           "version": "4.1.1",
@@ -6723,7 +6710,6 @@
6723 6710
         "once": {
6724 6711
           "version": "1.4.0",
6725 6712
           "bundled": true,
6726
-          "optional": true,
6727 6713
           "requires": {
6728 6714
             "wrappy": "1"
6729 6715
           }
@@ -6799,8 +6785,7 @@
6799 6785
         },
6800 6786
         "safe-buffer": {
6801 6787
           "version": "5.1.1",
6802
-          "bundled": true,
6803
-          "optional": true
6788
+          "bundled": true
6804 6789
         },
6805 6790
         "safer-buffer": {
6806 6791
           "version": "2.1.2",
@@ -6830,7 +6815,6 @@
6830 6815
         "string-width": {
6831 6816
           "version": "1.0.2",
6832 6817
           "bundled": true,
6833
-          "optional": true,
6834 6818
           "requires": {
6835 6819
             "code-point-at": "^1.0.0",
6836 6820
             "is-fullwidth-code-point": "^1.0.0",
@@ -6848,7 +6832,6 @@
6848 6832
         "strip-ansi": {
6849 6833
           "version": "3.0.1",
6850 6834
           "bundled": true,
6851
-          "optional": true,
6852 6835
           "requires": {
6853 6836
             "ansi-regex": "^2.0.0"
6854 6837
           }
@@ -6887,13 +6870,11 @@
6887 6870
         },
6888 6871
         "wrappy": {
6889 6872
           "version": "1.0.2",
6890
-          "bundled": true,
6891
-          "optional": true
6873
+          "bundled": true
6892 6874
         },
6893 6875
         "yallist": {
6894 6876
           "version": "3.0.2",
6895
-          "bundled": true,
6896
-          "optional": true
6877
+          "bundled": true
6897 6878
         }
6898 6879
       }
6899 6880
     },
@@ -8634,8 +8615,8 @@
8634 8615
       }
8635 8616
     },
8636 8617
     "lib-jitsi-meet": {
8637
-      "version": "github:jitsi/lib-jitsi-meet#86e3badd5c04e1df72435205d28a58c8a64e343a",
8638
-      "from": "github:jitsi/lib-jitsi-meet#86e3badd5c04e1df72435205d28a58c8a64e343a",
8618
+      "version": "github:jitsi/lib-jitsi-meet#f6054a887a5d5363681356aff6e79d89343f0bfc",
8619
+      "from": "github:jitsi/lib-jitsi-meet#f6054a887a5d5363681356aff6e79d89343f0bfc",
8639 8620
       "requires": {
8640 8621
         "@jitsi/sdp-interop": "0.1.14",
8641 8622
         "@jitsi/sdp-simulcast": "0.2.1",

+ 1
- 1
package.json Целия файл

@@ -51,7 +51,7 @@
51 51
     "js-utils": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
52 52
     "jsrsasign": "8.0.12",
53 53
     "jwt-decode": "2.2.0",
54
-    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#86e3badd5c04e1df72435205d28a58c8a64e343a",
54
+    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#f6054a887a5d5363681356aff6e79d89343f0bfc",
55 55
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
56 56
     "lodash": "4.17.11",
57 57
     "moment": "2.19.4",

Loading…
Отказ
Запис