|
11 | 11 | // util includes
|
12 | 12 | #include <utils/Image.h>
|
13 | 13 | #include <utils/ColorRgb.h>
|
| 14 | +#include <utils/PixelFormat.h> |
14 | 15 | #include <utils/VideoMode.h>
|
15 | 16 |
|
16 | 17 | // grabber includes
|
17 | 18 | #include <grabber/VideoStandard.h>
|
18 |
| -#include <grabber/PixelFormat.h> |
19 | 19 |
|
20 | 20 | /// Capture class for V4L2 devices
|
21 | 21 | ///
|
22 | 22 | /// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
|
23 | 23 | class V4L2Grabber : public QObject
|
24 | 24 | {
|
25 |
| - Q_OBJECT |
| 25 | + Q_OBJECT |
26 | 26 |
|
27 | 27 | public:
|
28 |
| - V4L2Grabber(const std::string & device, |
29 |
| - int input, |
30 |
| - VideoStandard videoStandard, PixelFormat pixelFormat, |
31 |
| - int width, |
32 |
| - int height, |
33 |
| - int frameDecimation, |
34 |
| - int horizontalPixelDecimation, |
35 |
| - int verticalPixelDecimation); |
36 |
| - virtual ~V4L2Grabber(); |
| 28 | + V4L2Grabber(const std::string & device, |
| 29 | + int input, |
| 30 | + VideoStandard videoStandard, PixelFormat pixelFormat, |
| 31 | + int width, |
| 32 | + int height, |
| 33 | + int frameDecimation, |
| 34 | + int horizontalPixelDecimation, |
| 35 | + int verticalPixelDecimation); |
| 36 | + virtual ~V4L2Grabber(); |
37 | 37 |
|
38 | 38 | public slots:
|
39 |
| - void setCropping(int cropLeft, |
40 |
| - int cropRight, |
41 |
| - int cropTop, |
42 |
| - int cropBottom); |
| 39 | + void setCropping(int cropLeft, |
| 40 | + int cropRight, |
| 41 | + int cropTop, |
| 42 | + int cropBottom); |
43 | 43 |
|
44 |
| - void set3D(VideoMode mode); |
| 44 | + void set3D(VideoMode mode); |
45 | 45 |
|
46 |
| - void setSignalThreshold(double redSignalThreshold, |
47 |
| - double greenSignalThreshold, |
48 |
| - double blueSignalThreshold, |
49 |
| - int noSignalCounterThreshold); |
| 46 | + void setSignalThreshold(double redSignalThreshold, |
| 47 | + double greenSignalThreshold, |
| 48 | + double blueSignalThreshold, |
| 49 | + int noSignalCounterThreshold); |
50 | 50 |
|
51 |
| - void start(); |
| 51 | + void start(); |
52 | 52 |
|
53 |
| - void stop(); |
| 53 | + void stop(); |
54 | 54 |
|
55 | 55 | signals:
|
56 |
| - void newFrame(const Image<ColorRgb> & image); |
| 56 | + void newFrame(const Image<ColorRgb> & image); |
57 | 57 |
|
58 | 58 | private slots:
|
59 |
| - int read_frame(); |
| 59 | + int read_frame(); |
60 | 60 |
|
61 | 61 | private:
|
62 |
| - void open_device(); |
| 62 | + void open_device(); |
63 | 63 |
|
64 |
| - void close_device(); |
| 64 | + void close_device(); |
65 | 65 |
|
66 |
| - void init_read(unsigned int buffer_size); |
| 66 | + void init_read(unsigned int buffer_size); |
67 | 67 |
|
68 |
| - void init_mmap(); |
| 68 | + void init_mmap(); |
69 | 69 |
|
70 |
| - void init_userp(unsigned int buffer_size); |
| 70 | + void init_userp(unsigned int buffer_size); |
71 | 71 |
|
72 |
| - void init_device(VideoStandard videoStandard, int input); |
| 72 | + void init_device(VideoStandard videoStandard, int input); |
73 | 73 |
|
74 |
| - void uninit_device(); |
| 74 | + void uninit_device(); |
75 | 75 |
|
76 |
| - void start_capturing(); |
| 76 | + void start_capturing(); |
77 | 77 |
|
78 |
| - void stop_capturing(); |
| 78 | + void stop_capturing(); |
79 | 79 |
|
80 |
| - bool process_image(const void *p, int size); |
| 80 | + bool process_image(const void *p, int size); |
81 | 81 |
|
82 |
| - void process_image(const uint8_t *p); |
| 82 | + void process_image(const uint8_t *p); |
83 | 83 |
|
84 |
| - int xioctl(int request, void *arg); |
| 84 | + int xioctl(int request, void *arg); |
85 | 85 |
|
86 |
| - void throw_exception(const std::string &error); |
| 86 | + void throw_exception(const std::string &error); |
87 | 87 |
|
88 |
| - void throw_errno_exception(const std::string &error); |
| 88 | + void throw_errno_exception(const std::string &error); |
89 | 89 |
|
90 | 90 | private:
|
91 |
| - enum io_method { |
92 |
| - IO_METHOD_READ, |
93 |
| - IO_METHOD_MMAP, |
94 |
| - IO_METHOD_USERPTR |
95 |
| - }; |
| 91 | + enum io_method { |
| 92 | + IO_METHOD_READ, |
| 93 | + IO_METHOD_MMAP, |
| 94 | + IO_METHOD_USERPTR |
| 95 | + }; |
96 | 96 |
|
97 |
| - struct buffer { |
98 |
| - void *start; |
99 |
| - size_t length; |
100 |
| - }; |
| 97 | + struct buffer { |
| 98 | + void *start; |
| 99 | + size_t length; |
| 100 | + }; |
101 | 101 |
|
102 | 102 | private:
|
103 |
| - const std::string _deviceName; |
104 |
| - const io_method _ioMethod; |
105 |
| - int _fileDescriptor; |
106 |
| - std::vector<buffer> _buffers; |
107 |
| - |
108 |
| - PixelFormat _pixelFormat; |
109 |
| - int _width; |
110 |
| - int _height; |
111 |
| - int _frameByteSize; |
112 |
| - int _cropLeft; |
113 |
| - int _cropRight; |
114 |
| - int _cropTop; |
115 |
| - int _cropBottom; |
116 |
| - int _frameDecimation; |
117 |
| - int _horizontalPixelDecimation; |
118 |
| - int _verticalPixelDecimation; |
119 |
| - int _noSignalCounterThreshold; |
120 |
| - |
121 |
| - ColorRgb _noSignalThresholdColor; |
122 |
| - |
123 |
| - VideoMode _mode3D; |
124 |
| - |
125 |
| - int _currentFrame; |
126 |
| - int _noSignalCounter; |
127 |
| - |
128 |
| - QSocketNotifier * _streamNotifier; |
| 103 | + const std::string _deviceName; |
| 104 | + const io_method _ioMethod; |
| 105 | + int _fileDescriptor; |
| 106 | + std::vector<buffer> _buffers; |
| 107 | + |
| 108 | + PixelFormat _pixelFormat; |
| 109 | + int _width; |
| 110 | + int _height; |
| 111 | + int _frameByteSize; |
| 112 | + int _cropLeft; |
| 113 | + int _cropRight; |
| 114 | + int _cropTop; |
| 115 | + int _cropBottom; |
| 116 | + int _frameDecimation; |
| 117 | + int _horizontalPixelDecimation; |
| 118 | + int _verticalPixelDecimation; |
| 119 | + int _noSignalCounterThreshold; |
| 120 | + |
| 121 | + ColorRgb _noSignalThresholdColor; |
| 122 | + |
| 123 | + VideoMode _mode3D; |
| 124 | + |
| 125 | + int _currentFrame; |
| 126 | + int _noSignalCounter; |
| 127 | + |
| 128 | + QSocketNotifier * _streamNotifier; |
129 | 129 | };
|
0 commit comments