bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/media/service.js

91 lines
2.9 KiB
JavaScript
Raw Normal View History

import Presentations from '/imports/api/presentations';
import Settings from '/imports/ui/services/settings';
import getFromUserSettings from '/imports/ui/services/users-settings';
import { isExternalVideoEnabled, isScreenSharingEnabled } from '/imports/ui/services/features';
import { ACTIONS } from '../layout/enums';
2022-06-23 21:05:11 +08:00
import UserService from '/imports/ui/components/user-list/service';
import NotesService from '/imports/ui/components/notes/service';
import { getVideoUrl } from '/imports/ui/components/external-video-player/service';
import VideoStreams from '/imports/api/video-streams';
import { isPresentationEnabled } from '/imports/ui/services/features';
import { isVideoBroadcasting } from '/imports/ui/components/screenshare/service';
import Auth from '/imports/ui/services/auth/index';
const LAYOUT_CONFIG = Meteor.settings.public.layout;
const KURENTO_CONFIG = Meteor.settings.public.kurento;
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
2017-06-03 03:25:02 +08:00
const getPresentationInfo = () => {
const currentPresentation = Presentations.findOne({
2017-07-25 02:46:53 +08:00
current: true,
2017-06-03 03:25:02 +08:00
});
return {
current_presentation: (currentPresentation != null),
};
};
2016-09-15 04:25:31 +08:00
function shouldShowWhiteboard() {
return true;
}
function shouldShowScreenshare() {
const { viewScreenshare } = Settings.dataSaving;
2022-06-23 21:05:11 +08:00
return isScreenSharingEnabled() && (viewScreenshare || UserService.isUserPresenter()) && isVideoBroadcasting();
2016-09-15 04:25:31 +08:00
}
function shouldShowExternalVideo() {
return isExternalVideoEnabled() && getVideoUrl();
}
function shouldShowSharedNotes() {
return NotesService.isSharedNotesPinned();
}
2016-09-15 04:25:31 +08:00
function shouldShowOverlay() {
return getFromUserSettings('bbb_enable_video', KURENTO_CONFIG.enableVideo);
2016-09-15 04:25:31 +08:00
}
const setPresentationIsOpen = (layoutContextDispatch, value) => {
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
value,
});
2018-04-10 02:48:21 +08:00
};
const isThereWebcamOn = (meetingID) => {
return VideoStreams.find({
meetingId: meetingID
}).count() > 0;
}
const buildLayoutWhenPresentationAreaIsDisabled = (layoutContextDispatch) => {
const isSharingVideo = getVideoUrl();
const isSharedNotesPinned = NotesService.isSharedNotesPinned();
const hasScreenshare = isVideoBroadcasting();
const isThereWebcam = isThereWebcamOn(Auth.meetingID);
const isGeneralMediaOff = !hasScreenshare && !isSharedNotesPinned && !isSharingVideo
const webcamIsOnlyContent = isThereWebcam && isGeneralMediaOff;
const isThereNoMedia = !isThereWebcam && isGeneralMediaOff;
const isPresentationDisabled = !isPresentationEnabled();
if (isPresentationDisabled && (webcamIsOnlyContent || isThereNoMedia)) {
setPresentationIsOpen(layoutContextDispatch, false);
}
}
export default {
buildLayoutWhenPresentationAreaIsDisabled,
getPresentationInfo,
2016-09-15 04:25:31 +08:00
shouldShowWhiteboard,
shouldShowScreenshare,
shouldShowExternalVideo,
2016-09-15 04:25:31 +08:00
shouldShowOverlay,
isVideoBroadcasting,
setPresentationIsOpen,
shouldShowSharedNotes,
};