Explorar el Código

fix(presenter): resize desktop track to 720p when presenter starts

j8
Jaya Allamsetty hace 5 años
padre
commit
7b25b847ba
Se han modificado 2 ficheros con 33 adiciones y 12 borrados
  1. 32
    11
      conference.js
  2. 1
    1
      react/features/base/tracks/functions.js

+ 32
- 11
conference.js Ver fichero

@@ -1665,19 +1665,40 @@ export default {
1665 1665
             return;
1666 1666
         }
1667 1667
 
1668
+        // Create a new presenter track and apply the presenter effect.
1668 1669
         if (!this.localPresenterVideo && !mute) {
1669
-            // create a new presenter track and apply the presenter effect.
1670
-            let { height } = this.localVideo.track.getSettings();
1671
-
1672
-            // Workaround for Firefox since it doesn't return the correct width/height of the desktop stream
1673
-            // that is being currently shared.
1674
-            if (!height) {
1675
-                const desktopResizeConstraints = {
1670
+            let { aspectRatio, height } = this.localVideo.track.getSettings();
1671
+            const { width } = this.localVideo.track.getSettings();
1672
+            let desktopResizeConstraints = {};
1673
+            let resizeDesktopStream = false;
1674
+            const DESKTOP_STREAM_CAP = 720;
1675
+
1676
+            // Determine the constraints if the desktop track needs to be resized.
1677
+            // Resizing is needed when the resolution cannot be determined or when
1678
+            // the window is bigger than 720p.
1679
+            if (height && width) {
1680
+                aspectRatio = aspectRatio ?? (width / height).toPrecision(4);
1681
+                const advancedConstraints = [ { aspectRatio } ];
1682
+                const isPortrait = height >= width;
1683
+
1684
+                // Determine which dimension needs resizing and resize only that side
1685
+                // keeping the aspect ratio same as before.
1686
+                if (isPortrait && width > DESKTOP_STREAM_CAP) {
1687
+                    resizeDesktopStream = true;
1688
+                    advancedConstraints.push({ width: DESKTOP_STREAM_CAP });
1689
+                } else if (!isPortrait && height > DESKTOP_STREAM_CAP) {
1690
+                    resizeDesktopStream = true;
1691
+                    advancedConstraints.push({ height: DESKTOP_STREAM_CAP });
1692
+                }
1693
+                desktopResizeConstraints.advanced = advancedConstraints;
1694
+            } else {
1695
+                resizeDesktopStream = true;
1696
+                desktopResizeConstraints = {
1676 1697
                     width: 1280,
1677
-                    height: 720,
1678
-                    resizeMode: 'crop-and-scale'
1698
+                    height: 720
1679 1699
                 };
1680
-
1700
+            }
1701
+            if (resizeDesktopStream) {
1681 1702
                 try {
1682 1703
                     await this.localVideo.track.applyConstraints(desktopResizeConstraints);
1683 1704
                 } catch (err) {
@@ -1685,7 +1706,7 @@ export default {
1685 1706
 
1686 1707
                     return;
1687 1708
                 }
1688
-                height = desktopResizeConstraints.height;
1709
+                height = this.localVideo.track.getSettings().height ?? DESKTOP_STREAM_CAP;
1689 1710
             }
1690 1711
             const defaultCamera = getUserSelectedCameraDeviceId(APP.store.getState());
1691 1712
             let effect;

+ 1
- 1
react/features/base/tracks/functions.js Ver fichero

@@ -27,7 +27,7 @@ export async function createLocalPresenterTrack(options, desktopHeight) {
27 27
 
28 28
     // compute the constraints of the camera track based on the resolution
29 29
     // of the desktop screen that is being shared.
30
-    const cameraHeights = [ 180, 270, 360, 540, 720 ];
30
+    const cameraHeights = [ 120, 180, 240, 360, 480, 600, 720 ];
31 31
     const proportion = 4;
32 32
     const result = cameraHeights.find(
33 33
             height => (desktopHeight / proportion) < height);

Loading…
Cancelar
Guardar