@@ -46,6 +46,7 @@ public:
virtual int createCamera(const CameraDescriptor *descriptor);
std::shared_ptr<MediaDevice> acquireMediaDevice(DeviceEnumerator *enumerator,
const DeviceMatch &dm);
+ bool acquireMediaDevice(std::shared_ptr<MediaDevice> media);
bool usesMediaDevice(const MediaDevice *media) const;
bool acquire(Camera *camera);
@@ -204,6 +204,29 @@ PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,
return media;
}
+/**
+ * \brief Acquire a specific MediaDevice
+ * \param[in] media The media device to acquire
+ *
+ * Acquire the media device \a media for this pipeline handler instance. As with
+ * the search variant, the caller shall not release the device explicitly, it
+ * will be automatically released when the pipeline handler is destroyed.
+ *
+ * \context This function shall be called from the CameraManager thread.
+ *
+ * \return True if the media device was acquired, or false if it was already
+ * in use
+ */
+bool PipelineHandler::acquireMediaDevice(std::shared_ptr<MediaDevice> media)
+{
+ if (!media->acquire())
+ return false;
+
+ mediaDevices_.push_back(std::move(media));
+
+ return true;
+}
+
/**
* \brief Check if this pipeline handler instance uses a media device
* \param[in] media The media device to check for
Add an acquireMediaDevice() overload that acquires a given MediaDevice instance rather than the existing search mechanism. Camera creation through a descriptor already knows exactly which media devices the camera needs, so this is a simpler shortcut. This will be used in future commits to acquire a camera through the enumeration API. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- include/libcamera/internal/pipeline_handler.h | 1 + src/libcamera/pipeline_handler.cpp | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+)