From patchwork Tue Apr 2 00:53:31 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: 835 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4B73610BF for ; Tue, 2 Apr 2019 02:54:02 +0200 (CEST) X-Halon-ID: cde5a054-54e1-11e9-846a-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id cde5a054-54e1-11e9-846a-005056917a89; Tue, 02 Apr 2019 02:54:01 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Apr 2019 02:53:31 +0200 Message-Id: <20190402005332.25018-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190402005332.25018-1-niklas.soderlund@ragnatech.se> References: <20190402005332.25018-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 4/5] libcamera: stream: Add basic stream usage hints definitions 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: Tue, 02 Apr 2019 00:54:02 -0000 In preparation of reworking how a default configuration is retrieved from a camera add stream usage hints. The hints will be used by applications to describe how it intends to use a camera and replace the Stream IDs role when retrieving default configuration from the camera using streamConfiguration(). Signed-off-by: Niklas Söderlund --- include/libcamera/stream.h | 39 ++++++++++++++++++ src/libcamera/stream.cpp | 84 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 3e8e83a2ff245879..445b80de66217934 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -35,7 +35,46 @@ private: StreamConfiguration configuration_; }; +class StreamHint +{ +public: + enum Type { + Viewfinder, + Video, + Still, + }; + Type type() const { return type_; } + +protected: + StreamHint(Type type); + StreamHint(Type type, StreamConfiguration hints); + +private: + Type type_; + StreamConfiguration hints_; +}; + +class Viewfinder : public StreamHint +{ +public: + Viewfinder(unsigned int width, unsigned int height); + +private: + static StreamConfiguration initHints(unsigned int width, unsigned int height); +}; + +class Video : public StreamHint +{ +public: + Video(); +}; + +class Still : public StreamHint +{ +public: + Still(); +}; } /* namespace libcamera */ diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index c4943c91b2e6ce13..32f26a1f8e6adb2c 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -102,4 +102,88 @@ Stream::Stream() * \return The active configuration of the stream */ +/** + * \class StreamHint + * \brief Stream usage hint information + * + * The StreamHint class carries information about stream usage hints from the + * application to a specific pipeline handler implementation. The pipeline + * handler shall take the usage hints into account when select which stream + * to use for the desired operation. + */ + +/** + * \enum StreamHint::Type + * \brief List of types of usage hints + */ + +/** + * \fn StreamHint::type() + * \brief Retrieve the usage hint type + * \return The hint type + */ + +/** + * \brief Create a stream hint + * \param[in] type Stream hint type + */ +StreamHint::StreamHint(Type type) + : type_(type), hints_() +{ +} + +/** + * \brief Create a stream hint with parameters + * \param[in] type Stream hint type + * \param[in] hints Stream hint parameters + */ +StreamHint::StreamHint(Type type, StreamConfiguration hints) + : type_(type), hints_(hints) +{ +} + +/** + * \class Viewfinder + * \brief Stream usage hint for viewfinder + */ + +/** + * \brief Create a viewfinder stream hint + * \param[in] width Desired view finder width + * \param[in] height Desired view finder height + */ +Viewfinder::Viewfinder(unsigned int width, unsigned int height) + : StreamHint(Type::Viewfinder, initHints(width, height)) +{ +} + +StreamConfiguration Viewfinder::initHints(unsigned int width, + unsigned int height) +{ + StreamConfiguration hints = {}; + + hints.width = width; + hints.height = height; + + return hints; +} + +/** + * \class Video + * \brief Stream usage hint for video + */ +Video::Video() + : StreamHint(Type::Video) +{ +} + +/** + * \class Still + * \brief Stream usage hint for still images + */ +Still::Still() + : StreamHint(Type::Still) +{ +} + } /* namespace libcamera */