2020-05-07 18:26:10 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2020-05-07 18:26:10 +00:00
|
|
|
import { VIDEO_QUALITY_LEVELS } from '../base/conference';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2020-05-07 18:26:10 +00:00
|
|
|
import logger from './logger';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum video size the local participant should send and receive from
|
|
|
|
* remote participants.
|
|
|
|
*
|
|
|
|
* @param {number} frameHeight - The user preferred max frame height for send and
|
|
|
|
* receive video.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function setVideoQuality(frameHeight: number) {
|
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const { conference, maxReceiverVideoQuality } = getState()['features/base/conference'];
|
|
|
|
|
|
|
|
if (frameHeight < VIDEO_QUALITY_LEVELS.LOW) {
|
|
|
|
logger.error(`Invalid frame height for video quality - ${frameHeight}`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
conference.setReceiverVideoConstraint(Math.min(frameHeight, maxReceiverVideoQuality));
|
|
|
|
conference.setSenderVideoConstraint(Math.min(frameHeight, VIDEO_QUALITY_LEVELS.HIGH))
|
|
|
|
.catch(err => {
|
|
|
|
logger.error(`Set video quality command failed - ${err}`);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|