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

functions.tsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { IReduxState } from '../app/types';
  2. import { IStateful } from '../base/app/types';
  3. import { toState } from '../base/redux/functions';
  4. import { isCloudRecordingRunning } from '../recording/functions';
  5. import { isScreenVideoShared } from '../screen-share/functions';
  6. import ScreenshotCaptureSummary from './ScreenshotCaptureSummary';
  7. /**
  8. * Creates a new instance of ScreenshotCapture.
  9. *
  10. * @param {Object | Function} stateful - The redux store, state, or
  11. * {@code getState} function.
  12. * @returns {Promise<ScreenshotCapture>}
  13. */
  14. export function createScreenshotCaptureSummary(stateful: IStateful) {
  15. if (!MediaStreamTrack.prototype.getSettings && !MediaStreamTrack.prototype.getConstraints) {
  16. return Promise.reject(new Error('ScreenshotCaptureSummary not supported!'));
  17. }
  18. return new ScreenshotCaptureSummary(toState(stateful));
  19. }
  20. /**
  21. * Checks if the screenshot capture is enabled based on the config.
  22. *
  23. * @param {Object} state - Redux state.
  24. * @param {boolean} checkSharing - Whether to check if screensharing is on.
  25. * @param {boolean} checkRecording - Whether to check is recording is on.
  26. * @returns {boolean}
  27. */
  28. export function isScreenshotCaptureEnabled(state: IReduxState, checkSharing?: boolean, checkRecording?: boolean) {
  29. const { screenshotCapture } = state['features/base/config'];
  30. if (!screenshotCapture?.enabled) {
  31. return false;
  32. }
  33. if (checkSharing && !isScreenVideoShared(state)) {
  34. return false;
  35. }
  36. if (checkRecording) {
  37. // Feature enabled always.
  38. if (screenshotCapture.mode === 'always') {
  39. return true;
  40. }
  41. // Feature enabled only when recording is also on.
  42. return isCloudRecordingRunning(state);
  43. }
  44. return true;
  45. }