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';
|
2023-04-27 00:09:02 +08:00
|
|
|
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';
|
2019-11-06 04:23:13 +08:00
|
|
|
|
2021-11-20 03:03:36 +08:00
|
|
|
const VideoPreviewContainer = (props) => <VideoPreview {...props} />;
|
2020-05-10 01:19:41 +08:00
|
|
|
|
2023-03-27 23:36:25 +08:00
|
|
|
export default withTracker(({ setIsOpen, callbackToClose }) => ({
|
2020-05-26 01:32:24 +08:00
|
|
|
startSharing: (deviceId) => {
|
2023-03-27 23:36:25 +08:00
|
|
|
callbackToClose();
|
|
|
|
setIsOpen(false);
|
2019-11-28 00:19:09 +08:00
|
|
|
VideoService.joinVideo(deviceId);
|
2018-11-07 07:10:56 +08:00
|
|
|
},
|
2023-04-27 00:09:02 +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 }
|
|
|
|
);
|
2023-03-28 05:46:42 +08:00
|
|
|
ScreenShareService.setCameraAsContentDeviceId(deviceId);
|
2023-04-27 00:09:02 +08:00
|
|
|
},
|
2020-05-26 01:32:24 +08:00
|
|
|
stopSharing: (deviceId) => {
|
2023-03-27 23:36:25 +08:00
|
|
|
callbackToClose();
|
|
|
|
setIsOpen(false);
|
2020-03-12 03:42:53 +08:00
|
|
|
if (deviceId) {
|
2021-04-03 11:06:39 +08:00
|
|
|
const streamId = VideoService.getMyStreamId(deviceId);
|
|
|
|
if (streamId) VideoService.stopVideo(streamId);
|
2020-03-12 03:42:53 +08:00
|
|
|
} else {
|
|
|
|
VideoService.exitVideo();
|
|
|
|
}
|
2019-11-29 04:28:41 +08:00
|
|
|
},
|
2023-03-28 05:46:42 +08:00
|
|
|
stopSharingCameraAsContent: () => {
|
2023-05-10 01:37:59 +08:00
|
|
|
callbackToClose();
|
|
|
|
setIsOpen(false);
|
2023-03-28 05:46:42 +08:00
|
|
|
ScreenShareService.screenshareHasEnded();
|
|
|
|
},
|
2019-11-29 04:28:41 +08:00
|
|
|
sharedDevices: VideoService.getSharedDevices(),
|
2023-03-28 05:46:42 +08:00
|
|
|
cameraAsContentDeviceId: ScreenShareService.getCameraAsContentDeviceId(),
|
2021-11-20 02:23:17 +08:00
|
|
|
isCamLocked: VideoService.isUserLocked(),
|
2022-02-22 21:33:26 +08:00
|
|
|
camCapReached: VideoService.hasCapReached(),
|
2023-03-27 23:36:25 +08:00
|
|
|
closeModal: () => {
|
|
|
|
callbackToClose();
|
|
|
|
setIsOpen(false);
|
|
|
|
},
|
2018-11-17 02:56:39 +08:00
|
|
|
webcamDeviceId: Service.webcamDeviceId(),
|
2020-03-12 03:42:53 +08:00
|
|
|
hasVideoStream: VideoService.hasVideoStream(),
|
2023-03-27 23:36:25 +08:00
|
|
|
}))(VideoPreviewContainer);
|