mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-21 15:53:54 +03:00
android: camera_device: Generate template for Video
The capture request template for video recording use cases requires a fixed FPS range. Generate the request templates for the VIDEO_RECORD and VIDEO_SNAPSHOT capture intents using the preview template and updating the supported FPS range. This change fixes the CTS tests android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceRecordingTemplate Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
f179616ec7
commit
eb5a9d822f
2 changed files with 34 additions and 6 deletions
|
@ -1386,11 +1386,7 @@ CameraMetadata *CameraDevice::requestTemplatePreview()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \todo Depending on the requested CaptureIntent, the FPS range
|
* Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata
|
||||||
* needs to be adjusted. For example, the capture template for
|
|
||||||
* video capture intent shall report a fixed value.
|
|
||||||
*
|
|
||||||
* Also assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata
|
|
||||||
* has been assembled as {{min, max} {max, max}}.
|
* has been assembled as {{min, max} {max, max}}.
|
||||||
*/
|
*/
|
||||||
requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
|
requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
|
||||||
|
@ -1464,6 +1460,30 @@ CameraMetadata *CameraDevice::requestTemplatePreview()
|
||||||
return requestTemplate;
|
return requestTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraMetadata *CameraDevice::requestTemplateVideo()
|
||||||
|
{
|
||||||
|
CameraMetadata *previewTemplate = requestTemplatePreview();
|
||||||
|
if (!previewTemplate)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The video template requires a fixed FPS range. Everything else
|
||||||
|
* stays the same as the preview template.
|
||||||
|
*/
|
||||||
|
camera_metadata_ro_entry_t entry;
|
||||||
|
staticMetadata_->getEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
|
||||||
|
&entry);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata
|
||||||
|
* has been assembled as {{min, max} {max, max}}.
|
||||||
|
*/
|
||||||
|
previewTemplate->updateEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
|
||||||
|
entry.data.i32 + 2, 2);
|
||||||
|
|
||||||
|
return previewTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Produce a metadata pack to be used as template for a capture request.
|
* Produce a metadata pack to be used as template for a capture request.
|
||||||
*/
|
*/
|
||||||
|
@ -1479,15 +1499,23 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CAMERA3_TEMPLATE_PREVIEW:
|
case CAMERA3_TEMPLATE_PREVIEW:
|
||||||
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
|
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
|
||||||
|
requestTemplate = requestTemplatePreview();
|
||||||
break;
|
break;
|
||||||
case CAMERA3_TEMPLATE_STILL_CAPTURE:
|
case CAMERA3_TEMPLATE_STILL_CAPTURE:
|
||||||
|
/*
|
||||||
|
* Use the preview template for still capture, they only differ
|
||||||
|
* for the torch mode we currently do not support.
|
||||||
|
*/
|
||||||
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
||||||
|
requestTemplate = requestTemplatePreview();
|
||||||
break;
|
break;
|
||||||
case CAMERA3_TEMPLATE_VIDEO_RECORD:
|
case CAMERA3_TEMPLATE_VIDEO_RECORD:
|
||||||
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
|
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
|
||||||
|
requestTemplate = requestTemplateVideo();
|
||||||
break;
|
break;
|
||||||
case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:
|
case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:
|
||||||
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
|
captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
|
||||||
|
requestTemplate = requestTemplateVideo();
|
||||||
break;
|
break;
|
||||||
/* \todo Implement templates generation for the remaining use cases. */
|
/* \todo Implement templates generation for the remaining use cases. */
|
||||||
case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:
|
case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:
|
||||||
|
@ -1497,7 +1525,6 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestTemplate = requestTemplatePreview();
|
|
||||||
if (!requestTemplate || !requestTemplate->isValid()) {
|
if (!requestTemplate || !requestTemplate->isValid()) {
|
||||||
LOG(HAL, Error) << "Failed to construct request template";
|
LOG(HAL, Error) << "Failed to construct request template";
|
||||||
delete requestTemplate;
|
delete requestTemplate;
|
||||||
|
|
|
@ -99,6 +99,7 @@ private:
|
||||||
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
|
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
|
||||||
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
|
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
|
||||||
CameraMetadata *requestTemplatePreview();
|
CameraMetadata *requestTemplatePreview();
|
||||||
|
CameraMetadata *requestTemplateVideo();
|
||||||
libcamera::PixelFormat toPixelFormat(int format) const;
|
libcamera::PixelFormat toPixelFormat(int format) const;
|
||||||
int processControls(Camera3RequestDescriptor *descriptor);
|
int processControls(Camera3RequestDescriptor *descriptor);
|
||||||
std::unique_ptr<CameraMetadata> getResultMetadata(
|
std::unique_ptr<CameraMetadata> getResultMetadata(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue