From patchwork Wed Sep 2 15:22:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9467 X-Patchwork-Delegate: jacopo@jmondi.org 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 850D3BE174 for ; Wed, 2 Sep 2020 15:19:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 631AB62984; Wed, 2 Sep 2020 17:19:06 +0200 (CEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 646A9629A3 for ; Wed, 2 Sep 2020 17:19:05 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 46E3024000F; Wed, 2 Sep 2020 15:19:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Sep 2020 17:22:30 +0200 Message-Id: <20200902152236.69770-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902152236.69770-1-jacopo@jmondi.org> References: <20200902152236.69770-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/12] libcamera: camera_configuration: Return config index 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: , Cc: tfiga@google.com, hiroh@google.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When adding a new StreamConfiguration to a CameraConfiguration instance it might be useful to know how what is the index of the newly added item to be able to retrieve it later. Return the index of the newly inserted item, which corresponds to the 0-indexed number of items in the CameraConfiguration::config_ vector, from CameraConfiguration::addConfiguration(). Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi Acked-by: Laurent Pinchart --- include/libcamera/camera.h | 2 +- src/libcamera/camera.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 272c12c3c473..53c32afa23a5 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -39,7 +39,7 @@ public: virtual ~CameraConfiguration(); - void addConfiguration(const StreamConfiguration &cfg); + int 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 4a9c19c33cfb..9a8923620e24 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration() /** * \brief Add a stream configuration to the camera configuration * \param[in] cfg The stream configuration + * \return The index of the newly added stream configuration */ -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) { config_.push_back(cfg); + + return config_.size() - 1; } /**