浏览代码

ref(ScreenObtainer): Always set the resolution constraints for SS.

It was behind a testing flag setScreenSharingResolutionConstraints.
dev1
Jaya Allamsetty 2 年前
父节点
当前提交
a85022d992
共有 1 个文件被更改,包括 16 次插入19 次删除
  1. 16
    19
      modules/RTC/ScreenObtainer.js

+ 16
- 19
modules/RTC/ScreenObtainer.js 查看文件

216
             getDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
216
             getDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
217
         }
217
         }
218
 
218
 
219
-        const { desktopSharingFrameRate } = this.options;
220
-        const setScreenSharingResolutionConstraints = browser.isChromiumBased()
221
-            && this.options?.testing?.setScreenSharingResolutionConstraints;
219
+        const audio = this._getAudioConstraints();
222
         let video = {};
220
         let video = {};
223
-
224
-        // Allow users to seamlessly switch which tab they are sharing without having to select the tab again.
225
-        if (browser.isChromiumBased() && browser.isVersionGreaterThan(106)) {
226
-            video.surfaceSwitching = 'include';
227
-        }
221
+        const { desktopSharingFrameRate } = this.options;
228
 
222
 
229
         if (typeof desktopSharingFrameRate === 'object') {
223
         if (typeof desktopSharingFrameRate === 'object') {
230
             video.frameRate = desktopSharingFrameRate;
224
             video.frameRate = desktopSharingFrameRate;
231
         }
225
         }
232
 
226
 
233
-        // Capturing the screenshare at very high resolutions restricts the framerate. Therefore, skip this hack when
234
-        // the capture framerate is > 5 fps.
235
-        if (setScreenSharingResolutionConstraints && !(desktopSharingFrameRate?.max > SS_DEFAULT_FRAME_RATE)) {
236
-            // Set bogus resolution constraints to work around
237
-            // https://bugs.chromium.org/p/chromium/issues/detail?id=1056311
238
-            video.height = 99999;
239
-            video.width = 99999;
240
-        }
227
+        // At the time of this writing 'min' constraint for fps is not supported by getDisplayMedia on any of the
228
+        // browsers. getDisplayMedia will fail with an error "invalid constraints" in this case.
229
+        video.frameRate && delete video.frameRate.min;
241
 
230
 
242
-        const audio = this._getAudioConstraints();
231
+        if (browser.isChromiumBased()) {
232
+            // Allow users to seamlessly switch which tab they are sharing without having to select the tab again.
233
+            browser.isVersionGreaterThan(106) && (video.surfaceSwitching = 'include');
243
 
234
 
244
-        // At the time of this writing 'min' constraint for fps is not supported by getDisplayMedia.
245
-        video.frameRate && delete video.frameRate.min;
235
+            // Set bogus resolution constraints to work around
236
+            // https://bugs.chromium.org/p/chromium/issues/detail?id=1056311 for low fps screenshare. Capturing SS at
237
+            // very high resolutions restricts the framerate. Therefore, skip this hack when capture fps > 5 fps.
238
+            if (desktopSharingFrameRate?.max <= SS_DEFAULT_FRAME_RATE) {
239
+                video.height = 99999;
240
+                video.width = 99999;
241
+            }
242
+        }
246
 
243
 
247
         if (Object.keys(video).length === 0) {
244
         if (Object.keys(video).length === 0) {
248
             video = true;
245
             video = true;

正在加载...
取消
保存