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

80 lines
2.0 KiB
C
Raw Normal View History

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"
#include "MediaStreamItf.h"
2017-02-02 17:24:40 +01:00
namespace tgvoip{
class EchoCanceller{
2017-02-02 17:24:40 +01:00
public:
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);
void ProcessInput(unsigned char* data, unsigned char* out, size_t len);
2017-12-27 18:25:47 +01:00
void SetAECStrength(int strength);
2017-02-02 17:24:40 +01:00
private:
2017-03-30 16:06:59 +02:00
bool enableAEC;
bool enableAGC;
bool enableNS;
2018-05-28 01:17:22 +02:00
bool isOn;
#ifndef TGVOIP_NO_DSP
2018-05-15 20:23:46 +02:00
void RunBufferFarendThread(void* arg);
2017-02-02 17:24:40 +01:00
bool didBufferFarend;
2018-05-15 20:23:46 +02:00
Mutex aecMutex;
2017-03-30 16:06:59 +02:00
void* aec;
void* splittingFilter; // webrtc::SplittingFilter
void* splittingFilterIn; // webrtc::IFChannelBuffer
void* splittingFilterOut; // webrtc::IFChannelBuffer
void* splittingFilterFarend; // webrtc::SplittingFilter
void* splittingFilterFarendIn; // webrtc::IFChannelBuffer
void* splittingFilterFarendOut; // webrtc::IFChannelBuffer
2018-05-15 20:23:46 +02:00
Thread* bufferFarendThread;
BlockingQueue<int16_t*>* farendQueue;
BufferPool* farendBufferPool;
2017-02-02 17:24:40 +01:00
bool running;
void* ns; // NsxHandle
2017-03-30 16:06:59 +02:00
void* agc;
int32_t agcMicLevel;
//int32_t outstandingFarendFrames=0;
2017-02-02 17:24:40 +01:00
#endif
};
class AudioEffect{
public:
virtual ~AudioEffect()=0;
virtual void Process(int16_t* inOut, size_t numSamples)=0;
virtual void SetPassThrough(bool passThrough);
protected:
bool passThrough;
};
class AutomaticGainControl : public AudioEffect{
public:
AutomaticGainControl();
virtual ~AutomaticGainControl();
virtual void Process(int16_t* inOut, size_t numSamples);
private:
void* agc;
void* splittingFilter;
void* splittingFilterIn;
void* splittingFilterOut;
int32_t agcMicLevel;
};
};
2017-02-02 17:24:40 +01:00
#endif //LIBTGVOIP_ECHOCANCELLER_H