bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/webcam/container.jsx

76 lines
2.3 KiB
React
Raw Normal View History

import React, { useContext } from 'react';
2022-02-15 23:54:55 +08:00
import { withModalMounter } from '/imports/ui/components/common/modal/service';
import { withTracker } from 'meteor/react-meteor-data';
import MediaService from '/imports/ui/components/media/service';
import Auth from '/imports/ui/services/auth';
import VideoService from '/imports/ui/components/video-provider/service';
import { UsersContext } from '../components-data/users-context/context';
2021-09-11 04:48:52 +08:00
import {
layoutSelect,
layoutSelectInput,
layoutSelectOutput,
layoutDispatch,
} from '../layout/context';
import WebcamComponent from '/imports/ui/components/webcam/component';
const WebcamContainer = ({
audioModalIsOpen,
swapLayout,
usersVideo,
}) => {
2021-09-11 04:48:52 +08:00
const fullscreen = layoutSelect((i) => i.fullscreen);
const isRTL = layoutSelect((i) => i.isRTL);
const cameraDockInput = layoutSelectInput((i) => i.cameraDock);
const focusedId = layoutSelectInput((i) => i.focusedId);
2021-09-11 04:48:52 +08:00
const presentation = layoutSelectOutput((i) => i.presentation);
const cameraDock = layoutSelectOutput((i) => i.cameraDock);
const layoutContextDispatch = layoutDispatch();
2021-08-07 01:23:46 +08:00
const { cameraOptimalGridSize } = cameraDockInput;
const { display: displayPresentation } = presentation;
const usingUsersContext = useContext(UsersContext);
const { users } = usingUsersContext;
const currentUser = users[Auth.meetingID][Auth.userID];
2021-10-13 20:30:08 +08:00
return !audioModalIsOpen
&& usersVideo.length > 0
? (
<WebcamComponent
{...{
swapLayout,
usersVideo,
focusedId: cameraDock.focusedId,
cameraDock,
cameraOptimalGridSize,
2021-08-05 19:03:24 +08:00
layoutContextDispatch,
fullscreen,
isPresenter: currentUser.presenter,
displayPresentation,
2021-08-07 01:23:46 +08:00
isRTL,
}}
/>
)
: null;
};
export default withModalMounter(withTracker((props) => {
const { current_presentation: hasPresentation } = MediaService.getPresentationInfo();
const data = {
audioModalIsOpen: Session.get('audioModalIsOpen'),
isMeteorConnected: Meteor.status().connected,
};
const { streams: usersVideo } = VideoService.getVideoStreams();
data.usersVideo = usersVideo;
data.swapLayout = !hasPresentation || props.isLayoutSwapped;
if (data.swapLayout) {
data.floatingOverlay = true;
data.hideOverlay = true;
}
return data;
})(WebcamContainer));