Show a patch.

GET /api/1.1/patches/16803/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16803,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16803/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16803/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20220726182500.425182-3-hanlinchen@chromium.org>",
    "date": "2022-07-26T18:24:56",
    "name": "[libcamera-devel,2/6] libcamera: Camera: Add signals for completion of metadata and partial result",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "0db041b4685a134f24297069245421020575d938",
    "submitter": {
        "id": 98,
        "url": "https://patchwork.libcamera.org/api/1.1/people/98/?format=api",
        "name": "Hanlin Chen",
        "email": "hanlinchen@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16803/mbox/",
    "series": [
        {
            "id": 3329,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3329/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3329",
            "date": "2022-07-26T18:24:54",
            "name": "Implement Android Partial Result Featrue",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3329/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16803/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16803/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 A0A7FBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jul 2022 18:25:32 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5DC4763318;\n\tTue, 26 Jul 2022 20:25:32 +0200 (CEST)",
            "from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com\n\t[IPv6:2607:f8b0:4864:20::1029])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3670363317\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 20:25:31 +0200 (CEST)",
            "by mail-pj1-x1029.google.com with SMTP id\n\to5-20020a17090a3d4500b001ef76490983so14057906pjf.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 11:25:30 -0700 (PDT)",
            "from localhost ([2401:fa00:1:17:739:6574:4032:5911])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tip13-20020a17090b314d00b001f2fee30a59sm904883pjb.57.2022.07.26.11.25.28\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tTue, 26 Jul 2022 11:25:29 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658859932;\n\tbh=/J1uvqY5cxlHrHovY8ssTqJmGQWBuqdFF6AammIt0tk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=ThvY191oImr5lMI1jjL/lsUUGBj2NXmJrDo9tiZwQsjCjINRTXS2ayfWnqPsgVBC5\n\taq+h0oqJ7zQpvwLR/r9mwO8qJ2UXYZ5vZ76xXkPzEYnqmz5QSC2mA0m4CjWichUwgf\n\tQ2mdxfyNNpej31TJqNGmROkoxtAEqRSmv1lhkCgMylgp5lvQB6K846EaBLNAj7IJeH\n\tqEVfsjiK3CYplNAjDTeca4k3cuXUTDz8lMuo7zgK0zpj5Yg1uKU046rfdaDoSftEa1\n\t/ISTKYZBi0iVRwU98lDO6rQr+nYn+04x8lO3InevsXrfJdxk4Eww0FugpP1KTUuotu\n\toT1fdpxNJjDlA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=zl9BEdReWHmY1cqNo3JDLudkoxv111RZ4PNfY4ukwoY=;\n\tb=XfKOWlei3hAIpmQh/3s+N7zBJp1dwvvyb4L/1Uctq/HjTaTHAvfrXihaHvIQxQmqgM\n\tinD/0kmqnRvHnerGt69PVuCE9BKkjP+/SMagcZVzFRi+kbD3zqlj+80hS/lHsnnclMDQ\n\ttAI7uBXa8i7cird8hdu6DQwDkmmkey/O6Qoyc="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"XfKOWlei\"; \n\tdkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=zl9BEdReWHmY1cqNo3JDLudkoxv111RZ4PNfY4ukwoY=;\n\tb=6tNHFK0zZDx/S1u3bfZ+35fW/oYmOEFmD1Bhu4J4VYOtGS9/wihM3W5g3IhyUgpD3Y\n\tgWlauDhEhWS1neXBbkMywC3QWq5rWe+Xd9rzVahj2yQ/LW9ydTRkLGZrFMyFDABRtXD7\n\t+LU4VGSMuuka2aJRGY0TbHObtNA/CgviwNB+pc6Vm59dxIpTnM2u0qcjfQeJ4t5GLJDA\n\teXiCaeXTXnPYJVDeNCeXlmF4HNFYhh6eRbN567QXP14q/onmFmXMZnFcaBsa5WSdZAVR\n\tEwc3dt3qsSji4FhPE9MtoU6zDEYWmnEG3nmcdGG4JWcjFqicSYm+EE2PZEYu5Nqn23QI\n\tyzrg==",
        "X-Gm-Message-State": "AJIora844G+T/sGzKb+20W0k0h7Q/ASZYN2aZLMzW1BMJppIw0l5tWYl\n\tsFTc5AnjiBA6JAD2J+hWVoqhcKUaTQ6MJQ==",
        "X-Google-Smtp-Source": "AGRyM1t49SkoqTu1YGVDI55gDC1vSe7cqV+kUqOHANCDKiAMx52X53v+SZwX8dJCkbRGfMm8iqBBvg==",
        "X-Received": "by 2002:a17:90a:5aa3:b0:1f2:2bb7:aea9 with SMTP id\n\tn32-20020a17090a5aa300b001f22bb7aea9mr434836pji.197.1658859929224; \n\tTue, 26 Jul 2022 11:25:29 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 27 Jul 2022 02:24:56 +0800",
        "Message-Id": "<20220726182500.425182-3-hanlinchen@chromium.org>",
        "X-Mailer": "git-send-email 2.37.1.359.gd136c6c3e2-goog",
        "In-Reply-To": "<20220726182500.425182-1-hanlinchen@chromium.org>",
        "References": "<20220726182500.425182-1-hanlinchen@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/6] libcamera: Camera: Add signals for\n\tcompletion of metadata and partial result",
        "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>",
        "From": "Han-Lin Chen via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Han-Lin Chen <hanlinchen@chromium.org>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Allows pipelien handler to signal partial result completion by adding the\nfollowing signals to Camera:\n\nSignal<Request *, ControlList *> metadataCompleted;\nSignal<Request *, Result *> partialResultCompleted;\n\nTogether with the bufferCompleted signal, the pipeline handler is allowed to\nreturn buffers, partial metadata and combination of both at any  stage of\nprocessing.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n include/libcamera/camera.h                    |   2 +\n include/libcamera/internal/pipeline_handler.h |   3 +\n include/libcamera/request.h                   |  40 +++++\n src/libcamera/camera.cpp                      |  10 ++\n src/libcamera/pipeline_handler.cpp            | 100 ++++++++++-\n src/libcamera/request.cpp                     | 159 ++++++++++++++++++\n 6 files changed, 310 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 5aa4bf69..187e01d8 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -99,7 +99,9 @@ public:\n \n \tconst std::string &id() const;\n \n+\tSignal<Request *, Result *> partialResultCompleted;\n \tSignal<Request *, FrameBuffer *> bufferCompleted;\n+\tSignal<Request *, ControlList *> metadataCompleted;\n \tSignal<Request *> requestCompleted;\n \tSignal<> disconnected;\n \ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex c3e4c258..03d46367 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -33,6 +33,7 @@ class FrameBuffer;\n class MediaDevice;\n class PipelineHandler;\n class Request;\n+class Result;\n \n class PipelineHandler : public std::enable_shared_from_this<PipelineHandler>,\n \t\t\tpublic Object\n@@ -62,7 +63,9 @@ public:\n \tvoid registerRequest(Request *request);\n \tvoid queueRequest(Request *request);\n \n+\tvoid completeMetadata(Request *request, const ControlList &metadata);\n \tbool completeBuffer(Request *request, FrameBuffer *buffer);\n+\tvoid completePartialResult(Request *request, Result &&result);\n \tvoid completeRequest(Request *request);\n \n \tconst char *name() const { return name_; }\ndiff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex dffde153..ac520226 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -25,8 +25,43 @@ namespace libcamera {\n class Camera;\n class CameraControlValidator;\n class FrameBuffer;\n+class Request;\n class Stream;\n \n+class Result\n+{\n+public:\n+\tResult(Request *request);\n+\tResult(Result &&result);\n+\t~Result();\n+\n+\tRequest *request() const { return request_; }\n+\tconst ControlList &metadata() const { return metadata_; }\n+\n+\tconst std::vector<FrameBuffer *> &buffers() const { return buffers_; }\n+\tint addBuffer(FrameBuffer *buffer);\n+\n+\ttemplate<typename T, typename V>\n+\tvoid set(const Control<T> &ctrl, const V &value)\n+\t{\n+\t\treturn metadata_.set(ctrl, value);\n+\t}\n+\n+\tvoid set(unsigned int id, const ControlValue &value);\n+\tvoid merge(const ControlList &source);\n+\n+\tstd::string toString() const;\n+\n+private:\n+\tLIBCAMERA_DISABLE_COPY(Result)\n+\n+\tRequest *request_;\n+\tControlList metadata_;\n+\tstd::vector<FrameBuffer *> buffers_;\n+};\n+\n+std::ostream &operator<<(std::ostream &out, const Result &r);\n+\n class Request : public Extensible\n {\n \tLIBCAMERA_DECLARE_PRIVATE()\n@@ -44,6 +79,7 @@ public:\n \t};\n \n \tusing BufferMap = std::map<const Stream *, FrameBuffer *>;\n+\tusing ResultList = std::vector<Result>;\n \n \tRequest(Camera *camera, uint64_t cookie = 0);\n \t~Request();\n@@ -53,9 +89,12 @@ public:\n \tControlList &controls() { return *controls_; }\n \tControlList &metadata() { return *metadata_; }\n \tconst BufferMap &buffers() const { return bufferMap_; }\n+\tResultList &resultList() { return results_; }\n+\tResult *addResult(Result &&result);\n \tint addBuffer(const Stream *stream, FrameBuffer *buffer,\n \t\t      std::unique_ptr<Fence> fence = nullptr);\n \tFrameBuffer *findBuffer(const Stream *stream) const;\n+\tconst Stream *findStream(const FrameBuffer *buffer) const;\n \n \tuint32_t sequence() const;\n \tuint64_t cookie() const { return cookie_; }\n@@ -71,6 +110,7 @@ private:\n \tControlList *controls_;\n \tControlList *metadata_;\n \tBufferMap bufferMap_;\n+\tResultList results_;\n \n \tconst uint64_t cookie_;\n \tStatus status_;\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 4d3523e2..a5fb9b33 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -765,6 +765,16 @@ const std::string &Camera::id() const\n  * completed\n  */\n \n+/**\n+ * \\var Camera::metadataCompleted\n+ * \\brief Signal emitted when a partial metadata for a request is completed\n+ */\n+\n+/**\n+ * \\var Camera::partialResultCompleted\n+ * \\brief Signal emitted when a partial result for a request is completed\n+ */\n+\n /**\n  * \\var Camera::requestCompleted\n  * \\brief Signal emitted when a request queued to the camera has completed\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 7c180a8e..2102da58 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -453,9 +453,10 @@ void PipelineHandler::doQueueRequests()\n  * \\param[in] request The request the buffer belongs to\n  * \\param[in] buffer The buffer that has completed\n  *\n- * This function shall be called by pipeline handlers to signal completion of\n+ * This function could be called by pipeline handlers to signal completion of\n  * the \\a buffer part of the \\a request. It notifies applications of buffer\n- * completion and updates the request's internal buffer tracking. The request\n+ * completion and updates the request's internal buffer tracking. The function\n+ * notify completion of a partial result including the buffer. The request\n  * is not completed automatically when the last buffer completes to give\n  * pipeline handlers a chance to perform any operation that may still be\n  * needed. They shall complete requests explicitly with completeRequest().\n@@ -466,10 +467,74 @@ void PipelineHandler::doQueueRequests()\n  * otherwise\n  */\n bool PipelineHandler::completeBuffer(Request *request, FrameBuffer *buffer)\n+{\n+\tResult result(request);\n+\tresult.addBuffer(buffer);\n+\tcompletePartialResult(request, std::move(result));\n+\n+\treturn request->_d()->hasPendingBuffers();\n+}\n+\n+/**\n+ * \\brief Complete part of metadata for a request\n+ * \\param[in] request The request the buffer belongs to\n+ * \\param[in] metadata The partial metadata that has completed\n+ *\n+ * This function could be called by pipeline handlers to signal completion of\n+ * the \\a metadata part of the \\a request. It notifies applications of metadata\n+ * completion. The function notify completion of a partial result including the\n+ * metadata. The request is not completed automatically when the last metadata\n+ * completes to give pipeline handlers a chance to perform any operation that\n+ * may still be needed. They shall complete requests explicitly with\n+ * completeRequest().\n+ *\n+ * \\context This function shall be called from the CameraManager thread.\n+ */\n+void PipelineHandler::completeMetadata(Request *request, const ControlList &metadata)\n+{\n+\tResult result = Result(request);\n+\tresult.merge(metadata);\n+\tcompletePartialResult(request, std::move(result));\n+}\n+\n+/**\n+ * \\brief Complete part of metadata and buffer for a request\n+ * \\param[in] request The request the buffer belongs to\n+ * \\param[in] result The partial result that has completed\n+ *\n+ * This function could be called by pipeline handlers to signal completion of\n+ * the \\a result part of the \\a request. It notifies applications of partial\n+ * completion. The function notify completion of buffers and metadata included\n+ * in the result. The request is not completed automatically when the last\n+ * result completes to give pipeline handlers a chance to perform any operation\n+ * that may still be needed. They shall complete requests explicitly with\n+ * completeRequest(). The function only accepts rvalue of a Result type and\n+ * its interval content will be moved to the internal store to avoid copying\n+ * big metadata.\n+ *\n+ * \\context This function shall be called from the CameraManager thread.\n+ */\n+void PipelineHandler::completePartialResult(Request *request, Result &&result)\n {\n \tCamera *camera = request->_d()->camera();\n-\tcamera->bufferCompleted.emit(request, buffer);\n-\treturn request->_d()->completeBuffer(buffer);\n+\tResult *movedResult = request->addResult(std::move(result));\n+\n+\tASSERT(movedResult->request() == request);\n+\tASSERT(!movedResult->buffers().empty() || !movedResult->metadata().empty());\n+\n+\tfor (auto buffer : movedResult->buffers()) {\n+\t\trequest->_d()->completeBuffer(buffer);\n+\t\tcamera->bufferCompleted.emit(request, buffer);\n+\t}\n+\n+\tif (!movedResult->metadata().empty()) {\n+\t\trequest->metadata().merge(movedResult->metadata());\n+\t\tcamera->metadataCompleted.emit(\n+\t\t\trequest,\n+\t\t\t&const_cast<ControlList &>(movedResult->metadata()));\n+\t}\n+\n+\tcamera->partialResultCompleted.emit(request, movedResult);\n }\n \n /**\n@@ -494,6 +559,33 @@ void PipelineHandler::completeRequest(Request *request)\n \n \tCamera::Private *data = camera->_d();\n \n+\t/*\n+\t * Collect metadata which is not yet completed by the Camera, and\n+\t * create one partial result to cover the missing metadata before\n+\t * completing the whole request. This guarantees the aggregation of\n+\t * metadata in completed partial results equals to the global metadata\n+\t * in the request.\n+\t *\n+\t * \\todo: Forbid merging metadata into request.metadata() directly and\n+\t * force calling completeMetadata() and completePartialResult() to\n+\t * report metadata.\n+\t */\n+\tstd::unordered_set<unsigned int> completedMetadata;\n+\tfor (auto &result : request->resultList()) {\n+\t\tfor (auto &[id, _] : result.metadata())\n+\t\t\tcompletedMetadata.insert(id);\n+\t}\n+\n+\tControlList &requestMetadata = request->metadata();\n+\tif (requestMetadata.size() > completedMetadata.size()) {\n+\t\tResult result(request);\n+\t\tfor (auto &[id, value] : requestMetadata)\n+\t\t\tif (!completedMetadata.count(id))\n+\t\t\t\tresult.set(id, value);\n+\n+\t\tcompletePartialResult(request, std::move(result));\n+\t}\n+\n \tauto iter = data->queuedRequests_.begin();\n \twhile (iter != data->queuedRequests_.end()) {\n \t\tif ((*iter)->status() != Request::RequestPending) {\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex d2af1d22..275722a4 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -323,6 +323,11 @@ void Request::Private::timeout()\n  * \\brief A map of Stream to FrameBuffer pointers\n  */\n \n+/**\n+ * \\typedef Request::ResultList\n+ * \\brief A list partial results associated with a request\n+ */\n+\n /**\n  * \\class Request\n  * \\brief A frame capture request\n@@ -394,6 +399,7 @@ void Request::reuse(ReuseFlag flags)\n \n \tstatus_ = RequestPending;\n \n+\tresults_.clear();\n \tcontrols_->clear();\n \tmetadata_->clear();\n }\n@@ -424,6 +430,12 @@ void Request::reuse(ReuseFlag flags)\n  * \\return The map of Stream to FrameBuffer\n  */\n \n+/**\n+ * \\fn Request::resultList()\n+ * \\brief Retrieve the request's partial results\n+ * \\return A reference to the list of results that associates with the request\n+ */\n+\n /**\n  * \\brief Add a FrameBuffer with its associated Stream to the Request\n  * \\param[in] stream The stream the buffer belongs to\n@@ -489,6 +501,20 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n \treturn 0;\n }\n \n+/**\n+ * \\brief Add result into the internal result list\n+ * \\param[in] result The result to add into the request\n+ *\n+ * The function only accepts rvalue and moves its content into the request\n+ *\n+ * \\return The result moved into the request\n+ */\n+Result *Request::addResult(Result &&result)\n+{\n+\tresults_.emplace_back(std::move(result));\n+\treturn &results_.back();\n+}\n+\n /**\n  * \\var Request::bufferMap_\n  * \\brief Mapping of streams to buffers for this request\n@@ -513,6 +539,21 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const\n \treturn it->second;\n }\n \n+/**\n+ * \\brief Return the stream associated with a buffer\n+ * \\param[in] buffer The buffer the stream is associated to\n+ * \\return The stream associated with the buffer, or nullptr if the buffer is\n+ * not part of this request\n+ */\n+const Stream *Request::findStream(const FrameBuffer *buffer) const\n+{\n+\tfor (auto &[key, value] : bufferMap_)\n+\t\tif (buffer == value)\n+\t\t\treturn key;\n+\n+\treturn nullptr;\n+}\n+\n /**\n  * \\fn Request::metadata()\n  * \\brief Retrieve the request's metadata\n@@ -606,4 +647,122 @@ std::ostream &operator<<(std::ostream &out, const Request &r)\n \treturn out;\n }\n \n+/**\n+ * \\class Result\n+ * \\brief A partial result of a frame capture request\n+ *\n+ * A Result allows pipeline handler to report partial results to the application\n+ */\n+\n+/**\n+ * \\brief Create a partial result for a capture request\n+ * \\param[in] request The request the result associated to\n+ */\n+Result::Result(Request *request)\n+\t: request_(request)\n+{\n+}\n+\n+/**\n+ * \\brief Move constructor of a Result\n+ * \\param[in] result The other result\n+ */\n+Result::Result(Result &&result) = default;\n+\n+Result::~Result() = default;\n+\n+/**\n+ * \\fn Result::request()\n+ * \\brief Retrieve the result's associated request\n+ * \\return The Request pointer associated with the result\n+ */\n+\n+/**\n+ * \\fn Result::metadata()\n+ * \\brief Retrieve the result's metadata\n+ * \\return The metadata contained in the result\n+ */\n+\n+/**\n+ * \\fn Result::buffers()\n+ * \\brief Retrieve the result's buffers\n+ * \\return The buffers contained in the result\n+ */\n+\n+/**\n+ * \\fn Result::set(const Control<T> &ctrl, const V &value)\n+ * \\brief Set the control \\a ctrl value to \\a value into metadata\n+ * \\param[in] ctrl The control\n+ * \\param[in] value The control value\n+ */\n+\n+/**\n+ * \\brief Add a FrameBuffer with its associated Stream to the Result\n+ * \\param[in] buffer The FrameBuffer to add to the result\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EINVAL The buffer does not reference a valid Stream in the request\n+ */\n+int Result::addBuffer(FrameBuffer *buffer)\n+{\n+\tif (!buffer || !request_->findStream(buffer)) {\n+\t\tLOG(Request, Error) << \"Invalid buffer reference\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tbuffers_.emplace_back(buffer);\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Set the control \\a id to \\a value\n+ * \\param[in] id The control id\n+ * \\param[in] value The control value\n+ */\n+void Result::set(unsigned int id, const ControlValue &value)\n+{\n+\tmetadata_.set(id, value);\n+}\n+\n+/**\n+ * \\brief Merge the \\a source into the metadata of the result\n+ * \\param[in] source The ControlList to merge into this metadata\n+ */\n+void Result::merge(const ControlList &source)\n+{\n+\tmetadata_.merge(source);\n+}\n+\n+/**\n+ * \\brief Generate a string representation of the Result internals\n+ *\n+ * This function facilitates debugging of Result state while it is used\n+ * internally within libcamera.\n+ *\n+ * \\return A string representing the current state of the result\n+ */\n+std::string Result::toString() const\n+{\n+\tstd::stringstream ss;\n+\tss << *this;\n+\n+\treturn ss.str();\n+}\n+\n+/**\n+ * \\brief Insert a text representation of a Result into an output stream\n+ * \\param[in] out The output stream\n+ * \\param[in] r The Result\n+ * \\return The output stream \\a out\n+ */\n+std::ostream &operator<<(std::ostream &out, const Result &r)\n+{\n+\t/* Example Output: Result(55:1/2) */\n+\tout << \"Result(\" << r.request()->sequence() << \":\"\n+\t    << r.buffers().size() << \"/\"\n+\t    << const_cast<Result &>(r).metadata().size() << \")\";\n+\n+\treturn out;\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "2/6"
    ]
}