/*************************************************************************************** * * video.h is part of SimpleSkyCam. * ***************************************************************************************/ #ifndef _VIDEO_H_ #define _VIDEO_H_ #include #include #include #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 *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_