You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.tsx 1.8KB

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