2021-07-26 11:38:56 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-12-08 14:15:59 +00:00
|
|
|
import { getCurrentConference } from '../base/conference';
|
2022-01-28 09:11:35 +00:00
|
|
|
import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
|
2021-07-26 11:38:56 +00:00
|
|
|
import { toState } from '../base/redux';
|
2022-01-28 09:11:35 +00:00
|
|
|
import { getActiveSession } from '../recording/functions';
|
|
|
|
import { isScreenVideoShared } from '../screen-share';
|
2021-07-26 11:38:56 +00:00
|
|
|
|
|
|
|
import ScreenshotCaptureSummary from './ScreenshotCaptureSummary';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance of ScreenshotCapture.
|
|
|
|
*
|
|
|
|
* @param {Object | Function} stateful - The redux store, state, or
|
|
|
|
* {@code getState} function.
|
|
|
|
* @returns {Promise<ScreenshotCapture>}
|
|
|
|
*/
|
|
|
|
export function createScreenshotCaptureSummary(stateful: Object | Function) {
|
|
|
|
if (!MediaStreamTrack.prototype.getSettings && !MediaStreamTrack.prototype.getConstraints) {
|
|
|
|
return Promise.reject(new Error('ScreenshotCaptureSummary not supported!'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ScreenshotCaptureSummary(toState(stateful));
|
|
|
|
}
|
2021-12-08 14:15:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a participant's connection JID given its ID.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store state.
|
|
|
|
* @param {string} participantId - ID of the given participant.
|
|
|
|
* @returns {string|undefined} - The participant connection JID if found.
|
|
|
|
*/
|
|
|
|
export function getParticipantJid(state: Object, participantId: string) {
|
|
|
|
const conference = getCurrentConference(state);
|
|
|
|
|
|
|
|
if (!conference) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const participant = conference.getParticipantById(participantId);
|
|
|
|
|
|
|
|
if (!participant) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return participant.getJid();
|
|
|
|
}
|
2022-01-28 09:11:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the screenshot capture is enabled based on the config.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {boolean} checkSharing - Whether to check if screensharing is on.
|
|
|
|
* @param {boolean} checkRecording - Whether to check is recording is on.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isScreenshotCaptureEnabled(state: Object, checkSharing, checkRecording) {
|
|
|
|
const { screenshotCapture } = state['features/base/config'];
|
|
|
|
|
|
|
|
if (!screenshotCapture?.enabled) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkSharing && !isScreenVideoShared(state)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkRecording) {
|
|
|
|
// Feature enabled always.
|
|
|
|
if (screenshotCapture.mode === 'always') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Feature enabled only when recording is also on.
|
|
|
|
return Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|