Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 21, 2024
1 parent 9460c02 commit f05b21e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::sync::Mutex<Option<bytes::Bytes>>>;

/// Run the camera agent.
///
/// Handles restreaming a single camera as HLS with history.
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand Down

0 comments on commit f05b21e

Please sign in to comment.