Skip to content

Commit

Permalink
src: lib: controls: onvif: manager: Update code related to camera con…
Browse files Browse the repository at this point in the history
…text split
  • Loading branch information
joaoantoniocardoso committed Nov 28, 2024
1 parent d7b8f37 commit 9926349
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/lib/controls/onvif/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ impl Manager {
.get(stream_uri)
.context("Camera not found")?;

let Some(streams_information) = &camera.streams_information else {
let Some(streams_information) = &camera.context.read().await.streams_information.clone()
else {
return Err(anyhow!("Failed getting stream information"));
};

Expand All @@ -307,16 +308,29 @@ impl Manager {
let mcontext = MANAGER.read().await.mcontext.clone();
let mcontext = mcontext.read().await;

mcontext
.cameras
.keys()
.map(|stream_uri| {
VideoSourceType::Onvif(VideoSourceOnvif {
name: format!("{stream_uri}"),
source: VideoSourceOnvifType::Onvif(stream_uri.clone()),
})
})
.collect::<Vec<VideoSourceType>>()
let mut streams_available = vec![];
for (stream_uri, camera) in mcontext.cameras.iter() {
let device_information = camera.context.read().await.device_information.clone();

let name = format!(
"{model} - {manufacturer} ({hardware_id})",
model = device_information.model,
manufacturer = device_information.manufacturer,
hardware_id = device_information.hardware_id
);

let source = VideoSourceOnvifType::Onvif(stream_uri.clone());

let stream = VideoSourceType::Onvif(VideoSourceOnvif {
name,
source,
device_information,
});

streams_available.push(stream);
}

streams_available
}

#[instrument(level = "debug")]
Expand Down

0 comments on commit 9926349

Please sign in to comment.