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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LIBTGVOIP_ECHOCANCELLER_H
|
|
|
|
#define LIBTGVOIP_ECHOCANCELLER_H
|
|
|
|
|
|
|
|
#include "threading.h"
|
2018-06-04 21:37:43 +02:00
|
|
|
#include "Buffers.h"
|
2017-02-02 17:24:40 +01:00
|
|
|
#include "BlockingQueue.h"
|
2017-09-07 07:39:33 +02:00
|
|
|
#include "MediaStreamItf.h"
|
2018-11-09 16:44:01 +01:00
|
|
|
#include "utils.h"
|
2017-02-02 17:24:40 +01:00
|
|
|
|
2018-11-21 19:22:31 +01:00
|
|
|
namespace webrtc{
|
|
|
|
class AudioProcessing;
|
|
|
|
class AudioFrame;
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
namespace tgvoip{
|
|
|
|
class EchoCanceller{
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
public:
|
2018-11-09 16:44:01 +01:00
|
|
|
TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller);
|
2017-04-28 13:17:56 +02:00
|
|
|
EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC);
|
|
|
|
virtual ~EchoCanceller();
|
2017-02-02 17:24:40 +01:00
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
|
|
|
void SpeakerOutCallback(unsigned char* data, size_t len);
|
|
|
|
void Enable(bool enabled);
|
2018-11-30 13:39:31 +01:00
|
|
|
void ProcessInput(int16_t* inOut, size_t numSamples, bool& hasVoice);
|
2017-12-27 18:25:47 +01:00
|
|
|
void SetAECStrength(int strength);
|
2018-11-30 13:39:31 +01:00
|
|
|
void SetVoiceDetectionEnabled(bool enabled);
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
private:
|
2017-03-30 16:06:59 +02:00
|
|
|
bool enableAEC;
|
|
|
|
bool enableAGC;
|
|
|
|
bool enableNS;
|
2018-11-30 13:39:31 +01:00
|
|
|
bool enableVAD=false;
|
2018-05-28 01:17:22 +02:00
|
|
|
bool isOn;
|
2017-04-09 18:14:33 +02:00
|
|
|
#ifndef TGVOIP_NO_DSP
|
2018-11-21 19:22:31 +01:00
|
|
|
webrtc::AudioProcessing* apm=NULL;
|
|
|
|
webrtc::AudioFrame* audioFrame=NULL;
|
2018-11-09 16:44:01 +01:00
|
|
|
void RunBufferFarendThread();
|
2017-02-02 17:24:40 +01:00
|
|
|
bool didBufferFarend;
|
2018-05-15 20:23:46 +02:00
|
|
|
Thread* bufferFarendThread;
|
2019-04-15 01:43:10 +02:00
|
|
|
BlockingQueue<Buffer>* farendQueue;
|
|
|
|
BufferPool<960*2, 10> farendBufferPool;
|
2017-02-02 17:24:40 +01:00
|
|
|
bool running;
|
|
|
|
#endif
|
|
|
|
};
|
2017-09-07 07:39:33 +02:00
|
|
|
|
2018-12-30 00:24:55 +01:00
|
|
|
namespace effects{
|
2017-09-07 07:39:33 +02:00
|
|
|
|
2018-12-30 00:24:55 +01:00
|
|
|
class AudioEffect{
|
|
|
|
public:
|
|
|
|
virtual ~AudioEffect()=0;
|
|
|
|
virtual void Process(int16_t* inOut, size_t numSamples)=0;
|
|
|
|
virtual void SetPassThrough(bool passThrough);
|
|
|
|
protected:
|
2018-12-31 02:05:58 +01:00
|
|
|
bool passThrough=false;
|
2018-12-30 00:24:55 +01:00
|
|
|
};
|
2017-09-07 07:39:33 +02:00
|
|
|
|
2018-12-30 00:24:55 +01: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;
|
2017-09-07 07:39:33 +02:00
|
|
|
};
|
2017-02-02 17:24:40 +01:00
|
|
|
|
2018-12-30 00:24:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-02 17:24:40 +01:00
|
|
|
#endif //LIBTGVOIP_ECHOCANCELLER_H
|