Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(screenshot-capture) Updated feature (#10865)

Robert Pintiliif0118c0fb596
diff --git a/conference.js b/conference.js
index 6612b57705..2716bf33c5 100644
--- a/conference.js
+++ b/conference.js
@@ -71,8 +71,7 @@ import {
JitsiMediaDevicesEvents,
JitsiParticipantConnectionStatus,
JitsiTrackErrors,
- JitsiTrackEvents,
- JitsiRecordingConstants
+ JitsiTrackEvents
} from './react/features/base/lib-jitsi-meet';
import {
getStartWithAudioMuted,
@@ -141,10 +140,10 @@ import {
setJoiningInProgress,
setPrejoinPageVisibility
} from './react/features/prejoin';
-import { getActiveSession } from './react/features/recording/functions';
import { disableReceiver, stopReceiver } from './react/features/remote-control';
import { setScreenAudioShareState, isScreenAudioShared } from './react/features/screen-share/';
import { toggleScreenshotCaptureSummary } from './react/features/screenshot-capture';
+import { isScreenshotCaptureEnabled } from './react/features/screenshot-capture/functions';
import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/AudioMixerEffect';
import { createPresenterEffect } from './react/features/stream-effects/presenter';
import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
@@ -1572,9 +1571,7 @@ export default {
this._stopProxyConnection();
- if (config.enableScreenshotCapture) {
- APP.store.dispatch(toggleScreenshotCaptureSummary(false));
- }
+ APP.store.dispatch(toggleScreenshotCaptureSummary(false));
const tracks = APP.store.getState()['features/base/tracks'];
const duration = getLocalVideoTrack(tracks)?.jitsiTrack.getDuration() ?? 0;
@@ -1953,10 +1950,8 @@ export default {
})
.then(() => {
this.videoSwitchInProgress = false;
- if (config.enableScreenshotCapture) {
- if (getActiveSession(APP.store.getState(), JitsiRecordingConstants.mode.FILE)) {
- APP.store.dispatch(toggleScreenshotCaptureSummary(true));
- }
+ if (isScreenshotCaptureEnabled(APP.store.getState(), false, true)) {
+ APP.store.dispatch(toggleScreenshotCaptureSummary(true));
}
sendAnalytics(createScreenSharingEvent('started'));
logger.log('Screen sharing started');
diff --git a/config.js b/config.js
index f4ea80840c..538ab7cd4d 100644
--- a/config.js
+++ b/config.js
@@ -98,6 +98,17 @@ var config = {
// Disables self-view settings in UI
// disableSelfViewSettings: false,
+ // screenshotCapture : {
+ // Enables the screensharing capture feature.
+ // enabled: false,
+ //
+ // The mode for the screenshot capture feature.
+ // Can be either 'recording' - screensharing screenshots are taken
+ // only when the recording is also on,
+ // or 'always' - screensharing screenshots are always taken.
+ // mode: 'recording'
+ // }
+
// Disables ICE/UDP by filtering out local and remote UDP candidates in
// signalling.
// webrtcIceUdpDisable: false,
diff --git a/modules/API/API.js b/modules/API/API.js
index 298dd7ca18..cd0217511b 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -67,9 +67,10 @@ import { toggleLobbyMode, setKnockingParticipantApproval } from '../../react/fea
import { isForceMuted } from '../../react/features/participants-pane/functions';
import { RECORDING_TYPES } from '../../react/features/recording/constants';
import { getActiveSession } from '../../react/features/recording/functions';
-import { isScreenAudioSupported, isScreenVideoShared } from '../../react/features/screen-share';
+import { isScreenAudioSupported } from '../../react/features/screen-share';
import { startScreenShareFlow, startAudioScreenShareFlow } from '../../react/features/screen-share/actions';
import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture';
+import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions';
import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
import { extractYoutubeIdOrURL } from '../../react/features/shared-video/functions';
import { toggleTileView, setTileView } from '../../react/features/video-layout';
@@ -481,9 +482,7 @@ function initCommands() {
return;
}
- const enableScreenshotCapture = state['features/base/config'].enableScreenshotCapture;
-
- if (enableScreenshotCapture && isScreenVideoShared(state)) {
+ if (isScreenshotCaptureEnabled(state, true, false)) {
APP.store.dispatch(toggleScreenshotCaptureSummary(true));
}
conference.startRecording(recordingConfig);
@@ -514,9 +513,7 @@ function initCommands() {
const activeSession = getActiveSession(state, mode);
if (activeSession && activeSession.id) {
- if (state['features/base/config'].enableScreenshotCapture) {
- APP.store.dispatch(toggleScreenshotCaptureSummary(false));
- }
+ APP.store.dispatch(toggleScreenshotCaptureSummary(false));
conference.stopRecording(activeSession.id);
} else {
logger.error('No recording or streaming session found');
diff --git a/react/features/base/config/configWhitelist.js b/react/features/base/config/configWhitelist.js
index f90f79bfa0..cc480e4f91 100644
--- a/react/features/base/config/configWhitelist.js
+++ b/react/features/base/config/configWhitelist.js
@@ -144,7 +144,6 @@ export default [
'enableOpusRed',
'enableRemb',
'enableSaveLogs',
- 'enableScreenshotCapture',
'enableTalkWhileMuted',
'enableUnifiedOnChrome',
'enableNoAudioDetection',
@@ -197,6 +196,7 @@ export default [
'readOnlyName',
'replaceParticipant',
'resolution',
+ 'screenshotCapture',
'startAudioMuted',
'startAudioOnly',
'startLastN',
diff --git a/react/features/recording/components/Recording/web/StartRecordingDialog.js b/react/features/recording/components/Recording/web/StartRecordingDialog.js
index 7d26ce1909..83a770e8af 100644
--- a/react/features/recording/components/Recording/web/StartRecordingDialog.js
+++ b/react/features/recording/components/Recording/web/StartRecordingDialog.js
@@ -5,8 +5,8 @@ import React from 'react';
import { Dialog } from '../../../../base/dialog';
import { translate } from '../../../../base/i18n';
import { connect } from '../../../../base/redux';
-import { isScreenVideoShared } from '../../../../screen-share';
import { toggleScreenshotCaptureSummary } from '../../../../screenshot-capture';
+import { isScreenshotCaptureEnabled } from '../../../../screenshot-capture/functions';
import AbstractStartRecordingDialog, {
mapStateToProps as abstractMapStateToProps
} from '../AbstractStartRecordingDialog';
@@ -72,9 +72,9 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
* @returns {void}
*/
_toggleScreenshotCapture() {
- const { dispatch, _screensharing, _screenshotCaptureEnabled } = this.props;
+ const { dispatch, _screenshotCaptureEnabled } = this.props;
- if (_screenshotCaptureEnabled && _screensharing) {
+ if (_screenshotCaptureEnabled) {
dispatch(toggleScreenshotCaptureSummary(true));
}
}
@@ -94,8 +94,7 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
function mapStateToProps(state) {
return {
...abstractMapStateToProps(state),
- _screensharing: isScreenVideoShared(state),
- _screenshotCaptureEnabled: state['features/base/config'].enableScreenshotCapture
+ _screenshotCaptureEnabled: isScreenshotCaptureEnabled(state, true, false)
};
}
diff --git a/react/features/recording/components/Recording/web/StopRecordingDialog.js b/react/features/recording/components/Recording/web/StopRecordingDialog.js
index e3b73e971d..21db4f22a3 100644
--- a/react/features/recording/components/Recording/web/StopRecordingDialog.js
+++ b/react/features/recording/components/Recording/web/StopRecordingDialog.js
@@ -8,7 +8,7 @@ import { connect } from '../../../../base/redux';
import { toggleScreenshotCaptureSummary } from '../../../../screenshot-capture';
import AbstractStopRecordingDialog, {
type Props,
- _mapStateToProps as abstractMapStateToProps
+ _mapStateToProps
} from '../AbstractStopRecordingDialog';
/**
@@ -46,25 +46,8 @@ class StopRecordingDialog extends AbstractStopRecordingDialog<Props> {
* @returns {void}
*/
_toggleScreenshotCapture() {
- const { dispatch, _screenshotCaptureEnabled } = this.props;
-
- if (_screenshotCaptureEnabled) {
- dispatch(toggleScreenshotCaptureSummary(false));
- }
+ this.props.dispatch(toggleScreenshotCaptureSummary(false));
}
}
-/**
- * Maps redux state to component props.
- *
- * @param {Object} state - Redux state.
- * @returns {Object}
- */
-function _mapStateToProps(state) {
- return {
- ...abstractMapStateToProps(state),
- _screenshotCaptureEnabled: state['features/base/config'].enableScreenshotCapture
- };
-}
-
export default translate(connect(_mapStateToProps)(StopRecordingDialog));
diff --git a/react/features/screenshot-capture/actions.js b/react/features/screenshot-capture/actions.js
index a77caf63dc..d38e124001 100644
--- a/react/features/screenshot-capture/actions.js
+++ b/react/features/screenshot-capture/actions.js
@@ -36,8 +36,6 @@ export function toggleScreenshotCaptureSummary(enabled: boolean) {
const state = getState();
if (state['features/screenshot-capture'].capturesEnabled !== enabled) {
- const { jitsiTrack } = getLocalVideoTrack(state['features/base/tracks']);
-
if (!screenshotSummary) {
try {
screenshotSummary = await createScreenshotCaptureSummary(state);
@@ -48,6 +46,8 @@ export function toggleScreenshotCaptureSummary(enabled: boolean) {
if (enabled) {
try {
+ const { jitsiTrack } = getLocalVideoTrack(state['features/base/tracks']);
+
await screenshotSummary.start(jitsiTrack);
dispatch(setScreenshotCapture(enabled));
} catch {
diff --git a/react/features/screenshot-capture/functions.js b/react/features/screenshot-capture/functions.js
index eefcb42451..d79983c571 100644
--- a/react/features/screenshot-capture/functions.js
+++ b/react/features/screenshot-capture/functions.js
@@ -1,7 +1,10 @@
// @flow
import { getCurrentConference } from '../base/conference';
+import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
import { toState } from '../base/redux';
+import { getActiveSession } from '../recording/functions';
+import { isScreenVideoShared } from '../screen-share';
import ScreenshotCaptureSummary from './ScreenshotCaptureSummary';
@@ -42,3 +45,36 @@ export function getParticipantJid(state: Object, participantId: string) {
return participant.getJid();
}
+
+/**
+ * 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;
+
+}