Show a patch.

GET /api/patches/415/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 415,
    "url": "https://patchwork.libcamera.org/api/patches/415/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/415/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190127002208.18913-5-niklas.soderlund@ragnatech.se>",
    "date": "2019-01-27T00:22:06",
    "name": "[libcamera-devel,v3,4/6] libcamera: camera: extend camera object to support streams",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "fa1adae7d4e02cd4bb40ff24f7106be637231ce8",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/415/mbox/",
    "series": [
        {
            "id": 144,
            "url": "https://patchwork.libcamera.org/api/series/144/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=144",
            "date": "2019-01-27T00:22:04",
            "name": "libcamera: add basic support for streams and format configuration",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/144/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/415/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/415/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 F0EF960C7D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Jan 2019 01:22:57 +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 af5040c7-21c9-11e9-874f-005056917f90;\n\tSun, 27 Jan 2019 01:22:54 +0100 (CET)"
        ],
        "X-Halon-ID": "af5040c7-21c9-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": "Sun, 27 Jan 2019 01:22:06 +0100",
        "Message-Id": "<20190127002208.18913-5-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190127002208.18913-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190127002208.18913-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 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": "Sun, 27 Jan 2019 00:22:58 -0000"
    },
    "content": "A camera consist of one or more video streams origination from the same\nvideo source. The different streams could for example have access to\ndifferent hardware blocks in the video pipeline and therefor be able to\nprocess the video source in different ways.\n\nAll static information describing each streams needs 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\nmight 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           | 10 ++++-\n src/libcamera/camera.cpp             | 55 ++++++++++++++++++++++++++--\n src/libcamera/pipeline/ipu3/ipu3.cpp |  4 +-\n src/libcamera/pipeline/uvcvideo.cpp  |  4 +-\n src/libcamera/pipeline/vimc.cpp      |  4 +-\n 5 files changed, 69 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 7e358f8c0aa093cf..786d4d7d66bed5b2 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@@ -39,10 +43,14 @@ private:\n \tfriend class PipelineHandler;\n \tvoid disconnect();\n \n+\tbool haveStreamID(unsigned int id) const;\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..3b2c00d0a4bb45d1 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 shall provide\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,19 @@ 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+\tfor (const Stream &stream : streams) {\n+\t\tif (camera->haveStreamID(stream.id())) {\n+\t\t\tLOG(Camera, Error) << \"Duplication of stream ID\";\n+\t\t\tcamera.reset();\n+\t\t\tbreak;\n+\t\t}\n+\t\tcamera->streams_.push_back(stream);\n+\t}\n+\n+\treturn camera;\n }\n \n /**\n@@ -102,7 +117,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,10 +141,24 @@ 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+/**\n+ * \\brief Check if camera have a stream ID\n+ * \\param[in] id Stream ID to check for\n+ * \\return ture if stream ID exists, else false\n+ */\n+bool Camera::haveStreamID(unsigned int id) const\n+{\n+\tfor (const Stream &stream : streams_)\n+\t\tif (stream.id() == id)\n+\t\t\treturn true;\n+\n+\treturn false;\n+}\n+\n /**\n  * \\brief Acquire the camera device for exclusive access\n  *\n@@ -164,4 +194,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 support\n+ * and each streams capabilities.\n+ *\n+ * \\return An array of all the camera's streams or an empty list on error.\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..dbb2a89163c36cbc 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@@ -197,7 +198,8 @@ void PipelineHandlerIPU3::registerCameras()\n \t\t\tcontinue;\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{ Stream(0) };\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\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex c51e8bc1f2c2bf25..bc4a8d7236be589d 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@@ -64,7 +65,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(0) };\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..c426a953aea1b3dd 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@@ -56,7 +57,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(0) };\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",
        "v3",
        "4/6"
    ]
}