From 5d05504ec8ad335e88a832c0d1dab3a82a63f6e2 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Thu, 18 Apr 2024 18:49:32 +0700 Subject: [PATCH 1/2] Add a discovery udpxml test --- crates/core/src/bcudp/xml.rs | 42 +++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/core/src/bcudp/xml.rs b/crates/core/src/bcudp/xml.rs index ba5daea..82ad353 100644 --- a/crates/core/src/bcudp/xml.rs +++ b/crates/core/src/bcudp/xml.rs @@ -150,7 +150,7 @@ pub struct D2cCr { /// Called timer but not sure what it is a timer of pub timer: Timer, /// Unknown seems to be 0 on success and -3 on fail - pub rsp: u32, + pub rsp: i32, /// Client ID pub cid: i32, /// Camera ID @@ -358,7 +358,7 @@ pub struct D2cCfm { /// Type of connection observed values are `"local"` pub conn: String, /// Unknown known values are `0`, `-3, seems to be 0 on success and -3 on fail` - pub rsp: u32, + pub rsp: i32, /// The client connection ID pub cid: i32, /// The camera connection ID @@ -377,7 +377,7 @@ pub struct C2rCfm { /// Type of connection observed values are `"local"` pub conn: String, /// Unknown known values are `0`, `-3, seems to be 0 on success and -3 on fail` - pub rsp: u32, + pub rsp: i32, /// The client connection ID pub cid: i32, /// The camera connection ID @@ -439,3 +439,39 @@ pub struct D2cHb { /// The camera connection ID pub did: i32, } + +/// This test was added because of issues with Argus3 during discovery +#[test] +fn test_d2c_c_r_deser() { + let sample = indoc::indoc!( + r#" + + + + 3000 + 20000 + 60000 + + 0 + -376737975 + 49 + + + "# + ); + let b: UdpXml = UdpXml::try_parse(sample.as_bytes()).unwrap(); + + assert_matches::assert_matches!( + b, + UdpXml::D2cCr(D2cCr { + timer: Timer { + def: 3000, + hb: 20000, + hbt: 60000, + }, + rsp: 0, + cid: -376737975, + did: 49, + }) + ); +} From e146f9593be446db63349f3707d367a17effb976 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Thu, 18 Apr 2024 18:50:20 +0700 Subject: [PATCH 2/2] Reduce history buffer duration --- src/common/streamthread.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/streamthread.rs b/src/common/streamthread.rs index ce3656d..5c4eaa0 100644 --- a/src/common/streamthread.rs +++ b/src/common/streamthread.rs @@ -316,11 +316,11 @@ impl StreamInstance { impl StreamData { async fn new(name: StreamKind, instance: NeoInstance, strict: bool) -> Result { - const BUFFER_DURATION: Duration = Duration::from_secs(15); + const BUFFER_DURATION: Duration = Duration::from_secs(3); // 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); + const BUFFER_SIZE: usize = 30usize * BUFFER_DURATION.as_millis() as usize / 1000usize; + let (vid, _) = broadcast::(BUFFER_SIZE); + let (aud, _) = broadcast::(BUFFER_SIZE); let (vid_history, _) = watch::>(VecDeque::new()); let vid_history = Arc::new(vid_history); let (aud_history, _) = watch::>(VecDeque::new()); @@ -579,7 +579,7 @@ impl StreamData { let drop_time = d.ts.saturating_sub(BUFFER_DURATION); let dts = d.ts; history.push_back(d); - while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 { + while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > BUFFER_SIZE { history.pop_front(); } log::info!("history: {}", history.len()); @@ -602,7 +602,7 @@ impl StreamData { let drop_time = d.ts.saturating_sub(BUFFER_DURATION); let dts = d.ts; history.push_back(d); - while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 { + while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > BUFFER_SIZE { history.pop_front(); } }); @@ -621,7 +621,7 @@ impl StreamData { let drop_time = d.ts.saturating_sub(BUFFER_DURATION); let dts = d.ts; history.push_back(d); - while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > 1000 { + while history.front().is_some_and(|di| di.ts < drop_time || di.ts > dts) || history.len() > BUFFER_SIZE { history.pop_front(); } });