{"id":11519,"url":"https://patchwork.libcamera.org/api/1.1/patches/11519/?format=json","web_url":"https://patchwork.libcamera.org/patch/11519/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210308170728.2212649-4-jacopo@jmondi.org>","date":"2021-03-08T17:07:28","name":"[libcamera-devel,3/3] android: camera_device: Generate template for Video","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"2c0c538b84f4600be8e1a7fee71cabce5bd06467","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11519/mbox/","series":[{"id":1770,"url":"https://patchwork.libcamera.org/api/1.1/series/1770/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1770","date":"2021-03-08T17:07:25","name":"android: Fix capture templates for video recording","version":1,"mbox":"https://patchwork.libcamera.org/series/1770/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11519/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11519/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 68D2EBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Mar 2021 17:07:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3188A68AB2;\n\tMon,  8 Mar 2021 18:07:12 +0100 (CET)","from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C53FB68AAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Mar 2021 18:07:09 +0100 (CET)","from uno.homenet.telecomitalia.it\n\t(host-79-22-58-175.retail.telecomitalia.it [79.22.58.175])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 3071E20000E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Mar 2021 17:07:08 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  8 Mar 2021 18:07:28 +0100","Message-Id":"<20210308170728.2212649-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.30.0","In-Reply-To":"<20210308170728.2212649-1-jacopo@jmondi.org>","References":"<20210308170728.2212649-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 3/3] android: camera_device: Generate\n\ttemplate for Video","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The capture request template for video recording use cases requires\na fixed FPS range. Generate the request templates for the VIDEO_RECORD\nand VIDEO_SNAPSHOT capture intents using the preview template and\nupdating the supported FPS range.\n\nThis change fixes the CTS tests\nandroid.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceRecordingTemplate\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 39 +++++++++++++++++++++++++++++------\n src/android/camera_device.h   |  1 +\n 2 files changed, 34 insertions(+), 6 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 0621ec26feb8..58bebab31cb8 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1396,11 +1396,7 @@ CameraMetadata *CameraDevice::requestTemplatePreview()\n \t}\n \n \t/*\n-\t * \\todo Depending on the requested CaptureIntent, the FPS range\n-\t * needs to be adjusted. For example, the capture template for\n-\t * video capture intent shall report a fixed value.\n-\t *\n-\t * Also assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata\n+\t * Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata\n \t * has been assembled as {{min, max} {max, max}}.\n \t */\n \trequestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,\n@@ -1474,6 +1470,30 @@ CameraMetadata *CameraDevice::requestTemplatePreview()\n \treturn requestTemplate;\n }\n \n+CameraMetadata *CameraDevice::requestTemplateVideo()\n+{\n+\tCameraMetadata *previewTemplate = requestTemplatePreview();\n+\tif (!previewTemplate)\n+\t\treturn nullptr;\n+\n+\t/*\n+\t * The video template requires a fixed FPS range. Everything else\n+\t * stays the same as the preview template.\n+\t */\n+\tcamera_metadata_ro_entry_t entry;\n+\tstaticMetadata_->getEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,\n+\t\t\t\t  &entry);\n+\n+\t/*\n+\t * Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata\n+\t * has been assembled as {{min, max} {max, max}}.\n+\t */\n+\tpreviewTemplate->updateEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,\n+\t\t\t\t     entry.data.i32 + 2, 2);\n+\n+\treturn previewTemplate;\n+}\n+\n /*\n  * Produce a metadata pack to be used as template for a capture request.\n  */\n@@ -1489,14 +1509,22 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n \tswitch (type) {\n \tcase CAMERA3_TEMPLATE_PREVIEW:\n \t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n+\t\trequestTemplate = requestTemplatePreview();\n \t\tbreak;\n \tcase CAMERA3_TEMPLATE_STILL_CAPTURE:\n+\t\t/*\n+\t\t * Use the preview template for still capture, they only differ\n+\t\t * for the torch mode we currently do not support.\n+\t\t */\n \t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;\n+\t\trequestTemplate = requestTemplatePreview();\n \t\tbreak;\n \tcase CAMERA3_TEMPLATE_VIDEO_RECORD:\n+\t\trequestTemplate = requestTemplateVideo();\n \t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;\n \t\tbreak;\n \tcase CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:\n+\t\trequestTemplate = requestTemplateVideo();\n \t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;\n \t\tbreak;\n \t/* \\todo Implement templates generation for the remaining use cases. */\n@@ -1507,7 +1535,6 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n \t\treturn nullptr;\n \t}\n \n-\trequestTemplate = requestTemplatePreview();\n \tif (!requestTemplate || !requestTemplate->isValid()) {\n \t\tLOG(HAL, Error) << \"Failed to construct request template\";\n \t\tdelete requestTemplate;\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex f96934dbf4e7..ebbd7b9b8ab1 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -101,6 +101,7 @@ private:\n \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n \tCameraMetadata *requestTemplatePreview();\n+\tCameraMetadata *requestTemplateVideo();\n \tlibcamera::PixelFormat toPixelFormat(int format) const;\n \tint processControls(Camera3RequestDescriptor *descriptor);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n","prefixes":["libcamera-devel","3/3"]}