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

functions.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // @flow
  2. import { getCurrentConference } from '../base/conference';
  3. import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
  4. import { toState } from '../base/redux';
  5. import { getActiveSession } from '../recording/functions';
  6. import { isScreenVideoShared } from '../screen-share';
  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: Object | Function) {
  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. * Get a participant's connection JID given its ID.
  23. *
  24. * @param {Object} state - The redux store state.
  25. * @param {string} participantId - ID of the given participant.
  26. * @returns {string|undefined} - The participant connection JID if found.
  27. */
  28. export function getParticipantJid(state: Object, participantId: string) {
  29. const conference = getCurrentConference(state);
  30. if (!conference) {
  31. return;
  32. }
  33. const participant = conference.getParticipantById(participantId);
  34. if (!participant) {
  35. return;
  36. }
  37. return participant.getJid();
  38. }
  39. /**
  40. * Checks if the screenshot capture is enabled based on the config.
  41. *
  42. * @param {Object} state - Redux state.
  43. * @param {boolean} checkSharing - Whether to check if screensharing is on.
  44. * @param {boolean} checkRecording - Whether to check is recording is on.
  45. * @returns {boolean}
  46. */
  47. export function isScreenshotCaptureEnabled(state: Object, checkSharing, checkRecording) {
  48. const { screenshotCapture } = state['features/base/config'];
  49. if (!screenshotCapture?.enabled) {
  50. return false;
  51. }
  52. if (checkSharing && !isScreenVideoShared(state)) {
  53. return false;
  54. }
  55. if (checkRecording) {
  56. // Feature enabled always.
  57. if (screenshotCapture.mode === 'always') {
  58. return true;
  59. }
  60. // Feature enabled only when recording is also on.
  61. return Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE));
  62. }
  63. return true;
  64. }