|
|
@@ -1,5 +1,4 @@
|
|
1
|
1
|
// @flow
|
|
2
|
|
-import { JitsiTrackEvents } from '../../base/lib-jitsi-meet';
|
|
3
|
2
|
|
|
4
|
3
|
import {
|
|
5
|
4
|
CLEAR_TIMEOUT,
|
|
|
@@ -16,7 +15,6 @@ import {
|
|
16
|
15
|
export default class JitsiStreamBackgroundEffect {
|
|
17
|
16
|
_model: Object;
|
|
18
|
17
|
_options: Object;
|
|
19
|
|
- _screenSharing: Object;
|
|
20
|
18
|
_segmentationPixelCount: number;
|
|
21
|
19
|
_inputVideoElement: HTMLVideoElement;
|
|
22
|
20
|
_onMaskFrameTimer: Function;
|
|
|
@@ -39,21 +37,19 @@ export default class JitsiStreamBackgroundEffect {
|
|
39
|
37
|
* @class
|
|
40
|
38
|
* @param {Object} model - Meet model.
|
|
41
|
39
|
* @param {Object} options - Segmentation dimensions.
|
|
42
|
|
- * @param {Object} screenSharing - Desktop track for displaying desktop share as virtual background.
|
|
43
|
40
|
*/
|
|
44
|
|
- constructor(model: Object, options: Object, screenSharing: Object) {
|
|
|
41
|
+ constructor(model: Object, options: Object) {
|
|
45
|
42
|
this._options = options;
|
|
46
|
|
- this._screenSharing = screenSharing;
|
|
47
|
43
|
|
|
48
|
44
|
if (this._options.virtualBackground.backgroundType === 'image') {
|
|
49
|
45
|
this._virtualImage = document.createElement('img');
|
|
50
|
46
|
this._virtualImage.crossOrigin = 'anonymous';
|
|
51
|
47
|
this._virtualImage.src = this._options.virtualBackground.virtualSource;
|
|
52
|
48
|
}
|
|
53
|
|
- if (this._options.virtualBackground.backgroundType === 'desktop-share' && this._screenSharing) {
|
|
|
49
|
+ if (this._options.virtualBackground.backgroundType === 'desktop-share') {
|
|
54
|
50
|
this._virtualVideo = document.createElement('video');
|
|
55
|
51
|
this._virtualVideo.autoplay = true;
|
|
56
|
|
- this._virtualVideo.srcObject = this._screenSharing.stream;
|
|
|
52
|
+ this._virtualVideo.srcObject = this._options?.virtualBackground?.virtualSource?.stream;
|
|
57
|
53
|
}
|
|
58
|
54
|
this._model = model;
|
|
59
|
55
|
this._options = options;
|
|
|
@@ -252,15 +248,6 @@ export default class JitsiStreamBackgroundEffect {
|
|
252
|
248
|
this._inputVideoElement.height = parseInt(height, 10);
|
|
253
|
249
|
this._inputVideoElement.autoplay = true;
|
|
254
|
250
|
this._inputVideoElement.srcObject = stream;
|
|
255
|
|
- this._screenSharing && this._screenSharing.on(
|
|
256
|
|
- JitsiTrackEvents.LOCAL_TRACK_STOPPED,
|
|
257
|
|
- () => {
|
|
258
|
|
- this._options.virtualBackground.enabled = false;
|
|
259
|
|
- this._options.virtualBackground.backgroundType = 'none';
|
|
260
|
|
- this._options.virtualBackground.selectedThumbnail = 'none';
|
|
261
|
|
- this._options.virtualBackground.backgroundEffectEnabled = false;
|
|
262
|
|
- this._options.virtualBackground.enabled = false;
|
|
263
|
|
- });
|
|
264
|
251
|
this._inputVideoElement.onloadeddata = () => {
|
|
265
|
252
|
this._maskFrameTimerWorker.postMessage({
|
|
266
|
253
|
id: SET_TIMEOUT,
|
|
|
@@ -282,6 +269,5 @@ export default class JitsiStreamBackgroundEffect {
|
|
282
|
269
|
});
|
|
283
|
270
|
|
|
284
|
271
|
this._maskFrameTimerWorker.terminate();
|
|
285
|
|
- this._screenSharing && this._screenSharing.dispose();
|
|
286
|
272
|
}
|
|
287
|
273
|
}
|