2022-10-27 07:33:11 +00:00
|
|
|
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
|
|
|
import { SET_CONFIG } from '../base/config/actionTypes';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
2020-07-07 20:34:52 +00:00
|
|
|
|
2021-05-10 20:06:19 +00:00
|
|
|
import { setPreferredVideoQuality } from './actions';
|
2020-07-07 20:34:52 +00:00
|
|
|
import logger from './logger';
|
|
|
|
|
2021-05-10 20:06:19 +00:00
|
|
|
import './subscriber';
|
2020-09-03 22:40:54 +00:00
|
|
|
|
2020-07-07 20:34:52 +00:00
|
|
|
/**
|
|
|
|
* 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') {
|
2022-10-27 07:33:11 +00:00
|
|
|
dispatch(setPreferredVideoQuality(Number.parseInt(`${resolution}`, 10)));
|
2020-07-07 20:34:52 +00:00
|
|
|
logger.info(`Configured preferred receiver video frame height to: ${resolution}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-09-01 21:45:59 +00:00
|
|
|
case SET_CONFIG: {
|
|
|
|
const state = getState();
|
|
|
|
const { videoQuality = {} } = state['features/base/config'];
|
2020-10-07 23:08:48 +00:00
|
|
|
const { persistedPrefferedVideoQuality } = state['features/video-quality-persistent-storage'];
|
2020-09-01 21:45:59 +00:00
|
|
|
|
2020-10-07 23:08:48 +00:00
|
|
|
if (videoQuality.persist && typeof persistedPrefferedVideoQuality !== 'undefined') {
|
|
|
|
dispatch(setPreferredVideoQuality(persistedPrefferedVideoQuality));
|
2020-09-01 21:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-07-07 20:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|