From patchwork Fri Dec 6 18:30:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22254 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 73EFBBE173 for ; Fri, 6 Dec 2024 18:30:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51B3967E3C; Fri, 6 Dec 2024 19:30:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BMSDq1lG"; 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 9BEA3618B3 for ; Fri, 6 Dec 2024 19:30:44 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C0B4DB2B; Fri, 6 Dec 2024 19:30:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733509815; bh=tlCiCVsWM/KHaFwXfpVs9RnN9F9AeC8pr3J50dbiSxM=; h=From:To:Cc:Subject:Date:From; b=BMSDq1lGiXe5Orn9dLaXDCpEgD4HLtCMwn/LkC/bIX3bhjJlq9n6sqF5cLY3RCNBK JMiRmRjCj0NkdLFxqLaxHdKBgecstD8vdTZMuQse4SXV4uCA0SG5Hn0TiGJzkp0hEq X6gCHd5ntQenlpTijgY+e4xmU35xc1rH7cMHBYDo= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Kieran Bingham , Stefan Klug , Laurent Pinchart Subject: [PATCH v4] libcamera: stream: Add operator<<(StreamConfiguration) Date: Fri, 6 Dec 2024 19:30:35 +0100 Message-ID: <20241206183036.107837-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 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" The StreamConfiguration class only implements toString() but doesn't offer an overload of operator<<() which is more convenient to use. Add an overload for operator<<(StreamConfiguration) and re-implement StreamConfiguration::toString() on top of it. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Stefan Klug Reviewed-by: Laurent Pinchart --- include/libcamera/stream.h | 2 ++ src/libcamera/stream.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 071b71698acb..ea228aea7d56 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -61,6 +61,8 @@ private: StreamFormats formats_; }; +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg); + enum class StreamRole { Raw, StillCapture, diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 1f75dbbc5b64..eb92cb69df31 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -392,7 +392,23 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) */ std::string StreamConfiguration::toString() const { - return size.toString() + "-" + pixelFormat.toString(); + std::stringstream ss; + ss << *this; + + return ss.str(); +} + +/** + * \brief Insert a text representation of a StreamConfiguration into an output + * stream + * \param[in] out The output stream + * \param[in] cfg The StreamConfiguration + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg) +{ + out << cfg.size << "-" << cfg.pixelFormat; + return out; } /**