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) Add initial call for region selection (#10818)

Robert Pintiliic58ebd9792f6
diff --git a/react/features/screenshot-capture/ScreenshotCaptureSummary.js b/react/features/screenshot-capture/ScreenshotCaptureSummary.js
index 9bdc8d4f1b..3eedaa99c5 100644
--- a/react/features/screenshot-capture/ScreenshotCaptureSummary.js
+++ b/react/features/screenshot-capture/ScreenshotCaptureSummary.js
@@ -33,6 +33,7 @@ export default class ScreenshotCaptureSummary {
_currentCanvasContext: CanvasRenderingContext2D;
_handleWorkerAction: Function;
_initScreenshotCapture: Function;
+ _initializedRegion: boolean;
_imageCapture: any;
_streamWorker: Worker;
_streamHeight: any;
@@ -54,6 +55,35 @@ export default class ScreenshotCaptureSummary {
this._initScreenshotCapture = this._initScreenshotCapture.bind(this);
this._streamWorker = new Worker(timerWorkerScript, { name: 'Screenshot capture worker' });
this._streamWorker.onmessage = this._handleWorkerAction;
+
+ this._initializedRegion = false;
+ }
+
+ /**
+ * Make a call to backend for region selection.
+ *
+ * @returns {void}
+ */
+ async _initRegionSelection() {
+ const { _screenshotHistoryRegionUrl } = this._state['features/base/config'];
+ const conference = getCurrentConference(this._state);
+ const sessionId = conference.getMeetingUniqueId();
+ const { jwt } = this._state['features/base/jwt'];
+
+ if (!_screenshotHistoryRegionUrl) {
+ return;
+ }
+
+ const headers = {
+ ...jwt && { 'Authorization': `Bearer ${jwt}` }
+ };
+
+ await fetch(`${_screenshotHistoryRegionUrl}/${sessionId}`, {
+ method: 'POST',
+ headers
+ });
+
+ this._initializedRegion = true;
}
/**
@@ -63,7 +93,7 @@ export default class ScreenshotCaptureSummary {
* @returns {Promise} - Promise that resolves once effect has started or rejects if the
* videoType parameter is not desktop.
*/
- start(track: Object) {
+ async start(track: Object) {
const { videoType } = track;
const stream = track.getOriginalStream();
@@ -80,6 +110,9 @@ export default class ScreenshotCaptureSummary {
this._currentCanvas.width = parseInt(width, 10);
this._imageCapture = new ImageCapture(desktopTrack);
+ if (!this._initializedRegion) {
+ await this._initRegionSelection();
+ }
this._initScreenshotCapture();
}