libcamera  v0.2.0+150-2031e2f2
Supporting cameras in Linux since 2019
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
libcamera::MappedBuffer Class Reference

Provide an interface to support managing memory mapped buffers. More...

Inheritance diagram for libcamera::MappedBuffer:
Inheritance graph
[legend]

Public Types

using Plane = Span< uint8_t >
 A mapped region of memory accessible to the CPU. More...
 

Public Member Functions

 MappedBuffer (MappedBuffer &&other)
 Move constructor, construct the MappedBuffer with the contents of other using move semantics. More...
 
MappedBufferoperator= (MappedBuffer &&other)
 Move assignment operator, replace the mappings with those of other. More...
 
bool isValid () const
 Check if the MappedBuffer instance is valid. More...
 
int error () const
 Retrieve the map error status. More...
 
const std::vector< Plane > & planes () const
 Retrieve the mapped planes. More...
 

Protected Member Functions

 MappedBuffer ()
 Construct an empty MappedBuffer.
 

Protected Attributes

int error_
 Stores the error value if present. More...
 
std::vector< Planeplanes_
 Stores the internal mapped planes. More...
 
std::vector< Planemaps_
 Stores the mapped buffer. More...
 

Detailed Description

Provide an interface to support managing memory mapped buffers.

The MappedBuffer interface provides access to a set of MappedPlanes which are available for access by the CPU.

This class is not meant to be constructed directly, but instead derived classes should be used to implement the correct mapping of a source buffer.

This allows treating CPU accessible memory through a generic interface regardless of whether it originates from a libcamera FrameBuffer or other source.

Member Typedef Documentation

◆ Plane

A mapped region of memory accessible to the CPU.

The MappedBuffer::Plane uses the Span interface to describe the mapped memory region.

Constructor & Destructor Documentation

◆ MappedBuffer()

libcamera::MappedBuffer::MappedBuffer ( MappedBuffer &&  other)

Move constructor, construct the MappedBuffer with the contents of other using move semantics.

Parameters
[in]otherThe other MappedBuffer

Moving a MappedBuffer moves the mappings contained in the other to the new MappedBuffer and invalidates the other.

No mappings are unmapped or destroyed in this process.

Member Function Documentation

◆ error()

libcamera::MappedBuffer::error ( ) const
inline

Retrieve the map error status.

This function retrieves the error status from the MappedBuffer. The error status is a negative number as defined by errno.h. If no error occurred, this function returns 0.

Returns
The map error code

◆ isValid()

libcamera::MappedBuffer::isValid ( ) const
inline

Check if the MappedBuffer instance is valid.

Returns
True if the MappedBuffer has valid mappings, false otherwise

◆ operator=()

MappedBuffer & libcamera::MappedBuffer::operator= ( MappedBuffer &&  other)

Move assignment operator, replace the mappings with those of other.

Parameters
[in]otherThe other MappedBuffer

Moving a MappedBuffer moves the mappings contained in the other to the new MappedBuffer and invalidates the other.

No mappings are unmapped or destroyed in this process.

◆ planes()

libcamera::MappedBuffer::planes ( ) const
inline

Retrieve the mapped planes.

This function retrieves the successfully mapped planes stored as a vector of Span<uint8_t> to provide access to the mapped memory.

Returns
A vector of the mapped planes

Member Data Documentation

◆ error_

libcamera::MappedBuffer::error_
protected

Stores the error value if present.

MappedBuffer derived classes shall set this to a negative value as defined by errno.h if an error occured during the mapping process.

◆ maps_

libcamera::MappedBuffer::maps_
protected

Stores the mapped buffer.

MappedBuffer derived classes shall store the mappings they create in this vector which is parsed during destruct to unmap any memory mappings which completed successfully.

◆ planes_

libcamera::MappedBuffer::planes_
protected

Stores the internal mapped planes.

MappedBuffer derived classes shall store the mappings they create in this vector which points the beginning of mapped plane addresses.


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