@@ -41,13 +41,13 @@ public:
virtual int init() = 0;
virtual int enumerate() = 0;
+ void addDevice(std::unique_ptr<MediaDeviceBase> media);
std::shared_ptr<MediaDeviceBase> search(const DeviceMatch &dm);
Signal<> devicesAdded;
protected:
std::unique_ptr<MediaDeviceBase> createDevice(const std::string &deviceNode);
- void addDevice(std::unique_ptr<MediaDeviceBase> media);
void removeDevice(const std::string &deviceNode);
private:
@@ -77,6 +77,7 @@ protected:
virtual void releaseDevice(Camera *camera);
CameraManager *manager_;
+ std::vector<std::shared_ptr<MediaDeviceBase>> mediaDevices_;
private:
void unlockMediaDevices();
@@ -87,7 +88,6 @@ private:
void doQueueRequest(Request *request);
void doQueueRequests();
- std::vector<std::shared_ptr<MediaDeviceBase>> mediaDevices_;
std::vector<std::weak_ptr<Camera>> cameras_;
std::queue<Request *> waitingRequests_;
@@ -9,6 +9,7 @@
#include <libcamera/camera.h>
+#include "libcamera/internal/media_device_virtual.h"
#include "libcamera/internal/pipeline_handler.h"
namespace libcamera {
@@ -41,6 +42,9 @@ public:
int queueRequestDevice(Camera *camera, Request *request) override;
bool match(DeviceEnumerator *enumerator) override;
+
+private:
+ std::shared_ptr<MediaDeviceVirtual> mediaDeviceVirtual_;
};
VirtualCameraConfiguration::VirtualCameraConfiguration()
@@ -54,7 +58,7 @@ CameraConfiguration::Status VirtualCameraConfiguration::validate()
}
PipelineHandlerVirtual::PipelineHandlerVirtual(CameraManager *manager)
- : PipelineHandler(manager)
+ : PipelineHandler(manager), mediaDeviceVirtual_(new MediaDeviceVirtual("virtual"))
{
}
@@ -104,7 +108,8 @@ int PipelineHandlerVirtual::queueRequestDevice(Camera *camera, Request *request)
bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator)
{
(void)enumerator;
- return false;
+ mediaDevices_.push_back(mediaDeviceVirtual_);
+ return false; // Prevent infinite loops for now
}
REGISTER_PIPELINE_HANDLER(PipelineHandlerVirtual)
Add a dummy MediaDeviceVirtual in PipelineHandlerVirtual::match, to avoid having no MediaDevice in the pipeline handler. Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> --- include/libcamera/internal/device_enumerator.h | 2 +- include/libcamera/internal/pipeline_handler.h | 2 +- src/libcamera/pipeline/virtual/virtual.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-)