From 9786953e5f18c5ce75b79379efb174a846ebe060 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Mon, 21 Aug 2023 09:32:02 +0700 Subject: [PATCH] Change some timeouts and send ack less often --- crates/core/src/bc_protocol/connection/udpsource.rs | 11 ++++++----- src/rtsp/mod.rs | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/core/src/bc_protocol/connection/udpsource.rs b/crates/core/src/bc_protocol/connection/udpsource.rs index 0d7617d..54ff3b0 100644 --- a/crates/core/src/bc_protocol/connection/udpsource.rs +++ b/crates/core/src/bc_protocol/connection/udpsource.rs @@ -343,7 +343,7 @@ impl UdpPayloadInner { // Queue up ack packets let ack_cancel = cancel.clone(); - let mut ack_interval = interval(Duration::from_millis(10)); // Offical Client does ack every 10ms + let mut ack_interval = interval(Duration::from_millis(100)); // Offical Client does ack every 10ms ack_interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); let (ack_tx, mut ack_rx) = channel(1000); let thread_camera_id = camera_id; @@ -391,9 +391,10 @@ impl UdpPayloadInner { .build() .unwrap(); - // A packet of ANY kind must be recieved in the last second - // since there are 10 acks a second 3s should be fine (first packet has 15s while later 3s) - let mut recv_timeout = Box::pin(sleep(Duration::from_secs(15))); + // A packet of ANY kind must be recieved in the 10 last second + // This is based on the official client which also seems to take 10s timeout + const TIME_OUT: u64 = 10; + let mut recv_timeout = Box::pin(sleep(Duration::from_secs(TIME_OUT))); runtime.block_on(async { let res = tokio::select! { @@ -407,7 +408,7 @@ impl UdpPayloadInner { socket_rx.next().await.ok_or(Error::DroppedConnection) } => { log::trace!("Got packet"); - recv_timeout.as_mut().reset(Instant::now() + Duration::from_secs(3)); + recv_timeout.as_mut().reset(Instant::now() + Duration::from_secs(TIME_OUT)); v } _ = recv_timeout.as_mut() => { diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index f58f360..c6dd680 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -258,6 +258,7 @@ async fn camera_main(camera: Camera) -> Result<(), CameraFailureKi streaming.join().await }, if ! active_tags.is_empty() => { info!("{}: Join Pause", name); + panic!(); Ok(StreamChange::StreamError(v)) }, v = await_change(