Jetson Linux API 参考文档

32.7.4 版本

详细描述

定义了基于 V4L2 组件的辅助类。

这个派生类为 V4L2 组件提供了通用功能。诸如编码器/解码器等基于 V4L2 的组件从此类扩展。

此类以 V4L2 M2M 设备为模型。它包括使用 v4l2_open 打开的设备的文件描述符 (FD)、两个平面 (NvV4l2ElementPlane)、输出平面、捕获平面和其他辅助方法,例如设置/获取控件、订阅/出队事件等。

定义位于文件 65NvV4l2Element.h

NvV4l2Element 的继承关系图
NvV4l2Element 的协作图

公共成员函数

virtual ~NvV4l2Element ()
 
int subscribeEvent (uint32_t type, uint32_t id, uint32_t flags)
 订阅 V4L2 事件。 更多...
 
int dqEvent (struct v4l2_event &event, uint32_t max_wait_ms)
 从元素中出队一个事件。 更多...
 
int setControl (uint32_t id, int32_t value)
 设置控件的值。 更多...
 
int getControl (uint32_t id, int32_t &value)
 获取控件的值。 更多...
 
int setExtControls (struct v4l2_ext_controls &ctl)
 设置多个控件的值。 更多...
 
int getExtControls (struct v4l2_ext_controls &ctl)
 获取多个控件的值。 更多...
 
virtual int isInError ()
 
int abort ()
 立即终止排队缓冲区的处理。 更多...
 
virtual int waitForIdle (uint32_t max_wait_ms)
 等待直到元素处理完所有输出平面缓冲区。 更多...
 
void enableProfiling ()
 为 V4l2Element 启用性能分析。 更多...
 
void getProfilingData (NvElementProfiler::NvElementProfilerData &data)
 获取元素的性能分析数据。 更多...
 
void printProfilingStats (std::ostream &out_stream=std::cout)
 将元素的性能分析数据打印到输出流。 更多...
 
bool isProfilingEnabled ()
 检查是否为元素启用了性能分析。 更多...
 

数据字段

NvV4l2ElementPlane output_plane
 设置输出平面。 更多...
 
NvV4l2ElementPlane capture_plane
 设置捕获平面。 更多...
 
void * app_data
 指向应用程序特定数据的指针。 更多...
 

保护成员函数

 NvV4l2Element (const char *comp_name, const char *dev_node, int flags, NvElementProfiler::ProfilerField fields)
 创建一个名为 name 的新 V4l2Element。 更多...
 

保护属性

int fd
 指定使用 v4l2_open 打开的设备的 FD。 更多...
 
uint32_t output_plane_pixfmt
 输出平面缓冲区的像素格式。 更多...
 
uint32_t capture_plane_pixfmt
 捕获平面缓冲区的像素格式。 更多...
 
int is_in_error
 指示元素操作期间是否遇到错误。 更多...
 
const char * comp_name
 指定组件的名称,用于调试。 更多...
 
NvElementProfiler profiler
 元素的性能分析器。 更多...
 

构造函数 & 析构函数文档

◆ ~NvV4l2Element()

virtual NvV4l2Element::~NvV4l2Element ( )
virtual

◆ NvV4l2Element()

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

创建一个名为 name 的新 V4l2Element。

此构造函数在 dev_node 上调用 v4l2_open。如果 v4l2_open 失败,则设置一个错误。

此函数还会检查设备是否支持 V4L2_CAP_VIDEO_M2M_MPLANE 功能。

参数
[in]comp_name指向标识元素实例的唯一名称的指针。
[in]dev_node指向设备的 /dev/ * 节点的指针。
[in]flags用于打开设备的标志。
[in]fields对元素有效的性能分析器字段。

成员函数文档

◆ abort()

int NvV4l2Element::abort ( )

立即终止排队缓冲区的处理。

所有缓冲区都返回给应用程序。

在内部对两个平面调用 VIDIOC_STREAMOFF IOCTL。

返回值
成功返回 0,否则返回 -1。

◆ dqEvent()

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

从元素中出队一个事件。

在内部调用 VIDIOC_DQEVENT IOCTL。调用者可以指定等待事件出队的最长时间。调用会阻塞,直到事件成功出队或达到超时时间。

参数
[in,out]event对要填充的 v4l2_event 结构的引用。
[in]max_wait_ms指定事件出队的最长等待时间,以毫秒为单位。
返回值
成功返回 0,否则返回 -1。

