libcamera: libcamera::FrameBuffer Class Reference

libcamera v0.0.5 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
libcamera::FrameBuffer Class Reference

Frame buffer data and its associated dynamic metadata. More...

Inheritance diagram for libcamera::FrameBuffer:
[legend]
Collaboration diagram for libcamera::FrameBuffer:
[legend]

## Classes
struct | Plane
| A memory region to store a single plane of a frame. More...
class | Private
| Base class for FrameBuffer private data. More...

## Public Member Functions
| FrameBuffer (const std::vector< Plane > &planes, unsigned int cookie=0)
| Construct a FrameBuffer with an array of planes.
| FrameBuffer (std::unique_ptr< Private > d)
| Construct a FrameBuffer with an extensible private class.
const std::vector< Plane > & | planes () const
| Retrieve the static plane descriptors.
Request * | request () const
| Retrieve the request this buffer belongs to.
const FrameMetadata & | metadata () const
| Retrieve the dynamic metadata.
uint64_t | cookie () const
| Retrieve the cookie.
void | setCookie (uint64_t cookie)
| Set the cookie.
std::unique_ptr< Fence > | releaseFence ()
| Extract the Fence associated with this Framebuffer.
Public Member Functions inherited from libcamera::Extensible
| Extensible (std::unique_ptr< Private > d)
| Construct an instance of an Extensible class.

## Additional Inherited Members
Protected Member Functions inherited from libcamera::Extensible
template<typename T >
const T * | _d () const
| Retrieve the private data instance.
template<typename T >
T * | _d ()

## Detailed Description

Frame buffer data and its associated dynamic metadata.

The FrameBuffer class is the primary interface for applications, IPAs and pipeline handlers to interact with frame memory. It contains all the static and dynamic information to manage the whole life cycle of a frame capture, from buffer creation to consumption.

The static information describes the memory planes that make a frame. The planes are specified when creating the FrameBuffer and are expressed as a set of dmabuf file descriptors, offset and length.

The dynamic information is grouped in a FrameMetadata instance. It is updated during the processing of a queued capture request, and is valid from the completion of the buffer as signaled by Camera::bufferComplete() until the FrameBuffer is either reused in a new request or deleted.

The creator of a FrameBuffer (application, IPA or pipeline handler) may associate to it an integer cookie for any private purpose. The cookie may be set when creating the FrameBuffer, and updated at any time with setCookie(). The cookie is transparent to the libcamera core and shall only be set by the creator of the FrameBuffer. This mechanism supplements the Request cookie.

## Constructor & Destructor Documentation

## ◆ FrameBuffer() [1/2]

libcamera::FrameBuffer::FrameBuffer | ( | const std::vector< Plane > & | planes,
|  | unsigned int | cookie = `0`
| ) |  |

Construct a FrameBuffer with an array of planes.

Parameters

  [in] | planes | The frame memory planes
  [in] | cookie | Cookie

## ◆ FrameBuffer() [2/2]

libcamera::FrameBuffer::FrameBuffer | ( | std::unique_ptr< Private > | d | ) |

Construct a FrameBuffer with an extensible private class.

Parameters

  [in] | d | The extensible private class

## Member Function Documentation

## ◆ cookie()

uint64_t libcamera::FrameBuffer::cookie | ( |  | ) | const

Retrieve the cookie.

The cookie belongs to the creator of the FrameBuffer, which controls its lifetime and value.

See also
  setCookie()

Returns
  The cookie

## ◆ metadata()

const FrameMetadata & libcamera::FrameBuffer::metadata | ( |  | ) | const

Retrieve the dynamic metadata.

Returns
  Dynamic metadata for the frame contained in the buffer

## ◆ planes()

const std::vector< FrameBuffer::Plane > & libcamera::FrameBuffer::planes | ( |  | ) | const

Retrieve the static plane descriptors.

Returns
  Array of plane descriptors

## ◆ releaseFence()

std::unique_ptr< Fence > libcamera::FrameBuffer::releaseFence | ( |  | ) |

Extract the Fence associated with this Framebuffer.

This function moves the buffer's fence ownership to the caller. After the fence has been released, calling this function always return nullptr.

If buffer with a Fence completes with errors due to a failure in handling the fence, applications are responsible for releasing the Fence before calling Request::addBuffer() again.

Returns
  A unique pointer to the Fence if set, or nullptr if the fence has been released already

## ◆ request()

Request * libcamera::FrameBuffer::request | ( |  | ) | const

Retrieve the request this buffer belongs to.

The intended callers of this function are buffer completion handlers that need to associate a buffer to the request it belongs to.

A FrameBuffer is associated to a request by Request::addBuffer() and the association is valid until the buffer completes. The returned request pointer is valid only during that interval.

Returns
  The Request the FrameBuffer belongs to, or nullptr if the buffer is not associated with a request

## ◆ setCookie()

void libcamera::FrameBuffer::setCookie | ( | uint64_t | cookie | ) |

Set the cookie.

Parameters

  [in] | cookie | Cookie to set

The cookie belongs to the creator of the FrameBuffer. Its value may be modified at any time with this function. Applications and IPAs shall not modify the cookie value of buffers they haven't created themselves. The libcamera core never modifies the buffer cookie.

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

- include/libcamera/framebuffer.h
- src/libcamera/framebuffer.cpp