[libcamera-devel] [PATCH v1 3/6] android: camera_stream: Notify process() status with a Signal
Umang Jain
umang.jain at ideasonboard.com
Tue Sep 7 21:57:01 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 commits), 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. 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 | 10 ++++++++++
src/android/camera_stream.h | 13 ++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index 0fed5382..81af53af 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_) {
@@ -121,6 +123,14 @@ int CameraStream::process(const FrameBuffer *source,
return postProcessor_->process(source, &dest, requestMetadata, resultMetadata);
}
+void CameraStream::handlePostProcessing(PostProcessor::Status status)
+{
+ if (status == PostProcessor::Status::Success)
+ processComplete.emit(ProcessStatus::Success);
+ else
+ processComplete.emit(ProcessStatus::Failed);
+}
+
FrameBuffer *CameraStream::getBuffer()
{
if (!allocator_)
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index 5c232cb6..f9b11e5d 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,15 @@ public:
libcamera::FrameBuffer *getBuffer();
void putBuffer(libcamera::FrameBuffer *buffer);
+ enum ProcessStatus {
+ Failed,
+ Success,
+ };
+ libcamera::Signal<ProcessStatus> processComplete;
+
private:
+ void handlePostProcessing(PostProcessor::Status status);
+
CameraDevice *const cameraDevice_;
const libcamera::CameraConfiguration *config_;
const Type type_;
--
2.31.0
More information about the libcamera-devel
mailing list