forked from jnohlgard/python-v4l2capture
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv4l2capture.h
134 lines (112 loc) · 2.96 KB
/
v4l2capture.h
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// python-v4l2capture
// Python extension to capture video with video4linux2
//
// 2009, 2010, 2011 Fredrik Portstrom, released into the public domain
// 2011, Joakim Gebart
// 2013, Tim Sheerman-Chase
// See README for license
#ifndef V4L2CAPTURE_H
#define V4L2CAPTURE_H
#include <vector>
#include <pthread.h>
#include <string>
#include "base.h"
struct buffer {
void *start;
size_t length;
};
struct capability {
int id;
const char *name;
};
class SetFormatParams
{
public:
std::string fmt;
int width, height;
SetFormatParams()
{
width = 0;
height = 0;
}
SetFormatParams(const SetFormatParams &in)
{
SetFormatParams::operator=(in);
}
const SetFormatParams &operator=(const SetFormatParams &in)
{
width = in.width;
height = in.height;
fmt = in.fmt;
return *this;
}
};
/*static struct capability capabilities[] = {
{ V4L2_CAP_ASYNCIO, "asyncio" },
{ V4L2_CAP_AUDIO, "audio" },
{ V4L2_CAP_HW_FREQ_SEEK, "hw_freq_seek" },
{ V4L2_CAP_RADIO, "radio" },
{ V4L2_CAP_RDS_CAPTURE, "rds_capture" },
{ V4L2_CAP_READWRITE, "readwrite" },
{ V4L2_CAP_SLICED_VBI_CAPTURE, "sliced_vbi_capture" },
{ V4L2_CAP_SLICED_VBI_OUTPUT, "sliced_vbi_output" },
{ V4L2_CAP_STREAMING, "streaming" },
{ V4L2_CAP_TUNER, "tuner" },
{ V4L2_CAP_VBI_CAPTURE, "vbi_capture" },
{ V4L2_CAP_VBI_OUTPUT, "vbi_output" },
{ V4L2_CAP_VIDEO_CAPTURE, "video_capture" },
{ V4L2_CAP_VIDEO_OUTPUT, "video_output" },
{ V4L2_CAP_VIDEO_OUTPUT_OVERLAY, "video_output_overlay" },
{ V4L2_CAP_VIDEO_OVERLAY, "video_overlay" }
};*/
int my_ioctl(int fd, int request, void *arg, int utimeout);
class Video_in_Manager : public Base_Video_In
{
public:
//Device_manager *self;
std::string devName;
int stop;
int stopped;
pthread_mutex_t lock;
std::vector<std::string> openDeviceFlag;
std::vector<int> startDeviceFlag;
std::vector<class SetFormatParams> setFormatFlags;
int stopDeviceFlag;
int closeDeviceFlag;
int deviceStarted;
int fd;
struct buffer *buffers;
int frameWidth, frameHeight;
int buffer_counts;
std::string pxFmt;
int verbose;
std::string targetFmt;
std::vector<unsigned char *> decodedFrameBuff;
std::vector<class FrameMetaData> decodedFrameMetaBuff;
unsigned decodedFrameBuffMaxSize;
Video_in_Manager(const char *devNameIn);
virtual ~Video_in_Manager();
void Stop();
void WaitForStop();
void OpenDevice();
void SetFormat(const char *fmt, int width, int height);
void StartDevice(int buffer_count);
void StopDevice();
void CloseDevice();
int GetFrame(unsigned char **buffOut, class FrameMetaData *metaOut);
void Test();
protected:
int ReadFrame();
int OpenDeviceInternal();
int SetFormatInternal(class SetFormatParams &args);
int GetFormatInternal();
int StartDeviceInternal(int buffer_count);
void StopDeviceInternal();
int CloseDeviceInternal();
public:
void Run();
};
void *Video_in_Worker_thread(void *arg);
std::vector<std::vector<std::wstring> > List_in_devices();
// **********************************************************************
#endif //V4L2CAPTURE_H