[PATCH v2 3/4] converter: converter_v4l2_m2m: Rename private Stream class
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed May 29 13:07:43 CEST 2024
Quoting Umang Jain (2024-05-29 08:02:47)
> Rename the private Stream class from V4L2M2MConverter::Stream to
> V4L2M2MConverter::V4L2M2MStream. This is done to improve readability
> of the code when we drop the handling of stream by indexes in a
> subsequent patch.
The namespaces do cover this already, but given I already got confused
by (V4L2M2MConverter::)Stream and (libcamera::)Stream, I think this is
beneficial...
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
> ---
> .../internal/converter/converter_v4l2_m2m.h | 6 ++--
> .../converter/converter_v4l2_m2m.cpp | 34 +++++++++----------
> 2 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h
> index 1126050c..0da62290 100644
> --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h
> +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h
> @@ -57,10 +57,10 @@ public:
> const std::map<unsigned int, FrameBuffer *> &outputs);
>
> private:
> - class Stream : protected Loggable
> + class V4L2M2MStream : protected Loggable
> {
> public:
> - Stream(V4L2M2MConverter *converter, unsigned int index);
> + V4L2M2MStream(V4L2M2MConverter *converter, unsigned int index);
>
> bool isValid() const { return m2m_ != nullptr; }
>
> @@ -91,7 +91,7 @@ private:
>
> std::unique_ptr<V4L2M2MDevice> m2m_;
>
> - std::vector<Stream> streams_;
> + std::vector<V4L2M2MStream> streams_;
> std::map<FrameBuffer *, unsigned int> queue_;
> };
>
> diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp
> index 27a50e34..6309a0c0 100644
> --- a/src/libcamera/converter/converter_v4l2_m2m.cpp
> +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp
> @@ -32,24 +32,24 @@ namespace libcamera {
> LOG_DECLARE_CATEGORY(Converter)
>
> /* -----------------------------------------------------------------------------
> - * V4L2M2MConverter::Stream
> + * V4L2M2MConverter::V4L2M2MStream
> */
>
> -V4L2M2MConverter::Stream::Stream(V4L2M2MConverter *converter, unsigned int index)
> +V4L2M2MConverter::V4L2M2MStream::V4L2M2MStream(V4L2M2MConverter *converter, unsigned int index)
> : converter_(converter), index_(index)
> {
> m2m_ = std::make_unique<V4L2M2MDevice>(converter->deviceNode());
>
> - m2m_->output()->bufferReady.connect(this, &Stream::outputBufferReady);
> - m2m_->capture()->bufferReady.connect(this, &Stream::captureBufferReady);
> + m2m_->output()->bufferReady.connect(this, &V4L2M2MStream::outputBufferReady);
> + m2m_->capture()->bufferReady.connect(this, &V4L2M2MStream::captureBufferReady);
>
> int ret = m2m_->open();
> if (ret < 0)
> m2m_.reset();
> }
>
> -int V4L2M2MConverter::Stream::configure(const StreamConfiguration &inputCfg,
> - const StreamConfiguration &outputCfg)
> +int V4L2M2MConverter::V4L2M2MStream::configure(const StreamConfiguration &inputCfg,
> + const StreamConfiguration &outputCfg)
> {
> V4L2PixelFormat videoFormat =
> m2m_->output()->toV4L2PixelFormat(inputCfg.pixelFormat);
> @@ -101,13 +101,13 @@ int V4L2M2MConverter::Stream::configure(const StreamConfiguration &inputCfg,
> return 0;
> }
>
> -int V4L2M2MConverter::Stream::exportBuffers(unsigned int count,
> - std::vector<std::unique_ptr<FrameBuffer>> *buffers)
> +int V4L2M2MConverter::V4L2M2MStream::exportBuffers(unsigned int count,
> + std::vector<std::unique_ptr<FrameBuffer>> *buffers)
> {
> return m2m_->capture()->exportBuffers(count, buffers);
> }
>
> -int V4L2M2MConverter::Stream::start()
> +int V4L2M2MConverter::V4L2M2MStream::start()
> {
> int ret = m2m_->output()->importBuffers(inputBufferCount_);
> if (ret < 0)
> @@ -134,7 +134,7 @@ int V4L2M2MConverter::Stream::start()
> return 0;
> }
>
> -void V4L2M2MConverter::Stream::stop()
> +void V4L2M2MConverter::V4L2M2MStream::stop()
> {
> m2m_->capture()->streamOff();
> m2m_->output()->streamOff();
> @@ -142,7 +142,7 @@ void V4L2M2MConverter::Stream::stop()
> m2m_->output()->releaseBuffers();
> }
>
> -int V4L2M2MConverter::Stream::queueBuffers(FrameBuffer *input, FrameBuffer *output)
> +int V4L2M2MConverter::V4L2M2MStream::queueBuffers(FrameBuffer *input, FrameBuffer *output)
> {
> int ret = m2m_->output()->queueBuffer(input);
> if (ret < 0)
> @@ -155,12 +155,12 @@ int V4L2M2MConverter::Stream::queueBuffers(FrameBuffer *input, FrameBuffer *outp
> return 0;
> }
>
> -std::string V4L2M2MConverter::Stream::logPrefix() const
> +std::string V4L2M2MConverter::V4L2M2MStream::logPrefix() const
> {
> return "stream" + std::to_string(index_);
> }
>
> -void V4L2M2MConverter::Stream::outputBufferReady(FrameBuffer *buffer)
> +void V4L2M2MConverter::V4L2M2MStream::outputBufferReady(FrameBuffer *buffer)
> {
> auto it = converter_->queue_.find(buffer);
> if (it == converter_->queue_.end())
> @@ -172,7 +172,7 @@ void V4L2M2MConverter::Stream::outputBufferReady(FrameBuffer *buffer)
> }
> }
>
> -void V4L2M2MConverter::Stream::captureBufferReady(FrameBuffer *buffer)
> +void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer)
> {
> converter_->outputBufferReady.emit(buffer);
> }
> @@ -336,7 +336,7 @@ int V4L2M2MConverter::configure(const StreamConfiguration &inputCfg,
> streams_.reserve(outputCfgs.size());
>
> for (unsigned int i = 0; i < outputCfgs.size(); ++i) {
> - Stream &stream = streams_.emplace_back(this, i);
> + V4L2M2MStream &stream = streams_.emplace_back(this, i);
>
> if (!stream.isValid()) {
> LOG(Converter, Error)
> @@ -377,7 +377,7 @@ int V4L2M2MConverter::start()
> {
> int ret;
>
> - for (Stream &stream : streams_) {
> + for (V4L2M2MStream &stream : streams_) {
> ret = stream.start();
> if (ret < 0) {
> stop();
> @@ -393,7 +393,7 @@ int V4L2M2MConverter::start()
> */
> void V4L2M2MConverter::stop()
> {
> - for (Stream &stream : utils::reverse(streams_))
> + for (V4L2M2MStream &stream : utils::reverse(streams_))
> stream.stop();
> }
>
> --
> 2.44.0
>
More information about the libcamera-devel
mailing list