houxiao
2017-06-13 4b914a5d7e3d7971cb3e3ed49047fa331bd74da3
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
/* ---------------------------------------------------------------------------
** This software is in the public domain, furnished "as is", without technical
** support, and with no warranty, express or implied, as to its usefulness for
** any purpose.
**
** V4l2MmapDevice.h
** 
** V4L2 source using mmap API
**
** -------------------------------------------------------------------------*/
 
 
#ifndef V4L2_MMAP_DEVICE
#define V4L2_MMAP_DEVICE
 
#include "V4l2Device.h"
 
#define V4L2MMAP_NBBUFFER 10
 
class V4l2MmapDevice : public V4l2Device
{    
    protected:    
        size_t writeInternal(char* buffer, size_t bufferSize);
        size_t readInternal(char* buffer, size_t bufferSize);
            
    public:
        V4l2MmapDevice(const V4L2DeviceParameters & params, v4l2_buf_type deviceType);        
        virtual ~V4l2MmapDevice();
 
        virtual bool init(unsigned int mandatoryiCapabilities);
        virtual bool isReady() { return  ((m_fd != -1)&& (n_buffers != 0)); };
        virtual bool start();
        virtual bool stop();
    
    protected:
        unsigned int  n_buffers;
    
        struct buffer 
        {
            void *                  start;
            size_t                  length;
        };
        buffer m_buffer[V4L2MMAP_NBBUFFER];
};
 
#endif