代码拉取完成,页面将自动刷新
同步操作将从 zhouws-chn/ZPlay_VideoPlayer 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#ifndef ZFFMPEG_H
#define ZFFMPEG_H
#include <QMutex>
#include <QMutexLocker>
#include <QThread>
#include <QList>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/version.h>
#include <libavdevice/avdevice.h>
#include <libavutil/time.h>
#include <libavutil/mathematics.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
}
typedef struct {
int sample_rate; // 样本率
int channel;
int sample_fmt;
float curPlaySec;
} AudioInfo_t;
typedef struct {
QList<AVPacket>list;
QMutex _mutex;
} CacheData_t;
#define LIST_CACHE_LENGTH 5
class ZFFmpeg : public QThread {
public:
static ZFFmpeg* getInstance();
int Load(QString);
AVPacket Read();
AVFrame * Decode(AVPacket *pkt);
/* cache data */
CacheData_t videoList;
CacheData_t audioList;
/* Thread */
void start(Priority = InheritPriority);
int play();
int pause();
int stop();
int seekPosByMs(float pos);
int GetTotalTimeMsec();
int GetCurTimeMsec();
bool CheckIsStop() {
return _isStop;
}
int GetAudioSampleRate() {
return _audioInfo.sample_rate;
}
int GetAudioSampleSize() {
return _audioInfo.sample_fmt;
}
int GetAudioChannel() {
return _audioInfo.channel;
}
/* var interface*/
AVFormatContext* GetFormatCtx() {
return pFormatCtx;
}
int GetAudioStream() {
return audioStream;
}
int GetVideoStream() {
return videoStream;
}
int GetVideoWidth() {
return videoWidth;
}
int GetVideoHeight() {
return videoHeight;
}
float GetPts(AVPacket *);
AudioInfo_t GetAudioInfo() {
return _audioInfo;
}
SwrContext* GetACtx() {
return aCtx;
}
private:
ZFFmpeg();
static QAtomicPointer<ZFFmpeg>_instance;
static QMutex _mutex;
/* Thread */
void run() override;
bool cacheData = false;
/* */
AVFormatContext *pFormatCtx = nullptr;
/* info */
float _totalTimeSec = 0;
int videoStream = -1;
int audioStream = -1;
int videoWidth = -1;
int videoHeight = -1;
bool _isStop = true;
AudioInfo_t _audioInfo = { 0 };
SwrContext *aCtx;
int Seek(float pos);
void clearList();
signals:
void playOver();
};
#endif // ZFFMPEG_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。