File: EchoCanceller.h

package info (click to toggle)
libtgvoip 2.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 9,004 kB
  • sloc: cpp: 61,331; ansic: 24,725; sh: 4,150; makefile: 749; asm: 242
file content (83 lines) | stat: -rwxr-xr-x 1,829 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// 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"
#include "utils.h"

namespace webrtc{
	class AudioProcessing;
	class AudioFrame;
}

namespace tgvoip{
class EchoCanceller{

public:
	TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller);
	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);
	void ProcessInput(int16_t* inOut, size_t numSamples, bool& hasVoice);
	void SetAECStrength(int strength);
	void SetVoiceDetectionEnabled(bool enabled);

private:
	bool enableAEC;
	bool enableAGC;
	bool enableNS;
	bool enableVAD=false;
	bool isOn;
#ifndef TGVOIP_NO_DSP
	webrtc::AudioProcessing* apm=NULL;
	webrtc::AudioFrame* audioFrame=NULL;
	void RunBufferFarendThread();
	bool didBufferFarend;
	Thread* bufferFarendThread;
	BlockingQueue<int16_t*>* farendQueue;
	BufferPool* farendBufferPool;
	bool running;
#endif
};

namespace effects{

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;
};

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;
};

}
}

#endif //LIBTGVOIP_ECHOCANCELLER_H