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

Added config to choose between recording and always mode
Created function to check if feature should be used
Removed check from stop feature as it now checks if the feature was previously on
Only get video track on feature start
This commit is contained in:
Robert Pintilii 2022-01-28 11:11:35 +02:00 committed by GitHub
parent ae5723406d
commit f0118c0fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 44 deletions

View File

@ -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');

View File

@ -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,

View File

@ -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');

View File

@ -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',

View File

@ -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)
};
}

View File

@ -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));

View File

@ -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 {

View File

@ -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;
}