diff --git a/src/coordinator/mod.rs b/src/coordinator/mod.rs index dbbf2ea..0e21a22 100644 --- a/src/coordinator/mod.rs +++ b/src/coordinator/mod.rs @@ -193,7 +193,9 @@ pub async fn start_coordinator( y_adj = y; } Err(e) => { - info!("Could not calculate the tracking!: {e}"); + if state.tracker_state.tracking_id > 0 { + info!("Could not calculate the tracking!: {e}"); + } } } diff --git a/src/coordinator/remote_video_processor.rs b/src/coordinator/remote_video_processor.rs index b80c8f6..861eff5 100644 --- a/src/coordinator/remote_video_processor.rs +++ b/src/coordinator/remote_video_processor.rs @@ -6,7 +6,7 @@ use std::{ use async_recursion::async_recursion; use async_channel::Sender; -use futures_util::{stream::SplitStream, SinkExt, StreamExt, TryStreamExt}; +use futures_util::{stream::{SplitSink, SplitStream}, SinkExt, StreamExt, TryStreamExt}; use gstreamer_app::AppSink; use tokio::{net::TcpStream, sync::Mutex, time::sleep_until}; use tokio_tungstenite::{connect_async, tungstenite::Message, MaybeTlsStream, WebSocketStream}; @@ -75,7 +75,7 @@ pub async fn remote_video_loop( break; } - let do_not_break = handle_message(&mut recvr, &to_mec, last_iter).await; + let do_not_break = handle_message(&mut recvr, &mut sender, &to_mec, last_iter).await; if !do_not_break { break; } @@ -131,6 +131,7 @@ fn get_video_frame(appsink: &AppSink) -> Result { #[async_recursion] async fn handle_message( recvr: &mut SplitStream>>, + sender: &mut SplitSink>, Message>, to_mec: &Sender, last_iter: Instant, ) -> bool { @@ -144,15 +145,15 @@ async fn handle_message( Message::Pong(_) | Message::Frame(_) | Message::Text(_) => { warn!("There was an unhandled message type from the camera: {}\n{}", message, message.to_string()); // this was not the expected response, recursion! - return handle_message(recvr, to_mec, last_iter).await; + return handle_message(recvr, sender, to_mec, last_iter).await; } Message::Ping(content) => { - if let Err(e) = to_mec.send(ApplicationEvent::SocketMessage(Message::Pong(content))).await { + if let Err(e) = sender.send(Message::Pong(content)).await { error!("Video processor could not send message to MEC, exiting: {e}"); return false; } // this was not the expected response, recursion! - return handle_message(recvr, to_mec, last_iter).await; + return handle_message(recvr, sender, to_mec, last_iter).await; } Message::Binary(bin) => { let message = std::str::from_utf8(&bin);