Sfoglia il codice sorgente

Merge pull request #2077 from jitsi/device-changes

Fixes few changes around changing devices
j8
virtuacoplenny 8 anni fa
parent
commit
205822ac31
2 ha cambiato i file con 28 aggiunte e 14 eliminazioni
  1. 27
    13
      conference.js
  2. 1
    1
      react/features/base/tracks/actions.js

+ 27
- 13
conference.js Vedi File

2176
         APP.UI.addListener(
2176
         APP.UI.addListener(
2177
             UIEvents.VIDEO_DEVICE_CHANGED,
2177
             UIEvents.VIDEO_DEVICE_CHANGED,
2178
             cameraDeviceId => {
2178
             cameraDeviceId => {
2179
+                const videoWasMuted = this.isLocalVideoMuted();
2180
+
2179
                 sendAnalyticsEvent('settings.changeDevice.video');
2181
                 sendAnalyticsEvent('settings.changeDevice.video');
2180
                 createLocalTracksF({
2182
                 createLocalTracksF({
2181
                     devices: [ 'video' ],
2183
                     devices: [ 'video' ],
2183
                     micDeviceId: null
2185
                     micDeviceId: null
2184
                 })
2186
                 })
2185
                 .then(([ stream ]) => {
2187
                 .then(([ stream ]) => {
2186
-                    if (this.isAudioOnly()) {
2188
+                    // if we are in audio only mode or video was muted before
2189
+                    // changing device, then mute
2190
+                    if (this.isAudioOnly() || videoWasMuted) {
2187
                         return stream.mute()
2191
                         return stream.mute()
2188
                             .then(() => stream);
2192
                             .then(() => stream);
2189
                     }
2193
                     }
2191
                     return stream;
2195
                     return stream;
2192
                 })
2196
                 })
2193
                 .then(stream => {
2197
                 .then(stream => {
2194
-                    this.useVideoStream(stream);
2198
+                    // if we are screen sharing we do not want to stop it
2199
+                    if (this.isSharingScreen) {
2200
+                        return Promise.resolve();
2201
+                    }
2202
+
2203
+                    return this.useVideoStream(stream);
2204
+                })
2205
+                .then(() => {
2195
                     logger.log('switched local video device');
2206
                     logger.log('switched local video device');
2196
                     APP.settings.setCameraDeviceId(cameraDeviceId, true);
2207
                     APP.settings.setCameraDeviceId(cameraDeviceId, true);
2197
                 })
2208
                 })
2204
         APP.UI.addListener(
2215
         APP.UI.addListener(
2205
             UIEvents.AUDIO_DEVICE_CHANGED,
2216
             UIEvents.AUDIO_DEVICE_CHANGED,
2206
             micDeviceId => {
2217
             micDeviceId => {
2218
+                const audioWasMuted = this.isLocalAudioMuted();
2219
+
2207
                 sendAnalyticsEvent(
2220
                 sendAnalyticsEvent(
2208
                     'settings.changeDevice.audioIn');
2221
                     'settings.changeDevice.audioIn');
2209
                 createLocalTracksF({
2222
                 createLocalTracksF({
2212
                     micDeviceId
2225
                     micDeviceId
2213
                 })
2226
                 })
2214
                 .then(([ stream ]) => {
2227
                 .then(([ stream ]) => {
2228
+                    // if audio was muted before changing the device, mute
2229
+                    // with the new device
2230
+                    if (audioWasMuted) {
2231
+                        return stream.mute()
2232
+                            .then(() => stream);
2233
+                    }
2234
+
2235
+                    return stream;
2236
+                })
2237
+                .then(stream => {
2215
                     this.useAudioStream(stream);
2238
                     this.useAudioStream(stream);
2216
                     logger.log('switched local audio device');
2239
                     logger.log('switched local audio device');
2217
                     APP.settings.setMicDeviceId(micDeviceId, true);
2240
                     APP.settings.setMicDeviceId(micDeviceId, true);
2408
         const promises = [];
2431
         const promises = [];
2409
         const audioWasMuted = this.isLocalAudioMuted();
2432
         const audioWasMuted = this.isLocalAudioMuted();
2410
         const videoWasMuted = this.isLocalVideoMuted();
2433
         const videoWasMuted = this.isLocalVideoMuted();
2411
-        const availableAudioInputDevices
2412
-            = mediaDeviceHelper.getDevicesFromListByKind(devices, 'audioinput');
2413
-        const availableVideoInputDevices
2414
-            = mediaDeviceHelper.getDevicesFromListByKind(devices, 'videoinput');
2415
 
2434
 
2416
         if (typeof newDevices.audiooutput !== 'undefined') {
2435
         if (typeof newDevices.audiooutput !== 'undefined') {
2417
             // Just ignore any errors in catch block.
2436
             // Just ignore any errors in catch block.
2430
                 .then(() => {
2449
                 .then(() => {
2431
                     // If audio was muted before, or we unplugged current device
2450
                     // If audio was muted before, or we unplugged current device
2432
                     // and selected new one, then mute new audio track.
2451
                     // and selected new one, then mute new audio track.
2433
-                    if (audioWasMuted
2434
-                        || currentDevices.audioinput.length
2435
-                        > availableAudioInputDevices.length) {
2452
+                    if (audioWasMuted) {
2436
                         sendAnalyticsEvent('deviceListChanged.audio.muted');
2453
                         sendAnalyticsEvent('deviceListChanged.audio.muted');
2437
                         logger.log('Audio mute: device list changed');
2454
                         logger.log('Audio mute: device list changed');
2438
                         muteLocalAudio(true);
2455
                         muteLocalAudio(true);
2440
 
2457
 
2441
                     // If video was muted before, or we unplugged current device
2458
                     // If video was muted before, or we unplugged current device
2442
                     // and selected new one, then mute new video track.
2459
                     // and selected new one, then mute new video track.
2443
-                    if (!this.isSharingScreen
2444
-                        && (videoWasMuted
2445
-                            || currentDevices.videoinput.length
2446
-                                > availableVideoInputDevices.length)) {
2460
+                    if (!this.isSharingScreen && videoWasMuted) {
2447
                         sendAnalyticsEvent('deviceListChanged.video.muted');
2461
                         sendAnalyticsEvent('deviceListChanged.video.muted');
2448
                         logger.log('Video mute: device list changed');
2462
                         logger.log('Video mute: device list changed');
2449
                         muteLocalVideo(true);
2463
                         muteLocalVideo(true);

+ 1
- 1
react/features/base/tracks/actions.js Vedi File

165
                             logger.log(`Replace ${newTrack.getType()} track - ${
165
                             logger.log(`Replace ${newTrack.getType()} track - ${
166
                                 isMuted ? 'muted' : 'unmuted'}`);
166
                                 isMuted ? 'muted' : 'unmuted'}`);
167
 
167
 
168
-                            return dispatch(setMuted());
168
+                            return dispatch(setMuted(isMuted));
169
                         }
169
                         }
170
                     })
170
                     })
171
                     .then(() => {
171
                     .then(() => {

Loading…
Annulla
Salva