bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-preview/container.jsx

65 lines
2.2 KiB
React
Raw Normal View History

2018-11-07 07:10:56 +08:00
import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import Service from './service';
import VideoPreview from './component';
2019-11-28 21:13:06 +08:00
import VideoService from '../video-provider/service';
import ScreenShareService from '/imports/ui/components/screenshare/service';
2023-03-11 01:25:24 +08:00
import logger from '/imports/startup/client/logger';
import { SCREENSHARING_ERRORS } from '/imports/api/screenshare/client/bridge/errors';
const VideoPreviewContainer = (props) => <VideoPreview {...props} />;
export default withTracker(({ setIsOpen, callbackToClose }) => ({
startSharing: (deviceId) => {
callbackToClose();
setIsOpen(false);
2019-11-28 00:19:09 +08:00
VideoService.joinVideo(deviceId);
2018-11-07 07:10:56 +08:00
},
startSharingCameraAsContent: (deviceId) => {
callbackToClose();
setIsOpen(false);
2023-03-11 01:25:24 +08:00
const handleFailure = (error) => {
const {
errorCode = SCREENSHARING_ERRORS.UNKNOWN_ERROR.errorCode,
errorMessage = error.message,
} = error;
logger.error({
logCode: 'camera_as_content_failed',
extraInfo: { errorCode, errorMessage },
}, `Sharing camera as content failed: ${errorMessage} (code=${errorCode})`);
ScreenShareService.screenshareHasEnded();
};
ScreenShareService.shareScreen(
true, handleFailure, { stream: Service.getStream(deviceId)._mediaStream }
);
ScreenShareService.setCameraAsContentDeviceId(deviceId);
},
stopSharing: (deviceId) => {
callbackToClose();
setIsOpen(false);
2020-03-12 03:42:53 +08:00
if (deviceId) {
const streamId = VideoService.getMyStreamId(deviceId);
if (streamId) VideoService.stopVideo(streamId);
2020-03-12 03:42:53 +08:00
} else {
VideoService.exitVideo();
}
},
stopSharingCameraAsContent: () => {
callbackToClose();
setIsOpen(false);
ScreenShareService.screenshareHasEnded();
},
sharedDevices: VideoService.getSharedDevices(),
cameraAsContentDeviceId: ScreenShareService.getCameraAsContentDeviceId(),
isCamLocked: VideoService.isUserLocked(),
camCapReached: VideoService.hasCapReached(),
closeModal: () => {
callbackToClose();
setIsOpen(false);
},
webcamDeviceId: Service.webcamDeviceId(),
2020-03-12 03:42:53 +08:00
hasVideoStream: VideoService.hasVideoStream(),
}))(VideoPreviewContainer);