libcamera  v0.0.0
Supporting cameras in Linux since 2019
Public Types | Public Member Functions | Friends | List of all members
libcamera::Request Class Reference

A frame capture request. More...

Public Types

enum  Status { RequestPending , RequestComplete , RequestCancelled }
 

Public Member Functions

 Request (Camera *camera, uint64_t cookie=0)
 Create a capture request for a camera. More...
 
 Request (const Request &)=delete
 
Requestoperator= (const Request &)=delete
 
ControlListcontrols ()
 Retrieve the request's ControlList. More...
 
ControlListmetadata ()
 Retrieve the request's metadata. More...
 
const std::map< Stream *, FrameBuffer * > & buffers () const
 Retrieve the request's streams to buffers map. More...
 
int addBuffer (Stream *stream, FrameBuffer *buffer)
 Add a FrameBuffer with its associated Stream to the Request. More...
 
FrameBufferfindBuffer (Stream *stream) const
 Return the buffer associated with a stream. 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...
 

Friends

class PipelineHandler
 

Detailed Description

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.

Member Enumeration Documentation

◆ Status

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

Constructor & Destructor Documentation

◆ Request()

libcamera::Request::Request ( Camera camera,
uint64_t  cookie = 0 
)

Create a capture request for a camera.

Parameters
[in]cameraThe camera that creates the request
[in]cookieOpaque cookie for application use

The cookie is stored in the request and is accessible through the cookie() method 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.

Todo:
Should the Camera expose a validator instance, to avoid creating a new instance for each request?
Todo:
: Add a validator for metadata controls.

Member Function Documentation

◆ addBuffer()

int libcamera::Request::addBuffer ( Stream stream,
FrameBuffer buffer 
)

Add a FrameBuffer with its associated Stream to the Request.

Parameters
[in]streamThe stream the buffer belongs to
[in]bufferThe FrameBuffer to add to the request

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 method returns -EEXIST.

Returns
0 on success or a negative error code otherwise
Return values
-EEXISTThe request already contains a buffer for the stream
-EINVALThe buffer does not reference a valid Stream

◆ buffers()

libcamera::Request::buffers ( ) const
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.

Returns
The map of Stream to FrameBuffer

◆ controls()

libcamera::Request::controls ( )
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 method and updated with ControlList::operator[]() or ControlList::update().

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.

Returns
A reference to the ControlList in this request

◆ cookie()

libcamera::Request::cookie ( ) const
inline

Retrieve the cookie set when the request was created.

Returns
The request cookie

◆ findBuffer()

FrameBuffer * libcamera::Request::findBuffer ( Stream stream) const

Return the buffer associated with a stream.

Parameters
[in]streamThe stream the buffer is associated to
Returns
The buffer associated with the stream, or nullptr if the stream is not part of this request

◆ hasPendingBuffers()

libcamera::Request::hasPendingBuffers ( ) const
inline

Check if a request has buffers yet to be completed.

Returns
True if the request has buffers pending for completion, false otherwise

◆ metadata()

libcamera::Request::metadata ( )
inline

Retrieve the request's metadata.

Todo:
Offer a read-only API towards applications while keeping a read/write API internally.
Returns
The metadata associated with the request

◆ status()

libcamera::Request::status ( ) const
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.

Returns
The request completion status

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