libcamera
v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
|
The MediaDevice represents a Media Controller device with its full graph of connected objects. More...
Public Member Functions | |
MediaDevice (const std::string &deviceNode) | |
Construct a MediaDevice. More... | |
bool | acquire () |
Claim a device for exclusive use. More... | |
void | release () |
Release a device previously claimed for exclusive use. More... | |
bool | busy () const |
Check if a device is in use. More... | |
bool | lock () |
Lock the device to prevent it from being used by other instances of libcamera. More... | |
void | unlock () |
Unlock the device and free it for use for libcamera instances. More... | |
int | populate () |
Populate the MediaDevice with device information and media objects. More... | |
bool | isValid () const |
Query whether the media graph has been populated and is valid. More... | |
const std::string & | driver () const |
Retrieve the media device driver name. More... | |
const std::string & | deviceNode () const |
Retrieve the media device node path. More... | |
const std::string & | model () const |
Retrieve the media device model name. More... | |
unsigned int | version () const |
Retrieve the media device API version. More... | |
unsigned int | hwRevision () const |
Retrieve the media device hardware revision. More... | |
const std::vector< MediaEntity * > & | entities () const |
Retrieve the list of entities in the media graph. More... | |
MediaEntity * | getEntityByName (const std::string &name) const |
Return the MediaEntity with name name. More... | |
MediaLink * | link (const std::string &sourceName, unsigned int sourceIdx, const std::string &sinkName, unsigned int sinkIdx) |
Retrieve the MediaLink connecting two pads, identified by entity names and pad indexes. More... | |
MediaLink * | link (const MediaEntity *source, unsigned int sourceIdx, const MediaEntity *sink, unsigned int sinkIdx) |
Retrieve the MediaLink connecting two pads, identified by the entities they belong to and pad indexes. More... | |
MediaLink * | link (const MediaPad *source, const MediaPad *sink) |
Retrieve the MediaLink that connects two pads. More... | |
int | disableLinks () |
Disable all links in the media device. More... | |
Public Attributes | |
Signal | disconnected |
Signal emitted when the media device is disconnected from the system. More... | |
Protected Member Functions | |
std::string | logPrefix () const override |
Retrieve a string to be prefixed to the log message. More... | |
Protected Member Functions inherited from libcamera::Loggable | |
LogMessage | _log (const LogCategory *category, LogSeverity severity, const char *fileName=__builtin_FILE(), unsigned int line=__builtin_LINE()) const |
Create a temporary LogMessage object to log a message. More... | |
Friends | |
int | MediaLink::setEnabled (bool enable) |
The MediaDevice represents a Media Controller device with its full graph of connected objects.
A MediaDevice instance is associated with a media controller device node when created, and that association is kept for the lifetime of the MediaDevice instance.
The instance is created with an empty media graph. Before performing any other operation, it must be populate by calling populate(). Instances of MediaEntity, MediaPad and MediaLink are created to model the media graph, and stored in a map indexed by object id.
The graph is valid once successfully populated, as reported by the isValid() function. It can be queried to list all entities(), or entities can be looked up by name with getEntityByName(). The graph can be traversed from entity to entity through pads and links as exposed by the corresponding classes.
Media devices can be claimed for exclusive use with acquire(), released with release() and tested with busy(). This mechanism is aimed at pipeline managers to claim media devices they support during enumeration.
libcamera::MediaDevice::MediaDevice | ( | const std::string & | deviceNode | ) |
Construct a MediaDevice.
[in] | deviceNode | The media device node path |
Once constructed the media device is invalid, and must be populated with populate() before the media graph can be queried.
bool libcamera::MediaDevice::acquire | ( | ) |
Claim a device for exclusive use.
The device claiming mechanism offers simple media device access arbitration between multiple users. When the media device is created, it is available to all users. Users can query the media graph to determine whether they can support the device and, if they do, claim the device for exclusive use. Other users are then expected to skip over media devices in use as reported by the busy() function.
Once claimed the device shall be released by its user when not needed anymore by calling the release() function. Acquiring the media device opens a file descriptor to the device which is kept open until release() is called.
Exclusive access is only guaranteed if all users of the media device abide by the device claiming mechanism, as it isn't enforced by the media device itself.
|
inline |
|
inline |
Retrieve the media device node path.
int libcamera::MediaDevice::disableLinks | ( | ) |
Disable all links in the media device.
Disable all the media device links, clearing the MEDIA_LNK_FL_ENABLED flag on links which are not flagged as IMMUTABLE.
|
inline |
Retrieve the media device driver name.
|
inline |
Retrieve the list of entities in the media graph.
MediaEntity * libcamera::MediaDevice::getEntityByName | ( | const std::string & | name | ) | const |
Return the MediaEntity with name name.
[in] | name | The entity name |
|
inline |
Retrieve the media device hardware revision.
The hardware revision is in a driver-specific format.
|
inline |
Query whether the media graph has been populated and is valid.
MediaLink * libcamera::MediaDevice::link | ( | const std::string & | sourceName, |
unsigned int | sourceIdx, | ||
const std::string & | sinkName, | ||
unsigned int | sinkIdx | ||
) |
Retrieve the MediaLink connecting two pads, identified by entity names and pad indexes.
[in] | sourceName | The source entity name |
[in] | sourceIdx | The index of the source pad |
[in] | sinkName | The sink entity name |
[in] | sinkIdx | The index of the sink pad |
Find the link that connects the pads at index sourceIdx of the source entity with name sourceName, to the pad at index sinkIdx of the sink entity with name sinkName, if any.
MediaLink * libcamera::MediaDevice::link | ( | const MediaEntity * | source, |
unsigned int | sourceIdx, | ||
const MediaEntity * | sink, | ||
unsigned int | sinkIdx | ||
) |
Retrieve the MediaLink connecting two pads, identified by the entities they belong to and pad indexes.
[in] | source | The source entity |
[in] | sourceIdx | The index of the source pad |
[in] | sink | The sink entity |
[in] | sinkIdx | The index of the sink pad |
Find the link that connects the pads at index sourceIdx of the source entity source, to the pad at index sinkIdx of the sink entity sink, if any.
Retrieve the MediaLink that connects two pads.
[in] | source | The source pad |
[in] | sink | The sink pad |
bool libcamera::MediaDevice::lock | ( | ) |
Lock the device to prevent it from being used by other instances of libcamera.
Multiple instances of libcamera might be running on the same system, at the same time. To allow the different instances to coexist, system resources in the form of media devices must be accessible for enumerating the cameras they provide at all times, while still allowing an instance to lock a resource while it prepares to actively use a camera from the resource.
This function shall not be called from a pipeline handler implementation directly, as the base PipelineHandler implementation handles this on the behalf of the specified implementation.
|
overrideprotectedvirtual |
Retrieve a string to be prefixed to the log message.
This function allows classes inheriting from the Loggable class to extend the logger with an object-specific prefix output right before the log message contents.
Implements libcamera::Loggable.
|
inline |
Retrieve the media device model name.
int libcamera::MediaDevice::populate | ( | ) |
Populate the MediaDevice with device information and media objects.
This function retrieves the media device information and enumerates all media objects in the media device graph and creates their MediaObject representations. All entities, pads and links are stored as MediaEntity, MediaPad and MediaLink respectively, with cross-references between objects. Interfaces are not processed.
Entities are stored in a separate list in the MediaDevice to ease lookup, while pads are accessible from the entity they belong to and links from the pads they connect.
void libcamera::MediaDevice::release | ( | ) |
void libcamera::MediaDevice::unlock | ( | ) |
Unlock the device and free it for use for libcamera instances.
This function shall not be called from a pipeline handler implementation directly, as the base PipelineHandler implementation handles this on the behalf of the specified implementation.
|
inline |
Retrieve the media device API version.
The version is formatted with the KERNEL_VERSION() macro.
libcamera::MediaDevice::disconnected |
Signal emitted when the media device is disconnected from the system.
This signal is emitted when the device enumerator detects that the media device has been removed from the system. For hot-pluggable devices this is usually caused by physical device disconnection, but can also result from driver unloading for most devices. The media device is passed as a parameter.