summaryrefslogtreecommitdiff
path: root/src/libcamera/request.cpp
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-10 20:23:29 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-29 12:18:02 +0100
commit1dfb8d45dc04222d3d2f2bb3a8622a7e59d68228 (patch)
treef781687f66e5a2c4b098a99d855fd686c81fb638 /src/libcamera/request.cpp
parentd874b3e34173811fa89b68b4b71f22182bc5fd98 (diff)
libcamera: request: Add a toString()
Provide a toString helper to assist in printing Request state for debug and logging contexts. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/request.cpp')
-rw-r--r--src/libcamera/request.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 5280b68c..ce2dd7b1 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -8,6 +8,7 @@
#include <libcamera/request.h>
#include <map>
+#include <sstream>
#include <libcamera/buffer.h>
#include <libcamera/camera.h>
@@ -286,9 +287,7 @@ void Request::complete()
status_ = cancelled_ ? RequestCancelled : RequestComplete;
- LOG(Request, Debug)
- << "Request has completed - cookie: " << cookie_
- << (cancelled_ ? " [Cancelled]" : "");
+ LOG(Request, Debug) << toString();
LIBCAMERA_TRACEPOINT(request_complete, this);
}
@@ -321,4 +320,27 @@ bool Request::completeBuffer(FrameBuffer *buffer)
return !hasPendingBuffers();
}
+/**
+ * \brief Generate a string representation of the Request internals
+ *
+ * This function facilitates debugging of Request state while it is used
+ * internally within libcamera.
+ *
+ * \return A string representing the current state of the request
+ */
+std::string Request::toString() const
+{
+ std::stringstream ss;
+
+ /* Pending, Completed, Cancelled(X). */
+ static const char *statuses = "PCX";
+
+ /* Example Output: Request(55:P:1/2:6523524) */
+ ss << "Request(" << sequence_ << ":" << statuses[status_] << ":"
+ << pending_.size() << "/" << bufferMap_.size() << ":"
+ << cookie_ << ")";
+
+ return ss.str();
+}
+
} /* namespace libcamera */