Browse Source

feat: Add an option to set bogus resolution constraints for getDisplayMedia. (#1991)

* feat: Add an option to set bogus resolution constraints for getDisplayMedia.
dev1
bgrozev 3 years ago
parent
commit
6870779a12
No account linked to committer's email address
1 changed files with 18 additions and 1 deletions
  1. 18
    1
      modules/RTC/ScreenObtainer.js

+ 18
- 1
modules/RTC/ScreenObtainer.js View File

215
         }
215
         }
216
 
216
 
217
         const { desktopSharingFrameRate } = this.options;
217
         const { desktopSharingFrameRate } = this.options;
218
-        const video = typeof desktopSharingFrameRate === 'object' ? { frameRate: desktopSharingFrameRate } : true;
218
+        const setScreenSharingResolutionConstraints = browser.isChromiumBased()
219
+            && this.options?.testing?.setScreenSharingResolutionConstraints;
220
+        let video = {};
221
+
222
+        if (typeof desktopSharingFrameRate === 'object') {
223
+            video.frameRate = desktopSharingFrameRate;
224
+        }
225
+        if (setScreenSharingResolutionConstraints) {
226
+            // Set bogus resolution constraints to work around
227
+            // https://bugs.chromium.org/p/chromium/issues/detail?id=1056311
228
+            video.height = 99999;
229
+            video.width = 99999;
230
+        }
231
+
219
         const audio = this._getAudioConstraints();
232
         const audio = this._getAudioConstraints();
220
 
233
 
221
         // At the time of this writing 'min' constraint for fps is not supported by getDisplayMedia.
234
         // At the time of this writing 'min' constraint for fps is not supported by getDisplayMedia.
222
         video.frameRate && delete video.frameRate.min;
235
         video.frameRate && delete video.frameRate.min;
223
 
236
 
237
+        if (Object.keys(video).length === 0) {
238
+            video = true;
239
+        }
240
+
224
         const constraints = {
241
         const constraints = {
225
             video,
242
             video,
226
             audio,
243
             audio,

Loading…
Cancel
Save