[8/8,DNI] apps: cam: Use Camera::metadataAvailable signal
diff mbox series

Message ID 20241206160747.97176-9-jacopo.mondi@ideasonboard.com
State New
Headers show
Series
  • libcamera: Support partial metadata completion
Related show

Commit Message

Jacopo Mondi Dec. 6, 2024, 4:07 p.m. UTC
Handle the Camera::metadataAvailable signal and print the metadata
list.

Use the --metadata option of cam to validate that the metadata list
in Request::metadata() matches the accumulated results.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/apps/cam/camera_session.cpp | 17 +++++++++++++++++
 src/apps/cam/camera_session.h   |  2 ++
 2 files changed, 19 insertions(+)

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 6e9890ccfda1..422874ae74ea 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -246,6 +246,7 @@  int CameraSession::start()
 					   + "-stream" + std::to_string(index);
 	}
 
+	camera_->metadataAvailable.connect(this, &CameraSession::metadataAvailable);
 	camera_->requestCompleted.connect(this, &CameraSession::requestComplete);
 
 #ifdef HAVE_KMS
@@ -407,6 +408,22 @@  int CameraSession::queueRequest(Request *request)
 	return camera_->queueRequest(request);
 }
 
+void CameraSession::metadataAvailable(Request *request,
+				      std::unordered_set<const ControlId *> ids)
+{
+	const ControlList &metadata = request->metadata();
+
+	std::cerr << "EARLY METADATA COMPLETION FOR REQUEST: "
+		  << request->sequence() << std::endl;
+
+	for (const auto id : ids) {
+		const ControlValue &value = metadata.get(id->id());
+
+		std::cout << "\t" << id->name() << " = "
+			  << value.toString() << std::endl;
+	}
+}
+
 void CameraSession::requestComplete(Request *request)
 {
 	if (request->status() == Request::RequestCancelled)
diff --git a/src/apps/cam/camera_session.h b/src/apps/cam/camera_session.h
index 4442fd9b1a6a..0539f759a65a 100644
--- a/src/apps/cam/camera_session.h
+++ b/src/apps/cam/camera_session.h
@@ -53,6 +53,8 @@  private:
 	int startCapture();
 
 	int queueRequest(libcamera::Request *request);
+	void metadataAvailable(libcamera::Request *request,
+			       std::unordered_set<const libcamera::ControlId *> ids);
 	void requestComplete(libcamera::Request *request);
 	void processRequest(libcamera::Request *request);
 	void sinkRelease(libcamera::Request *request);