Loading...
Searching...
No Matches
media_object.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* Media Device objects: entities, pads and links.
*/
#pragma once
#include <string>
#include <vector>
#include <linux/media.h>
#include <libcamera/base/class.h>
namespace libcamera {
class MediaDevice;
class MediaEntity;
class MediaPad;
class MediaObject
{
public:
MediaDevice *device() { return dev_; }
const MediaDevice *device() const { return dev_; }
unsigned int id() const { return id_; }
protected:
friend class MediaDevice;
MediaObject(MediaDevice *dev, unsigned int id)
: dev_(dev), id_(id)
{
}
virtual ~MediaObject() = default;
MediaDevice *dev_;
unsigned int id_;
};
class MediaLink : public MediaObject
{
public:
MediaPad *source() const { return source_; }
MediaPad *sink() const { return sink_; }
unsigned int flags() const { return flags_; }
int setEnabled(bool enable);
std::string toString() const;
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink)
friend class MediaDevice;
MediaLink(const struct media_v2_link *link,
MediaPad *source, MediaPad *sink);
MediaPad *source_;
MediaPad *sink_;
unsigned int flags_;
};
std::ostream &operator<<(std::ostream &out, const MediaLink &link);
class MediaPad : public MediaObject
{
public:
unsigned int index() const { return index_; }
MediaEntity *entity() const { return entity_; }
unsigned int flags() const { return flags_; }
const std::vector<MediaLink *> &links() const { return links_; }
void addLink(MediaLink *link);
std::string toString() const;
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad)
friend class MediaDevice;
MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
unsigned int index_;
MediaEntity *entity_;
unsigned int flags_;
std::vector<MediaLink *> links_;
};
std::ostream &operator<<(std::ostream &out, const MediaPad &pad);
class MediaEntity : public MediaObject
{
public:
enum class Type {
Invalid,
MediaEntity,
V4L2Subdevice,
V4L2VideoDevice,
};
const std::string &name() const { return name_; }
unsigned int function() const { return function_; }
unsigned int flags() const { return flags_; }
Type type() const { return type_; }
const std::string &deviceNode() const { return deviceNode_; }
unsigned int deviceMajor() const { return major_; }
unsigned int deviceMinor() const { return minor_; }
const std::vector<MediaPad *> &pads() const { return pads_; }
const std::vector<MediaEntity *> &ancillaryEntities() const { return ancillaryEntities_; }
const MediaPad *getPadByIndex(unsigned int index) const;
const MediaPad *getPadById(unsigned int id) const;
int setDeviceNode(const std::string &deviceNode);
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
friend class MediaDevice;
MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
const struct media_v2_interface *iface);
void addPad(MediaPad *pad);
void addAncillaryEntity(MediaEntity *ancillaryEntity);
std::string name_;
unsigned int function_;
unsigned int flags_;
Type type_;
std::string deviceNode_;
unsigned int major_;
unsigned int minor_;
std::vector<MediaPad *> pads_;
std::vector<MediaEntity *> ancillaryEntities_;
};
} /* namespace libcamera */
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DISABLE_COPY_AND_MOVE
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
libcamera::MediaDevice
The MediaDevice represents a Media Controller device with its full graph of connected objects.
Definition media_device.h:28
libcamera::MediaEntity
The MediaEntity represents an entity in the media graph.
Definition media_object.h:97
libcamera::MediaEntity::ancillaryEntities
const std::vector< MediaEntity * > & ancillaryEntities() const
Retrieve all ancillary entities of the entity.
Definition media_object.h:115
libcamera::MediaEntity::type
Type type() const
Retrieve the entity's type.
Definition media_object.h:109
libcamera::MediaEntity::deviceNode
const std::string & deviceNode() const
Retrieve the entity's device node path, if any.
Definition media_object.h:110
libcamera::MediaEntity::flags
unsigned int flags() const
Retrieve the entity's flags.
Definition media_object.h:108
libcamera::MediaEntity::pads
const std::vector< MediaPad * > & pads() const
Retrieve all pads of the entity.
Definition media_object.h:114
libcamera::MediaEntity::getPadById
const MediaPad * getPadById(unsigned int id) const
Get a pad in this entity by its object id.
Definition media_object.cpp:399
libcamera::MediaEntity::Type
Type
The type of the interface exposed by the entity to userspace.
Definition media_object.h:99
libcamera::MediaEntity::Type::Invalid
@ Invalid
Invalid or unsupported entity type.
Definition media_object.h:100
libcamera::MediaEntity::function
unsigned int function() const
Retrieve the entity's main function.
Definition media_object.h:107
libcamera::MediaEntity::getPadByIndex
const MediaPad * getPadByIndex(unsigned int index) const
Get a pad in this entity by its index.
Definition media_object.cpp:384
libcamera::MediaEntity::deviceMajor
unsigned int deviceMajor() const
Retrieve the major number of the interface associated with the entity.
Definition media_object.h:111
libcamera::MediaEntity::name
const std::string & name() const
Retrieve the entity name.
Definition media_object.h:106
libcamera::MediaEntity::deviceMinor
unsigned int deviceMinor() const
Retrieve the minor number of the interface associated with the entity.
Definition media_object.h:112
libcamera::MediaEntity::setDeviceNode
int setDeviceNode(const std::string &deviceNode)
Set the path to the device node for the associated interface.
Definition media_object.cpp:414
libcamera::MediaLink
The MediaLink represents a link between two pads in the media graph.
Definition media_object.h:44
libcamera::MediaLink::source
MediaPad * source() const
Retrieve the link's source pad.
Definition media_object.h:46
libcamera::MediaLink::sink
MediaPad * sink() const
Retrieve the link's sink pad.
Definition media_object.h:47
libcamera::MediaLink::setEnabled
int setEnabled(bool enable)
Enable or disable a link.
Definition media_object.cpp:122
libcamera::MediaLink::flags
unsigned int flags() const
Retrieve the link's flags.
Definition media_object.h:48
libcamera::MediaLink::toString
std::string toString() const
Generate a string representation of the MediaLink.
Definition media_object.cpp:153
libcamera::MediaObject
Base class for all media objects.
Definition media_object.h:24
libcamera::MediaObject::MediaObject
MediaObject(MediaDevice *dev, unsigned int id)
Construct a MediaObject part of the MediaDevice dev, identified by the id unique within the device.
Definition media_object.h:33
libcamera::MediaObject::dev_
MediaDevice * dev_
The media device the media object belongs to.
Definition media_object.h:39
libcamera::MediaObject::id
unsigned int id() const
Retrieve the media object id.
Definition media_object.h:28
libcamera::MediaObject::device
MediaDevice * device()
Retrieve the media device the media object belongs to.
Definition media_object.h:26
libcamera::MediaObject::device
const MediaDevice * device() const
Retrieve the media device the media object belongs to.
Definition media_object.h:27
libcamera::MediaObject::id_
unsigned int id_
The media object id.
Definition media_object.h:40
libcamera::MediaPad
The MediaPad represents a pad of an entity in the media graph.
Definition media_object.h:69
libcamera::MediaPad::flags
unsigned int flags() const
Retrieve the pad flags.
Definition media_object.h:73
libcamera::MediaPad::addLink
void addLink(MediaLink *link)
Add a new link to this pad.
Definition media_object.cpp:258
libcamera::MediaPad::entity
MediaEntity * entity() const
Retrieve the entity the pad belongs to.
Definition media_object.h:72
libcamera::MediaPad::links
const std::vector< MediaLink * > & links() const
Retrieve all links in the pad.
Definition media_object.h:74
libcamera::MediaPad::index
unsigned int index() const
Retrieve the pad index.
Definition media_object.h:71
libcamera::MediaPad::toString
std::string toString() const
Generate a string representation of the MediaPad.
Definition media_object.cpp:267
libcamera::V4L2Subdevice
A V4L2 subdevice as exposed by the Linux kernel.
Definition v4l2_subdevice.h:76
libcamera::V4L2VideoDevice
V4L2VideoDevice object and API.
Definition v4l2_videodevice.h:189
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition geometry.cpp:91