[libcamera-devel] [PATCH 5/5] android: camera_device: Re-use PREVIEW template for other cases
Jacopo Mondi
jacopo at jmondi.org
Sat Jul 25 18:42:43 CEST 2020
As the VideoRecording and Manual request templates are very similar to
the one used for the Preview use case, re-use it and update the entries
that differ between use-cases.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 149 ++--------------------------------
1 file changed, 9 insertions(+), 140 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index bd501a9b1660..363151755366 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -920,168 +920,37 @@ CameraMetadata *CameraDevice::requestTemplatePreview()
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()) {
+ CameraMetadata *requestTemplate = requestTemplatePreview();
+ if (!requestTemplate || !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);
+ requestTemplate->updateEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+ aeFpsTarget.data(), aeFpsTarget.size());
return requestTemplate;
}
CameraMetadata *CameraDevice::requestTemplateManual()
{
- /*
- * \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()) {
+ CameraMetadata *requestTemplate = requestTemplatePreview();
+ if (!requestTemplate || !requestTemplate->isValid()) {
delete requestTemplate;
return nullptr;
}
uint8_t aeMode = ANDROID_CONTROL_AE_MODE_OFF;
- 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 = {
- 15, 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);
+ requestTemplate->updateEntry(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_OFF;
- 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);
+ requestTemplate->updateEntry(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);
uint8_t controlMode = ANDROID_CONTROL_MODE_OFF;
- 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);
+ requestTemplate->updateEntry(ANDROID_CONTROL_MODE, &controlMode, 1);
return requestTemplate;
}
--
2.27.0
More information about the libcamera-devel
mailing list