mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 18:37:46 +00:00
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.
42 lines
1.4 KiB
JavaScript
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;
|
|
}
|