{"id":457,"url":"https://patchwork.libcamera.org/api/1.1/patches/457/?format=json","web_url":"https://patchwork.libcamera.org/patch/457/","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":"<20190131181853.23739-5-niklas.soderlund@ragnatech.se>","date":"2019-01-31T18:18:51","name":"[libcamera-devel,v6,4/6] libcamera: camera: extend camera object to support streams","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8882c18bf32712a9296cecffe6e6d27402edf648","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/457/mbox/","series":[{"id":157,"url":"https://patchwork.libcamera.org/api/1.1/series/157/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=157","date":"2019-01-31T18:18:47","name":"libcamera: add basic support for streams and format configuration MIME-Version: 1.0","version":6,"mbox":"https://patchwork.libcamera.org/series/157/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/457/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/457/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 80FFE60DBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 31 Jan 2019 19:19:19 +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 b756cbf5-2584-11e9-b5ae-0050569116f7;\n\tThu, 31 Jan 2019 19:19:17 +0100 (CET)"],"X-Halon-ID":"b756cbf5-2584-11e9-b5ae-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":"Thu, 31 Jan 2019 19:18:51 +0100","Message-Id":"<20190131181853.23739-5-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190131181853.23739-1-niklas.soderlund@ragnatech.se>","References":"<20190131181853.23739-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 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":"Thu, 31 Jan 2019 18:19:19 -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 streams 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/camera.h           |  7 ++++++-\n src/libcamera/camera.cpp             | 26 ++++++++++++++++++++++++--\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, 44 insertions(+), 7 deletions(-)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 7e358f8c0aa093cf..d796ce32cc9a6fff 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,6 +45,7 @@ private:\n \n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::string name_;\n+\tstd::vector<Stream *> streams_;\n \n \tbool acquired_;\n };\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 500976b237bcbd2d..49f49fb71c11e124 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@@ -164,4 +172,18 @@ 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+ * supports and the capabilities of each stream.\n+ *\n+ * \\return An array of all the camera's streams.\n+ */\n+const std::vector<Stream *> &Camera::streams() const\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 2ebdb2b9eb880174..d2d3a1edf6a9f53a 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 \"log.h\"\n@@ -28,6 +29,7 @@ public:\n private:\n \tstd::shared_ptr<MediaDevice> media_;\n \tV4L2Device *video_;\n+\tStream stream_;\n };\n \n PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)\n@@ -70,7 +72,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","v6","4/6"]}