Skip to content

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

ref(presenter): refactor the desktop resize logic for presenter.

Jaya Allamsetty1e07385ac066
diff --git a/conference.js b/conference.js
index 99b630d4d6..5c51eaec02 100644
--- a/conference.js
+++ b/conference.js
@@ -1651,39 +1651,37 @@ export default {
// Create a new presenter track and apply the presenter effect.
if (!this.localPresenterVideo && !mute) {
const { height, width } = this.localVideo.track.getSettings() ?? this.localVideo.track.getConstraints();
- let desktopResizeConstraints = {};
- let resizeDesktopStream = false;
+ const isPortrait = height >= width;
const DESKTOP_STREAM_CAP = 720;
- // Resizing the desktop track for presenter is causing blurriness of the desktop share.
- // Disable this behavior for now until it is fixed in Chrome. The stream needs to be resized
- // Firefox always.
- if ((config.videoQuality && config.videoQuality.resizeDesktopForPresenter) || browser.isFirefox()) {
- // Resizing is needed when the window is bigger than 720p.
+ // Config.js setting for resizing high resolution desktop tracks to 720p when presenter is turned on.
+ const resizeEnabled = config.videoQuality && config.videoQuality.resizeDesktopForPresenter;
+ const highResolutionTrack
+ = (isPortrait && width > DESKTOP_STREAM_CAP) || (!isPortrait && height > DESKTOP_STREAM_CAP);
+
+ // Resizing the desktop track for presenter is causing blurriness of the desktop share on chrome.
+ // Disable resizing by default, enable it only when config.js setting is enabled.
+ // Firefox doesn't return width and height for desktop tracks. Therefore, track needs to be resized
+ // for creating the canvas for presenter.
+ const resizeDesktopStream = browser.isFirefox() || (highResolutionTrack && resizeEnabled);
+
+ if (resizeDesktopStream) {
+ let desktopResizeConstraints = {};
+
if (height && width) {
const advancedConstraints = [ { aspectRatio: (width / height).toPrecision(4) } ];
- 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 });
- }
+ const constraint = isPortrait ? { width: DESKTOP_STREAM_CAP } : { height: DESKTOP_STREAM_CAP };
+
+ advancedConstraints.push(constraint);
desktopResizeConstraints.advanced = advancedConstraints;
} else {
- resizeDesktopStream = true;
desktopResizeConstraints = {
width: 1280,
height: 720
};
}
- }
- if (resizeDesktopStream) {
+ // Apply the contraints on the desktop track.
try {
await this.localVideo.track.applyConstraints(desktopResizeConstraints);
} catch (err) {
@@ -1695,17 +1693,18 @@ export default {
const trackHeight = resizeDesktopStream
? this.localVideo.track.getSettings().height ?? DESKTOP_STREAM_CAP
: height;
- const defaultCamera = getUserSelectedCameraDeviceId(APP.store.getState());
let effect;
try {
- effect = await this._createPresenterStreamEffect(trackHeight, defaultCamera);
+ effect = await this._createPresenterStreamEffect(trackHeight);
} catch (err) {
- logger.error('Failed to unmute Presenter Video');
+ logger.error('Failed to unmute Presenter Video', err);
maybeShowErrorDialog(err);
return;
}
+
+ // Replace the desktop track on the peerconnection.
try {
await this.localVideo.setEffect(effect);
APP.store.dispatch(setVideoMuted(mute, MEDIA_TYPE.PRESENTER));