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: 21293 $ 26 * $Author: rjongbloed $ 27 * $Date: 2008-10-12 18:24:41 -0500 (Sun, 12 Oct 2008) $ 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 50 /////////////////////////////////////////////////////////////////////////////// 51 class OpalEchoCanceler : public PObject 52 { 53 PCLASSINFO(OpalEchoCanceler, PObject); 54 public: 55 enum Mode { 56 NoCancelation, 57 Cancelation 58 }; 59 60 struct Params { 61 Params( 62 Mode mode = NoCancelation m_modeParams63 ) : m_mode (mode) 64 { } 65 66 Mode m_mode; 67 }; 68 69 /**@name Construction */ 70 //@{ 71 /**Create a new canceler. 72 */ 73 OpalEchoCanceler(); 74 ~OpalEchoCanceler(); 75 //@} 76 77 78 /**@@name Basic operations */ 79 //@{ GetReceiveHandler()80 const PNotifier & GetReceiveHandler() const { return receiveHandler; } GetSendHandler()81 const PNotifier & GetSendHandler() const {return sendHandler; } 82 83 84 /**Set the silence detector parameters. 85 */ 86 void SetParameters( 87 const Params & newParam ///> New parameters for silence detector 88 ); 89 90 91 /**Set the clock rate for the preprocessor 92 */ 93 void SetClockRate( 94 const int clockRate ///> Clock Rate for the preprocessor 95 ); 96 97 protected: 98 PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, ReceivedPacket); 99 PDECLARE_NOTIFIER(RTP_DataFrame, OpalEchoCanceler, SentPacket); 100 101 PNotifier receiveHandler; 102 PNotifier sendHandler; 103 104 Params param; 105 106 private: 107 108 double mean; 109 int clockRate; 110 PQueueChannel *echo_chan; 111 PMutex stateMutex; 112 SpeexEchoState *echoState; 113 SpeexPreprocessState *preprocessState; 114 115 // the following types are all void * to avoid including Speex header files 116 void * ref_buf; 117 void * echo_buf; 118 void * e_buf; 119 void * noise; 120 }; 121 122 #endif // OPAL_CODEC_ECHOCANCEL_H 123 124 ///////////////////////////////////////////////////////////////////////////// 125