from fastapi import APIRouter 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 router = APIRouter() @router.get("/get_stream") async def get_stream(camera_id: str, type: str="flv"): url = await stream_rtsp_to_url(camera_id, type) if url is None: return Result.error(SysCodes.OPERATE_FAIL) return Result.ok(url) @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)