Files
jitsi-meet/react/features/screen-share/middleware.js
Jaya Allamsetty 765fbe5e1d feat: Change the screenshare capture fps from UI. (#9438)
* feat: Change the screenshare capture fps from UI.
Add the ability to change the capture frame rate for screenshare from the UI. The fps becomes effective only on screen shares that are started after the setting is changed.

* squash: add missing JSDOCs and translations for frames-per-second.
2021-06-28 10:48:16 +03:00

58 lines
1.4 KiB
JavaScript

// @flow
import { CONFERENCE_JOINED } from '../base/conference';
import { MiddlewareRegistry } from '../base/redux';
import { SET_SCREENSHARE_CAPTURE_FRAME_RATE } from './actionTypes';
import logger from './logger';
/**
* Implements the middleware of the feature screen-share.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
MiddlewareRegistry.register(store => next => action => {
const result = next(action);
switch (action.type) {
case CONFERENCE_JOINED: {
_setScreenshareCaptureFps(store);
break;
}
case SET_SCREENSHARE_CAPTURE_FRAME_RATE: {
const { captureFrameRate } = action;
_setScreenshareCaptureFps(store, captureFrameRate);
break;
}
}
return result;
});
/**
* Sets the capture frame rate for screenshare.
*
* @param {Store} store - The redux store.
* @param {number} frameRate - Frame rate to be configured.
* @private
* @returns {void}
*/
function _setScreenshareCaptureFps(store, frameRate) {
const state = store.getState();
const { conference } = state['features/base/conference'];
const { captureFrameRate } = state['features/screen-share'];
const screenShareFps = frameRate ?? captureFrameRate;
if (!conference) {
return;
}
if (screenShareFps) {
logger.debug(`Setting screenshare capture frame rate as ${screenShareFps}`);
conference.setDesktopSharingFrameRate(screenShareFps);
}
}