diff --git a/Backend/.env-openvidu b/Backend/.env-openvidu index 0ffb3e2..5dc2cc2 100644 --- a/Backend/.env-openvidu +++ b/Backend/.env-openvidu @@ -1,3 +1 @@ OPENVIDU_SECRET=MY_SECRET -OPENVIDU_WEBHOOK=true -OPENVIDU_WEBHOOK_ENDPOINT=https://localhost:8080/media-server diff --git a/Backend/src/app/mediaServer/mediaServer.controller.ts b/Backend/src/app/mediaServer/mediaServer.controller.ts index 55fd822..e1f4ead 100644 --- a/Backend/src/app/mediaServer/mediaServer.controller.ts +++ b/Backend/src/app/mediaServer/mediaServer.controller.ts @@ -30,7 +30,6 @@ export class MediaServerController { @Header('Content-Type', 'application/json') @Post('/media-server') async getMediaServerEvents(@Body() event: any) { - console.log(event); this.cameraStreamGateway.broadcastEvent(event); return { message: 'OK' }; } diff --git a/Backend/src/cameraStream/cameraStream.gateway.ts b/Backend/src/cameraStream/cameraStream.gateway.ts index e4c4069..b39a855 100644 --- a/Backend/src/cameraStream/cameraStream.gateway.ts +++ b/Backend/src/cameraStream/cameraStream.gateway.ts @@ -56,16 +56,16 @@ export class CameraStreamGateway implements OnGatewayConnection { async afterInit() { try { - const session = await this.openvidu.instance.createSession({}); + const session = await this.openvidu.instance.createSession(); this.sessionId = session.sessionId; - const nvr = await this.database.getNVRData(); + nvr.channels.forEach((id: number) => { const connectionProperties: ConnectionProperties = { type: ConnectionType.IPCAM, rtspUri: `${nvr.ip}/ch${id}_0.264`, adaptativeBitrate: true, - onlyPlayWithSubscribers: false, + onlyPlayWithSubscribers: true, networkCache: 1000, data: id.toString(), }; @@ -77,7 +77,7 @@ export class CameraStreamGateway implements OnGatewayConnection { .catch((error) => console.error(error)); }); } catch (error) { - console.error(`OpenVidu initialization Failed...`); + console.error(error); } } diff --git a/Backend/src/database/database.service.ts b/Backend/src/database/database.service.ts index 2416fec..dee2f54 100644 --- a/Backend/src/database/database.service.ts +++ b/Backend/src/database/database.service.ts @@ -257,10 +257,10 @@ export class DatabaseService { const array = await this.getRawDataArray('General', { name: 'NVR', }); - + return { ip: process.env.NVR_IP_ADDRESS, - channels: array[0].channels, + channels: cameraIds, }; } } diff --git a/Frontend/src/api/recent-activities.ts b/Frontend/src/api/recent-activities.ts index 038f1d6..1956ce7 100644 --- a/Frontend/src/api/recent-activities.ts +++ b/Frontend/src/api/recent-activities.ts @@ -2,18 +2,14 @@ import { Activity } from "@/types"; import { axiosClient } from "./axios-client"; import { endpoints } from "./endpoints"; -type RecentActivitiesResponseDTO = { - data: Activity[]; -}; +type RecentActivitiesResponseDTO = Activity[]; type RecentActivitiesCountResponseDTO = { _id: string; count: number; }[]; -type RecentActivityImageResponseDTO = { - data: any; -}; +type RecentActivityImageResponseDTO = any; export const getRecentActivities = (top: number, skip: number) => { return () => @@ -50,5 +46,8 @@ export const getActivityImage = (id: string, timestamp: string) => { `${id}/${timestamp}`, {} ) - .then((result) => result.data); + .then((result) => { + const blob = new Blob([result.data], { type: 'image/jpeg' }); + return {imageUrl:URL.createObjectURL(blob)} + }); }; diff --git a/Frontend/src/components/button/view-screenshot.tsx b/Frontend/src/components/button/view-screenshot.tsx index 913baf7..98fb019 100644 --- a/Frontend/src/components/button/view-screenshot.tsx +++ b/Frontend/src/components/button/view-screenshot.tsx @@ -26,7 +26,7 @@ export const ViewScreenshotButton: React.FC = ({ data: imageData, refetch: fetchImage, } = useQuery( - ["recentActivitiesCount", cameraId], + ["recentActivitiesImage", cameraId, timestamp], getActivityImage(cameraId, timestamp), { enabled: false } ); @@ -39,8 +39,8 @@ export const ViewScreenshotButton: React.FC = ({ if (imageData) { openModal({ title: timestamp, - modalContent: imageData.data, - isLoading: true, + modalContent: imageData, + isLoading: false, }); } }, [imageData]); diff --git a/Frontend/src/components/video-recording-screen/video-player.tsx b/Frontend/src/components/video-recording-screen/video-player.tsx index 0824deb..6061868 100644 --- a/Frontend/src/components/video-recording-screen/video-player.tsx +++ b/Frontend/src/components/video-recording-screen/video-player.tsx @@ -12,9 +12,8 @@ const VideoPlayer = ({ }) => { const [fullScreen, setFullScreen] = useState(false); const [videoControlHidden, setvideoControlHidden] = useState(false); - const [loading, setLoading] = useState(true); const intervalRef: any = useRef(null); - + /* event handlers */ const onScreenSizeToggle = () => { const elem = document.documentElement; @@ -60,7 +59,6 @@ const VideoPlayer = ({ return (
- {/* */}