OPAL  Version 3.14.3
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: 29536 $
26  * $Author: rjongbloed $
27  * $Date: 2013-04-19 18:55:15 +1000 (Fri, 19 Apr 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_config.h>
38 
39 #if OPAL_AEC
40 
41 #include <rtp/rtp.h>
42 #include <ptclib/qchannel.h>
43 
44 #ifndef SPEEX_ECHO_H
45 struct SpeexEchoState;
46 #endif
47 
48 #ifndef SPEEX_PREPROCESS_H
49 struct SpeexPreprocessState;
50 #endif
51 
53 class OpalEchoCanceler : public PObject
54 {
55  PCLASSINFO(OpalEchoCanceler, PObject);
56 public:
57  struct Params {
58  Params()
59  : m_enabled(false)
60  , m_duration(2000) // 250ms at 8kHz
61  { }
62 
63  bool m_enabled;
64  unsigned m_duration;
65 
66  };
67 
72  OpalEchoCanceler();
73  ~OpalEchoCanceler();
75 
76 
79  const PNotifier & GetReceiveHandler() const { return receiveHandler; }
80  const PNotifier & GetSendHandler() const {return sendHandler; }
81 
82 
85  void SetParameters(
86  const Params & newParam
87  );
88 
89 
92  void SetClockRate(
93  const int clockRate
94  );
95 
96 protected:
97  PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, ReceivedPacket);
98  PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, SentPacket);
99 
100  PNotifier receiveHandler;
101  PNotifier sendHandler;
102 
103  Params param;
104 
105  double mean;
106  int clockRate;
107  PQueueChannel *echo_chan;
108  PMutex stateMutex;
109  SpeexEchoState *echoState;
110  SpeexPreprocessState *preprocessState;
111 
112  // the following types are all void * to avoid including Speex header files
113  void * ref_buf;
114  void * echo_buf;
115  void * e_buf;
116  void * noise;
117 };
118 
119 
120 #endif // OPAL_AEC
121 
122 #endif // OPAL_CODEC_ECHOCANCEL_H
123 
124