-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcameravideosurface.h
43 lines (39 loc) · 1.12 KB
/
cameravideosurface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef CAMERAVIDEOSURFACE_H
#define CAMERAVIDEOSURFACE_H
#include <QAbstractVideoSurface>
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
}
class CameraVideoSurface : public QAbstractVideoSurface
{
Q_OBJECT
public:
CameraVideoSurface(QObject *parent = NULL);
~CameraVideoSurface();
void setCameraResolution(const QSize &size);
protected:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override;
bool present(const QVideoFrame &frame) override;
private slots:
void cameraStopSlot();
signals:
void showFrame(QImage image);
private:
void InitEncoder();
void Encode(AVFrame *frame);
private:
AVFormatContext *pOutputFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVStream *pOutputStream;
AVPacket *packet;
AVFrame *yuvFrame;
struct SwsContext *image_convert_ctx;
};
#endif // CAMERAVIDEOSURFACE_H