2017-02-02 17:24:40 +01: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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "AudioInput.h"
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
#include "../os/android/AudioInputAndroid.h"
|
|
|
|
#elif defined(__APPLE__)
|
2017-04-09 18:14:33 +02:00
|
|
|
#include <TargetConditionals.h>
|
|
|
|
#if TARGET_OS_IPHONE
|
2017-02-02 17:24:40 +01:00
|
|
|
#include "../os/darwin/AudioInputAudioUnit.h"
|
2017-04-09 18:14:33 +02:00
|
|
|
#else
|
|
|
|
#include "../os/darwin/AudioInputAudioUnitOSX.h"
|
|
|
|
#endif
|
2017-04-17 20:57:07 +02:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
#include "../os/windows/AudioInputWave.h"
|
|
|
|
#elif defined(__linux__)
|
|
|
|
#include "../os/linux/AudioInputALSA.h"
|
2017-02-02 17:24:40 +01:00
|
|
|
#else
|
|
|
|
#error "Unsupported operating system"
|
|
|
|
#endif
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
using namespace tgvoip;
|
|
|
|
using namespace tgvoip::audio;
|
|
|
|
|
|
|
|
AudioInput::AudioInput() : currentDevice("default"){
|
|
|
|
failed=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioInput::AudioInput(std::string deviceID) : currentDevice(deviceID){
|
2017-03-30 16:06:59 +02:00
|
|
|
failed=false;
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
AudioInput *AudioInput::Create(std::string deviceID){
|
2017-02-02 17:24:40 +01:00
|
|
|
#if defined(__ANDROID__)
|
2017-04-28 13:17:56 +02:00
|
|
|
return new AudioInputAndroid();
|
2017-02-02 17:24:40 +01:00
|
|
|
#elif defined(__APPLE__)
|
2017-04-28 13:17:56 +02:00
|
|
|
#if TARGET_OS_OSX
|
|
|
|
return new AudioInputAudioUnit(deviceID);
|
|
|
|
#else
|
|
|
|
return new AudioInputAudioUnit();
|
|
|
|
#endif
|
2017-04-17 20:57:07 +02:00
|
|
|
#elif defined(_WIN32)
|
2017-04-28 13:17:56 +02:00
|
|
|
return new AudioInputWave(deviceID);
|
2017-04-17 20:57:07 +02:00
|
|
|
#elif defined(__linux__)
|
2017-04-28 13:17:56 +02:00
|
|
|
return new AudioInputALSA();
|
2017-02-02 17:24:40 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
AudioInput::~AudioInput(){
|
2017-04-09 18:14:33 +02:00
|
|
|
|
2017-02-02 17:24:40 +01:00
|
|
|
}
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
bool AudioInput::IsInitialized(){
|
2017-03-30 16:06:59 +02:00
|
|
|
return !failed;
|
|
|
|
}
|
2017-04-28 13:17:56 +02:00
|
|
|
|
|
|
|
void AudioInput::EnumerateDevices(std::vector<AudioInputDevice>& devs){
|
|
|
|
#if defined(__APPLE__) && TARGET_OS_OSX
|
|
|
|
AudioInputAudioUnit::EnumerateDevices(devs);
|
|
|
|
#elif defined(_WIN32)
|
|
|
|
AudioInputWave::EnumerateDevices(devs);
|
|
|
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
|
|
|
return new AudioInputALSA();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string AudioInput::GetCurrentDevice(){
|
|
|
|
return currentDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInput::SetCurrentDevice(std::string deviceID){
|
|
|
|
|
|
|
|
}
|