74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
#ifndef __CAPTUREAUDIO_H__
|
|
#define __CAPTUREAUDIO_H__
|
|
#include "stdint.h"
|
|
#include "../third/portaudio/portaudio.h"
|
|
#include <vector>
|
|
#include <string>
|
|
//Windows
|
|
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 "libavdevice/avdevice.h"
|
|
#include "libavfilter/avfilter.h"
|
|
|
|
|
|
};
|
|
#include <functional>
|
|
#include <dshow.h>
|
|
#include <windows.h>
|
|
#include "qedit.h"
|
|
#include <mutex>
|
|
#include <vector>
|
|
#include <thread>
|
|
#include "guiddef.h"
|
|
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 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__
|