Prevent parallel screenshare and external-video

This commit is contained in:
Anton Georgiev 2019-12-18 16:40:04 -05:00
parent 771079c8f1
commit 4e1d55efd2
3 changed files with 23 additions and 0 deletions

View File

@ -1,9 +1,16 @@
import { check } from 'meteor/check';
import Meetings from '/imports/api/meetings';
import addScreenshare from '../modifiers/addScreenshare';
import Logger from '/imports/startup/server/logger';
export default function handleScreenshareStarted({ body }, meetingId) {
check(meetingId, String);
check(body, Object);
const meeting = Meetings.findOne({ meetingId });
if (meeting && meeting.externalVideoUrl) {
Logger.info(`ScreenshareStarted: There is external video being shared. Stopping it due to presenter change, ${meeting.externalVideoUrl}`);
Meetings.update({ meetingId }, { $set: { externalVideoUrl: null } });
}
return addScreenshare(meetingId, body);
}

View File

@ -1,5 +1,7 @@
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import Meetings from '/imports/api/meetings';
import stopWatchingExternalVideo from '/imports/api/external-videos/server/methods/stopWatchingExternalVideo';
export default function changePresenter(presenter, userId, meetingId, changedBy) {
const selector = {
@ -26,5 +28,10 @@ export default function changePresenter(presenter, userId, meetingId, changedBy)
return null;
};
const meeting = Meetings.findOne({ meetingId });
if (meeting && meeting.externalVideoUrl) {
Logger.info(`ChangePresenter:There is external video being shared. Stopping it due to presenter change, ${meeting.externalVideoUrl}`);
stopWatchingExternalVideo({ meetingId, requesterUserId: userId });
}
return Users.update(selector, modifier, cb);
}

View File

@ -3,6 +3,9 @@ import KurentoBridge from '/imports/api/screenshare/client/bridge';
import Settings from '/imports/ui/services/settings';
import logger from '/imports/startup/client/logger';
import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc';
import { stopWatching } from '/imports/ui/components/external-video-player/service';
import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
// when the meeting information has been updated check to see if it was
// screensharing. If it has changed either trigger a call to receive video
@ -47,6 +50,12 @@ const presenterScreenshareHasStarted = () => {
};
const shareScreen = (onFail) => {
// stop external video share if running
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
if (meeting && meeting.externalVideoUrl) {
stopWatching();
}
KurentoBridge.kurentoShareScreen(onFail);
};