Debian Codegraph @

lib/include/libv4lconvert.h

raw
1 /*
2 # (C) 2008 Hans de Goede <[email protected]>
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU Lesser General Public License as published by
6 # the Free Software Foundation; either version 2.1 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17 */
18
19 #ifndef __LIBV4LCONVERT_H
20 #define __LIBV4LCONVERT_H
21
22 /* These headers are not needed by us, but by linux/videodev2.h,
23 which is broken on some systems and doesn't include them itself :( */
24
25 #ifdef linux
26 #include <sys/time.h>
27 #include <linux/types.h>
28 #include <linux/ioctl.h>
29 #endif
30
31 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
32 #include <sys/time.h>
33 #include <sys/types.h>
34 #include <sys/ioctl.h>
35 #endif
36
37 /* end broken header workaround includes */
38
39 #if defined(__OpenBSD__)
40 #include <sys/videoio.h>
41 #else
42 #include <linux/videodev2.h>
43 #endif
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif /* __cplusplus */
48
49 #if HAVE_VISIBILITY
50 #define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
51 #else
52 #define LIBV4L_PUBLIC
53 #endif
54
55 struct libv4l_dev_ops;
56 struct v4lconvert_data;
57
58 LIBV4L_PUBLIC const struct libv4l_dev_ops *v4lconvert_get_default_dev_ops();
59
60 LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create(int fd);
61 LIBV4L_PUBLIC struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd,
62 void *dev_ops_priv, const struct libv4l_dev_ops *dev_ops);
63 LIBV4L_PUBLIC void v4lconvert_destroy(struct v4lconvert_data *data);
64
65 /* When doing flipping / rotating / video-processing, only supported
66 destination formats can be used (as flipping / rotating / video-processing
67 is not supported on other formats). This function can be used to query
68 if that is the case. */
69 LIBV4L_PUBLIC int v4lconvert_supported_dst_fmt_only(
70 struct v4lconvert_data *data);
71
72 /* With regards to dest_fmt just like VIDIOC_TRY_FMT, except that the try
73 format will succeed and return the requested V4L2_PIX_FMT_foo in dest_fmt if
74 the cam has a format from which v4lconvert can convert to dest_fmt.
75 The real format to which the cam should be set is returned through src_fmt
76 when not NULL.
77 Note that just like the real VIDIOC_TRY_FMT this function will change the
78 dest_fmt when not supported. This includes changing it to a supported
79 destination format when trying a native format of the camera and
80 v4lconvert_supported_dst_fmt_only() returns true. */
81 LIBV4L_PUBLIC int v4lconvert_try_format(struct v4lconvert_data *data,
82 struct v4l2_format *dest_fmt, /* in / out */
83 struct v4l2_format *src_fmt); /* out */
84
85 /* Like VIDIOC_ENUM_FMT, but the emulated formats are added at the end of the
86 list, except if flipping / processing is active for the device, then only
87 supported destination formats are listed */
88 LIBV4L_PUBLIC int v4lconvert_enum_fmt(struct v4lconvert_data *data,
89 struct v4l2_fmtdesc *fmt);
90
91 /* Is conversion necessary or can the app use the data directly? */
92 LIBV4L_PUBLIC int v4lconvert_needs_conversion(struct v4lconvert_data *data,
93 const struct v4l2_format *src_fmt, /* in */
94 const struct v4l2_format *dest_fmt); /* in */
95
96 /* This function does the following conversions:
97 - format conversion
98 - cropping
99 if enabled:
100 - processing (auto whitebalance, auto gain, gamma correction)
101 - horizontal/vertical flipping
102 - 90 degree (clockwise) rotation
103
104 NOTE: the last 3 steps are enabled/disabled depending on
105 - the internal device list
106 - the state of the (software emulated) image controls
107
108 Therefore this function should
109 - not be used when getting the frames from libv4l
110 - be called only once per frame
111 Otherwise this may result in unintended double conversions !
112
113 Returns the amount of bytes written to dest and -1 on error */
114 LIBV4L_PUBLIC int v4lconvert_convert(struct v4lconvert_data *data,
115 const struct v4l2_format *src_fmt, /* in */
116 const struct v4l2_format *dest_fmt, /* in */
117 unsigned char *src, int src_size, unsigned char *dest, int dest_size);
118
119 /* get a string describing the last error */
120 LIBV4L_PUBLIC const char *v4lconvert_get_error_message(struct v4lconvert_data *data);
121
122 /* Just like VIDIOC_ENUM_FRAMESIZE, except that the framesizes of emulated
123 formats can be enumerated as well. */
124 LIBV4L_PUBLIC int v4lconvert_enum_framesizes(struct v4lconvert_data *data,
125 struct v4l2_frmsizeenum *frmsize);
126
127 /* Just like VIDIOC_ENUM_FRAMEINTERVALS, except that the intervals of emulated
128 formats can be enumerated as well. */
129 LIBV4L_PUBLIC int v4lconvert_enum_frameintervals(struct v4lconvert_data *data,
130 struct v4l2_frmivalenum *frmival);
131
132 /* Pass calls to query, get and set video controls to the libv4lcontrol class */
133 LIBV4L_PUBLIC int v4lconvert_vidioc_queryctrl(struct v4lconvert_data *data,
134 void *arg);
135 LIBV4L_PUBLIC int v4lconvert_vidioc_g_ctrl(struct v4lconvert_data *data,
136 void *arg);
137 LIBV4L_PUBLIC int v4lconvert_vidioc_s_ctrl(struct v4lconvert_data *data,
138 void *arg);
139 LIBV4L_PUBLIC int v4lconvert_vidioc_g_ext_ctrls(struct v4lconvert_data *data,
140 void *arg);
141 LIBV4L_PUBLIC int v4lconvert_vidioc_try_ext_ctrls(struct v4lconvert_data *data,
142 void *arg);
143 LIBV4L_PUBLIC int v4lconvert_vidioc_s_ext_ctrls(struct v4lconvert_data *data,
144 void *arg);
145
146 /* Is the passed in pixelformat supported as destination format? */
147 LIBV4L_PUBLIC int v4lconvert_supported_dst_format(unsigned int pixelformat);
148
149 /* Get/set the no fps libv4lconvert uses to decide if a compressed format
150 must be used as src fmt to stay within the bus bandwidth */
151 LIBV4L_PUBLIC int v4lconvert_get_fps(struct v4lconvert_data *data);
152 LIBV4L_PUBLIC void v4lconvert_set_fps(struct v4lconvert_data *data, int fps);
153
154 /* Fixup bytesperline and sizeimage for supported destination formats */
155 LIBV4L_PUBLIC void v4lconvert_fixup_fmt(struct v4l2_format *fmt);
156
157 #ifdef __cplusplus
158 }
159 #endif /* __cplusplus */
160
161 #endif