50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef __CAPTUREAUDIO_H__
|
|
#define __CAPTUREAUDIO_H__
|
|
#include "stdint.h"
|
|
#include "../third/portaudio/portaudio.h"
|
|
#include <vector>
|
|
#include <string>
|
|
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<CaptureAudio::MICInfo> 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__
|