您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // @flow
  2. import { CONFERENCE_JOINED } from '../base/conference';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { SET_SCREENSHARE_CAPTURE_FRAME_RATE } from './actionTypes';
  5. import logger from './logger';
  6. /**
  7. * Implements the middleware of the feature screen-share.
  8. *
  9. * @param {Store} store - The redux store.
  10. * @returns {Function}
  11. */
  12. MiddlewareRegistry.register(store => next => action => {
  13. const result = next(action);
  14. switch (action.type) {
  15. case CONFERENCE_JOINED: {
  16. _setScreenshareCaptureFps(store);
  17. break;
  18. }
  19. case SET_SCREENSHARE_CAPTURE_FRAME_RATE: {
  20. const { captureFrameRate } = action;
  21. _setScreenshareCaptureFps(store, captureFrameRate);
  22. break;
  23. }
  24. }
  25. return result;
  26. });
  27. /**
  28. * Sets the capture frame rate for screenshare.
  29. *
  30. * @param {Store} store - The redux store.
  31. * @param {number} frameRate - Frame rate to be configured.
  32. * @private
  33. * @returns {void}
  34. */
  35. function _setScreenshareCaptureFps(store, frameRate) {
  36. const state = store.getState();
  37. const { conference } = state['features/base/conference'];
  38. const { captureFrameRate } = state['features/screen-share'];
  39. const screenShareFps = frameRate ?? captureFrameRate;
  40. if (!conference) {
  41. return;
  42. }
  43. if (screenShareFps) {
  44. logger.debug(`Setting screenshare capture frame rate as ${screenShareFps}`);
  45. conference.setDesktopSharingFrameRate(screenShareFps);
  46. }
  47. }