migrate userShareWebcam
This commit is contained in:
parent
06b7463183
commit
349535b5ce
@ -1,8 +1,6 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import userShareWebcam from './methods/userShareWebcam';
|
||||
import userUnshareWebcam from './methods/userUnshareWebcam';
|
||||
|
||||
Meteor.methods({
|
||||
userShareWebcam,
|
||||
userUnshareWebcam,
|
||||
});
|
||||
|
@ -1,34 +0,0 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
export default function userShareWebcam(stream) {
|
||||
try {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'UserBroadcastCamStartMsg';
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(stream, String);
|
||||
|
||||
Logger.info(`user sharing webcam: ${meetingId} ${requesterUserId}`);
|
||||
|
||||
// const actionName = 'joinVideo';
|
||||
/* TODO throw an error if user has no permission to share webcam
|
||||
if (!isAllowedTo(actionName, credentials)) {
|
||||
throw new Meteor.Error('not-allowed', `You are not allowed to share webcam`);
|
||||
} */
|
||||
|
||||
const payload = {
|
||||
stream,
|
||||
};
|
||||
|
||||
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
} catch (err) {
|
||||
Logger.error(`Exception while invoking method userShareWebcam ${err.stack}`);
|
||||
}
|
||||
}
|
@ -123,6 +123,7 @@ const propTypes = {
|
||||
currentVideoPageIndex: PropTypes.number.isRequired,
|
||||
totalNumberOfStreams: PropTypes.number.isRequired,
|
||||
isMeteorConnected: PropTypes.bool.isRequired,
|
||||
playStart: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class VideoProvider extends Component {
|
||||
@ -1153,6 +1154,7 @@ class VideoProvider extends Component {
|
||||
handlePlayStart(message) {
|
||||
const { cameraId: stream, role } = message;
|
||||
const peer = this.webRtcPeers[stream];
|
||||
const { playStart } = this.props;
|
||||
|
||||
if (peer) {
|
||||
logger.info({
|
||||
@ -1169,7 +1171,7 @@ class VideoProvider extends Component {
|
||||
this.clearRestartTimers(stream);
|
||||
this.attachVideoStream(stream);
|
||||
|
||||
VideoService.playStart(stream);
|
||||
playStart(stream);
|
||||
} else {
|
||||
logger.warn({
|
||||
logCode: 'video_provider_playstart_no_peer',
|
||||
|
@ -1,14 +1,29 @@
|
||||
import React from 'react';
|
||||
import { withTracker } from 'meteor/react-meteor-data';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import VideoProvider from './component';
|
||||
import VideoService from './service';
|
||||
import { sortVideoStreams } from '/imports/ui/components/video-provider/stream-sorting';
|
||||
import { CAMERA_BROADCAST_START } from './mutations';
|
||||
|
||||
const { defaultSorting: DEFAULT_SORTING } = Meteor.settings.public.kurento.cameraSortingModes;
|
||||
|
||||
const VideoProviderContainer = ({ children, ...props }) => {
|
||||
const { streams, isGridEnabled } = props;
|
||||
return (!streams.length && !isGridEnabled ? null : <VideoProvider {...props}>{children}</VideoProvider>);
|
||||
const [cameraBroadcastStart] = useMutation(CAMERA_BROADCAST_START);
|
||||
|
||||
const sendUserShareWebcam = (cameraId) => {
|
||||
cameraBroadcastStart({ variables: { cameraId } });
|
||||
};
|
||||
|
||||
const playStart = (cameraId) => {
|
||||
if (VideoService.isLocalStream(cameraId)) {
|
||||
sendUserShareWebcam(cameraId);
|
||||
VideoService.joinedVideo();
|
||||
}
|
||||
};
|
||||
|
||||
return (!streams.length && !isGridEnabled ? null : <VideoProvider {...props} playStart={playStart}>{children}</VideoProvider>);
|
||||
};
|
||||
|
||||
export default withTracker(({ swapLayout, ...rest }) => {
|
||||
|
@ -0,0 +1,13 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const CAMERA_BROADCAST_START = gql`
|
||||
mutation CameraBroadcastStart($cameraId: String!) {
|
||||
cameraBroadcastStart(
|
||||
stream: $cameraId
|
||||
)
|
||||
}
|
||||
`;
|
||||
|
||||
export default {
|
||||
CAMERA_BROADCAST_START,
|
||||
};
|
@ -1073,4 +1073,5 @@ export default {
|
||||
getPreloadedStream: () => videoService.getPreloadedStream(),
|
||||
getStats: () => videoService.getStats(),
|
||||
updatePeerDictionaryReference: (newRef) => videoService.updatePeerDictionaryReference(newRef),
|
||||
joinedVideo: () => videoService.joinedVideo(),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user