1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-02 09:37:52 +01:00

Simplify everything

This commit is contained in:
Daniil Gentili 2017-07-04 10:30:21 +01:00
parent ef6b8f6279
commit 4c43234455
6 changed files with 26 additions and 38 deletions

1
.gitignore vendored
View File

@ -19,3 +19,4 @@ bld/
# Visual Studio 2015 cache/options directory
.vs/
*.o

View File

@ -1129,9 +1129,9 @@ simpleAudioBlock random_id:long random_bytes:string raw_data:string = DecryptedA
if(!audioInput){
LOGI("before create audio io");
audioInput=tgvoip::audio::AudioInput::Create(this);
audioInput=tgvoip::audio::AudioInput::Create(currentAudioInput);
audioInput->Configure(48000, 16, 1);
audioOutput=tgvoip::audio::AudioOutput::Create(this);
audioOutput=tgvoip::audio::AudioOutput::Create(currentAudioOutput);
audioOutput->Configure(48000, 16, 1);
echoCanceller=new EchoCanceller(config.enableAEC, config.enableNS, config.enableAGC);
encoder=new OpusEncoder(audioInput);

View File

@ -6,11 +6,10 @@
#include "AudioInput.h"
#include "../logging.h"
#include <phpcpp.h>
#ifdef PHP_LIBTGVOIP
#include "../../audio/AudioInputPHP.h"
#else
#ifdef LIBTGVOIP_CUSTOM
#include AUDIOINPUT_HEADER
#elif
#if defined(__ANDROID__)
#include "../os/android/AudioInputAndroid.h"
#elif defined(__APPLE__)
@ -31,7 +30,6 @@
#else
#error "Unsupported operating system"
#endif
#endif
using namespace tgvoip;
using namespace tgvoip::audio;
@ -46,11 +44,10 @@ AudioInput::AudioInput(std::string deviceID) : currentDevice(deviceID){
failed=false;
}
AudioInput *AudioInput::Create(void* controller){
#ifdef PHP_LIBTGVOIP
return new AudioInputPHP(controller);
#else
#if defined(__ANDROID__)
AudioInput *AudioInput::Create(std::string deviceID){
#ifdef LIBTGVOIP_CUSTOM
return new AUDIOINPUT_CLASS(deviceID);
#elif defined(__ANDROID__)
return new AudioInputAndroid();
#elif defined(__APPLE__)
#if TARGET_OS_OSX
@ -75,7 +72,6 @@ AudioInput *AudioInput::Create(void* controller){
}
return new AudioInputALSA(deviceID);
#endif
#endif
}
@ -88,10 +84,9 @@ bool AudioInput::IsInitialized(){
}
void AudioInput::EnumerateDevices(std::vector<AudioInputDevice>& devs){
#ifdef PHP_LIBTGVOIP
return;
#else
#if defined(__APPLE__) && TARGET_OS_OSX
#ifdef LIBTGVOIP_CUSTOM
AUDIOINPUT_CLASS::EnumerateDevices(devs);
#elif defined(__APPLE__) && TARGET_OS_OSX
AudioInputAudioUnit::EnumerateDevices(devs);
#elif defined(_WIN32)
#ifdef TGVOIP_WINXP_COMPAT
@ -105,7 +100,6 @@ void AudioInput::EnumerateDevices(std::vector<AudioInputDevice>& devs){
if(!AudioInputPulse::IsAvailable() || !AudioInputPulse::EnumerateDevices(devs))
AudioInputALSA::EnumerateDevices(devs);
#endif
#endif
}
std::string AudioInput::GetCurrentDevice(){

View File

@ -28,7 +28,7 @@ public:
bool IsInitialized();
virtual std::string GetCurrentDevice();
virtual void SetCurrentDevice(std::string deviceID);
static AudioInput* Create(void* controller);
static AudioInput* Create(std::string deviceID);
static void EnumerateDevices(std::vector<AudioInputDevice>& devs);
static int32_t GetEstimatedDelay();

View File

@ -6,12 +6,10 @@
#include "AudioOutput.h"
#include "../logging.h"
#include <phpcpp.h>
#ifdef PHP_LIBTGVOIP
#include "../../audio/AudioOutputPHP.h"
#else
#if defined(__ANDROID__)
#ifdef LIBTGVOIP_CUSTOM
#include AUDIOOUTPUT_HEADER
#elif defined(__ANDROID__)
#include "../os/android/AudioOutputOpenSLES.h"
#include "../os/android/AudioOutputAndroid.h"
#elif defined(__APPLE__)
@ -32,7 +30,6 @@
#else
#error "Unsupported operating system"
#endif
#endif
using namespace tgvoip;
using namespace tgvoip::audio;
@ -42,11 +39,10 @@ int AudioOutput::systemVersion;
#endif
int32_t AudioOutput::estimatedDelay=60;
AudioOutput *AudioOutput::Create(void* controller){
#ifdef PHP_LIBTGVOIP
return new AudioOutputPHP(controller);
#else
#if defined(__ANDROID__)
AudioOutput *AudioOutput::Create(std::string deviceID){
#ifdef LIBTGVOIP_CUSTOM
return new AUDIOOUTPUT_CLASS(deviceID);
#elif defined(__ANDROID__)
if(systemVersion<21)
return new AudioOutputAndroid();
return new AudioOutputOpenSLES();
@ -73,7 +69,6 @@ AudioOutput *AudioOutput::Create(void* controller){
}
return new AudioOutputALSA(deviceID);
#endif
#endif
}
AudioOutput::AudioOutput() : currentDevice("default"){
@ -102,10 +97,9 @@ float AudioOutput::GetLevel(){
void AudioOutput::EnumerateDevices(std::vector<AudioOutputDevice>& devs){
#ifdef PHP_LIBTGVOIP
return;
#else
#if defined(__APPLE__) && TARGET_OS_OSX
#ifdef LIBTGVOIP_CUSTOM
AUDIOOUTPUT_CLASS::EnumerateDevices(devs);
#elif defined(__APPLE__) && TARGET_OS_OSX
AudioOutputAudioUnit::EnumerateDevices(devs);
#elif defined(_WIN32)
#ifdef TGVOIP_WINXP_COMPAT
@ -119,7 +113,6 @@ void AudioOutput::EnumerateDevices(std::vector<AudioOutputDevice>& devs){
if(!AudioOutputPulse::IsAvailable() || !AudioOutputPulse::EnumerateDevices(devs))
AudioOutputALSA::EnumerateDevices(devs);
#endif
#endif
}

View File

@ -29,10 +29,10 @@ public:
static int32_t GetEstimatedDelay();
virtual std::string GetCurrentDevice();
virtual void SetCurrentDevice(std::string deviceID);
static AudioOutput* Create(void* controller);
static AudioOutput* Create(std::string deviceID);
static void EnumerateDevices(std::vector<AudioOutputDevice>& devs);
bool IsInitialized();
#if defined(__ANDROID__)
static int systemVersion;
#endif