libcamera  v0.4.0+139-39419ce4
Supporting cameras in Linux since 2019
Public Member Functions | List of all members
libcamera::DebugMetadata Class Reference

Helper to record metadata for later use. More...

Public Member Functions

void enableByControl (const ControlList &controls)
 Enable based on controls::DebugMetadataEnable in the supplied ControlList. More...
 
void enable (bool enable=true)
 Enable or disable metadata handling. More...
 
void setParent (DebugMetadata *parent)
 Set the parent metadata handler to parent. More...
 
void moveEntries (ControlList &list)
 Move all cached entries into control list list. More...
 
template<typename T , typename V >
void set (const Control< T > &ctrl, const V &value)
 Set the value of ctrl to value. More...
 
void set (unsigned int id, const ControlValue &value)
 Set the value of control id to value. More...
 

Detailed Description

Helper to record metadata for later use.

Metadata is a useful tool for debugging the internal state of libcamera. It has the benefit that it is easy to use and related tooling is readily available. The difficulty is that the metadata control list is often not directly available (either because the variable to debug lives inside process() of an IPA or inside a closed algorithm class with no direct access to the IPA and therefore the metadata list).

This class helps in both cases. It allows to forward the data to a parent or alternatively record the data and at a later point in time copy it to the metadata list when it becomes available. Both mechanisms allow easy reuse and loose coupling.

Typical usage is to instantiate a DebugMetadata object in every class/algorithm where debug metadata shall be recorded (the inner object). If the IPA doesn't support debug metadata, the object is still usable, but the debug data gets dropped. If the IPA supports debug metadata it will either register a parent DebugMetadata object on the inner object or manually retrieve the data using enable()/moveToList().

The concepts of forwarding to a parent and recording for later retrieval are mutually exclusive and the parent takes precedence. E.g. it is not allowed to enable a DebugMetadata object, log entries to it and later set the parent.

This is done to keep the path open for using other means of data transport (like tracing). For every tracing event a corresponding context needs to be available on set() time. The parent can be treated as such, the top level object (the one where enable() get's called) also lives in a place where that information is also available.

Member Function Documentation

◆ enable()

void libcamera::DebugMetadata::enable ( bool  enable = true)

Enable or disable metadata handling.

Parameters
[in]enableThe enable state

When enable is true, all calls to set() get cached and can later be retrieved using moveEntries(). When enable is false, the cache gets cleared and no further metadata is recorded.

Forwarding to a parent is independent of the enabled state.

◆ enableByControl()

void libcamera::DebugMetadata::enableByControl ( const ControlList controls)

Enable based on controls::DebugMetadataEnable in the supplied ControlList.

Parameters
[in]controlsThe supplied ControlList

This function looks for controls::DebugMetadataEnable and enables or disables debug metadata handling accordingly.

◆ moveEntries()

void libcamera::DebugMetadata::moveEntries ( ControlList list)

Move all cached entries into control list list.

Parameters
[in]listThe control list

This function moves all entries into the list specified by list. Duplicate entries in list get overwritten.

◆ set() [1/2]

template<typename T , typename V >
libcamera::DebugMetadata::set ( const Control< T > &  ctrl,
const V &  value 
)
inline

Set the value of ctrl to value.

Parameters
[in]ctrlThe control to set
[in]valueThe control value

If a parent is set, the value gets passed there unconditionally. Otherwise it gets cached if the instance is enabled or dropped silently when disabled.

See also
enable()

◆ set() [2/2]

void libcamera::DebugMetadata::set ( unsigned int  id,
const ControlValue value 
)

Set the value of control id to value.

Parameters
[in]idThe id of the control
[in]valueThe control value

If a parent is set, the value gets passed there unconditionally. Otherwise it gets cached if the instance is enabled or dropped silently when disabled.

See also
enable()

◆ setParent()

void libcamera::DebugMetadata::setParent ( DebugMetadata parent)

Set the parent metadata handler to parent.

Parameters
[in]parentThe parent handler

When a parent is set, all further calls to set() are unconditionally forwarded to that instance.

The parent can be reset by passing a nullptr.


The documentation for this class was generated from the following files: