sipxmedialib  Version 3.3
MprSpeexEchoCancel.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2006 ProfitFuel Inc. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // Copyright (C) 2006 SIPez LLC.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 #ifndef _MprSpeexEchoCancel_h_
14 #define _MprSpeexEchoCancel_h_
15 
16 // SYSTEM INCLUDES
17 #include <speex/speex_echo.h>
18 
19 // APPLICATION INCLUDES
20 #include "mp/MpAudioResource.h"
21 #include "mp/MpBufPool.h"
22 #include "mp/MpResourceMsg.h"
23 
24 // DEFINES
25 
28 #ifdef ANDROID
29 # define SPEEX_DEFAULT_AEC_FILTER_LENGTH 240
30 #else
31 # define SPEEX_DEFAULT_AEC_FILTER_LENGTH 200
32 #endif
33 
34 // MACROS
35 // EXTERNAL FUNCTIONS
36 // EXTERNAL VARIABLES
37 // CONSTANTS
38 // STRUCTS
39 // TYPEDEFS
40 // FORWARD DECLARATIONS
41 
43 
50 {
51 /* //////////////////////////// PUBLIC //////////////////////////////////// */
52 public:
53 
54  static const UtlContainableType TYPE;
55 
56  enum {
57 #ifdef WIN32
58  MAX_ECHO_QUEUE=21,
60 #elif defined(ANDROID)
61  MAX_ECHO_QUEUE=40,
63 #else
66 #endif
67  };
68 
73  };
74 
75 /* ============================ CREATORS ================================== */
77 
78 
80  MprSpeexEchoCancel(const UtlString& rName,
81  OsMsgQ* pSpkrQ=NULL,
82  int spkrQDelayMs=DEFAULT_ECHO_QUEUE_LEN,
83  int filterLength=SPEEX_DEFAULT_AEC_FILTER_LENGTH);
101  virtual
104 
106 
107 /* ============================ MANIPULATORS ============================== */
109 
110 
112  OsStatus setSpkrQ(const UtlString& namedResource,
113  OsMsgQ& fgQ,
114  OsMsgQ *pSpkrQ);
123  static inline void setGlobalEnableState(GlobalEnableState state);
129  static inline GlobalEnableState getGlobalEnableState();
136 
137 /* ============================ ACCESSORS ================================= */
139 
140 
142  UtlContainableType getContainableType() const;
143 
145  inline SpeexEchoState *getSpeexEchoState() const;
152 
153 /* ============================ INQUIRY =================================== */
155 
156 
158 
159 /* //////////////////////////// PROTECTED ///////////////////////////////// */
160 protected:
161 
162 /* //////////////////////////// PRIVATE /////////////////////////////////// */
163 private:
164 
165  typedef enum
166  {
168  } AddlResMsgTypes;
169 
170  SpeexEchoState *mpEchoState;
173  OsMsgQ *mpSpkrQ;
174  const int mSpkrQDelayMs;
177 
183 
184  virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
185  MpBufPtr outBufs[],
186  int inBufsSize,
187  int outBufsSize,
188  UtlBoolean isEnabled,
189  int samplesPerFrame,
190  int samplesPerSecond);
191 
193  virtual UtlBoolean handleMessage(MpResourceMsg& rMsg);
194 
196  OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
204  MprSpeexEchoCancel(const MprSpeexEchoCancel& rMprSpeexEchoCancel);
206 
209 
210 };
211 
212 /* ============================ INLINE METHODS ============================ */
213 
215 {
216  smGlobalEnableState = state;
217 }
218 
220 {
221  return(smGlobalEnableState);
222 }
223 
225 {
226  return mpEchoState;
227 }
228 
229 #endif // _MprSpeexEchoCancel_h_
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
All MprSpeexEchoCancel resources are forced to disable.
Definition: MprSpeexEchoCancel.h:71
AddlResMsgTypes
Definition: MprSpeexEchoCancel.h:165
int samplesPerFrame
virtual UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handles an incoming flowgraph message for this media processing object.
Definition: MpResourceMsg.h:56
static volatile GlobalEnableState smGlobalEnableState
Definition: MprSpeexEchoCancel.h:179
#define SPEEX_DEFAULT_AEC_FILTER_LENGTH
Default filter length (tail length) of AEC filter (in milliseconds).
Definition: MprSpeexEchoCancel.h:31
Definition: MprSpeexEchoCancel.h:64
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
int samplesPerSecond
const int mSpkrQDelayMs
How much should we delay data from mpSpkrQ (in ms)?
Definition: MprSpeexEchoCancel.h:174
MprSpeexEchoCancel(const UtlString &rName, OsMsgQ *pSpkrQ=NULL, int spkrQDelayMs=DEFAULT_ECHO_QUEUE_LEN, int filterLength=SPEEX_DEFAULT_AEC_FILTER_LENGTH)
Constructor.
Each resource respect its own enable/disable state.
Definition: MprSpeexEchoCancel.h:72
static GlobalEnableState getGlobalEnableState()
Get global state.
Definition: MprSpeexEchoCancel.h:219
GlobalEnableState
Definition: MprSpeexEchoCancel.h:69
virtual ~MprSpeexEchoCancel()
Destructor.
Smart pointer to MpAudioBuf.
Definition: MpAudioBuf.h:168
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
bool mStartedCanceling
Have we started cancelling?
Definition: MprSpeexEchoCancel.h:171
OsStatus setFlowGraph(MpFlowGraphBase *pFlowGraph)
Associates this resource with the indicated flow graph.
MpAudioBufPtr mpSilenceBuf
Definition: MprSpeexEchoCancel.h:176
SpeexEchoState * getSpeexEchoState() const
Return Speex internal echo state structure.
Definition: MprSpeexEchoCancel.h:224
SpeexEchoState * mpEchoState
Speex internal AEC state.
Definition: MprSpeexEchoCancel.h:170
int mSpkrQDelayFrames
How much should we delay data from mpSpkrQ (in frames)?
Definition: MprSpeexEchoCancel.h:175
virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[], MpBufPtr outBufs[], int inBufsSize, int outBufsSize, UtlBoolean isEnabled, int samplesPerFrame, int samplesPerSecond)
This method does the real work for the media processing resource and must be defined in each class de...
Definition: MprSpeexEchoCancel.h:167
int mFilterLength
Filter tail length. See constructor docs for details.
Definition: MprSpeexEchoCancel.h:172
Smart pointer to MpBuf.
Definition: MpBuf.h:160
Definition: MprSpeexEchoCancel.h:65
OsMsgQ * mpSpkrQ
Queue with echo reference data.
Definition: MprSpeexEchoCancel.h:173
OsStatus setSpkrQ(const UtlString &namedResource, OsMsgQ &fgQ, OsMsgQ *pSpkrQ)
Send message to enable/disable copy queue.
static void setGlobalEnableState(GlobalEnableState state)
Set global enable/disable state.
Definition: MprSpeexEchoCancel.h:214
MprSpeexEchoCancel & operator=(const MprSpeexEchoCancel &rhs)
Assignment operator (not implemented for this class)
The "Speex Echo Canceler" media processing resource.
Definition: MprSpeexEchoCancel.h:49
UtlContainableType getContainableType() const
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
static const UtlContainableType TYPE
Class name, used for run-time checks.
Definition: MprSpeexEchoCancel.h:54
All MprSpeexEchoCancel resources are forced to enable.
Definition: MprSpeexEchoCancel.h:70