Patch Detail
Show a patch.
GET /api/1.1/patches/192/?format=api
{ "id": 192, "url": "https://patchwork.libcamera.org/api/1.1/patches/192/?format=api", "web_url": "https://patchwork.libcamera.org/patch/192/", "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": "<20190108204733.10823-3-jacopo@jmondi.org>", "date": "2019-01-08T20:47:32", "name": "[libcamera-devel,v3,2/3] libcamera: media_device: Add functions to get a MediaLink", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "74bd5f707ea91211cbf1deee70e97cd4e3faefc4", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/192/mbox/", "series": [ { "id": 63, "url": "https://patchwork.libcamera.org/api/1.1/series/63/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=63", "date": "2019-01-08T20:47:30", "name": "libcamera: media device: Add link handling", "version": 3, "mbox": "https://patchwork.libcamera.org/series/63/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/192/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/192/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A3FCD60B30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Jan 2019 21:47:33 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 3828F4000A;\n\tTue, 8 Jan 2019 20:47:33 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Jan 2019 21:47:32 +0100", "Message-Id": "<20190108204733.10823-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190108204733.10823-1-jacopo@jmondi.org>", "References": "<20190108204733.10823-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 2/3] libcamera: media_device: Add\n\tfunctions to get a MediaLink", "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, 08 Jan 2019 20:47:33 -0000" }, "content": "Add three overloaded functions 'link()' to retrieve a link between two\npads. Each overloaded implementation exposes a different method to\nidentify the source and sink pads.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/media_device.h | 6 +++\n src/libcamera/media_device.cpp | 80 ++++++++++++++++++++++++++++\n 2 files changed, 86 insertions(+)", "diff": "diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h\nindex 9f45fc7..22c32b7 100644\n--- a/src/libcamera/include/media_device.h\n+++ b/src/libcamera/include/media_device.h\n@@ -40,6 +40,12 @@ public:\n \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n \tMediaEntity *getEntityByName(const std::string &name) const;\n \n+\tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n+\t\t\tconst std::string &sinkName, unsigned int sinkIdx);\n+\tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n+\t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n+\tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n+\n private:\n \tstd::string driver_;\n \tstd::string devnode_;\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex b0d10ed..ca12caa 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -306,6 +306,86 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n \treturn nullptr;\n }\n \n+/**\n+ * \\brief Retrieve the MediaLink connecting two pads, identified by entity\n+ * names and pad indexes\n+ * \\param sourceName The source entity name\n+ * \\param sourceIdx The index of the source pad\n+ * \\param sinkName The sink entity name\n+ * \\param sinkIdx The index of the sink pad\n+ *\n+ * Find the link that connects the pads at index \\a sourceIdx of the source\n+ * entity with name \\a sourceName, to the pad at index \\a sinkIdx of the\n+ * sink entity with name \\a sinkName, if any.\n+ *\n+ * \\sa MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx, const MediaEntity *sink, unsigned int sinkIdx) const\n+ * \\sa MediaDevice::link(const MediaPad *source, const MediaPad *sink) const\n+ *\n+ * \\return The link that connects the two pads, or nullptr if no such a link\n+ * exists\n+ */\n+MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx,\n+\t\t\t const std::string &sinkName, unsigned int sinkIdx)\n+{\n+\tconst MediaEntity *source = getEntityByName(sourceName);\n+\tconst MediaEntity *sink = getEntityByName(sinkName);\n+\tif (!source || !sink)\n+\t\treturn nullptr;\n+\n+\treturn link(source, sourceIdx, sink, sinkIdx);\n+}\n+\n+/**\n+ * \\brief Retrieve the MediaLink connecting two pads, identified by the\n+ * entities they belong to and pad indexes\n+ * \\param source The source entity\n+ * \\param sourceIdx The index of the source pad\n+ * \\param sink The sink entity\n+ * \\param sinkIdx The index of the sink pad\n+ *\n+ * Find the link that connects the pads at index \\a sourceIdx of the source\n+ * entity \\a source, to the pad at index \\a sinkIdx of the sink entity \\a\n+ * sink, if any.\n+ *\n+ * \\sa MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx, const std::string &sinkName, unsigned int sinkIdx) const\n+ * \\sa MediaDevice::link(const MediaPad *source, const MediaPad *sink) const\n+ *\n+ * \\return The link that connects the two pads, or nullptr if no such a link\n+ * exists\n+ */\n+MediaLink *MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx,\n+\t\t\t const MediaEntity *sink, unsigned int sinkIdx)\n+{\n+\n+\tconst MediaPad *sourcePad = source->getPadByIndex(sourceIdx);\n+\tconst MediaPad *sinkPad = sink->getPadByIndex(sinkIdx);\n+\tif (!sourcePad || !sinkPad)\n+\t\treturn nullptr;\n+\n+\treturn link(sourcePad, sinkPad);\n+}\n+\n+/**\n+ * \\brief Retrieve the MediaLink that connects two pads\n+ * \\param source The source pad\n+ * \\param sink The sink pad\n+ *\n+ * \\sa MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx, const std::string &sinkName, unsigned int sinkIdx) const\n+ * \\sa MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx, const MediaEntity *sink, unsigned int sinkIdx) const\n+ *\n+ * \\return The link that connects the two pads, or nullptr if no such a link\n+ * exists\n+ */\n+MediaLink *MediaDevice::link(const MediaPad *source, const MediaPad *sink)\n+{\n+\tfor (MediaLink *link : source->links()) {\n+\t\tif (link->sink()->id() == sink->id())\n+\t\t\treturn link;\n+\t}\n+\n+\treturn nullptr;\n+}\n+\n /**\n * \\var MediaDevice::objects_\n * \\brief Global map of media objects (entities, pads, links) keyed by their\n", "prefixes": [ "libcamera-devel", "v3", "2/3" ] }