Procházet zdrojové kódy

fix(device-selection): Default device change.

master
Hristo Terezov před 6 roky
rodič
revize
4abc2db24a
4 změnil soubory, kde provedl 54 přidání a 42 odebrání
  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 Zobrazit soubor

2340
         const promises = [];
2340
         const promises = [];
2341
         const audioWasMuted = this.isLocalAudioMuted();
2341
         const audioWasMuted = this.isLocalAudioMuted();
2342
         const videoWasMuted = this.isLocalVideoMuted();
2342
         const videoWasMuted = this.isLocalVideoMuted();
2343
+        const requestedInput = {
2344
+            audio: Boolean(newDevices.audioinput),
2345
+            video: Boolean(newDevices.videoinput)
2346
+        };
2343
 
2347
 
2344
         if (typeof newDevices.audiooutput !== 'undefined') {
2348
         if (typeof newDevices.audiooutput !== 'undefined') {
2345
             const { dispatch } = APP.store;
2349
             const { dispatch } = APP.store;
2351
             promises.push(setAudioOutputPromise);
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
         promises.push(
2370
         promises.push(
2355
             mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
2371
             mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
2356
                     createLocalTracksF,
2372
                     createLocalTracksF,
2369
                     });
2385
                     });
2370
 
2386
 
2371
                     return Promise.all(muteSyncPromises)
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
                 .then(() => {
2403
                 .then(() => {
2376
                     // Log and sync known mute state.
2404
                     // Log and sync known mute state.

+ 9
- 6
modules/devices/mediaDeviceHelper.js Zobrazit soubor

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

+ 14
- 33
package-lock.json Zobrazit soubor

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

+ 1
- 1
package.json Zobrazit soubor

51
     "js-utils": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
51
     "js-utils": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
52
     "jsrsasign": "8.0.12",
52
     "jsrsasign": "8.0.12",
53
     "jwt-decode": "2.2.0",
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
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
55
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
56
     "lodash": "4.17.11",
56
     "lodash": "4.17.11",
57
     "moment": "2.19.4",
57
     "moment": "2.19.4",

Načítá se…
Zrušit
Uložit