libcamera
v0.0.0+925-96eaad12
Supporting cameras in Linux since 2019
|
A buffer handle and dynamic metadata. More...
Public Types | |
enum | Status { BufferSuccess, BufferError, BufferCancelled } |
Public Member Functions | |
Buffer (unsigned int index=-1, const Buffer *metadata=nullptr) | |
Construct a buffer not associated with any stream. More... | |
Buffer (const Buffer &)=delete | |
Buffer & | operator= (const Buffer &)=delete |
unsigned int | index () const |
Retrieve the Buffer index. More... | |
const std::array< int, 3 > & | dmabufs () const |
Retrieve the dmabuf file descriptors for all buffer planes. More... | |
BufferMemory * | mem () |
Retrieve the BufferMemory this buffer is associated with. More... | |
unsigned int | bytesused () const |
Retrieve the number of bytes occupied by the data in the buffer. More... | |
uint64_t | timestamp () const |
Retrieve the time when the buffer was processed. More... | |
unsigned int | sequence () const |
Retrieve the buffer sequence number. More... | |
Status | status () const |
Retrieve the buffer status. More... | |
Request * | request () const |
Retrieve the request this buffer belongs to. More... | |
Stream * | stream () const |
Retrieve the stream this buffer is associated with. More... | |
Friends | |
class | Camera |
class | Request |
class | Stream |
class | V4L2VideoDevice |
A buffer handle and dynamic metadata.
The Buffer class references a buffer memory and associates dynamic metadata related to the frame contained in the buffer. It allows referencing buffer memory through a single interface regardless of whether the memory is allocated internally in libcamera or provided externally through dmabuf.
Buffer instances are allocated dynamically for a stream through Stream::createBuffer(), added to a request with Request::addBuffer() and deleted automatically after the request complete handler returns.
Buffer completion status
Enumerator | |
---|---|
BufferSuccess | The buffer has completed with success and contains valid data. All its other metadata (such as bytesused(), timestamp() or sequence() number) are valid. |
BufferError | The buffer has completed with an error and doesn't contain valid data. Its other metadata are valid. |
BufferCancelled | The buffer has been cancelled due to capture stop. Its other metadata are invalid and shall not be used. |
libcamera::Buffer::Buffer | ( | unsigned int | index = -1 , |
const Buffer * | metadata = nullptr |
||
) |
Construct a buffer not associated with any stream.
This method constructs an orphaned buffer not associated with any stream. It is not meant to be called by applications, they should instead create buffers for a stream with Stream::createBuffer().
|
inline |
Retrieve the number of bytes occupied by the data in the buffer.
|
inline |
Retrieve the dmabuf file descriptors for all buffer planes.
The dmabufs array contains one dmabuf file descriptor per plane. Unused entries are set to -1.
|
inline |
Retrieve the Buffer index.
|
inline |
Retrieve the BufferMemory this buffer is associated with.
The association between the buffer and a BufferMemory instance is valid from the time the request containing this buffer is queued to a camera to the end of that request's completion handler.
|
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::prepare() and the association is valid until the buffer completes. The returned request pointer is valid only during that interval.
|
inline |
Retrieve the buffer sequence number.
The sequence number is a monotonically increasing number assigned to the buffer processed by the stream. Gaps in the sequence numbers indicate dropped frames.
|
inline |
Retrieve the buffer status.
The buffer status reports whether the buffer has completed successfully (BufferSuccess) or if an error occurred (BufferError).
|
inline |
Retrieve the stream this buffer is associated with.
A Buffer is associated to the stream that created it with Stream::createBuffer() and the association is valid until the buffer is destroyed. Buffer instances that are created directly are not associated with any stream.
|
inline |
Retrieve the time when the buffer was processed.
The timestamp is expressed as a number of nanoseconds since the epoch.