{"id":77,"url":"https://patchwork.libcamera.org/api/patches/77/?format=json","web_url":"https://patchwork.libcamera.org/patch/77/","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":"<20181222230041.29999-2-niklas.soderlund@ragnatech.se>","date":"2018-12-22T23:00:30","name":"[libcamera-devel,01/12] libcamera: Add Camera class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0edf331e6314edb44504bfe5222f69c5335521f7","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/77/mbox/","series":[{"id":38,"url":"https://patchwork.libcamera.org/api/series/38/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=38","date":"2018-12-22T23:00:29","name":"Add basic camera enumeration","version":1,"mbox":"https://patchwork.libcamera.org/series/38/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/77/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/77/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 29AC360B31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 Dec 2018 00:02:17 +0100 (CET)","from wyvern.dyn.berto.se (unknown [217.31.177.236])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 90233b24-063d-11e9-9adf-005056917a89;\n\tSun, 23 Dec 2018 00:01:50 +0100 (CET)"],"X-Halon-ID":"90233b24-063d-11e9-9adf-005056917a89","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, 23 Dec 2018 00:00:30 +0100","Message-Id":"<20181222230041.29999-2-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20181222230041.29999-1-niklas.soderlund@ragnatech.se>","References":"<20181222230041.29999-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 01/12] libcamera: Add Camera class","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":"Sat, 22 Dec 2018 23:02:17 -0000"},"content":"Provide a Camera class which represents our main interface to handling\ncamera devices. This is a rework of Kieran's initial proposal and\nLaurent's documentation of the file changed to fit the device\nenumerators needs.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h    | 31 +++++++++++\n include/libcamera/libcamera.h |  2 +\n include/libcamera/meson.build |  1 +\n src/libcamera/camera.cpp      | 97 +++++++++++++++++++++++++++++++++++\n src/libcamera/meson.build     |  1 +\n 5 files changed, 132 insertions(+)\n create mode 100644 include/libcamera/camera.h\n create mode 100644 src/libcamera/camera.cpp","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nnew file mode 100644\nindex 0000000000000000..7622385cc94c11cd\n--- /dev/null\n+++ b/include/libcamera/camera.h\n@@ -0,0 +1,31 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * camera.h - Camera object interface\n+ */\n+#ifndef __LIBCAMERA_CAMERA_H__\n+#define __LIBCAMERA_CAMERA_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+class Camera\n+{\n+public:\n+\tCamera(const std::string &name);\n+\t~Camera();\n+\n+\tconst std::string &name() const;\n+\tvoid get();\n+\tvoid put();\n+\n+private:\n+\tint ref_;\n+\tstd::string name_;\n+};\n+\n+}\n+\n+#endif /* __LIBCAMERA_CAMERA_H__ */\ndiff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h\nindex 790771b61e41e123..44c094d92feed5ba 100644\n--- a/include/libcamera/libcamera.h\n+++ b/include/libcamera/libcamera.h\n@@ -7,6 +7,8 @@\n #ifndef __LIBCAMERA_LIBCAMERA_H__\n #define __LIBCAMERA_LIBCAMERA_H__\n \n+#include <libcamera/camera.h>\n+\n namespace libcamera {\n \n class libcamera\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 8c82675a25d29913..9b266ad926681db9 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_api = files([\n+    'camera.h',\n     'libcamera.h',\n ])\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nnew file mode 100644\nindex 0000000000000000..a85516876ce79ba4\n--- /dev/null\n+++ b/src/libcamera/camera.cpp\n@@ -0,0 +1,97 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * camera.cpp - Camera device\n+ */\n+\n+#include <libcamera/camera.h>\n+\n+#include \"log.h\"\n+\n+/**\n+ * \\file camera.h\n+ * \\brief Camera device handling\n+ *\n+ * At the core of libcamera is the camera device, combining one image source\n+ * with processing hardware able to provide one or multiple image streams. The\n+ * Camera class represents a camera device.\n+ *\n+ * A camera device contains a single image source, and separate camera device\n+ * instances relate to different image sources. For instance, a phone containing\n+ * front and back image sensors will be modelled with two camera devices, one\n+ * for each sensor. When multiple streams can be produced from the same image\n+ * source, all those streams are guaranteed to be part of the same camera\n+ * device.\n+ *\n+ * While not sharing image sources, separate camera devices can share other\n+ * system resources, such as an ISP. For this reason camera device instances may\n+ * not be fully independent, in which case usage restrictions may apply. For\n+ * instance, a phone with a front and a back camera device may not allow usage\n+ * of the two devices simultaneously.\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class Camera\n+ * \\brief Camera device\n+ *\n+ * The Camera class models a camera capable of producing one or more image\n+ * streams from a single image source. It provides the main interface to\n+ * configuring and controlling the device, and capturing image streams. It is\n+ * the central object exposed by libcamera.\n+ */\n+\n+/**\n+ * \\brief Construct a named camera device\n+ *\n+ * \\param[in] name The name to set on the camera device\n+ *\n+ * The caller is responsible for guaranteeing unicity of the camera\n+ * device name.\n+ */\n+Camera::Camera(const std::string &name)\n+\t: ref_(1), name_(name)\n+{\n+\tLOG(Debug) << \"Camera Constructed for \" << name_;\n+}\n+\n+Camera::~Camera()\n+{\n+\tif (ref_)\n+\t\tLOG(Error) << \"Camera Destroyed while still in use!\";\n+\telse\n+\t\tLOG(Debug) << \"Camera Destroyed\";\n+}\n+\n+/**\n+ * \\brief Retrieve the name of the camera\n+ *\n+ * \\return Name of the camera device\n+ */\n+const std::string &Camera::name() const\n+{\n+\treturn name_;\n+}\n+\n+/**\n+ * \\brief Increase the use count of the camera\n+ */\n+void Camera::get()\n+{\n+\tref_++;\n+}\n+\n+/**\n+ * \\brief Decreases the use count of the camera.\n+ *\n+ * When the use count of the camera reaches zero the camera device is deleted.\n+ */\n+void Camera::put()\n+{\n+\tif (--ref_ == 0)\n+\t\tdelete this;\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex f632eb5dd7791ad2..46591069aa5f8beb 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_sources = files([\n+    'camera.cpp',\n     'log.cpp',\n     'main.cpp',\n ])\n","prefixes":["libcamera-devel","01/12"]}