Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Jaya Allamsetty7b25b847ba1e
diff --git a/conference.js b/conference.js
index f329dedd54..ff8aecda72 100644
--- a/conference.js
+++ b/conference.js
@@ -1665,19 +1665,40 @@ export default {
return;
}
+ // Create a new presenter track and apply the presenter effect.
if (!this.localPresenterVideo && !mute) {
- // create a new presenter track and apply the presenter effect.
- let { height } = this.localVideo.track.getSettings();
-
- // Workaround for Firefox since it doesn't return the correct width/height of the desktop stream
- // that is being currently shared.
- if (!height) {
- const desktopResizeConstraints = {
+ let { aspectRatio, height } = this.localVideo.track.getSettings();
+ const { width } = this.localVideo.track.getSettings();
+ let desktopResizeConstraints = {};
+ let resizeDesktopStream = false;
+ const DESKTOP_STREAM_CAP = 720;
+
+ // Determine the constraints if the desktop track needs to be resized.
+ // Resizing is needed when the resolution cannot be determined or when
+ // the window is bigger than 720p.
+ if (height && width) {
+ aspectRatio = aspectRatio ?? (width / height).toPrecision(4);
+ const advancedConstraints = [ { aspectRatio } ];
+ const isPortrait = height >= width;
+
+ // Determine which dimension needs resizing and resize only that side
+ // keeping the aspect ratio same as before.
+ if (isPortrait && width > DESKTOP_STREAM_CAP) {
+ resizeDesktopStream = true;
+ advancedConstraints.push({ width: DESKTOP_STREAM_CAP });
+ } else if (!isPortrait && height > DESKTOP_STREAM_CAP) {
+ resizeDesktopStream = true;
+ advancedConstraints.push({ height: DESKTOP_STREAM_CAP });
+ }
+ desktopResizeConstraints.advanced = advancedConstraints;
+ } else {
+ resizeDesktopStream = true;
+ desktopResizeConstraints = {
width: 1280,
- height: 720,
- resizeMode: 'crop-and-scale'
+ height: 720
};
-
+ }
+ if (resizeDesktopStream) {
try {
await this.localVideo.track.applyConstraints(desktopResizeConstraints);
} catch (err) {
@@ -1685,7 +1706,7 @@ export default {
return;
}
- height = desktopResizeConstraints.height;
+ height = this.localVideo.track.getSettings().height ?? DESKTOP_STREAM_CAP;
}
const defaultCamera = getUserSelectedCameraDeviceId(APP.store.getState());
let effect;
diff --git a/react/features/base/tracks/functions.js b/react/features/base/tracks/functions.js
index 9d8a59dca5..fcfdf2eab9 100644
--- a/react/features/base/tracks/functions.js
+++ b/react/features/base/tracks/functions.js
@@ -27,7 +27,7 @@ export async function createLocalPresenterTrack(options, desktopHeight) {
// compute the constraints of the camera track based on the resolution
// of the desktop screen that is being shared.
- const cameraHeights = [ 180, 270, 360, 540, 720 ];
+ const cameraHeights = [ 120, 180, 240, 360, 480, 600, 720 ];
const proportion = 4;
const result = cameraHeights.find(
height => (desktopHeight / proportion) < height);