From patchwork Tue Jan 22 23:44:59 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: 336 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 506A660C7D for ; Wed, 23 Jan 2019 00:46:39 +0100 (CET) X-Halon-ID: e8e61eee-1e9f-11e9-911a-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 e8e61eee-1e9f-11e9-911a-0050569116f7; Wed, 23 Jan 2019 00:46:16 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Jan 2019 00:44:59 +0100 Message-Id: <20190122234505.32634-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> References: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/8] libcamera: stream: add basic StreamConfiguration class 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, 22 Jan 2019 23:46:40 -0000 Add a simple StreamConfiguration class to hold configuration data for a single stream of a Camera. In its current form not many configuration parameters are supported but it's expected the number of options will grow over time. At this stage the pixel format is represented as a unsigned int to allow for a easy mapping to the V4L2 API. This might be subject to change in the future as we finalize how libcamera shall represent pixelformats. A StreamConfiguration objected needs to be created from the Stream object it should configure. As the two objects are so closely related I have at this stage opted to implement them in the same stream.{h,cpp} as the Stream class. Signed-off-by: Niklas Söderlund --- include/libcamera/stream.h | 20 ++++++++++++ src/libcamera/stream.cpp | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 415815ba12c65e47..8750797c36dd9b42 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -20,6 +20,26 @@ private: unsigned int id_; }; +class StreamConfiguration final +{ +public: + StreamConfiguration(class Stream &stream); + + unsigned int id() const { return id_; }; + unsigned int width() const { return width_; }; + unsigned int height() const { return height_; }; + unsigned int pixelformat() const { return pixelformat_; }; + + void setDimension(unsigned int width, unsigned int height); + void setPixelFormat(unsigned int pixelformat); + +private: + unsigned int id_; + unsigned int width_; + unsigned int height_; + unsigned int pixelformat_; +}; + } /* namespace libcamera */ #endif /* __LIBCAMERA_STREAM_H__ */ diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 3b44e834ee02b35a..e40756260c5768f3 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -63,4 +63,68 @@ Stream::Stream(unsigned int id) * \return The stream ID */ +/** + * \class StreamConfiguration + * \brief Stream configuration object + * + * The StreamConfiguration class is a model of all information which can be + * configured for a single video stream. A application should acquire a all + * Stream object from a camera, select the ones it wish to use, create a + * StreamConfiguration for each of those streams, set the desired parameter on + * the objects and feed them back to the camera object to configure the camera. + */ + +/** + * \fn StreamConfiguration::id() + * \brief Retrieve the streams ID + * \return The stream ID + */ + +/** + * \fn StreamConfiguration::width() + * \brief Retrieve the Stream width + * \return The stream width + */ + +/** + * \fn StreamConfiguration::height() + * \brief Retrieve the Stream height + * \return The stream height + */ + +/** + * \fn StreamConfiguration::pixelformat() + * \brief Retrieve the Stream pixelformat + * \return The stream pixelformat + */ + +/** + * \brief Set desired width and height for the stream + * \param[in] width The desired width of the stream + * \param[in] height The desired height of the stream + */ +void StreamConfiguration::setDimension(unsigned int width, unsigned int height) +{ + width_ = width; + height_ = height; +} + +/** + * \brief Set desired pixelformat for the stream + * \param[in] pixelformat The desired pixelformat of the stream + */ +void StreamConfiguration::setPixelFormat(unsigned int pixelformat) +{ + pixelformat_ = pixelformat; +} + +/** + * \brief Create a new configuration container for a stream + * \param[in] stream The stream object the configuration object should act on + */ +StreamConfiguration::StreamConfiguration(class Stream &stream) + : id_(stream.id()), width_(0), height_(0), pixelformat_(0) +{ +} + } /* namespace libcamera */