OPAL  Version 3.18.8
echocancel.h
Go to the documentation of this file.
1 /*
2  * echocancel.h
3  *
4  * Open Phone Abstraction Library (OPAL)
5  * Formally known as the Open H323 project.
6  *
7  * Copyright (c) 2004 Post Increment
8  *
9  * The contents of this file are subject to the Mozilla Public License
10  * Version 1.0 (the "License"); you may not use this file except in
11  * compliance with the License. You may obtain a copy of the License at
12  * http://www.mozilla.org/MPL/
13  *
14  * Software distributed under the License is distributed on an "AS IS"
15  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16  * the License for the specific language governing rights and limitations
17  * under the License.
18  *
19  * The Original Code is Open Phone Abstraction Library.
20  *
21  * The author of this code is Damien Sandras
22  *
23  * Contributor(s): Miguel Rodriguez Perez
24  */
25 
26 #ifndef OPAL_CODEC_ECHOCANCEL_H
27 #define OPAL_CODEC_ECHOCANCEL_H
28 
29 #ifdef P_USE_PRAGMA
30 #pragma interface
31 #endif
32 
33 #include <opal_config.h>
34 
35 #if OPAL_AEC
36 
37 #include <rtp/rtp.h>
38 #include <ptclib/qchannel.h>
39 
40 #ifndef SPEEX_ECHO_H
41 struct SpeexEchoState;
42 #endif
43 
44 #ifndef SPEEX_PREPROCESS_H
45 struct SpeexPreprocessState;
46 #endif
47 
49 class OpalEchoCanceler : public PObject
50 {
51  PCLASSINFO(OpalEchoCanceler, PObject);
52 public:
53  struct Params {
54  Params()
55  : m_enabled(false)
56  , m_duration(2000) // 250ms at 8kHz
57  { }
58 
59  bool m_enabled;
60  unsigned m_duration;
61 
62  };
63 
68  OpalEchoCanceler();
69  ~OpalEchoCanceler();
71 
72 
75  const PNotifier & GetReceiveHandler() const { return receiveHandler; }
76  const PNotifier & GetSendHandler() const {return sendHandler; }
77 
78 
81  void SetParameters(
82  const Params & newParam
83  );
84 
85 
88  void SetClockRate(
89  const int clockRate
90  );
91 
92 protected:
93  PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, ReceivedPacket);
94  PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, SentPacket);
95 
96  PNotifier receiveHandler;
97  PNotifier sendHandler;
98 
99  Params param;
100 
101  double mean;
102  int clockRate;
103  PQueueChannel *echo_chan;
104  PDECLARE_MUTEX(stateMutex);
105  SpeexEchoState *echoState;
106  SpeexPreprocessState *preprocessState;
107 
108  // the following types are all void * to avoid including Speex header files
109  void * ref_buf;
110  void * echo_buf;
111  void * e_buf;
112  void * noise;
113 };
114 
115 
116 #endif // OPAL_AEC
117 
118 #endif // OPAL_CODEC_ECHOCANCEL_H
119 
120 
Definition: rtp.h:540