|
@@ -13,15 +13,16 @@ export const SS_DEFAULT_FRAME_RATE = 5;
|
13
|
13
|
/**
|
14
|
14
|
* Handles obtaining a stream from a screen capture on different browsers.
|
15
|
15
|
*/
|
16
|
|
-const ScreenObtainer = {
|
|
16
|
+class ScreenObtainer {
|
|
17
|
+
|
17
|
18
|
/**
|
18
|
|
- * If not <tt>null</tt> it means that the initialization process is still in
|
19
|
|
- * progress. It is used to make desktop stream request wait and continue
|
20
|
|
- * after it's done.
|
21
|
|
- * {@type Promise|null}
|
|
19
|
+ *
|
22
|
20
|
*/
|
23
|
|
-
|
24
|
|
- obtainStream: null,
|
|
21
|
+ constructor() {
|
|
22
|
+ this.obtainStream = this._createObtainStreamMethod();
|
|
23
|
+ this.options = {};
|
|
24
|
+ this._electronSkipDisplayMedia = false;
|
|
25
|
+ }
|
25
|
26
|
|
26
|
27
|
/**
|
27
|
28
|
* Initializes the function used to obtain a screen capture
|
|
@@ -31,14 +32,11 @@ const ScreenObtainer = {
|
31
|
32
|
*/
|
32
|
33
|
init(options = {}) {
|
33
|
34
|
this.options = options;
|
34
|
|
- this.obtainStream = this._createObtainStreamMethod();
|
35
|
35
|
|
36
|
36
|
if (!this.obtainStream) {
|
37
|
|
- logger.info('Desktop sharing disabled');
|
|
37
|
+ logger.warn('Desktop sharing not supported');
|
38
|
38
|
}
|
39
|
|
-
|
40
|
|
- this._electronSkipDisplayMedia = false;
|
41
|
|
- },
|
|
39
|
+ }
|
42
|
40
|
|
43
|
41
|
/**
|
44
|
42
|
* Returns a method which will be used to obtain the screen sharing stream
|
|
@@ -57,10 +55,10 @@ const ScreenObtainer = {
|
57
|
55
|
} else if (supportsGetDisplayMedia) {
|
58
|
56
|
return this.obtainScreenFromGetDisplayMedia;
|
59
|
57
|
}
|
60
|
|
- logger.info('Screen sharing not supported on ', browser.getName());
|
|
58
|
+ logger.warn('Screen sharing not supported on ', browser.getName());
|
61
|
59
|
|
62
|
60
|
return null;
|
63
|
|
- },
|
|
61
|
+ }
|
64
|
62
|
|
65
|
63
|
/**
|
66
|
64
|
* Gets the appropriate constraints for audio sharing.
|
|
@@ -77,7 +75,7 @@ const ScreenObtainer = {
|
77
|
75
|
} : true;
|
78
|
76
|
|
79
|
77
|
return audio;
|
80
|
|
- },
|
|
78
|
+ }
|
81
|
79
|
|
82
|
80
|
/**
|
83
|
81
|
* Checks whether obtaining a screen capture is supported in the current
|
|
@@ -86,7 +84,7 @@ const ScreenObtainer = {
|
86
|
84
|
*/
|
87
|
85
|
isSupported() {
|
88
|
86
|
return this.obtainStream !== null;
|
89
|
|
- },
|
|
87
|
+ }
|
90
|
88
|
|
91
|
89
|
/**
|
92
|
90
|
* Obtains a screen capture stream on Electron.
|
|
@@ -190,7 +188,7 @@ const ScreenObtainer = {
|
190
|
188
|
} else {
|
191
|
189
|
onFailure(new JitsiTrackError(JitsiTrackErrors.ELECTRON_DESKTOP_PICKER_NOT_FOUND));
|
192
|
190
|
}
|
193
|
|
- },
|
|
191
|
+ }
|
194
|
192
|
|
195
|
193
|
/**
|
196
|
194
|
* Obtains a screen capture stream using getDisplayMedia.
|
|
@@ -349,7 +347,7 @@ const ScreenObtainer = {
|
349
|
347
|
errorCallback(new JitsiTrackError(JitsiTrackErrors.SCREENSHARING_USER_CANCELED));
|
350
|
348
|
}
|
351
|
349
|
});
|
352
|
|
- },
|
|
350
|
+ }
|
353
|
351
|
|
354
|
352
|
/**
|
355
|
353
|
* Obtains a screen capture stream using getDisplayMedia.
|
|
@@ -371,7 +369,7 @@ const ScreenObtainer = {
|
371
|
369
|
errorCallback(new JitsiTrackError(JitsiTrackErrors
|
372
|
370
|
.SCREENSHARING_USER_CANCELED));
|
373
|
371
|
});
|
374
|
|
- },
|
|
372
|
+ }
|
375
|
373
|
|
376
|
374
|
/** Sets the contentHint on the transmitted MediaStreamTrack to indicate charaterstics in the video stream, which
|
377
|
375
|
* informs RTCPeerConnection on how to encode the track (to prefer motion or individual frame detail).
|
|
@@ -389,7 +387,7 @@ const ScreenObtainer = {
|
389
|
387
|
} else {
|
390
|
388
|
logger.warn('MediaStreamTrack contentHint attribute not supported');
|
391
|
389
|
}
|
392
|
|
- },
|
|
390
|
+ }
|
393
|
391
|
|
394
|
392
|
/**
|
395
|
393
|
* Sets the max frame rate to be used for a desktop track capture.
|
|
@@ -405,6 +403,6 @@ const ScreenObtainer = {
|
405
|
403
|
max: maxFps
|
406
|
404
|
};
|
407
|
405
|
}
|
408
|
|
-};
|
|
406
|
+}
|
409
|
407
|
|
410
|
|
-export default ScreenObtainer;
|
|
408
|
+export default new ScreenObtainer();
|