From patchwork Fri Dec 6 16:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22235 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 CCBE1BE173 for ; Fri, 6 Dec 2024 16:22:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 114B867E1F; Fri, 6 Dec 2024 17:22:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YvOJ6UuJ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E8BE618B3 for ; Fri, 6 Dec 2024 17:22:38 +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 5B615641; Fri, 6 Dec 2024 17:22:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733502128; bh=ac0ikermms3mqQBuukq11Cn/a7MveYiZuQx8G95R20A=; h=From:To:Cc:Subject:Date:From; b=YvOJ6UuJzDxKYh1bovcBo0tSUm/uJiBcgaBcLXI1O3yUTx4NWP00kavJIz8yW92F4 fbMnu9c/l3zFB71gbe6QnchDVQzziOcTTxoZKjXQrlGZaYEdQ4Uo8HRBgVhIegjMSO P+X2RP+yl7etycvnExpeDmxDTEsDEx8qGSnAvXz8= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi Subject: [PATCH v2] libcamera: stream: Add operator<<(StreamConfiguration) Date: Fri, 6 Dec 2024 17:22:29 +0100 Message-ID: <20241206162230.97619-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 --- include/libcamera/stream.h | 2 ++ src/libcamera/stream.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) -- 2.47.1 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..63aa5a027295 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 << size.toString() + "-" + pixelFormat.toString(); + return out; } /**