#ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H

#include <QWidget>
#include "kylincamera_global.h"

class VideoCapture;
class VideoDecoder;
class VideoEncoder;
class CCycleBuffer;
class AudioCapture;
class VideoDisplay : public QWidget
{
    Q_OBJECT
public:
    explicit VideoDisplay(QWidget *parent, KylinCameraInfo *device);
    ~VideoDisplay();

    void paintEvent(QPaintEvent *);

    CameraMode m_camera_mode;
    VideoCapture *videoCapture;
    VideoDecoder *videoDecoder;
    VideoEncoder *videoEncoder;
    AudioCapture *audioCapture;
    char *m_rgb_buf;

    FILE *rgb_fp;

    void set_src_ratio(unsigned int width, unsigned int height);
    void set_background_color(QColor color);

protected:
    void resizeEvent(QResizeEvent *event);

private:
    double des_w_h_ratio;
    double src_w_h_ratio;
    int scale_w;
    int scale_h;
    QColor background_color;

    char m_start_status;

    CCycleBuffer *m_capture_buf;
    CCycleBuffer *m_encoder_buf;
    CCycleBuffer *m_audio_buf;
Q_SIGNALS:
    void readout();
};

#endif // VIDEOWIDGET_H
