2 videodevice.cpp - Kopete Video Device Low-level Support
4 Copyright (c) 2005-2006 by Cláudio da Silveira Pinheiro <taupter@gmail.com>
6 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
15 *************************************************************************
20 #ifndef KOPETE_AVVIDEODEVICELISTITEM_H
21 #define KOPETE_AVVIDEODEVICELISTITEM_H
23 #include <config-kopete.h>
27 #include <sys/ioctl.h>
28 #include <sys/types.h>
34 #if defined(__linux__) && defined(ENABLE_AV)
36 #include <asm/types.h>
37 #undef __STRICT_ANSI__
38 #ifndef __u64 //required by videodev.h
39 #define __u64 unsigned long long
41 #ifndef __s64 //required by videodev.h
42 #define __s64 signed long long
44 #ifndef __s32 //required by videodev.h
45 #define __s32 signed long
50 #define pgoff_t unsigned long
54 #include <linux/kernel.h>
55 #include <linux/videodev.h>
56 #define VIDEO_MODE_PAL_Nc 3
57 #define VIDEO_MODE_PAL_M 4
58 #define VIDEO_MODE_PAL_N 5
59 #define VIDEO_MODE_NTSC_JP 6
60 #define __STRICT_ANSI__
67 #include <q3valuevector.h>
68 #include <kcombobox.h>
70 #include "videoinput.h"
77 @author Kopete Developers
82 #if defined( __linux__) && defined(ENABLE_AV)
85 #ifdef V4L2_CAP_VIDEO_CAPTURE
96 PIXELFORMAT_GREY
= (1 << 0),
97 PIXELFORMAT_RGB332
= (1 << 1),
98 PIXELFORMAT_RGB444
= (1 << 2),
99 PIXELFORMAT_RGB555
= (1 << 3),
100 PIXELFORMAT_RGB565
= (1 << 4),
101 PIXELFORMAT_RGB555X
= (1 << 5),
102 PIXELFORMAT_RGB565X
= (1 << 6),
103 PIXELFORMAT_BGR24
= (1 << 7),
104 PIXELFORMAT_RGB24
= (1 << 8),
105 PIXELFORMAT_BGR32
= (1 << 9),
106 PIXELFORMAT_RGB32
= (1 << 10),
109 PIXELFORMAT_SBGGR8
= (1 << 11),
112 PIXELFORMAT_YUYV
= (1 << 12),
113 PIXELFORMAT_UYVY
= (1 << 13),
114 PIXELFORMAT_YUV420P
= (1 << 14),
115 PIXELFORMAT_YUV422P
= (1 << 15),
117 // Compressed formats
118 PIXELFORMAT_JPEG
= (1 << 16),
119 PIXELFORMAT_MPEG
= (1 << 17),
122 PIXELFORMAT_DV
= (1 << 18),
123 PIXELFORMAT_ET61X251
= (1 << 19),
124 PIXELFORMAT_HI240
= (1 << 20),
125 PIXELFORMAT_HM12
= (1 << 21),
126 PIXELFORMAT_MJPEG
= (1 << 22),
127 PIXELFORMAT_PWC1
= (1 << 23),
128 PIXELFORMAT_PWC2
= (1 << 24),
129 PIXELFORMAT_SN9C10X
= (1 << 25),
130 PIXELFORMAT_WNVA
= (1 << 26),
131 PIXELFORMAT_YYUV
= (1 << 27)
133 // PIXELFORMAT_ALL = 0x00003FFF
139 STANDARD_PAL_B
= (1 << 0),
140 STANDARD_PAL_B1
= (1 << 1),
141 STANDARD_PAL_G
= (1 << 2),
142 STANDARD_PAL_H
= (1 << 3),
143 STANDARD_PAL_I
= (1 << 4),
144 STANDARD_PAL_D
= (1 << 5),
145 STANDARD_PAL_D1
= (1 << 6),
146 STANDARD_PAL_K
= (1 << 7),
148 STANDARD_PAL_M
= (1 << 8),
149 STANDARD_PAL_N
= (1 << 9),
150 STANDARD_PAL_Nc
= (1 << 10),
151 STANDARD_PAL_60
= (1 << 11),
152 // STANDARD_PAL_60 is a hybrid standard with 525 lines, 60 Hz refresh rate, and PAL color modulation with a 4.43 MHz color subcarrier. Some PAL video recorders can play back NTSC tapes in this mode for display on a 50/60 Hz agnostic PAL TV.
154 STANDARD_NTSC_M
= (1 << 12),
155 STANDARD_NTSC_M_JP
= (1 << 13),
156 STANDARD_NTSC_443
= (1 << 14),
157 // STANDARD_NTSC_443 is a hybrid standard with 525 lines, 60 Hz refresh rate, and NTSC color modulation with a 4.43 MHz color subcarrier.
158 STANDARD_NTSC_M_KR
= (1 << 15),
160 STANDARD_SECAM_B
= (1 << 16),
161 STANDARD_SECAM_D
= (1 << 17),
162 STANDARD_SECAM_G
= (1 << 18),
163 STANDARD_SECAM_H
= (1 << 19),
164 STANDARD_SECAM_K
= (1 << 20),
165 STANDARD_SECAM_K1
= (1 << 21),
166 STANDARD_SECAM_L
= (1 << 22),
167 STANDARD_SECAM_LC
= (1 << 23),
170 STANDARD_ATSC_8_VSB
= (1 << 24),
171 STANDARD_ATSC_16_VSB
= (1 << 25),
173 // Some common needed stuff
174 STANDARD_PAL_BG
= ( STANDARD_PAL_B
| STANDARD_PAL_B1
| STANDARD_PAL_G
),
175 STANDARD_PAL_DK
= ( STANDARD_PAL_D
| STANDARD_PAL_D1
| STANDARD_PAL_K
),
176 STANDARD_PAL
= ( STANDARD_PAL_BG
| STANDARD_PAL_DK
| STANDARD_PAL_H
| STANDARD_PAL_I
),
177 STANDARD_NTSC
= ( STANDARD_NTSC_M
| STANDARD_NTSC_M_JP
| STANDARD_NTSC_M_KR
),
178 STANDARD_SECAM_DK
= ( STANDARD_SECAM_D
| STANDARD_SECAM_K
| STANDARD_SECAM_K1
),
179 STANDARD_SECAM
= ( STANDARD_SECAM_B
| STANDARD_SECAM_G
| STANDARD_SECAM_H
| STANDARD_SECAM_DK
| STANDARD_SECAM_L
| STANDARD_SECAM_LC
),
181 // some merged standards */
182 STANDARD_MN
= ( STANDARD_PAL_M
| STANDARD_PAL_N
| STANDARD_PAL_Nc
| STANDARD_NTSC
),
183 STANDARD_B
= ( STANDARD_PAL_B
| STANDARD_PAL_B1
| STANDARD_SECAM_B
),
184 STANDARD_GH
= ( STANDARD_PAL_G
| STANDARD_PAL_H
| STANDARD_SECAM_G
| STANDARD_SECAM_H
),
185 STANDARD_DK
= ( STANDARD_PAL_DK
| STANDARD_SECAM_DK
),
187 STANDARD_525_60
= ( STANDARD_PAL_M
| STANDARD_PAL_60
| STANDARD_NTSC
| STANDARD_NTSC_443
),
188 STANDARD_625_50
= ( STANDARD_PAL
| STANDARD_PAL_N
| STANDARD_PAL_Nc
| STANDARD_SECAM
),
189 STANDARD_ATSC
= ( STANDARD_ATSC_8_VSB
| STANDARD_ATSC_16_VSB
),
191 STANDARD_UNKNOWN
= 0,
192 STANDARD_ALL
= ( STANDARD_525_60
| STANDARD_625_50
)
208 pixel_format pixelformat
;
209 QVector
<uchar
> data
; // maybe it should be a rawbuffer instead of it? It could make us avoid a memory copy
211 struct rawbuffer
// raw buffer
222 int setFileName(QString filename
);
226 int showDeviceCapabilities();
235 int setSize( int newwidth
, int newheight
);
237 pixel_format
setPixelFormat(pixel_format newformat
);
238 int pixelFormatCode(pixel_format pixelformat
);
239 pixel_format
pixelFormatForPalette( int palette
);
240 int pixelFormatDepth(pixel_format pixelformat
);
241 QString
pixelFormatName(pixel_format pixelformat
);
242 QString
pixelFormatName(int pixelformat
);
243 int detectPixelFormats();
245 __u64
signalStandardCode(signal_standard standard
);
246 QString
signalStandardName(signal_standard standard
);
247 QString
signalStandardName(int standard
);
248 int detectSignalStandards();
251 int selectInput(int input
);
252 int setInputParameters();
253 int startCapturing();
255 int getFrame(imagebuffer
*imgbuffer
);
256 int getImage(QImage
*qimage
);
260 float getBrightness();
261 float setBrightness(float brightness
);
263 float setContrast(float contrast
);
264 float getSaturation();
265 float setSaturation(float saturation
);
266 float getWhiteness();
267 float setWhiteness(float whiteness
);
269 float setHue(float Hue
);
271 bool getAutoBrightnessContrast();
272 bool setAutoBrightnessContrast(bool brightnesscontrast
);
273 bool getAutoColorCorrection();
274 bool setAutoColorCorrection(bool colorcorrection
);
275 bool getImageAsMirror();
276 bool setImageAsMirror(bool imageasmirror
);
286 void setUdi( const QString
& );
290 size_t m_modelindex
; // Defines what's the number of a device when more than 1 device of a given model is present;
291 QString full_filename
;
292 videodev_driver m_driver
;
296 #if defined(__linux__) && defined(ENABLE_AV)
297 #ifdef V4L2_CAP_VIDEO_CAPTURE
298 struct v4l2_capability V4L2_capabilities
;
299 struct v4l2_cropcap cropcap
;
300 struct v4l2_crop crop
;
301 struct v4l2_format fmt
;
302 struct v4l2_fmtdesc fmtdesc
; // Not sure if it must be here or inside detectPixelFormats(). Should inve
303 // struct v4l2_input m_input;
304 struct v4l2_queryctrl queryctrl
;
305 struct v4l2_querymenu querymenu
;
306 void enumerateMenu (void);
308 struct video_capability V4L_capabilities
;
309 struct video_buffer V4L_videobuffer
;
311 QVector
<Kopete::AV::VideoInput
> m_input
;
314 int currentwidth
, minwidth
, maxwidth
, currentheight
, minheight
, maxheight
;
316 QVector
<rawbuffer
> m_rawbuffers
;
317 unsigned int m_streambuffers
;
318 imagebuffer m_currentbuffer
;
322 pixel_format m_pixelformat
;
324 io_method m_io_method
;
326 bool m_videochromakey
;
333 int xioctl(int request
, void *arg
);
334 int errnoReturn(const char* s
);