libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::V4L2M2MConverter Class Reference

The V4L2 M2M converter implements the converter interface based on V4L2 M2M device. More...

Inheritance diagram for libcamera::V4L2M2MConverter:
[legend]
Collaboration diagram for libcamera::V4L2M2MConverter:
[legend]

## Public Member Functions
| V4L2M2MConverter (std::shared_ptr< MediaDevice > media)
| Construct a V4L2M2MConverter instance.
int | loadConfiguration (const std::string &filename) override
bool | isValid () const override
std::vector< PixelFormat > | formats (PixelFormat input) override
SizeRange | sizes (const Size &input) override
| Retrieve the range of minimum and maximum output sizes for an input size.
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.
Size | adjustInputSize (const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down) override
| Adjust the converter input size to a valid value.
Size | adjustOutputSize (const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down) override
| Adjust the converter output size to a valid value.
int | configure (const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfg) override
| Configure a set of output stream conversion from an input stream.
bool | isConfigured (const Stream *stream) const override
| Check if a given stream is configured.
int | exportBuffers (const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers) override
| Export buffers from the converter device.
int | start () override
| Start the converter streaming operation.
void | stop () override
| Stop the converter streaming operation.
int | validateOutput (StreamConfiguration *cfg, bool *adjusted, Alignment align=Alignment::Down) override
| Validate and possibily adjust cfg to a valid converter output.
int | queueBuffers (FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs, const V4L2Request *request=nullptr) override
| Queue buffers to converter device.
int | setInputCrop (const Stream *stream, Rectangle *rect) override
| Set the crop rectangle rect for stream.
std::pair< Rectangle, Rectangle > | inputCropBounds () override
| Retrieve the crop bounds of the converter.
std::pair< Rectangle, Rectangle > | inputCropBounds (const Stream *stream) override
| Retrieve the crop bounds for stream.
int | applyControls (const Stream *stream, ControlList &ctrls, const V4L2Request *request=nullptr)
| Apply controls.
int | allocateRequests (unsigned int count, std::vector< std::unique_ptr< V4L2Request > > *requests)
| Allocate requests.
bool | supportsRequests ()
| Check if requests are supported.
Public Member Functions inherited from libcamera::Converter
| Converter (std::shared_ptr< MediaDevice > media, Features features=Feature::None)
| Construct a Converter instance.
const std::string & | deviceNode () const
| The converter device node attribute accessor.
Features | features () const
| Retrieve the features supported by the converter.

## Additional Inherited Members
Public Types inherited from libcamera::Converter
enum class | Feature { None = 0 , InputCrop = (1 << 0) }
| Specify the features supported by the converter. More...
enum class | Alignment { Down = 0 , Up }
| The alignment mode specified when adjusting the converter input or output sizes. More...
using | Features = Flags<Feature>
| A bitwise combination of features supported by the converter.
Public Attributes inherited from libcamera::Converter
Signal< FrameBuffer * > | inputBufferReady
| A signal emitted when the input frame buffer completes.
Signal< FrameBuffer * > | outputBufferReady
| A signal emitted on each frame buffer completion of the output queue.
Protected Attributes inherited from libcamera::Converter
Features | features_
| Stores the features supported by the converter.

## Detailed Description

The V4L2 M2M converter implements the converter interface based on V4L2 M2M device.

## Constructor & Destructor Documentation

## ◆ V4L2M2MConverter()

libcamera::V4L2M2MConverter::V4L2M2MConverter | ( | std::shared_ptr< MediaDevice > | media | ) |

Construct a V4L2M2MConverter instance.

Parameters

  [in] | media | The media device implementing the converter

## Member Function Documentation

## ◆ adjustInputSize()

Size libcamera::V4L2M2MConverter::adjustInputSize | ( | const PixelFormat & | pixFmt,
|  | const Size & | size,
|  | Alignment | align = Alignment::Down )
| override virtual

Adjust the converter input size to a valid value.

Parameters

  [in] | pixFmt | The pixel format of the converter input stream
  [in] | size | The converter input size to adjust to a valid value
  [in] | align | The desired alignment

Returns
  The adjusted converter input size or a null Size if size cannot be adjusted

