浏览代码

fix(blur): when switching video tracks.

master
Hristo Terezov 6 年前
父节点
当前提交
f030a3f1fb
共有 2 个文件被更改,包括 71 次插入77 次删除
  1. 34
    52
      conference.js
  2. 37
    25
      react/features/base/tracks/functions.js

+ 34
- 52
conference.js 查看文件

@@ -106,7 +106,6 @@ import {
106 106
     trackRemoved
107 107
 } from './react/features/base/tracks';
108 108
 import { getJitsiMeetGlobalNS } from './react/features/base/util';
109
-import { getBlurEffect } from './react/features/blur';
110 109
 import { addMessage } from './react/features/chat';
111 110
 import { showDesktopPicker } from './react/features/desktop-picker';
112 111
 import { appendSuffix } from './react/features/display-name';
@@ -560,63 +559,47 @@ export default {
560 559
             // Resolve with no tracks
561 560
             tryCreateLocalTracks = Promise.resolve([]);
562 561
         } else {
563
-            const loadEffectsPromise = options.startWithBlurEnabled
564
-                ? getBlurEffect()
565
-                    .then(blurEffect => [ blurEffect ])
566
-                    .catch(error => {
567
-                        logger.error('Failed to obtain the blur effect instance with error: ', error);
568
-
569
-                        return Promise.resolve([]);
570
-                    })
571
-                : Promise.resolve([]);
572
-
573
-            tryCreateLocalTracks = loadEffectsPromise.then(trackEffects =>
574
-                createLocalTracksF(
575
-                    {
576
-                        devices: initialDevices,
577
-                        effects: trackEffects
578
-                    }, true)
579
-                    .catch(err => {
580
-                        if (requestedAudio && requestedVideo) {
581
-
582
-                            // Try audio only...
583
-                            audioAndVideoError = err;
584
-
585
-                            return (
586
-                                createLocalTracksF({ devices: [ 'audio' ] }, true));
587
-                        } else if (requestedAudio && !requestedVideo) {
588
-                            audioOnlyError = err;
562
+            tryCreateLocalTracks = createLocalTracksF({ devices: initialDevices }, true)
563
+                .catch(err => {
564
+                    if (requestedAudio && requestedVideo) {
589 565
 
590
-                            return [];
591
-                        } else if (requestedVideo && !requestedAudio) {
592
-                            videoOnlyError = err;
566
+                        // Try audio only...
567
+                        audioAndVideoError = err;
593 568
 
594
-                            return [];
595
-                        }
596
-                        logger.error('Should never happen');
597
-                    })
598
-                    .catch(err => {
599
-                        // Log this just in case...
600
-                        if (!requestedAudio) {
601
-                            logger.error('The impossible just happened', err);
602
-                        }
569
+                        return (
570
+                            createLocalTracksF({ devices: [ 'audio' ] }, true));
571
+                    } else if (requestedAudio && !requestedVideo) {
603 572
                         audioOnlyError = err;
604 573
 
605
-                        // Try video only...
606
-                        return requestedVideo
607
-                            ? createLocalTracksF({ devices: [ 'video' ] }, true)
608
-                            : [];
609
-                    })
610
-                    .catch(err => {
611
-                        // Log this just in case...
612
-                        if (!requestedVideo) {
613
-                            logger.error('The impossible just happened', err);
614
-                        }
574
+                        return [];
575
+                    } else if (requestedVideo && !requestedAudio) {
615 576
                         videoOnlyError = err;
616 577
 
617 578
                         return [];
618
-                    })
619
-            );
579
+                    }
580
+                    logger.error('Should never happen');
581
+                })
582
+                .catch(err => {
583
+                    // Log this just in case...
584
+                    if (!requestedAudio) {
585
+                        logger.error('The impossible just happened', err);
586
+                    }
587
+                    audioOnlyError = err;
588
+
589
+                    // Try video only...
590
+                    return requestedVideo
591
+                        ? createLocalTracksF({ devices: [ 'video' ] }, true)
592
+                        : [];
593
+                })
594
+                .catch(err => {
595
+                    // Log this just in case...
596
+                    if (!requestedVideo) {
597
+                        logger.error('The impossible just happened', err);
598
+                    }
599
+                    videoOnlyError = err;
600
+
601
+                    return [];
602
+                });
620 603
         }
