#ifndef VIDEOCAPTURE_H
#define VIDEOCAPTURE_H

#include <QThread>
#include <QMutex>

#include "kylincamera_global.h"
class CCycleBuffer;
class V4l2Capture;

class VideoCapture : public QThread
{
    Q_OBJECT
public:
    VideoCapture(CCycleBuffer *buf, KylinCameraInfo *device);
    ~VideoCapture();

    int m_buf_size;
    uint8_t *m_buf;
    int m_width;
    int m_height;
    int m_format;
    int m_fps;
    double m_real_time;
    char m_devname[16];
    bool m_start_flag;
    FILE *yuv_fp;
    bool m_stopped;
    bool m_run_stopped;
    QMutex m_mutex;
    int m_readable;

    V4l2Capture *v4l2Capture;

    int capture_init(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps);
    int capture_deinit();

    int capture_set_ctrl(int id, int value);
    int capture_get_ctrl(int id, int *pvalue);
    int capture_query_ctrl(int id, struct v4l2_queryctrl *pvalue);

Q_SIGNALS:
    void readout();

private:
    void run();

     CCycleBuffer *m_capture_buf;

};

#endif // VIDEOCAPTURE_H
