18 lines
539 B
Python
18 lines
539 B
Python
from fastapi import APIRouter
|
|
from app.services.stream_manager import stop_stream
|
|
from app.services.ffmpeg_service import stream_rtsp_to_flv
|
|
from linxyun.utils.result import Result
|
|
router = APIRouter()
|
|
|
|
@router.get("/get_stream")
|
|
async def get_stream(camera_id: str):
|
|
flv_url = await stream_rtsp_to_flv(camera_id)
|
|
if flv_url is None:
|
|
return Result.error("0001", "Stream not started")
|
|
return Result.ok(flv_url)
|
|
|
|
@router.get("/stop_stream")
|
|
def stop(id: str):
|
|
stop_stream(id)
|
|
return {"message": "Stream stopped"}
|