Don't forget to login

This commit is contained in:
QuantumEntangledAndy committed 2023-04-10 06:49:39 +07:00
1 parent 2ae25a1e58
commit 31723e9469
5 files changed
+26 -6

No files matched your search

@@ -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<String> = vec![];
let mut tokens: Vec<Option<&AbilityInfoToken>> = 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(
+1
View File
@@ -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)
}
+2 -2
View File
@@ -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)),
+7 -3
View File
@@ -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??
}
+9 -1
View File
@@ -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<Connected> {
}
pub(crate) async fn login(self) -> Result<Camera<LoggedIn>> {
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 {