Patch Detail
Show a patch.
GET /api/patches/1448/?format=api
{ "id": 1448, "url": "https://patchwork.libcamera.org/api/patches/1448/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1448/", "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": "<20190617100910.10879-1-laurent.pinchart@ideasonboard.com>", "date": "2019-06-17T10:09:10", "name": "[libcamera-devel] cam: Allow selecting cameras by index", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a551bff3366c9ad429f1025e950819eb28ddf055", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1448/mbox/", "series": [ { "id": 359, "url": "https://patchwork.libcamera.org/api/series/359/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=359", "date": "2019-06-17T10:09:10", "name": "[libcamera-devel] cam: Allow selecting cameras by index", "version": 1, "mbox": "https://patchwork.libcamera.org/series/359/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1448/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1448/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 829106487A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jun 2019 12:09:34 +0200 (CEST)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 201E25D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jun 2019 12:09:34 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560766174;\n\tbh=+EvNd0VY5ljHHRNHj1t7SREbP6JatLOgESexCleUqf4=;\n\th=From:To:Subject:Date:From;\n\tb=X7Dl7FiRTRZJXFkgSfcpH+oox5O7gW2kbmkUN+6kPdRJg4Inu1iEx+t/W9+mSTuSP\n\t0gisKBYbINw3vSCGzlJ9N8Pi6TnEOJWp5xq559ZUpkP4tg67agK5WXXLZ3e5I1p8tj\n\tTRoFja1MzevjX63fE8/0E2zhSnytI9U9TU/VesiA=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 17 Jun 2019 13:09:10 +0300", "Message-Id": "<20190617100910.10879-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] cam: Allow selecting cameras by index", "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": "Mon, 17 Jun 2019 10:09:34 -0000" }, "content": "As camera names can be cumbersome to type, selection of cameras by index\nfrom a list can be useful. Print the list of detected cameras with an\nindex for each item, and interpret the camera name as an index if it is\na numerical value in the range from 1 to the number of cameras.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/main.cpp | 17 ++++++++++++++---\n 1 file changed, 14 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex f03a9faf87fa..0e7610b1befd 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -73,7 +73,14 @@ int CamApp::init(int argc, char **argv)\n \t}\n \n \tif (options_.isSet(OptCamera)) {\n-\t\tcamera_ = cm_->get(options_[OptCamera]);\n+\t\tconst std::string &cameraName = options_[OptCamera];\n+\t\tchar *endptr;\n+\t\tunsigned long index = strtoul(cameraName.c_str(), &endptr, 10);\n+\t\tif (*endptr == '\\0' && index > 0 && index <= cm_->cameras().size())\n+\t\t\tcamera_ = cm_->cameras()[index - 1];\n+\t\telse\n+\t\t\tcamera_ = cm_->get(cameraName);\n+\n \t\tif (!camera_) {\n \t\t\tstd::cout << \"Camera \"\n \t\t\t\t << std::string(options_[OptCamera])\n@@ -172,8 +179,12 @@ int CamApp::run()\n {\n \tif (options_.isSet(OptList)) {\n \t\tstd::cout << \"Available cameras:\" << std::endl;\n-\t\tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n-\t\t\tstd::cout << \"- \" << cam->name() << std::endl;\n+\n+\t\tunsigned int index = 1;\n+\t\tfor (const std::shared_ptr<Camera> &cam : cm_->cameras()) {\n+\t\t\tstd::cout << index << \": \" << cam->name() << std::endl;\n+\t\t\tindex++;\n+\t\t}\n \t}\n \n \tif (options_.isSet(OptCapture)) {\n", "prefixes": [ "libcamera-devel" ] }