2024-08-01 01:47:54 +08:00
|
|
|
import React, { useContext } from 'react';
|
2024-06-12 21:25:46 +08:00
|
|
|
import { useMutation, useReactiveVar } from '@apollo/client';
|
2024-05-24 22:44:36 +08:00
|
|
|
import { defineMessages } from 'react-intl';
|
2019-04-16 05:39:07 +08:00
|
|
|
import {
|
2023-03-28 05:40:08 +08:00
|
|
|
getSharingContentType,
|
2024-06-13 19:59:11 +08:00
|
|
|
useIsScreenGloballyBroadcasting,
|
|
|
|
useIsCameraAsContentGloballyBroadcasting,
|
|
|
|
useShouldEnableVolumeControl,
|
2024-06-14 22:35:23 +08:00
|
|
|
useIsScreenBroadcasting,
|
|
|
|
useIsCameraAsContentBroadcasting,
|
|
|
|
useScreenshareHasAudio,
|
|
|
|
useBroadcastContentType,
|
2019-04-16 05:39:07 +08:00
|
|
|
} from './service';
|
2024-08-01 01:47:54 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2017-07-25 03:29:34 +08:00
|
|
|
import ScreenshareComponent from './component';
|
2021-09-11 04:48:52 +08:00
|
|
|
import { layoutSelect, layoutSelectOutput, layoutDispatch } from '../layout/context';
|
2021-09-28 03:57:02 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2024-01-20 02:40:27 +08:00
|
|
|
import { EXTERNAL_VIDEO_STOP } from '../external-video-player/mutations';
|
2024-05-01 20:39:03 +08:00
|
|
|
import { PINNED_PAD_SUBSCRIPTION } from '../notes/queries';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
|
2024-06-12 21:25:46 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
2024-09-14 01:53:14 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-04-25 00:07:06 +08:00
|
|
|
|
2023-03-28 05:40:08 +08:00
|
|
|
const screenshareIntlMessages = defineMessages({
|
|
|
|
// SCREENSHARE
|
|
|
|
label: {
|
|
|
|
id: 'app.screenshare.screenShareLabel',
|
|
|
|
description: 'screen share area element label',
|
|
|
|
},
|
|
|
|
presenterLoadingLabel: {
|
|
|
|
id: 'app.screenshare.presenterLoadingLabel',
|
|
|
|
},
|
|
|
|
viewerLoadingLabel: {
|
|
|
|
id: 'app.screenshare.viewerLoadingLabel',
|
|
|
|
},
|
|
|
|
presenterSharingLabel: {
|
|
|
|
id: 'app.screenshare.presenterSharingLabel',
|
|
|
|
},
|
|
|
|
autoplayBlockedDesc: {
|
|
|
|
id: 'app.media.screenshare.autoplayBlockedDesc',
|
|
|
|
},
|
|
|
|
autoplayAllowLabel: {
|
|
|
|
id: 'app.media.screenshare.autoplayAllowLabel',
|
|
|
|
},
|
|
|
|
started: {
|
|
|
|
id: 'app.media.screenshare.start',
|
|
|
|
description: 'toast to show when a screenshare has started',
|
|
|
|
},
|
|
|
|
ended: {
|
|
|
|
id: 'app.media.screenshare.end',
|
|
|
|
description: 'toast to show when a screenshare has ended',
|
|
|
|
},
|
|
|
|
endedDueToDataSaving: {
|
|
|
|
id: 'app.media.screenshare.endDueToDataSaving',
|
|
|
|
description: 'toast to show when a screenshare has ended by changing data savings option',
|
2024-05-24 22:44:36 +08:00
|
|
|
},
|
2023-03-28 05:40:08 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const cameraAsContentIntlMessages = defineMessages({
|
|
|
|
// CAMERA AS CONTENT
|
|
|
|
label: {
|
|
|
|
id: 'app.cameraAsContent.cameraAsContentLabel',
|
|
|
|
description: 'screen share area element label',
|
|
|
|
},
|
|
|
|
presenterLoadingLabel: {
|
|
|
|
id: 'app.cameraAsContent.presenterLoadingLabel',
|
|
|
|
},
|
|
|
|
viewerLoadingLabel: {
|
|
|
|
id: 'app.cameraAsContent.viewerLoadingLabel',
|
|
|
|
},
|
|
|
|
presenterSharingLabel: {
|
|
|
|
id: 'app.cameraAsContent.presenterSharingLabel',
|
|
|
|
},
|
|
|
|
autoplayBlockedDesc: {
|
|
|
|
id: 'app.media.cameraAsContent.autoplayBlockedDesc',
|
|
|
|
},
|
|
|
|
autoplayAllowLabel: {
|
|
|
|
id: 'app.media.cameraAsContent.autoplayAllowLabel',
|
|
|
|
},
|
|
|
|
started: {
|
|
|
|
id: 'app.media.cameraAsContent.start',
|
|
|
|
description: 'toast to show when camera as content has started',
|
|
|
|
},
|
|
|
|
ended: {
|
|
|
|
id: 'app.media.cameraAsContent.end',
|
|
|
|
description: 'toast to show when camera as content has ended',
|
|
|
|
},
|
|
|
|
endedDueToDataSaving: {
|
|
|
|
id: 'app.media.cameraAsContent.endDueToDataSaving',
|
|
|
|
description: 'toast to show when camera as content has ended by changing data savings option',
|
|
|
|
},
|
|
|
|
});
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2019-07-24 03:56:39 +08:00
|
|
|
const ScreenshareContainer = (props) => {
|
2021-09-11 04:48:52 +08:00
|
|
|
const screenShare = layoutSelectOutput((i) => i.screenShare);
|
|
|
|
const fullscreen = layoutSelect((i) => i.fullscreen);
|
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2024-08-01 01:47:54 +08:00
|
|
|
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-07-13 03:47:06 +08:00
|
|
|
const { element } = fullscreen;
|
2021-09-10 21:16:44 +08:00
|
|
|
const fullscreenElementId = 'Screenshare';
|
2021-07-07 03:27:28 +08:00
|
|
|
const fullscreenContext = (element === fullscreenElementId);
|
2024-01-20 02:40:27 +08:00
|
|
|
const [stopExternalVideoShare] = useMutation(EXTERNAL_VIDEO_STOP);
|
2021-06-15 19:51:44 +08:00
|
|
|
|
2024-06-04 21:40:54 +08:00
|
|
|
const { data: pinnedPadData } = useDeduplicatedSubscription(PINNED_PAD_SUBSCRIPTION);
|
2024-05-29 21:26:11 +08:00
|
|
|
|
|
|
|
const NOTES_CONFIG = window.meetingClientSettings.public.notes;
|
2024-06-13 19:59:11 +08:00
|
|
|
const LAYOUT_CONFIG = window.meetingClientSettings.public.layout;
|
2024-05-29 21:26:11 +08:00
|
|
|
|
2024-04-25 00:07:06 +08:00
|
|
|
const isSharedNotesPinned = !!pinnedPadData
|
|
|
|
&& pinnedPadData.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
|
|
|
|
2024-09-14 01:53:14 +08:00
|
|
|
const {
|
2024-09-18 05:04:00 +08:00
|
|
|
data: currentUserData,
|
2024-09-14 01:53:14 +08:00
|
|
|
} = useCurrentUser((u) => ({
|
|
|
|
presenter: u.presenter,
|
|
|
|
}));
|
2024-09-14 02:33:12 +08:00
|
|
|
const isPresenter = currentUserData?.presenter;
|
2021-11-23 22:20:29 +08:00
|
|
|
|
2023-03-28 05:40:08 +08:00
|
|
|
const info = {
|
|
|
|
screenshare: {
|
2024-05-24 22:44:36 +08:00
|
|
|
icon: 'desktop',
|
2023-03-28 05:40:08 +08:00
|
|
|
locales: screenshareIntlMessages,
|
|
|
|
startPreviewSizeBig: false,
|
|
|
|
showSwitchPreviewSizeButton: true,
|
|
|
|
},
|
|
|
|
camera: {
|
2024-05-24 22:44:36 +08:00
|
|
|
icon: 'video',
|
2023-03-28 05:40:08 +08:00
|
|
|
locales: cameraAsContentIntlMessages,
|
|
|
|
startPreviewSizeBig: true,
|
|
|
|
showSwitchPreviewSizeButton: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-06-14 22:35:23 +08:00
|
|
|
const broadcastContentType = useBroadcastContentType();
|
|
|
|
const getContentType = () => (isPresenter ? getSharingContentType() : broadcastContentType);
|
2023-03-28 05:40:08 +08:00
|
|
|
const contentTypeInfo = info[getContentType()];
|
|
|
|
const defaultInfo = info.camera;
|
2024-05-24 22:44:36 +08:00
|
|
|
const selectedInfo = contentTypeInfo || defaultInfo;
|
2024-06-12 21:25:46 +08:00
|
|
|
const outputDeviceId = useReactiveVar(AudioManager._outputDeviceId.value);
|
2024-06-13 19:59:11 +08:00
|
|
|
const screenIsGloballyBroadcasting = useIsScreenGloballyBroadcasting();
|
|
|
|
const cameraAsContentIsGloballyBroadcasting = useIsCameraAsContentGloballyBroadcasting();
|
|
|
|
const enableVolumeControl = useShouldEnableVolumeControl();
|
2024-06-14 22:35:23 +08:00
|
|
|
const isScreenBroadcasting = useIsScreenBroadcasting();
|
|
|
|
const isCameraAsContentBroadcasting = useIsCameraAsContentBroadcasting();
|
|
|
|
const hasAudio = useScreenshareHasAudio();
|
2023-03-28 05:40:08 +08:00
|
|
|
|
2024-08-01 01:47:54 +08:00
|
|
|
let pluginScreenshareHelperItems = [];
|
|
|
|
if (pluginsExtensibleAreasAggregatedState.screenshareHelperItems) {
|
|
|
|
pluginScreenshareHelperItems = [
|
|
|
|
...pluginsExtensibleAreasAggregatedState.screenshareHelperItems,
|
|
|
|
];
|
|
|
|
}
|
2024-09-18 05:04:00 +08:00
|
|
|
if ((isScreenBroadcasting || isCameraAsContentBroadcasting) && currentUserData) {
|
2021-07-07 03:27:28 +08:00
|
|
|
return (
|
|
|
|
<ScreenshareComponent
|
|
|
|
{
|
|
|
|
...{
|
2024-08-01 01:47:54 +08:00
|
|
|
pluginScreenshareHelperItems,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-07-07 03:27:28 +08:00
|
|
|
...props,
|
|
|
|
...screenShare,
|
|
|
|
fullscreenContext,
|
|
|
|
fullscreenElementId,
|
2024-04-25 00:07:06 +08:00
|
|
|
isSharedNotesPinned,
|
2024-01-20 02:40:27 +08:00
|
|
|
stopExternalVideoShare,
|
2024-06-12 21:25:46 +08:00
|
|
|
outputDeviceId,
|
2024-06-13 19:59:11 +08:00
|
|
|
enableVolumeControl,
|
2024-06-14 22:35:23 +08:00
|
|
|
hasAudio,
|
2024-06-13 19:59:11 +08:00
|
|
|
isGloballyBroadcasting: screenIsGloballyBroadcasting
|
|
|
|
|| cameraAsContentIsGloballyBroadcasting,
|
|
|
|
hidePresentationOnJoin: getFromUserSettings(
|
|
|
|
'bbb_hide_presentation_on_join',
|
|
|
|
LAYOUT_CONFIG.hidePresentationOnJoin,
|
|
|
|
),
|
2023-03-28 05:40:08 +08:00
|
|
|
...selectedInfo,
|
2024-09-18 05:50:32 +08:00
|
|
|
isPresenter,
|
2021-07-07 03:27:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
2017-07-25 03:29:34 +08:00
|
|
|
}
|
2019-07-24 03:56:39 +08:00
|
|
|
return null;
|
|
|
|
};
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2024-06-13 19:59:11 +08:00
|
|
|
export default ScreenshareContainer;
|