|
@@ -36,6 +36,8 @@ const ScreenObtainer = {
|
36
|
36
|
if (!this.obtainStream) {
|
37
|
37
|
logger.info('Desktop sharing disabled');
|
38
|
38
|
}
|
|
39
|
+
|
|
40
|
+ this._electronSkipDisplayMedia = false;
|
39
|
41
|
},
|
40
|
42
|
|
41
|
43
|
/**
|
|
@@ -48,7 +50,7 @@ const ScreenObtainer = {
|
48
|
50
|
_createObtainStreamMethod() {
|
49
|
51
|
const supportsGetDisplayMedia = browser.supportsGetDisplayMedia();
|
50
|
52
|
|
51
|
|
- if (browser.isElectron() && !this.options.testing?.electronUseGetDisplayMedia) {
|
|
53
|
+ if (browser.isElectron()) {
|
52
|
54
|
return this.obtainScreenOnElectron;
|
53
|
55
|
} else if (browser.isReactNative() && supportsGetDisplayMedia) {
|
54
|
56
|
return this.obtainScreenFromGetDisplayMediaRN;
|
|
@@ -94,12 +96,24 @@ const ScreenObtainer = {
|
94
|
96
|
* @param {Object} options - Optional parameters.
|
95
|
97
|
*/
|
96
|
98
|
obtainScreenOnElectron(onSuccess, onFailure, options = {}) {
|
97
|
|
- if (typeof window.JitsiMeetScreenObtainer?.openDesktopPicker === 'function') {
|
98
|
|
- // Detect if we have the fallback option.
|
99
|
|
- if (window.JitsiMeetScreenObtainer?.gDMSupported) {
|
100
|
|
- return this.obtainScreenFromGetDisplayMedia(onSuccess, onFailure);
|
101
|
|
- }
|
|
99
|
+ if (!this._electronSkipDisplayMedia) {
|
|
100
|
+ // Fall-back to the old API in case of not supported error. This can happen if
|
|
101
|
+ // an old Electron SDK is used with a new Jitsi Meet + lib-jitsi-meet version.
|
|
102
|
+ this.obtainScreenFromGetDisplayMedia(onSuccess, err => {
|
|
103
|
+ if (err.name === JitsiTrackErrors.SCREENSHARING_NOT_SUPPORTED_ERROR) {
|
|
104
|
+ // Make sure we don't recurse infinitely.
|
|
105
|
+ this._electronSkipDisplayMedia = true;
|
|
106
|
+ this.obtainScreenOnElectron(onSuccess, onFailure);
|
|
107
|
+ } else {
|
|
108
|
+ onFailure(err);
|
|
109
|
+ }
|
|
110
|
+ });
|
|
111
|
+
|
|
112
|
+ return;
|
|
113
|
+ }
|
102
|
114
|
|
|
115
|
+ // TODO: legacy flow, remove after the Electron SDK supporting gDM has been out for a while.
|
|
116
|
+ if (typeof window.JitsiMeetScreenObtainer?.openDesktopPicker === 'function') {
|
103
|
117
|
const { desktopSharingFrameRate, desktopSharingResolution, desktopSharingSources } = this.options;
|
104
|
118
|
|
105
|
119
|
window.JitsiMeetScreenObtainer.openDesktopPicker(
|
|
@@ -293,14 +307,18 @@ const ScreenObtainer = {
|
293
|
307
|
})
|
294
|
308
|
.catch(error => {
|
295
|
309
|
const errorDetails = {
|
296
|
|
- errorName: error?.name,
|
297
|
|
- errorMsg: error?.message,
|
298
|
|
- errorStack: error?.stack
|
|
310
|
+ errorCode: error.code,
|
|
311
|
+ errorName: error.name,
|
|
312
|
+ errorMsg: error.message,
|
|
313
|
+ errorStack: error.stack
|
299
|
314
|
};
|
300
|
315
|
|
301
|
316
|
logger.warn('getDisplayMedia error', JSON.stringify(constraints), JSON.stringify(errorDetails));
|
302
|
317
|
|
303
|
|
- if (errorDetails.errorMsg?.indexOf('denied by system') !== -1) {
|
|
318
|
+ if (errorDetails.code === DOMException.NOT_SUPPORTED_ERR) {
|
|
319
|
+ // This error is thrown when an Electron client has not set a permissions handler.
|
|
320
|
+ errorCallback(new JitsiTrackError(JitsiTrackErrors.SCREENSHARING_NOT_SUPPORTED_ERROR));
|
|
321
|
+ } else if (errorDetails.errorMsg?.indexOf('denied by system') !== -1) {
|
304
|
322
|
// On Chrome this is the only thing different between error returned when user cancels
|
305
|
323
|
// and when no permission was given on the OS level.
|
306
|
324
|
errorCallback(new JitsiTrackError(JitsiTrackErrors.PERMISSION_DENIED));
|