|
@@ -50,40 +50,36 @@ export default class ScreenshotCaptureEffect {
|
50
|
50
|
this._streamWorker.onmessage = this._handleWorkerAction;
|
51
|
51
|
}
|
52
|
52
|
|
53
|
|
- /**
|
54
|
|
- * Checks if the local track supports this effect.
|
55
|
|
- *
|
56
|
|
- * @param {JitsiLocalTrack} jitsiLocalTrack - Targeted local track.
|
57
|
|
- * @returns {boolean} - Returns true if this effect can run on the specified track, false otherwise.
|
58
|
|
- */
|
59
|
|
- isEnabled(jitsiLocalTrack: Object) {
|
60
|
|
- return jitsiLocalTrack.isVideoTrack() && jitsiLocalTrack.videoType === 'desktop';
|
61
|
|
- }
|
62
|
|
-
|
63
|
53
|
/**
|
64
|
54
|
* Starts the screenshot capture event on a loop.
|
65
|
55
|
*
|
66
|
56
|
* @param {MediaStream} stream - The desktop stream from which screenshots are to be sent.
|
67
|
|
- * @returns {MediaStream} - The same stream, with the interval set.
|
|
57
|
+ * @param {string} videoType - The type of the media stream.
|
|
58
|
+ * @returns {Promise} - Promise that resolves once effect has started or rejects if the
|
|
59
|
+ * videoType parameter is not desktop.
|
68
|
60
|
*/
|
69
|
|
- startEffect(stream: MediaStream) {
|
70
|
|
- const desktopTrack = stream.getVideoTracks()[0];
|
71
|
|
- const { height, width }
|
72
|
|
- = desktopTrack.getSettings() ?? desktopTrack.getConstraints();
|
73
|
|
-
|
74
|
|
- this._streamHeight = height;
|
75
|
|
- this._streamWidth = width;
|
76
|
|
- this._currentCanvas.height = parseInt(height, 10);
|
77
|
|
- this._currentCanvas.width = parseInt(width, 10);
|
78
|
|
- this._videoElement.height = parseInt(height, 10);
|
79
|
|
- this._videoElement.width = parseInt(width, 10);
|
80
|
|
- this._videoElement.srcObject = stream;
|
81
|
|
- this._videoElement.play();
|
82
|
|
-
|
83
|
|
- // Store first capture for comparisons in {@code this._handleScreenshot}.
|
84
|
|
- this._videoElement.addEventListener('loadeddata', this._initScreenshotCapture);
|
85
|
|
-
|
86
|
|
- return stream;
|
|
61
|
+ startEffect(stream: MediaStream, videoType: string) {
|
|
62
|
+ return new Promise<void>((resolve, reject) => {
|
|
63
|
+ if (videoType !== 'desktop') {
|
|
64
|
+ reject();
|
|
65
|
+ }
|
|
66
|
+ const desktopTrack = stream.getVideoTracks()[0];
|
|
67
|
+ const { height, width }
|
|
68
|
+ = desktopTrack.getSettings() ?? desktopTrack.getConstraints();
|
|
69
|
+
|
|
70
|
+ this._streamHeight = height;
|
|
71
|
+ this._streamWidth = width;
|
|
72
|
+ this._currentCanvas.height = parseInt(height, 10);
|
|
73
|
+ this._currentCanvas.width = parseInt(width, 10);
|
|
74
|
+ this._videoElement.height = parseInt(height, 10);
|
|
75
|
+ this._videoElement.width = parseInt(width, 10);
|
|
76
|
+ this._videoElement.srcObject = stream;
|
|
77
|
+ this._videoElement.play();
|
|
78
|
+
|
|
79
|
+ // Store first capture for comparisons in {@code this._handleScreenshot}.
|
|
80
|
+ this._videoElement.addEventListener('loadeddata', this._initScreenshotCapture);
|
|
81
|
+ resolve();
|
|
82
|
+ });
|
87
|
83
|
}
|
88
|
84
|
|
89
|
85
|
/**
|