multimedia/client/qt_gl_/yuvgl/media/AACAudioCoder.h

53 lines
1.3 KiB
C
Raw Normal View History

2020-06-04 15:28:45 +00:00
#pragma once
#include "AudioCapture.h"
#ifdef __cplusplus
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"
};
#endif
namespace AAC_CODER {
class AACAudioCoder :public CaptureAudio::CaptureAudioObserver {
public:
class EncodeAudioObserver {
public:
virtual void OnAudioEncode(const void *frameaddress, uint32_t framelen,uint16_t pts) {};
};
enum CAP_STATUS {
RUNNING = 1,
STOP = 2,
PAUSE = 3,
READY = 4,
UNREADY = 5,
FAIL = 6,
};
void OnAudioData(const void *frameaddress, uint32_t framelen);
AACAudioCoder(unsigned int smprate, unsigned int channel);
~AACAudioCoder();
int Encode(unsigned char *input, unsigned int num);
int SetObserver(EncodeAudioObserver *);
private:
unsigned int mpts;
CAP_STATUS mStatus;
unsigned long mSampleRate = 44100;
unsigned int mChannels = 2;
unsigned int mPCMBitSize = 16;
uint8_t* mAACBuffer;
unsigned long nMaxOutputBytes;
uintptr_t mFablaAacenc;
AVCodec *mCodec;
AVCodec *pCodec;
AVCodecContext *mCodecCtx = NULL;
AVFrame *mFrame;
AVPacket pkt;
uint8_t* mFrameBuf;
uint16_t mPts;
EncodeAudioObserver *mObserver;
};
}