Show a patch.

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

{
    "id": 16810,
    "url": "https://patchwork.libcamera.org/api/patches/16810/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16810/",
    "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": "<20220726194123.170208-2-utkarsh02t@gmail.com>",
    "date": "2022-07-26T19:41:22",
    "name": "[libcamera-devel,v5,2/3] qcam: Add a GUI way to use capture script",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "664b72504cb948689087634377ea979ac71614d6",
    "submitter": {
        "id": 114,
        "url": "https://patchwork.libcamera.org/api/people/114/?format=api",
        "name": "Utkarsh Tiwari",
        "email": "utkarsh02t@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16810/mbox/",
    "series": [
        {
            "id": 3330,
            "url": "https://patchwork.libcamera.org/api/series/3330/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3330",
            "date": "2022-07-26T19:38:56",
            "name": "Introduce capture scripts to qcam",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/3330/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16810/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16810/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B17BEC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jul 2022 19:41:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6953463315;\n\tTue, 26 Jul 2022 21:41:49 +0200 (CEST)",
            "from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com\n\t[IPv6:2607:f8b0:4864:20::102f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46FB160487\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 21:41:48 +0200 (CEST)",
            "by mail-pj1-x102f.google.com with SMTP id b10so14349302pjq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 12:41:48 -0700 (PDT)",
            "from localhost.localdomain ([2404:bd00:3:d6bf:24ea:3f52:4c78:7bd8])\n\tby smtp.gmail.com with ESMTPSA id\n\ta5-20020aa794a5000000b0052ac1af926fsm12017782pfl.20.2022.07.26.12.41.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 26 Jul 2022 12:41:46 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658864509;\n\tbh=B/wjX/CiabQtTbA2lH4jK0Q9SRy7gRPZ7b6EznReXrk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=xd8v+ujh9TM6yU0PtHUMXuGRTOEYJZOB441uHRtqkkbiHfgothWjOKdNx1/+EeTJe\n\tTAb23YTAKgX7asvD/rG8MohjGb6wIWgSt+OcNgrxWYZr/sYAayPtAQhINpuV6cmGko\n\tC8WPFDpnK1MeB4EXAcxmqghAtVpCNpf78ydbN4zKY4ZhtRh7+051yEuhm2VDFa0hbj\n\tpLx/xqZMZfTop+h0qEZHYWE7VxUBuc+N+A+Ml5x1pPfAZqzt8K3w8KJuAkG4K2vazz\n\tvLZqYvljetUin2JJGmUV1YohURiyu4Z4HTrHlreVizxRr0nI33HPNbHZOd9uvSCd4Q\n\taRLFkgf6ZgVcA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=3ngs0oX40Iiqxk9DsOXNqG4eDRWgWD07yRSe0zd2ziA=;\n\tb=kqMS5IfUiQb5QQfvojsH1gkpqQ7529LNBbfH/8Zi8+twwTIqmkGMBPdAQS3qFC0aaI\n\tCQvTOwu+al9xeXV6ibqZAerKJ8kbm/02ctOhYSYqKCwXErxG/PZP0nIWuKSlzdVp9XDv\n\t579dLGvNORPhndz/i8fD+Ilgrz89VtHVYBnVMjt71Ou1p4XdYDsB6tQw1L+VENk6z2z2\n\tc85n3Kr80ToWEi+IBFitHdMGYUlEfg73YJbwRWVEa4kFdwYhYH+MKTuB5uCveHsrcHEt\n\to034jhwWrkWcEQ0yyMylkcnf1m2p34wAVeV1OAKfI9lr+0igmJ8DKfku6fWIfrK6XwGf\n\tCKcw=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kqMS5IfU\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=3ngs0oX40Iiqxk9DsOXNqG4eDRWgWD07yRSe0zd2ziA=;\n\tb=5F0LemjGtS+HfgO9C2z+2TriwEXq5K9bWCkUKUAwiWoBbBdLddQDxkPZg5LVcVpa5S\n\tbrPBAgtauZdp/n36Xmy5vpuuQG0HtfCO4VCY3yr4j9zAYtsv4dpHvuNiwFnfTt4mU/S6\n\tqeDDR2NvoydeSK1t7skB0e6xFVdwmMMv9oTfV/Tu0dRAlw6s4VGrMGGC39Iqkg7y5sa/\n\tvIOWrOVjRjGKDNgxgcAmzoislhsLlkKQqsi4edEkwWcWEjxzV+k3KKdMlrBevEWB75V+\n\ttceFOusoZADkdcJF9rl5vyHn+AxeZTpjBZMF233uXA7szcwO2nbCkoTSWd8PUy1+Ra3c\n\tKvvw==",
        "X-Gm-Message-State": "AJIora+Br/PRwSPjlAWkgIuKarRJ0yc6HxlacuB5B02zjJdUwIPBhw6t\n\tVSZBPXChQkVop1j5NLo0jL6WE1F0AZI=",
        "X-Google-Smtp-Source": "AGRyM1vHOkfj+GCNuOneR0RTk3WTYZME4YN5rbG6aXfVEYm3dT1rfEXO/mqMDMaJfKtdU14Td20eKw==",
        "X-Received": "by 2002:a17:903:32c6:b0:16d:328f:898d with SMTP id\n\ti6-20020a17090332c600b0016d328f898dmr17828612plr.143.1658864506585; \n\tTue, 26 Jul 2022 12:41:46 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 27 Jul 2022 01:11:22 +0530",
        "Message-Id": "<20220726194123.170208-2-utkarsh02t@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220726194123.170208-1-utkarsh02t@gmail.com>",
        "References": "<20220726194123.170208-1-utkarsh02t@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 2/3] qcam: Add a GUI way to use capture\n\tscript",
        "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>",
        "From": "Utkarsh Tiwari via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Utkarsh Tiwari <utkarsh02t@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Implement an Open Capture Script button which would allow the user\nto open a Capture Script (*.yaml).\nThis button has two states :\n    - Open Capture Script\n    - Stop the execution of current capture script\n\nWhen being clicked in open state, present them with a QFileDialog to\nallow user to select a single file.\n\nIntroduce a queueCount_ to keep track of the requests queued.\n\nWhen stopping the execution of the capture script the queueCount_ is not\nreseted and the capture is continues as it is (i.e it is not stopped or\nrestarted).\n\nRequests are queued with any controls the script matching the current\nqueueCount_.\n\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n Changes from v4\n\t- Reworded the commit message to clarify button states and\n\tqueueCount_ reseting.\n\n src/qcam/assets/feathericons/feathericons.qrc |  2 +\n src/qcam/main_window.cpp                      | 68 +++++++++++++++++++\n src/qcam/main_window.h                        |  6 ++\n src/qcam/meson.build                          |  2 +\n 4 files changed, 78 insertions(+)",
    "diff": "diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc\nindex c5302040..6b08395a 100644\n--- a/src/qcam/assets/feathericons/feathericons.qrc\n+++ b/src/qcam/assets/feathericons/feathericons.qrc\n@@ -3,9 +3,11 @@\n <qresource>\n \t<file>aperture.svg</file>\n \t<file>camera-off.svg</file>\n+\t<file>file.svg</file>\n \t<file>play-circle.svg</file>\n \t<file>save.svg</file>\n \t<file>stop-circle.svg</file>\n \t<file>x-circle.svg</file>\n+\t<file>x-square.svg</file>\n </qresource>\n </RCC>\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 4e773c31..9dc96fbb 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -20,6 +20,7 @@\n #include <QImage>\n #include <QImageWriter>\n #include <QInputDialog>\n+#include <QMessageBox>\n #include <QMutexLocker>\n #include <QStandardPaths>\n #include <QStringList>\n@@ -233,6 +234,13 @@ int MainWindow::createToolbars()\n \tsaveRaw_ = action;\n #endif\n \n+\t/* Open Script... action. */\n+\taction = toolbar_->addAction(QIcon::fromTheme(\"document-open\",\n+\t\t\t\t\t\t      QIcon(\":file.svg\")),\n+\t\t\t\t     \"Open Capture Script\");\n+\tconnect(action, &QAction::triggered, this, &MainWindow::chooseScript);\n+\tscriptExecAction_ = action;\n+\n \treturn 0;\n }\n \n@@ -256,6 +264,60 @@ void MainWindow::updateTitle()\n \tsetWindowTitle(title_ + \" : \" + QString::number(fps, 'f', 2) + \" fps\");\n }\n \n+/**\n+ * \\brief Load a capture script for handling the capture session.\n+ *\n+ * If already capturing, it would restart the capture.\n+ */\n+void MainWindow::chooseScript()\n+{\n+\tif (script_) {\n+\t\t/*\n+\t\t * This is the second valid press of load script button,\n+\t\t * It indicates stopping, Stop and set button for new script.\n+\t\t */\n+\t\tscript_.reset();\n+\t\tscriptExecAction_->setIcon(QIcon::fromTheme(\"document-open\",\n+\t\t\t\t\t\t\t    QIcon(\":file.svg\")));\n+\t\tscriptExecAction_->setText(\"Open Capture Script\");\n+\t\treturn;\n+\t}\n+\n+\tQString scriptFile = QFileDialog::getOpenFileName(this, \"Open Capture Script\", QDir::currentPath(),\n+\t\t\t\t\t\t\t  \"Capture Script (*.yaml)\");\n+\tif (scriptFile.isEmpty())\n+\t\treturn;\n+\n+\t/*\n+\t * If we are already capturing,\n+\t * stop so we don't have stuck image in viewfinder.\n+\t */\n+\tbool wasCapturing = isCapturing_;\n+\tif (isCapturing_)\n+\t\ttoggleCapture(false);\n+\n+\tscript_ = std::make_unique<CaptureScript>(camera_, scriptFile.toStdString());\n+\tif (!script_->valid()) {\n+\t\tscript_.reset();\n+\t\tQMessageBox::critical(this, \"Invalid Script\",\n+\t\t\t\t      \"Couldn't load the capture script\");\n+\t\tif (wasCapturing)\n+\t\t\ttoggleCapture(true);\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * Valid script verified\n+\t * Set the button to indicate stopping availibility.\n+\t */\n+\tscriptExecAction_->setIcon(QIcon(\":x-square.svg\"));\n+\tscriptExecAction_->setText(\"Stop Script execution\");\n+\n+\t/* Start capture again if we were capturing before. */\n+\tif (wasCapturing)\n+\t\ttoggleCapture(true);\n+}\n+\n /* -----------------------------------------------------------------------------\n  * Camera Selection\n  */\n@@ -511,6 +573,7 @@ int MainWindow::startCapture()\n \tpreviousFrames_ = 0;\n \tframesCaptured_ = 0;\n \tlastBufferTime_ = 0;\n+\tqueueCount_ = 0;\n \n \tret = camera_->start();\n \tif (ret) {\n@@ -790,5 +853,10 @@ void MainWindow::renderComplete(FrameBuffer *buffer)\n \n int MainWindow::queueRequest(Request *request)\n {\n+\tif (script_)\n+\t\trequest->controls() = script_->frameControls(queueCount_);\n+\n+\tqueueCount_++;\n+\n \treturn camera_->queueRequest(request);\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex bc844711..eb398c1d 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -26,6 +26,7 @@\n #include <QQueue>\n #include <QTimer>\n \n+#include \"../cam/capture_script.h\"\n #include \"../cam/stream_options.h\"\n \n #include \"viewfinder.h\"\n@@ -87,11 +88,14 @@ private:\n \tvoid processHotplug(HotplugEvent *e);\n \tvoid processViewfinder(libcamera::FrameBuffer *buffer);\n \n+\tvoid chooseScript();\n+\n \t/* UI elements */\n \tQToolBar *toolbar_;\n \tQAction *startStopAction_;\n \tQComboBox *cameraCombo_;\n \tQAction *saveRaw_;\n+\tQAction *scriptExecAction_;\n \tViewFinder *viewfinder_;\n \n \tQIcon iconPlay_;\n@@ -125,6 +129,8 @@ private:\n \tQElapsedTimer frameRateInterval_;\n \tuint32_t previousFrames_;\n \tuint32_t framesCaptured_;\n+\tuint32_t queueCount_;\n \n \tstd::vector<std::unique_ptr<libcamera::Request>> requests_;\n+\tstd::unique_ptr<CaptureScript> script_;\n };\ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex c46f4631..67074252 100644\n--- a/src/qcam/meson.build\n+++ b/src/qcam/meson.build\n@@ -15,6 +15,7 @@ endif\n qcam_enabled = true\n \n qcam_sources = files([\n+    '../cam/capture_script.cpp',\n     '../cam/image.cpp',\n     '../cam/options.cpp',\n     '../cam/stream_options.cpp',\n@@ -37,6 +38,7 @@ qcam_resources = files([\n qcam_deps = [\n     libatomic,\n     libcamera_public,\n+    libyaml,\n     qt5_dep,\n ]\n \n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "2/3"
    ]
}