Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] Disable remote video while in the background
Saúl Ibarra Corretgé2d5f0479bdfc
diff --git a/react/features/background/actionTypes.js b/react/features/background/actionTypes.jsindex f126ace50c..7f7323e0a3 100644--- a/react/features/background/actionTypes.js+++ b/react/features/background/actionTypes.js@@ -27,6 +27,21 @@ export const _SET_APP_STATE_LISTENERexport const _SET_BACKGROUND_VIDEO_MUTED= Symbol('_SET_BACKGROUND_VIDEO_MUTED');+/**+ * The type of redux action which signals that the video channel's lastN value+ * must be changed.+ *+ * {+ * type: _SET_LASTN,+ * lastN: boolean+ * }+ *+ * @protected+ */+export const _SET_LASTN+ = Symbol('_SET_LASTN');++/*** The type of redux action which signals that the app state has changed (in* terms of execution mode). The app state can be one of 'active', 'inactive',diff --git a/react/features/background/actions.js b/react/features/background/actions.jsindex e0ddf4136f..4723fed46c 100644--- a/react/features/background/actions.js+++ b/react/features/background/actions.js@@ -3,6 +3,7 @@ import { setVideoMuted } from '../base/media';import {_SET_APP_STATE_LISTENER,_SET_BACKGROUND_VIDEO_MUTED,+ _SET_LASTN,APP_STATE_CHANGED} from './actionTypes';@@ -54,6 +55,23 @@ export function _setAppStateListener(listener: ?Function) {*/export function _setBackgroundVideoMuted(muted: boolean) {return (dispatch, getState) => {+ // Disable remote video when we mute by setting lastN to 0.+ // Skip it if the conference is in audio only mode, as it's+ // already configured to have no video.+ const { audioOnly } = getState()['features/base/conference'];++ if (!audioOnly) {+ const { config } = getState()['features/base/lib-jitsi-meet'];+ const defaultLastN+ = typeof config.channelLastN === 'undefined'+ ? -1 : config.channelLastN;++ dispatch({+ type: _SET_LASTN,+ lastN: muted ? 0 : defaultLastN+ });+ }+if (muted) {const mediaState = getState()['features/base/media'];@@ -62,16 +80,16 @@ export function _setBackgroundVideoMuted(muted: boolean) {return;}} else {- const bgState = getState()['features/background'];+ const { videoMuted } = getState()['features/background'];- if (!bgState.videoMuted) {+ if (!videoMuted) {// We didn't mute video, do nothing.return;}}- // Remember that video was muted due to the app going to the background- // vs user's choice.+ // Remember that local video was muted due to the app going to the+ // background vs user's choice.dispatch({type: _SET_BACKGROUND_VIDEO_MUTED,muteddiff --git a/react/features/background/middleware.js b/react/features/background/middleware.jsindex 2a1735fc23..19726a3d3d 100644--- a/react/features/background/middleware.js+++ b/react/features/background/middleware.js@@ -16,6 +16,7 @@ import {} from './actions';import {_SET_APP_STATE_LISTENER,+ _SET_LASTN,APP_STATE_CHANGED} from './actionTypes';@@ -46,6 +47,20 @@ MiddlewareRegistry.register(store => next => action => {break;}+ case _SET_LASTN: {+ const { conference } = store.getState()['features/base/conference'];++ if (conference) {+ try {+ conference.setLastN(action.lastN);+ } catch (err) {+ console.warn(`Error setting lastN: ${err}`);+ }+ }++ break;+ }+case APP_STATE_CHANGED:_appStateChanged(store.dispatch, action.appState);break;