[libcamera-devel,SimpleCam,2/2] simple-cam: processRequest: Report Request metadata
diff mbox series

Message ID 20220216123544.637834-3-kieran.bingham@ideasonboard.com
State Accepted
Delegated to: Kieran Bingham
Headers show
Series
  • Extend Request metadata reporting
Related show

Commit Message

Kieran Bingham Feb. 16, 2022, 12:35 p.m. UTC
The completed Request can contain extra data associated with the
completed capture to report IPA state or properties of the capture to
the application.

Process and report any metadata that is associated with the request
when it completes, to demonstrate the extra metadata available to be
processed.

Now that there is substantially more information than one line per
completed request, start each completed Request with a blank line to
separate from previous completions and report the state of the Request
itself with its .toString() helper.

Suggested-by: Nejc Galof <galof.nejc@gmail.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 simple-cam.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Patch
diff mbox series

diff --git a/simple-cam.cpp b/simple-cam.cpp
index e282463c3976..4de1b7de9ced 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -46,6 +46,29 @@  static void requestComplete(Request *request)
 
 static void processRequest(Request *request)
 {
+	std::cout << std::endl
+		  << "Request completed: " << request->toString() << std::endl;
+
+	/*
+	 * When a request has completed, it is populated with a metadata control
+	 * list that allows an application to determine various properties of
+	 * the completed request. This can include the timestamp of the Sensor
+	 * capture, or its gain and exposure values, or properties from the IPA
+	 * such as the state of the 3A algorithms.
+	 *
+	 * ControlValue types have a toString, so to examine each request, print
+	 * all the metadata for inspection. A custom application can parse each
+	 * of these items and process them according to its needs.
+	 */
+	const ControlList &requestMetadata = request->metadata();
+	for (const auto &ctrl : requestMetadata) {
+		const ControlId *id = controls::controls.at(ctrl.first);
+		const ControlValue &value = ctrl.second;
+
+		std::cout << "\t" << id->name() << " = " << value.toString()
+			  << std::endl;
+	}
+
 	/*
 	 * Each buffer has its own FrameMetadata to describe its state, or the
 	 * usage of each buffer. While in our simple capture we only provide one