converter: converter_v4l2_m2m: Rename private Stream class
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. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
ec2402a1ad
commit
7f85673e13
2 changed files with 20 additions and 20 deletions
|
@ -57,10 +57,10 @@ public:
|
||||||
const std::map<unsigned int, FrameBuffer *> &outputs);
|
const std::map<unsigned int, FrameBuffer *> &outputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Stream : protected Loggable
|
class V4L2M2MStream : protected Loggable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Stream(V4L2M2MConverter *converter, unsigned int index);
|
V4L2M2MStream(V4L2M2MConverter *converter, unsigned int index);
|
||||||
|
|
||||||
bool isValid() const { return m2m_ != nullptr; }
|
bool isValid() const { return m2m_ != nullptr; }
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<V4L2M2MDevice> m2m_;
|
std::unique_ptr<V4L2M2MDevice> m2m_;
|
||||||
|
|
||||||
std::vector<Stream> streams_;
|
std::vector<V4L2M2MStream> streams_;
|
||||||
std::map<FrameBuffer *, unsigned int> queue_;
|
std::map<FrameBuffer *, unsigned int> queue_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,24 +32,24 @@ namespace libcamera {
|
||||||
LOG_DECLARE_CATEGORY(Converter)
|
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)
|
: converter_(converter), index_(index)
|
||||||
{
|
{
|
||||||
m2m_ = std::make_unique<V4L2M2MDevice>(converter->deviceNode());
|
m2m_ = std::make_unique<V4L2M2MDevice>(converter->deviceNode());
|
||||||
|
|
||||||
m2m_->output()->bufferReady.connect(this, &Stream::outputBufferReady);
|
m2m_->output()->bufferReady.connect(this, &V4L2M2MStream::outputBufferReady);
|
||||||
m2m_->capture()->bufferReady.connect(this, &Stream::captureBufferReady);
|
m2m_->capture()->bufferReady.connect(this, &V4L2M2MStream::captureBufferReady);
|
||||||
|
|
||||||
int ret = m2m_->open();
|
int ret = m2m_->open();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
m2m_.reset();
|
m2m_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2M2MConverter::Stream::configure(const StreamConfiguration &inputCfg,
|
int V4L2M2MConverter::V4L2M2MStream::configure(const StreamConfiguration &inputCfg,
|
||||||
const StreamConfiguration &outputCfg)
|
const StreamConfiguration &outputCfg)
|
||||||
{
|
{
|
||||||
V4L2PixelFormat videoFormat =
|
V4L2PixelFormat videoFormat =
|
||||||
m2m_->output()->toV4L2PixelFormat(inputCfg.pixelFormat);
|
m2m_->output()->toV4L2PixelFormat(inputCfg.pixelFormat);
|
||||||
|
@ -101,13 +101,13 @@ int V4L2M2MConverter::Stream::configure(const StreamConfiguration &inputCfg,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2M2MConverter::Stream::exportBuffers(unsigned int count,
|
int V4L2M2MConverter::V4L2M2MStream::exportBuffers(unsigned int count,
|
||||||
std::vector<std::unique_ptr<FrameBuffer>> *buffers)
|
std::vector<std::unique_ptr<FrameBuffer>> *buffers)
|
||||||
{
|
{
|
||||||
return m2m_->capture()->exportBuffers(count, buffers);
|
return m2m_->capture()->exportBuffers(count, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2M2MConverter::Stream::start()
|
int V4L2M2MConverter::V4L2M2MStream::start()
|
||||||
{
|
{
|
||||||
int ret = m2m_->output()->importBuffers(inputBufferCount_);
|
int ret = m2m_->output()->importBuffers(inputBufferCount_);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -134,7 +134,7 @@ int V4L2M2MConverter::Stream::start()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V4L2M2MConverter::Stream::stop()
|
void V4L2M2MConverter::V4L2M2MStream::stop()
|
||||||
{
|
{
|
||||||
m2m_->capture()->streamOff();
|
m2m_->capture()->streamOff();
|
||||||
m2m_->output()->streamOff();
|
m2m_->output()->streamOff();
|
||||||
|
@ -142,7 +142,7 @@ void V4L2M2MConverter::Stream::stop()
|
||||||
m2m_->output()->releaseBuffers();
|
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);
|
int ret = m2m_->output()->queueBuffer(input);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -155,12 +155,12 @@ int V4L2M2MConverter::Stream::queueBuffers(FrameBuffer *input, FrameBuffer *outp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string V4L2M2MConverter::Stream::logPrefix() const
|
std::string V4L2M2MConverter::V4L2M2MStream::logPrefix() const
|
||||||
{
|
{
|
||||||
return "stream" + std::to_string(index_);
|
return "stream" + std::to_string(index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V4L2M2MConverter::Stream::outputBufferReady(FrameBuffer *buffer)
|
void V4L2M2MConverter::V4L2M2MStream::outputBufferReady(FrameBuffer *buffer)
|
||||||
{
|
{
|
||||||
auto it = converter_->queue_.find(buffer);
|
auto it = converter_->queue_.find(buffer);
|
||||||
if (it == converter_->queue_.end())
|
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);
|
converter_->outputBufferReady.emit(buffer);
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ int V4L2M2MConverter::configure(const StreamConfiguration &inputCfg,
|
||||||
streams_.reserve(outputCfgs.size());
|
streams_.reserve(outputCfgs.size());
|
||||||
|
|
||||||
for (unsigned int i = 0; i < outputCfgs.size(); ++i) {
|
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()) {
|
if (!stream.isValid()) {
|
||||||
LOG(Converter, Error)
|
LOG(Converter, Error)
|
||||||
|
@ -377,7 +377,7 @@ int V4L2M2MConverter::start()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (Stream &stream : streams_) {
|
for (V4L2M2MStream &stream : streams_) {
|
||||||
ret = stream.start();
|
ret = stream.start();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
stop();
|
stop();
|
||||||
|
@ -393,7 +393,7 @@ int V4L2M2MConverter::start()
|
||||||
*/
|
*/
|
||||||
void V4L2M2MConverter::stop()
|
void V4L2M2MConverter::stop()
|
||||||
{
|
{
|
||||||
for (Stream &stream : utils::reverse(streams_))
|
for (V4L2M2MStream &stream : utils::reverse(streams_))
|
||||||
stream.stop();
|
stream.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue