From patchwork Mon Jun 29 16:39:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8512 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 E3FB3BFFE2 for ; Mon, 29 Jun 2020 16:39:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B172160AF2; Mon, 29 Jun 2020 18:39:25 +0200 (CEST) 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="XoTlh50A"; 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 20B16609DB for ; Mon, 29 Jun 2020 18:39:21 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B41AEAF3; Mon, 29 Jun 2020 18:39:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593448760; bh=VvYQCSZDSdlBx3pYRD0FSJ2qtclPcmtvodBctcl9sDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XoTlh50A3KWlfH7oqXCHmOx+WBweFPFSlIkRG4cqxl8+QWhkN+jV3rLn1Ie80V1yE GkLLxvDo81BVa6qZv/AYVuRiOeqz7bBn8Z5XIqAKCrW2MqMhZ+vCq//n9wGwvh3KF+ g1wS+c6ipG81Pab7a2JNx0lsXIwdg/sdLnVOmOKY= From: Kieran Bingham To: libcamera devel Date: Mon, 29 Jun 2020 17:39:14 +0100 Message-Id: <20200629163916.1815321-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629163916.1815321-1-kieran.bingham@ideasonboard.com> References: <20200629163916.1815321-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: camera: Return a reference to the new configuration when adding 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" Facilitate easily referencing of the newly added StreamConfiguration as the source structure is copied, and not used after it has been added. This simplifies the caller, and allows the caller to compare the structure it passed to add, and the newly added configuration after validate() has been called. Signed-off-by: Kieran Bingham --- include/libcamera/camera.h | 3 ++- src/libcamera/camera.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 4d1a4a9f52ec..aee3a69881fc 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -38,7 +38,8 @@ public: virtual ~CameraConfiguration(); - void addConfiguration(const StreamConfiguration &cfg); + StreamConfiguration &addConfiguration(const StreamConfiguration &cfg); + virtual Status validate() = 0; StreamConfiguration &at(unsigned int index); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 69a1b4428e3f..a3b91cecc86d 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -104,10 +104,18 @@ CameraConfiguration::~CameraConfiguration() /** * \brief Add a stream configuration to the camera configuration * \param[in] cfg The stream configuration + * + * This method adds a new stream configuration to the CameraConfiguration using + * the values given in cfg, which are copied. A reference to the destination + * new StreamConfiguration is returned. + * + * \return A reference to the newly added stream configuration */ -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) +StreamConfiguration &CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) { config_.push_back(cfg); + + return config_.back(); } /**