-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathQFFmpegAudioDecoder.h
77 lines (65 loc) · 1.59 KB
/
QFFmpegAudioDecoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef QFFMPEGAUDIODECODER_H
#define QFFMPEGAUDIODECODER_H
#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QSemaphore>
#include "QOpenALEngine.h"
#include <QTimer>
#include <QQueue>
#include "QFFmpegClock.h"
extern "C"{
#include "libavutil/avstring.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"
}
typedef struct FFAVPacket {
AVPacket pkt;
int serial;
} FFAVPacket;
class QFFmpegAudioDecoder : public QThread
{
Q_OBJECT
public:
explicit QFFmpegAudioDecoder(QObject *parent = 0);
~QFFmpegAudioDecoder();
void setCodecCtx(AVCodecContext *mAudioCtx);
void setStream(AVStream *mStream);
void addPacket(AVPacket pkt);
int getQueueLength();
void setClock(QFFmpegClock *clock);
double getAudioTime();
signals:
public slots:
private:
AVCodecContext *mAudioCtx;
QQueue<FFAVPacket> queue;
QMutex mutex;
QSemaphore sema;
SwrContext *swr_ctx;
QOpenALEngine *al;
QTimer *timer;
AVStream *mStream;
double mAudioClock;
double mBufferStartTime;
QQueue<double> mBufferTimes;
QFFmpegClock *mClock;
protected:
void run();
private slots:
void timerUpdate();
void timerStart();
};
#endif // QFFMPEGAUDIODECODER_H