diff --git a/react/features/background/actionTypes.js b/react/features/background/actionTypes.js index f126ace50..7f7323e0a 100644 --- a/react/features/background/actionTypes.js +++ b/react/features/background/actionTypes.js @@ -27,6 +27,21 @@ export const _SET_APP_STATE_LISTENER export 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.js index e0ddf4136..4723fed46 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, muted diff --git a/react/features/background/middleware.js b/react/features/background/middleware.js index 2a1735fc2..19726a3d3 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;