621 604
 
622 605
         // Hide the permissions prompt/overlay as soon as the tracks are
@@ -678,7 +661,6 @@ export default {
678 661
                     'initial device list initialization failed', error))
679 662
                 .then(() => this.createInitialLocalTracksAndConnect(
680 663
                 options.roomName, {
681
-                    startWithBlurEnabled: APP.store.getState()['features/blur'].blurEnabled,
682 664
                     startAudioOnly: config.startAudioOnly,
683 665
                     startScreenSharing: config.startScreenSharing,
684 666
                     startWithAudioMuted: config.startWithAudioMuted || config.startSilent,

+ 37
- 25
react/features/base/tracks/functions.js 查看文件

@@ -1,5 +1,6 @@
1 1
 /* global APP */
2 2
 
3
+import { getBlurEffect } from '../../blur';
3 4
 import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet';
4 5
 import { MEDIA_TYPE } from '../media';
5 6
 import {
@@ -50,38 +51,49 @@ export function createLocalTracksF(
50 51
         }
51 52
     }
52 53
 
54
+    const state = store.getState();
53 55
     const {
54 56
         constraints,
55 57
         desktopSharingFrameRate,
56 58
         firefox_fake_device, // eslint-disable-line camelcase
57 59
         resolution
58
-    } = store.getState()['features/base/config'];
60
+    } = state['features/base/config'];
61
+    const loadEffectsPromise = state['features/blur'].blurEnabled
62
+        ? getBlurEffect()
63
+            .then(blurEffect => [ blurEffect ])
64
+            .catch(error => {
65
+                logger.error('Failed to obtain the blur effect instance with error: ', error);
66
+
67
+                return Promise.resolve([]);
68
+            })
69
+        : Promise.resolve([]);
59 70
 
60 71
     return (
61
-        JitsiMeetJS.createLocalTracks(
62
-            {
63
-                cameraDeviceId,
64
-                constraints,
65
-                desktopSharingExtensionExternalInstallation:
66
-                    options.desktopSharingExtensionExternalInstallation,
67
-                desktopSharingFrameRate,
68
-                desktopSharingSourceDevice:
69
-                    options.desktopSharingSourceDevice,
70
-                desktopSharingSources: options.desktopSharingSources,
71
-
72
-                // Copy array to avoid mutations inside library.
73
-                devices: options.devices.slice(0),
74
-                effects: options.effects,
75
-                firefox_fake_device, // eslint-disable-line camelcase
76
-                micDeviceId,
77
-                resolution
78
-            },
79
-            firePermissionPromptIsShownEvent)
80
-        .catch(err => {
81
-            logger.error('Failed to create local tracks', options.devices, err);
82
-
83
-            return Promise.reject(err);
84
-        }));
72
+        loadEffectsPromise.then(effects =>
73
+            JitsiMeetJS.createLocalTracks(
74
+                {
75
+                    cameraDeviceId,
76
+                    constraints,
77
+                    desktopSharingExtensionExternalInstallation:
78
+                        options.desktopSharingExtensionExternalInstallation,
79
+                    desktopSharingFrameRate,
80
+                    desktopSharingSourceDevice:
81
+                        options.desktopSharingSourceDevice,
82
+                    desktopSharingSources: options.desktopSharingSources,
83
+
84
+                    // Copy array to avoid mutations inside library.
85
+                    devices: options.devices.slice(0),
86
+                    effects,
87
+                    firefox_fake_device, // eslint-disable-line camelcase
88
+                    micDeviceId,
89
+                    resolution
90
+                },
91
+                firePermissionPromptIsShownEvent)
92
+            .catch(err => {
93
+                logger.error('Failed to create local tracks', options.devices, err);
94
+
95
+                return Promise.reject(err);
96
+            })));
85 97
 }
86 98
 
87 99
 /**

正在加载...
取消
保存