fix(screenshot-capture) Add initial call for region selection (#10818)

This commit is contained in:
Robert Pintilii 2022-01-27 11:14:48 +02:00 committed by GitHub
parent 35e97450f9
commit c58ebd9792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 1 deletions

View File

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