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

70 lines
2.0 KiB
JavaScript
Raw Normal View History

2018-04-24 23:51:41 +08:00
import SessionStorage from '/imports/ui/services/storage/session';
import Presentations from '/imports/api/presentations';
import { isVideoBroadcasting } from '/imports/ui/components/screenshare/service';
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
import Settings from '/imports/ui/services/settings';
import VideoService from '/imports/ui/components/video-provider/service';
import PollingService from '/imports/ui/components/polling/service';
2017-06-03 03:25:02 +08:00
const getPresentationInfo = () => {
2017-07-01 03:16:00 +08:00
const currentPresentation = Presentations.findOne({
2017-07-25 02:46:53 +08:00
current: true,
2017-06-03 03:25:02 +08:00
});
return {
2017-06-03 03:25:02 +08:00
current_presentation: (currentPresentation != null),
};
};
const isUserPresenter = () => Users.findOne({ userId: Auth.userID }).presenter;
2016-09-15 04:25:31 +08:00
function shouldShowWhiteboard() {
return true;
}
function shouldShowScreenshare() {
return isVideoBroadcasting() && Meteor.settings.public.kurento.enableScreensharing;
2016-09-15 04:25:31 +08:00
}
function shouldShowOverlay() {
return Meteor.settings.public.kurento.enableVideo;
2016-09-15 04:25:31 +08:00
}
2018-04-10 02:48:21 +08:00
const swapLayout = {
value: false,
tracker: new Tracker.Dependency(),
};
const toggleSwapLayout = () => {
swapLayout.value = !swapLayout.value;
swapLayout.tracker.changed();
};
export const shouldEnableSwapLayout = () => {
const { viewParticipantsWebcams } = Settings.dataSaving;
const usersVideo = VideoService.getAllUsersVideo();
const poll = PollingService.mapPolls();
return usersVideo.length > 0 // prevent swap without any webcams
&& viewParticipantsWebcams // prevent swap when dataSaving for webcams is enabled
&& !poll.pollExists; // prevent swap when there is a poll running
};
2018-04-10 02:48:21 +08:00
export const getSwapLayout = () => {
swapLayout.tracker.depend();
2018-04-24 23:51:41 +08:00
const metaAutoSwapLayout = SessionStorage.getItem('meta_html5autoswaplayout') || false;
2018-04-24 23:23:54 +08:00
return metaAutoSwapLayout || (swapLayout.value && shouldEnableSwapLayout());
2018-04-10 02:48:21 +08:00
};
export default {
getPresentationInfo,
2016-09-15 04:25:31 +08:00
shouldShowWhiteboard,
shouldShowScreenshare,
2016-09-15 04:25:31 +08:00
shouldShowOverlay,
isUserPresenter,
isVideoBroadcasting,
2018-04-10 02:48:21 +08:00
toggleSwapLayout,
shouldEnableSwapLayout,
};