@@ -75,6 +75,8 @@ public:
int enumerate(std::map<std::string, std::string> &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,
@@ -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
Add 'match()' method to the MediaDevice class. The method allows matching the media device against a MediaDeviceDesc. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/include/media_device.h | 2 ++ src/libcamera/media_device.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) -- 2.20.1