diff --git a/agent/src/main.rs b/agent/src/main.rs index 577cf2e..e5dd79f 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -14,6 +14,8 @@ const METRIC_DISK_USAGE: &str = "satori_agent_disk_usage"; const METRIC_FFMPEG_INVOCATIONS: &str = "satori_agent_ffmpeg_invocations"; const METRIC_SEGMENTS: &str = "satori_agent_segments"; +type SharedImageData = std::sync::Arc>>; + /// Run the camera agent. /// /// Handles restreaming a single camera as HLS with history. @@ -82,6 +84,7 @@ async fn main() { .unwrap_or_else(|_| panic!("tcp listener should bind to {}", cli.http_server_address)); // Configure HTTP server routes + let frame_image = SharedImageData::default(); let app = Router::new() .route("/player", get(Html(include_str!("player.html")))) // .nest_service("/frame.jpg", ServeFile::new(frame_file)) @@ -94,8 +97,12 @@ async fn main() { }); let mut metrics_interval = tokio::time::interval(Duration::from_secs(30)); + let mut jpeg_rx = streamer.jpeg_subscribe(); loop { tokio::select! { + Ok(image) = jpeg_rx.recv() => { + frame_image.lock().unwrap().replace(image); + } _ = metrics_interval.tick() => { update_segment_count_metric(&config); update_disk_usage_metric(&config);