Implements libcamera::Converter.

## ◆ adjustOutputSize()

Size libcamera::V4L2M2MConverter::adjustOutputSize | ( | const PixelFormat & | pixFmt,
|  | const Size & | size,
|  | Alignment | align = Alignment::Down )
| override virtual

Adjust the converter output size to a valid value.

Parameters

  [in] | pixFmt | The pixel format of the converter output stream
  [in] | size | The converter output size to adjust to a valid value
  [in] | align | The desired alignment

Returns
  The adjusted converter output size or a null Size if size cannot be adjusted

Implements libcamera::Converter.

## ◆ allocateRequests()

int libcamera::V4L2M2MConverter::allocateRequests | ( | unsigned int | count,
|  | std::vector< std::unique_ptr< V4L2Request > > * | requests )

Allocate requests.

Parameters

  [in] | count | Number of requests to allocate
  [out] | requests | Vector to store allocated requests

Allocates and stores count requests in requests. If allocation fails, an error is returned and requests is cleared.

Returns
  0 on success or a negative error code otherwise

## ◆ applyControls()

int libcamera::V4L2M2MConverter::applyControls | ( | const Stream * | stream,
|  | ControlList & | ctrls,
|  | const V4L2Request * | request = nullptr )

Apply controls.

Parameters

  [in] | stream | The stream on which to apply the controls
  [in] | ctrls | The controls to apply
  [in] | request | An optional request

Returns
  0 on success or a negative error code otherwise

See also
  V4L2Device::setControls()

## ◆ configure()

int libcamera::V4L2M2MConverter::configure | ( | const StreamConfiguration & | inputCfg,
|  | const std::vector< std::reference_wrapper< const StreamConfiguration > > & | outputCfgs )
| override virtual

Configure a set of output stream conversion from an input stream.

Parameters

  [in] | inputCfg | Input stream configuration
  [out] | outputCfgs | A list of output stream configurations

Returns
  0 on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ exportBuffers()

int libcamera::V4L2M2MConverter::exportBuffers | ( | const Stream * | stream,
|  | unsigned int | count,
|  | std::vector< std::unique_ptr< FrameBuffer > > * | buffers )
| override virtual

Export buffers from the converter device.

Parameters

  [in] | stream | Output stream pointer exporting the buffers
  [in] | count | Number of buffers to allocate
  [out] | buffers | Vector to store allocated buffers

This function operates similarly to V4L2VideoDevice::exportBuffers() on the output stream indicated by the output.

Returns
  The number of allocated buffers on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ formats()

std::vector< PixelFormat > libcamera::V4L2M2MConverter::formats | ( | PixelFormat | input | ) |
| override virtual

Parameters

  [in] | input | Input pixel format to retrieve output pixel format list for

Returns
  The list of supported output pixel formats

Implements libcamera::Converter.

## ◆ inputCropBounds() [1/2]

std::pair< Rectangle, Rectangle > libcamera::V4L2M2MConverter::inputCropBounds | ( |  | ) |
| inline override virtual

Retrieve the crop bounds of the converter.

Retrieve the minimum and maximum crop bounds of the converter. This can be used to query the crop bounds before configuring a stream.

Returns
  A pair containing the minimum and maximum crop bound in that order

Implements libcamera::Converter.

## ◆ inputCropBounds() [2/2]

std::pair< Rectangle, Rectangle > libcamera::V4L2M2MConverter::inputCropBounds | ( | const Stream * | stream | ) |
| override virtual

Retrieve the crop bounds for stream.

Parameters

  [in] | stream | The output stream

Retrieve the minimum and maximum crop bounds for stream. The converter should support cropping (Feature::InputCrop).

The crop bounds depend on the configuration of the output stream and hence this function should be called after the stream has been configured using configure().

When called with an unconfigured stream, this function returns a pair of null rectangles.

Returns
  A pair containing the minimum and maximum crop bound in that order

Implements libcamera::Converter.

## ◆ isConfigured()

bool libcamera::V4L2M2MConverter::isConfigured | ( | const Stream * | stream | ) | const
| override virtual

Check if a given stream is configured.

Parameters

  [in] | stream | The output stream

