Jetson Linux API Reference

32.7.3 Release

Detailed Description

Defines a helper class for V4L2 based components.

This derived class provides common functionality for V4L2 components. V4L2-based components such as encoder/decoder extend from this class.

This class is modeled on V4L2 M2M devices. It includes the file descriptor (FD) of the device opened using v4l2_open, two planes (NvV4l2ElementPlane), output plane, capture plane, and other helper methods, such as setting/getting controls, subscribing/dequeueing events, etc.

Definition at line 65 of file NvV4l2Element.h.

Inheritance diagram for NvV4l2Element:
Collaboration diagram for NvV4l2Element:

Public Member Functions

virtual ~NvV4l2Element ()
 
int subscribeEvent (uint32_t type, uint32_t id, uint32_t flags)
 Subscribes to an V4L2 event. More...
 
int dqEvent (struct v4l2_event &event, uint32_t max_wait_ms)
 Dequeues an event from the element. More...
 
int setControl (uint32_t id, int32_t value)
 Sets the value of a control. More...
 
int getControl (uint32_t id, int32_t &value)
 Gets the value of a control. More...
 
int setExtControls (struct v4l2_ext_controls &ctl)
 Sets the value of several controls. More...
 
int getExtControls (struct v4l2_ext_controls &ctl)
 Gets the value of several controls. More...
 
virtual int isInError ()
 
int abort ()
 Terminates processing of queued buffers immediately. More...
 
virtual int waitForIdle (uint32_t max_wait_ms)
 Waits until the element processes all the output plane buffers. More...
 
void enableProfiling ()
 Enables profiling for the V4l2Element. More...
 
void getProfilingData (NvElementProfiler::NvElementProfilerData &data)
 Gets profiling data for the element. More...
 
void printProfilingStats (std::ostream &out_stream=std::cout)
 Prints profiling data for the element to an output stream. More...
 
bool isProfilingEnabled ()
 Checks whether profiling is enabled for the element. More...
 

Data Fields

NvV4l2ElementPlane output_plane
 Sets the output plane. More...
 
NvV4l2ElementPlane capture_plane
 Sets the capture plane. More...
 
void * app_data
 A pointer to the application-specific data. More...
 

Protected Member Functions

 NvV4l2Element (const char *comp_name, const char *dev_node, int flags, NvElementProfiler::ProfilerField fields)
 Creates a new V4l2Element named name. More...
 

Protected Attributes

int fd
 Specifies the FD of the device opened using v4l2_open. More...
 
uint32_t output_plane_pixfmt
 Pixel format of output plane buffers. More...
 
uint32_t capture_plane_pixfmt
 Pixel format of capture plane buffers. More...
 
int is_in_error
 Indicates if an error was encountered during the operation of the element. More...
 
const char * comp_name
 Specifies the name of the component, for debugging. More...
 
NvElementProfiler profiler
 Profiler for the element. More...
 

Constructor & Destructor Documentation

◆ ~NvV4l2Element()

virtual NvV4l2Element::~NvV4l2Element ( )
virtual

◆ NvV4l2Element()

NvV4l2Element::NvV4l2Element ( const char *  comp_name,
const char *  dev_node,
int  flags,
NvElementProfiler::ProfilerField  fields 
)
protected

Creates a new V4l2Element named name.

This constructor calls v4l2_open on the dev_node. It sets an error if v4l2_open fails.

This function also checks if the device supports V4L2_CAP_VIDEO_M2M_MPLANE capability.

Parameters
[in]comp_nameA pointer to the unique name to identity the element instance.
[in]dev_nodeA pointer to /dev/ * node of the device.
[in]flagsFlags with which to open the device.
[in]fieldsProfiler fields that are valid for the element.

Member Function Documentation

◆ abort()

int NvV4l2Element::abort ( )

Terminates processing of queued buffers immediately.

All the buffers are returned to the application.

Calls VIDIOC_STREAMOFF IOCTL on both of the planes internally.

Returns
0 for success, -1 otherwise.

◆ dqEvent()

int NvV4l2Element::dqEvent ( struct v4l2_event &  event,
uint32_t  max_wait_ms 
)

Dequeues an event from the element.

Calls VIDIOC_DQEVENT IOCTL internally. The caller can specify the maximum time to wait for dequeuing the event. The call blocks until an event is dequeued successfully or timeout is reached.

