From patchwork Fri Jan 25 15:33:35 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: 381 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 C87C260C6A for ; Fri, 25 Jan 2019 16:33:52 +0100 (CET) X-Halon-ID: 9d3d18f7-20b6-11e9-874f-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 9d3d18f7-20b6-11e9-874f-005056917f90; Fri, 25 Jan 2019 16:33:50 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 16:33:35 +0100 Message-Id: <20190125153340.2744-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125153340.2744-1-niklas.soderlund@ragnatech.se> References: <20190125153340.2744-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/7] 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: Fri, 25 Jan 2019 15:33:53 -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 */