summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libcamera/include/v4l2_device.h4
-rw-r--r--src/libcamera/v4l2_device.cpp12
2 files changed, 15 insertions, 1 deletions
diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
index 474c05b5..c6f3d9a0 100644
--- a/src/libcamera/include/v4l2_device.h
+++ b/src/libcamera/include/v4l2_device.h
@@ -32,10 +32,12 @@ struct V4L2Capability final : v4l2_capability {
bool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; }
};
+class MediaEntity;
class V4L2Device
{
public:
- V4L2Device(const std::string &devnode);
+ explicit V4L2Device(const std::string &devnode);
+ explicit V4L2Device(const MediaEntity &entity);
V4L2Device(const V4L2Device &) = delete;
~V4L2Device();
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 59c5ac98..5809fc62 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -12,6 +12,7 @@
#include <unistd.h>
#include "log.h"
+#include "media_object.h"
#include "v4l2_device.h"
/**
@@ -94,6 +95,17 @@ V4L2Device::V4L2Device(const std::string &devnode)
{
}
+/**
+ * \brief Construct a V4L2Device from a MediaEntity
+ * \param entity The MediaEntity to build the device from
+ *
+ * Construct a V4L2Device from a MediaEntity's device node path.
+ */
+V4L2Device::V4L2Device(const MediaEntity &entity)
+ : V4L2Device(entity.devnode())
+{
+}
+
V4L2Device::~V4L2Device()
{
close();