http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-parm.html
Name
VIDIOC_G_PARM, VIDIOC_S_PARM — Get or set streaming parameters //获取或设置数据流的参数,一般设置帧率等参数
Synopsis
int ioctl( | int fd, |
int request, | |
v4l2_streamparm *argp) ; |
Arguments
-
File descriptor returned by
open()
. -
VIDIOC_G_PARM, VIDIOC_S_PARM
-
fd
request
argp
Description
The current video standard determines a nominal number of frames per second. If less than this number of frames is to be captured or output, applications can request frame skipping or duplicating on the driver side. This is especially useful when using the read()
or write()
, which are not augmented by timestamps or sequence counters, and to avoid unnecessary data copying.
Further these ioctls can be used to determine the number of buffers used internally by a driver in read/write mode. For implications see the section discussing the read()
function.
To get and set the streaming parameters applications call the VIDIOC_G_PARM
and VIDIOC_S_PARM
ioctl, respectively. They take apointer to a struct v4l2_streamparm which contains a union holding separate parameters for input and output devices.
Table A.73. struct v4l2_streamparm
__u32 | type | The buffer (stream) type, same as struct v4l2_formattype , set by the application. See Table 3.3, “enum v4l2_buf_type” | |
union | parm | ||
struct v4l2_captureparm | capture | Parameters for capture devices, used whentype is V4L2_BUF_TYPE_VIDEO_CAPTURE . | |
struct v4l2_outputparm | output | Parameters for output devices, used whentype is V4L2_BUF_TYPE_VIDEO_OUTPUT . | |
__u8 | raw_data [200] | A place holder for future extensions. |
Table A.74. struct v4l2_captureparm
__u32 | capability | See Table A.76, “Streaming Parameters Capabilites”. |
__u32 | capturemode | Set by drivers and applications, see Table A.77, “Capture Parameters Flags”. |
struct v4l2_fract | timeperframe | This is the desired period between successive frames captured by the driver, in seconds. The field is intended to skip frames on the driver side, saving I/O bandwidth. Applications store here the desired frame period, drivers return the actual frame period, which must be greater or equal to the nominal frame period determined by the current video standard (struct v4l2_standard Drivers support this function only when they set the |
__u32 | extendedmode | Custom (driver specific) streaming parameters. When unused, applications and drivers must set this field to zero.Applications using this field should check the driver name and version, see the section called “Querying Capabilities”. |
__u32 | readbuffers | Applications set this field to the desired number of buffers used internally by the driver in read() mode. Drivers return the actual number of buffers. When an application requests zero buffers, drivers should just return the current setting rather than the minimum or an error code. For details see the section called “Read/Write”. |
__u32 | reserved [4] | Reserved for future extensions. Drivers andapplications must set the array to zero. |
Table A.75. struct v4l2_outputparm
__u32 | capability | See Table A.76, “Streaming Parameters Capabilites”. |
__u32 | outputmode | Set by drivers and applications, see Table A.77, “Capture Parameters Flags”. |
struct v4l2_fract | timeperframe | This is the desired period betweensuccessive frames output by the driver, in seconds. |
The field is intended torepeat frames on the driver side in Applications store here the desired frameperiod, drivers return the actual frame period, which must be greateror equal to the nominal frame period determined by the current videostandard (struct v4l2_standard Drivers support this function only when they set the | ||
__u32 | extendedmode | Custom (driver specific) streaming parameters. Whenunused, applications and drivers must set this field to zero.Applications using this field should check the driver name andversion, see the section called “Querying Capabilities”. |
__u32 | writebuffers | Applications set this field to the desired numberof buffers used internally by the driver inwrite() mode. Drivers return the actual number ofbuffers. When an application requests zero buffers, drivers shouldjust return the current setting rather than the minimum or an errorcode. For details see the section called “Read/Write”. |
__u32 | reserved [4] | Reserved for future extensions. Drivers andapplications must set the array to zero. |
Table A.76. Streaming Parameters Capabilites
V4L2_CAP_TIMEPERFRAME | 0x1000 | The frame skipping/repeating controlled by thetimeperframe field is supported. |
Table A.77. Capture Parameters Flags
V4L2_MODE_HIGHQUALITY | 0x0001 | High quality imaging mode. High quality modeis intended for still imaging applications. The idea is to get thebest possible image quality that the hardware can deliver. It is notdefined how the driver writer may achieve that; it will depend on thehardware and the ingenuity of the driver writer. High quality mode isa different mode from the the regular motion video capture modes. Inhigh quality mode:
|
Return Value
On success 0 is returned, on error -1 and the errno
variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.
例子:
/* set framerate */
struct v4l2_streamparm* setfps;
setfps=(struct v4l2_streamparm *) calloc(1, sizeof(struct v4l2_streamparm));
memset(setfps, 0, sizeof(struct v4l2_streamparm));
setfps->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps->parm.capture.timeperframe.numerator=1;
setfps->parm.capture.timeperframe.denominator=vd->fps;//15
ret = ioctl(vd->fd, VIDIOC_S_PARM, setfps);