1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-04 10:37:49 +01:00
libtgvoip/audio/AudioIO.h
Grishka 5380aaba0d 2.2
- Refactored audio I/O to allow sharing a common context between input and output, for those OSes that require this
- Rewritten periodic operation handling to use a "run loop" thingy instead of an ugly loop formerly known as tick thread
- Fixed a bunch of compiler warnings (closes #13)
- Added automake so you no longer need to use the GYP file for standalone builds (closes #43)
2018-07-17 19:48:21 +03:00

63 lines
1.2 KiB
C++

//
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#ifndef LIBTGVOIP_AUDIOIO_H
#define LIBTGVOIP_AUDIOIO_H
#include "AudioInput.h"
#include "AudioOutput.h"
#include <memory>
#include <string>
namespace tgvoip{
namespace audio {
class AudioIO{
public:
virtual ~AudioIO(){};
static std::shared_ptr<AudioIO> Create();
virtual AudioInput* GetInput()=0;
virtual AudioOutput* GetOutput()=0;
bool Failed();
std::string GetErrorDescription();
protected:
bool failed=false;
std::string error;
};
template<class I, class O> class ContextlessAudioIO : public AudioIO{
public:
ContextlessAudioIO(){
input=new I();
output=new O();
}
ContextlessAudioIO(std::string inputDeviceID, std::string outputDeviceID){
input=new I(inputDeviceID);
output=new O(outputDeviceID);
}
virtual ~ContextlessAudioIO(){
delete input;
delete output;
}
virtual AudioInput* GetInput(){
return input;
}
virtual AudioOutput* GetOutput(){
return output;
}
private:
I* input;
O* output;
};
}
}
#endif //LIBTGVOIP_AUDIOIO_H