{"id":23496,"url":"https://patchwork.libcamera.org/api/1.1/patches/23496/?format=json","web_url":"https://patchwork.libcamera.org/patch/23496/","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":"<20250606164156.1442682-16-barnabas.pocze@ideasonboard.com>","date":"2025-06-06T16:41:48","name":"[RFC,v1,15/23] libcamera: pipeline_handler: Add metadataAvailable() function","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"826a7844b500f072d367566a163f6ac093f10992","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23496/mbox/","series":[{"id":5210,"url":"https://patchwork.libcamera.org/api/1.1/series/5210/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5210","date":"2025-06-06T16:41:33","name":"libcamera: Add `MetadataList`","version":1,"mbox":"https://patchwork.libcamera.org/series/5210/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23496/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23496/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 4B63AC332C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Jun 2025 16:42:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1C5B68DD7;\n\tFri,  6 Jun 2025 18:42:47 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A08968DC8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Jun 2025 18:42:19 +0200 (CEST)","from pb-laptop.local (185.182.215.79.nat.pool.zt.hu\n\t[185.182.215.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A03FB8DB;\n\tFri,  6 Jun 2025 18:42:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FRmvPFIQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749228134;\n\tbh=KEBykHu4ZK0hxfanIyPCBBbc35h6VOsKusO/SB43KhA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FRmvPFIQWK/ZwqcQdIEFfjZYH3EdO1tO1KnYBnWuD2zOqTP/25ooLhJlbKpYEwfHk\n\td7KliCAlB+yc1Gxuzqw6Rg8Z4Qt+iVI299ZcXkA/g/MpD33dUF3OlMINx3GAgltWlq\n\tbajPE7m4uveEZ3/xGw0qappG/nAR5ExpZIBdetQ4=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[RFC PATCH v1 15/23] libcamera: pipeline_handler: Add\n\tmetadataAvailable() function","Date":"Fri,  6 Jun 2025 18:41:48 +0200","Message-ID":"<20250606164156.1442682-16-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250606164156.1442682-1-barnabas.pocze@ideasonboard.com>","References":"<20250606164156.1442682-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nCurrently the way pipeline handlers have to store metadata results\nfor a Request is to access the Request::metadata_ list directly and\neither merge a ControlList or set a single control value there.\n\nDirect access to Request::metadata_ is however problematic as even if\nmetadata would be available earlier, pipeline handlers can only\naccumulate the results in Request::metadata_ and they're only available\nfor applications at Request complete time.\n\nInstead of letting pipeline handlers access Request::metadata_ directly\nprovide two helper functions, similar in spirit to\nPipelineHandler::completeBuffer() and\nPipelineHandler::completeRequest(), to allow pipeline handlers to\nnotify early availability of metadata.\n\nProvide two overloads, one that accepts a ControlList and merges it into\nRequest::metadata_ and one that allows to set a single metadata result\nthere without going through an intermediate copy.\n\nThe newly provided helpers trigger the Camera::availableMetadata signal\nfrom where applications can retrieve the list of controls that have\njust been made available by the pipeline handler.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n[Fill both metadat lists, use `type_identity`, adjust commit message.]\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nOriginal: https://patchwork.libcamera.org/patch/22229/\n---\n include/libcamera/internal/pipeline_handler.h | 21 +++++++\n src/libcamera/pipeline_handler.cpp            | 61 +++++++++++++++++++\n 2 files changed, 82 insertions(+)","diff":"diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 972a2fa65..bdec80589 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -13,11 +13,15 @@\n #include <sys/types.h>\n #include <vector>\n \n+#include <libcamera/base/details/cxx20.h>\n #include <libcamera/base/object.h>\n \n+#include <libcamera/camera.h>\n #include <libcamera/controls.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/request.h\"\n+\n namespace libcamera {\n \n class Camera;\n@@ -58,6 +62,23 @@ public:\n \tvoid registerRequest(Request *request);\n \tvoid queueRequest(Request *request);\n \n+\tvoid metadataAvailable(Request *request, const ControlList &metadata);\n+\n+\ttemplate<typename T>\n+\tvoid metadataAvailable(Request *request, const Control<T> &ctrl,\n+\t\t\t       const details::cxx20::type_identity_t<T> &value)\n+\t{\n+\t\tauto &m = request->metadata2();\n+\t\tconst auto c = m.checkpoint();\n+\n+\t\tm.set(ctrl, value);\n+\t\trequest->metadata().set(ctrl, value);\n+\n+\t\tconst auto d = c.diffSince();\n+\t\tif (d)\n+\t\t\trequest->_d()->camera()->metadataAvailable.emit(request, d);\n+\t}\n+\n \tbool completeBuffer(Request *request, FrameBuffer *buffer);\n \tvoid completeRequest(Request *request);\n \tvoid cancelRequest(Request *request);\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex d84dff3c9..6a9d11241 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -507,6 +507,67 @@ void PipelineHandler::doQueueRequests()\n  * \\return 0 on success or a negative error code otherwise\n  */\n \n+/**\n+ * \\brief Notify the availability of a list of metadata for \\a request\n+ * \\param[in] request The request the metadata belongs to\n+ * \\param[in] metadata The metadata list\n+ *\n+ * This function should be called multiple times by pipeline handlers to signal\n+ * the availability of a list of metadata results. It notifies applications\n+ * by triggering the Camera::availableMetadata signal and accumulates the\n+ * metadata results in Request::metadata().\n+ *\n+ * Early metadata completion allows pipeline handlers to fast track delivery of\n+ * metadata results as soon as they are available before the completion of \\a\n+ * request. The full list of metadata results of a Request is available at\n+ * Request completion time in Request::metadata().\n+ *\n+ * A metadata key is expected to be notified at most once. Metadata keys\n+ * notified multiple times are ignored.\n+ *\n+ * This overload allows to signal the availability of a list of metadata and\n+ * merges them in the Request::metadata() list. This operations is expensive\n+ * as controls are copied from \\a metadata to Request::metadata().\n+ *\n+ * \\context This function shall be called from the CameraManager thread.\n+ */\n+void PipelineHandler::metadataAvailable(Request *request, const ControlList &metadata)\n+{\n+\trequest->metadata().merge(metadata);\n+\n+\tconst auto d = request->metadata2().merge(metadata);\n+\tif (d)\n+\t\trequest->_d()->camera()->metadataAvailable.emit(request, d);\n+}\n+\n+/**\n+ * \\fn void PipelineHandler::metadataAvailable(Request *request, const Control<T> &ctrl,\n+ *\t\t\t\t\t       const details::cxx20::type_identity_t<T> &value)\n+ * \\brief Notify the availability of a metadata result for \\a request\n+ * \\param[in] request The request the metadata belongs to\n+ * \\param[in] ctrl The control id to notify\n+ * \\param[in] value the control value\n+ *\n+ * This function should be called multiple times by pipeline handlers to signal\n+ * the availability of a metadata result. It notifies applications\n+ * by triggering the Camera::availableMetadata signal and accumulates the\n+ * metadata result in Request::metadata().\n+ *\n+ * Early metadata completion allows pipeline handlers to fast track delivery of\n+ * metadata results as soon as they are available before the completion of \\a\n+ * request. The full list of metadata results of a Request is available at\n+ * Request completion time in Request::metadata().\n+ *\n+ * A metadata key is expected to be notified at most once. Metadata keys\n+ * notified multiple times are ignored.\n+ *\n+ * This overload allows to signal the availability of a single metadata and\n+ * merge \\a value in the Request::metadata() list. This operations copies \\a\n+ * value in the Request::metadata() list without creating intermediate copies.\n+ *\n+ * \\context This function shall be called from the CameraManager thread.\n+ */\n+\n /**\n  * \\brief Complete a buffer for a request\n  * \\param[in] request The request the buffer belongs to\n","prefixes":["RFC","v1","15/23"]}