From patchwork Mon Jan 21 17:27:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 302 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A64060C83 for ; Mon, 21 Jan 2019 18:27:03 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 0DD711BF214; Mon, 21 Jan 2019 17:27:02 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:00 +0100 Message-Id: <20190121172705.19985-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] libcamera: v4l2_device: Add MediaEntity contructor X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2019 17:27:03 -0000 Construct a V4L2Device from a MediaEntity device node path. While at there mark constructor as explicit to avoid copy-construction. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_device.h | 4 +++- src/libcamera/v4l2_device.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 474c05b..c6f3d9a 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 54b53de..59a1ad9 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -12,6 +12,7 @@ #include #include "log.h" +#include "media_object.h" #include "v4l2_device.h" /** @@ -92,6 +93,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();