libcamera  v0.0.0
Supporting cameras in Linux since 2019
Classes | Public Member Functions | Friends | List of all members
libcamera::FrameBuffer Class Referencefinal

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

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 (const FrameBuffer &)=delete
 
 FrameBuffer (FrameBuffer &&)=delete
 
FrameBufferoperator= (const FrameBuffer &)=delete
 
FrameBufferoperator= (FrameBuffer &&)=delete
 
const std::vector< Plane > & planes () const
 Retrieve the static plane descriptors. More...
 
Requestrequest () const
 Retrieve the request this buffer belongs to. More...
 
void setRequest (Request *request)
 Set the request this buffer belongs to. More...
 
const FrameMetadatametadata () const
 Retrieve the dynamic metadata. More...
 
unsigned int cookie () const
 Retrieve the cookie. More...
 
void setCookie (unsigned int cookie)
 Set the cookie. More...
 
int copyFrom (const FrameBuffer *src)
 Copy the contents from another buffer. More...
 

Friends

class Request
 
class V4L2VideoDevice
 

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 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()

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

Member Function Documentation

◆ cookie()

libcamera::FrameBuffer::cookie ( ) const
inline

Retrieve the cookie.

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

See also
setCookie()
Returns
The cookie

◆ copyFrom()

int libcamera::FrameBuffer::copyFrom ( const FrameBuffer src)

Copy the contents from another buffer.

Parameters
[in]srcBuffer to copy

Copy the buffer contents and metadata from src to this buffer. The destination FrameBuffer shall have the same number of planes as the source buffer, and each destination plane shall be larger than or equal to the corresponding source plane.

The complete metadata of the source buffer is copied to the destination buffer. If an error occurs during the copy, the destination buffer's metadata status is set to FrameMetadata::FrameError, and other metadata fields are not modified.

The operation is performed using memcpy() so is very slow, users needs to consider this before copying buffers.

Returns
0 on success or a negative error code otherwise

◆ metadata()

libcamera::FrameBuffer::metadata ( ) const
inline

Retrieve the dynamic metadata.

Returns
Dynamic metadata for the frame contained in the buffer

◆ planes()

libcamera::FrameBuffer::planes ( ) const
inline

Retrieve the static plane descriptors.

Returns
Array of plane descriptors

◆ request()

libcamera::FrameBuffer::request ( ) const
inline

Retrieve the request this buffer belongs to.

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

A Buffer 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 Buffer belongs to, or nullptr if the buffer is not associated with a request

◆ setCookie()

libcamera::FrameBuffer::setCookie ( unsigned int  cookie)
inline

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 method. Applications and IPAs shall not modify the cookie value of buffers they haven't created themselves. The libcamera core never modifies the buffer cookie.

◆ setRequest()

libcamera::FrameBuffer::setRequest ( Request request)
inline

Set the request this buffer belongs to.

Parameters
[in]requestRequest to set

The intended callers of this method are pipeline handlers and only for buffers that are internal to the pipeline.

Todo:
Shall be hidden from applications with a d-pointer design.

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