[RN] Disable remote video while in the background
Set the video channel "last N" property to 0, thus making the client not receive any remote video.
This commit is contained in:
parent
e8068cf5ac
commit
2d5f0479bd
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue