mirror of
https://github.com/danog/libtgvoip.git
synced 2024-11-30 04:39:03 +01:00
Fixes
This commit is contained in:
parent
ef108581ac
commit
55c2202937
@ -80,6 +80,8 @@ EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC){
|
||||
running=true;
|
||||
|
||||
start_thread(bufferFarendThread, EchoCanceller::StartBufferFarendThread, this);
|
||||
}else{
|
||||
aec=NULL;
|
||||
}
|
||||
|
||||
if(enableNS){
|
||||
@ -92,6 +94,8 @@ EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC){
|
||||
WebRtcNs_Init((NsHandle*)ns, 48000);
|
||||
WebRtcNs_set_policy((NsHandle*)ns, 1);
|
||||
#endif*/
|
||||
}else{
|
||||
ns=NULL;
|
||||
}
|
||||
|
||||
if(enableAGC){
|
||||
@ -103,6 +107,8 @@ EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC){
|
||||
WebRtcAgc_Init(agc, 0, 255, kAgcModeAdaptiveDigital, 48000);
|
||||
WebRtcAgc_set_config(agc, agcConfig);
|
||||
agcMicLevel=0;
|
||||
}else{
|
||||
agc=NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -354,6 +360,17 @@ void EchoCanceller::ProcessInput(unsigned char* data, unsigned char* out, size_t
|
||||
memcpy(samplesOut, bufIn->ibuf_const()->bands(0)[0], 960*2);
|
||||
}
|
||||
|
||||
void EchoCanceller::SetAECStrength(int strength){
|
||||
if(aec){
|
||||
#ifndef TGVOIP_USE_DESKTOP_DSP
|
||||
AecmConfig cfg;
|
||||
cfg.cngMode=AecmFalse;
|
||||
cfg.echoMode=(int16_t) strength;
|
||||
WebRtcAecm_set_config(aec, cfg);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
AudioEffect::~AudioEffect(){
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
void SpeakerOutCallback(unsigned char* data, size_t len);
|
||||
void Enable(bool enabled);
|
||||
void ProcessInput(unsigned char* data, unsigned char* out, size_t len);
|
||||
void SetAECStrength(int strength);
|
||||
|
||||
private:
|
||||
bool enableAEC;
|
||||
|
@ -232,6 +232,7 @@ VoIPController::VoIPController() : activeNetItfName(""),
|
||||
udpSocket=NetworkSocket::Create(PROTO_UDP);
|
||||
realUdpSocket=udpSocket;
|
||||
udpConnectivityState=UDP_UNKNOWN;
|
||||
echoCancellationStrength=1;
|
||||
|
||||
outputAGC=NULL;
|
||||
outputAGCEnabled=false;
|
||||
@ -1147,6 +1148,7 @@ simpleAudioBlock random_id:long random_bytes:string raw_data:string = DecryptedA
|
||||
audioOutput=tgvoip::audio::AudioOutput::Create(currentAudioOutput);
|
||||
audioOutput->Configure(48000, 16, 1);
|
||||
echoCanceller=new EchoCanceller(config.enableAEC, config.enableNS, config.enableAGC);
|
||||
echoCanceller->SetAECStrength(echoCancellationStrength);
|
||||
encoder=new OpusEncoder(audioInput);
|
||||
encoder->SetCallback(AudioInputCallback, this);
|
||||
encoder->SetOutputFrameDuration(outgoingAudioStream->frameDuration);
|
||||
@ -2472,6 +2474,12 @@ void VoIPController::SetAudioOutputGainControlEnabled(bool enabled){
|
||||
outputAGC->SetPassThrough(!enabled);
|
||||
}
|
||||
|
||||
void VoIPController::SetEchoCancellationStrength(int strength){
|
||||
echoCancellationStrength=strength;
|
||||
if(echoCanceller)
|
||||
echoCanceller->SetAECStrength(strength);
|
||||
}
|
||||
|
||||
Endpoint::Endpoint(int64_t id, uint16_t port, IPv4Address& _address, IPv6Address& _v6address, char type, unsigned char peerTag[16]) : address(_address), v6address(_v6address){
|
||||
this->id=id;
|
||||
this->port=port;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "CongestionControl.h"
|
||||
#include "NetworkSocket.h"
|
||||
|
||||
#define LIBTGVOIP_VERSION "1.0.1"
|
||||
#define LIBTGVOIP_VERSION "1.0.3"
|
||||
|
||||
#define STATE_WAIT_INIT 1
|
||||
#define STATE_WAIT_INIT_ACK 2
|
||||
@ -341,6 +341,7 @@ public:
|
||||
* @param enabled I usually pick argument names to be self-explanatory
|
||||
*/
|
||||
void SetAudioOutputGainControlEnabled(bool enabled);
|
||||
void SetEchoCancellationStrength(int strength);
|
||||
|
||||
private:
|
||||
struct PendingOutgoingPacket{
|
||||
@ -464,6 +465,7 @@ private:
|
||||
int udpConnectivityState;
|
||||
double lastUdpPingTime;
|
||||
int udpPingCount;
|
||||
int echoCancellationStrength;
|
||||
|
||||
int proxyProtocol;
|
||||
std::string proxyAddress;
|
||||
|
@ -303,6 +303,10 @@ extern "C" JNIEXPORT void Java_org_telegram_messenger_voip_VoIPController_native
|
||||
((VoIPController*)(intptr_t)inst)->SetAudioOutputGainControlEnabled(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_org_telegram_messenger_voip_VoIPController_nativeSetEchoCancellationStrength(JNIEnv* env, jclass cls, jlong inst, jint strength){
|
||||
((VoIPController*)(intptr_t)inst)->SetEchoCancellationStrength(strength);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint Java_org_telegram_messenger_voip_Resampler_convert44to48(JNIEnv* env, jclass cls, jobject from, jobject to){
|
||||
return tgvoip::audio::Resampler::Convert44To48((int16_t *) env->GetDirectBufferAddress(from), (int16_t *) env->GetDirectBufferAddress(to), (size_t) (env->GetDirectBufferCapacity(from)/2), (size_t) (env->GetDirectBufferCapacity(to)/2));
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ void AudioInputALSA::Stop(){
|
||||
|
||||
void* AudioInputALSA::StartThread(void* arg){
|
||||
((AudioInputALSA*)arg)->RunThread();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AudioInputALSA::RunThread(){
|
||||
|
@ -74,6 +74,7 @@ bool AudioOutputALSA::IsPlaying(){
|
||||
|
||||
void* AudioOutputALSA::StartThread(void* arg){
|
||||
((AudioOutputALSA*)arg)->RunThread();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AudioOutputALSA::RunThread(){
|
||||
|
Loading…
Reference in New Issue
Block a user