75 lines
1.7 KiB
C
75 lines
1.7 KiB
C
|
#ifndef VIDEO_PLAY_H
|
||
|
#define VIDEO_PLAY_H
|
||
|
|
||
|
#include <QThread>
|
||
|
#include <qdebug.h>
|
||
|
#include <QImage>
|
||
|
#include <QDateTime>
|
||
|
|
||
|
extern "C" {
|
||
|
#include <libavutil/opt.h>
|
||
|
#include <libavutil/mem.h>
|
||
|
#include <libavutil/fifo.h>
|
||
|
#include <libavutil/pixfmt.h>
|
||
|
#include <libavutil/log.h>
|
||
|
#include <libavutil/imgutils.h>
|
||
|
#include <libavcodec/avcodec.h>
|
||
|
#include <libavformat/avformat.h>
|
||
|
#include <libswscale/swscale.h>
|
||
|
#include <libswresample/swresample.h>
|
||
|
#include <libavfilter/avfilter.h>
|
||
|
#include <libavfilter/buffersrc.h>
|
||
|
#include <libavfilter/buffersink.h>
|
||
|
}
|
||
|
|
||
|
|
||
|
//视频音频解码线程
|
||
|
class ReverseDecodThread: public QThread
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
|
||
|
//构造函数
|
||
|
ReverseDecodThread();
|
||
|
~ReverseDecodThread();
|
||
|
char m_MediaFile[1024];
|
||
|
int m_run = 0;; //1表示运行 0表示停止 2表示暂停
|
||
|
double m_n64CurrentSeekPos = 0; //当前seek位置
|
||
|
bool is_CurrentSeekPos = 0; //1需要跳转 0不需要
|
||
|
|
||
|
void SetSate(int run);
|
||
|
int GetSate();
|
||
|
void SetSeekPos(qint64 pos);
|
||
|
void PausePlay();
|
||
|
void StopPlay();
|
||
|
void LogSend(QString text);
|
||
|
|
||
|
//加载视频文件
|
||
|
int set_VideoFile(QString media);
|
||
|
|
||
|
protected:
|
||
|
void run();
|
||
|
int StartPlay();
|
||
|
signals:
|
||
|
void sig_getCurrentTime(double Sec, double total_Sec);
|
||
|
void VideoDataOutput(QImage); //输出信号
|
||
|
void VideoSizeChanged(int w, int h);
|
||
|
|
||
|
private:
|
||
|
int video_width=0;
|
||
|
int video_height=0;
|
||
|
AVFormatContext *format_ctx=nullptr;
|
||
|
int video_stream_index = -1;
|
||
|
AVFrame *RGB24_pFrame = nullptr;
|
||
|
AVFrame *SRC_VIDEO_pFrame= nullptr;
|
||
|
uint8_t *out_buffer_rgb= nullptr;
|
||
|
struct SwsContext *img_convert_ctx=nullptr; //用于解码后的视频格式转换
|
||
|
|
||
|
double video_clock_tmp;
|
||
|
|
||
|
qint64 play_base_time=0;
|
||
|
|
||
|
int st_index[AVMEDIA_TYPE_NB]{ 0 };
|
||
|
|
||
|
};
|
||
|
#endif // VIDEO_PLAY_H
|