From patchwork Tue Nov 23 10:40:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 14699 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 DCFB3BDB13 for ; Tue, 23 Nov 2021 10:41:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96B1860398; Tue, 23 Nov 2021 11:41:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qQbBa1Lx"; dkim-atps=neutral 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 2AED06033C for ; Tue, 23 Nov 2021 11:41:04 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C292DA1B; Tue, 23 Nov 2021 11:41:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1637664064; bh=s9Rs+u6OhvJblp2sk0T3CF3w3kgC5jPMWV7ntWkFZkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQbBa1Lx50RnHHTpIGiEfHTc8lwI8kIS88bX50LLrAyQG5aMhusgS0PjfD77zmTpt yJjPePmbpwe/iGsgQR1Gsaj6tllKHLm44gE8KoSKxG8hYBURTITbVvlMrQkqJNjysu cfFJZuVGbNDPDTf5cZEHPrGorgNIluua8flRWeBw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Nov 2021 19:40:38 +0900 Message-Id: <20211123104042.3100902-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211123104042.3100902-1-paul.elder@ideasonboard.com> References: <20211123104042.3100902-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/7] android: camera_metadata: Add appendEntry helper 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add appendEntry() helper, that automatically detects if updateEntry() or addEntry() should be used. For now only implement it for enums and arithmetic values, as they will mainly be used in populating templates, where the preview template generator may or may not have (based on capabilities) already added a key. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham --- src/android/camera_metadata.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h index 8555c7c3..cca14d6c 100644 --- a/src/android/camera_metadata.h +++ b/src/android/camera_metadata.h @@ -33,6 +33,17 @@ public: bool hasEntry(uint32_t tag) const; + template || + std::is_enum_v> * = nullptr> + bool appendEntry(uint32_t tag, const T &data) + { + if (hasEntry(tag)) + return updateEntry(tag, &data, 1, sizeof(T)); + else + return addEntry(tag, &data, 1, sizeof(T)); + } + template || std::is_enum_v> * = nullptr>