Parameters
[in,out]eventA reference to the v4l2_event structure to fill.
[in]max_wait_msSpecifies the max wait time for dequeuing an event, in milliseconds.
Returns
0 for success, -1 otherwise.

◆ enableProfiling()

void NvV4l2Element::enableProfiling ( )
virtual

Enables profiling for the V4l2Element.

Must be called before setting either plane formats.

Reimplemented from NvElement.

◆ getControl()

int NvV4l2Element::getControl ( uint32_t  id,
int32_t &  value 
)

Gets the value of a control.

Calls VIDIOC_G_CTRL IOCTL internally.

Parameters
[in]idID of the control to get.
[out]valueA reference to the variable into which the control value is read.
Returns
0 for success, -1 otherwise.

◆ getExtControls()

int NvV4l2Element::getExtControls ( struct v4l2_ext_controls &  ctl)

Gets the value of several controls.

Calls VIDIOC_G_EXT_CTRLS IOCTL internally.

Parameters
[in,out]ctlA pointer to the controls to get.
Returns
0 for success, -1 otherwise.

◆ getProfilingData()

void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.

◆ isInError()

virtual int NvV4l2Element::isInError ( )
virtual

Reimplemented from NvElement.

◆ isProfilingEnabled()

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.

◆ printProfilingStats()

void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
inherited

Prints profiling data for the element to an output stream.

Parameters
[in]out_streamOutput stream of type std::ostream to print the data to. It takes the default value std::cout if not specified.

◆ setControl()

int NvV4l2Element::setControl ( uint32_t  id,
int32_t  value 
)

Sets the value of a control.

Calls VIDIOC_S_CTRL IOCTL internally.

Parameters
[in]idID of the control to be set.
[in]valueValue to be set on the control.
Returns
0 for success, -1 otherwise.

◆ setExtControls()

int NvV4l2Element::setExtControls ( struct v4l2_ext_controls &  ctl)

Sets the value of several controls.

Calls VIDIOC_S_EXT_CTRLS IOCTL internally.

Parameters
[in]ctlA pointer to the controls to set.
Returns
0 for success, -1 otherwise.

◆ subscribeEvent()

int NvV4l2Element::subscribeEvent ( uint32_t  type,
uint32_t  id,
uint32_t  flags 
)

Subscribes to an V4L2 event.

Calls VIDIOC_SUBSCRIBE_EVENT IOCTL internally.

Parameters
[in]typeType of the event.
[in]idID of the event source.
[in]flagsEvent flags.
Returns
0 for success, -1 otherwise.

◆ waitForIdle()

virtual int NvV4l2Element::waitForIdle ( uint32_t  max_wait_ms)
virtual

Waits until the element processes all the output plane buffers.

Objects extending V4l2Element must implement this because the idle condition is component-specific.

Parameters
[in]max_wait_msMax time to wait in milliseconds.
Returns
0 for success, -1 otherwise.

Reimplemented in NvVideoConverter.

Field Documentation

◆ app_data

void* NvV4l2Element::app_data

A pointer to the application-specific data.

Definition at line 169 of file NvV4l2Element.h.

◆ capture_plane

NvV4l2ElementPlane NvV4l2Element::capture_plane

Sets the capture plane.

Capture plane of the element

Definition at line 145 of file NvV4l2Element.h.

◆ capture_plane_pixfmt

uint32_t NvV4l2Element::capture_plane_pixfmt
protected

Pixel format of capture plane buffers.

Definition at line 182 of file NvV4l2Element.h.

◆ comp_name

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

◆ fd

int NvV4l2Element::fd
protected

Specifies the FD of the device opened using v4l2_open.

Definition at line 179 of file NvV4l2Element.h.

◆ is_in_error

int NvElement::is_in_error
protectedinherited

Indicates if an error was encountered during the operation of the element.

Definition at line 120 of file NvElement.h.

Referenced by NvElement::isInError().

◆ output_plane

NvV4l2ElementPlane NvV4l2Element::output_plane

Sets the output plane.

Output plane of the element

Definition at line 141 of file NvV4l2Element.h.

◆ output_plane_pixfmt

uint32_t NvV4l2Element::output_plane_pixfmt
protected

Pixel format of output plane buffers.

Definition at line 181 of file NvV4l2Element.h.

◆ profiler

NvElementProfiler NvElement::profiler
protectedinherited

Profiler for the element.

Definition at line 124 of file NvElement.h.


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