|
@@ -180,11 +180,15 @@ const ScreenObtainer = {
|
180
|
180
|
|
181
|
181
|
// We have to use the old API on Electron to get a desktop stream.
|
182
|
182
|
navigator.mediaDevices.getUserMedia(constraints)
|
183
|
|
- .then(stream => onSuccess({
|
184
|
|
- stream,
|
185
|
|
- sourceId: streamId,
|
186
|
|
- sourceType: streamType
|
187
|
|
- }), onFailure);
|
|
183
|
+ .then(stream => {
|
|
184
|
+ this.setContentHint(stream);
|
|
185
|
+ onSuccess({
|
|
186
|
+ stream,
|
|
187
|
+ sourceId: streamId,
|
|
188
|
+ sourceType: streamType
|
|
189
|
+ });
|
|
190
|
+ })
|
|
191
|
+ .catch(err => onFailure(err));
|
188
|
192
|
} else {
|
189
|
193
|
// As noted in Chrome Desktop Capture API:
|
190
|
194
|
// If user didn't select any source (i.e. canceled the prompt)
|
|
@@ -257,6 +261,7 @@ const ScreenObtainer = {
|
257
|
261
|
|
258
|
262
|
getDisplayMedia(constraints)
|
259
|
263
|
.then(stream => {
|
|
264
|
+ this.setContentHint(stream);
|
260
|
265
|
callback({
|
261
|
266
|
stream,
|
262
|
267
|
sourceId: stream.id
|
|
@@ -294,6 +299,7 @@ const ScreenObtainer = {
|
294
|
299
|
|
295
|
300
|
navigator.mediaDevices.getDisplayMedia({ video: true })
|
296
|
301
|
.then(stream => {
|
|
302
|
+ this.setContentHint(stream);
|
297
|
303
|
callback({
|
298
|
304
|
stream,
|
299
|
305
|
sourceId: stream.id });
|
|
@@ -304,6 +310,24 @@ const ScreenObtainer = {
|
304
|
310
|
});
|
305
|
311
|
},
|
306
|
312
|
|
|
313
|
+ /** Sets the contentHint on the transmitted MediaStreamTrack to indicate charaterstics in the video stream, which
|
|
314
|
+ * informs RTCPeerConnection on how to encode the track (to prefer motion or individual frame detail).
|
|
315
|
+ *
|
|
316
|
+ * @param {MediaStream} stream - The captured desktop stream.
|
|
317
|
+ * @returns {void}
|
|
318
|
+ */
|
|
319
|
+ setContentHint(stream) {
|
|
320
|
+ const { desktopSharingFrameRate } = this.options;
|
|
321
|
+ const desktopTrack = stream.getVideoTracks()[0];
|
|
322
|
+
|
|
323
|
+ // Set contentHint on the desktop track based on the fps requested.
|
|
324
|
+ if ('contentHint' in desktopTrack) {
|
|
325
|
+ desktopTrack.contentHint = desktopSharingFrameRate?.max > SS_DEFAULT_FRAME_RATE ? 'motion' : 'detail';
|
|
326
|
+ } else {
|
|
327
|
+ logger.warn('MediaStreamTrack contentHint attribute not supported');
|
|
328
|
+ }
|
|
329
|
+ },
|
|
330
|
+
|
307
|
331
|
/**
|
308
|
332
|
* Sets the max frame rate to be used for a desktop track capture.
|
309
|
333
|
*
|