Преглед изворни кода

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
     trackRemoved
106
     trackRemoved
107
 } from './react/features/base/tracks';
107
 } from './react/features/base/tracks';
108
 import { getJitsiMeetGlobalNS } from './react/features/base/util';
108
 import { getJitsiMeetGlobalNS } from './react/features/base/util';
109
-import { getBlurEffect } from './react/features/blur';
110
 import { addMessage } from './react/features/chat';
109
 import { addMessage } from './react/features/chat';
111
 import { showDesktopPicker } from './react/features/desktop-picker';
110
 import { showDesktopPicker } from './react/features/desktop-picker';
112
 import { appendSuffix } from './react/features/display-name';
111
 import { appendSuffix } from './react/features/display-name';
560
             // Resolve with no tracks
559
             // Resolve with no tracks
561
             tryCreateLocalTracks = Promise.resolve([]);
560
             tryCreateLocalTracks = Promise.resolve([]);
562
         } else {
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
                         audioOnlyError = err;
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
                         videoOnlyError = err;
576
                         videoOnlyError = err;
616
 
577
 
617
                         return [];
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
         // Hide the permissions prompt/overlay as soon as the tracks are
605
         // Hide the permissions prompt/overlay as soon as the tracks are
678
                     'initial device list initialization failed', error))
661
                     'initial device list initialization failed', error))
679
                 .then(() => this.createInitialLocalTracksAndConnect(
662
                 .then(() => this.createInitialLocalTracksAndConnect(
680
                 options.roomName, {
663
                 options.roomName, {
681
-                    startWithBlurEnabled: APP.store.getState()['features/blur'].blurEnabled,
682
                     startAudioOnly: config.startAudioOnly,
664
                     startAudioOnly: config.startAudioOnly,
683
                     startScreenSharing: config.startScreenSharing,
665
                     startScreenSharing: config.startScreenSharing,
684
                     startWithAudioMuted: config.startWithAudioMuted || config.startSilent,
666
                     startWithAudioMuted: config.startWithAudioMuted || config.startSilent,

+ 37
- 25
react/features/base/tracks/functions.js Прегледај датотеку

1
 /* global APP */
1
 /* global APP */
2
 
2
 
3
+import { getBlurEffect } from '../../blur';
3
 import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet';
4
 import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet';
4
 import { MEDIA_TYPE } from '../media';
5
 import { MEDIA_TYPE } from '../media';
5
 import {
6
 import {
50
         }
51
         }
51
     }
52
     }
52
 
53
 
54
+    const state = store.getState();
53
     const {
55
     const {
54
         constraints,
56
         constraints,
55
         desktopSharingFrameRate,
57
         desktopSharingFrameRate,
56
         firefox_fake_device, // eslint-disable-line camelcase
58
         firefox_fake_device, // eslint-disable-line camelcase
57
         resolution
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
     return (
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
 /**

Loading…
Откажи
Сачувај