libcamera
v0.3.2+188-9fc86dc0
Supporting cameras in Linux since 2019
|
A frame capture request. More...
Inherits Extensible.
Public Types | |
enum | Status { RequestPending, RequestComplete, RequestCancelled } |
enum | ReuseFlag { Default = 0, ReuseBuffers = (1 << 0) } |
using | BufferMap = std::map< const Stream *, FrameBuffer * > |
A map of Stream to FrameBuffer pointers. | |
Public Member Functions | |
Request (Camera *camera, uint64_t cookie=0) | |
Create a capture request for a camera. More... | |
void | reuse (ReuseFlag flags=Default) |
Reset the request for reuse. More... | |
ControlList & | controls () |
Retrieve the request's ControlList. More... | |
ControlList & | metadata () |
Retrieve the request's metadata. More... | |
const BufferMap & | buffers () const |
Retrieve the request's streams to buffers map. More... | |
int | addBuffer (const Stream *stream, FrameBuffer *buffer, std::unique_ptr< Fence > fence=nullptr) |
Add a FrameBuffer with its associated Stream to the Request. More... | |
FrameBuffer * | findBuffer (const Stream *stream) const |
Return the buffer associated with a stream. More... | |
uint32_t | sequence () const |
Retrieve the sequence number for the request. More... | |
uint64_t | cookie () const |
Retrieve the cookie set when the request was created. More... | |
Status | status () const |
Retrieve the request completion status. More... | |
bool | hasPendingBuffers () const |
Check if a request has buffers yet to be completed. More... | |
std::string | toString () const |
Generate a string representation of the Request internals. More... | |
A frame capture request.
A Request allows an application to associate buffers and controls on a per-frame basis to be queued to the camera device for processing.
Flags to control the behavior of Request::reuse()
Enumerator | |
---|---|
Default | Don't reuse buffers |
ReuseBuffers | Reuse the buffers that were previously added by addBuffer() |
Request completion status
Enumerator | |
---|---|
RequestPending | The request hasn't completed yet |
RequestComplete | The request has completed |
RequestCancelled | The request has been cancelled due to capture stop |
libcamera::Request::Request | ( | Camera * | camera, |
uint64_t | cookie = 0 |
||
) |
Create a capture request for a camera.
[in] | camera | The camera that creates the request |
[in] | cookie | Opaque cookie for application use |
The cookie is stored in the request and is accessible through the cookie() function at any time. It is typically used by applications to map the request to an external resource in the request completion handler, and is completely opaque to libcamera.
int libcamera::Request::addBuffer | ( | const Stream * | stream, |
FrameBuffer * | buffer, | ||
std::unique_ptr< Fence > | fence = nullptr |
||
) |
Add a FrameBuffer with its associated Stream to the Request.
[in] | stream | The stream the buffer belongs to |
[in] | buffer | The FrameBuffer to add to the request |
[in] | fence | The optional fence |
A reference to the buffer is stored in the request. The caller is responsible for ensuring that the buffer will remain valid until the request complete callback is called.
A request can only contain one buffer per stream. If a buffer has already been added to the request for the same stream, this function returns -EEXIST.
A Fence can be optionally associated with the buffer.
When a valid Fence is provided to this function, fence is moved to buffer and this Request will only be queued to the device once the fences of all its buffers have been correctly signalled.
If the fence associated with buffer isn't signalled, the request will fail after a timeout. The buffer will still contain the fence, which applications must retrieve with FrameBuffer::releaseFence() before the buffer can be reused in another request. Attempting to add a buffer that still contains a fence to a request will result in this function returning -EEXIST.
-EEXIST | The request already contains a buffer for the stream or the buffer still references a fence |
-EINVAL | The buffer does not reference a valid Stream |
|
inline |
Retrieve the request's streams to buffers map.
Return a reference to the map that associates each Stream part of the request to the FrameBuffer the Stream output should be directed to.
|
inline |
Retrieve the request's ControlList.
Requests store a list of controls to be applied to all frames captured for the request. They are created with an empty list of controls that can be accessed through this function. Control values can be retrieved using ControlList::get() and updated using ControlList::set().
Only controls supported by the camera to which this request will be submitted shall be included in the controls list. Attempting to add an unsupported control causes undefined behaviour.
|
inline |
Retrieve the cookie set when the request was created.
FrameBuffer * libcamera::Request::findBuffer | ( | const Stream * | stream | ) | const |
Return the buffer associated with a stream.
[in] | stream | The stream the buffer is associated to |
bool libcamera::Request::hasPendingBuffers | ( | ) | const |
Check if a request has buffers yet to be completed.
|
inline |
Retrieve the request's metadata.
Reset the request for reuse.
[in] | flags | Indicate whether or not to reuse the buffers |
Reset the status and controls associated with the request, to allow it to be reused and requeued without destruction. This function shall be called prior to queueing the request to the camera, in lieu of constructing a new request. The application can reuse the buffers that were previously added to the request via addBuffer() by setting flags to ReuseBuffers.
uint32_t libcamera::Request::sequence | ( | ) | const |
Retrieve the sequence number for the request.
When requests are queued, they are given a sequential number to track the order in which requests are queued to a camera. This number counts all requests given to a camera and is reset to zero between camera stop/start sequences.
It can be used to support debugging and identifying the flow of requests through a pipeline, but does not guarantee to represent the sequence number of any images in the stream. The sequence number is stored as an unsigned integer and will wrap when overflowed.
|
inline |
Retrieve the request completion status.
The request status indicates whether the request has completed successfully or with an error. When requests are created and before they complete the request status is set to RequestPending, and is updated at completion time to RequestComplete. If a request is cancelled at capture stop before it has completed, its status is set to RequestCancelled.
std::string libcamera::Request::toString | ( | ) | const |