libcamera: device_enumerator: add DeviceMatch class
Provide a DeviceMatch class which represents all properties of a media device a pipeline hander can specify when searching for a device to use in its pipeline. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
0eab433d05
commit
c0d39bab5b
2 changed files with 50 additions and 0 deletions
|
@ -75,4 +75,40 @@ int DeviceInfo::lookup(const std::string &name, std::string &devnode) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DeviceMatch
|
||||
*/
|
||||
|
||||
DeviceMatch::DeviceMatch(const std::string &driver)
|
||||
: driver_(driver)
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceMatch::add(const std::string &entity)
|
||||
{
|
||||
entities_.push_back(entity);
|
||||
}
|
||||
|
||||
bool DeviceMatch::match(const DeviceInfo *info) const
|
||||
{
|
||||
if (driver_ != info->info().driver)
|
||||
return false;
|
||||
|
||||
for (const std::string &name : entities_) {
|
||||
bool found = false;
|
||||
|
||||
for (const std::string &entity : info->entities()) {
|
||||
if (name == entity) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -39,6 +39,20 @@ private:
|
|||
std::map<std::string, std::string> entities_;
|
||||
};
|
||||
|
||||
class DeviceMatch
|
||||
{
|
||||
public:
|
||||
DeviceMatch(const std::string &driver);
|
||||
|
||||
void add(const std::string &entity);
|
||||
|
||||
bool match(const DeviceInfo *info) const;
|
||||
|
||||
private:
|
||||
std::string driver_;
|
||||
std::vector<std::string> entities_;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue