2020-06-04 15:28:45 +00:00
|
|
|
|
#ifndef __CAPTUREAUDIO_H__
|
|
|
|
|
#define __CAPTUREAUDIO_H__
|
|
|
|
|
#include "stdint.h"
|
|
|
|
|
#include "../third/portaudio/portaudio.h"
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
2020-06-19 09:30:29 +00:00
|
|
|
|
//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"
|
2020-06-21 17:13:44 +00:00
|
|
|
|
#include "libavfilter/avfilter.h"
|
|
|
|
|
|
2020-06-19 09:30:29 +00:00
|
|
|
|
|
|
|
|
|
};
|
2020-06-19 17:10:03 +00:00
|
|
|
|
#include <functional>
|
|
|
|
|
#include <dshow.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include "qedit.h"
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <vector>
|
2020-06-21 17:13:44 +00:00
|
|
|
|
#include <thread>
|
2020-06-19 17:10:03 +00:00
|
|
|
|
#include "guiddef.h"
|
2020-06-04 15:28:45 +00:00
|
|
|
|
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) {};
|
|
|
|
|
};
|
2020-06-19 17:10:03 +00:00
|
|
|
|
typedef struct MICInfo
|
2020-06-04 15:28:45 +00:00
|
|
|
|
{
|
|
|
|
|
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; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
uint16_t mChanel; //ͨ<><CDA8><EFBFBD><EFBFBD>
|
|
|
|
|
PaStream *mInStream;
|
|
|
|
|
PaStream *mOutStream;
|
|
|
|
|
unsigned long mSize;
|
|
|
|
|
CAP_STATUS mStatus;
|
|
|
|
|
CaptureAudioObserver *observer;
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-19 09:30:29 +00:00
|
|
|
|
|
|
|
|
|
|
2020-06-04 15:28:45 +00:00
|
|
|
|
#endif //__CAPTUREAUDIO_H__
|