Files
jitsi-meet/react/features/video-quality/middleware.js
Jaya Allamsetty 91197bc69f fix(quality-control): Send the new receiver constraints on state changes.
The client now listens for changes to lastN, selectedEndpoints and maxReceiverVideoQuality in redux to trigger sending  bridge message in the new format. This fixes an issue where the stage view <-> tile view changes prompt two receiver constraints messages to be sent, first with the maxHeight update and then with the selected endpoints update.
2021-05-10 16:06:19 -04:00

48 lines
1.4 KiB
JavaScript

// @flow
import { CONFERENCE_JOINED } from '../base/conference';
import { SET_CONFIG } from '../base/config';
import { MiddlewareRegistry } from '../base/redux';
import { setPreferredVideoQuality } from './actions';
import logger from './logger';
import './subscriber';
/**
* Implements the middleware of the feature video-quality.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const result = next(action);
switch (action.type) {
case CONFERENCE_JOINED: {
if (navigator.product === 'ReactNative') {
const { resolution } = getState()['features/base/config'];
if (typeof resolution !== 'undefined') {
dispatch(setPreferredVideoQuality(Number.parseInt(resolution, 10)));
logger.info(`Configured preferred receiver video frame height to: ${resolution}`);
}
}
break;
}
case SET_CONFIG: {
const state = getState();
const { videoQuality = {} } = state['features/base/config'];
const { persistedPrefferedVideoQuality } = state['features/video-quality-persistent-storage'];
if (videoQuality.persist && typeof persistedPrefferedVideoQuality !== 'undefined') {
dispatch(setPreferredVideoQuality(persistedPrefferedVideoQuality));
}
break;
}
}
return result;
});