mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-18 05:47:46 +00:00
Changed screen capture to non effect. Effects are used to alter the stream, this feature does not need to alter the stream, it just needs access to it Changed image diff library. Previous library diff’ed the whole image, the new one has en early return threshold Use ImageCaptureAPI to take the screenshot. Added polyfill for it and polyfill for createImageBitmap Added analytics
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
// @flow
|
|
|
|
import { getLocalVideoTrack } from '../../features/base/tracks';
|
|
|
|
|
|
import { SET_SCREENSHOT_CAPTURE } from './actionTypes';
|
|
import { createScreenshotCaptureSummary } from './functions';
|
|
import logger from './logger';
|
|
|
|
let screenshotSummary;
|
|
|
|
/**
|
|
* Marks the on-off state of screenshot captures.
|
|
*
|
|
* @param {boolean} enabled - Whether to turn screen captures on or off.
|
|
* @returns {{
|
|
* type: START_SCREENSHOT_CAPTURE,
|
|
* payload: enabled
|
|
* }}
|
|
*/
|
|
function setScreenshotCapture(enabled) {
|
|
return {
|
|
type: SET_SCREENSHOT_CAPTURE,
|
|
payload: enabled
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Action that toggles the screenshot captures.
|
|
*
|
|
* @param {boolean} enabled - Bool that represents the intention to start/stop screenshot captures.
|
|
* @returns {Promise}
|
|
*/
|
|
export function toggleScreenshotCaptureSummary(enabled: boolean) {
|
|
return async function(dispatch: (Object) => Object, getState: () => any) {
|
|
const state = getState();
|
|
|
|
if (state['features/screenshot-capture'].capturesEnabled !== enabled) {
|
|
const { jitsiTrack } = getLocalVideoTrack(state['features/base/tracks']);
|
|
|
|
if (!screenshotSummary) {
|
|
try {
|
|
screenshotSummary = await createScreenshotCaptureSummary(state);
|
|
} catch (err) {
|
|
logger.error('Cannot create screenshotCaptureSummary', err);
|
|
}
|
|
}
|
|
|
|
if (enabled) {
|
|
try {
|
|
await screenshotSummary.start(jitsiTrack);
|
|
dispatch(setScreenshotCapture(enabled));
|
|
} catch {
|
|
|
|
// Handle promise rejection from {@code start} due to stream type not being desktop.
|
|
logger.error('Unsupported stream type.');
|
|
}
|
|
} else {
|
|
screenshotSummary.stop();
|
|
dispatch(setScreenshotCapture(enabled));
|
|
}
|
|
}
|
|
|
|
return Promise.resolve();
|
|
};
|
|
}
|