Added enable config option
This commit is contained in:
6 files changed
+103
-58
No files matched your search
@@ -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)]
|
||||
|
||||
@@ -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
@@ -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?);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
Reference in new issue
Block a user