Skip to content

Commit

Permalink
Merge pull request #206 from ant-media/screenShareAspectRatio
Browse files Browse the repository at this point in the history
Fix cropped video during screen share
  • Loading branch information
burak-58 authored Jan 19, 2024
2 parents 5b1e181 + e9dd213 commit ac8c896
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ codesigning.asc
webapp/src/main/webapp/
.vscode/

react/.env.development
4 changes: 3 additions & 1 deletion react/src/Components/Cards/VideoCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ function VideoCard(props) {

const timeoutRef = React.useRef(null);

const isScreenSharedVideo = (conference?.screenSharedVideoId === props?.id) || (conference?.isScreenShared === true && isLocal);

const mirrorView = isLocal && !conference?.isScreenShared;
//const isScreenSharing =
// conference?.isScreenShared ||
Expand Down Expand Up @@ -259,7 +261,7 @@ function VideoCard(props) {
>
<CustomizedVideo
{...props}
style={{ objectFit: props.pinned ? "contain" : "cover" }}
style={{ objectFit: props.pinned || isScreenSharedVideo ? "contain" : "cover" }}
ref={refVideo}
playsInline
muted={isLocal}
Expand Down
9 changes: 8 additions & 1 deletion react/src/pages/AntMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ function getMediaConstraints(videoSendResolution, frameRate) {
let constraint = null;

switch (videoSendResolution) {
case "screenConstraints":
constraint = {
video: {
width: {max: window.screen.width}, height: {max: window.screen.height}, frameRate: {ideal: frameRate}
}
};
break;
case "qvgaConstraints":
constraint = {
video: {
Expand Down Expand Up @@ -1261,7 +1268,7 @@ function AntMedia() {
let mediaConstraints = {video: true};

if (isScreenShared) {
mediaConstraints = getMediaConstraints("fullHdConstraints", 25);
mediaConstraints = getMediaConstraints("screenConstraints", 20);
promise = webRTCAdaptor?.applyConstraints(mediaConstraints);
} else if (videoSendResolution === "auto" && !isPinned) {
mediaConstraints = getMediaConstraints("qvgaConstraints", 15);
Expand Down

0 comments on commit ac8c896

Please sign in to comment.