@@ -87,8 +87,11 @@ int PostProcessorJpeg::process(const FrameBuffer *source,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata)
{
- if (!encoder_)
+ if (!encoder_) {
+ processComplete.emit(PostProcessor::Status::Failed,
+ resultMetadata);
return 0;
+ }
ASSERT(destination->numPlanes() == 1);
@@ -181,6 +184,8 @@ int PostProcessorJpeg::process(const FrameBuffer *source,
exif.data(), quality);
if (jpeg_size < 0) {
LOG(JPEG, Error) << "Failed to encode stream image";
+ processComplete.emit(PostProcessor::Status::Failed,
+ resultMetadata);
return jpeg_size;
}
@@ -195,5 +200,7 @@ int PostProcessorJpeg::process(const FrameBuffer *source,
/* Update the JPEG result Metadata. */
resultMetadata->addEntry(ANDROID_JPEG_SIZE, jpeg_size);
+ processComplete.emit(PostProcessor::Status::Success, resultMetadata);
+
return 0;
}
@@ -8,6 +8,7 @@
#define __ANDROID_POST_PROCESSOR_H__
#include <libcamera/base/object.h>
+#include <libcamera/base/signal.h>
#include <libcamera/framebuffer.h>
#include <libcamera/stream.h>
@@ -27,6 +28,12 @@ public:
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata) = 0;
+
+ enum Status {
+ Success,
+ Failed,
+ };
+ libcamera::Signal<Status, CameraMetadata *> processComplete;
};
#endif /* __ANDROID_POST_PROCESSOR_H__ */
@@ -60,6 +60,7 @@ int PostProcessorYuv::process(const FrameBuffer *source,
const MappedFrameBuffer sourceMapped(source, MappedFrameBuffer::MapFlag::Read);
if (!sourceMapped.isValid()) {
LOG(YUV, Error) << "Failed to mmap camera frame buffer";
+ processComplete.emit(PostProcessor::Status::Failed, metadata);
return -EINVAL;
}
@@ -77,9 +78,12 @@ int PostProcessorYuv::process(const FrameBuffer *source,
libyuv::FilterMode::kFilterBilinear);
if (ret) {
LOG(YUV, Error) << "Failed NV12 scaling: " << ret;
+ processComplete.emit(PostProcessor::Status::Failed, metadata);
return -EINVAL;
}
+ processComplete.emit(PostProcessor::Status::Success, metadata);
+
return 0;
}
When a post-processor is running asynchronously, we should be able to know whether the post-processing operation on the stream has been completed or not. Secondly, we should be able to know if it completed successfully or encountered some errors. This commit introduces a Signal<> which when connected, will notify that the post-processing has been completed. The status of PostProcessor::process() will be passed as a PostProcessor::Status argument. The populated CameraMetadata shall also be available in the signal-handler. /* * DNI: I do not like the multiple places of signal emission. * We need to use goto but first we need to make a single point * of return somehow, and restructure the error paths a bit. */ Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- src/android/jpeg/post_processor_jpeg.cpp | 9 ++++++++- src/android/post_processor.h | 7 +++++++ src/android/yuv/post_processor_yuv.cpp | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-)