Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix, updates lastN after exiting the pip mode #10491

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions react/features/base/lastn/actionTypes.js
@@ -1,11 +1,21 @@
// @flow

/**
* The type of (redux) action which sets the last-n for the conference.
* The type of (redux) action which sets the applicable last-n for the conference.
*
* {
* type: SET_LAST_N,
* lastN: number
* type: SET_APPLIED_LAST_N,
* appliedLastN: number
* }
*/
export const SET_LAST_N = 'SET_LAST_N';
export const SET_APPLIED_LAST_N = 'SET_APPLIED_LAST_N';

/**
* The type of (redux) action which sets the last-n for the conference based on the user's configurations.
*
* {
* type: SET_CONFIG_LAST_N,
* configLastN: number
* }
*/
export const SET_CONFIG_LAST_N = 'SET_CONFIG_LAST_N';
33 changes: 25 additions & 8 deletions react/features/base/lastn/actions.js
@@ -1,19 +1,36 @@
// @flow

import { SET_LAST_N } from './actionTypes';
import { SET_APPLIED_LAST_N, SET_CONFIG_LAST_N } from './actionTypes';

/**
* Sets the last-n, i.e., the number of remote videos to be requested from the bridge for the conference.
* Sets the applicable last-n, i.e., the number of remote videos to be requested from the bridge for the conference.
*
* @param {number} lastN - The number of remote videos to be requested.
* @param {number} appliedLastN - The number of remote videos to be requested.
* @returns {{
* type: SET_LAST_N,
* lastN: number
* type: SET_APPLIED_LAST_N,
* appliedLastN: number
* }}
*/
export function setLastN(lastN: number) {
export function setAppliedLastN(appliedLastN: number) {
return {
type: SET_LAST_N,
lastN
type: SET_APPLIED_LAST_N,
appliedLastN
};
}

/**
* Sets the configured last-n, i.e., the number of remote videos to be requested from the bridge for the conference
* considering the user's configuration, e.g., videoQualitySlider.
*
* @param {number} configLastN - The number of remote videos to be requested.
* @returns {{
* type: SET_CONFIG_LAST_N,
* configLastN: number
* }}
*/
export function setConfigLastN(configLastN: number) {
return {
type: SET_CONFIG_LAST_N,
configLastN
};
}
24 changes: 13 additions & 11 deletions react/features/base/lastn/middleware.js
Expand Up @@ -20,7 +20,8 @@ import {
import { MiddlewareRegistry } from '../redux';
import { isLocalVideoTrackDesktop } from '../tracks/functions';

import { setLastN } from './actions';
import { SET_CONFIG_LAST_N } from './actionTypes';
import { setAppliedLastN } from './actions';
import { limitLastN } from './functions';
import logger from './logger';

Expand All @@ -31,7 +32,7 @@ import logger from './logger';
* @private
* @returns {void}
*/
const _updateLastN = debounce(({ dispatch, getState }) => {
const _updateAppliedLastN = debounce(({ dispatch, getState }) => {
const state = getState();
const { conference } = state['features/base/conference'];

Expand All @@ -45,25 +46,25 @@ const _updateLastN = debounce(({ dispatch, getState }) => {
const { appState } = state['features/background'] || {};
const { enabled: filmStripEnabled } = state['features/filmstrip'];
const config = state['features/base/config'];
const { lastNLimits, lastN } = state['features/base/lastn'];
const { lastNLimits, configLastN } = state['features/base/lastn'];
const participantCount = getParticipantCount(state);

// Select the lastN value based on the following preference order.
// 1. The last-n value in redux.
// 2. The last-n value from 'startLastN' if it is specified in config.js
// 3. The last-n value from 'channelLastN' if specified in config.js.
// 4. -1 as the default value.
let lastNSelected = lastN || (config.startLastN ?? (config.channelLastN ?? -1));
let newAppliedLastN = configLastN || (config.startLastN ?? (config.channelLastN ?? -1));

// Apply last N limit based on the # of participants and config settings.
const limitedLastN = limitLastN(participantCount, lastNLimits);

if (limitedLastN !== undefined) {
lastNSelected = lastNSelected === -1 ? limitedLastN : Math.min(limitedLastN, lastNSelected);
newAppliedLastN = newAppliedLastN === -1 ? limitedLastN : Math.min(limitedLastN, newAppliedLastN);
}

if (typeof appState !== 'undefined' && appState !== 'active') {
lastNSelected = isLocalVideoTrackDesktop(state) ? 1 : 0;
newAppliedLastN = isLocalVideoTrackDesktop(state) ? 1 : 0;
} else if (audioOnly) {
const { remoteScreenShares, tileViewEnabled } = state['features/video-layout'];
const largeVideoParticipantId = state['features/large-video'].participantId;
Expand All @@ -74,15 +75,15 @@ const _updateLastN = debounce(({ dispatch, getState }) => {
// view since we make an exception only for screenshare when in audio-only mode. If the user unpins
// the screenshare, lastN will be set to 0 here. It will be set to 1 if screenshare has been auto pinned.
if (!tileViewEnabled && largeVideoParticipant && !largeVideoParticipant.local) {
lastNSelected = (remoteScreenShares || []).includes(largeVideoParticipantId) ? 1 : 0;
newAppliedLastN = (remoteScreenShares || []).includes(largeVideoParticipantId) ? 1 : 0;
} else {
lastNSelected = 0;
newAppliedLastN = 0;
}
} else if (!filmStripEnabled) {
lastNSelected = 1;
newAppliedLastN = 1;
}

dispatch(setLastN(lastNSelected));
dispatch(setAppliedLastN(newAppliedLastN));
}, 1000); /* Don't send this more often than once a second. */


Expand All @@ -100,7 +101,8 @@ MiddlewareRegistry.register(store => next => action => {
case SET_AUDIO_ONLY:
case SET_FILMSTRIP_ENABLED:
case SET_TILE_VIEW:
_updateLastN(store);
case SET_CONFIG_LAST_N:
_updateAppliedLastN(store);
break;
}

Expand Down
16 changes: 12 additions & 4 deletions react/features/base/lastn/reducer.js
Expand Up @@ -3,19 +3,27 @@ import {
} from '../config';
import { ReducerRegistry, set } from '../redux';

import { SET_LAST_N } from './actionTypes';
import { SET_APPLIED_LAST_N, SET_CONFIG_LAST_N } from './actionTypes';
import { validateLastNLimits } from './functions';

ReducerRegistry.register('features/base/lastn', (state = { }, action) => {
switch (action.type) {
case SET_CONFIG:
return _setConfig(state, action);
case SET_LAST_N: {
const { lastN } = action;
case SET_APPLIED_LAST_N: {
const { appliedLastN } = action;

return {
...state,
lastN
appliedLastN
};
}
case SET_CONFIG_LAST_N: {
const { configLastN } = action;

return {
...state,
configLastN
};
}
}
Expand Down
Expand Up @@ -7,7 +7,7 @@ import type { Dispatch } from 'redux';
import { createToolbarEvent, sendAnalytics } from '../../analytics';
import { setAudioOnly } from '../../base/audio-only';
import { translate } from '../../base/i18n';
import { setLastN, getLastNForQualityLevel } from '../../base/lastn';
import { setConfigLastN, getLastNForQualityLevel } from '../../base/lastn';
import { connect } from '../../base/redux';
import { withPixelLineHeight } from '../../base/styles/functions.web';
import { setPreferredVideoQuality } from '../actions';
Expand Down Expand Up @@ -354,7 +354,7 @@ class VideoQualitySlider extends Component<Props> {
const lastN = getLastNForQualityLevel(qualityLevel, _channelLastN);

// Set the lastN for the conference.
this.props.dispatch(setLastN(lastN));
this.props.dispatch(setConfigLastN(lastN));
}
}

Expand Down
4 changes: 2 additions & 2 deletions react/features/video-quality/subscriber.js
Expand Up @@ -64,7 +64,7 @@ StateListenerRegistry.register(
* lastn state and dispatching additional actions.
*/
StateListenerRegistry.register(
/* selector */ state => state['features/base/lastn'].lastN,
/* selector */ state => state['features/base/lastn'].appliedLastN,
/* listener */ (lastN, store) => {
_updateReceiverVideoConstraints(store);
});
Expand Down Expand Up @@ -187,7 +187,7 @@ function _updateReceiverVideoConstraints({ getState }) {
if (!conference) {
return;
}
const { lastN } = state['features/base/lastn'];
const { appliedLastN: lastN } = state['features/base/lastn'];
const { maxReceiverVideoQuality, preferredVideoQuality } = state['features/video-quality'];
const { participantId: largeVideoParticipantId } = state['features/large-video'];
const maxFrameHeight = Math.min(maxReceiverVideoQuality, preferredVideoQuality);
Expand Down