summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/camera_manager.h1
-rw-r--r--src/libcamera/camera_manager.cpp21
2 files changed, 22 insertions, 0 deletions
diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h
index 45e72df0..56dbd26f 100644
--- a/include/libcamera/camera_manager.h
+++ b/include/libcamera/camera_manager.h
@@ -28,6 +28,7 @@ public:
std::shared_ptr<Camera> get(const std::string &name);
void addCamera(std::shared_ptr<Camera> camera);
+ void removeCamera(Camera *camera);
static CameraManager *instance();
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 3eccf20c..f90201ad 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -192,6 +192,27 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera)
}
/**
+ * \brief Remove a camera from the camera manager
+ * \param[in] camera The camera to be removed
+ *
+ * This function is called by pipeline handlers to unregister cameras from the
+ * camera manager. Unregistered cameras won't be reported anymore by the
+ * cameras() and get() calls, but references may still exist in applications.
+ */
+void CameraManager::removeCamera(Camera *camera)
+{
+ for (auto iter = cameras_.begin(); iter != cameras_.end(); ++iter) {
+ if (iter->get() == camera) {
+ LOG(Camera, Debug)
+ << "Unregistering camera '"
+ << camera->name() << "'";
+ cameras_.erase(iter);
+ return;
+ }
+ }
+}
+
+/**
* \brief Retrieve the camera manager instance
*
* The CameraManager is a singleton and can't be constructed manually. This