From c05b4a43e84cae9c7fdb9f2215f0784f2386bfbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 28 Jan 2020 11:06:03 +0100 Subject: [PATCH] rn,tracks: do not load stream effects on mobile --- react/features/base/tracks/functions.js | 26 ++------------ .../base/tracks/loadEffects.native.js | 11 ++++++ react/features/base/tracks/loadEffects.web.js | 35 +++++++++++++++++++ 3 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 react/features/base/tracks/loadEffects.native.js create mode 100644 react/features/base/tracks/loadEffects.web.js diff --git a/react/features/base/tracks/functions.js b/react/features/base/tracks/functions.js index 1d7e78a2a..9d8a59dca 100644 --- a/react/features/base/tracks/functions.js +++ b/react/features/base/tracks/functions.js @@ -1,7 +1,5 @@ /* global APP */ -import { createScreenshotCaptureEffect } from '../../stream-effects/screenshot-capture'; -import { getBlurEffect } from '../../blur'; import JitsiMeetJS, { JitsiTrackErrors, browser } from '../lib-jitsi-meet'; import { MEDIA_TYPE } from '../media'; import { @@ -9,6 +7,7 @@ import { getUserSelectedMicDeviceId } from '../settings'; +import loadEffects from './loadEffects'; import logger from './logger'; /** @@ -94,29 +93,10 @@ export function createLocalTracksF(options = {}, firePermissionPromptIsShownEven firefox_fake_device, // eslint-disable-line camelcase resolution } = state['features/base/config']; - const constraints = options.constraints - ?? state['features/base/config'].constraints; - - const blurPromise = state['features/blur'].blurEnabled - ? getBlurEffect() - .catch(error => { - logger.error('Failed to obtain the blur effect instance with error: ', error); - - return Promise.resolve(); - }) - : Promise.resolve(); - const screenshotCapturePromise = state['features/screenshot-capture']?.capturesEnabled - ? createScreenshotCaptureEffect(state) - .catch(error => { - logger.error('Failed to obtain the screenshot capture effect effect instance with error: ', error); - - return Promise.resolve(); - }) - : Promise.resolve(); - const loadEffectsPromise = Promise.all([ blurPromise, screenshotCapturePromise ]); + const constraints = options.constraints ?? state['features/base/config'].constraints; return ( - loadEffectsPromise.then(effectsArray => { + loadEffects(store).then(effectsArray => { // Filter any undefined values returned by Promise.resolve(). const effects = effectsArray.filter(effect => Boolean(effect)); diff --git a/react/features/base/tracks/loadEffects.native.js b/react/features/base/tracks/loadEffects.native.js new file mode 100644 index 000000000..339896e7c --- /dev/null +++ b/react/features/base/tracks/loadEffects.native.js @@ -0,0 +1,11 @@ +// @flow + +/** + * Loads the enabled stream effects. + * + * @param {Object} store - The Redux store. + * @returns {Promsie} - A Promise which resolves when all effects are created. + */ +export default function loadEffects(store: Object): Promise { // eslint-disable-line no-unused-vars + return Promise.resolve(); +} diff --git a/react/features/base/tracks/loadEffects.web.js b/react/features/base/tracks/loadEffects.web.js new file mode 100644 index 000000000..c25acd3a2 --- /dev/null +++ b/react/features/base/tracks/loadEffects.web.js @@ -0,0 +1,35 @@ +// @flow + +import { createScreenshotCaptureEffect } from '../../stream-effects/screenshot-capture'; +import { getBlurEffect } from '../../blur'; + +import logger from './logger'; + +/** + * Loads the enabled stream effects. + * + * @param {Object} store - The Redux store. + * @returns {Promsie} - A Promise which resolves when all effects are created. + */ +export default function loadEffects(store: Object): Promise { + const state = store.getState(); + + const blurPromise = state['features/blur'].blurEnabled + ? getBlurEffect() + .catch(error => { + logger.error('Failed to obtain the blur effect instance with error: ', error); + + return Promise.resolve(); + }) + : Promise.resolve(); + const screenshotCapturePromise = state['features/screenshot-capture']?.capturesEnabled + ? createScreenshotCaptureEffect(state) + .catch(error => { + logger.error('Failed to obtain the screenshot capture effect effect instance with error: ', error); + + return Promise.resolve(); + }) + : Promise.resolve(); + + return Promise.all([ blurPromise, screenshotCapturePromise ]); +}