summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index 5de8a0cb..c51e8bc1 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -10,6 +10,7 @@
#include "device_enumerator.h"
#include "media_device.h"
#include "pipeline_handler.h"
+#include "v4l2_device.h"
namespace libcamera {
@@ -23,15 +24,19 @@ public:
private:
std::shared_ptr<MediaDevice> media_;
+ V4L2Device *video_;
};
PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)
- : PipelineHandler(manager), media_(nullptr)
+ : PipelineHandler(manager), media_(nullptr), video_(nullptr)
{
}
PipelineHandlerUVC::~PipelineHandlerUVC()
{
+ if (video_)
+ delete video_;
+
if (media_)
media_->release();
}
@@ -47,6 +52,18 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
media_->acquire();
+ for (MediaEntity *entity : media_->entities()) {
+ if (entity->flags() & MEDIA_ENT_FL_DEFAULT) {
+ video_ = new V4L2Device(*entity);
+ break;
+ }
+ }
+
+ if (!video_ || video_->open()) {
+ media_->release();
+ return false;
+ }
+
std::shared_ptr<Camera> camera = Camera::create(this, media_->model());
registerCamera(std::move(camera));
hotplugMediaDevice(media_.get());