OPAL  Version 3.12.9
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  * $Revision: 29230 $
26  * $Author: rjongbloed $
27  * $Date: 2013-03-11 12:20:22 +1100 (Mon, 11 Mar 2013) $
28  */
29 
30 #ifndef OPAL_CODEC_ECHOCANCEL_H
31 #define OPAL_CODEC_ECHOCANCEL_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #include <opal/buildopts.h>
38 
39 #include <rtp/rtp.h>
40 #include <ptclib/qchannel.h>
41 
42 #ifndef SPEEX_ECHO_H
43 struct SpeexEchoState;
44 #endif
45 
46 #ifndef SPEEX_PREPROCESS_H
47 struct SpeexPreprocessState;
48 #endif
49 
51 class OpalEchoCanceler : public PObject
52 {
53  PCLASSINFO(OpalEchoCanceler, PObject);
54 public:
55  struct Params {
57  : m_enabled(false)
58  , m_duration(2000) // 250ms at 8kHz
59  { }
60 
61  bool m_enabled;
62  unsigned m_duration;
63 
64  };
65 
73 
74 
77  const PNotifier & GetReceiveHandler() const { return receiveHandler; }
78  const PNotifier & GetSendHandler() const {return sendHandler; }
79 
80 
83  void SetParameters(
84  const Params & newParam
85  );
86 
87 
90  void SetClockRate(
91  const int clockRate
92  );
93 
94 protected:
97 
98  PNotifier receiveHandler;
99  PNotifier sendHandler;
100 
102 
103  double mean;
105  PQueueChannel *echo_chan;
106  PMutex stateMutex;
107  SpeexEchoState *echoState;
108  SpeexPreprocessState *preprocessState;
109 
110  // the following types are all void * to avoid including Speex header files
111  void * ref_buf;
112  void * echo_buf;
113  void * e_buf;
114  void * noise;
115 };
116 
117 
118 #endif // OPAL_CODEC_ECHOCANCEL_H
119 
120