libcamera: pipeline: uvcvideo: create a V4L2Device for the default video entity
Add a V4L2Device for the default video entity in the media graph. The UVC pipeline needs to search for the entity marked with the MEDIA_ENT_FL_DEFAULT flag as the entity names in the media graph varies depending on which device is used. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
25a2f96a28
commit
67d313240c
1 changed files with 18 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "device_enumerator.h"
|
#include "device_enumerator.h"
|
||||||
#include "media_device.h"
|
#include "media_device.h"
|
||||||
#include "pipeline_handler.h"
|
#include "pipeline_handler.h"
|
||||||
|
#include "v4l2_device.h"
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
|
@ -23,15 +24,19 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<MediaDevice> media_;
|
std::shared_ptr<MediaDevice> media_;
|
||||||
|
V4L2Device *video_;
|
||||||
};
|
};
|
||||||
|
|
||||||
PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)
|
PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)
|
||||||
: PipelineHandler(manager), media_(nullptr)
|
: PipelineHandler(manager), media_(nullptr), video_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineHandlerUVC::~PipelineHandlerUVC()
|
PipelineHandlerUVC::~PipelineHandlerUVC()
|
||||||
{
|
{
|
||||||
|
if (video_)
|
||||||
|
delete video_;
|
||||||
|
|
||||||
if (media_)
|
if (media_)
|
||||||
media_->release();
|
media_->release();
|
||||||
}
|
}
|
||||||
|
@ -47,6 +52,18 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
|
||||||
|
|
||||||
media_->acquire();
|
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());
|
std::shared_ptr<Camera> camera = Camera::create(this, media_->model());
|
||||||
registerCamera(std::move(camera));
|
registerCamera(std::move(camera));
|
||||||
hotplugMediaDevice(media_.get());
|
hotplugMediaDevice(media_.get());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue