From patchwork Tue Jul 19 12:26:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16690 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 33DBCBD1F1 for ; Tue, 19 Jul 2022 12:26:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A366363312; Tue, 19 Jul 2022 14:26:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658233603; bh=Sct2NOXcleZIay+bPcicpJH51w1vAjY4meaZjk7glfY=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iilQF6VwkNlfMedPXiWwgPJUmG7etEo1si8eRTRVChat/H6TTHgCaQmuxVlRTseG7 ji7cRwv7xf8lx3yvCR6DbTzBTToOJlFhXo4xYqFM0YrSReGSchPTdbd8OcL4ZmSPWb +IABACoYrK4Kzjz3ImSNX8M9fD7PbboBqsfW4mCFUzSROl3G4W3KG0aK9TF53WkL2O DOHg+NqN3y+cXGLI15YJp1D+BNn9LARj0JcQFoCBiSuDiZeG1zu7/JBKVdLkfA84ju 0iLf/vRdIoNpJzEIZEqv9DTPsm7mFmam5T7JtpTPqDhDRV8lLNWTpStGyFc3KCjD7G gSGutTST4iQww== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DD1A603F4 for ; Tue, 19 Jul 2022 14:26:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oCVAKu8n"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 91B466EE; Tue, 19 Jul 2022 14:26:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658233601; bh=Sct2NOXcleZIay+bPcicpJH51w1vAjY4meaZjk7glfY=; h=From:To:Cc:Subject:Date:From; b=oCVAKu8n5f+5Xoe5lWlBSMSFY16oW7Z92/LJPdpYq8gEHmXTnG1HqCFEtljmYauM6 Hq7dZRXG5FforFIK2YId/MB6oCYYxLvyzmpTCANIDDF55dEPXsx6c0e0Px9Cf+ydOR YvX9Y9/L1M7KkPHpH7CD3hwnIUzWs8cDC3iUp10I= To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Jul 2022 15:26:04 +0300 Message-Id: <20220719122604.20709-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] simple-cam: Update to the new ControList::get() API X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The ControlList::get() function has changed and now returns a std::optional. Adapt simple-cam accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- simple-cam.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) base-commit: bb97f3bbd96a9d347e1b7f6cb68d94efaf8db574 diff --git a/simple-cam.cpp b/simple-cam.cpp index 4de1b7de9ced..3e17839d17e6 100644 --- a/simple-cam.cpp +++ b/simple-cam.cpp @@ -133,18 +133,22 @@ std::string cameraName(Camera *camera) const ControlList &props = camera->properties(); std::string name; - switch (props.get(properties::Location)) { - case properties::CameraLocationFront: - name = "Internal front camera"; - break; - case properties::CameraLocationBack: - name = "Internal back camera"; - break; - case properties::CameraLocationExternal: - name = "External camera"; - if (props.contains(properties::Model)) - name += " '" + props.get(properties::Model) + "'"; - break; + const auto &location = props.get(properties::Location); + if (location) { + switch (*location) { + case properties::CameraLocationFront: + name = "Internal front camera"; + break; + case properties::CameraLocationBack: + name = "Internal back camera"; + break; + case properties::CameraLocationExternal: + name = "External camera"; + const auto &model = props.get(properties::Model); + if (model) + name = " '" + *model + "'"; + break; + } } name += " (" + camera->id() + ")";