Patch Detail
Show a patch.
GET /api/patches/3647/?format=api
{ "id": 3647, "url": "https://patchwork.libcamera.org/api/patches/3647/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3647/", "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": "<20200501023432.90032-6-niklas.soderlund@ragnatech.se>", "date": "2020-05-01T02:34:31", "name": "[libcamera-devel,v3,5/6] qcam: Make use of StreamKeyValueParser", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "519f60d822fa04336005654ede5f3e93ede44c3d", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3647/mbox/", "series": [ { "id": 864, "url": "https://patchwork.libcamera.org/api/series/864/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=864", "date": "2020-05-01T02:34:27", "name": "{cam, qcam}: Unify stream option parsing", "version": 3, "mbox": "https://patchwork.libcamera.org/series/864/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3647/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3647/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E612614BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 1 May 2020 04:34:45 +0200 (CEST)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 505b946d-8b54-11ea-89d0-0050569116f7;\n\tFri, 01 May 2020 04:34:43 +0200 (CEST)" ], "X-Halon-ID": "505b946d-8b54-11ea-89d0-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, 1 May 2020 04:34:31 +0200", "Message-Id": "<20200501023432.90032-6-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.26.2", "In-Reply-To": "<20200501023432.90032-1-niklas.soderlund@ragnatech.se>", "References": "<20200501023432.90032-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 5/6] qcam: Make use of\n\tStreamKeyValueParser", "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": "Fri, 01 May 2020 02:34:46 -0000" }, "content": "Use the StreamKeyValueParser helper to parse stream configuration from\nthe command line. This extends qcam to accept role hints and pixel\nformat in addition to a size.\n\nCurrently only one viewfinder stream is supported, add a check to keep\nthis behavior. Going forward this restriction will be lifted to support\nmore then one stream.\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- Add log messages\n---\n src/qcam/main.cpp | 13 +++++--------\n src/qcam/main_window.cpp | 37 ++++++++++++++++++++-----------------\n src/qcam/main_window.h | 4 ++--\n src/qcam/meson.build | 1 +\n 4 files changed, 28 insertions(+), 27 deletions(-)", "diff": "diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\nindex 862d714f467c04f9..b3468cbf47e28894 100644\n--- a/src/qcam/main.cpp\n+++ b/src/qcam/main.cpp\n@@ -13,8 +13,9 @@\n \n #include <libcamera/camera_manager.h>\n \n-#include \"main_window.h\"\n #include \"../cam/options.h\"\n+#include \"../cam/stream_options.h\"\n+#include \"main_window.h\"\n \n void signalHandler(int signal)\n {\n@@ -24,11 +25,7 @@ void signalHandler(int signal)\n \n OptionsParser::Options parseOptions(int argc, char *argv[])\n {\n-\tKeyValueParser sizeParser;\n-\tsizeParser.addOption(\"width\", OptionInteger, \"Width in pixels\",\n-\t\t\t ArgumentRequired);\n-\tsizeParser.addOption(\"height\", OptionInteger, \"Height in pixels\",\n-\t\t\t ArgumentRequired);\n+\tStreamKeyValueParser streamKeyValue;\n \n \tOptionsParser parser;\n \tparser.addOption(OptCamera, OptionString,\n@@ -36,8 +33,8 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n \t\t\t ArgumentRequired, \"camera\");\n \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n \t\t\t \"help\");\n-\tparser.addOption(OptSize, &sizeParser, \"Set the stream size\",\n-\t\t\t \"size\", true);\n+\tparser.addOption(OptStream, &streamKeyValue,\n+\t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n \n \tOptionsParser::Options options = parser.parse(argc, argv);\n \tif (options.isSet(OptHelp))\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 5a2ac699f349f7cc..74427592ea47de28 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -280,29 +280,25 @@ void MainWindow::toggleCapture(bool start)\n */\n int MainWindow::startCapture()\n {\n+\tStreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);\n \tint ret;\n \n+\t/* Verify roles are supported. */\n+\tif (roles.size() != 1) {\n+\t\tqCritical() << \"Only one stream supported\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (roles[0] != StreamRole::Viewfinder) {\n+\t\tqCritical() << \"Only viewfinder supported\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Configure the camera. */\n-\tconfig_ = camera_->generateConfiguration({ StreamRole::Viewfinder });\n+\tconfig_ = camera_->generateConfiguration(roles);\n \n \tStreamConfiguration &cfg = config_->at(0);\n \n-\tif (options_.isSet(OptSize)) {\n-\t\tconst std::vector<OptionValue> &sizeOptions =\n-\t\t\toptions_[OptSize].toArray();\n-\n-\t\t/* Set desired stream size if requested. */\n-\t\tfor (const auto &value : sizeOptions) {\n-\t\t\tKeyValueParser::Options opt = value.toKeyValues();\n-\n-\t\t\tif (opt.isSet(\"width\"))\n-\t\t\t\tcfg.size.width = opt[\"width\"];\n-\n-\t\t\tif (opt.isSet(\"height\"))\n-\t\t\t\tcfg.size.height = opt[\"height\"];\n-\t\t}\n-\t}\n-\n \t/* Use a format supported by the viewfinder if available. */\n \tstd::vector<PixelFormat> formats = cfg.formats().pixelformats();\n \tfor (const PixelFormat &format : viewfinder_->nativeFormats()) {\n@@ -316,6 +312,13 @@ int MainWindow::startCapture()\n \t\t}\n \t}\n \n+\t/* Allow user to override configuration. */\n+\tif (StreamKeyValueParser::updateConfiguration(config_.get(),\n+\t\t\t\t\t\t options_[OptStream])) {\n+\t\tqWarning() << \"Failed to update configuration\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \tCameraConfiguration::Status validation = config_->validate();\n \tif (validation == CameraConfiguration::Invalid) {\n \t\tqWarning() << \"Failed to create valid camera configuration\";\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 4ec37d40e1cff495..aea1f1dee20fcbb6 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -23,7 +23,7 @@\n #include <libcamera/framebuffer_allocator.h>\n #include <libcamera/stream.h>\n \n-#include \"../cam/options.h\"\n+#include \"../cam/stream_options.h\"\n #include \"viewfinder.h\"\n \n using namespace libcamera;\n@@ -34,7 +34,7 @@ class QComboBox;\n enum {\n \tOptCamera = 'c',\n \tOptHelp = 'h',\n-\tOptSize = 's',\n+\tOptStream = 's',\n };\n \n class MainWindow : public QMainWindow\ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex c256d06f8ccfc0ae..895264be4a3388f4 100644\n--- a/src/qcam/meson.build\n+++ b/src/qcam/meson.build\n@@ -3,6 +3,7 @@ qcam_sources = files([\n 'main.cpp',\n 'main_window.cpp',\n '../cam/options.cpp',\n+ '../cam/stream_options.cpp',\n 'viewfinder.cpp',\n ])\n \n", "prefixes": [ "libcamera-devel", "v3", "5/6" ] }