[libcamera-devel] [PATCH 4/5] android: camera_device: Construct VideoRecording request template
Jacopo Mondi
jacopo at jmondi.org
Sat Jul 25 18:42:42 CEST 2020
Construct the template for the VIDEO_RECORDING request template.
The constructed control pack is quite similar to the one used for
preview, with the exception that the desired FPS rage is a single value.
This fixes the CTS 9.0.r12 test:
android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceRecordingTemplate
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 86 ++++++++++++++++++++++++++++++++++-
src/android/camera_device.h | 1 +
2 files changed, 86 insertions(+), 1 deletion(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ca746b685c26..bd501a9b1660 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -918,6 +918,90 @@ CameraMetadata *CameraDevice::requestTemplatePreview()
return requestTemplate;
}
+CameraMetadata *CameraDevice::requestTemplateVideoRecord()
+{
+ /*
+ * \todo Keep this in sync with the actual number of entries.
+ * Currently: 20 entries, 35 bytes
+ */
+ CameraMetadata *requestTemplate = new CameraMetadata(20, 35);
+ if (!requestTemplate->isValid()) {
+ delete requestTemplate;
+ return nullptr;
+ }
+
+ uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_MODE,
+ &aeMode, 1);
+
+ int32_t aeExposureCompensation = 0;
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
+ &aeExposureCompensation, 1);
+
+ uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
+ &aePrecaptureTrigger, 1);
+
+ uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK,
+ &aeLock, 1);
+
+ std::vector<int32_t> aeFpsTarget = {
+ 30, 30,
+ };
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+ aeFpsTarget.data(),
+ aeFpsTarget.size());
+
+ uint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
+ requestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE,
+ &aeAntibandingMode, 1);
+
+ uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;
+ requestTemplate->addEntry(ANDROID_CONTROL_AF_TRIGGER,
+ &afTrigger, 1);
+
+ uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO;
+ requestTemplate->addEntry(ANDROID_CONTROL_AWB_MODE,
+ &awbMode, 1);
+
+ uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;
+ requestTemplate->addEntry(ANDROID_CONTROL_AWB_LOCK,
+ &awbLock, 1);
+
+ uint8_t flashMode = ANDROID_FLASH_MODE_OFF;
+ requestTemplate->addEntry(ANDROID_FLASH_MODE,
+ &flashMode, 1);
+
+ uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
+ requestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE,
+ &faceDetectMode, 1);
+
+ uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;
+ requestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE,
+ &noiseReduction, 1);
+
+ uint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;
+ requestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
+ &aberrationMode, 1);
+
+ uint8_t controlMode = ANDROID_CONTROL_MODE_AUTO;
+ requestTemplate->addEntry(ANDROID_CONTROL_MODE, &controlMode, 1);
+
+ float lensAperture = 2.53 / 100;
+ requestTemplate->addEntry(ANDROID_LENS_APERTURE, &lensAperture, 1);
+
+ uint8_t opticalStabilization = ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
+ requestTemplate->addEntry(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
+ &opticalStabilization, 1);
+
+ uint8_t captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
+ requestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT,
+ &captureIntent, 1);
+
+ return requestTemplate;
+}
+
CameraMetadata *CameraDevice::requestTemplateManual()
{
/*
@@ -1024,7 +1108,7 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
break;
case CAMERA3_TEMPLATE_VIDEO_RECORD:
- requestTemplate = requestTemplatePreview();
+ requestTemplate = requestTemplateVideoRecord();
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
break;
case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index db7b3c558993..87ee36e96805 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -84,6 +84,7 @@ private:
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
CameraMetadata *requestTemplatePreview();
+ CameraMetadata *requestTemplateVideoRecord();
CameraMetadata *requestTemplateManual();
libcamera::PixelFormat toPixelFormat(int format);
std::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,
--
2.27.0
More information about the libcamera-devel
mailing list