Debian Codegraph @

libs/indibase/webcam/v4l2_base.h

raw symbols SCIP
1 /*
2 Copyright (C) 2005 by Jasem Mutlaq <[email protected]>
3 Copyright (C) 2013 Geehalel ([email protected])
4
5 Based on V4L 2 Example
6 http://v4l2spec.bytesex.org/spec-single/v4l2.html#CAPTURE-EXAMPLE
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22 */
23
24 #pragma once
25
26 //#include "videodev2.h"
27 #include "eventloop.h"cxx . . $ `<file>/libs/eventloop/eventloop.h`/
28 #include "indidevapi.h"cxx . . $ `<file>/libs/indicore/indidevapi.h`/
29 // this adds add dependency to indidriver for v4l_legacy, meade_lpi
30
31 // Can't use logger as legacy drivers don't use defaultdevice
32 //#include "indilogger.h"
33 #include "v4l2_decode/v4l2_decode.h"cxx . . $ `<file>/libs/indibase/webcam/v4l2_decode/v4l2_decode.h`/
34 // for direct recording
35 #include "stream/streammanager.h"cxx . . $ `<file>/libs/indibase/stream/streammanager.h`/
36
37 #include <stdio.h>
38 #include <cstdlib>
39 #include <map>
40
41 #include <dirent.h>
42 #include <linux/videodev2.h>
43
44 #define VIDEO_COMPRESSION_LEVELcxx . . $ `libs/indibase/webcam/v4l2_base.h:44:9`! 4
45
46 class V4L2_Drivercxx . . $ V4L2_Driver#;
47
48 enumcxx . . $ $anonymous_type_59a021e6c7e8154a_0#
49 {
50 LX_ACTIVEcxx . . $ LX_ACTIVE. = 0,
51 LX_TRIGGEREDcxx . . $ LX_TRIGGERED.,
52 LX_ACCUMULATINGcxx . . $ LX_ACCUMULATING.
53 };
54
55 namespace INDIcxx . . $ INDI/
56 {
57
58 class V4L2_Basecxx . . $ INDI/V4L2_Base#
59 {
60 public:
61 V4L2_Basecxx . . $ INDI/V4L2_Base#V4L2_Base(49f6e7a06ebc5aa8).();
62 virtual ~cxx . . $ INDI/V4L2_Base#`~V4L2_Base`(49f6e7a06ebc5aa8).V4L2_Basecxx . . $ INDI/V4L2_Base#();
63
64 typedef enumcxx . . $ INDI/V4L2_Base#$anonymous_type_1# { IO_METHOD_READcxx . . $ INDI/V4L2_Base#IO_METHOD_READ., IO_METHOD_MMAPcxx . . $ INDI/V4L2_Base#IO_METHOD_MMAP., IO_METHOD_USERPTRcxx . . $ INDI/V4L2_Base#IO_METHOD_USERPTR. } io_methodcxx . . $ INDI/V4L2_Base#io_method#;
65
66 struct buffercxx . . $ INDI/V4L2_Base#buffer#
67 {
68 void *startcxx . . $ INDI/V4L2_Base#buffer#start.;
69 size_t lengthcxx . . $ INDI/V4L2_Base#buffer#length.;
70 };
71
72 /* Connection */
73 virtual int connectCamcxx . . $ INDI/V4L2_Base#connectCam(15b8ec328ea39ccc).(const char *devpath, char *errmsg, int pixelFormat = -1, int width = -1, int height = -1);
74 virtual void disconnectCamcxx . . $ INDI/V4L2_Base#disconnectCam(b45ddcbc8423892c).(bool stopcapture);
75 char *getDeviceNamecxx . . $ INDI/V4L2_Base#getDeviceName(41208ce6ca65dd58).();
76 void setDeviceNamecxx . . $ INDI/V4L2_Base#setDeviceName(85c52e162fed56f9).(const char *name);
77 bool isLXmodCapablecxx . . $ INDI/V4L2_Base#isLXmodCapable(c9857a73d68e59ba).();
78
79 /* Updates */
80 void callFramecxx . . $ INDI/V4L2_Base#callFrame(5d22bdacc48458e8).(void *p);
81
82 // Enumerate all available V42L devices and return a map with common device name
83 static stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> enumeratecxx . . $ INDI/V4L2_Base#enumerate(50fdc5276c3a9e1b).();
84 static int video_dev_file_selectcxx . . $ INDI/V4L2_Base#video_dev_file_select(39071f79bcec8c).(const dirent *entry);
85
86 /* Image Format/Size */
87 int getFormatcxx . . $ INDI/V4L2_Base#getFormat(b126dc7c1de90089).();
88 int getWidthcxx . . $ INDI/V4L2_Base#getWidth(b126dc7c1de90089).();
89 int getHeightcxx . . $ INDI/V4L2_Base#getHeight(b126dc7c1de90089).();
90 int getBppcxx . . $ INDI/V4L2_Base#getBpp(b126dc7c1de90089).();
91 void setNativecxx . . $ INDI/V4L2_Base#setNative(b45ddcbc8423892c).(bool value) {m_Nativecxx . . $ INDI/V4L2_Base#m_Native. = value;}
92 virtual int setSizecxx . . $ INDI/V4L2_Base#setSize(9b79fb6aee4c0440).(int x, int y);
93 virtual void getMaxMinSizecxx . . $ INDI/V4L2_Base#getMaxMinSize(a90a5d8ba88c22b1).(int &x_max, int &y_max, int &x_min, int &y_min);
94
95 /* Frame rate */
96 int (V4L2_Basecxx . . $ INDI/V4L2_Base#::*setframeratecxx . . $ INDI/V4L2_Base#setframerate.)(struct v4l2_fractcxx . . $ v4l2_fract# frate, char *errmsg);
97 struct v4l2_fractcxx . . $ v4l2_fract# (V4L2_Basecxx . . $ INDI/V4L2_Base#::*getframeratecxx . . $ INDI/V4L2_Base#getframerate.)();
98
99 unsigned char *getYcxx . . $ INDI/V4L2_Base#getY(37d8967d10cb1e7b).();
100 unsigned char *getUcxx . . $ INDI/V4L2_Base#getU(37d8967d10cb1e7b).();
101 unsigned char *getVcxx . . $ INDI/V4L2_Base#getV(37d8967d10cb1e7b).();
102 unsigned char * getMJPEGBuffercxx . . $ INDI/V4L2_Base#getMJPEGBuffer(6809728d7d2d5ca5).(int &size);
103 unsigned char *getRGBBuffercxx . . $ INDI/V4L2_Base#getRGBBuffer(37d8967d10cb1e7b).();
104 float *getLinearYcxx . . $ INDI/V4L2_Base#getLinearY(a3aba87f01dec7c2).();
105
106 void registerCallbackcxx . . $ INDI/V4L2_Base#registerCallback(97a347b124788245).(WPFcxx . . $ WPF# *fp, void *ud);
107
108 int start_capturingcxx . . $ INDI/V4L2_Base#start_capturing(1ef8e6ec083aabb9).(char *errmsg);
109 int stop_capturingcxx . . $ INDI/V4L2_Base#stop_capturing(1ef8e6ec083aabb9).(char *errmsg);
110 static void newFramecxx . . $ INDI/V4L2_Base#newFrame(6ca3d68f5c5f0975).(int fd, void *p);
111
112 //void setDropFrameCount(unsigned int count) { dropFrameCount = count;}
113 void enumerate_ctrlcxx . . $ INDI/V4L2_Base#enumerate_ctrl(49f6e7a06ebc5aa8).();
114 void enumerate_menucxx . . $ INDI/V4L2_Base#enumerate_menu(49f6e7a06ebc5aa8).();
115 bool enumerate_ext_ctrlcxx . . $ INDI/V4L2_Base#enumerate_ext_ctrl(c9857a73d68e59ba).();
116 int queryINTControlscxx . . $ INDI/V4L2_Base#queryINTControls(b4554a832aba7799).(INumberVectorPropertycxx . . $ INumberVectorProperty# *nvp);
117 bool queryExtControlscxx . . $ INDI/V4L2_Base#queryExtControls(d0cfb1aeae70be18).(INumberVectorPropertycxx . . $ INumberVectorProperty# *nvp, unsigned int *nnumber, ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# **options,
118 unsigned int *noptions, const char *dev, const char *group);
119 void queryControlscxx . . $ INDI/V4L2_Base#queryControls(ba2f0dd485c50786).(INumberVectorPropertycxx . . $ INumberVectorProperty# *nvp, unsigned int *nnumber, ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# **options,
120 unsigned int *noptions, const char *dev, const char *group);
121
122 int getControlcxx . . $ INDI/V4L2_Base#getControl(c01533101fe3f60e).(unsigned int ctrl_id, double *value, char *errmsg);
123 int setINTControlcxx . . $ INDI/V4L2_Base#setINTControl(9e865f9d38b839cc).(unsigned int ctrl_id, double new_value, char *errmsg);
124 int setOPTControlcxx . . $ INDI/V4L2_Base#setOPTControl(6e5ef277f6fa70a7).(unsigned int ctrl_id, unsigned int new_value, char *errmsg);
125
126 int query_ctrlcxx . . $ INDI/V4L2_Base#query_ctrl(b750c65f9a094f76).(unsigned int ctrl_id, double &ctrl_min, double &ctrl_max, double &ctrl_step, double &ctrl_value,
127 char *errmsg);
128 void getinputscxx . . $ INDI/V4L2_Base#getinputs(937b9cd86f7e998c).(ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# *inputssp);
129 int setinputcxx . . $ INDI/V4L2_Base#setinput(fa84e865f2d62ca9).(unsigned int inputindex, char *errmsg);
130 void getcaptureformatscxx . . $ INDI/V4L2_Base#getcaptureformats(937b9cd86f7e998c).(ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# *captureformatssp);
131 int setcaptureformatcxx . . $ INDI/V4L2_Base#setcaptureformat(fa84e865f2d62ca9).(unsigned int captureformatindex, char *errmsg);
132 void getcapturesizescxx . . $ INDI/V4L2_Base#getcapturesizes(ec660873eb4e5e09).(ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# *capturesizessp, INumberVectorPropertycxx . . $ INumberVectorProperty# *capturesizenp);
133 int setcapturesizecxx . . $ INDI/V4L2_Base#setcapturesize(6e5ef277f6fa70a7).(unsigned int w, unsigned int h, char *errmsg);
134 void getframeratescxx . . $ INDI/V4L2_Base#getframerates(ec660873eb4e5e09).(ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# *frameratessp, INumberVectorPropertycxx . . $ INumberVectorProperty# *frameratenp);
135 int setcroprectcxx . . $ INDI/V4L2_Base#setcroprect(6a7e88cfafed3a23).(int x, int y, int w, int h, char *errmsg);
136 struct v4l2_rectcxx . . $ v4l2_rect# getcroprectcxx . . $ INDI/V4L2_Base#getcroprect(c222985ec745b0bf).();
137
138 void setColorProcessingcxx . . $ INDI/V4L2_Base#setColorProcessing(9e113dd3a0d25c95).(bool quantization, bool colorconvert, bool linearization);
139
140 void setlxstatecxx . . $ INDI/V4L2_Base#setlxstate(68e3ae50fe6578a9).(short s)
141 {
142 IDLog("setlexstate to %d\n", s);
143 lxstatecxx . . $ INDI/V4L2_Base#lxstate. = s;
144 }
145 short getlxstatecxx . . $ INDI/V4L2_Base#getlxstate(4c3706f7850cf040).()
146 {
147 return lxstatecxx . . $ INDI/V4L2_Base#lxstate.;
148 }
149 bool isstreamactivecxx . . $ INDI/V4L2_Base#isstreamactive(c9857a73d68e59ba).()
150 {
151 return streamactivecxx . . $ INDI/V4L2_Base#streamactive.;
152 }
153
154 void doDecodecxx . . $ INDI/V4L2_Base#doDecode(b45ddcbc8423892c).(bool);
155
156 protected:
157 int xioctlcxx . . $ INDI/V4L2_Base#xioctl(4ca4126ad99967a3).(int fd, int request, void *arg, char const *const request_str);
158 int ioctl_set_formatcxx . . $ INDI/V4L2_Base#ioctl_set_format(8c9d4a8a0324559a).(struct v4l2_formatcxx . . $ v4l2_format# new_fmt, char *errmsg);
159
160 int read_framecxx . . $ INDI/V4L2_Base#read_frame(1ef8e6ec083aabb9).(char *errsg);
161 int uninit_devicecxx . . $ INDI/V4L2_Base#uninit_device(1ef8e6ec083aabb9).(char *errmsg);
162 int open_devicecxx . . $ INDI/V4L2_Base#open_device(2f051e3560ff300f).(const char *devpath, char *errmsg);
163 int check_devicecxx . . $ INDI/V4L2_Base#check_device(1ef8e6ec083aabb9).(char *errmsg);
164 int init_devicecxx . . $ INDI/V4L2_Base#init_device(1ef8e6ec083aabb9).(char *errmsg);
165 int init_mmapcxx . . $ INDI/V4L2_Base#init_mmap(1ef8e6ec083aabb9).(char *errmsg);
166 int errno_exitcxx . . $ INDI/V4L2_Base#errno_exit(2f051e3560ff300f).(const char *s, char *errmsg);
167
168 void close_devicecxx . . $ INDI/V4L2_Base#close_device(49f6e7a06ebc5aa8).();
169 void init_userpcxx . . $ INDI/V4L2_Base#init_userp(cb2f890c2fdad230).(unsigned int buffer_size);
170 void init_readcxx . . $ INDI/V4L2_Base#init_read(cb2f890c2fdad230).(unsigned int buffer_size);
171
172 void findMinMaxcxx . . $ INDI/V4L2_Base#findMinMax(49f6e7a06ebc5aa8).();
173
174 int enumeratedInputscxx . . $ INDI/V4L2_Base#enumeratedInputs.;
175 int enumeratedCaptureFormatscxx . . $ INDI/V4L2_Base#enumeratedCaptureFormats.;
176
177 /* Frame rate */
178 int stdsetframeratecxx . . $ INDI/V4L2_Base#stdsetframerate(263612933c1116e4).(struct v4l2_fractcxx . . $ v4l2_fract# frate, char *errmsg);
179 int pwcsetframeratecxx . . $ INDI/V4L2_Base#pwcsetframerate(263612933c1116e4).(struct v4l2_fractcxx . . $ v4l2_fract# frate, char *errmsg);
180 struct v4l2_fractcxx . . $ v4l2_fract# stdgetframeratecxx . . $ INDI/V4L2_Base#stdgetframerate(c0c6e2c490120f9e).();
181
182 struct v4l2_capabilitycxx . . $ v4l2_capability# capcxx . . $ INDI/V4L2_Base#cap.;
183 struct v4l2_cropcapcxx . . $ v4l2_cropcap# cropcapcxx . . $ INDI/V4L2_Base#cropcap.;
184 struct v4l2_cropcxx . . $ v4l2_crop# cropcxx . . $ INDI/V4L2_Base#crop.;
185 struct v4l2_formatcxx . . $ v4l2_format# fmtcxx . . $ INDI/V4L2_Base#fmt.;
186 struct v4l2_inputcxx . . $ v4l2_input# inputcxx . . $ INDI/V4L2_Base#input.;
187 struct v4l2_buffercxx . . $ v4l2_buffer# bufcxx . . $ INDI/V4L2_Base#buf.;
188
189 bool cancropcxx . . $ INDI/V4L2_Base#cancrop.;
190 bool cropsetcxx . . $ INDI/V4L2_Base#cropset.;
191 bool cansetratecxx . . $ INDI/V4L2_Base#cansetrate.;
192 bool streamedoncecxx . . $ INDI/V4L2_Base#streamedonce.;
193 bool streamactivecxx . . $ INDI/V4L2_Base#streamactive.;
194
195 short lxstatecxx . . $ INDI/V4L2_Base#lxstate.;
196
197 struct v4l2_queryctrlcxx . . $ v4l2_queryctrl# queryctrlcxx . . $ INDI/V4L2_Base#queryctrl.;
198 struct v4l2_querymenucxx . . $ v4l2_querymenu# querymenucxx . . $ INDI/V4L2_Base#querymenu.;
199 bool has_ext_pix_formatcxx . . $ INDI/V4L2_Base#has_ext_pix_format.;
200
201 bool is_compressedcxx . . $ INDI/V4L2_Base#is_compressed(50ce9a9e25b4a850).() const;
202
203 WPFcxx . . $ WPF# *callbackcxx . . $ INDI/V4L2_Base#callback.;
204 void *uptrcxx . . $ INDI/V4L2_Base#uptr.;
205 char dev_namecxx . . $ INDI/V4L2_Base#dev_name.[64];
206 const char *pathcxx . . $ INDI/V4L2_Base#path.;
207 bool m_Nativecxx . . $ INDI/V4L2_Base#m_Native. {false};
208 io_methodcxx . . $ INDI/V4L2_Base#io_method# iocxx . . $ INDI/V4L2_Base#io.;
209 int fdcxx . . $ INDI/V4L2_Base#fd.;
210 struct buffercxx . . $ INDI/V4L2_Base#buffer# *bufferscxx . . $ INDI/V4L2_Base#buffers.;
211 unsigned int n_bufferscxx . . $ INDI/V4L2_Base#n_buffers.;
212 bool reallocate_bufferscxx . . $ INDI/V4L2_Base#reallocate_buffers.;
213 //int dropFrame;
214 //bool dropFrameEnabled;
215 //unsigned int dropFrameCount;
216
217 struct v4l2_fractcxx . . $ v4l2_fract# frameRatecxx . . $ INDI/V4L2_Base#frameRate.;
218 int xmaxcxx . . $ INDI/V4L2_Base#xmax., xmincxx . . $ INDI/V4L2_Base#xmin., ymaxcxx . . $ INDI/V4L2_Base#ymax., ymincxx . . $ INDI/V4L2_Base#ymin.;
219 int selectCallBackIDcxx . . $ INDI/V4L2_Base#selectCallBackID.;
220 //unsigned char * YBuf,*UBuf,*VBuf, *yuvBuffer, *colorBuffer, *rgb24_buffer, *cropbuf;
221
222 V4L2_Decodecxx . . $ V4L2_Decode# *v4l2_decodecxx . . $ INDI/V4L2_Base#v4l2_decode.;
223 V4L2_Decodercxx . . $ V4L2_Decoder# *decodercxx . . $ INDI/V4L2_Base#decoder.;
224 bool dodecodecxx . . $ INDI/V4L2_Base#dodecode.;
225
226 int bppcxx . . $ INDI/V4L2_Base#bpp.;
227
228 friend class ::V4L2_Drivercxx . . $ V4L2_Driver#;
229
230 char deviceNamecxx . . $ INDI/V4L2_Base#deviceName.[MAXINDIDEVICEcxx . . $ `build/libs/indicore/indiapi.h:193:9`!];
231 };
232 }