-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Mar 1, 2021
1 parent
8d8e11d
commit 1598053
Showing
10 changed files
with
328 additions
and
219 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import React, {useRef, useEffect} from 'react' | ||
import React, { useRef, useEffect } from 'react' | ||
import Box from '@material-ui/core/Box' | ||
import JSMpeg from '@cycjimmy/jsmpeg-player' | ||
//const JSMpeg = React.lazy(() => import('@cycjimmy/jsmpeg-player')); | ||
|
||
const CameraView = () => { | ||
const ref=useRef(null); | ||
const CameraView = ({ cameraAdress = "" }) => { | ||
const ref = useRef(null); | ||
|
||
useEffect(() => { | ||
if(!ref || !ref.current) return; | ||
if (!ref || !ref.current) return; | ||
/* new JSMpeg.VideoElement( | ||
ref.current, | ||
`ws:https://${window.location.host}:2000/api/stream/${encodeURIComponent( | ||
'rtsp:https://admin:[email protected]:8001')}` | ||
) */ | ||
new JSMpeg.VideoElement( | ||
ref.current, | ||
`ws:https://${window.location.host}:2000/api/stream/test` | ||
ref.current, | ||
`ws:https://${window.location.host}:2000/api/customstream?cam=${cameraAdress}}` | ||
) | ||
|
||
/* new JSMpeg.VideoElement( | ||
ref.current, | ||
`ws:https://${window.location.host}:2000/api/customstream?cam=${cameraAdress})}` | ||
) */ | ||
|
||
}, []) | ||
|
||
return ( | ||
<Box width={500} height={300} ref={ref}> | ||
</Box> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ const Dashboard = (props) => { | |
<Card> | ||
<CardHeader title="Dashboard"/> | ||
<CardContent> | ||
<CameraView/> | ||
<CameraView cameraAdress="rtsp:https://admin:[email protected]:1000/11"/> | ||
<CameraView cameraAdress="rtsp:https://admin:[email protected]:9000/"/> | ||
<BuildingRosenstrasse/> | ||
</CardContent> | ||
</Card> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Repository } from "typeorm"; | ||
|
||
export default abstract class BaseController<T> { | ||
protected readonly service: Repository<T>; | ||
constructor(service: Repository<T>) { | ||
this.service = service; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Request, Response } from "express"; | ||
import { Repository, getRepository } from "typeorm"; | ||
import { Camera } from "../entity/Camera"; | ||
import getList from "../util/getList"; | ||
import BaseController from "./basecontroller"; | ||
|
||
export class CameraController<T> extends BaseController<T>{ | ||
constructor(service: Repository<T>) { | ||
super(service) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
export async function getCameras(req: Request, res: Response) { | ||
getList(getRepository(Camera), req, res) | ||
} | ||
|
||
export async function getCamera(req: Request, res: Response) { | ||
try { | ||
const { id } = req.params; | ||
const result = await getRepository(Camera).findOne(id) | ||
|
||
if (!result) { | ||
return res.status(404).send({ message: `could not find building with the provided id ${id}` }) | ||
} | ||
return res.send(result); | ||
} catch (error) { | ||
console.log(error) | ||
res.status(500).send({ error: "server error" }) | ||
} | ||
} | ||
|
||
|
||
export async function createCamera(req: Request, res: Response) { | ||
try { | ||
const result = await getRepository(Camera).save(req.body); | ||
res.send(result) | ||
} catch (error) { | ||
res.status(500).send({ | ||
error: error | ||
}) | ||
} | ||
|
||
} | ||
|
||
|
||
export async function deleteCamera(req: Request, res: Response) { | ||
try { | ||
const result = await getRepository(Camera).delete(req.params.id) | ||
return res.send(result); | ||
} catch (error) { | ||
res.status(500).send(error) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.