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 --- include/libcamera/camera.h | 3 ++- include/libcamera/request.h | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 6d693d9a..21fac550 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -93,7 +94,7 @@ public: int allocateBuffers(); int freeBuffers(); - Request *createRequest(); + Request *createRequest(uint64_t cookie = 0); int queueRequest(Request *request); int start(); diff --git a/include/libcamera/request.h b/include/libcamera/request.h index a93468d7..4fdb3b51 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -8,6 +8,7 @@ #define __LIBCAMERA_REQUEST_H__ #include +#include #include #include @@ -29,7 +30,7 @@ public: RequestCancelled, }; - explicit Request(Camera *camera); + Request(Camera *camera, uint64_t cookie = 0); Request(const Request &) = delete; Request &operator=(const Request &) = delete; @@ -38,6 +39,7 @@ public: int setBuffers(const std::map &streamMap); Buffer *findBuffer(Stream *stream) const; + uint64_t cookie() const { return cookie_; } Status status() const { return status_; } bool hasPendingBuffers() const { return !pending_.empty(); } @@ -56,6 +58,7 @@ private: std::map bufferMap_; std::unordered_set pending_; + const uint64_t cookie_; Status status_; }; -- cgit v1.2.1