diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-12-26 23:45:04 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-03 00:59:06 +0200 |
commit | 973c12488c772e02ee9f027a49f25052cd991c20 (patch) | |
tree | ec5534117a967a66e2f54b96bf315fa9f2fc148f /src/libcamera/pipeline/simple/converter.h | |
parent | be50270b7dedd596d5cca34ca66dce82fc92fe73 (diff) |
libcamera: pipeline: simple: converter: Add multi-stream support
While the M2M device backing the converter doesn't support multiple
streams natively, it can be run once per stream to produce multiple
outputs from the same input, with different output formats and sizes.
To support this, create a class to model a stream and move control of
the M2M device to the Stream class. The SimpleConverter class then
creates stream instances and iterates over them. Each stream needs its
own instance of the V4L2M2MDevice, to support different output
configurations. The SimpleConverter class retains a device instance to
support the query operations.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/simple/converter.h')
-rw-r--r-- | src/libcamera/pipeline/simple/converter.h | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h index be6844ca..480e528d 100644 --- a/src/libcamera/pipeline/simple/converter.h +++ b/src/libcamera/pipeline/simple/converter.h @@ -8,13 +8,18 @@ #ifndef __LIBCAMERA_PIPELINE_SIMPLE_CONVERTER_H__ #define __LIBCAMERA_PIPELINE_SIMPLE_CONVERTER_H__ +#include <functional> +#include <map> #include <memory> +#include <string> #include <tuple> #include <vector> #include <libcamera/pixel_format.h> #include <libcamera/signal.h> +#include "libcamera/internal/log.h" + namespace libcamera { class FrameBuffer; @@ -38,26 +43,57 @@ public: strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size); int configure(const StreamConfiguration &inputCfg, - const StreamConfiguration &outputCfg); - int exportBuffers(unsigned int count, + const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfg); + int exportBuffers(unsigned int ouput, unsigned int count, std::vector<std::unique_ptr<FrameBuffer>> *buffers); int start(); void stop(); - int queueBuffers(FrameBuffer *input, FrameBuffer *output); + int queueBuffers(FrameBuffer *input, + const std::map<unsigned int, FrameBuffer *> &outputs); Signal<FrameBuffer *> inputBufferReady; Signal<FrameBuffer *> outputBufferReady; private: - void m2mInputBufferReady(FrameBuffer *buffer); - void m2mOutputBufferReady(FrameBuffer *buffer); + class Stream : protected Loggable + { + public: + Stream(SimpleConverter *converter, unsigned int index); + + bool isValid() const { return m2m_ != nullptr; } + + int configure(const StreamConfiguration &inputCfg, + const StreamConfiguration &outputCfg); + int exportBuffers(unsigned int count, + std::vector<std::unique_ptr<FrameBuffer>> *buffers); + + int start(); + void stop(); + + int queueBuffers(FrameBuffer *input, FrameBuffer *output); + + protected: + std::string logPrefix() const override; + + private: + void captureBufferReady(FrameBuffer *buffer); + void outputBufferReady(FrameBuffer *buffer); + + SimpleConverter *converter_; + unsigned int index_; + std::unique_ptr<V4L2M2MDevice> m2m_; + + unsigned int inputBufferCount_; + unsigned int outputBufferCount_; + }; + std::string deviceNode_; std::unique_ptr<V4L2M2MDevice> m2m_; - unsigned int inputBufferCount_; - unsigned int outputBufferCount_; + std::vector<Stream> streams_; + std::map<FrameBuffer *, unsigned int> queue_; }; } /* namespace libcamera */ |