From 6bea9a805e8d7511287b42821d48df98d53230d2 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Wed, 27 Sep 2023 13:26:48 +0700 Subject: [PATCH] CLippy and build fixes --- src/common/reactor.rs | 2 +- src/rtsp/gst/server.rs | 4 ++-- src/rtsp/mod.rs | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common/reactor.rs b/src/common/reactor.rs index 7923aaf..7eb9967 100644 --- a/src/common/reactor.rs +++ b/src/common/reactor.rs @@ -90,7 +90,7 @@ impl NeoReactor { }, NeoReactorCommand::UpdateConfig(new_conf, reply) => { // Shutdown or Notify instances of a change - let mut names = new_conf.cameras.iter().filter_map(|cam_conf| cam_conf.enabled.then(|| (cam_conf.name.clone(), cam_conf.clone()))).collect::>(); + let mut names = new_conf.cameras.iter().filter(|cam_conf| cam_conf.enabled).map(|cam_conf| (cam_conf.name.clone(), cam_conf.clone())).collect::>(); // Remove those no longer in the config instances.retain(|name, _| names.contains_key(name)); for (name, instance) in instances.iter() { diff --git a/src/rtsp/gst/server.rs b/src/rtsp/gst/server.rs index e8ecb72..e2a8226 100644 --- a/src/rtsp/gst/server.rs +++ b/src/rtsp/gst/server.rs @@ -44,7 +44,7 @@ impl NeoRtspServer { let factory = Object::new::(); // Setup auth - let auth = factory.auth().unwrap_or_else(RTSPAuth::new); + let auth = factory.auth().unwrap_or_default(); auth.set_supported_methods(RTSPAuthMethod::Basic); let mut un_authtoken = RTSPToken::new(&[ //RTSP_TOKEN_MEDIA_FACTORY_ROLE: Means look inside the media factory settings and use the same permissions this user (`"anonymous"`) has @@ -139,7 +139,7 @@ impl NeoRtspServerImpl { client_auth: TlsAuthenticationMode, ) -> AnyResult<()> { debug!("Setting up TLS using {}", cert_file); - let auth = self.obj().auth().unwrap_or_else(RTSPAuth::new); + let auth = self.obj().auth().unwrap_or_default(); // We seperate reading the file and changing to a PEM so that we get different error messages. let cert_contents = fs::read_to_string(cert_file).with_context(|| "TLS file not found")?; diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index 768286b..1dcb4c6 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -588,16 +588,17 @@ async fn stream_main( let mut curr_pn = None; let mut client_activator = stream_instance.activator_handle().await; client_activator.deactivate().await?; + let thread_name = name.clone(); set.spawn(async move { loop { curr_pn = pn - .wait_for(|pn| pn != curr_pn && pn.is_some()) + .wait_for(|pn| pn != &curr_pn && pn.is_some()) .await? .clone(); log::info!("{}: Enabling Push Notification", thread_name); client_activator.activate().await?; tokio::select! { - v = pn.wait_for(|pn| pn != curr_pn && pn.is_some()) => { + v = pn.wait_for(|pn| pn != &curr_pn && pn.is_some()) => { v?; // If another PN during wait then go back to wait more continue; @@ -656,16 +657,17 @@ async fn stream_main( let mut curr_pn = None; let mut client_activator = stream_instance.activator_handle().await; client_activator.deactivate().await?; + let thread_name = name.clone(); set.spawn(async move { loop { curr_pn = pn - .wait_for(|pn| pn != curr_pn && pn.is_some()) + .wait_for(|pn| pn != &curr_pn && pn.is_some()) .await? .clone(); log::info!("{}: Enabling Push Notification", thread_name); client_activator.activate().await?; tokio::select! { - v = pn.wait_for(|pn| pn != curr_pn && pn.is_some()) => { + v = pn.wait_for(|pn| pn != &curr_pn && pn.is_some()) => { v?; // If another PN during wait then go back to wait more continue;