From patchwork Fri Dec 28 07:57:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 94 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 C121360B32 for ; Fri, 28 Dec 2018 08:58:00 +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 5CB9B1BF206; Fri, 28 Dec 2018 07:58:00 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 28 Dec 2018 08:57:43 +0100 Message-Id: <20181228075743.28637-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228075743.28637-1-jacopo@jmondi.org> References: <20181228075743.28637-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH RESEND v2 4/4] libcamera: media device: Add 'match()' method 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: Fri, 28 Dec 2018 07:58:00 -0000 Add 'match()' method to the MediaDevice class. The method allows matching the media device against a MediaDeviceDesc. Signed-off-by: Jacopo Mondi --- src/libcamera/include/media_device.h | 2 ++ src/libcamera/media_device.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) -- 2.20.1 diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h index e1b26e2..9f6d091 100644 --- a/src/libcamera/include/media_device.h +++ b/src/libcamera/include/media_device.h @@ -75,6 +75,8 @@ public: int enumerate(std::map &entitiesMap); void dumpGraph(std::ostream &os); + bool match(MediaDeviceDesc &desc); + int resetLinks(); int link(const std::string &source, unsigned int sourceIdx, const std::string &sink, unsigned int sinkIdx, diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index b98d62f..a961506 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -453,6 +453,25 @@ int MediaDevice::setupLink(const MediaPad *source, const MediaPad *sink, return 0; } +/** + * \brief Match the media device represented by this object against + * a media device description \a desc + * \param desc The media device description to math this MediaDevice against + */ +bool MediaDevice::match(MediaDeviceDesc &desc) +{ + /* TODO: add more fields to MediaDeviceDesc and match them + * against media_device_info fields if required */ + if (name_ != desc.driver()) + return false; + + for (std::string &e : desc.entities()) + if (!getEntityByName(e)) + return false; + + return true; +} + /** * \fn MediaDevice::resetLinks() * \brief Reset all links on the media graph