Show a patch.

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

{
    "id": 931,
    "url": "https://patchwork.libcamera.org/api/patches/931/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/931/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190405235842.27884-8-niklas.soderlund@ragnatech.se>",
    "date": "2019-04-05T23:58:41",
    "name": "[libcamera-devel,v3,7/8] libcamera: camera: Add CameraConfiguration",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1cd67af53117aea742a9af7a880b8ef8f23d6af9",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/931/mbox/",
    "series": [
        {
            "id": 242,
            "url": "https://patchwork.libcamera.org/api/series/242/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=242",
            "date": "2019-04-05T23:58:34",
            "name": "libcamera: stream: Add basic stream usages",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/242/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/931/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/931/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 239F06110D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  6 Apr 2019 01:59:24 +0200 (CEST)",
            "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid d4c194a2-57fe-11e9-8144-0050569116f7;\n\tSat, 06 Apr 2019 01:59:21 +0200 (CEST)"
        ],
        "X-Halon-ID": "d4c194a2-57fe-11e9-8144-0050569116f7",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat,  6 Apr 2019 01:58:41 +0200",
        "Message-Id": "<20190405235842.27884-8-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190405235842.27884-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190405235842.27884-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 7/8] libcamera: camera: Add\n\tCameraConfiguration",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Fri, 05 Apr 2019 23:59:24 -0000"
    },
    "content": "To properly support both multiple streams and stream usages the library\nmust provide a method to map the stream usages to the returned streams\nconfigurations. Add a camera configuration object to handle this\nmapping.\n\nApplications can iterate over the returned camera configuration to\nretrieve the streams selected by the library in the same order as the\nusages it provided to the library.\n\nApplication can use the operator[] to retrieve the stream pointer and\nthe stream configuration. Using a numerical index retrieves the stream\npointer, the numerical indexes corresponds to the insertion order of\nusages by the application, using the stream pointer retrieves the\nstream's configuration.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h |  28 ++++++\n src/libcamera/camera.cpp   | 173 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 201 insertions(+)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 0386671c902e55e8..8455049151d5c5a2 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -24,6 +24,34 @@ class Stream;\n class StreamConfiguration;\n class StreamUsage;\n \n+class CameraConfiguration\n+{\n+public:\n+\tusing iterator = std::vector<Stream *>::iterator;\n+\tusing const_iterator = std::vector<Stream *>::const_iterator;\n+\n+\tCameraConfiguration();\n+\n+\titerator begin();\n+\titerator end();\n+\tconst_iterator begin() const;\n+\tconst_iterator end() const;\n+\n+\tbool valid() const;\n+\tbool empty() const;\n+\tstd::size_t size() const;\n+\n+\tStream *front();\n+\n+\tStream *operator[](unsigned int index) const;\n+\tStreamConfiguration &operator[](Stream *stream);\n+\tconst StreamConfiguration &operator[](Stream *stream) const;\n+\n+private:\n+\tstd::vector<Stream *> order_;\n+\tstd::map<Stream *, StreamConfiguration> config_;\n+};\n+\n class Camera final\n {\n public:\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 63fde0ffc3d02d6c..98145edea1ac9c91 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -39,6 +39,179 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(Camera)\n \n+/**\n+ * \\class CameraConfiguration\n+ * \\brief Hold configuration for streams of the camera\n+ *\n+ * The CameraConfiguration is filled with information by the application either\n+ * manually or with the streamConfiguration() helper. The helper takes a list\n+ * of usages describing how the application intends to use streams of the\n+ * camera, the application in return are provided with a default camera\n+ * configuration it can tune.\n+ *\n+ * Applications iterate over the CameraConfiguration to discover which streams\n+ * the camera has associated to the usages, and can inspect the configuration\n+ * of individual streams using the operator[].\n+ */\n+\n+/**\n+ * \\typedef CameraConfiguration::iterator\n+ * \\brief Iterator for the streams in the configuration\n+ */\n+\n+/**\n+ * \\typedef CameraConfiguration::const_iterator\n+ * \\brief Const iterator for the streams in the configuration\n+ */\n+\n+/**\n+ * \\brief Create an empty camera configuration\n+ */\n+CameraConfiguration::CameraConfiguration()\n+\t: order_({}), config_({})\n+{\n+}\n+\n+/**\n+ * \\brief Retrieve an iterator to the first stream in the sequence\n+ *\n+ * \\return An iterator to the first stream\n+ */\n+std::vector<Stream *>::iterator CameraConfiguration::begin()\n+{\n+\treturn order_.begin();\n+}\n+\n+/**\n+ * \\brief Retrieve an iterator pointing to the past-the-end stream in the\n+ * sequence\n+ *\n+ * \\return An iterator to the element following the last stream\n+ */\n+std::vector<Stream *>::iterator CameraConfiguration::end()\n+{\n+\treturn order_.end();\n+}\n+\n+/**\n+ * \\brief Retrieve an iterator to the first element of the streams\n+ *\n+ * \\return An iterator to the first stream\n+ */\n+std::vector<Stream *>::const_iterator CameraConfiguration::begin() const\n+{\n+\treturn order_.begin();\n+}\n+\n+/**\n+ * \\brief Retrieve an iterator to the end of the streams\n+ *\n+ * \\return An iterator to the element following the last stream\n+ */\n+std::vector<Stream *>::const_iterator CameraConfiguration::end() const\n+{\n+\treturn order_.end();\n+}\n+\n+/**\n+ * \\brief Check if the camera configuration is valid\n+ *\n+ * \\return True if the configuration is valid\n+ */\n+bool CameraConfiguration::valid() const\n+{\n+\tif (empty())\n+\t\treturn false;\n+\n+\tfor (auto const &it : config_) {\n+\t\tconst StreamConfiguration &conf = it.second;\n+\n+\t\tif (conf.width == 0 || conf.height == 0 ||\n+\t\t    conf.pixelFormat == 0 || conf.bufferCount == 0)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * \\brief Check if the camera configuration is empty\n+ *\n+ * \\return True if the configuration is empty\n+ */\n+bool CameraConfiguration::empty() const\n+{\n+\treturn order_.empty();\n+}\n+\n+/**\n+ * \\brief Retrieve the number of stream configurations\n+ *\n+ * \\return Number of stream configurations\n+ */\n+std::size_t CameraConfiguration::size() const\n+{\n+\treturn order_.size();\n+}\n+\n+/**\n+ * \\brief Access the first stream in the configuration\n+ *\n+ * \\return The first stream in the configuration\n+ */\n+Stream *CameraConfiguration::front()\n+{\n+\treturn order_.front();\n+}\n+/**\n+ * \\brief Retrieve a stream pointer from index\n+ * \\param[in] index Numerical index\n+ *\n+ * The \\a index represents the zero bases insertion order of stream and stream\n+ * configuration into the camera configuration.\n+ *\n+ * \\return The stream pointer at index, or a nullptr if the index is out of\n+ * bounds\n+ */\n+Stream *CameraConfiguration::operator[](unsigned int index) const\n+{\n+\tif (index >= order_.size())\n+\t\treturn nullptr;\n+\n+\treturn order_.at(index);\n+}\n+\n+/**\n+ * \\brief Retrieve a reference to a stream configuration\n+ * \\param[in] stream Stream to retrieve configuration for\n+ *\n+ * If the camera configuration does not yet contain a configuration for\n+ * the requested stream, create and return an empty stream configuration.\n+ *\n+ * \\return The configuration for the stream\n+ */\n+StreamConfiguration &CameraConfiguration::operator[](Stream *stream)\n+{\n+\tif (config_.find(stream) == config_.end())\n+\t\torder_.push_back(stream);\n+\n+\treturn config_[stream];\n+}\n+\n+/**\n+ * \\brief Retrieve a const reference to a stream configuration\n+ * \\param[in] stream Stream to retrieve configuration for\n+ *\n+ * No new stream configuration is created if called with \\a stream that is not\n+ * already part of the camera configuration, doing so is an illegal operation.\n+ *\n+ * \\return The configuration for the stream\n+ */\n+const StreamConfiguration &CameraConfiguration::operator[](Stream *stream) const\n+{\n+\treturn config_.at(stream);\n+}\n+\n /**\n  * \\class Camera\n  * \\brief Camera device\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "7/8"
    ]
}