From patchwork Thu Nov 24 02:51:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17852 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 4A63DBDE6B for ; Thu, 24 Nov 2022 02:51:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E80B96331E; Thu, 24 Nov 2022 03:51:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669258313; bh=40cx5Kok1BbswVCPQnu1hRgCA5VMy9jgv48Cub9+y5M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Zx7cOUTBdqgHFpMU2hRK07AeLEPjssaRtpZlKu0sncH3L4fcLW1qXoZPIU94S2K5D EDAd0BdIdHzNpqJ0mWMRqGmEYTMMUC22eSGde5eqEJm/z0cjizRhAdYCNfB8XpRRf+ mBGynAQkeEu3QzPEphQje6AKiFsb17a/YKpRf5F1sQF5+IVapnRiWLg/Zu7sAzUrbT MvgRrkV3vwoDID8M25SgEh6dqw2Qxu88nd4t4zx2iQKLKI/SjPlB6CyuIaOj3JWpAi K645iMBcPW7OxnYX2kkQ9BP0cbsIkG76/7bbhox7el93N5+McJXCKVtz8F/9dxBg6f dFWBHvWoLcNzA== 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 B95FE63313 for ; Thu, 24 Nov 2022 03:51:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="O2uDbMt4"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 48647496 for ; Thu, 24 Nov 2022 03:51:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669258311; bh=40cx5Kok1BbswVCPQnu1hRgCA5VMy9jgv48Cub9+y5M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O2uDbMt4ydJ+YIYqMA0aRl8Z4FAZK9i2+oWgT1x+wUnwrqounlQPdHUmK4+ZA/6EN EcASrU2r46KWzqC+JT8N/FNDO6EJMR1u/G70CEy0tKUpiWMKP99/1BsP4ZHvE0jjuo wMjk9cP20ACf9WezOvzxcRgiYEj9lAvBSHBXhc5E= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 04:51:25 +0200 Message-Id: <20221124025133.17875-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221124025133.17875-1-laurent.pinchart@ideasonboard.com> References: <20221124025133.17875-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/9] libcamera: stream: Add operator<<() to print StreamRole as a string 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera prints stream role values in log messages. To be more user-friendly, add a specialization of operator<<() to print the role name as a string instead of a numerical value. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- include/libcamera/stream.h | 3 +++ src/libcamera/stream.cpp | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index f0ae7e62e0a3..efec695ad317 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -70,6 +71,8 @@ enum StreamRole { using StreamRoles = std::vector; +std::ostream &operator<<(std::ostream &out, StreamRole role); + class Stream { public: diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 686e693bccba..67f308157fbf 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -417,6 +417,25 @@ std::string StreamConfiguration::toString() const * acceptable. */ +/** + * \brief Insert a text representation of a StreamRole into an output stream + * \param[in] out The output stream + * \param[in] role The StreamRole + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, StreamRole role) +{ + static constexpr std::array names{ + "Raw", + "StillCapture", + "VideoRecording", + "Viewfinder", + }; + + out << names[static_cast>(role)]; + return out; +} + /** * \typedef StreamRoles * \brief A vector of StreamRole