Browse Source

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

It was behind a testing flag setScreenSharingResolutionConstraints.
dev1
Jaya Allamsetty 2 years ago
parent
commit
a85022d992
1 changed files with 16 additions and 19 deletions
  1. 16
    19
      modules/RTC/ScreenObtainer.js

+ 16
- 19
modules/RTC/ScreenObtainer.js View File

@@ -216,33 +216,30 @@ const ScreenObtainer = {
216 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 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 223
         if (typeof desktopSharingFrameRate === 'object') {
230 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 244
         if (Object.keys(video).length === 0) {
248 245
             video = true;

Loading…
Cancel
Save