2018-10-03 14:34:43 +00: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_ECHOCANCELLER_H
|
|
|
|
#define LIBTGVOIP_ECHOCANCELLER_H
|
|
|
|
|
|
|
|
#include "threading.h"
|
|
|
|
#include "Buffers.h"
|
|
|
|
#include "BlockingQueue.h"
|
|
|
|
#include "MediaStreamItf.h"
|
2019-02-06 18:22:38 +00:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
namespace webrtc{
|
|
|
|
class AudioProcessing;
|
|
|
|
class AudioFrame;
|
|
|
|
}
|
2018-10-03 14:34:43 +00:00
|
|
|
|
|
|
|
namespace tgvoip{
|
|
|
|
class EchoCanceller{
|
|
|
|
|
|
|
|
public:
|
2019-02-06 18:22:38 +00:00
|
|
|
TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller);
|
2018-10-03 14:34:43 +00:00
|
|
|
EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC);
|
|
|
|
virtual ~EchoCanceller();
|
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
|
|
|
void SpeakerOutCallback(unsigned char* data, size_t len);
|
|
|
|
void Enable(bool enabled);
|
2019-02-06 18:22:38 +00:00
|
|
|
void ProcessInput(int16_t* inOut, size_t numSamples, bool& hasVoice);
|
2018-10-03 14:34:43 +00:00
|
|
|
void SetAECStrength(int strength);
|
2019-02-06 18:22:38 +00:00
|
|
|
void SetVoiceDetectionEnabled(bool enabled);
|
2018-10-03 14:34:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool enableAEC;
|
|
|
|
bool enableAGC;
|
|
|
|
bool enableNS;
|
2019-02-06 18:22:38 +00:00
|
|
|
bool enableVAD=false;
|
2018-10-03 14:34:43 +00:00
|
|
|
bool isOn;
|
|
|
|
#ifndef TGVOIP_NO_DSP
|
2019-02-06 18:22:38 +00:00
|
|
|
webrtc::AudioProcessing* apm=NULL;
|
|
|
|
webrtc::AudioFrame* audioFrame=NULL;
|
|
|
|
void RunBufferFarendThread();
|
2018-10-03 14:34:43 +00:00
|
|
|
bool didBufferFarend;
|
|
|
|
Thread* bufferFarendThread;
|
|
|
|
BlockingQueue<int16_t*>* farendQueue;
|
|
|
|
BufferPool* farendBufferPool;
|
|
|
|
bool running;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2019-02-06 18:22:38 +00:00
|
|
|
namespace effects{
|
2018-10-03 14:34:43 +00:00
|
|
|
|
2019-02-06 18:22:38 +00:00
|
|
|
class AudioEffect{
|
|
|
|
public:
|
|
|
|
virtual ~AudioEffect()=0;
|
|
|
|
virtual void Process(int16_t* inOut, size_t numSamples)=0;
|
|
|
|
virtual void SetPassThrough(bool passThrough);
|
|
|
|
protected:
|
|
|
|
bool passThrough=false;
|
|
|
|
};
|
2018-10-03 14:34:43 +00:00
|
|
|
|
2019-02-06 18:22:38 +00:00
|
|
|
class Volume : public AudioEffect{
|
|
|
|
public:
|
|
|
|
Volume();
|
|
|
|
virtual ~Volume();
|
|
|
|
virtual void Process(int16_t* inOut, size_t numSamples);
|
|
|
|
/**
|
|
|
|
* Level is (0.0, 2.0]
|
|
|
|
*/
|
|
|
|
void SetLevel(float level);
|
|
|
|
float GetLevel();
|
|
|
|
private:
|
|
|
|
float level=1.0f;
|
|
|
|
float multiplier=1.0f;
|
2018-10-03 14:34:43 +00:00
|
|
|
};
|
|
|
|
|
2019-02-06 18:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 14:34:43 +00:00
|
|
|
#endif //LIBTGVOIP_ECHOCANCELLER_H
|