bigbluebutton-Github/bigbluebutton-html5/imports/api/video-streams/server/modifiers/sharedWebcam.js
2019-12-10 08:21:20 -03:00

42 lines
882 B
JavaScript

import Logger from '/imports/startup/server/logger';
import VideoStreams from '/imports/api/video-streams';
import { check } from 'meteor/check';
import {
getDeviceId,
getUserName,
} from '/imports/api/video-streams/server/helpers';
export default function sharedWebcam(meetingId, userId, stream) {
check(meetingId, String);
check(userId, String);
check(stream, String);
const deviceId = getDeviceId(stream);
const name = getUserName(userId);
const selector = {
meetingId,
userId,
deviceId,
};
const modifier = {
$set: {
stream,
name,
},
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Error setting stream: ${err}`);
}
if (numChanged) {
return Logger.info(`Updated stream=${stream} meeting=${meetingId}`);
}
};
return VideoStreams.upsert(selector, modifier, cb);
}