瀏覽代碼

fix(screenshare): do not limit resolution for fake screenshare (#877)

A camera source can be used as a screenshare source.
Normally for screenshare resolution is not capped and
the same will be true for the fake screenshare source.
dev1
virtuacoplenny 6 年之前
父節點
當前提交
320919ecfa
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 29 行新增25 行删除
  1. 29
    25
      modules/RTC/RTCUtils.js

+ 29
- 25
modules/RTC/RTCUtils.js 查看文件

@@ -1034,22 +1034,9 @@ class RTCUtils extends Listenable {
1034 1034
                 new Error('Desktop sharing is not supported!'));
1035 1035
         }
1036 1036
 
1037
-        const {
1038
-            desktopSharingExtensionExternalInstallation,
1039
-            desktopSharingFrameRate,
1040
-            desktopSharingSources
1041
-        } = options;
1042
-
1043 1037
         return new Promise((resolve, reject) => {
1044 1038
             screenObtainer.obtainStream(
1045
-                {
1046
-                    ...desktopSharingExtensionExternalInstallation,
1047
-                    desktopSharingSources,
1048
-                    gumOptions: {
1049
-                        frameRate: desktopSharingFrameRate
1050
-                    },
1051
-                    trackOptions: getTrackSSConstraints(options)
1052
-                },
1039
+                this._parseDesktopSharingOptions(options),
1053 1040
                 stream => {
1054 1041
                     resolve(stream);
1055 1042
                 },
@@ -1310,23 +1297,40 @@ class RTCUtils extends Listenable {
1310 1297
                         device.kind === 'videoinput'
1311 1298
                             && (device.deviceId === desktopSharingSourceDevice
1312 1299
                             || device.label === desktopSharingSourceDevice));
1313
-
1314 1300
                 const requestedDevices = [ 'video' ];
1315
-                const constraints = newGetConstraints(
1316
-                    requestedDevices, { options });
1317
-
1318
-                // Use exact to make sure there is no fallthrough to another
1319
-                // camera device. If a matching device could not be found,
1320
-                // try anyways and let the caller handle errors.
1321
-                constraints.video.deviceId = {
1322
-                    exact: (matchingDevice && matchingDevice.deviceId)
1323
-                        || desktopSharingSourceDevice
1301
+
1302
+                // Leverage the helper used by {@link _newGetDesktopMedia} to
1303
+                // get constraints for the desktop stream.
1304
+                const { gumOptions, trackOptions }
1305
+                    = this._parseDesktopSharingOptions(options);
1306
+
1307
+                // Create a custom constraints object to use exact device
1308
+                // matching to make sure there is no fallthrough to another
1309
+                // camera device. If a matching device could not be found, try
1310
+                // anyways and let the caller handle errors.
1311
+                const constraints = {
1312
+                    video: {
1313
+                        ...gumOptions,
1314
+                        deviceId: {
1315
+                            exact: (matchingDevice && matchingDevice.deviceId)
1316
+                                || desktopSharingSourceDevice
1317
+                        }
1318
+                    }
1324 1319
                 };
1325 1320
 
1326 1321
                 return this._newGetUserMediaWithConstraints(
1327 1322
                     requestedDevices, constraints)
1328 1323
                     .then(stream => {
1329
-                        return { stream };
1324
+                        const track = stream && stream.getTracks()[0];
1325
+                        const applyConstrainsPromise
1326
+                            = track && track.applyConstraints
1327
+                                ? track.applyConstraints(trackOptions)
1328
+                                : Promise.resolve();
1329
+
1330
+                        return applyConstrainsPromise
1331
+                            .then(() => {
1332
+                                return { stream };
1333
+                            });
1330 1334
                     });
1331 1335
             }
1332 1336
 

Loading…
取消
儲存