{"id":452,"url":"https://patchwork.libcamera.org/api/patches/452/?format=json","web_url":"https://patchwork.libcamera.org/patch/452/","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":"<20190130115615.17362-7-niklas.soderlund@ragnatech.se>","date":"2019-01-30T11:56:15","name":"[libcamera-devel,v5,6/6] libcamera: camera: extend camera object to support configuration of streams","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"885f850ce6a3908280cc84d5a266d88963c100ff","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/452/mbox/","series":[{"id":156,"url":"https://patchwork.libcamera.org/api/series/156/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=156","date":"2019-01-30T11:56:09","name":"libcamera: add basic support for streams and format configuration","version":5,"mbox":"https://patchwork.libcamera.org/series/156/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/452/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/452/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 4E45560B2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Jan 2019 12:57:05 +0100 (CET)","from wyvern.c.hoisthospitality.com (unknown [217.64.245.162])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 26407874-2486-11e9-911a-0050569116f7;\n\tWed, 30 Jan 2019 12:57:03 +0100 (CET)"],"X-Halon-ID":"26407874-2486-11e9-911a-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":"Wed, 30 Jan 2019 12:56:15 +0100","Message-Id":"<20190130115615.17362-7-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190130115615.17362-1-niklas.soderlund@ragnatech.se>","References":"<20190130115615.17362-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 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":"Wed, 30 Jan 2019 11:57:05 -0000"},"content":"Extend the camera to support reading and configuring 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   | 61 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 01498935ae4aab58..b21d116edc0f3a57 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 \tconst std::vector<Stream *> streams() const;\n+\tstd::map<Stream*, StreamConfiguration> streamConfiguration(std::vector<Stream*> &streams);\n+\tint configureStreams(std::map<Stream*, 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 986b74407aed6bd2..a293350f731e18df 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -190,4 +190,65 @@ const 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 specifies 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<Stream*, StreamConfiguration>\n+Camera::streamConfiguration(std::vector<Stream*> &streams)\n+{\n+\tif (disconnected_ || !streams.size())\n+\t\tstd::map<unsigned int, StreamConfiguration>{};\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 specifies 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 caller's 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+ * \\retval -ENODEV The camera is not connected to any hardware\n+ * \\retval -EACCES The user have not acquired exclusive access to the camera\n+ * \\retval -EINVAL The configuration is not valid\n+ */\n+int Camera::configureStreams(std::map<Stream*, 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+\treturn pipe_->configureStreams(this, config);\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v5","6/6"]}