2018-07-17 18:48:21 +02:00
|
|
|
//
|
|
|
|
// 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"
|
2020-01-22 12:43:51 +01:00
|
|
|
#include "../tools/utils.h"
|
2018-07-17 18:48:21 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2020-01-22 12:43:51 +01:00
|
|
|
namespace tgvoip
|
|
|
|
{
|
|
|
|
namespace audio
|
|
|
|
{
|
|
|
|
class AudioIO
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AudioIO(){};
|
|
|
|
virtual ~AudioIO(){};
|
|
|
|
TGVOIP_DISALLOW_COPY_AND_ASSIGN(AudioIO);
|
2020-01-24 20:26:34 +01:00
|
|
|
static std::unique_ptr<AudioIO> Create(std::string inputDevice, std::string outputDevice);
|
|
|
|
virtual std::shared_ptr<AudioInput> GetInput() = 0;
|
|
|
|
virtual std::shared_ptr<AudioOutput> GetOutput() = 0;
|
2020-01-22 12:43:51 +01:00
|
|
|
bool Failed();
|
|
|
|
std::string GetErrorDescription();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool failed = false;
|
|
|
|
std::string error;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class I, class O>
|
|
|
|
class ContextlessAudioIO : public AudioIO
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContextlessAudioIO()
|
|
|
|
{
|
2020-01-24 20:26:34 +01:00
|
|
|
input = std::make_shared<I>();
|
|
|
|
output = std::make_shared<O>();
|
2020-01-22 12:43:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ContextlessAudioIO(std::string inputDeviceID, std::string outputDeviceID)
|
|
|
|
{
|
2020-01-24 20:26:34 +01:00
|
|
|
input = std::make_shared<I>(inputDeviceID);
|
|
|
|
output = std::make_shared<O>(outputDeviceID);
|
2020-01-22 12:43:51 +01:00
|
|
|
}
|
2018-07-17 18:48:21 +02:00
|
|
|
|
2020-01-24 20:26:34 +01:00
|
|
|
virtual std::shared_ptr<AudioInput> GetInput()
|
2020-01-22 12:43:51 +01:00
|
|
|
{
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:26:34 +01:00
|
|
|
virtual std::shared_ptr<AudioOutput> *GetOutput()
|
2020-01-22 12:43:51 +01:00
|
|
|
{
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-01-24 20:26:34 +01:00
|
|
|
std::shared_ptr<I> input;
|
|
|
|
std::shared_ptr<O> output;
|
2020-01-22 12:43:51 +01:00
|
|
|
};
|
|
|
|
} // namespace audio
|
|
|
|
} // namespace tgvoip
|
2018-07-17 18:48:21 +02:00
|
|
|
|
|
|
|
#endif //LIBTGVOIP_AUDIOIO_H
|