libcamera: request: Add cookie to make request tracking easier
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
int allocateBuffers();
|
||||
int freeBuffers();
|
||||
|
||||
Request *createRequest();
|
||||
Request *createRequest(uint64_t cookie = 0);
|
||||
int queueRequest(Request *request);
|
||||
|
||||
int start();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define __LIBCAMERA_REQUEST_H__
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
@@ -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<Stream *, Buffer *> &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<Stream *, Buffer *> bufferMap_;
|
||||
std::unordered_set<Buffer *> pending_;
|
||||
|
||||
const uint64_t cookie_;
|
||||
Status status_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user