|
@@ -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;
|