/usr/include/sipxtapi/mp/MprSpeexEchoCancel.h is in libsipxtapi-dev 3.3.0~test17-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | //
// Copyright (C) 2004-2006 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2006 ProfitFuel Inc. All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2006 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////
#ifndef _MprSpeexEchoCancel_h_
#define _MprSpeexEchoCancel_h_
// SYSTEM INCLUDES
#include <speex/speex_echo.h>
// APPLICATION INCLUDES
#include "mp/MpAudioResource.h"
#include "mp/MpBufPool.h"
#include "mp/MpResourceMsg.h"
// DEFINES
/// @brief Default filter length (tail length) of AEC filter (in milliseconds).
/// @see documentation on MprSpeexEchoCancel::MprSpeexEchoCancel() for more information.
#ifdef ANDROID
# define SPEEX_DEFAULT_AEC_FILTER_LENGTH 240
#else
# define SPEEX_DEFAULT_AEC_FILTER_LENGTH 200
#endif
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
/// The "Speex Echo Canceler" media processing resource.
/**
* It takes mic data from the first input, speaker data from the mpSpkrQ message
* queue and produce echo canceled audio data on the first output. To increase
* echo cancellation quality you should connect output of the resource directly
* to MprSpeexPreprocess input.
*/
class MprSpeexEchoCancel : public MpAudioResource
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
static const UtlContainableType TYPE; ///< Class name, used for run-time checks.
enum {
#ifdef WIN32
MAX_ECHO_QUEUE=21,
DEFAULT_ECHO_QUEUE_LEN=130
#elif defined(ANDROID)
MAX_ECHO_QUEUE=40,
DEFAULT_ECHO_QUEUE_LEN=300
#else
MAX_ECHO_QUEUE=20,
DEFAULT_ECHO_QUEUE_LEN=90
#endif
};
enum GlobalEnableState {
GLOBAL_ENABLE, ///< All MprSpeexEchoCancel resources are forced to enable
GLOBAL_DISABLE, ///< All MprSpeexEchoCancel resources are forced to disable
LOCAL_MODE ///< Each resource respect its own enable/disable state
};
/* ============================ CREATORS ================================== */
///@name Creators
//@{
/// Constructor
MprSpeexEchoCancel(const UtlString& rName,
OsMsgQ* pSpkrQ=NULL,
int spkrQDelayMs=DEFAULT_ECHO_QUEUE_LEN,
int filterLength=SPEEX_DEFAULT_AEC_FILTER_LENGTH);
/**<
* @param[in] rName - resource name.
* @param[in] pSpkrQ - pointer to a queue with speaker audio data.
* @param[in] spkrQDelayMs - number of milliseconds we should delay
* delay data from speaker queue. Set this value to maximum
* of the delay audio device will *definitely* add while
* playing and recording audio. This value is used to minimize
* delay between far and near end audio in AEC and reduce
* computational cost of AEC.
* @param[in] filterLength - the length (in msec) of the echo cancelling
* filter you want to use (also known as tail length).
* The recommended tail length is approximately the third of
* the room reverberation time. For example,in a small room,
* reverberation time is in the order of 300 ms, so a tail
* length of 100 ms is a good choice.
*/
/// Destructor
virtual
~MprSpeexEchoCancel();
//@}
/* ============================ MANIPULATORS ============================== */
///@name Manipulators
//@{
/// Send message to enable/disable copy queue.
OsStatus setSpkrQ(const UtlString& namedResource,
OsMsgQ& fgQ,
OsMsgQ *pSpkrQ);
/**<
* @param[in] namedResource - the name of the resource to send a message to.
* @param[in] fgQ - the queue of the flowgraph containing the resource which
* the message is to be received by.
* @param[in] pSpkrQ - pointer to a queue with speaker data.
* @returns the result of attempting to queue the message to this resource.
*/
/// Set global enable/disable state.
static inline void setGlobalEnableState(GlobalEnableState state);
/**<
* @see smGlobalEnableState for more details.
*/
/// Get global state.
static inline GlobalEnableState getGlobalEnableState();
/**<
* @see smGlobalEnableState for more details.
*/
//@}
/* ============================ ACCESSORS ================================= */
///@name Accessors
//@{
/// @copydoc UtlContainable::getContainableType()
UtlContainableType getContainableType() const;
/// Return Speex internal echo state structure.
inline SpeexEchoState *getSpeexEchoState() const;
/**<
* Used by MprSpeexPreprocess to access echo state to enable residual
* echo removal.
*/
//@}
/* ============================ INQUIRY =================================== */
///@name Inquiry
//@{
//@}
/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
typedef enum
{
MPRM_SET_SPEAKER_QUEUE = MpResourceMsg::MPRM_EXTERNAL_MESSAGE_START
} AddlResMsgTypes;
SpeexEchoState *mpEchoState; ///< Speex internal AEC state
bool mStartedCanceling; ///< Have we started cancelling?
int mFilterLength; ///< Filter tail length. See constructor docs for details
OsMsgQ *mpSpkrQ; ///< Queue with echo reference data
const int mSpkrQDelayMs; ///< How much should we delay data from mpSpkrQ (in ms)?
int mSpkrQDelayFrames; ///< How much should we delay data from mpSpkrQ (in frames)?
MpAudioBufPtr mpSilenceBuf; ///< Buffer with silence - used when empty message
///< arrives from mpSpkrQ or mic input
static volatile GlobalEnableState smGlobalEnableState;
///< Global enable/disable switch for all Speex AEC resources. We need
///< this switch because sipXmediaAdapterLib exports only a static method
///< to turn AEC on and off.
virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
MpBufPtr outBufs[],
int inBufsSize,
int outBufsSize,
UtlBoolean isEnabled,
int samplesPerFrame,
int samplesPerSecond);
/// @copydoc MpResource::handleMessage()
virtual UtlBoolean handleMessage(MpResourceMsg& rMsg);
/// @brief Associates this resource with the indicated flow graph.
OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
/**<
* We use this overloaded method for initialization of some of our member
* variables, which depend on flowgraph's properties (like frame size).
*
* @retval OS_SUCCESS - for now, this method always returns success
*/
/// Copy constructor (not implemented for this class)
MprSpeexEchoCancel(const MprSpeexEchoCancel& rMprSpeexEchoCancel);
/// Assignment operator (not implemented for this class)
MprSpeexEchoCancel& operator=(const MprSpeexEchoCancel& rhs);
};
/* ============================ INLINE METHODS ============================ */
void MprSpeexEchoCancel::setGlobalEnableState(GlobalEnableState state)
{
smGlobalEnableState = state;
}
MprSpeexEchoCancel::GlobalEnableState MprSpeexEchoCancel::getGlobalEnableState()
{
return(smGlobalEnableState);
}
SpeexEchoState *MprSpeexEchoCancel::getSpeexEchoState() const
{
return mpEchoState;
}
#endif // _MprSpeexEchoCancel_h_
|