Added enable config option

This commit is contained in:
QuantumEntangledAndy committed 2023-08-07 10:52:16 +07:00
1 parent c198f21c92
commit a45bcf8761
6 files changed
+103 -58

No files matched your search

+3
View File
@@ -123,6 +123,9 @@ pub(crate) struct CameraConfig {
#[serde(default = "default_true", alias = "splash")]
pub(crate) use_splash: bool,
#[serde(default = "default_true", alias = "enable")]
pub(crate) enabled: bool,
}
#[derive(Debug, Deserialize, Validate, Clone)]
+1
View File
@@ -95,6 +95,7 @@ pub(crate) async fn main(_: Opt, config: Config) -> Result<()> {
for camera_config in config
.cameras
.iter()
.filter(|c| c.enabled)
.map(|a| Arc::new(a.clone()))
.collect::<Vec<_>>()
{
+1 -1
View File
@@ -88,7 +88,7 @@ pub(crate) async fn main(_opt: Opt, mut config: Config) -> Result<()> {
)
}
let mut cameras = vec![];
for camera_config in config.cameras.drain(..) {
for camera_config in config.cameras.drain(..).filter(|c| c.enabled) {
cameras
.push(Camera::<Disconnected>::new(camera_config, &config.users, rtsp.clone()).await?);
}
+1
View File
@@ -153,6 +153,7 @@ pub(crate) fn find_camera_by_name<'a>(config: &'a Config, name: &str) -> Result<
config
.cameras
.iter()
.filter(|c| c.enabled)
.find(|c| c.name == name)
.ok_or_else(|| anyhow!("Camera {} not found in the config file", name))
}