1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/zhouws-chn-ZPlay_VideoPlayer

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
zffmpeg.h 2.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
tang_god Отправлено 27.08.2020 02:34 80f89a6
#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

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/zhouws-chn-ZPlay_VideoPlayer.git
git@api.gitlife.ru:oschina-mirror/zhouws-chn-ZPlay_VideoPlayer.git
oschina-mirror
zhouws-chn-ZPlay_VideoPlayer
zhouws-chn-ZPlay_VideoPlayer
master