libcamera  v0.3.2+250-e3783092
Supporting cameras in Linux since 2019
Classes | Public Member Functions | List of all members
libcamera::FrameBuffer Class Reference

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

Inherits Extensible.

Classes

struct  Plane
 A memory region to store a single plane of a frame. More...
 

Public Member Functions

 FrameBuffer (const std::vector< Plane > &planes, unsigned int cookie=0)
 Construct a FrameBuffer with an array of planes. More...
 
 FrameBuffer (std::unique_ptr< Private > d)
 Construct a FrameBuffer with an extensible private class. More...
 
const std::vector< Plane > & planes () const
 Retrieve the static plane descriptors. More...
 
Requestrequest () const
 Retrieve the request this buffer belongs to. More...
 
const FrameMetadatametadata () const
 Retrieve the dynamic metadata. More...
 
uint64_t cookie () const
 Retrieve the cookie. More...
 
void setCookie (uint64_t cookie)
 Set the cookie. More...
 
std::unique_ptr< FencereleaseFence ()
 Extract the Fence associated with this Framebuffer. More...
 

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]planesThe frame memory planes
[in]cookieCookie

◆ FrameBuffer() [2/2]

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

Construct a FrameBuffer with an extensible private class.

Parameters
[in]dThe 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]cookieCookie 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: