Files
jitsi-meet/react/features/video-quality/reducer.js
paweldomas d3d5847605 feat: configurable quality levels for video height
Allows to adjust thresholds which control the video quality level
in the thumbnail view.

Changes the default behaviour to request the SD (360p) resolution only
when the thumbnails are at least 360 pixels tall and the height of
720 is required for the high quality level.

The thresholds can be configured with the 'videoQuality.minHeightForQualityLvl'
config property. Check the description in the config.js for more details.
2020-08-20 11:07:36 -07:00

42 lines
1.4 KiB
JavaScript

import { VIDEO_QUALITY_LEVELS } from '../base/conference';
import { SET_CONFIG } from '../base/config';
import { ReducerRegistry, set } from '../base/redux';
import { validateMinHeightForQualityLvl } from './functions';
import logger from './logger';
const DEFAULT_STATE = {
minHeightForQualityLvl: new Map()
};
DEFAULT_STATE.minHeightForQualityLvl.set(360, VIDEO_QUALITY_LEVELS.STANDARD);
DEFAULT_STATE.minHeightForQualityLvl.set(720, VIDEO_QUALITY_LEVELS.HIGH);
ReducerRegistry.register('features/base/videoquality', (state = DEFAULT_STATE, action) => {
switch (action.type) {
case SET_CONFIG:
return _setConfig(state, action);
}
return state;
});
/**
* Extracts the height to quality level mapping from the new config.
*
* @param {Object} state - The Redux state of feature base/lastn.
* @param {Action} action - The Redux action SET_CONFIG to reduce.
* @private
* @returns {Object} The new state after the reduction of the specified action.
*/
function _setConfig(state, { config }) {
const configuredMap = config?.videoQuality?.minHeightForQualityLvl;
const convertedMap = validateMinHeightForQualityLvl(configuredMap);
if (configuredMap && !convertedMap) {
logger.error('Invalid config value videoQuality.minHeightForQualityLvl');
}
return convertedMap ? set(state, 'minHeightForQualityLvl', convertedMap) : state;
}