Patch Detail
Show a patch.
GET /api/1.1/patches/4028/?format=api
{ "id": 4028, "url": "https://patchwork.libcamera.org/api/1.1/patches/4028/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4028/", "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": "<20200611171528.9381-6-email@uajain.com>", "date": "2020-06-11T17:16:07", "name": "[libcamera-devel,v4,5/6] qcam: main_window: Introduce initial hotplug support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "0cfae39d6d7dc6c0adc9ed57d865b4534245f793", "submitter": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/people/1/?format=api", "name": "Umang Jain", "email": "email@uajain.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/4028/mbox/", "series": [ { "id": 993, "url": "https://patchwork.libcamera.org/api/1.1/series/993/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=993", "date": "2020-06-11T17:16:02", "name": "Introduce UVC hotplugging support", "version": 4, "mbox": "https://patchwork.libcamera.org/series/993/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4028/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4028/checks/", "tags": {}, "headers": { "Return-Path": "<bounces+15657259-5c31-libcamera-devel=lists.libcamera.org@em7280.uajain.com>", "Received": [ "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EEF161DFC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Jun 2020 19:16:07 +0200 (CEST)", "by filterdrecv-p3iad2-784dbb6bd8-6snds with SMTP id\n\tfilterdrecv-p3iad2-784dbb6bd8-6snds-19-5EE266D6-83\n\t2020-06-11 17:16:06.927259659 +0000 UTC m=+680958.357246709", "from mail.uajain.com (unknown)\n\tby ismtpd0008p1maa1.sendgrid.net (SG) with ESMTP\n\tid qY0nuwV4QSyqTiQxjTeDYA Thu, 11 Jun 2020 17:16:06.451 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=uajain.com\n\theader.i=@uajain.com header.b=\"oCXxs9BS\"; \n\tdkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=HBjEdPx/lhdtvyjmpXvqfUD2vSMUlvrIpG19HuvHFEg=;\n\tb=oCXxs9BSoIy2AC94FyfS+4kffIZ0LDwpGH0uGn0S2I2fH8qIAKXxy/2z1LepDSNEmrEK\n\tXJH+DQhll21xOtMEz/WVtiyeQnocFBq9DjjpPQMXVqdjLZyWo1dHcTEic8ZUFTGTeaoxQE\n\th/dfvJIgb59z+io7tIwoGs331eSdFCLeQ=", "From": "Umang Jain <email@uajain.com>", "Date": "Thu, 11 Jun 2020 17:16:07 +0000 (UTC)", "Message-Id": "<20200611171528.9381-6-email@uajain.com>", "In-Reply-To": "<20200611171528.9381-1-email@uajain.com>", "References": "<20200611171528.9381-1-email@uajain.com>", "Mime-Version": "1.0", "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPc4om/Oij3lMEQBxKPi/30Oz/DwSQ6C97TnwZl55Mgdu1vHj4ACGu6c9ssDkHq3vZAUZCBbkOtIYFPbf8pH/IG+2A9W51daH+NkONGw4JYwKJhIFg4YkXPbTHuKhXcaU+pGBAROzEFTCuYYZYoglk/PE0BR9t3dztqSe+s1+fx6GAjxgzKFB68PpH7gE9RtLOb0w1keQxQObdony+EdeBgiA==", "To": "laurent.pinchart@ideasonboard.com, libcamera-devel@lists.libcamera.org", "Content-Transfer-Encoding": "7bit", "Content-Type": "text/plain; charset=us-ascii", "Subject": "[libcamera-devel] [PATCH v4 5/6] qcam: main_window: Introduce\n\tinitial hotplug support", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "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, 11 Jun 2020 17:16:08 -0000" }, "content": "Hook up various QCam UI bits with hotplug support introduced\nin previous commits. This looks good-enough as first steps\nto see how the hotplugging functionality is turning out to be\nfrom application point-of-view.\n\nOne can still think of few edge case nuances not yet covered\nunder this implementation hence, those are intentionally\nkept out of scope for now. It might require some thinking\nand/or additional time on hand.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/qcam/main_window.cpp | 76 ++++++++++++++++++++++++++++++++++++++++\n src/qcam/main_window.h | 6 ++++\n 2 files changed, 82 insertions(+)", "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 2960259..7bc1360 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -59,6 +59,36 @@ public:\n \t}\n };\n \n+/**\n+ * \\brief Custom QEvent to signal hotplug or unplug\n+ */\n+class HotplugEvent : public QEvent\n+{\n+public:\n+\tenum PlugEvent {\n+\t\tHotPlug,\n+\t\tHotUnplug\n+\t};\n+\n+\tHotplugEvent(std::shared_ptr<Camera> camera, PlugEvent event)\n+\t\t: QEvent(type()), camera_(std::move(camera)), plugEvent_(event)\n+\t{\n+\t}\n+\n+\tstatic Type type()\n+\t{\n+\t\tstatic int type = QEvent::registerEventType();\n+\t\treturn static_cast<Type>(type);\n+\t}\n+\n+\tPlugEvent hotplugEvent() const { return plugEvent_; }\n+\tCamera *camera() const { return camera_.get(); }\n+\n+private:\n+\tstd::shared_ptr<Camera> camera_;\n+\tPlugEvent plugEvent_;\n+};\n+\n MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \t: saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr),\n \t isCapturing_(false), captureRaw_(false)\n@@ -81,6 +111,10 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \tsetCentralWidget(viewfinder_);\n \tadjustSize();\n \n+\t/* Hotplug/unplug support */\n+\tcm_->cameraAdded.connect(this, &MainWindow::addCamera);\n+\tcm_->cameraRemoved.connect(this, &MainWindow::removeCamera);\n+\n \t/* Open the camera and start capture. */\n \tret = openCamera();\n \tif (ret < 0) {\n@@ -105,6 +139,9 @@ bool MainWindow::event(QEvent *e)\n \tif (e->type() == CaptureEvent::type()) {\n \t\tprocessCapture();\n \t\treturn true;\n+\t} else if (e->type() == HotplugEvent::type()) {\n+\t\tprocessHotplug(static_cast<HotplugEvent *>(e));\n+\t\treturn true;\n \t}\n \n \treturn QMainWindow::event(e);\n@@ -535,6 +572,45 @@ void MainWindow::stopCapture()\n \tsetWindowTitle(title_);\n }\n \n+/* -----------------------------------------------------------------------------\n+ * Camera hotplugging support\n+ */\n+\n+void MainWindow::processHotplug(HotplugEvent *e)\n+{\n+\tCamera *camera = e->camera();\n+\tHotplugEvent::PlugEvent event = e->hotplugEvent();\n+\n+\tif (event == HotplugEvent::HotPlug) {\n+\t\tcameraCombo_->addItem(QString::fromStdString(camera->name()));\n+\t} else if (event == HotplugEvent::HotUnplug) {\n+\t\t/* Check if the currently-streaming camera is removed. */\n+\t\tif (camera == camera_.get()) {\n+\t\t\ttoggleCapture(false);\n+\t\t\tcameraCombo_->setCurrentIndex(0);\n+\t\t}\n+\n+\t\tint camIndex = cameraCombo_->findText(QString::fromStdString(camera->name()));\n+\t\tcameraCombo_->removeItem(camIndex);\n+\t}\n+}\n+\n+void MainWindow::addCamera(std::shared_ptr<Camera> camera)\n+{\n+\tqInfo() << \"Adding new camera:\" << camera->name().c_str();\n+\tQCoreApplication::postEvent(this,\n+\t\t\t\t new HotplugEvent(std::move(camera),\n+\t\t\t\t\t\t HotplugEvent::HotPlug));\n+}\n+\n+void MainWindow::removeCamera(std::shared_ptr<Camera> camera)\n+{\n+\tqInfo() << \"Removing camera:\" << camera->name().c_str();\n+\tQCoreApplication::postEvent(this,\n+\t\t\t\t new HotplugEvent(std::move(camera),\n+\t\t\t\t\t\t HotplugEvent::HotUnplug));\n+}\n+\n /* -----------------------------------------------------------------------------\n * Image Save\n */\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 59fa2d9..4606fe4 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -32,6 +32,8 @@ using namespace libcamera;\n class QAction;\n class QComboBox;\n \n+class HotplugEvent;\n+\n enum {\n \tOptCamera = 'c',\n \tOptHelp = 'h',\n@@ -87,8 +89,12 @@ private:\n \tint startCapture();\n \tvoid stopCapture();\n \n+\tvoid addCamera(std::shared_ptr<Camera> camera);\n+\tvoid removeCamera(std::shared_ptr<Camera> camera);\n+\n \tvoid requestComplete(Request *request);\n \tvoid processCapture();\n+\tvoid processHotplug(HotplugEvent *e);\n \tvoid processViewfinder(FrameBuffer *buffer);\n \n \t/* UI elements */\n", "prefixes": [ "libcamera-devel", "v4", "5/6" ] }