Skip to content

Commit

Permalink
Merge pull request #37 from videosdk-live/feature/screen-share-request
Browse files Browse the repository at this point in the history
screen share request changes
  • Loading branch information
ChintanRajpara committed Jul 8, 2022
2 parents e737c1f + ce7b248 commit c509b29
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "videosdk-rtc-react-prebuilt-ui",
"version": "0.3.7",
"version": "0.3.8",
"private": true,
"homepage": "https://embed.videosdk.live/rtc-js-prebuilt/0.3.7/",
"homepage": "https://embed.videosdk.live/rtc-js-prebuilt/0.3.8/",
"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
Expand Down
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const App = () => {
participantCanLeave: "participantCanLeave",
participantCanToggleOtherWebcam: "participantCanToggleOtherWebcam",
participantCanToggleOtherMic: "participantCanToggleOtherMic",
partcipantCanToogleOtherScreenShare:
"partcipantCanToogleOtherScreenShare",
participantCanToggleLivestream: "participantCanToggleLivestream",
participantCanEndMeeting: "participantCanEndMeeting",
//
Expand Down Expand Up @@ -506,6 +508,8 @@ const App = () => {
paramKeys.participantCanToggleOtherMic === "true",
participantCanToggleOtherWebcam:
paramKeys.participantCanToggleOtherWebcam === "true",
partcipantCanToogleOtherScreenShare:
paramKeys.partcipantCanToogleOtherScreenShare === "true",
participantCanToggleLivestream:
paramKeys.participantCanToggleLivestream === "true",
notificationSoundEnabled:
Expand Down
2 changes: 2 additions & 0 deletions src/MeetingAppContextDef.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const MeetingAppProvider = ({
askJoin,
participantCanToggleOtherMic,
participantCanToggleOtherWebcam,
partcipantCanToogleOtherScreenShare,
canRemoveOtherParticipant,
notificationSoundEnabled,
canPin,
Expand Down Expand Up @@ -205,6 +206,7 @@ export const MeetingAppProvider = ({
askJoin,
participantCanToggleOtherMic,
participantCanToggleOtherWebcam,
partcipantCanToogleOtherScreenShare,
canRemoveOtherParticipant,
notificationSoundEnabled,
canToggleWhiteboard,
Expand Down
15 changes: 11 additions & 4 deletions src/components/JoinScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ export default function JoinMeeting({
style={{
display: "flex",
flex: 1,
flexDirection:
meetingUrl === "" || meetingTitle === "" ? "row" : "column",
flexDirection: isXStoSM
? "column"
: meetingUrl === "" || meetingTitle === ""
? "row"
: "column",
justifyContent: "center",
alignItems: "center",
}}
Expand All @@ -456,7 +459,11 @@ export default function JoinMeeting({
style={{
display: "flex",
flex: isSMOnly ? 0 : 1,
flexDirection: meetingUrl || meetingTitle ? "row" : "column",
flexDirection: isXStoSM
? "column"
: meetingUrl || meetingTitle
? "row"
: "column",
alignItems: "center",
justifyContent: "center",
}}
Expand Down Expand Up @@ -685,7 +692,7 @@ export default function JoinMeeting({
<Grid
item
xs={12}
md={meetingTitle || meetingUrl ? 5 : 6}
md={isXStoSM ? 5 : meetingTitle || meetingUrl ? 5 : 6}
style={{
width: "100%",
display: "flex",
Expand Down
26 changes: 25 additions & 1 deletion src/components/MediaRequested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMeeting } from "@videosdk.live/react-sdk";
import { useMeeting, usePubSub } from "@videosdk.live/react-sdk";
import React, { useEffect, useRef, useState } from "react";
import ConfirmBox from "./ConfirmBox";

Expand All @@ -12,6 +12,8 @@ const MediaRequested = () => {

const [reqMicInfo, setReqMicInfo] = useState(reqInfoDefaultState);
const [reqWebcamInfo, setReqWebcamInfo] = useState(reqInfoDefaultState);
const [reqScreenShareInfo, setReqScreenShareInfo] =
useState(reqInfoDefaultState);

const mMeetingRef = useRef();

Expand Down Expand Up @@ -42,11 +44,33 @@ const MediaRequested = () => {
mMeetingRef.current = mMeeting;
}, [mMeeting]);

usePubSub(`SCR_SHR_REQ_${mMeeting?.localParticipant.id}`, {
onMessageReceived: (data) => {
if (data.message.setScreenShareOn) {
setReqScreenShareInfo({
enabled: true,
participantName: "Host",
accept: () => {
mMeeting?.toggleScreenShare();
},
reject: () => {},
});
} else {
mMeeting?.toggleScreenShare();
}
},
});

return (
<>
{[
{ ...reqMicInfo, setter: setReqMicInfo, type: "mic" },
{ ...reqWebcamInfo, setter: setReqWebcamInfo, type: "webcam" },
{
...reqScreenShareInfo,
setter: setReqScreenShareInfo,
type: "screenShare",
},
].map(({ accept, enabled, participantName, setter, reject, type }, i) => {
return (
<ConfirmBox
Expand Down
18 changes: 10 additions & 8 deletions src/meetingContainer/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,14 +1231,16 @@ const TopBar = ({ topBarHeight }) => {
);
})}

<Box ml={2}>
<OutlineIconButton
Icon={MoreHorizIcon}
// Icon={Boolean(anchorEl) ? CloseIcon : MoreHorizIcon}
// isFocused={anchorEl}
onClick={handleClickFAB}
/>
</Box>
{excludeFirstFourElements.length >= 1 && (
<Box ml={2}>
<OutlineIconButton
Icon={MoreHorizIcon}
// Icon={Boolean(anchorEl) ? CloseIcon : MoreHorizIcon}
// isFocused={anchorEl}
onClick={handleClickFAB}
/>
</Box>
)}

<SwipeableDrawer
anchor={"bottom"}
Expand Down
51 changes: 50 additions & 1 deletion src/meetingContainer/sideViewContainer/ParticipantsTabPanel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { useMeeting, useParticipant } from "@videosdk.live/react-sdk";
import {
useMeeting,
useParticipant,
usePubSub,
} from "@videosdk.live/react-sdk";
import {
Close,
MoreVert,
Expand All @@ -7,6 +11,8 @@ import {
Mic as MicIcon,
VideocamOff as VideocamOffIcon,
Videocam as VideocamIcon,
ScreenShareOutlined,
ScreenShare,
} from "@material-ui/icons";
import {
Avatar,
Expand Down Expand Up @@ -35,6 +41,7 @@ function ParticipantListItem({
participantExpandedId,
setParticipantExpandedId,
}) {
const { presenterId } = useMeeting();
const {
participant,
micOn,
Expand All @@ -53,11 +60,18 @@ function ParticipantListItem({
const {
participantCanToggleOtherMic,
participantCanToggleOtherWebcam,
partcipantCanToogleOtherScreenShare,
canRemoveOtherParticipant,
canPin,
animationsEnabled,
} = useMeetingAppContext();

const isParticipantPresenting = useMemo(() => {
return presenterId === participantId;
}, [presenterId, participantId]);

const { publish } = usePubSub(`SCR_SHR_REQ_${participantId}`);

const [isParticipantKickoutVisible, setIsParticipantKickoutVisible] =
useState(false);

Expand Down Expand Up @@ -284,6 +298,41 @@ function ParticipantListItem({
</Tooltip>
</Box>
)}

<Box ml={1} mr={0}>
<Tooltip title={`Screen share`}>
<IconButton
disabled={
!(
!isLocal &&
partcipantCanToogleOtherScreenShare &&
(presenterId ? isParticipantPresenting : true)
)
}
style={{ padding: 0 }}
onClick={() => {
publish({ setScreenShareOn: !isParticipantPresenting });
}}
>
<Box
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
borderRadius: 100,
}}
p={0.5}
>
{isParticipantPresenting ? (
<ScreenShare />
) : (
<ScreenShareOutlined color="#ffffff80" />
)}
</Box>
</IconButton>
</Tooltip>
</Box>

{!isLocal && canRemoveOtherParticipant && (
<Box ml={1} mr={0}>
<Tooltip title={`Remove`}>
Expand Down

0 comments on commit c509b29

Please sign in to comment.