[libcamera-devel] [PATCH v2 2/7] libcamera: stream: add basic StreamConfiguration class
Niklas Söderlund
niklas.soderlund at ragnatech.se
Fri Jan 25 16:33:35 CET 2019
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 <niklas.soderlund at ragnatech.se>
---
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 */
--
2.20.1
More information about the libcamera-devel
mailing list