From d411e9c25b350b24a1279ea301356056e3293bf3 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Wed, 10 May 2023 11:38:13 +0700 Subject: [PATCH] Restamp over clear buffer during reconnect --- src/rtsp/gst/server.rs | 1 + src/rtsp/mod.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/rtsp/gst/server.rs b/src/rtsp/gst/server.rs index 2a24280..6109145 100644 --- a/src/rtsp/gst/server.rs +++ b/src/rtsp/gst/server.rs @@ -283,6 +283,7 @@ impl NeoRtspServer { } // Clear buffers on all senders of a tag + #[allow(dead_code)] // Old function, was used to clear buffer on reconnect pub(crate) async fn clear_buffer>(&self, tag: T) -> AnyResult<()> { if let Some(sender) = self.imp().get_sender(tag).await { sender.send(FactoryCommand::ClearBuffer).await?; diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index 4d9295e..9733008 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -185,11 +185,15 @@ async fn camera_main(camera: Camera) -> Result<(), CameraFailureKi let rtsp_thread = loggedin.get_rtsp(); // Clear all buffers present - tags.iter() - .map(|tag| rtsp_thread.clear_buffer(tag)) - .collect::>() - .collect::>() - .await; + // Uncomment to clear buffers. This is now handlled in the buffer itself, + // instead of clearing it restamps it whenever there is a jump in the + // timestamps of >1s + // + // tags.iter() + // .map(|tag| rtsp_thread.clear_buffer(tag)) + // .collect::>() + // .collect::>() + // .await; // Start pulling data from the camera let mut streaming = loggedin