{"id":10176,"url":"https://patchwork.libcamera.org/api/1.1/patches/10176/?format=json","web_url":"https://patchwork.libcamera.org/patch/10176/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20201021154043.511274-1-kieran.bingham@ideasonboard.com>","date":"2020-10-21T15:40:43","name":"[libcamera-devel,Simple-Cam:] simple-cam: Use friendly camera names","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d3fb4d83546bcf301333867957238eb39c2353e1","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/1.1/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/10176/mbox/","series":[{"id":1400,"url":"https://patchwork.libcamera.org/api/1.1/series/1400/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1400","date":"2020-10-21T15:40:43","name":"[libcamera-devel,Simple-Cam:] simple-cam: Use friendly camera names","version":1,"mbox":"https://patchwork.libcamera.org/series/1400/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10176/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10176/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 BC71BBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 15:40:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 477F360BE7;\n\tWed, 21 Oct 2020 17:40:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B52B5603F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 17:40:46 +0200 (CEST)","from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C45F92;\n\tWed, 21 Oct 2020 17:40:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eB6aqnWN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603294846;\n\tbh=xD6Ju89V7gYM6IvxbQ2kbTAJlq6tQAhuq5u6qeJg2Ag=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=eB6aqnWNLkzx5aFkCSnQHHZimVEYyLlHTLx1Qx6qAJyU9AwsU1l0SsADTGp/dFqTs\n\t4s2FBUJCupLmTe97LM7SBOx4Uun8JElFra80GOM0ILrEcZy0lkvZDMvW0VXBdJfWxI\n\tZnjKgXI8K7TFwqy2obqIflSN52eZFvKE2IHK2lyw=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Wed, 21 Oct 2020 16:40:43 +0100","Message-Id":"<20201021154043.511274-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Subject":"[libcamera-devel] [Simple-Cam: PATCH] simple-cam: Use friendly\n\tcamera names","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Take the example code for generating a camera name from 'cam' and use\nit when reporting cameras within the simple-cam application.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nI wonder if this cameraName() might be something that\nshould go into libcamera::utils as a public API helper?\n\n\nI know we want to allow applications to decide their own naming too, but\nI think we've discussed in the past about having a helper library on top\nto make things easier for application developers ?\n\n\n simple-cam.cpp | 30 +++++++++++++++++++++++++++---\n 1 file changed, 27 insertions(+), 3 deletions(-)","diff":"diff --git a/simple-cam.cpp b/simple-cam.cpp\nindex 727bb6d86480..1b6fd3939bf6 100644\n--- a/simple-cam.cpp\n+++ b/simple-cam.cpp\n@@ -60,6 +60,30 @@ static void requestComplete(Request *request)\n \tcamera->queueRequest(request);\n }\n \n+std::string cameraName(std::shared_ptr<libcamera::Camera> camera)\n+{\n+\tconst ControlList &props = camera->properties();\n+\tstd::string name;\n+\n+\tswitch (props.get(properties::Location)) {\n+\tcase properties::CameraLocationFront:\n+\t\tname = \"Internal front camera\";\n+\t\tbreak;\n+\tcase properties::CameraLocationBack:\n+\t\tname = \"Internal back camera\";\n+\t\tbreak;\n+\tcase properties::CameraLocationExternal:\n+\t\tname = \"External camera\";\n+\t\tif (props.contains(properties::Model))\n+\t\t\tname += \" '\" + props.get(properties::Model) + \"'\";\n+\t\tbreak;\n+\t}\n+\n+\tname += \" (\" + camera->id() + \")\";\n+\n+\treturn name;\n+}\n+\n int main()\n {\n \t/*\n@@ -77,11 +101,11 @@ int main()\n \tcm->start();\n \n \t/*\n-\t * Just as a test, list all id's of the Camera registered in the\n-\t * system. They are indexed by name by the CameraManager.\n+\t * Just as a test, generate names of the Cameras registered in the\n+\t * system, and list them.\n \t */\n \tfor (auto const &camera : cm->cameras())\n-\t\tstd::cout << camera->id() << std::endl;\n+\t\tstd::cout << \" - \" << cameraName(camera) << std::endl;\n \n \t/*\n \t * --------------------------------------------------------------------\n","prefixes":["libcamera-devel","Simple-Cam:"]}