diff --git a/crates/core/src/bc_protocol/abilityinfo.rs b/crates/core/src/bc_protocol/abilityinfo.rs index 6718584..6a7b99c 100644 --- a/crates/core/src/bc_protocol/abilityinfo.rs +++ b/crates/core/src/bc_protocol/abilityinfo.rs @@ -1,5 +1,6 @@ use super::{BcCamera, Error, Result}; use crate::bc::{model::*, xml::*}; +use log::*; impl BcCamera { /// Get the ability info xml for the current user @@ -53,6 +54,11 @@ impl BcCamera { /// Populate ability list of the camera pub async fn polulate_abilities(&self) -> Result<()> { let info = self.get_abilityinfo().await?; + let info_res = yaserde::ser::serialize_with_writer(&info, vec![], &Default::default()); + if let Ok(Ok(info_str)) = info_res.map(String::from_utf8) { + debug!("Abilities: {}", info_str); + } + let mut abilities: Vec = vec![]; let mut tokens: Vec> = vec![ @@ -67,6 +73,7 @@ impl BcCamera { info.io.as_ref(), info.streaming.as_ref(), ]; + for token in tokens.drain(..).flatten() { for sub_module in token.sub_module.iter() { abilities.extend( diff --git a/crates/core/src/bc_protocol/login.rs b/crates/core/src/bc_protocol/login.rs index b6b9810..4291727 100644 --- a/crates/core/src/bc_protocol/login.rs +++ b/crates/core/src/bc_protocol/login.rs @@ -166,6 +166,7 @@ impl BcCamera { } // Populate the list of abilities this user has with the camera + log::debug!("Populating abilities"); self.polulate_abilities().await?; Ok(device_info) } diff --git a/crates/core/src/bcudp/codex.rs b/crates/core/src/bcudp/codex.rs index 5ba9d06..74ad60c 100644 --- a/crates/core/src/bcudp/codex.rs +++ b/crates/core/src/bcudp/codex.rs @@ -41,7 +41,7 @@ impl Decoder for BcUdpCodex { }, .. })) => { - log::error!("Relay terminate"); + // log::error!("Relay terminate"); Err(Error::RelayTerminate) } Ok(BcUdp::Discovery(UdpDiscovery { @@ -50,7 +50,7 @@ impl Decoder for BcUdpCodex { }, .. })) => { - log::error!("Camera terminate"); + // log::error!("Camera terminate"); Err(Error::CameraTerminate) } Ok(bc) => Ok(Some(bc)), diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index f51ee01..293833d 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -88,9 +88,10 @@ pub(crate) async fn main(_opt: Opt, mut config: Config) -> Result<()> { } let mut set = tokio::task::JoinSet::new(); - for camera in cameras.drain(..) { + for mut camera in cameras.drain(..) { // Spawn each camera controller in it's own thread set.spawn(async move { + let shared = camera.shared.clone(); let name = camera.get_name(); loop { let failure = camera_main(camera).await; @@ -101,7 +102,10 @@ pub(crate) async fn main(_opt: Opt, mut config: Config) -> Result<()> { } Err(CameraFailureKind::Retry(e)) => { warn!("{}: Retryable error: {:X?}", name, e); - todo!(); // Do backoff + camera = Camera { + shared: shared.clone(), + state: Disconnected {}, + }; } Ok(()) => { info!("{}: Shutting down", name); @@ -121,7 +125,7 @@ pub(crate) async fn main(_opt: Opt, mut config: Config) -> Result<()> { let bind_port = config.bind_port; set.spawn(async move { rtsp.run(&bind_addr, bind_port).await }); - if let Some(joined) = set.join_next().await { + while let Some(joined) = set.join_next().await { joined?? } diff --git a/src/rtsp/states/connected.rs b/src/rtsp/states/connected.rs index e1736bd..20d4aca 100644 --- a/src/rtsp/states/connected.rs +++ b/src/rtsp/states/connected.rs @@ -5,7 +5,7 @@ use super::{camera::Camera, disconnected::Disconnected, loggedin::LoggedIn}; use anyhow::Result; -use neolink_core::bc_protocol::BcCamera; +use neolink_core::bc_protocol::{BcCamera, MaxEncryption}; pub(crate) struct Connected { pub(crate) camera: BcCamera, @@ -20,6 +20,14 @@ impl Camera { } pub(crate) async fn login(self) -> Result> { + let max_encryption = match self.shared.config.max_encryption.to_lowercase().as_str() { + "none" => MaxEncryption::None, + "bcencrypt" => MaxEncryption::BcEncrypt, + "aes" => MaxEncryption::Aes, + _ => MaxEncryption::Aes, + }; + + self.state.camera.login_with_maxenc(max_encryption).await?; Ok(Camera { shared: self.shared, state: LoggedIn {