2020-06-09 11:09:46 +08:00
|
|
|
import React from 'react';
|
2018-02-17 03:18:53 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
|
|
import VideoProvider from './component';
|
2018-02-19 12:23:05 +08:00
|
|
|
import VideoService from './service';
|
2023-08-09 00:05:54 +08:00
|
|
|
import { sortVideoStreams } from '/imports/ui/components/video-provider/stream-sorting';
|
|
|
|
|
|
|
|
const { defaultSorting: DEFAULT_SORTING } = Meteor.settings.public.kurento.cameraSortingModes;
|
2018-02-17 03:18:53 +08:00
|
|
|
|
2018-12-18 06:19:26 +08:00
|
|
|
const VideoProviderContainer = ({ children, ...props }) => {
|
2023-05-12 04:20:26 +08:00
|
|
|
const { streams, isGridEnabled } = props;
|
|
|
|
return (!streams.length && !isGridEnabled ? null : <VideoProvider {...props}>{children}</VideoProvider>);
|
2018-12-18 06:19:26 +08:00
|
|
|
};
|
2018-02-17 03:18:53 +08:00
|
|
|
|
2021-06-22 04:16:59 +08:00
|
|
|
export default withTracker(({ swapLayout, ...rest }) => {
|
2020-08-25 02:30:24 +08:00
|
|
|
// getVideoStreams returns a dictionary consisting of:
|
|
|
|
// {
|
|
|
|
// streams: array of mapped streams
|
|
|
|
// totalNumberOfStreams: total number of shared streams in the server
|
|
|
|
// }
|
|
|
|
const {
|
|
|
|
streams,
|
2023-08-09 00:05:54 +08:00
|
|
|
gridUsers,
|
2021-06-22 04:16:59 +08:00
|
|
|
totalNumberOfStreams,
|
2020-08-25 02:30:24 +08:00
|
|
|
} = VideoService.getVideoStreams();
|
|
|
|
|
2023-08-09 00:05:54 +08:00
|
|
|
let usersVideo = streams;
|
|
|
|
|
|
|
|
if(gridUsers.length > 0) {
|
|
|
|
const items = usersVideo.concat(gridUsers);
|
|
|
|
usersVideo = sortVideoStreams(items, DEFAULT_SORTING);
|
|
|
|
}
|
|
|
|
|
2020-08-25 02:30:24 +08:00
|
|
|
return {
|
2021-06-22 04:16:59 +08:00
|
|
|
swapLayout,
|
2023-08-09 00:05:54 +08:00
|
|
|
streams: usersVideo,
|
2020-08-25 02:30:24 +08:00
|
|
|
totalNumberOfStreams,
|
|
|
|
isUserLocked: VideoService.isUserLocked(),
|
|
|
|
currentVideoPageIndex: VideoService.getCurrentVideoPageIndex(),
|
2023-02-24 00:21:20 +08:00
|
|
|
isMeteorConnected: Meteor.status().connected,
|
2021-06-22 04:16:59 +08:00
|
|
|
...rest,
|
2020-08-25 02:30:24 +08:00
|
|
|
};
|
2021-08-05 15:26:03 +08:00
|
|
|
})(VideoProviderContainer);
|