[libcamera-devel] [PATCH v2] android: CameraDevice: factorize reporting a capture result

Hirokazu Honda hiroh at chromium.org
Mon Apr 26 12:57:53 CEST 2021


This factorizes a code of reporting a capture result including
notifying either shutter or error. It will be useful to report
capture results in other places than
CameraDevice::reqeustComplete().

Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
 src/android/camera_device.cpp | 22 +++++++++++++++-------
 src/android/camera_device.h   |  4 ++++
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index fb89195e..70174a2b 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -2132,7 +2132,20 @@ void CameraDevice::requestComplete(Request *request)
 			cameraStream->putBuffer(src);
 	}
 
-	/* Prepare to call back the Android camera stack. */
+	reportDescriptor(descriptor, status, timestamp,
+			 resultMetadata ? resultMetadata->get() : nullptr);
+}
+
+std::string CameraDevice::logPrefix() const
+{
+	return "'" + camera_->id() + "'";
+}
+
+void CameraDevice::reportDescriptor(Camera3RequestDescriptor &descriptor,
+				    camera3_buffer_status status,
+				    uint64_t timestamp,
+				    camera_metadata_t *metadata)
+{
 	camera3_capture_result_t captureResult = {};
 	captureResult.frame_number = descriptor.frameNumber_;
 	captureResult.num_output_buffers = descriptor.buffers_.size();
@@ -2147,7 +2160,7 @@ void CameraDevice::requestComplete(Request *request)
 		notifyShutter(descriptor.frameNumber_, timestamp);
 
 		captureResult.partial_result = 1;
-		captureResult.result = resultMetadata->get();
+		captureResult.result = metadata;
 	}
 
 	if (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) {
@@ -2164,11 +2177,6 @@ void CameraDevice::requestComplete(Request *request)
 	callbacks_->process_capture_result(callbacks_, &captureResult);
 }
 
-std::string CameraDevice::logPrefix() const
-{
-	return "'" + camera_->id() + "'";
-}
-
 void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp)
 {
 	camera3_notify_msg_t notify = {};
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index fa652c3c..a42b8dc0 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -101,6 +101,10 @@ private:
 
 	std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
 	libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);
+	void reportDescriptor(Camera3RequestDescriptor &descriptor,
+			      camera3_buffer_status status,
+			      uint64_t timestamp = 0,
+			      camera_metadata_t *metadata = nullptr);
 	void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
 	void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
 	std::unique_ptr<CameraMetadata> requestTemplatePreview();
-- 
2.31.1.498.g6c1eba8ee3d-goog



More information about the libcamera-devel mailing list