fix(blur): when switching video tracks.

This commit is contained in:
Hristo Terezov 2019-07-08 11:59:23 +01:00
parent 8f79779ca7
commit f030a3f1fb
2 changed files with 69 additions and 75 deletions

View File

@ -106,7 +106,6 @@ import {
trackRemoved trackRemoved
} from './react/features/base/tracks'; } from './react/features/base/tracks';
import { getJitsiMeetGlobalNS } from './react/features/base/util'; import { getJitsiMeetGlobalNS } from './react/features/base/util';
import { getBlurEffect } from './react/features/blur';
import { addMessage } from './react/features/chat'; import { addMessage } from './react/features/chat';
import { showDesktopPicker } from './react/features/desktop-picker'; import { showDesktopPicker } from './react/features/desktop-picker';
import { appendSuffix } from './react/features/display-name'; import { appendSuffix } from './react/features/display-name';
@ -560,63 +559,47 @@ export default {
// Resolve with no tracks // Resolve with no tracks
tryCreateLocalTracks = Promise.resolve([]); tryCreateLocalTracks = Promise.resolve([]);
} else { } else {
const loadEffectsPromise = options.startWithBlurEnabled tryCreateLocalTracks = createLocalTracksF({ devices: initialDevices }, true)
? getBlurEffect() .catch(err => {
.then(blurEffect => [ blurEffect ]) if (requestedAudio && requestedVideo) {
.catch(error => {
logger.error('Failed to obtain the blur effect instance with error: ', error);
return Promise.resolve([]); // Try audio only...
}) audioAndVideoError = err;
: Promise.resolve([]);
tryCreateLocalTracks = loadEffectsPromise.then(trackEffects => return (
createLocalTracksF( createLocalTracksF({ devices: [ 'audio' ] }, true));
{ } else if (requestedAudio && !requestedVideo) {
devices: initialDevices,
effects: trackEffects
}, true)
.catch(err => {
if (requestedAudio && requestedVideo) {
// Try audio only...
audioAndVideoError = err;
return (
createLocalTracksF({ devices: [ 'audio' ] }, true));
} else if (requestedAudio && !requestedVideo) {
audioOnlyError = err;
return [];
} else if (requestedVideo && !requestedAudio) {
videoOnlyError = err;
return [];
}
logger.error('Should never happen');
})
.catch(err => {
// Log this just in case...
if (!requestedAudio) {
logger.error('The impossible just happened', err);
}
audioOnlyError = err; audioOnlyError = err;
// Try video only... return [];
return requestedVideo } else if (requestedVideo && !requestedAudio) {
? createLocalTracksF({ devices: [ 'video' ] }, true)
: [];
})
.catch(err => {
// Log this just in case...
if (!requestedVideo) {
logger.error('The impossible just happened', err);
}
videoOnlyError = err; videoOnlyError = err;
return []; return [];
}) }
); logger.error('Should never happen');
})
.catch(err => {
// Log this just in case...
if (!requestedAudio) {
logger.error('The impossible just happened', err);
}
audioOnlyError = err;
// Try video only...
return requestedVideo
? createLocalTracksF({ devices: [ 'video' ] }, true)
: [];
})
.catch(err => {
// Log this just in case...
if (!requestedVideo) {
logger.error('The impossible just happened', err);
}
videoOnlyError = err;
return [];
});
} }
// Hide the permissions prompt/overlay as soon as the tracks are // Hide the permissions prompt/overlay as soon as the tracks are
@ -678,7 +661,6 @@ export default {
'initial device list initialization failed', error)) 'initial device list initialization failed', error))
.then(() => this.createInitialLocalTracksAndConnect( .then(() => this.createInitialLocalTracksAndConnect(
options.roomName, { options.roomName, {
startWithBlurEnabled: APP.store.getState()['features/blur'].blurEnabled,
startAudioOnly: config.startAudioOnly, startAudioOnly: config.startAudioOnly,
startScreenSharing: config.startScreenSharing, startScreenSharing: config.startScreenSharing,
startWithAudioMuted: config.startWithAudioMuted || config.startSilent, startWithAudioMuted: config.startWithAudioMuted || config.startSilent,

View File

@ -1,5 +1,6 @@
/* global APP */ /* global APP */
import { getBlurEffect } from '../../blur';
import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet'; import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet';
import { MEDIA_TYPE } from '../media'; import { MEDIA_TYPE } from '../media';
import { import {
@ -50,38 +51,49 @@ export function createLocalTracksF(
} }
} }
const state = store.getState();
const { const {
constraints, constraints,
desktopSharingFrameRate, desktopSharingFrameRate,
firefox_fake_device, // eslint-disable-line camelcase firefox_fake_device, // eslint-disable-line camelcase
resolution resolution
} = store.getState()['features/base/config']; } = state['features/base/config'];
const loadEffectsPromise = state['features/blur'].blurEnabled
? getBlurEffect()
.then(blurEffect => [ blurEffect ])
.catch(error => {
logger.error('Failed to obtain the blur effect instance with error: ', error);
return Promise.resolve([]);
})
: Promise.resolve([]);
return ( return (
JitsiMeetJS.createLocalTracks( loadEffectsPromise.then(effects =>
{ JitsiMeetJS.createLocalTracks(
cameraDeviceId, {
constraints, cameraDeviceId,
desktopSharingExtensionExternalInstallation: constraints,
options.desktopSharingExtensionExternalInstallation, desktopSharingExtensionExternalInstallation:
desktopSharingFrameRate, options.desktopSharingExtensionExternalInstallation,
desktopSharingSourceDevice: desktopSharingFrameRate,
options.desktopSharingSourceDevice, desktopSharingSourceDevice:
desktopSharingSources: options.desktopSharingSources, options.desktopSharingSourceDevice,
desktopSharingSources: options.desktopSharingSources,
// Copy array to avoid mutations inside library. // Copy array to avoid mutations inside library.
devices: options.devices.slice(0), devices: options.devices.slice(0),
effects: options.effects, effects,
firefox_fake_device, // eslint-disable-line camelcase firefox_fake_device, // eslint-disable-line camelcase
micDeviceId, micDeviceId,
resolution resolution
}, },
firePermissionPromptIsShownEvent) firePermissionPromptIsShownEvent)
.catch(err => { .catch(err => {
logger.error('Failed to create local tracks', options.devices, err); logger.error('Failed to create local tracks', options.devices, err);
return Promise.reject(err); return Promise.reject(err);
})); })));
} }
/** /**