diff --git a/src/common/mdthread.rs b/src/common/mdthread.rs index b83700e..450789b 100644 --- a/src/common/mdthread.rs +++ b/src/common/mdthread.rs @@ -1,6 +1,7 @@ //! This thread will listen to motion messages //! from the camera. +use anyhow::Context; use std::sync::Arc; use tokio::{ sync::{ @@ -70,9 +71,9 @@ impl NeoCamMdThread { let watcher = watcher.clone(); Box::pin( async move { - let mut md = cam.listen_on_motion().await?; + let mut md = cam.listen_on_motion().await.with_context("Error in getting MD listen_on_motion")?; loop { - let event = md.next_motion().await?; + let event = md.next_motion().await.with_context("Error in getting MD next_motion")?; match event { MotionStatus::Start(at) => { watcher.send_replace( diff --git a/src/rtsp/gst/factory.rs b/src/rtsp/gst/factory.rs index 4b377a4..507af26 100644 --- a/src/rtsp/gst/factory.rs +++ b/src/rtsp/gst/factory.rs @@ -123,7 +123,16 @@ impl NeoMediaFactoryImpl { } fn build_pipeline(&self, media: Element) -> AnyResult> { match self.call_back.blocking_lock().as_ref() { - Some(call) => call(media), + Some(call) => { + let new_media = call(media); + match new_media { + Ok(new_media) => Ok(new_media), + Err(e) => { + log::debug!("Media source is currently restarting"); + Ok(None) + } + } + } None => Ok(None), } }