{"id":16846,"url":"https://patchwork.libcamera.org/api/patches/16846/?format=json","web_url":"https://patchwork.libcamera.org/patch/16846/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220727125754.1109455-1-paul.elder@ideasonboard.com>","date":"2022-07-27T12:57:54","name":"[libcamera-devel] cam: capture_script: Add support for Rectangle and Size controls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"eec06b3f9ef52a5637e1a649096c3b85d8a25f9e","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16846/mbox/","series":[{"id":3336,"url":"https://patchwork.libcamera.org/api/series/3336/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3336","date":"2022-07-27T12:57:54","name":"[libcamera-devel] cam: capture_script: Add support for Rectangle and Size controls","version":1,"mbox":"https://patchwork.libcamera.org/series/3336/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16846/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16846/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 B9A58BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 12:58:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1898E63311;\n\tWed, 27 Jul 2022 14:58:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9809563309\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 14:58:04 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 32A62835;\n\tWed, 27 Jul 2022 14:58:02 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658926686;\n\tbh=elg+cfcb0P6ERHIMe8vzKA9Pf7F3JP7/LP9iOfUVXgc=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=QgYDsZMiN7bTKaAyEbNWRKmnRPXXqSBhak4RZ7RgpxMWC5hWXnFl2OUVht/h0XuwP\n\tY9BTRm6WRi1+inC7c3SniQnG+iVavvauUtXgBrO4Ge3WWyJz7NfacmvNJPCuxlUa5Z\n\tc3UmdCNF6AsuvPHmUJ1q0he/k+EIDHRahQA2lQGmew65vaDNxWAr9+RPdqOvd5S7ts\n\tClFzI09fgL4Pq5QvsipYr2YP7AQl46sz8yfewScWiaDZJ3uszt4WQbDACXCQ+/7Iry\n\tn3ct/1Zf+gDXYkNb2hqvyDOtcx82JYtrRzLmGbQir7dDhq7WalaNiUqzE95QXV2oa0\n\t5JX6rTLhIzlKA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658926684;\n\tbh=elg+cfcb0P6ERHIMe8vzKA9Pf7F3JP7/LP9iOfUVXgc=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=aos+HcC0Sp1LQ7keutIrQy0WfVY0uWbcLNYiOcb4sFM+Vgb8QcffmOX5dMXJU1At3\n\tz1dyHzEVFo5xx0RGnHF87dsvOajnKYr01+IAHuZ9LiSaa0yiBf4WQ5DSyeTU1ByZk+\n\tKK5hZT4DPXvODBDzUVP/azW1PH02w6xYObnFzB0w="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"aos+HcC0\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 27 Jul 2022 21:57:54 +0900","Message-Id":"<20220727125754.1109455-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.30.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] cam: capture_script: Add support for\n\tRectangle and Size controls","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add support for Rectangle and Size control values in the capture script\nparser.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/cam/capture_script.cpp | 61 +++++++++++++++++++++++++++++++++++---\n src/cam/capture_script.h   |  4 +++\n 2 files changed, 61 insertions(+), 4 deletions(-)","diff":"diff --git a/src/cam/capture_script.cpp b/src/cam/capture_script.cpp\nindex 9f22d5f7..6421b6df 100644\n--- a/src/cam/capture_script.cpp\n+++ b/src/cam/capture_script.cpp\n@@ -252,6 +252,53 @@ std::string CaptureScript::parseScalar()\n \treturn eventScalarValue(event);\n }\n \n+Rectangle CaptureScript::unpackRectangle(const ControlId *id,\n+\t\t\t\t\t const std::string &repr)\n+{\n+\t/* Format: (<left>,<top>)/<width>x<height> */\n+\n+\tstd::map<char, int> delims = { { '(', -1 },\n+\t\t\t\t       { ')', -1 },\n+\t\t\t\t       { ',', -1 },\n+\t\t\t\t       { '/', -1 },\n+\t\t\t\t       { 'x', -1 } };\n+\n+\tfor (unsigned int i = 0; i < repr.size(); i++)\n+\t\tif (delims.count(repr[i]))\n+\t\t\tdelims[repr[i]] = i;\n+\n+\tfor (auto &pair : delims) {\n+\t\tif (pair.second == -1) {\n+\t\t\tunpackFailure(id, repr);\n+\t\t\treturn Rectangle{};\n+\t\t}\n+\t}\n+\n+\tint32_t left =   strtol(repr.substr(delims['('] + 1, delims[',']).c_str(), NULL, 10);\n+\tint32_t top =    strtol(repr.substr(delims[','] + 1, delims[')']).c_str(), NULL, 10);\n+\tint32_t width =  strtol(repr.substr(delims['/'] + 1, delims['x']).c_str(), NULL, 10);\n+\tint32_t height = strtol(repr.substr(delims['x'] + 1).c_str(), NULL, 10);\n+\n+\treturn Rectangle(left, top, width, height);\n+}\n+\n+Size CaptureScript::unpackSize(const ControlId *id,\n+\t\t\t       const std::string &repr)\n+{\n+\t/* Format: <width>x<height> */\n+\n+\tint pos = repr.find(\"x\");\n+\tif (pos == std::string::npos) {\n+\t\tunpackFailure(id, repr);\n+\t\treturn Size{};\n+\t}\n+\n+\tint32_t width = strtol(repr.substr(0, pos), NULL, 10);\n+\tint32_t height = strtol(repr.substr(pos), NULL, 10);\n+\n+\treturn Size(width, height);\n+}\n+\n void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr)\n {\n \tstatic const std::map<unsigned int, const char *> typeNames = {\n@@ -281,6 +328,8 @@ ControlValue CaptureScript::unpackControl(const ControlId *id,\n \t\t\t\t\t  const std::string &repr)\n {\n \tControlValue value{};\n+\tRectangle rect;\n+\tSize size;\n \n \tswitch (id->type()) {\n \tcase ControlTypeNone:\n@@ -324,13 +373,17 @@ ControlValue CaptureScript::unpackControl(const ControlId *id,\n \t\tvalue.set<std::string>(repr);\n \t\tbreak;\n \t}\n-\tcase ControlTypeRectangle:\n-\t\t/* \\todo Parse rectangles. */\n+\tcase ControlTypeRectangle: {\n+\t\trect = unpackRectangle(id, repr);\n+\t\tvalue.set<Rectangle>(rect);\n \t\tbreak;\n-\tcase ControlTypeSize:\n-\t\t/* \\todo Parse Sizes. */\n+\t}\n+\tcase ControlTypeSize: {\n+\t\tsize = unpackSize(id, repr);\n+\t\tvalue.set<Size>(size);\n \t\tbreak;\n \t}\n+\t}\n \n \treturn value;\n }\ndiff --git a/src/cam/capture_script.h b/src/cam/capture_script.h\nindex 8b4f8f62..f2dbfdf8 100644\n--- a/src/cam/capture_script.h\n+++ b/src/cam/capture_script.h\n@@ -55,6 +55,10 @@ private:\n \n \tstd::string parseScalar();\n \n+\tlibcamera::Rectangle unpackRectangle(const libcamera::ControlId *id,\n+\t\t\t\t\t     const std::string &repr);\n+\tlibcamera::Size unpackSize(const libcamera::ControlId *id,\n+\t\t\t\t   const std::string &repr);\n \tvoid unpackFailure(const libcamera::ControlId *id,\n \t\t\t   const std::string &repr);\n \tlibcamera::ControlValue unpackControl(const libcamera::ControlId *id,\n","prefixes":["libcamera-devel"]}