2014-08-23 21:57:07 +00:00
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
** 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.
|
|
|
|
**
|
2014-11-02 15:42:30 +00:00
|
|
|
** V4l2Capture.h
|
2014-08-23 21:57:07 +00:00
|
|
|
**
|
|
|
|
** V4L2 wrapper
|
|
|
|
**
|
|
|
|
** -------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
2014-11-02 15:42:30 +00:00
|
|
|
#ifndef V4L2_CAPTURE
|
|
|
|
#define V4L2_CAPTURE
|
2014-08-23 21:57:07 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
// ---------------------------------
|
|
|
|
// V4L2 Capture parameters
|
|
|
|
// ---------------------------------
|
|
|
|
struct V4L2DeviceParameters
|
|
|
|
{
|
2014-08-24 14:35:18 +00:00
|
|
|
V4L2DeviceParameters(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps, int verbose) :
|
2014-08-23 21:57:07 +00:00
|
|
|
m_devName(devname), m_format(format), m_width(width), m_height(height), m_fps(fps), m_verbose(verbose) {};
|
|
|
|
|
|
|
|
std::string m_devName;
|
2014-08-24 14:35:18 +00:00
|
|
|
unsigned int m_format;
|
|
|
|
unsigned int m_width;
|
|
|
|
unsigned int m_height;
|
2014-08-23 21:57:07 +00:00
|
|
|
int m_fps;
|
|
|
|
int m_verbose;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------
|
|
|
|
// V4L2 Capture
|
|
|
|
// ---------------------------------
|
2014-11-02 15:42:30 +00:00
|
|
|
class V4l2Capture
|
2014-08-23 21:57:07 +00:00
|
|
|
{
|
|
|
|
protected:
|
2014-11-02 15:42:30 +00:00
|
|
|
V4l2Capture(V4L2DeviceParameters params);
|
2014-08-23 21:57:07 +00:00
|
|
|
|
|
|
|
public:
|
2014-11-02 15:42:30 +00:00
|
|
|
virtual ~V4l2Capture();
|
2014-08-23 21:57:07 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
int getFd() { return m_fd; };
|
2014-11-08 18:13:19 +00:00
|
|
|
int getBufferSize() { return m_bufferSize; };
|
|
|
|
int getFormat() { return m_format; } ;
|
|
|
|
void queryFormat();
|
2014-08-23 21:57:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool init(unsigned int mandatoryCapabilities);
|
2014-09-05 19:34:50 +00:00
|
|
|
void close();
|
|
|
|
|
2014-08-23 21:57:07 +00:00
|
|
|
int initdevice(const char *dev_name, unsigned int mandatoryCapabilities);
|
|
|
|
int checkCapabilities(int fd, unsigned int mandatoryCapabilities);
|
|
|
|
int configureFormat(int fd);
|
|
|
|
int configureParam(int fd);
|
|
|
|
int xioctl(int fd, int request, void *arg);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual bool captureStart() = 0;
|
|
|
|
virtual size_t read(char* buffer, size_t bufferSize) = 0;
|
|
|
|
virtual bool captureStop() = 0;
|
2014-09-07 17:01:44 +00:00
|
|
|
virtual bool isReady() = 0;
|
2014-08-23 21:57:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
V4L2DeviceParameters m_params;
|
|
|
|
int m_fd;
|
|
|
|
int m_bufferSize;
|
2014-11-08 18:13:19 +00:00
|
|
|
int m_format;
|
2014-08-23 21:57:07 +00:00
|
|
|
};
|
|
|
|
|
2014-08-24 14:35:18 +00:00
|
|
|
#endif
|