2024-12-12 20:04:36 +08:00
|
|
|
from fastapi import APIRouter
|
2024-12-17 20:07:29 +08:00
|
|
|
from app.services.stream_manager import reset_stream_time
|
|
|
|
from app.services.ffmpeg_service import stream_rtsp_to_url
|
|
|
|
from linxyun.utils.result import Result, SysCodes
|
2024-12-18 17:49:49 +08:00
|
|
|
from app.model import Stream
|
2024-12-12 20:04:36 +08:00
|
|
|
router = APIRouter()
|
|
|
|
|
2024-12-18 17:49:49 +08:00
|
|
|
@router.post("/get_stream")
|
|
|
|
async def get_stream(camera_id: str, stream: Stream = Stream(), type: str="flv", ):
|
|
|
|
return await stream_rtsp_to_url(camera_id, type, stream)
|
|
|
|
|
2024-12-17 20:07:29 +08:00
|
|
|
|
|
|
|
@router.get("/looking/{camera_id}")
|
|
|
|
async def looking(camera_id: str):
|
|
|
|
status = reset_stream_time(camera_id)
|
|
|
|
if status is True:
|
|
|
|
return Result.ok()
|
|
|
|
else:
|
|
|
|
return Result.error(SysCodes.OPERATE_FAIL)
|
|
|
|
|
2024-12-12 20:04:36 +08:00
|
|
|
|