Browse Source

fix(electron):Respect desktopSharingSources option

dev1
Hristo Terezov 3 years ago
parent
commit
f3f922a895

+ 9
- 4
modules/RTC/RTCUtils.js View File

@@ -443,11 +443,12 @@ class RTCUtils extends Listenable {
443 443
      * logic compared to use screenObtainer versus normal device capture logic
444 444
      * in RTCUtils#_getUserMedia.
445 445
      *
446
+     * @param {Object} options - Optional parameters.
446 447
      * @returns {Promise} A promise which will be resolved with an object which
447 448
      * contains the acquired display stream. If desktop sharing is not supported
448 449
      * then a rejected promise will be returned.
449 450
      */
450
-    _getDesktopMedia() {
451
+    _getDesktopMedia(options) {
451 452
         if (!screenObtainer.isSupported()) {
452 453
             return Promise.reject(new Error('Desktop sharing is not supported!'));
453 454
         }
@@ -459,7 +460,8 @@ class RTCUtils extends Listenable {
459 460
                 },
460 461
                 error => {
461 462
                     reject(error);
462
-                });
463
+                },
464
+                options);
463 465
         });
464 466
     }
465 467
 
@@ -509,6 +511,8 @@ class RTCUtils extends Listenable {
509 511
      * @param {Object} options.desktopSharingFrameRate.max - Maximum fps
510 512
      * @param {String} options.desktopSharingSourceDevice - The device id or
511 513
      * label for a video input source that should be used for screensharing.
514
+     * @param {Array<string>} options.desktopSharingSources - The types of sources ("screen", "window", etc)
515
+     * from which the user can select what to share.
512 516
      * @returns {Promise} The promise, when successful, will return an array of
513 517
      * meta data for the requested device type, which includes the stream and
514 518
      * track. If an error occurs, it will be deferred to the caller for
@@ -542,7 +546,8 @@ class RTCUtils extends Listenable {
542 546
             }
543 547
 
544 548
             const {
545
-                desktopSharingSourceDevice
549
+                desktopSharingSourceDevice,
550
+                desktopSharingSources
546 551
             } = otherOptions;
547 552
 
548 553
             // Attempt to use a video input device as a screenshare source if
@@ -580,7 +585,7 @@ class RTCUtils extends Listenable {
580 585
                     });
581 586
             }
582 587
 
583
-            return this._getDesktopMedia();
588
+            return this._getDesktopMedia({ desktopSharingSources });
584 589
         }.bind(this);
585 590
 
586 591
         /**

+ 4
- 2
modules/RTC/ScreenObtainer.js View File

@@ -124,14 +124,16 @@ const ScreenObtainer = {
124 124
      *
125 125
      * @param onSuccess - Success callback.
126 126
      * @param onFailure - Failure callback.
127
+     * @param {Object} options - Optional parameters.
127 128
      */
128
-    obtainScreenOnElectron(onSuccess, onFailure) {
129
+    obtainScreenOnElectron(onSuccess, onFailure, options = {}) {
129 130
         if (window.JitsiMeetScreenObtainer && window.JitsiMeetScreenObtainer.openDesktopPicker) {
130 131
             const { desktopSharingFrameRate, desktopSharingSources } = this.options;
131 132
 
132 133
             window.JitsiMeetScreenObtainer.openDesktopPicker(
133 134
                 {
134
-                    desktopSharingSources: desktopSharingSources || [ 'screen', 'window' ]
135
+                    desktopSharingSources:
136
+                        options.desktopSharingSources || desktopSharingSources || [ 'screen', 'window' ]
135 137
                 },
136 138
                 (streamId, streamType, screenShareAudio = false) => {
137 139
                     if (streamId) {

+ 5
- 1
types/auto/modules/RTC/RTCUtils.d.ts View File

@@ -40,11 +40,12 @@ declare class RTCUtils extends Listenable {
40 40
      * logic compared to use screenObtainer versus normal device capture logic
41 41
      * in RTCUtils#_getUserMedia.
42 42
      *
43
+     * @param {Object} options - Optional parameters.
43 44
      * @returns {Promise} A promise which will be resolved with an object which
44 45
      * contains the acquired display stream. If desktop sharing is not supported
45 46
      * then a rejected promise will be returned.
46 47
      */
47
-    _getDesktopMedia(): Promise<any>;
48
+    _getDesktopMedia(options: any): Promise<any>;
48 49
     /**
49 50
      * Private utility for determining if the passed in MediaStream contains
50 51
      * tracks of the type(s) specified in the requested devices.
@@ -70,6 +71,8 @@ declare class RTCUtils extends Listenable {
70 71
      * @param {Object} options.desktopSharingFrameRate.max - Maximum fps
71 72
      * @param {String} options.desktopSharingSourceDevice - The device id or
72 73
      * label for a video input source that should be used for screensharing.
74
+     * @param {Array<string>} options.desktopSharingSources - The types of sources ("screen", "window", etc)
75
+     * from which the user can select what to share.
73 76
      * @returns {Promise} The promise, when successful, will return an array of
74 77
      * meta data for the requested device type, which includes the stream and
75 78
      * track. If an error occurs, it will be deferred to the caller for
@@ -82,6 +85,7 @@ declare class RTCUtils extends Listenable {
82 85
             max: any;
83 86
         };
84 87
         desktopSharingSourceDevice: string;
88
+        desktopSharingSources: Array<string>;
85 89
     }): Promise<any>;
86 90
     /**
87 91
      * Checks whether it is possible to enumerate available cameras/microphones.

+ 4
- 2
types/auto/modules/RTC/ScreenObtainer.d.ts View File

@@ -64,15 +64,17 @@ declare namespace ScreenObtainer {
64 64
      *
65 65
      * @param onSuccess - Success callback.
66 66
      * @param onFailure - Failure callback.
67
+     * @param {Object} options - Optional parameters.
67 68
      */
68
-    function obtainScreenOnElectron(onSuccess: any, onFailure: any): void;
69
+    function obtainScreenOnElectron(onSuccess: any, onFailure: any, options?: any): void;
69 70
     /**
70 71
      * Obtains a screen capture stream on Electron.
71 72
      *
72 73
      * @param onSuccess - Success callback.
73 74
      * @param onFailure - Failure callback.
75
+     * @param {Object} options - Optional parameters.
74 76
      */
75
-    function obtainScreenOnElectron(onSuccess: any, onFailure: any): void;
77
+    function obtainScreenOnElectron(onSuccess: any, onFailure: any, options?: any): void;
76 78
     /**
77 79
      * Obtains a screen capture stream using getDisplayMedia.
78 80
      *

Loading…
Cancel
Save