libcamera: Add pointer to MediaDevice to MediaObject
Add a MediaDevice member field to the MediaObject class hierarcy. Each media object now has a reference to the media device it belongs to, and which it has been created by. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
aed8c7823e
commit
6275a14215
3 changed files with 32 additions and 12 deletions
|
@ -21,14 +21,17 @@ class MediaPad;
|
||||||
class MediaObject
|
class MediaObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MediaDevice *device() { return dev_; }
|
||||||
unsigned int id() const { return id_; }
|
unsigned int id() const { return id_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class MediaDevice;
|
friend class MediaDevice;
|
||||||
|
|
||||||
MediaObject(unsigned int id) : id_(id) { }
|
MediaObject(MediaDevice *dev, unsigned int id) :
|
||||||
|
dev_(dev), id_(id) { }
|
||||||
virtual ~MediaObject() { }
|
virtual ~MediaObject() { }
|
||||||
|
|
||||||
|
MediaDevice *dev_;
|
||||||
unsigned int id_;
|
unsigned int id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,7 +96,7 @@ public:
|
||||||
private:
|
private:
|
||||||
friend class MediaDevice;
|
friend class MediaDevice;
|
||||||
|
|
||||||
MediaEntity(const struct media_v2_entity *entity,
|
MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
|
||||||
unsigned int major = 0, unsigned int minor = 0);
|
unsigned int major = 0, unsigned int minor = 0);
|
||||||
MediaEntity(const MediaEntity &) = delete;
|
MediaEntity(const MediaEntity &) = delete;
|
||||||
~MediaEntity();
|
~MediaEntity();
|
||||||
|
|
|
@ -430,11 +430,11 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)
|
||||||
|
|
||||||
MediaEntity *entity;
|
MediaEntity *entity;
|
||||||
if (iface)
|
if (iface)
|
||||||
entity = new MediaEntity(&mediaEntities[i],
|
entity = new MediaEntity(this, &mediaEntities[i],
|
||||||
iface->devnode.major,
|
iface->devnode.major,
|
||||||
iface->devnode.minor);
|
iface->devnode.minor);
|
||||||
else
|
else
|
||||||
entity = new MediaEntity(&mediaEntities[i]);
|
entity = new MediaEntity(this, &mediaEntities[i]);
|
||||||
|
|
||||||
if (!addObject(entity)) {
|
if (!addObject(entity)) {
|
||||||
delete entity;
|
delete entity;
|
||||||
|
|
|
@ -42,28 +42,43 @@ namespace libcamera {
|
||||||
* \class MediaObject
|
* \class MediaObject
|
||||||
* \brief Base class for all media objects
|
* \brief Base class for all media objects
|
||||||
*
|
*
|
||||||
* MediaObject is an abstract base class for all media objects in the media
|
* MediaObject is an abstract base class for all media objects in the
|
||||||
* graph. Every media graph object is identified by an id unique in the media
|
* media graph. Each object is identified by a reference to the media
|
||||||
* device context, and this base class provides that.
|
* device it belongs to and a unique id within that media device.
|
||||||
|
* This base class provide helpers to media objects to keep track of
|
||||||
|
* these identifiers.
|
||||||
*
|
*
|
||||||
* \sa MediaEntity, MediaPad, MediaLink
|
* \sa MediaEntity, MediaPad, MediaLink
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn MediaObject::MediaObject()
|
* \fn MediaObject::MediaObject()
|
||||||
* \brief Construct a MediaObject with \a id
|
* \brief Construct a MediaObject part of the MediaDevice \a dev,
|
||||||
|
* identified by the \a id unique within the device
|
||||||
|
* \param dev The media device this object belongs to
|
||||||
* \param id The media object id
|
* \param id The media object id
|
||||||
*
|
*
|
||||||
* The caller shall ensure unicity of the object id in the media device context.
|
* The caller shall ensure unicity of the object id in the media device context.
|
||||||
* This constraint is neither enforced nor checked by the MediaObject.
|
* This constraint is neither enforced nor checked by the MediaObject.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn MediaObject::device()
|
||||||
|
* \brief Retrieve the media device the media object belongs to
|
||||||
|
* \return The MediaDevice
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn MediaObject::id()
|
* \fn MediaObject::id()
|
||||||
* \brief Retrieve the media object id
|
* \brief Retrieve the media object id
|
||||||
* \return The media object id
|
* \return The media object id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \var MediaObject::dev_
|
||||||
|
* \brief The media device the media object belongs to
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \var MediaObject::id_
|
* \var MediaObject::id_
|
||||||
* \brief The media object id
|
* \brief The media object id
|
||||||
|
@ -88,7 +103,7 @@ namespace libcamera {
|
||||||
*/
|
*/
|
||||||
MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,
|
MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,
|
||||||
MediaPad *sink)
|
MediaPad *sink)
|
||||||
: MediaObject(link->id), source_(source),
|
: MediaObject(source->device(), link->id), source_(source),
|
||||||
sink_(sink), flags_(link->flags)
|
sink_(sink), flags_(link->flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -139,7 +154,7 @@ MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,
|
||||||
* \param entity The entity the pad belongs to
|
* \param entity The entity the pad belongs to
|
||||||
*/
|
*/
|
||||||
MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
|
MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
|
||||||
: MediaObject(pad->id), index_(pad->index), entity_(entity),
|
: MediaObject(entity->device(), pad->id), index_(pad->index), entity_(entity),
|
||||||
flags_(pad->flags)
|
flags_(pad->flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -283,13 +298,15 @@ int MediaEntity::setDeviceNode(const std::string &devnode)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Construct a MediaEntity
|
* \brief Construct a MediaEntity
|
||||||
|
* \param dev The media device this entity belongs to
|
||||||
* \param entity The media entity kernel data
|
* \param entity The media entity kernel data
|
||||||
* \param major The major number of the entity associated interface
|
* \param major The major number of the entity associated interface
|
||||||
* \param minor The minor number of the entity associated interface
|
* \param minor The minor number of the entity associated interface
|
||||||
*/
|
*/
|
||||||
MediaEntity::MediaEntity(const struct media_v2_entity *entity,
|
MediaEntity::MediaEntity(MediaDevice *dev,
|
||||||
|
const struct media_v2_entity *entity,
|
||||||
unsigned int major, unsigned int minor)
|
unsigned int major, unsigned int minor)
|
||||||
: MediaObject(entity->id), name_(entity->name),
|
: MediaObject(dev, entity->id), name_(entity->name),
|
||||||
major_(major), minor_(minor)
|
major_(major), minor_(minor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue