|
|
@@ -66,29 +66,53 @@ const ScreenObtainer = {
|
|
66
|
66
|
* Initializes the function used to obtain a screen capture
|
|
67
|
67
|
* (this.obtainStream).
|
|
68
|
68
|
*
|
|
69
|
|
- * @param options {object}
|
|
70
|
|
- * @param gum {Function} GUM method
|
|
|
69
|
+ * @param {object} options
|
|
|
70
|
+ * @param {boolean} [options.disableDesktopSharing]
|
|
|
71
|
+ * @param {boolean} [options.desktopSharingChromeDisabled]
|
|
|
72
|
+ * @param {boolean} [options.desktopSharingChromeExtId]
|
|
|
73
|
+ * @param {boolean} [options.desktopSharingFirefoxDisabled]
|
|
|
74
|
+ * @param {boolean} [options.desktopSharingFirefoxExtId] (deprecated)
|
|
|
75
|
+ * @param {Function} gum GUM method
|
|
71
|
76
|
*/
|
|
72
|
|
- init(options, gum) {
|
|
73
|
|
- let obtainDesktopStream = null;
|
|
74
|
|
-
|
|
|
77
|
+ init(options = {
|
|
|
78
|
+ disableDesktopSharing: false,
|
|
|
79
|
+ desktopSharingChromeDisabled: false,
|
|
|
80
|
+ desktopSharingChromeExtId: null,
|
|
|
81
|
+ desktopSharingFirefoxDisabled: false,
|
|
|
82
|
+ desktopSharingFirefoxExtId: null
|
|
|
83
|
+ }, gum) {
|
|
75
|
84
|
// eslint-disable-next-line no-param-reassign
|
|
76
|
85
|
this.options = options = options || {};
|
|
77
|
86
|
gumFunction = gum;
|
|
78
|
87
|
|
|
79
|
|
- if (RTCBrowserType.isFirefox()) {
|
|
80
|
|
- initFirefoxExtensionDetection(options);
|
|
|
88
|
+ this.obtainStream
|
|
|
89
|
+ = this.options.disableDesktopSharing
|
|
|
90
|
+ ? null : this._createObtainStreamMethod(options);
|
|
|
91
|
+
|
|
|
92
|
+ if (!this.obtainStream) {
|
|
|
93
|
+ logger.info('Desktop sharing disabled');
|
|
81
|
94
|
}
|
|
|
95
|
+ },
|
|
82
|
96
|
|
|
|
97
|
+ /**
|
|
|
98
|
+ * Returns a method which will be used to obtain the screen sharing stream
|
|
|
99
|
+ * (based on the browser type).
|
|
|
100
|
+ *
|
|
|
101
|
+ * @param {object} options passed from {@link init} - check description
|
|
|
102
|
+ * there
|
|
|
103
|
+ * @returns {Function}
|
|
|
104
|
+ * @private
|
|
|
105
|
+ */
|
|
|
106
|
+ _createObtainStreamMethod(options) {
|
|
83
|
107
|
if (RTCBrowserType.isNWJS()) {
|
|
84
|
|
- obtainDesktopStream = (_, onSuccess, onFailure) => {
|
|
|
108
|
+ return (_, onSuccess, onFailure) => {
|
|
85
|
109
|
window.JitsiMeetNW.obtainDesktopStream(
|
|
86
|
110
|
onSuccess,
|
|
87
|
111
|
(error, constraints) => {
|
|
88
|
112
|
let jitsiError;
|
|
89
|
113
|
|
|
90
|
114
|
// FIXME:
|
|
91
|
|
- // This is very very durty fix for recognising that the
|
|
|
115
|
+ // This is very very dirty fix for recognising that the
|
|
92
|
116
|
// user have clicked the cancel button from the Desktop
|
|
93
|
117
|
// sharing pick window. The proper solution would be to
|
|
94
|
118
|
// detect this in the NWJS application by checking the
|
|
|
@@ -116,57 +140,67 @@ const ScreenObtainer = {
|
|
116
|
140
|
});
|
|
117
|
141
|
};
|
|
118
|
142
|
} else if (RTCBrowserType.isElectron()) {
|
|
119
|
|
- obtainDesktopStream = this.obtainScreenOnElectron;
|
|
|
143
|
+ return this.obtainScreenOnElectron;
|
|
120
|
144
|
} else if (RTCBrowserType.isTemasysPluginUsed()) {
|
|
121
|
145
|
// XXX Don't require Temasys unless it's to be used because it
|
|
122
|
146
|
// doesn't run on React Native, for example.
|
|
123
|
147
|
const plugin
|
|
124
|
148
|
= require('./adapter.screenshare').WebRTCPlugin.plugin;
|
|
125
|
149
|
|
|
126
|
|
- if (plugin.HasScreensharingFeature) {
|
|
127
|
|
- if (plugin.isScreensharingAvailable) {
|
|
128
|
|
- obtainDesktopStream = obtainWebRTCScreen;
|
|
129
|
|
- logger.info('Using Temasys plugin for desktop sharing');
|
|
130
|
|
- } else {
|
|
131
|
|
- logger.info(
|
|
132
|
|
- 'Screensharing not available with Temasys plugin on'
|
|
133
|
|
- + ' this site');
|
|
134
|
|
- }
|
|
135
|
|
- } else {
|
|
136
|
|
- logger.info(
|
|
|
150
|
+ if (!plugin.HasScreensharingFeature) {
|
|
|
151
|
+ logger.warn(
|
|
137
|
152
|
'Screensharing not supported by this plugin version');
|
|
|
153
|
+
|
|
|
154
|
+ return null;
|
|
|
155
|
+ } else if (!plugin.isScreensharingAvailable) {
|
|
|
156
|
+ logger.warn(
|
|
|
157
|
+ 'Screensharing not available with Temasys plugin on'
|
|
|
158
|
+ + ' this site');
|
|
|
159
|
+
|
|
|
160
|
+ return null;
|
|
138
|
161
|
}
|
|
|
162
|
+
|
|
|
163
|
+ logger.info('Using Temasys plugin for desktop sharing');
|
|
|
164
|
+
|
|
|
165
|
+ return obtainWebRTCScreen;
|
|
139
|
166
|
} else if (RTCBrowserType.isChrome()) {
|
|
140
|
|
- if (options.desktopSharingChromeDisabled
|
|
|
167
|
+ if (RTCBrowserType.getChromeVersion() < 34) {
|
|
|
168
|
+ logger.info('Chrome extension not supported until ver 34');
|
|
|
169
|
+
|
|
|
170
|
+ return null;
|
|
|
171
|
+ } else if (options.desktopSharingChromeDisabled
|
|
141
|
172
|
|| options.desktopSharingChromeMethod === false
|
|
142
|
173
|
|| !options.desktopSharingChromeExtId) {
|
|
|
174
|
+
|
|
143
|
175
|
// TODO: desktopSharingChromeMethod is deprecated, remove.
|
|
144
|
|
- obtainDesktopStream = null;
|
|
145
|
|
- } else if (RTCBrowserType.getChromeVersion() >= 34) {
|
|
146
|
|
- obtainDesktopStream
|
|
147
|
|
- = this.obtainScreenFromExtension;
|
|
148
|
|
- logger.info('Using Chrome extension for desktop sharing');
|
|
149
|
|
- initChromeExtension(options);
|
|
150
|
|
- } else {
|
|
151
|
|
- logger.info('Chrome extension not supported until ver 34');
|
|
|
176
|
+ return null;
|
|
152
|
177
|
}
|
|
|
178
|
+
|
|
|
179
|
+ logger.info('Using Chrome extension for desktop sharing');
|
|
|
180
|
+ initChromeExtension(options);
|
|
|
181
|
+
|
|
|
182
|
+ return this.obtainScreenFromExtension;
|
|
153
|
183
|
} else if (RTCBrowserType.isFirefox()) {
|
|
154
|
184
|
if (options.desktopSharingFirefoxDisabled) {
|
|
155
|
|
- obtainDesktopStream = null;
|
|
|
185
|
+ return null;
|
|
156
|
186
|
} else if (window.location.protocol === 'http:') {
|
|
157
|
187
|
logger.log('Screen sharing is not supported over HTTP. '
|
|
158
|
188
|
+ 'Use of HTTPS is required.');
|
|
159
|
|
- obtainDesktopStream = null;
|
|
160
|
|
- } else {
|
|
161
|
|
- obtainDesktopStream = this.obtainScreenOnFirefox;
|
|
|
189
|
+
|
|
|
190
|
+ return null;
|
|
162
|
191
|
}
|
|
163
|
|
- }
|
|
164
|
192
|
|
|
165
|
|
- if (!obtainDesktopStream) {
|
|
166
|
|
- logger.info('Desktop sharing disabled');
|
|
|
193
|
+ initFirefoxExtensionDetection(options);
|
|
|
194
|
+
|
|
|
195
|
+ return this.obtainScreenOnFirefox;
|
|
167
|
196
|
}
|
|
168
|
197
|
|
|
169
|
|
- this.obtainStream = obtainDesktopStream;
|
|
|
198
|
+ logger.warn(
|
|
|
199
|
+ 'Screen sharing not supported by the current browser: ',
|
|
|
200
|
+ RTCBrowserType.getBrowserType(),
|
|
|
201
|
+ RTCBrowserType.getBrowserName());
|
|
|
202
|
+
|
|
|
203
|
+ return null;
|
|
170
|
204
|
},
|
|
171
|
205
|
|
|
172
|
206
|
/**
|