[libcamera-devel] [PATCH 5/9] libcamera: camera_manager: Try to match camera IDs first
Niklas Söderlund
niklas.soderlund at ragnatech.se
Sat Jul 18 15:23:20 CEST 2020
When getting a camera from a string match on camera ID before name.
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
src/libcamera/camera_manager.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 4d23d601e1fc8a28..796b84b5bb00bed4 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -346,6 +346,12 @@ std::shared_ptr<Camera> CameraManager::get(const std::string &name)
{
MutexLocker locker(p_->mutex_);
+ /* Search camera IDs first. */
+ for (std::shared_ptr<Camera> camera : p_->cameras_) {
+ if (camera->id() == name)
+ return camera;
+ }
+
for (std::shared_ptr<Camera> camera : p_->cameras_) {
if (camera->name() == name)
return camera;
--
2.27.0
More information about the libcamera-devel
mailing list