Patch Detail
Show a patch.
GET /api/1.1/patches/437/?format=api
{ "id": 437, "url": "https://patchwork.libcamera.org/api/1.1/patches/437/?format=api", "web_url": "https://patchwork.libcamera.org/patch/437/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190129020048.16774-5-niklas.soderlund@ragnatech.se>", "date": "2019-01-29T02:00:46", "name": "[libcamera-devel,v4,4/6] libcamera: camera: extend camera object to support streams", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f04d3c29f567f8846cb192a5d6b6268a88e0f16f", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/437/mbox/", "series": [ { "id": 153, "url": "https://patchwork.libcamera.org/api/1.1/series/153/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=153", "date": "2019-01-29T02:00:43", "name": "libcamera: add basic support for streams and format configuration", "version": 4, "mbox": "https://patchwork.libcamera.org/series/153/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/437/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/437/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 E98B260DBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jan 2019 03:00:59 +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 b7aded40-2369-11e9-874f-005056917f90;\n\tTue, 29 Jan 2019 03:00:57 +0100 (CET)" ], "X-Halon-ID": "b7aded40-2369-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": "Tue, 29 Jan 2019 03:00:46 +0100", "Message-Id": "<20190129020048.16774-5-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190129020048.16774-1-niklas.soderlund@ragnatech.se>", "References": "<20190129020048.16774-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 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": "Tue, 29 Jan 2019 02:01:00 -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>\n---\n include/libcamera/camera.h | 8 ++++++-\n src/libcamera/camera.cpp | 34 ++++++++++++++++++++++++----\n src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++++--\n src/libcamera/pipeline/uvcvideo.cpp | 5 +++-\n src/libcamera/pipeline/vimc.cpp | 5 +++-\n 5 files changed, 52 insertions(+), 9 deletions(-)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 7e358f8c0aa093cf..3ebb8e96cc63b98a 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+\tstd::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..c8604ec8a8e6eaf4 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+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 d74655d037728feb..f2029d17b4ad0273 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@@ -196,8 +198,11 @@ void PipelineHandlerIPU3::registerCameras()\n \t\tif (link->setEnabled(true))\n \t\t\tcontinue;\n \n+\t\tIPU3CameraData *data = new 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@@ -209,10 +214,10 @@ void PipelineHandlerIPU3::registerCameras()\n \t\t\tLOG(IPU3, Error)\n \t\t\t\t<< \"Failed to register camera[\"\n \t\t\t\t<< numCameras << \"] \\\"\" << cameraName << \"\\\"\";\n+\t\t\tdelete data;\n \t\t\tcontinue;\n \t\t}\n \n-\t\tIPU3CameraData *data = new IPU3CameraData();\n \t\tdata->dev_ = videoDev;\n \t\tsetCameraData(camera.get(),\n \t\t\t std::move(std::unique_ptr<IPU3CameraData>(data)));\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", "v4", "4/6" ] }