[{"id":35185,"web_url":"https://patchwork.libcamera.org/comment/35185/","msgid":"<4guw6dviptun2hpyscydak536msvzilnlb4llgvb7euy53assm@bl64gnxge2s6>","date":"2025-07-28T09:35:38","subject":"Re: [RFC PATCH v2 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Mon, Jul 21, 2025 at 12:46:14PM +0200, Barnabás Pőcze wrote:\n> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>\n> Add a new signal to the Camera class that allows applications to\n> receive notifications for early completion of metadata results.\n>\n> To avoid expensive copies of the metadata results the signal\n> transports a view object of metadata items that are ready.\n>\n> The signal is an opt-in feature for applications and the sum of\n> all metadata results notified through this signal is available\n> in Request::metadata() at request completion time.\n>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> [Use `MetadataList::Diff`, change documentation accordingly.]\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nFor the updated part\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n> Original: https://patchwork.libcamera.org/patch/22227/\n> ---\n>  include/libcamera/camera.h |  1 +\n>  src/libcamera/camera.cpp   | 54 ++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 55 insertions(+)\n>\n> diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> index e3e40aa89..44dbe7177 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -122,6 +122,7 @@ public:\n>\n>  \tconst std::string &id() const;\n>\n> +\tSignal<Request *, MetadataList::Diff> metadataAvailable;\n>  \tSignal<Request *, FrameBuffer *> bufferCompleted;\n>  \tSignal<Request *> requestCompleted;\n>  \tSignal<> disconnected;\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index fa57d46c9..5efeadd53 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -911,6 +911,60 @@ const std::string &Camera::id() const\n>  \treturn _d()->id_;\n>  }\n>\n> +/**\n> + * \\var Camera::metadataAvailable\n> + * \\brief Signal emitted when metadata for a request is available\n> + *\n> + * The metadataAvailable signal notifies applications about the availability\n> + * of metadata for a request before the request completes.\n> + *\n> + * As metadata results could be large in size, the signal transports only a view\n> + * object via which the newly completed metadata items can be accessed. Similarly\n> + * to the metadata list itself, this object is thread-safe, and can be sent to other\n> + * threads for deferred processing. The view object is valid until the request is\n> + * destroyed or reused, whichever happens first.\n> + *\n> + * Applications can access the value of the newly available metadata results as follows:\n> + *\n> + * \\code\n> +\n> +\tvoid metadataAvailableHandler(Request *request, MetadataList::Diff update)\n> +\t{\n> +\t\t// The object can be iterated...\n> +\t\tfor (auto &&[id, data] : update) {\n> +\t\t\t// `id` is the numeric identifier\n> +\t\t\t// `data` is a `ControlValueView` object\n> +\t\t}\n> +\n> +\t\t// ...or individual items can be looked up.\n> +\t\tif (auto x = update.get(controls::SensorTimestamp)) {\n> +\t\t\t// `SensorTimestamp` will only be found if it is part of this\n> +\t\t\t// particular update; metadata items completed earlier will\n> +\t\t\t// not be found.\n> +\t\t}\n> +\t}\n> +   \\endcode\n> + *\n> + * This signal is emitted multiple times for the same request, it is in fact\n> + * emitted by libcamera every time a new set of metadata is made available\n> + * by the Camera to the application.\n> + *\n> + * The sum of all metadata reported through this signal is equal to\n> + * Request::metadata() list when the Request completes.\n> + *\n> + * Application can opt-in to handle this signal to receive fast notifications\n> + * of metadata availability or can equally access the full metadata list\n> + * at Request complete time through Request::metadata() if they have no interest\n> + * in early metadata notification.\n> + *\n> + * \\note The received MetadataList::Diff object is merely a view, it is only valid until\n> + *       the associated Request is destroyed or \\ref Request::reuse() \"reused\". However,\n> + *       during its valid lifetime, an application is free to create copies and access the\n> + *       completed metadata items from separate thread by iteration or MetadataList::Diff::get().\n> + *\n> + * \\sa ControlValueView\n> + */\n> +\n>  /**\n>   * \\var Camera::bufferCompleted\n>   * \\brief Signal emitted when a buffer for a request queued to the camera has\n> --\n> 2.50.1\n>","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 4F182C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jul 2025 09:35:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 76FD36146B;\n\tMon, 28 Jul 2025 11:35:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C51516146B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jul 2025 11:35:56 +0200 (CEST)","from ideasonboard.com (mob-5-90-139-29.net.vodafone.it\n\t[5.90.139.29])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D70BA465;\n\tMon, 28 Jul 2025 11:35:12 +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=\"JzxNbGZx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753695314;\n\tbh=h6unRFVLOk4knFzmftE1+OdkA0ynvvMRc1eZ1DGOl30=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JzxNbGZxQWJqwmKkylNe07T72YHaNMz+AVtgVFq9lfPygiPRAEdxeBa2MUt/c26Ir\n\tr43lQc/EoUxtBXHMCfDVWOpso1awzw13VFmyIsCEzP2IAySjJ/SsFaxva1vikF2+dY\n\teqqkJ5WM66qYgF80cWu+MoveH9Yr8+3MzBS8EBcE=","Date":"Mon, 28 Jul 2025 11:35:38 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","Message-ID":"<4guw6dviptun2hpyscydak536msvzilnlb4llgvb7euy53assm@bl64gnxge2s6>","References":"<20250721104622.1550908-1-barnabas.pocze@ideasonboard.com>\n\t<20250721104622.1550908-15-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250721104622.1550908-15-barnabas.pocze@ideasonboard.com>","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>"}},{"id":35880,"web_url":"https://patchwork.libcamera.org/comment/35880/","msgid":"<175818696696.2127323.13254783564206357748@neptunite.rasen.tech>","date":"2025-09-18T09:16:06","subject":"Re: [RFC PATCH v2 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-07-21 19:46:14)\n> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> Add a new signal to the Camera class that allows applications to\n> receive notifications for early completion of metadata results.\n> \n> To avoid expensive copies of the metadata results the signal\n> transports a view object of metadata items that are ready.\n> \n> The signal is an opt-in feature for applications and the sum of\n> all metadata results notified through this signal is available\n> in Request::metadata() at request completion time.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> [Use `MetadataList::Diff`, change documentation accordingly.]\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n> Original: https://patchwork.libcamera.org/patch/22227/\n> ---\n>  include/libcamera/camera.h |  1 +\n>  src/libcamera/camera.cpp   | 54 ++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 55 insertions(+)\n> \n> diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> index e3e40aa89..44dbe7177 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -122,6 +122,7 @@ public:\n>  \n>         const std::string &id() const;\n>  \n> +       Signal<Request *, MetadataList::Diff> metadataAvailable;\n>         Signal<Request *, FrameBuffer *> bufferCompleted;\n>         Signal<Request *> requestCompleted;\n>         Signal<> disconnected;\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index fa57d46c9..5efeadd53 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -911,6 +911,60 @@ const std::string &Camera::id() const\n>         return _d()->id_;\n>  }\n>  \n> +/**\n> + * \\var Camera::metadataAvailable\n> + * \\brief Signal emitted when metadata for a request is available\n> + *\n> + * The metadataAvailable signal notifies applications about the availability\n> + * of metadata for a request before the request completes.\n> + *\n> + * As metadata results could be large in size, the signal transports only a view\n> + * object via which the newly completed metadata items can be accessed. Similarly\n> + * to the metadata list itself, this object is thread-safe, and can be sent to other\n> + * threads for deferred processing. The view object is valid until the request is\n> + * destroyed or reused, whichever happens first.\n\nAha, this answers my question that I had on the documentation patch.\n\n> + *\n> + * Applications can access the value of the newly available metadata results as follows:\n> + *\n> + * \\code\n> +\n> +       void metadataAvailableHandler(Request *request, MetadataList::Diff update)\n> +       {\n> +               // The object can be iterated...\n> +               for (auto &&[id, data] : update) {\n> +                       // `id` is the numeric identifier\n> +                       // `data` is a `ControlValueView` object\n> +               }\n> +\n> +               // ...or individual items can be looked up.\n> +               if (auto x = update.get(controls::SensorTimestamp)) {\n> +                       // `SensorTimestamp` will only be found if it is part of this\n> +                       // particular update; metadata items completed earlier will\n> +                       // not be found.\n> +               }\n> +       }\n> +   \\endcode\n> + *\n> + * This signal is emitted multiple times for the same request, it is in fact\n> + * emitted by libcamera every time a new set of metadata is made available\n> + * by the Camera to the application.\n> + *\n> + * The sum of all metadata reported through this signal is equal to\n> + * Request::metadata() list when the Request completes.\n> + *\n> + * Application can opt-in to handle this signal to receive fast notifications\n> + * of metadata availability or can equally access the full metadata list\n> + * at Request complete time through Request::metadata() if they have no interest\n> + * in early metadata notification.\n> + *\n> + * \\note The received MetadataList::Diff object is merely a view, it is only valid until\n> + *       the associated Request is destroyed or \\ref Request::reuse() \"reused\". However,\n> + *       during its valid lifetime, an application is free to create copies and access the\n> + *       completed metadata items from separate thread by iteration or MetadataList::Diff::get().\n\nI see, you document this here. imo it would also be useful to have in the design doc too.\n\nLooks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> + *\n> + * \\sa ControlValueView\n> + */\n> +\n>  /**\n>   * \\var Camera::bufferCompleted\n>   * \\brief Signal emitted when a buffer for a request queued to the camera has\n> -- \n> 2.50.1\n>","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 F068CC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Sep 2025 09:16:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9A2FC6936F;\n\tThu, 18 Sep 2025 11:16:16 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 692A862C39\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Sep 2025 11:16:14 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:7cf2:5f58:dd2a:9ec1])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 58999446;\n\tThu, 18 Sep 2025 11:14:54 +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=\"IeiPxwkf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758186894;\n\tbh=BR+oxqfahrL2zogsGw57LnBzWFN3O4UdQNUdiIH9EOg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=IeiPxwkfjSIAIpGriz2FRQkaZUvj++tNbbot+65BIPQLKIfJuPB7M2H+vGw5ltNlt\n\tqJNp/NXp0QKtjiRoeoUBsUBSCo82y/00tLSMEzIg5tFASFIdGmWTCU7D92XMT3wjx+\n\txrbO7ArfZ6NTxK5DIJaVl60oZyvZxAP7RAVRrRUw=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250721104622.1550908-15-barnabas.pocze@ideasonboard.com>","References":"<20250721104622.1550908-1-barnabas.pocze@ideasonboard.com>\n\t<20250721104622.1550908-15-barnabas.pocze@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 18 Sep 2025 18:16:06 +0900","Message-ID":"<175818696696.2127323.13254783564206357748@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]