1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*
Copyright (C) 2005 by Jasem Mutlaq
Some code based on qastrocam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef V4L1_BASE_H
#define V4L1_BASE_H
#include <stdio.h>
#include <stdlib.h>
#include "videodev.h"
#include "../eventloop.h"
class V4L1_Base
{
public:
V4L1_Base();
virtual ~V4L1_Base();
/* Connection */
virtual int connectCam(const char * devpath, char *errmsg);
virtual void disconnectCam();
char * getDeviceName();
/* Image settings */
int getBrightness();
int getContrast();
int getColor();
int getHue();
int getWhiteness();
void setContrast(int val);
void setBrightness(int val);
void setColor(int val);
void setHue(int val);
void setWhiteness(int val);
/* Updates */
static void updateFrame(int d, void * p);
void newFrame();
void setPictureSettings();
void getPictureSettings();
/* Image Size */
int getWidth();
int getHeight();
void checkSize(int & x, int & y);
virtual bool setSize(int x, int y);
virtual void getMaxMinSize(int & xmax, int & ymax, int & xmin, int & ymin);
/* Frame rate */
void setFPS(int fps);
int getFPS();
void init(int preferedPalette);
void allocBuffers();
int mmapInit();
void mmapCapture();
void mmapSync();
unsigned char * mmapFrame();
unsigned char * getY();
unsigned char * getU();
unsigned char * getV();
unsigned char * getColorBuffer();
int start_capturing(char *errmsg);
int stop_capturing(char *errmsg);
void registerCallback(WPF *fp, void *ud);
protected:
int fd;
WPF *callback;
void *uptr;
unsigned long options;
struct video_capability capability;
struct video_window window;
struct video_picture picture_format;
struct video_mbuf mmap_buffer;
unsigned char * buffer_start;
long mmap_sync_buffer;
long mmap_capture_buffer;
int frameRate;
bool streamActive;
int selectCallBackID;
unsigned char * YBuf,*UBuf,*VBuf, *colorBuffer;
};
#endif
|