]> rtime.felk.cvut.cz Git - v4l-streaming.git/blob - camv4l.h
Initial commit
[v4l-streaming.git] / camv4l.h
1 #ifndef CAM_V4L_H
2 #define CAM_V4L_H
3
4 /**
5  *  \file       camv4l.h 
6  *  
7  *  \brief This is header file v4l device (camera).
8  *
9  */
10
11 #include <stdio.h>
12 #include <unistd.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <fcntl.h>
16 #include <signal.h>
17 #include <errno.h>
18 #include <time.h>
19 #include <math.h>
20 #include <stdarg.h>
21 #include <linux/types.h>
22 #include <linux/videodev.h>
23 #include <sys/mman.h>
24 #include <sys/ioctl.h>
25 #include <sys/file.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28
29 #define DWIDTH 320      ///>Default width
30 #define DHEIGHT 240  ///>Default height
31
32 /* Input data output Palette define here */
33 #define VIDEO_PALETTE_RGB565 3          /* 16bit RGB */
34 #define VIDEO_PALETTE_RGB24  4          /* 24bit RGB */
35 #define VIDEO_PALETTE_RGB32  5          /* 32bit RGB */
36 #define VIDEO_PALETTE_YUV420P 15        /* YUV 420P */
37 #define VIDEO_PALETTE_RAW_JPEG  20
38
39
40 /**
41  * Camera type format date
42  */
43 enum cam_form {
44         JPEG,
45         YUVY,
46         YYUV,
47         YUYV,
48         GREY,
49         GBRG,
50         UNKNOW,
51 };
52
53 /**
54  * Struct represents input capture device
55  */
56 struct vdIn {
57         int fd;   // file descriptor
58         char *videodevice ; //name of camera
59
60         struct video_mmap vmmap;
61         struct video_capability videocap;
62         int mmapsize;
63         struct video_mbuf videombuf;
64         struct video_picture videopict;
65         struct video_window videowin;
66         struct video_channel videochan;
67         
68         unsigned int format ;   /* Format asked by apps for this frame */
69         int cameratype ;                /* native in frame format */
70         char *cameraname;
71         char *bridge;
72         int sizenative;
73         int sizeothers;
74         int palette;
75         int norme ;
76         int channel ;
77         int grabMethod ;                ///> Grab Methode 1=mmap 0=read
78         unsigned char *pFramebuffer;
79         unsigned char *pixTmp;  
80         int framesizeIn ;
81         int frame_cour;
82         int bppIn;
83         int hdrwidth;
84         int hdrheight;
85         int formatIn;
86         int flipUV;
87 };
88
89 /*
90 struct palette_list {
91         int num;
92         const char *name;
93 };
94
95
96 //Camera type jpeg yuvy yyuv yuyv grey gbrg
97 static struct palette_list Plist[] ={
98         {JPEG,"JPEG"},
99         {YUVY,"YUVY"},
100         {YYUV,"YYUV"},
101         {YUYV,"YUYV"},
102         {GREY,"GREY"},
103         {GBRG,"GBRG"},
104         {-1,NULL}
105 };
106 */
107
108
109 /**
110  * Fuction for initialization v4l device.
111  * \ingroup             common
112  * \param vd            Video device pointer 
113  *
114  * \return  0 if succesful or error number -1
115  */
116 int init_v4l ( struct vdIn *vd );
117
118 /**
119  * Fuction for initialization v4l device.
120  * \ingroup common
121  * \param vd            Video device pointer
122  *
123  * \return  0 if succesful or error number -1
124  */
125 int grab (struct vdIn *vd );
126
127 /**
128  * Fuction close v4l device.
129  * \ingroup common
130  * \param vd            Video device pointer 
131  * \return 0
132  */
133 int close_v4l (struct vdIn *vd);
134
135 /**
136  * Fuction sets color pallete video device.
137  * \ingroup common
138  * \param vd            Video device pointer 
139  *
140  * \return 1
141  */
142 int setPalette (struct vdIn *vd);
143
144 /**
145  * Fuction change size of image array video device.
146  * \ingroup common
147  * \param vd            Video device pointer 
148  *
149  *      \return 1
150  */
151 int changeSize (struct vdIn *vd);
152
153
154 /**
155  * Fuction get brightness from the camera.
156  * \ingroup common
157  * \param vd            Video device pointer
158  *
159  * \retutn brightness
160  */
161 __u8 getBrightness ( struct vdIn *vd);
162
163 /**
164  * Fuction set brightness to the camera.
165  * \ingroup common
166  * \param vd            Video device pointer 
167  * \param bright  New brightness value
168  */
169 void setBrightness ( struct vdIn *vd, __u8 bright);
170
171 /**
172  * Fuction get contrast from the camera.
173  * \ingroup common
174  * \param vd            Video device pointer 
175  *
176  * \return contrast
177  */
178 __u8 getContrast ( struct vdIn *vd);
179
180 /**
181  * Fuction set contrast to the camera.
182  * \ingroup common
183  * \param vd            Video device pointer 
184  * \param contrast  New contrast value
185  */
186 void setContrast ( struct vdIn *vd, __u8 contrast);
187
188 /**
189  * Fuction get colors from the camera.
190  * \ingroup common
191  * \param vd            Video device pointer 
192  *
193  * \return colors
194  */
195 __u8 getColors ( struct vdIn *vd);
196
197 /**
198  * Fuction set colors to the camera.
199  * \ingroup common
200  * \param vd            Video device pointer 
201  * \param colors  New colors value
202  */
203 void setColors ( struct vdIn *vd, __u8 colors);
204
205 /**
206  * Fuction get norme from the camera.
207  * \ingroup common
208  * \param vd            Video device pointer 
209  *
210  * \return norme
211  */
212 __u8 getNorme ( struct vdIn *vd);
213
214 /**
215  * Fuction set norme to the camera.
216  * \ingroup common
217  * \param vd            Video device pointer 
218  * \param norme  New norme value
219  */
220 void setNorme (struct vdIn *vd,__u8 norme);
221
222 /**
223  * Fuction get channel from the camera.
224  * \ingroup common
225  * \param vd            Video device pointer 
226  *
227  * \return channel
228  */
229 __u8 getChannel (struct vdIn *vd);
230
231 /**
232  * Fuction set channels to the camera.
233  * \ingroup common
234  * \param vd            Video device pointer 
235  * \param channel  New channel value
236  */
237 void setChannel( struct vdIn * vd,__u8 channel);
238
239
240 #endif /*CAM_V4L_H*/
241