bigbluebutton-Github/bigbluebutton-html5/imports/api/external-videos/server/methods/initializeExternalVideo.js
2020-01-13 15:07:21 -08:00

37 lines
1.0 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
const allowFromPresenter = (eventName, message) => {
const {
userId,
time,
rate,
state,
} = message;
const user = Users.findOne({ userId });
const ret = user && user.presenter;
Logger.debug(`ExternalVideo Streamer auth userid: ${userId}, event: ${eventName}, suc: ${ret}, time: ${time}, rate: ${rate}, state: ${state}`);
return ret;
};
export default function initializeExternalVideo(credentials) {
const { meetingId } = credentials;
check(meetingId, String);
const streamName = `external-videos-${meetingId}`;
if (!Meteor.StreamerCentral.instances[streamName]) {
const streamer = new Meteor.Streamer(streamName);
streamer.allowRead('all');
streamer.allowWrite('all');
streamer.allowEmit(allowFromPresenter);
} else {
Logger.debug(`External Video streamer is already created for ${streamName}`);
}
}