1 Star 0 Fork 7

Jcon/ZPlay_VideoPlayer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
zffmpeg.h 2.42 KB
一键复制 编辑 原始数据 按行查看 历史
#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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/J_con/ZPlay_VideoPlayer.git
[email protected]:J_con/ZPlay_VideoPlayer.git
J_con
ZPlay_VideoPlayer
ZPlay_VideoPlayer
master

搜索帮助