Show a patch.

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

{
    "id": 8990,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/8990/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8990/",
    "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": "<20200724191851.803350-4-niklas.soderlund@ragnatech.se>",
    "date": "2020-07-24T19:18:51",
    "name": "[libcamera-devel,v3,3/3] cam: Add optional argument to --capture to specify how many frames to capture",
    "commit_ref": "30e0ea843eb96a93f8282466e3a328fdda7fafdc",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "bebfba38b2bcd3b5ff046f7bb83ab38dca698893",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8990/mbox/",
    "series": [
        {
            "id": 1142,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1142/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1142",
            "date": "2020-07-24T19:18:48",
            "name": "cam: Add options to make batch testing with cam easier",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1142/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8990/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8990/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 6D5B6BD879\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2020 19:19:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B54D612E1;\n\tFri, 24 Jul 2020 21:19:22 +0200 (CEST)",
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 555966121D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 21:19:18 +0200 (CEST)",
            "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 67dec317-cde2-11ea-86ee-0050569116f7;\n\tFri, 24 Jul 2020 21:18:07 +0200 (CEST)"
        ],
        "X-Halon-ID": "67dec317-cde2-11ea-86ee-0050569116f7",
        "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": "Fri, 24 Jul 2020 21:18:51 +0200",
        "Message-Id": "<20200724191851.803350-4-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20200724191851.803350-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200724191851.803350-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 3/3] cam: Add optional argument to\n\t--capture to specify how many frames to capture",
        "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>",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Extend the '--capture' option with and optional numerical argument to be\nable to specify how many frames to capture before exiting. If the\noptional argument is not provided the old behavior of running until the\nuser interrupts with a SIGINT is retained.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v2\n- Move check in Capture::requestComplete() as to not leak the created\n  but never used Request.\n* Changes since v1\n- Extend --capture option instead of adding a new --count option.\n---\n src/cam/capture.cpp | 18 ++++++++++++++++--\n src/cam/capture.h   |  2 ++\n src/cam/main.cpp    |  5 +++--\n 3 files changed, 21 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\nindex f811a18c579508a1..3d8e89d52c7ab68d 100644\n--- a/src/cam/capture.cpp\n+++ b/src/cam/capture.cpp\n@@ -18,7 +18,8 @@ using namespace libcamera;\n \n Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,\n \t\t EventLoop *loop)\n-\t: camera_(camera), config_(config), writer_(nullptr), loop_(loop)\n+\t: camera_(camera), config_(config), writer_(nullptr), loop_(loop),\n+\t  captureCount_(0), captureLimit_(0)\n {\n }\n \n@@ -26,6 +27,9 @@ int Capture::run(const OptionsParser::Options &options)\n {\n \tint ret;\n \n+\tcaptureCount_ = 0;\n+\tcaptureLimit_ = options[OptCapture].toInteger();\n+\n \tif (!camera_) {\n \t\tstd::cout << \"Can't capture without a camera\" << std::endl;\n \t\treturn -ENODEV;\n@@ -132,7 +136,11 @@ int Capture::capture(FrameBufferAllocator *allocator)\n \t\t}\n \t}\n \n-\tstd::cout << \"Capture until user interrupts by SIGINT\" << std::endl;\n+\tif (captureLimit_)\n+\t\tstd::cout << \"Capture \" << captureLimit_ << \" frames\" << std::endl;\n+\telse\n+\t\tstd::cout << \"Capture until user interrupts by SIGINT\" << std::endl;\n+\n \tret = loop_->exec();\n \tif (ret)\n \t\tstd::cout << \"Failed to run capture loop\" << std::endl;\n@@ -184,6 +192,12 @@ void Capture::requestComplete(Request *request)\n \n \tstd::cout << info.str() << std::endl;\n \n+\tcaptureCount_++;\n+\tif (captureLimit_ && captureCount_ >= captureLimit_) {\n+\t\tloop_->exit(0);\n+\t\treturn;\n+\t}\n+\n \t/*\n \t * Create a new request and populate it with one buffer for each\n \t * stream.\ndiff --git a/src/cam/capture.h b/src/cam/capture.h\nindex acdefc47b24314d2..32940a2a12138887 100644\n--- a/src/cam/capture.h\n+++ b/src/cam/capture.h\n@@ -41,6 +41,8 @@ private:\n \tstd::chrono::steady_clock::time_point last_;\n \n \tEventLoop *loop_;\n+\tunsigned int captureCount_;\n+\tunsigned int captureLimit_;\n };\n \n #endif /* __CAM_CAPTURE_H__ */\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 3e83feabe64e036c..f5aba041d7c4c181 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -167,8 +167,9 @@ int CamApp::parseOptions(int argc, char *argv[])\n \tparser.addOption(OptCamera, OptionString,\n \t\t\t \"Specify which camera to operate on, by name or by index\", \"camera\",\n \t\t\t ArgumentRequired, \"camera\");\n-\tparser.addOption(OptCapture, OptionNone,\n-\t\t\t \"Capture until interrupted by user\", \"capture\");\n+\tparser.addOption(OptCapture, OptionInteger,\n+\t\t\t \"Capture until interrupted by user or until <count> frames captured\",\n+\t\t\t \"capture\", ArgumentOptional, \"count\");\n \tparser.addOption(OptFile, OptionString,\n \t\t\t \"Write captured frames to disk\\n\"\n \t\t\t \"The first '#' character in the file name is expanded to the stream name and frame sequence number.\\n\"\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "3/3"
    ]
}