| 6 |
| 7 | #ifndef LIBTGVOIP_ECHOCANCELLER_H |
| 8 | #define LIBTGVOIP_ECHOCANCELLER_H |
| 9 |
| 10 | #include "threading.h" |
| 11 | #include "Buffers.h" |
| 12 | #include "BlockingQueue.h" |
| 13 | #include "MediaStreamItf.h" |
| 14 | #include "utils.h" |
| 15 |
| 16 | namespace webrtc{ |
| 17 | class AudioProcessing; |
| 18 | class AudioFrame; |
| 19 | } |
| 20 |
| 21 | namespace tgvoip{ |
| 22 | class EchoCanceller{ |
| 23 |
| 24 | public: |
| 25 | TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller); |
| 26 | EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC); |
| 27 | virtual ~EchoCanceller(); |
| 28 | virtual void Start(); |
| 29 | virtual void Stop(); |
| 30 | void SpeakerOutCallback(unsigned char* data, size_t len); |
| 31 | void Enable(bool enabled); |
| 32 | void ProcessInput(int16_t* inOut, size_t numSamples, bool& hasVoice); |
| 33 | void SetAECStrength(int strength); |
| 34 | void SetVoiceDetectionEnabled(bool enabled); |
| 35 |
| 36 | private: |
| 37 | bool enableAEC; |
| 38 | bool enableAGC; |
| 39 | bool enableNS; |
| 40 | bool enableVAD=false; |
| 41 | bool isOn; |
| 42 | #ifndef TGVOIP_NO_DSP |
| 43 | webrtc::AudioProcessing* apm=NULL; |
| 44 | webrtc::AudioFrame* audioFrame=NULL; |
| 45 | void RunBufferFarendThread(); |
| 46 | bool didBufferFarend; |
| 47 | Thread* bufferFarendThread; |
| 48 | BlockingQueue<int16_t*>* farendQueue; |
| 49 | BufferPool* farendBufferPool; |
| 50 | bool running; |
| 51 | #endif |
| 52 | }; |
| 53 |
| 54 | namespace effects{ |
| 55 |
| 56 | class AudioEffect{ |
| 57 | public: |
| 58 | virtual ~AudioEffect()=0; |
| 59 | virtual void Process(int16_t* inOut, size_t numSamples)=0; |
| 60 | virtual void SetPassThrough(bool passThrough); |
| 61 | protected: |
| 62 | bool passThrough=false; |
| 63 | }; |
| 64 |
| 65 | class Volume : public AudioEffect{ |
| 66 | public: |
| 67 | Volume(); |
| 68 | virtual ~Volume(); |
| 69 | virtual void Process(int16_t* inOut, size_t numSamples); |
| 70 | /** |
| 71 | * Level is (0.0, 2.0] |
| 72 | */ |
| 73 | void SetLevel(float level); |
| 74 | float GetLevel(); |
| 75 | private: |
| 76 | float level=1.0f; |
| 77 | float multiplier=1.0f; |
| 78 | }; |
| 79 |
| 80 | } |
| 81 | } |
| 82 |
| 83 | #endif //LIBTGVOIP_ECHOCANCELLER_H |
| 84 |