You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
1.8 KiB
116 lines
1.8 KiB
/***************************************************************************************
|
|
*
|
|
* video.h is part of SimpleSkyCam.
|
|
*
|
|
***************************************************************************************/
|
|
|
|
#ifndef _VIDEO_H_
|
|
#define _VIDEO_H_
|
|
|
|
#include <string>
|
|
#include <list>
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
|
#include "gui.h"
|
|
#include "config.h"
|
|
|
|
|
|
enum {
|
|
IOMODE_READ,
|
|
IOMODE_MMAP,
|
|
IOMODE_USERPTR
|
|
};
|
|
|
|
|
|
enum {
|
|
VDEV_STATUS_UNKNOWN,
|
|
VDEV_STATUS_OK,
|
|
VDEV_STATUS_AGAIN,
|
|
VDEV_STATUS_ERROR
|
|
};
|
|
|
|
|
|
// callback status
|
|
enum {
|
|
VDEV_CBSTATUS_NOTHING = 1,
|
|
VDEV_CBSTATUS_NEWFRAME,
|
|
VDEV_CBSTATUS_ERROR
|
|
};
|
|
|
|
|
|
struct {
|
|
unsigned int size;
|
|
unsigned char* data;
|
|
} typedef VideoInBuffer;
|
|
|
|
|
|
struct {
|
|
int w;
|
|
int h;
|
|
uint32_t format;
|
|
uint32_t size;
|
|
uint32_t maxsize;
|
|
unsigned char *data;
|
|
} typedef VideoFrame;
|
|
|
|
|
|
#define VIDEOBUFFERS 3
|
|
class VideoDev {
|
|
private:
|
|
std::string conf_device;
|
|
std::string conf_devicename;
|
|
gboolean (*callback)(gpointer data);
|
|
int running;
|
|
GMutex mutex;
|
|
GThread *thread;
|
|
|
|
VideoFrame vf[VIDEOBUFFERS];
|
|
VideoInBuffer *inbuffers;
|
|
unsigned int inbuffers_cnt;
|
|
struct v4l2_cropcap cropcap;
|
|
struct v4l2_crop crop;
|
|
struct v4l2_format fmt;
|
|
|
|
|
|
int vf_rec;
|
|
int vf_get;
|
|
int io; // IO Mode
|
|
int fd;
|
|
|
|
int InitMMap();
|
|
int InitUserPtr();
|
|
int CaptureStart();
|
|
int CaptureStop();
|
|
int UnInit();
|
|
|
|
int OpenInit ();
|
|
int Close ();
|
|
int Grab();
|
|
int xioctl (int fd, int request, void *arg);
|
|
public:
|
|
VideoDev();
|
|
~VideoDev();
|
|
|
|
void Thread();
|
|
|
|
int Start(std::string dev, gboolean (*callback_func)(gpointer data)); // will start a new thread
|
|
int Stop(); // stop video processing and stop the pthread
|
|
|
|
int GetDeviceList(std::list<std::string> *list);
|
|
int IsRunning() { return running; };
|
|
|
|
VideoFrame *FrameGet();
|
|
void FrameNext();
|
|
void PrintCaps (uint32_t caps);
|
|
void PrintFmt(struct v4l2_format *f);
|
|
};
|
|
|
|
|
|
extern VideoDev videodev;
|
|
|
|
|
|
#endif // _VIDEO_H_
|
|
|