{"id":416,"url":"https://patchwork.libcamera.org/api/patches/416/?format=json","web_url":"https://patchwork.libcamera.org/patch/416/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190127002208.18913-7-niklas.soderlund@ragnatech.se>","date":"2019-01-27T00:22:08","name":"[libcamera-devel,v3,6/6] libcamera: camera: extend camera object to support configuration of streams","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"53e1e968453aa9fc702e2883e2e263c4b6d873ea","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/416/mbox/","series":[{"id":144,"url":"https://patchwork.libcamera.org/api/series/144/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=144","date":"2019-01-27T00:22:04","name":"libcamera: add basic support for streams and format configuration","version":3,"mbox":"https://patchwork.libcamera.org/series/144/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/416/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/416/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E58CE60C7F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Jan 2019 01:22:58 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid b265071f-21c9-11e9-874f-005056917f90;\n\tSun, 27 Jan 2019 01:22:58 +0100 (CET)"],"X-Halon-ID":"b265071f-21c9-11e9-874f-005056917f90","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":"Sun, 27 Jan 2019 01:22:08 +0100","Message-Id":"<20190127002208.18913-7-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190127002208.18913-1-niklas.soderlund@ragnatech.se>","References":"<20190127002208.18913-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 6/6] libcamera: camera: extend camera\n\tobject to support configuration of streams","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":"Sun, 27 Jan 2019 00:22:59 -0000"},"content":"Extend the camera to support reading and configuring of formats for\ngroups of streams. The implementation in the Camera are minimalistic as\nthe heavy lifting are done by the pipeline handler implementations.\n\nThe most important functionality the camera provides in this context is\nvalidation of data structures passed to it from the application and\naccess control to the pipeline handler.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h |  4 +++\n src/libcamera/camera.cpp   | 68 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 72 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 786d4d7d66bed5b2..798fee2487940208 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_CAMERA_H__\n #define __LIBCAMERA_CAMERA_H__\n \n+#include <map>\n #include <memory>\n #include <string>\n \n@@ -16,6 +17,7 @@ namespace libcamera {\n \n class PipelineHandler;\n class Stream;\n+class StreamConfiguration;\n \n class Camera final\n {\n@@ -35,6 +37,8 @@ public:\n \tvoid release();\n \n \tstd::vector<Stream> streams() const;\n+\tstd::map<unsigned int, StreamConfiguration> streamConfiguration(const std::vector<Stream> &streams) const;\n+\tint configureStreams(std::map<unsigned int, StreamConfiguration> &config);\n \n private:\n \tCamera(PipelineHandler *pipe, const std::string &name);\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 3b2c00d0a4bb45d1..e41143972b0b537a 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -211,4 +211,72 @@ std::vector<Stream> Camera::streams() const\n \treturn streams_;\n }\n \n+/**\n+ * \\brief Retrieve a group of stream configurations\n+ * \\param[in] streams A map of stream IDs and configurations to setup\n+ *\n+ * Retrieve the camera's configuration for a specified group of streams. The\n+ * caller can specify which of the camera's streams to retrieve configuration\n+ * from by populating \\a streams.\n+ *\n+ * The easiest way to populate the array of streams to fetch configuration from\n+ * is to first retrieve the camera's full array of stream by with streams() and\n+ * then potentially trim it down to only contain the streams the caller\n+ * are interested in.\n+ *\n+ * \\return A map of successfully retrieved stream IDs and configurations or an\n+ * empty list on error.\n+ */\n+std::map<unsigned int, StreamConfiguration>\n+Camera::streamConfiguration(const std::vector<Stream> &streams) const\n+{\n+\tstd::map<unsigned int, StreamConfiguration> config;\n+\n+\tif (disconnected_ || !streams.size())\n+\t\treturn config;\n+\n+\tfor (const Stream &stream : streams)\n+\t\tif (!haveStreamID(stream.id()))\n+\t\t\treturn config;\n+\n+\treturn pipe_->streamConfiguration(this, streams);\n+}\n+\n+/**\n+ * \\brief Configure the camera's streams prior to capture\n+ * \\param[in] config A map of stream IDs and configurations to setup\n+ *\n+ * Prior to starting capture, the camera must be configured to select a\n+ * group of streams to be involved in the capture and their configuration.\n+ * The caller specify which streams are to be involved and their configuration\n+ * by populating \\a config.\n+ *\n+ * The easiest way to populate the array of config is to fetch an initial\n+ * configuration from the camera with streamConfiguration() and then change the\n+ * parameters to fit the callers need and once all the streams parameters are\n+ * configured hand that over to configureStreams() to actually setup the camera.\n+ *\n+ * Exclusive access to the camera shall be ensured by a call to acquire() prior\n+ * to calling this function, otherwise an -EACCES error is be returned.\n+ *\n+ * \\return 0 on success or a negative error code on error.\n+ */\n+int Camera::configureStreams(std::map<unsigned int, StreamConfiguration> &config)\n+{\n+\tif (disconnected_)\n+\t\treturn -ENODEV;\n+\n+\tif (!acquired_)\n+\t\treturn -EACCES;\n+\n+\tif (!config.size())\n+\t\treturn -EINVAL;\n+\n+\tfor (const auto &pair : config)\n+\t\tif (!haveStreamID(pair.first))\n+\t\t\treturn -EINVAL;\n+\n+\treturn pipe_->configureStreams(this, config);\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v3","6/6"]}