[libcamera-devel] [RFC PATCH 4/5] android: camera_stream: Notify process() status with a Signal

Umang Jain umang.jain at ideasonboard.com
Thu Aug 26 23:30:15 CEST 2021


CameraStream takes care of any post-processing required via the
CameraStream::process(). Since the post-processor will be moved
to a separate thread (in subsequent commit), the caller of
CameraStream::process() should be able to get notified about the
status, in order to proceed further for completing the callbacks
to android framework.

Therefore, chain up to PostProcessor::processComplete signal in its
signal handler. Currently, we have only one post-processor in-use,
hence emit the corresponding CameraStream::PostProcessing value
according to the  PostProcessor::status received in the signal handler.

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
---
 src/android/camera_stream.cpp | 17 +++++++++++++++++
 src/android/camera_stream.h   | 14 +++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index 59b1df6e..bdcc7cf9 100644
--- a/src/android/camera_stream.cpp
+++ b/src/android/camera_stream.cpp
@@ -81,6 +81,8 @@ int CameraStream::configure()
 		int ret = postProcessor_->configure(configuration(), output);
 		if (ret)
 			return ret;
+
+		postProcessor_->processComplete.connect(this, &CameraStream::handlePostProcessing);
 	}
 
 	if (allocator_) {
@@ -119,6 +121,21 @@ int CameraStream::process(const libcamera::FrameBuffer *source,
 	return postProcessor_->process(source, &dest, requestMetadata, resultMetadata);
 }
 
+void CameraStream::handlePostProcessing(PostProcessor::Status status,
+					CameraMetadata *resultMetadata)
+{
+	switch (status) {
+	case PostProcessor::Status::Success:
+		processComplete.emit(this, ProcessStatus::Success, resultMetadata);
+		break;
+	case PostProcessor::Status::Failed:
+		processComplete.emit(this, ProcessStatus::Failed, resultMetadata);
+		break;
+	default:
+		LOG(HAL, Error) << "PostProcessor status invalid";
+	}
+}
+
 FrameBuffer *CameraStream::getBuffer()
 {
 	if (!allocator_)
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index 5c232cb6..d54d3f58 100644
--- a/src/android/camera_stream.h
+++ b/src/android/camera_stream.h
@@ -13,15 +13,18 @@
 
 #include <hardware/camera3.h>
 
+#include <libcamera/base/signal.h>
+
 #include <libcamera/camera.h>
 #include <libcamera/framebuffer.h>
 #include <libcamera/framebuffer_allocator.h>
 #include <libcamera/geometry.h>
 #include <libcamera/pixel_format.h>
 
+#include "post_processor.h"
+
 class CameraDevice;
 class CameraMetadata;
-class PostProcessor;
 
 class CameraStream
 {
@@ -125,7 +128,16 @@ public:
 	libcamera::FrameBuffer *getBuffer();
 	void putBuffer(libcamera::FrameBuffer *buffer);
 
+	enum ProcessStatus {
+		Failed,
+		Success,
+	};
+	libcamera::Signal<CameraStream *, ProcessStatus, CameraMetadata *> processComplete;
+
 private:
+	void handlePostProcessing(PostProcessor::Status status,
+				  CameraMetadata *resultMetadata);
+
 	CameraDevice *const cameraDevice_;
 	const libcamera::CameraConfiguration *config_;
 	const Type type_;
-- 
2.31.1



More information about the libcamera-devel mailing list