From patchwork Fri Apr 5 23:58:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 928 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 324A3610C5 for ; Sat, 6 Apr 2019 01:59:22 +0200 (CEST) X-Halon-ID: d3b31c62-57fe-11e9-8144-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id d3b31c62-57fe-11e9-8144-0050569116f7; Sat, 06 Apr 2019 01:59:19 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 6 Apr 2019 01:58:39 +0200 Message-Id: <20190405235842.27884-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190405235842.27884-1-niklas.soderlund@ragnatech.se> References: <20190405235842.27884-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/8] libcamera: stream: Add basic stream usages X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 23:59:22 -0000 In preparation of reworking how a default configuration is retrieved from a camera add stream usages. The usages will be used by applications to describe how they intend to use a camera and replace the Stream IDs when retrieving default configuration from the camera using streamConfiguration(). Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- include/libcamera/stream.h | 40 +++++++++++++++++ src/libcamera/stream.cpp | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 970c479627fab064..d0f7b0e124851f10 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -8,6 +8,7 @@ #define __LIBCAMERA_STREAM_H__ #include +#include namespace libcamera { @@ -21,9 +22,48 @@ struct StreamConfiguration { unsigned int bufferCount; }; +class StreamUsage +{ +public: + enum Role { + StillCapture, + VideoRecording, + Viewfinder, + }; + + Role role() const { return role_; } + const Size &size() const { return size_; } + +protected: + explicit StreamUsage(Role role); + StreamUsage(Role role, int width, int height); + +private: + Role role_; + Size size_; +}; + class Stream final { public: + class StillCapture : public StreamUsage + { + public: + StillCapture(); + }; + + class VideoRecording : public StreamUsage + { + public: + VideoRecording(); + }; + + class Viewfinder : public StreamUsage + { + public: + Viewfinder(int width, int height); + }; + Stream(); BufferPool &bufferPool() { return bufferPool_; } const StreamConfiguration &configuration() const { return configuration_; } diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index c4943c91b2e6ce13..85cd5256ee2f0aa4 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -60,6 +60,65 @@ namespace libcamera { * \brief Requested number of buffers to allocate for the stream */ +/** + * \class StreamUsage + * \brief Stream usage information + * + * The StreamUsage class describes how an application intends to use a stream. + * Usages are specified by applications and passed to cameras, that then select + * the most appropriate streams and their default configurations. + */ + +/** + * \enum StreamUsage::Role + * \brief Identify the role a stream is intended to play + * \var StreamUsage::StillCapture + * The stream is intended to capture high-resolution, high-quality still images + * with low frame rate. The captured frames may be exposed with flash. + * \var StreamUsage::VideoRecording + * The stream is intended to capture video for the purpose of recording or + * streaming. The video stream may produce a high frame rate and may be + * enhanced with video stabilization. + * \var StreamUsage::Viewfinder + * The stream is intended to capture video for the purpose of display on the + * local screen. The StreamUsage includes the desired resolution. Trade-offs + * between quality and usage of system resources are acceptable. + */ + +/** + * \fn StreamUsage::role() + * \brief Retrieve the stream role + * + * \return The stream role + */ + +/** + * \fn StreamUsage::size() + * \brief Retrieve desired size + * + * \return The desired size + */ + +/** + * \brief Create a stream usage + * \param[in] role Stream role + */ +StreamUsage::StreamUsage(Role role) + : role_(role) +{ +} + +/** + * \brief Create a stream usage with a desired size + * \param[in] role Stream role + * \param[in] width The desired width + * \param[in] height The desired height + */ +StreamUsage::StreamUsage(Role role, int width, int height) + : role_(role), size_(Size(width, height)) +{ +} + /** * \class Stream * \brief Video stream for a camera @@ -78,6 +137,39 @@ namespace libcamera { * optimal stream for the task. */ +/** + * \class Stream::StillCapture + * \brief Describe a still capture usage + */ +Stream::StillCapture::StillCapture() + : StreamUsage(Role::StillCapture) +{ +} + +/** + * \class Stream::VideoRecording + * \brief Describe a video recording usage + */ +Stream::VideoRecording::VideoRecording() + : StreamUsage(Role::VideoRecording) +{ +} + +/** + * \class Stream::Viewfinder + * \brief Describe a viewfinder usage + */ + +/** + * \brief Create a viewfinder usage with a desired dimension + * \param[in] width The desired viewfinder width + * \param[in] height The desired viewfinder height + */ +Stream::Viewfinder::Viewfinder(int width, int height) + : StreamUsage(Role::Viewfinder, width, height) +{ +} + /** * \brief Construct a stream with default parameters */