00001 /* 00002 * paec.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 * rewritten amd made generic ptlib by Simon Horne 00024 * 00025 * Contributor(s): Miguel Rodriguez Perez 00026 * 00027 * $Log: paec.h,v $ 00028 * Revision 1.5 2007/03/15 21:35:21 shorne 00029 * fix for buffer underrun 00030 * 00031 * Revision 1.4 2007/03/06 00:22:48 shorne 00032 * Changed to a buffering type arrangement 00033 * 00034 * Revision 1.3 2007/02/18 18:39:21 shorne 00035 * Added PWaitAndSignal 00036 * 00037 * Revision 1.2 2006/02/26 09:27:49 shorne 00038 * Renamed AEC class name, moved to seperate library 00039 * 00040 * Revision 1.1 2006/01/26 08:05:03 shorne 00041 * Added AEC support 00042 * 00043 */ 00044 00045 #ifndef __OPAL_ECHOCANCEL_H 00046 #define __OPAL_ECHOCANCEL_H 00047 00048 #ifdef P_USE_PRAGMA 00049 #pragma interface 00050 #endif 00051 00052 #include <ptclib/qchannel.h> 00053 00061 PQUEUE(ReceiveTimeQueue, PTimeInterval); 00062 00063 struct SpeexEchoState; 00064 struct SpeexPreprocessState; 00065 class PAec : public PObject 00066 { 00067 PCLASSINFO(PAec, PObject); 00068 public: 00069 00074 PAec(int _clock = 8000, int _sampletime = 30); 00075 ~PAec(); 00077 00082 void Send(BYTE * buffer, unsigned & length); 00083 00086 void Receive(BYTE * buffer, unsigned & length); 00088 00089 protected: 00090 PMutex readwritemute; 00091 PQueueChannel *echo_chan; 00092 SpeexEchoState *echoState; 00093 SpeexPreprocessState *preprocessState; 00094 int clockrate; // Frame Rate default 8000hz for narrowband audio 00095 int bufferTime; // Time between receiving and Transmitting 00096 PInt64 minbuffer; // minbuffer (in milliseconds) 00097 PInt64 maxbuffer; // maxbuffer (in milliseconds) 00098 int sampleTime; // Length of each sample 00099 ReceiveTimeQueue rectime; // Queue of timestamps for ensure read/write in sync 00100 PTimeInterval lastTimeStamp; // LastTimeStamp of recieved data 00101 BOOL receiveReady; 00102 void *ref_buf; 00103 void *echo_buf; 00104 void *e_buf; 00105 void *noise; 00106 00107 }; 00108 00109 #endif // __OPAL_ECHOCANCEL_H 00110