Returns
  True if the stream is configured or false otherwise

Implements libcamera::Converter.

## ◆ isValid()

bool libcamera::V4L2M2MConverter::isValid | ( |  | ) | const
| inline override virtual

Returns
  True is the converter is valid, false otherwise

Implements libcamera::Converter.

## ◆ loadConfiguration()

int libcamera::V4L2M2MConverter::loadConfiguration | ( | const std::string & | filename | ) |
| inline override virtual

Parameters

  [in] | filename | The file name path

Load converter dependent configuration parameters to apply on the hardware.

Returns
  0 on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ queueBuffers()

int libcamera::V4L2M2MConverter::queueBuffers | ( | FrameBuffer * | input,
|  | const std::map< const Stream *, FrameBuffer * > & | outputs,
|  | const V4L2Request * | request = nullptr )
| override virtual

Queue buffers to converter device.

Parameters

  [in] | input | The frame buffer to apply the conversion
  [out] | outputs | The container holding the output stream pointers and their respective frame buffer outputs.
  [in] | request | An optional request

This function queues the input frame buffer on the output streams of the outputs map key and retrieve the output frame buffer indicated by the buffer map value.

If request is provided the buffers are tied to that request.

Returns
  0 on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ setInputCrop()

int libcamera::V4L2M2MConverter::setInputCrop | ( | const Stream * | stream,
|  | Rectangle * | rect )
| override virtual

Set the crop rectangle rect for stream.

Parameters

  [in] | stream | The output stream
  [in,out] | rect | The crop rectangle to apply and return the rectangle that is actually applied

Set the crop rectangle rect for stream provided the converter supports cropping. The converter has the Feature::InputCrop flag in this case.

The underlying hardware can adjust the rectangle supplied by the user due to hardware constraints. The caller can inspect rect to determine the actual rectangle that has been applied by the converter, after this function returns.

Returns
  0 on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ sizes()

SizeRange libcamera::V4L2M2MConverter::sizes | ( | const Size & | input | ) |
| override virtual

Retrieve the range of minimum and maximum output sizes for an input size.

Parameters

  [in] | input | Input stream size to retrieve range for

Returns
  A range of output image sizes

Implements libcamera::Converter.

## ◆ start()

int libcamera::V4L2M2MConverter::start | ( |  | ) |
| override virtual

Start the converter streaming operation.

Returns
  0 on success or a negative error code otherwise

Implements libcamera::Converter.

## ◆ stop()

void libcamera::V4L2M2MConverter::stop | ( |  | ) |
| override virtual

Stop the converter streaming operation.

Implements libcamera::Converter.

## ◆ strideAndFrameSize()

std::tuple< unsigned int, unsigned int > libcamera::V4L2M2MConverter::strideAndFrameSize | ( | const PixelFormat & | pixelFormat,
|  | const Size & | size )
| override virtual

Retrieve the output stride and frame size for an input configutation.

Parameters

  [in] | pixelFormat | Input stream pixel format
  [in] | size | Input stream size

Returns
  A tuple indicating the stride and frame size or an empty tuple on error

Implements libcamera::Converter.

## ◆ supportsRequests()

bool libcamera::V4L2M2MConverter::supportsRequests | ( |  | ) |

Check if requests are supported.

Checks if the device supports V4L2 requests by trying to allocate a single request. The result is cached, so the allocation is only tried once.

Returns
  True if the device supports requests, false otherwise

## ◆ validateOutput()

int libcamera::V4L2M2MConverter::validateOutput | ( | StreamConfiguration * | cfg,
|  | bool * | adjusted,
|  | Alignment | align = Alignment::Down )
| override virtual

Validate and possibily adjust cfg to a valid converter output.

Parameters

  [in,out] | cfg | The StreamConfiguration to validate and adjust
  [out] | adjusted | Set to true if cfg has been adjusted
  [in] | align | The desired alignment

Returns
  0 if cfg is valid or has been adjusted, a negative error code otherwise if cfg cannot be adjusted

Implements libcamera::Converter.

The documentation for this class was generated from the following files:

- include/libcamera/internal/converter/converter_v4l2_m2m.h
- src/libcamera/converter/converter_v4l2_m2m.cpp