libcamera: Add MediaDevice class

The MediaDevice object implements handling and configuration of the media
graph associated with a media device.

The class allows enumeration of all pads, links and entities registered in
the media graph.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi
2018-12-18 12:49:41 +01:00
parent f0e16f0389
commit 363824662f
3 changed files with 433 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* media_device.h - Media device handler
*/
#ifndef __LIBCAMERA_MEDIA_DEVICE_H__
#define __LIBCAMERA_MEDIA_DEVICE_H__
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <linux/media.h>
#include "media_object.h"
namespace libcamera {
class MediaDevice
{
public:
MediaDevice(const std::string &devnode);
~MediaDevice();
int open();
void close();
int populate();
const std::string driver() const { return driver_; }
const std::string devnode() const { return devnode_; }
const std::vector<MediaEntity *> &entities() const { return entities_; }
private:
std::string driver_;
std::string devnode_;
int fd_;
std::map<unsigned int, MediaObject *> objects_;
MediaObject *object(unsigned int id);
int addObject(MediaObject *obj);
void clear();
std::vector<MediaEntity *> entities_;
MediaEntity *getEntityByName(const std::string &name);
void populateEntities(const struct media_v2_topology &topology);
int populatePads(const struct media_v2_topology &topology);
int populateLinks(const struct media_v2_topology &topology);
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_MEDIA_DEVICE_H__ */