33struct StreamConfiguration;
43 bool isValid()
const override {
return m2m_ !=
nullptr; }
45 std::vector<PixelFormat> formats(
PixelFormat input)
override;
48 std::tuple<unsigned int, unsigned int>
57 const std::vector<std::reference_wrapper<StreamConfiguration>>
61 std::vector<std::unique_ptr<FrameBuffer>> *buffers)
override;
70 const std::map<const Stream *, FrameBuffer *> &outputs,
74 std::pair<Rectangle, Rectangle>
inputCropBounds()
override {
return inputCropBounds_; }
80 std::vector<std::unique_ptr<V4L2Request>> *requests);
85 class V4L2M2MStream :
protected Loggable
90 bool isValid()
const {
return m2m_ !=
nullptr; }
92 int configure(
const StreamConfiguration &inputCfg,
93 const StreamConfiguration &outputCfg);
94 int exportBuffers(
unsigned int count,
95 std::vector<std::unique_ptr<FrameBuffer>> *buffers);
100 int applyControls(ControlList &ctrls,
const V4L2Request *request =
nullptr);
102 int queueBuffers(FrameBuffer *input, FrameBuffer *output,
103 const V4L2Request *request =
nullptr);
105 int setInputSelection(
unsigned int target, Rectangle *rect);
106 int getInputSelection(
unsigned int target, Rectangle *rect);
108 std::pair<Rectangle, Rectangle> inputCropBounds();
111 std::string logPrefix()
const override;
114 void captureBufferReady(FrameBuffer *buffer);
117 V4L2M2MConverter *converter_;
118 const Stream *stream_;
119 std::unique_ptr<V4L2M2MDevice> m2m_;
121 unsigned int inputBufferCount_;
122 unsigned int outputBufferCount_;
124 std::pair<Rectangle, Rectangle> inputCropBounds_;
127 Size adjustSizes(
const Size &size,
const std::vector<SizeRange> &ranges,
130 std::unique_ptr<V4L2M2MDevice> m2m_;
132 std::map<const Stream *, std::unique_ptr<V4L2M2MStream>> streams_;
133 std::map<FrameBuffer *, unsigned int> queue_;
134 std::pair<Rectangle, Rectangle> inputCropBounds_;
136 std::shared_ptr<MediaDevice> media_;
Associate a list of ControlId with their values for an object.
Definition controls.h:409
Abstract Base Class for converter.
Definition converter.h:36
Signal< FrameBuffer * > outputBufferReady
A signal emitted on each frame buffer completion of the output queue.
Definition converter.h:91
Alignment
The alignment mode specified when adjusting the converter input or output sizes.
Definition converter.h:45
@ Down
Adjust the Converter sizes to a smaller valid size.
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
Base class to support log message extensions.
Definition log.h:92
Describe a rectangle's position and dimensions.
Definition geometry.h:247
Describe a range of sizes.
Definition geometry.h:205
Describe a two-dimensional size.
Definition geometry.h:51
Video stream for a camera.
Definition stream.h:76
The V4L2 M2M converter implements the converter interface based on V4L2 M2M device.
Definition converter_v4l2_m2m.h:38
Size adjustOutputSize(const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down) override
Adjust the converter output size to a valid value.
Definition converter_v4l2_m2m.cpp:448
bool isConfigured(const Stream *stream) const override
Check if a given stream is configured.
Definition converter_v4l2_m2m.cpp:587
int setInputCrop(const Stream *stream, Rectangle *rect) override
Set the crop rectangle rect for stream.
Definition converter_v4l2_m2m.cpp:608
int start() override
Start the converter streaming operation.
Definition converter_v4l2_m2m.cpp:645
bool isValid() const override
Definition converter_v4l2_m2m.h:43
bool supportsRequests()
Check if requests are supported.
Definition converter_v4l2_m2m.cpp:802
int exportBuffers(const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers) override
Export buffers from the converter device.
Definition converter_v4l2_m2m.cpp:595
std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) override
Retrieve the output stride and frame size for an input configutation.
Definition converter_v4l2_m2m.cpp:412
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfg) override
Configure a set of output stream conversion from an input stream.
Definition converter_v4l2_m2m.cpp:550
int allocateRequests(unsigned int count, std::vector< std::unique_ptr< V4L2Request > > *requests)
Allocate requests.
Definition converter_v4l2_m2m.cpp:786
std::pair< Rectangle, Rectangle > inputCropBounds() override
Retrieve the crop bounds of the converter.
Definition converter_v4l2_m2m.h:74
Size adjustInputSize(const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down) override
Adjust the converter input size to a valid value.
Definition converter_v4l2_m2m.cpp:429
int loadConfiguration(const std::string &filename) override
Definition converter_v4l2_m2m.h:42
int validateOutput(StreamConfiguration *cfg, bool *adjusted, Alignment align=Alignment::Down) override
Validate and possibily adjust cfg to a valid converter output.
Definition converter_v4l2_m2m.cpp:672
int queueBuffers(FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs, const V4L2Request *request=nullptr) override
Queue buffers to converter device.
Definition converter_v4l2_m2m.cpp:720
void stop() override
Stop the converter streaming operation.
Definition converter_v4l2_m2m.cpp:663
int applyControls(const Stream *stream, ControlList &ctrls, const V4L2Request *request=nullptr)
Apply controls.
Definition converter_v4l2_m2m.cpp:773
SizeRange sizes(const Size &input) override
Retrieve the range of minimum and maximum output sizes for an input size.
Definition converter_v4l2_m2m.cpp:363
V4L2Request object and API.
Definition v4l2_request.h:22
Top-level libcamera namespace.
Definition backtrace.h:17
Signal & slot implementation.
Configuration parameters for a stream.
Definition stream.h:40