◆ enableProfiling()

void NvV4l2Element::enableProfiling ( )
virtual

为 V4l2Element 启用性能分析。

必须在设置任何平面格式之前调用。

NvElement 重新实现。

◆ getControl()

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

获取控件的值。

在内部调用 VIDIOC_G_CTRL IOCTL。

参数
[in]id要获取的控件的 ID。
[out]value对将从中读取控件值的变量的引用。
返回值
成功返回 0,否则返回 -1。

◆ getExtControls()

int NvV4l2Element::getExtControls ( struct v4l2_ext_controls &  ctl)

获取多个控件的值。

在内部调用 VIDIOC_G_EXT_CTRLS IOCTL。

参数
[in,out]ctl指向要获取的控件的指针。
返回值
成功返回 0,否则返回 -1。

◆ getProfilingData()

void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
继承自

获取元素的性能分析数据。

返回值
对元素的性能分析数据的常量引用。

◆ isInError()

virtual int NvV4l2Element::isInError ( )
virtual

NvElement 重新实现。

◆ isProfilingEnabled()

bool NvElement::isProfilingEnabled ( )
继承自

检查是否为元素启用了性能分析。

返回值
指示是否启用性能分析的布尔值。

◆ printProfilingStats()

void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
继承自

将元素的性能分析数据打印到输出流。

参数
[in]out_stream要将数据打印到的 std::ostream 类型的输出流。如果未指定,则采用默认值 std::cout。

◆ setControl()

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

设置控件的值。

在内部调用 VIDIOC_S_CTRL IOCTL。

参数
[in]id要设置的控件的 ID。
[in]value要在控件上设置的值。
返回值
成功返回 0,否则返回 -1。

◆ setExtControls()

int NvV4l2Element::setExtControls ( struct v4l2_ext_controls &  ctl)

设置多个控件的值。

在内部调用 VIDIOC_S_EXT_CTRLS IOCTL。

参数
[in]ctl指向要设置的控件的指针。
返回值
成功返回 0,否则返回 -1。

◆ subscribeEvent()

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

订阅 V4L2 事件。

在内部调用 VIDIOC_SUBSCRIBE_EVENT IOCTL。

参数
[in]type事件的类型。
[in]id事件源的 ID。
[in]flags事件标志。
返回值
成功返回 0,否则返回 -1。

◆ waitForIdle()

virtual int NvV4l2Element::waitForIdle ( uint32_t  max_wait_ms)
virtual

等待直到元素处理完所有输出平面缓冲区。

扩展 V4l2Element 的对象必须实现此方法,因为空闲条件是组件特定的。

参数
[in]max_wait_ms以毫秒为单位的最长等待时间。
返回值
成功返回 0,否则返回 -1。

NvVideoConverter 中重新实现。

字段文档

◆ app_data

void* NvV4l2Element::app_data

指向应用程序特定数据的指针。

定义位于文件 169NvV4l2Element.h

◆ capture_plane

NvV4l2ElementPlane NvV4l2Element::capture_plane

设置捕获平面。

元素的捕获平面

定义位于文件 145NvV4l2Element.h

◆ capture_plane_pixfmt

uint32_t NvV4l2Element::capture_plane_pixfmt
protected

捕获平面缓冲区的像素格式。

定义位于文件 182NvV4l2Element.h

◆ comp_name

const char* NvElement::comp_name
protectedinherited

指定组件的名称,用于调试。

定义位于文件 122NvElement.h

◆ fd

int NvV4l2Element::fd
protected

指定使用 v4l2_open 打开的设备的 FD。

定义位于文件 179NvV4l2Element.h

◆ is_in_error

int NvElement::is_in_error
protectedinherited

指示元素操作期间是否遇到错误。

定义位于文件 120NvElement.h

引用自 NvElement::isInError()

◆ output_plane

NvV4l2ElementPlane NvV4l2Element::output_plane

设置输出平面。

元素的输出平面

定义位于文件 141NvV4l2Element.h

◆ output_plane_pixfmt

uint32_t NvV4l2Element::output_plane_pixfmt
protected

输出平面缓冲区的像素格式。

定义位于文件 181NvV4l2Element.h

◆ profiler

NvElementProfiler NvElement::profiler
protectedinherited

元素的性能分析器。

定义位于文件 124NvElement.h


此类文档从以下文件生成
. All rights reserved.