Skip to main content

heldar_kernel/routes/
liveview.rs

1use axum::extract::{Path, State};
2use axum::routing::get;
3use axum::{Json, Router};
4
5use crate::error::AppResult;
6use crate::services::mediamtx::{self, LiveUrls};
7use crate::state::AppState;
8
9pub fn router() -> Router<AppState> {
10    Router::new().route(
11        "/api/v1/cameras/{id}/liveview",
12        get(liveview).post(liveview),
13    )
14}
15
16/// Ensure a MediaMTX path exists for the camera and return live playback URLs.
17async fn liveview(State(st): State<AppState>, Path(id): Path<String>) -> AppResult<Json<LiveUrls>> {
18    Ok(Json(mediamtx::ensure_live(&st, &id).await?))
19}