[{"id":36612,"web_url":"https://patchwork.libcamera.org/comment/36612/","msgid":"<176209693798.2973778.5261570307758382186@ping.linuxembedded.co.uk>","date":"2025-11-02T15:22:17","subject":"Re: [RFC PATCH v3 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-10-30 16:58:08)\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> Reviewed-by: Paul Elder <paul.elder@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 53089282a4..53f0485bc3 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -123,6 +123,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 7bfa50b52c..a6d331a03c 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> + *\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\ns/Application/Applications/\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> + * of metadata availability or can equally access the full metadata list\n> + * at Request completion 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 threads 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.51.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 B545DC3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  2 Nov 2025 15:22:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DFE6F60A85;\n\tSun,  2 Nov 2025 16:22:21 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D0F2606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  2 Nov 2025 16:22:20 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 582BD10D4;\n\tSun,  2 Nov 2025 16:20:28 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kLtcjiLP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762096828;\n\tbh=8ldCbFVU8qsv19GRnQ/27qU0vBET//gq2vIJv6rYu1U=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=kLtcjiLPGBS4c5zfJrgqyX5i6Jlj1Ff+HwPLRnuXonQus9QFOdIm0R06gMq/A/FQb\n\tRW1CppnGFg4iszDBOKyR99ziV6EOhvfHVy7LsY3AiB5zRV58tA5wsAx5FguDlcenWW\n\tVejMMenbMmxS0DAsa5bKQkPsAein0yMwrm4Cke9g=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251030165816.1095180-15-barnabas.pocze@ideasonboard.com>","References":"<20251030165816.1095180-1-barnabas.pocze@ideasonboard.com>\n\t<20251030165816.1095180-15-barnabas.pocze@ideasonboard.com>","Subject":"Re: [RFC PATCH v3 14/22] libcamera: camera: Introduce\n\tmetadataAvailable signal","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sun, 02 Nov 2025 15:22:17 +0000","Message-ID":"<176209693798.2973778.5261570307758382186@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]