Patch Detail
Show a patch.
GET /api/patches/3581/?format=api
{ "id": 3581, "url": "https://patchwork.libcamera.org/api/patches/3581/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3581/", "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-5-niklas.soderlund@ragnatech.se>", "date": "2020-04-27T22:05:28", "name": "[libcamera-devel,v2,4/5] cam: Make use of StreamKeyValueParser", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7d3847ced1992c3a795961f5dbbb59de4c4ef45a", "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/3581/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/3581/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3581/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 86F9360B02\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 00:06:18 +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 41519e97-88d3-11ea-b7d8-005056917a89;\n\tTue, 28 Apr 2020 00:05:50 +0200 (CEST)" ], "X-Halon-ID": "41519e97-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:28 +0200", "Message-Id": "<20200427220529.1085074-5-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 4/5] cam: 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:18 -0000" }, "content": "Use the StreamOptionsParser helper to parse stream configuration from\nthe command line.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/cam/main.cpp | 69 +++++-------------------------------------------\n 1 file changed, 6 insertions(+), 63 deletions(-)", "diff": "diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex ced4f567b8f38e00..c6814f21aa51cf41 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -16,7 +16,7 @@\n #include \"capture.h\"\n #include \"event_loop.h\"\n #include \"main.h\"\n-#include \"options.h\"\n+#include \"stream_options.h\"\n \n using namespace libcamera;\n \n@@ -154,16 +154,7 @@ void CamApp::quit()\n \n int CamApp::parseOptions(int argc, char *argv[])\n {\n-\tKeyValueParser streamKeyValue;\n-\tstreamKeyValue.addOption(\"role\", OptionString,\n-\t\t\t\t \"Role for the stream (viewfinder, video, still, stillraw)\",\n-\t\t\t\t ArgumentRequired);\n-\tstreamKeyValue.addOption(\"width\", OptionInteger, \"Width in pixels\",\n-\t\t\t\t ArgumentRequired);\n-\tstreamKeyValue.addOption(\"height\", OptionInteger, \"Height in pixels\",\n-\t\t\t\t ArgumentRequired);\n-\tstreamKeyValue.addOption(\"pixelformat\", OptionInteger, \"Pixel format\",\n-\t\t\t\t ArgumentRequired);\n+\tStreamKeyValueParser streamKeyValue;\n \n \tOptionsParser parser;\n \tparser.addOption(OptCamera, OptionString,\n@@ -202,38 +193,7 @@ int CamApp::parseOptions(int argc, char *argv[])\n \n int CamApp::prepareConfig()\n {\n-\tStreamRoles roles;\n-\n-\tif (options_.isSet(OptStream)) {\n-\t\tconst std::vector<OptionValue> &streamOptions =\n-\t\t\toptions_[OptStream].toArray();\n-\n-\t\t/* Use roles and get a default configuration. */\n-\t\tfor (auto const &value : streamOptions) {\n-\t\t\tKeyValueParser::Options opt = value.toKeyValues();\n-\n-\t\t\tstd::string role = opt.isSet(\"role\")\n-\t\t\t\t\t ? opt[\"role\"].toString()\n-\t\t\t\t\t : \"viewfinder\";\n-\n-\t\t\tif (role == \"viewfinder\") {\n-\t\t\t\troles.push_back(StreamRole::Viewfinder);\n-\t\t\t} else if (role == \"video\") {\n-\t\t\t\troles.push_back(StreamRole::VideoRecording);\n-\t\t\t} else if (role == \"still\") {\n-\t\t\t\troles.push_back(StreamRole::StillCapture);\n-\t\t\t} else if (role == \"stillraw\") {\n-\t\t\t\troles.push_back(StreamRole::StillCaptureRaw);\n-\t\t\t} else {\n-\t\t\t\tstd::cerr << \"Unknown stream role \"\n-\t\t\t\t\t << role << std::endl;\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t}\n-\t} else {\n-\t\t/* If no configuration is provided assume a single video stream. */\n-\t\troles.push_back(StreamRole::VideoRecording);\n-\t}\n+\tStreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);\n \n \tconfig_ = camera_->generateConfiguration(roles);\n \tif (!config_ || config_->size() != roles.size()) {\n@@ -243,26 +203,9 @@ int CamApp::prepareConfig()\n \t}\n \n \t/* Apply configuration if explicitly requested. */\n-\tif (options_.isSet(OptStream)) {\n-\t\tconst std::vector<OptionValue> &streamOptions =\n-\t\t\toptions_[OptStream].toArray();\n-\n-\t\tunsigned int i = 0;\n-\t\tfor (auto const &value : streamOptions) {\n-\t\t\tKeyValueParser::Options opt = value.toKeyValues();\n-\t\t\tStreamConfiguration &cfg = config_->at(i++);\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-\n-\t\t\t/* TODO: Translate 4CC string to ID. */\n-\t\t\tif (opt.isSet(\"pixelformat\"))\n-\t\t\t\tcfg.pixelFormat = PixelFormat(opt[\"pixelformat\"]);\n-\t\t}\n-\t}\n+\tif (StreamKeyValueParser::updateConfiguration(config_.get(),\n+\t\t\t\t\t\t options_[OptStream]))\n+\t\treturn -EINVAL;\n \n \tswitch (config_->validate()) {\n \tcase CameraConfiguration::Valid:\n", "prefixes": [ "libcamera-devel", "v2", "4/5" ] }