v4l2rtspserver/inc/V4l2Capture.h

77 lines
1.9 KiB
C
Raw Normal View History

/* ---------------------------------------------------------------------------
** 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
**
** V4L2 wrapper
**
** -------------------------------------------------------------------------*/
2014-11-02 15:42:30 +00:00
#ifndef V4L2_CAPTURE
#define V4L2_CAPTURE
#include <string>
#include <list>
#include <iostream>
// ---------------------------------
// V4L2 Capture parameters
// ---------------------------------
struct V4L2DeviceParameters
{
V4L2DeviceParameters(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps, int verbose) :
m_devName(devname), m_format(format), m_width(width), m_height(height), m_fps(fps), m_verbose(verbose) {};
std::string m_devName;
unsigned int m_format;
unsigned int m_width;
unsigned int m_height;
int m_fps;
int m_verbose;
};
// ---------------------------------
// V4L2 Capture
// ---------------------------------
2014-11-02 15:42:30 +00:00
class V4l2Capture
{
protected:
2014-11-02 15:42:30 +00:00
V4l2Capture(V4L2DeviceParameters params);
public:
2014-11-02 15:42:30 +00:00
virtual ~V4l2Capture();
public:
int getFd() { return m_fd; };
int getBufferSize() { return m_bufferSize; };
int getFormat() { return m_format; } ;
void queryFormat();
protected:
bool init(unsigned int mandatoryCapabilities);
2014-09-05 19:34:50 +00:00
void close();
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;
protected:
V4L2DeviceParameters m_params;
int m_fd;
int m_bufferSize;
int m_format;
};
#endif