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/camera.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/libcamera/camera.cpp') diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 810cb129..1f307654 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -754,10 +754,16 @@ int Camera::freeBuffers() /** * \brief Create a request object for the camera + * \param[in] cookie Opaque cookie for application use * * This method creates an empty request for the application to fill with * buffers and paramaters, and queue for capture. * + * The \a cookie is stored in the request and is accessible through the + * Request::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. + * * The ownership of the returned request is passed to the caller, which is * responsible for either queueing the request or deleting it. * @@ -766,12 +772,12 @@ int Camera::freeBuffers() * * \return A pointer to the newly created request, or nullptr on error */ -Request *Camera::createRequest() +Request *Camera::createRequest(uint64_t cookie) { if (disconnected_ || !stateBetween(CameraPrepared, CameraRunning)) return nullptr; - return new Request(this); + return new Request(this, cookie); } /** -- cgit v1.2.1