{"id":921,"url":"https://patchwork.libcamera.org/api/1.1/patches/921/?format=json","web_url":"https://patchwork.libcamera.org/patch/921/","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":"<20190405020256.22520-8-niklas.soderlund@ragnatech.se>","date":"2019-04-05T02:02:55","name":"[libcamera-devel,v2,7/8] libcamera: camera: Add CameraConfiguration","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"16adc9be2c6502dd0894088a63ac9277062d46a5","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/921/mbox/","series":[{"id":240,"url":"https://patchwork.libcamera.org/api/1.1/series/240/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=240","date":"2019-04-05T02:02:48","name":"libcamera: stream: Add basic stream usages","version":2,"mbox":"https://patchwork.libcamera.org/series/240/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/921/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/921/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A215611B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Apr 2019 04:03:11 +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 f390a0c1-5746-11e9-8144-0050569116f7;\n\tFri, 05 Apr 2019 04:03:05 +0200 (CEST)"],"X-Halon-ID":"f390a0c1-5746-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":"Fri,  5 Apr 2019 04:02:55 +0200","Message-Id":"<20190405020256.22520-8-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190405020256.22520-1-niklas.soderlund@ragnatech.se>","References":"<20190405020256.22520-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 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 02:03:12 -0000"},"content":"To properly support both multiple streams and usages the library must\nprovide a method to map the stream usages to the returned stream\nconfiguration. Add a camera configuration object to handle this mapping.\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. Further more the application can use\nthe streams to retrieve there configuration using operator[] of the\ncamera configuration.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h |  26 ++++++++\n src/libcamera/camera.cpp   | 121 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 147 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 0386671c902e55e8..311a51e4070d135c 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -14,6 +14,7 @@\n \n #include <libcamera/request.h>\n #include <libcamera/signal.h>\n+#include <libcamera/stream.h>\n \n namespace libcamera {\n \n@@ -24,6 +25,31 @@ 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 empty() const;\n+\tstd::size_t size() const;\n+\n+\tStream *front();\n+\n+\tStreamConfiguration &operator[](Stream *stream);\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..16162c524297012f 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -39,6 +39,127 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(Camera)\n \n+/**\n+ * \\class CameraConfiguration\n+ * \\brief Hold configuration for streams of the camera that applications\n+ * wish to modify and apply.\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+ * list of usages describing how the application intents to use the camera, the\n+ * application in returns is provided with a default camera configuration it\n+ * can tweak.\n+ *\n+ * Applications iterates over the CameraConfiguration to discover which streams\n+ * the camera have selected for its usages and can inspect the configuration\n+ * 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 element of the streams\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 to the end of the streams\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 Checks whether 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 Check 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+/**\n+ * \\brief Retrieve a reference to a stream configuration\n+ * \\param[in] stream Stream to retrieve configuration for\n+ *\n+ * If the camera configuration do not yet contain configuration for the\n+ * requested stream an empty stream configuration is created and returned.\n+ *\n+ * \\return 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  * \\class Camera\n  * \\brief Camera device\n","prefixes":["libcamera-devel","v2","7/8"]}