| 6 |
| 7 | #include "AudioInput.h" |
| 8 | #include "../logging.h" |
| 9 |
| 10 | #ifdef HAVE_CONFIG_H |
| 11 | #include "config.h" |
| 12 | #endif |
| 13 |
| 14 | #if defined(TGVOIP_USE_CALLBACK_AUDIO_IO) |
| 15 | // nothing |
| 16 | #elif defined(__ANDROID__) |
| 17 | #include "../os/android/AudioInputAndroid.h" |
| 18 | #elif defined(__APPLE__) |
| 19 | #include <TargetConditionals.h> |
| 20 | #include "../os/darwin/AudioInputAudioUnit.h" |
| 21 | #if TARGET_OS_OSX |
| 22 | #include "../os/darwin/AudioInputAudioUnitOSX.h" |
| 23 | #endif |
| 24 | #elif defined(_WIN32) |
| 25 | #ifdef TGVOIP_WINXP_COMPAT |
| 26 | #include "../os/windows/AudioInputWave.h" |
| 27 | #endif |
| 28 | #include "../os/windows/AudioInputWASAPI.h" |
| 29 | #elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__gnu_hurd__) |
| 30 | #ifndef WITHOUT_ALSA |
| 31 | #include "../os/linux/AudioInputALSA.h" |
| 32 | #endif |
| 33 | #ifndef WITHOUT_PULSE |
| 34 | #include "../os/linux/AudioPulse.h" |
| 35 | #endif |
| 36 | #else |
| 37 | #error "Unsupported operating system" |
| 38 | #endif |
| 39 |
| 40 | using namespace tgvoip; |
| 41 | using namespace tgvoip::audio; |
| 42 |
| 43 | int32_t AudioInput::estimatedDelay=60; |
| 44 |
| 45 | AudioInput::AudioInput() : currentDevice("default"){ |
| 46 | failed=false; |
| 47 | } |
| 48 |
| 49 | AudioInput::AudioInput(std::string deviceID) : currentDevice(deviceID){ |
| 50 | failed=false; |
| 51 | } |
| 52 |
| 53 |
| 54 | AudioInput::~AudioInput(){ |
| 55 |
| 56 | } |
| 57 |
| 58 | bool AudioInput::IsInitialized(){ |
| 59 | return !failed; |
| 60 | } |
| 61 |
| 62 | void AudioInput::EnumerateDevices(std::vector<AudioInputDevice>& devs){ |
| 63 | #if defined(TGVOIP_USE_CALLBACK_AUDIO_IO) |
| 64 | // not supported |
| 65 | #elif defined(__APPLE__) && TARGET_OS_OSX |
| 66 | AudioInputAudioUnitLegacy::EnumerateDevices(devs); |
| 67 | #elif defined(_WIN32) |
| 68 | #ifdef TGVOIP_WINXP_COMPAT |
| 69 | if(LOBYTE(LOWORD(GetVersion()))<6){ |
| 70 | AudioInputWave::EnumerateDevices(devs); |
| 71 | return; |
| 72 | } |
| 73 | #endif |
| 74 | AudioInputWASAPI::EnumerateDevices(devs); |
| 75 | #elif defined(__linux__) && !defined(__ANDROID__) |
| 76 | #if !defined(WITHOUT_PULSE) && !defined(WITHOUT_ALSA) |
| 77 | if(!AudioInputPulse::EnumerateDevices(devs)) |
| 78 | AudioInputALSA::EnumerateDevices(devs); |
| 79 | #elif defined(WITHOUT_PULSE) |
| 80 | AudioInputALSA::EnumerateDevices(devs); |
| 81 | #else |
| 82 | AudioInputPulse::EnumerateDevices(devs) |
| 83 | #endif |
| 84 | #endif |
| 85 | } |
| 86 |
| 87 | std::string AudioInput::GetCurrentDevice(){ |
| 88 | return currentDevice; |
| 89 | } |
| 90 |
| 91 | void AudioInput::SetCurrentDevice(std::string deviceID){ |
| 92 |
| 93 | } |
| 94 |
| 95 | int32_t AudioInput::GetEstimatedDelay(){ |
| 96 | return estimatedDelay; |
| 97 | } |
| 98 |