qt_rtmp_demo/media/AACDecoder.h

49 lines
1.1 KiB
C
Raw Normal View History

2023-11-12 16:13:24 +00:00
#pragma once
#include "RtmpPuller2.h"
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libswresample\swresample.h"
};
class AACDecoder :public RtmpPuller2::RtmpPullObserver {
public:
enum DECODE_STATUS {
RUNNING = 1,
STOP = 2,
PAUSE = 3,
FAIL = 4,
NOSOURCE = 6,
};
class AACDecoderObserver {
public:
virtual int OnAudioDecode(uint8_t *dat, uint16_t size) { return 0; };
};
void OnRtmpFrame(void * dat, uint32_t size);
AACDecoder();
AACDecoder(AVStream *p);
int Decode(uint8_t *dat,uint16_t);
int SetObserver(AACDecoderObserver *);
private:
AVFormatContext *mFormatCtx = nullptr;
AVCodecContext *mCodecCtx = nullptr;
AVCodec *mCodec = nullptr;
AVPacket *mPacket = nullptr;
uint16_t mSampleCnt;
enum AVSampleFormat mSampleFmt;
uint16_t mSampleRate;
uint16_t mChannel;
uint64_t mChannelLayout;
AVFrame *mPcmDat;
uint8_t *mU16Data;
AACDecoderObserver *mObserver;
DECODE_STATUS mStatus;
SwrContext * mSwrCtx;
};