From a6346397785a61296989144afacbcacf501d8b13 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Thu, 26 Oct 2023 11:35:27 +0700 Subject: [PATCH] Increase broadcast size to something more realist for large streams --- src/common/streamthread.rs | 6 ++++-- src/rtsp/stream.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/streamthread.rs b/src/common/streamthread.rs index 34a4c0e..b2bd2ff 100644 --- a/src/common/streamthread.rs +++ b/src/common/streamthread.rs @@ -318,8 +318,10 @@ impl StreamInstance { impl StreamData { async fn new(name: StreamKind, instance: NeoInstance, strict: bool) -> Result { const BUFFER_DURATION: Duration = Duration::from_secs(15); - let (vid, _) = broadcast::(100); - let (aud, _) = broadcast::(100); + // At 30fps for 15s with audio is is about 900 frames + // Therefore we set this buffer to a rather large 2000 + let (vid, _) = broadcast::(2000); + let (aud, _) = broadcast::(2000); let (vid_history, _) = watch::>(VecDeque::new()); let vid_history = Arc::new(vid_history); let (aud_history, _) = watch::>(VecDeque::new()); diff --git a/src/rtsp/stream.rs b/src/rtsp/stream.rs index 3cf3a36..5249b8d 100644 --- a/src/rtsp/stream.rs +++ b/src/rtsp/stream.rs @@ -337,8 +337,10 @@ async fn stream_run( // This is the data that gets sent to gstreamer thread // It represents the combination of the camera stream and the appsrc seek messages - let (aud_data_tx, aud_data_rx) = broadcast(100); - let (vid_data_tx, vid_data_rx) = broadcast(100); + // At 30fps for 15s with audio you need about 900 frames + // Therefore the buffer is rather large at 2000 + let (aud_data_tx, aud_data_rx) = broadcast(2000); + let (vid_data_tx, vid_data_rx) = broadcast(2000); // This thread takes the video data from the cam and passed it into the stream let mut vidstream = BroadcastStream::new(vidstream.resubscribe());