Patch Detail
Show a patch.
GET /api/patches/3582/?format=api
{ "id": 3582, "url": "https://patchwork.libcamera.org/api/patches/3582/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3582/", "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": "<20200427220529.1085074-6-niklas.soderlund@ragnatech.se>", "date": "2020-04-27T22:05:29", "name": "[libcamera-devel,v2,5/5] qcam: Make use of StreamKeyValueParser", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7a8222ce3ab6f721ad316cb43b7b34a28b4b846d", "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/3582/mbox/", "series": [ { "id": 838, "url": "https://patchwork.libcamera.org/api/series/838/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=838", "date": "2020-04-27T22:05:24", "name": "{cam, qcam}: Unify stream option parsing", "version": 2, "mbox": "https://patchwork.libcamera.org/series/838/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3582/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3582/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 1E12E61224\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 00:06:19 +0200 (CEST)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 41a35a98-88d3-11ea-b7d8-005056917a89;\n\tTue, 28 Apr 2020 00:05:51 +0200 (CEST)" ], "X-Halon-ID": "41a35a98-88d3-11ea-b7d8-005056917a89", "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": "Tue, 28 Apr 2020 00:05:29 +0200", "Message-Id": "<20200427220529.1085074-6-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.26.0", "In-Reply-To": "<20200427220529.1085074-1-niklas.soderlund@ragnatech.se>", "References": "<20200427220529.1085074-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 5/5] 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": "Mon, 27 Apr 2020 22:06:20 -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>\n---\n src/qcam/main.cpp | 12 ++++--------\n src/qcam/main_window.cpp | 35 ++++++++++++++++++-----------------\n src/qcam/main_window.h | 4 ++--\n src/qcam/meson.build | 1 +\n 4 files changed, 25 insertions(+), 27 deletions(-)", "diff": "diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\nindex 862d714f467c04f9..cd73fa764614e7e7 100644\n--- a/src/qcam/main.cpp\n+++ b/src/qcam/main.cpp\n@@ -13,8 +13,8 @@\n \n #include <libcamera/camera_manager.h>\n \n+#include \"../cam/stream_options.h\"\n #include \"main_window.h\"\n-#include \"../cam/options.h\"\n \n void signalHandler(int signal)\n {\n@@ -24,11 +24,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 +32,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 ed0cad417d62abea..ee779728fc630da8 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -277,29 +277,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\tqWarning() << \"Only one stream supported\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (roles[0] != StreamRole::Viewfinder) {\n+\t\tqWarning() << \"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@@ -313,6 +309,11 @@ 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\treturn -EINVAL;\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 5d6251c830707a79..5e9d9b8d9c6b2d6d 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@@ -33,7 +33,7 @@ class QAction;\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", "v2", "5/5" ] }