#ifndef __CAPTUREAUDIO_H__ #define __CAPTUREAUDIO_H__ #include "stdint.h" #include "../third/portaudio/portaudio.h" #include #include using namespace std; typedef int (CbAudio)(const void* input, void* output, unsigned long frameCount, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void * userData); class CaptureAudio { public: class CaptureAudioObserver { public: virtual void OnAudioData(const void *frameaddress, uint32_t framelen) {}; }; typedef struct _T_MicInfo { string name; int index; }MICInfo; enum CAP_STATUS { RUNNING = 1, STOP = 2, PAUSE = 3, FAIL = 4, }; vector EnumSpeakers(); CaptureAudio(uint16_t rate, uint8_t channel); ~CaptureAudio(); int StartCapture(); int InitCapture(int index,uint16_t rate,uint8_t channel); void StopCapture(); int SetObserver(CaptureAudioObserver*); int OnCallBack(const void* input, void* output, unsigned long frameCount); void AddCnt(unsigned int x) {this->mSize += x;}; private: uint16_t mSampleRate; //采样率 uint16_t mChanel; //通道号 PaStream *mInStream; PaStream *mOutStream; unsigned long mSize; CAP_STATUS mStatus; CaptureAudioObserver *observer; }; #endif //__CAPTUREAUDIO_H__