1 | /* --------------------------------------------------------------------------- |
2 | ** This software is in the public domain, furnished "as is", without technical |
3 | ** support, and with no warranty, express or implied, as to its usefulness for |
4 | ** any purpose. |
5 | ** |
6 | ** V4l2MmapDevice.h |
7 | ** |
8 | ** V4L2 source using mmap API |
9 | ** |
10 | ** -------------------------------------------------------------------------*/ |
11 | |
12 | |
13 | #ifndef V4L2_MMAP_DEVICE |
14 | #define V4L2_MMAP_DEVICE |
15 | |
16 | #include "V4l2Device.h" |
17 | |
18 | #define V4L2MMAP_NBBUFFER 10 |
19 | |
20 | class V4l2MmapDevice : public V4l2Device |
21 | { |
22 | protected: |
23 | size_t writeInternal(char* buffer, size_t bufferSize); |
24 | bool startPartialWrite(void); |
25 | size_t writePartialInternal(char*, size_t); |
26 | bool endPartialWrite(void); |
27 | size_t readInternal(char* buffer, size_t bufferSize); |
28 | |
29 | public: |
30 | V4l2MmapDevice(const V4L2DeviceParameters & params, v4l2_buf_type deviceType); |
31 | virtual ~V4l2MmapDevice(); |
32 | |
33 | virtual bool init(unsigned int mandatoryiCapabilities); |
34 | virtual bool isReady() { return ((m_fd != -1)&& (n_buffers != 0)); } |
35 | virtual bool start(); |
36 | virtual bool stop(); |
37 | |
38 | protected: |
39 | unsigned int n_buffers; |
40 | |
41 | struct buffer |
42 | { |
43 | void * start; |
44 | size_t length; |
45 | }; |
46 | buffer m_buffer[V4L2MMAP_NBBUFFER]; |
47 | }; |
48 | |
49 | #endif |
50 | |
51 | |