00001 /* 00002 * echocancel.h 00003 * 00004 * Open Phone Abstraction Library (OPAL) 00005 * Formally known as the Open H323 project. 00006 * 00007 * Copyright (c) 2004 Post Increment 00008 * 00009 * The contents of this file are subject to the Mozilla Public License 00010 * Version 1.0 (the "License"); you may not use this file except in 00011 * compliance with the License. You may obtain a copy of the License at 00012 * http://www.mozilla.org/MPL/ 00013 * 00014 * Software distributed under the License is distributed on an "AS IS" 00015 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00016 * the License for the specific language governing rights and limitations 00017 * under the License. 00018 * 00019 * The Original Code is Open Phone Abstraction Library. 00020 * 00021 * The author of this code is Damien Sandras 00022 * 00023 * Contributor(s): Miguel Rodriguez Perez 00024 * 00025 * $Revision: 29230 $ 00026 * $Author: rjongbloed $ 00027 * $Date: 2013-03-10 20:20:22 -0500 (Sun, 10 Mar 2013) $ 00028 */ 00029 00030 #ifndef OPAL_CODEC_ECHOCANCEL_H 00031 #define OPAL_CODEC_ECHOCANCEL_H 00032 00033 #ifdef P_USE_PRAGMA 00034 #pragma interface 00035 #endif 00036 00037 #include <opal/buildopts.h> 00038 00039 #include <rtp/rtp.h> 00040 #include <ptclib/qchannel.h> 00041 00042 #ifndef SPEEX_ECHO_H 00043 struct SpeexEchoState; 00044 #endif 00045 00046 #ifndef SPEEX_PREPROCESS_H 00047 struct SpeexPreprocessState; 00048 #endif 00049 00051 class OpalEchoCanceler : public PObject 00052 { 00053 PCLASSINFO(OpalEchoCanceler, PObject); 00054 public: 00055 struct Params { 00056 Params() 00057 : m_enabled(false) 00058 , m_duration(2000) // 250ms at 8kHz 00059 { } 00060 00061 bool m_enabled; 00062 unsigned m_duration; 00063 00064 }; 00065 00070 OpalEchoCanceler(); 00071 ~OpalEchoCanceler(); 00073 00074 00077 const PNotifier & GetReceiveHandler() const { return receiveHandler; } 00078 const PNotifier & GetSendHandler() const {return sendHandler; } 00079 00080 00083 void SetParameters( 00084 const Params & newParam 00085 ); 00086 00087 00090 void SetClockRate( 00091 const int clockRate 00092 ); 00093 00094 protected: 00095 PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, ReceivedPacket); 00096 PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, SentPacket); 00097 00098 PNotifier receiveHandler; 00099 PNotifier sendHandler; 00100 00101 Params param; 00102 00103 double mean; 00104 int clockRate; 00105 PQueueChannel *echo_chan; 00106 PMutex stateMutex; 00107 SpeexEchoState *echoState; 00108 SpeexPreprocessState *preprocessState; 00109 00110 // the following types are all void * to avoid including Speex header files 00111 void * ref_buf; 00112 void * echo_buf; 00113 void * e_buf; 00114 void * noise; 00115 }; 00116 00117 00118 #endif // OPAL_CODEC_ECHOCANCEL_H 00119 00120