#ifndef QFFMPEG_H
|
#define QFFMPEG_H
|
|
//必须加以下内容,否则编译不能通过,为了兼容C和C99标准
|
#ifndef INT64_C
|
#define INT64_C
|
#define UINT64_C
|
#endif
|
|
//引入ffmpeg头文件
|
extern "C"
|
{
|
#include <libavcodec/avcodec.h> //实现音视频的编解码功能
|
#include <libavformat/avformat.h> //实现音视频文件的读取和写入功能,支持多种音视频格式
|
#include <libavfilter/avfilter.h>
|
#include <libswscale/swscale.h>
|
#include <libavutil/frame.h>
|
#include <libavutil/imgutils.h>
|
}
|
|
// 引入SDL2头文件
|
//extern "C"
|
//{
|
// #include "SDL.h"
|
//}
|
|
#include <QObject>
|
#include <QMutex>
|
#include <QImage>
|
|
class QFFmpeg : public QObject
|
{
|
Q_OBJECT
|
public:
|
explicit QFFmpeg(QObject *parent = 0);
|
~QFFmpeg();
|
|
bool Init(); // 初始化
|
void Play(); // 播放
|
|
void SetUrl(QString url){this->url=url;} // 设置视频源
|
|
QString Url()const{return url;}
|
int VideoWidth()const{return videoWidth;}
|
int VideoHeight()const{return videoHeight;}
|
void SetIndex(int x){this->index=x;}
|
|
private:
|
QMutex mutex;
|
AVPicture pAVPicture;
|
AVFormatContext *pAVFormatContext;
|
AVCodecContext *pAVCodecContext;
|
AVFrame *pAVFrame;
|
SwsContext * pSwsContext;
|
AVPacket pAVPacket;
|
|
QString url;
|
int videoWidth;
|
int videoHeight;
|
int videoStreamIndex;
|
int index;
|
|
// SDL相关
|
// SDL_Window *sdlWindow;
|
// SDL_Renderer *sdlRenderer;
|
// SDL_Texture *sdlTexture;
|
|
signals:
|
void GetImage(const QImage &image,int x); // 发送解码后的图像信号
|
|
};
|
|
#endif // QFFMPEG_H
|