List and Set Video Formats
After aquiring the handle, you can set a video format. The
video format describes the layout of the video image data
coming from the device. In unicap, a video format is defined
by a unicap_video_format_t struct:
A video format consists of a description of the color
format, information on the dimensions and some flags. The
fields bpp and fourcc describe the color
format and the bit depth.
A video device may allow different dimensions for the same
color format. The size field contains the actual
size used. min_size and max_size contain the
minimum and maxmium allowed dimensions. On some devices, you
can set any dimension between min_size and
max_size, in this case h_stepping and
v_stepping will have a value greater than 0, ie. you
can set dimensions that are a multiple of h_stepping
horizontaly and a multiple of v_stepping vertically.
Many capture devices have different dimensions for a color
format but allow only a limited number of standard
resolutions. In this case, the sizes array contains a
list of allowed dimensions. The array contains
size_count ellements.
The buffer_size field tells the size of a data buffer
for this format in bytes. If an application is going to
allocate the buffer for itself, this is the amount of data
need to be allocated.
The following code will ask the user for a video format and
set it using the supplied handle. It will also handle the
case that a video format contains an array of allowed sizes.