From 33d3c4e2046044ec595ac2cb7ee7db4011e83fb7 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 12 Jul 2019 09:37:51 +0300 Subject: libcamera: request: Add cookie to make request tracking easier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applications often have to map requests queued to a camera to external resources. To make this easy, add a 64-bit integer cookie to the Request class that is set when the request is created and can be retrieved at any time, especially in the request completion handler. The cookie is completely transparent for libcamera and is never modified. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/request.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/libcamera/request.cpp') diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index f0b59858..8cf41a43 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -46,9 +46,17 @@ LOG_DEFINE_CATEGORY(Request) /** * \brief Create a capture request for a camera * \param[in] camera The camera that creates the request + * \param[in] cookie Opaque cookie for application use + * + * The \a 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. + * */ -Request::Request(Camera *camera) - : camera_(camera), controls_(camera), status_(RequestPending) +Request::Request(Camera *camera, uint64_t cookie) + : camera_(camera), controls_(camera), cookie_(cookie), + status_(RequestPending) { } @@ -119,6 +127,12 @@ Buffer *Request::findBuffer(Stream *stream) const return it->second; } +/** + * \fn Request::cookie() + * \brief Retrieve the cookie set when the request was created + * \return The request cookie + */ + /** * \fn Request::status() * \brief Retrieve the request completion status -- cgit v1.2.1