{"id":450,"url":"https://patchwork.libcamera.org/api/1.1/patches/450/?format=json","web_url":"https://patchwork.libcamera.org/patch/450/","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":"<20190130115615.17362-5-niklas.soderlund@ragnatech.se>","date":"2019-01-30T11:56:13","name":"[libcamera-devel,v5,4/6] libcamera: camera: extend camera object to support streams","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a73cbc2d047b8d4cf1c6efd7a9bc754e4b83e44f","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/450/mbox/","series":[{"id":156,"url":"https://patchwork.libcamera.org/api/1.1/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/450/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/450/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 88D7060B2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Jan 2019 12:56:57 +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 20d14117-2486-11e9-911a-0050569116f7;\n\tWed, 30 Jan 2019 12:56:55 +0100 (CET)"],"X-Halon-ID":"20d14117-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:13 +0100","Message-Id":"<20190130115615.17362-5-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 4/6] libcamera: camera: extend camera\n\tobject to support 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:56:57 -0000"},"content":"A camera consists of one or more video streams originating from the same\nvideo source. The different streams could for example have access to\ndifferent hardware blocks in the video pipeline and therefore be able to\nprocess the video source in different ways.\n\nAll static information describing each stream need to be recorded at\ncamera creation. After a camera is created an application can retrieve\nthe static information about its stream at any time.\n\nUpdate all pipeline handlers to register one stream per camera, this\nwill be extended in the future for some of the pipelines.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/camera.h           |  8 ++++++-\n src/libcamera/camera.cpp             | 34 ++++++++++++++++++++++++----\n src/libcamera/pipeline/ipu3/ipu3.cpp |  8 +++++--\n src/libcamera/pipeline/uvcvideo.cpp  |  5 +++-\n src/libcamera/pipeline/vimc.cpp      |  5 +++-\n 5 files changed, 51 insertions(+), 9 deletions(-)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 7e358f8c0aa093cf..01498935ae4aab58 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -15,12 +15,14 @@\n namespace libcamera {\n \n class PipelineHandler;\n+class Stream;\n \n class Camera final\n {\n public:\n \tstatic std::shared_ptr<Camera> create(PipelineHandler *pipe,\n-\t\t\t\t\t      const std::string &name);\n+\t\t\t\t\t      const std::string &name,\n+\t\t\t\t\t      const std::vector<Stream *> &streams);\n \n \tCamera(const Camera &) = delete;\n \tvoid operator=(const Camera &) = delete;\n@@ -32,6 +34,8 @@ public:\n \tint acquire();\n \tvoid release();\n \n+\tconst std::vector<Stream *> streams() const;\n+\n private:\n \tCamera(PipelineHandler *pipe, const std::string &name);\n \t~Camera();\n@@ -41,8 +45,10 @@ private:\n \n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::string name_;\n+\tstd::vector<Stream *> streams_;\n \n \tbool acquired_;\n+\tbool disconnected_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 500976b237bcbd2d..986b74407aed6bd2 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include <libcamera/camera.h>\n+#include <libcamera/stream.h>\n \n #include \"log.h\"\n #include \"pipeline_handler.h\"\n@@ -56,13 +57,15 @@ LOG_DECLARE_CATEGORY(Camera)\n  * \\brief Create a camera instance\n  * \\param[in] name The name of the camera device\n  * \\param[in] pipe The pipeline handler responsible for the camera device\n+ * \\param[in] streams Array of streams the camera provides\n  *\n  * The caller is responsible for guaranteeing unicity of the camera name.\n  *\n  * \\return A shared pointer to the newly created camera object\n  */\n std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n-\t\t\t\t       const std::string &name)\n+\t\t\t\t       const std::string &name,\n+\t\t\t\t       const std::vector<Stream *> &streams)\n {\n \tstruct Allocator : std::allocator<Camera> {\n \t\tvoid construct(void *p, PipelineHandler *pipe,\n@@ -76,7 +79,12 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n \t\t}\n \t};\n \n-\treturn std::allocate_shared<Camera>(Allocator(), pipe, name);\n+\tstd::shared_ptr<Camera> camera =\n+\t\tstd::allocate_shared<Camera>(Allocator(), pipe, name);\n+\n+\tcamera->streams_ = streams;\n+\n+\treturn camera;\n }\n \n /**\n@@ -102,7 +110,8 @@ const std::string &Camera::name() const\n  */\n \n Camera::Camera(PipelineHandler *pipe, const std::string &name)\n-\t: pipe_(pipe->shared_from_this()), name_(name), acquired_(false)\n+\t: pipe_(pipe->shared_from_this()), name_(name), acquired_(false),\n+\t  disconnected_(false)\n {\n }\n \n@@ -125,7 +134,7 @@ void Camera::disconnect()\n {\n \tLOG(Camera, Debug) << \"Disconnecting camera \" << name_;\n \n-\t/** \\todo Block API calls when they will be implemented. */\n+\tdisconnected_ = true;\n \tdisconnected.emit(this);\n }\n \n@@ -164,4 +173,21 @@ void Camera::release()\n \tacquired_ = false;\n }\n \n+/**\n+ * \\brief Retrieve all the camera's stream information\n+ *\n+ * Retrieve all of the camera's static stream information. The static\n+ * information describes among other things how many streams the camera\n+ * support and each streams capabilities.\n+ *\n+ * \\return An array of all the camera's streams valid streams.\n+ */\n+const std::vector<Stream *> Camera::streams() const\n+{\n+\tif (disconnected_)\n+\t\treturn std::vector<Stream *>{};\n+\n+\treturn streams_;\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 80f4a7bffee52948..52844da78419943d 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -9,6 +9,7 @@\n #include <vector>\n \n #include <libcamera/camera.h>\n+#include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n #include \"log.h\"\n@@ -37,6 +38,7 @@ private:\n \t\t\t: dev_(nullptr) {}\n \t\t~IPU3CameraData() { delete dev_; }\n \t\tV4L2Device *dev_;\n+\t\tStream stream_;\n \t};\n \n \tstd::shared_ptr<MediaDevice> cio2_;\n@@ -202,15 +204,17 @@ void PipelineHandlerIPU3::registerCameras()\n \t\tif (link->setEnabled(true))\n \t\t\tcontinue;\n \n+\t\tstd::unique_ptr<IPU3CameraData> data = utils::make_unique<IPU3CameraData>();\n+\n \t\tstd::string cameraName = sensor->name() + \" \" + std::to_string(id);\n-\t\tstd::shared_ptr<Camera> camera = Camera::create(this, cameraName);\n+\t\tstd::vector<Stream *> streams{ &data->stream_ };\n+\t\tstd::shared_ptr<Camera> camera = Camera::create(this, cameraName, streams);\n \n \t\t/*\n \t\t * If V4L2 device creation fails, the Camera instance won't be\n \t\t * registered. The 'camera' shared pointer goes out of scope\n \t\t * and deletes the Camera it manages.\n \t\t */\n-\t\tstd::unique_ptr<IPU3CameraData> data = utils::make_unique<IPU3CameraData>();\n \t\tdata->dev_ = createVideoDevice(id);\n \t\tif (!data->dev_) {\n \t\t\tLOG(IPU3, Error)\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex c51e8bc1f2c2bf25..8ea7ac74d2a5395d 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include <libcamera/camera.h>\n+#include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n #include \"media_device.h\"\n@@ -25,6 +26,7 @@ public:\n private:\n \tstd::shared_ptr<MediaDevice> media_;\n \tV4L2Device *video_;\n+\tStream stream_;\n };\n \n PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)\n@@ -64,7 +66,8 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n-\tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model());\n+\tstd::vector<Stream *> streams{ &stream_ };\n+\tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model(), streams);\n \tregisterCamera(std::move(camera));\n \thotplugMediaDevice(media_.get());\n \ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex f58a97d51619515d..9e1cf11a20c7a7e3 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include <libcamera/camera.h>\n+#include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n #include \"media_device.h\"\n@@ -23,6 +24,7 @@ public:\n \n private:\n \tstd::shared_ptr<MediaDevice> media_;\n+\tStream stream_;\n };\n \n PipeHandlerVimc::PipeHandlerVimc(CameraManager *manager)\n@@ -56,7 +58,8 @@ bool PipeHandlerVimc::match(DeviceEnumerator *enumerator)\n \n \tmedia_->acquire();\n \n-\tstd::shared_ptr<Camera> camera = Camera::create(this, \"Dummy VIMC Camera\");\n+\tstd::vector<Stream *> streams{ &stream_ };\n+\tstd::shared_ptr<Camera> camera = Camera::create(this, \"Dummy VIMC Camera\", streams);\n \tregisterCamera(std::move(camera));\n \n \treturn true;\n","prefixes":["libcamera-devel","v5","4/6"]}