瀏覽代碼

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 年之前
父節點
當前提交
6870779a12
No account linked to committer's email address
共有 1 個文件被更改,包括 18 次插入1 次删除
  1. 18
    1
      modules/RTC/ScreenObtainer.js

+ 18
- 1
modules/RTC/ScreenObtainer.js 查看文件

@@ -215,12 +215,29 @@ const ScreenObtainer = {
215 215
         }
216 216
 
217 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 232
         const audio = this._getAudioConstraints();
220 233
 
221 234
         // At the time of this writing 'min' constraint for fps is not supported by getDisplayMedia.
222 235
         video.frameRate && delete video.frameRate.min;
223 236
 
237
+        if (Object.keys(video).length === 0) {
238
+            video = true;
239
+        }
240
+
224 241
         const constraints = {
225 242
             video,
226 243
             audio,

Loading…
取消
儲存