libcamera v0.3.2+99-1230f78d
Supporting cameras in Linux since 2019
Classes | Public Member Functions | List of all members
libcamera::V4L2M2MConverter Class Reference

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

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

Public Member Functions

 V4L2M2MConverter (MediaDevice *media)
 Construct a V4L2M2MConverter instance. More...
 
int loadConfiguration (const std::string &filename)
 
bool isValid () const
 
std::vector< PixelFormatformats (PixelFormat input)
 
SizeRange sizes (const Size &input)
 Retrieve the range of minimum and maximum output sizes for an input size. More...
 
std::tuple< unsigned int, unsigned int > strideAndFrameSize (const PixelFormat &pixelFormat, const Size &size)
 Retrieve the output stride and frame size for an input configutation. More...
 
int configure (const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfg)
 Configure a set of output stream conversion from an input stream. More...
 
int exportBuffers (const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers)
 Export buffers from the converter device. More...
 
int start ()
 Start the converter streaming operation. More...
 
void stop ()
 Stop the converter streaming operation. More...
 
int queueBuffers (FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs)
 Queue buffers to converter device. More...
 
int setInputCrop (const Stream *stream, Rectangle *rect)
 Set the crop rectangle rect for stream. More...
 
std::pair< Rectangle, RectangleinputCropBounds (const Stream *stream)
 Retrieve the crop bounds for stream. More...
 
- Public Member Functions inherited from libcamera::Converter
 Converter (MediaDevice *media, Features features=Feature::None)
 Construct a Converter instance. More...
 
virtual int loadConfiguration (const std::string &filename)=0
 Load converter configuration from file. More...
 
virtual bool isValid () const =0
 Check if the converter configuration is valid. More...
 
virtual std::vector< PixelFormatformats (PixelFormat input)=0
 Retrieve the list of supported pixel formats for an input pixel format. More...
 
virtual SizeRange sizes (const Size &input)=0
 Retrieve the range of minimum and maximum output sizes for an input size. More...
 
virtual std::tuple< unsigned int, unsigned int > strideAndFrameSize (const PixelFormat &pixelFormat, const Size &size)=0
 Retrieve the output stride and frame size for an input configutation. More...
 
virtual int configure (const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfgs)=0
 Configure a set of output stream conversion from an input stream. More...
 
virtual int exportBuffers (const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers)=0
 Export buffers from the converter device. More...
 
virtual int start ()=0
 Start the converter streaming operation. More...
 
virtual void stop ()=0
 Stop the converter streaming operation. More...
 
virtual int queueBuffers (FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs)=0
 Queue buffers to converter device. More...
 
virtual int setInputCrop (const Stream *stream, Rectangle *rect)=0
 Set the crop rectangle rect for stream. More...
 
virtual std::pair< Rectangle, RectangleinputCropBounds (const Stream *stream)=0
 Retrieve the crop bounds for stream. More...
 
const std::string & deviceNode () const
 The converter device node attribute accessor. More...
 
Features features () const
 Retrieve the features supported by the converter. More...
 

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...
 
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 ( MediaDevice media)

Construct a V4L2M2MConverter instance.

Parameters
[in]mediaThe media device implementing the converter

Member Function Documentation

◆ configure()

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

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

Parameters
[in]inputCfgInput stream configuration
[out]outputCfgsA 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 
)
virtual

Export buffers from the converter device.

Parameters
[in]streamOutput stream pointer exporting the buffers
[in]countNumber of buffers to allocate
[out]buffersVector 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)
virtual
Parameters
[in]inputInput pixel format to retrieve output pixel format list for
Returns
The list of supported output pixel formats

Implements libcamera::Converter.

◆ inputCropBounds()

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

Retrieve the crop bounds for stream.

Parameters
[in]streamThe 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().

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

Implements libcamera::Converter.

◆ isValid()

libcamera::V4L2M2MConverter::isValid ( ) const
inlinevirtual
Returns
True is the converter is valid, false otherwise

Implements libcamera::Converter.

◆ loadConfiguration()

libcamera::V4L2M2MConverter::loadConfiguration ( const std::string &  filename)
inlinevirtual
Parameters
[in]filenameThe 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 
)
virtual

Queue buffers to converter device.

Parameters
[in]inputThe frame buffer to apply the conversion
[out]outputsThe container holding the output stream pointers and their respective frame buffer outputs.

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.

Returns
0 on success or a negative error code otherwise

Implements libcamera::Converter.

◆ setInputCrop()

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

Set the crop rectangle rect for stream.

Parameters
[in]streamThe output stream
[in,out]rectThe 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)
virtual

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

Parameters
[in]inputInput stream size to retrieve range for
Returns
A range of output image sizes

Implements libcamera::Converter.

◆ start()

int libcamera::V4L2M2MConverter::start ( )
virtual

Start the converter streaming operation.

Returns
0 on success or a negative error code otherwise

Implements libcamera::Converter.

◆ stop()

void libcamera::V4L2M2MConverter::stop ( )
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 
)
virtual

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

Parameters
[in]pixelFormatInput stream pixel format
[in]sizeInput stream size
Returns
A tuple indicating the stride and frame size or an empty tuple on error

Implements libcamera::Converter.


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