sipxmedialib  Version 3.3
MprToSpkr.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2007 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2007 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 
15 #ifndef _MprToSpkr_h_
16 #define _MprToSpkr_h_
17 
18 #define DETECT_SPKR_OVERFLOW
19 #undef DETECT_SPKR_OVERFLOW
20 // #define DETECT_SPKR_OVERFLOW //MG 10-3-01, trying to understand where the signal clips
21 
22 // SYSTEM INCLUDES
23 
24 // APPLICATION INCLUDES
25 #include "os/OsStatus.h"
26 #include "os/OsNotification.h"
27 #include "os/OsMsgQ.h"
28 //#include "mp/MpMisc.h"
29 #include "mp/MpAudioResource.h"
30 #include "mp/MpFlowGraphMsg.h"
31 #include "mp/MpCodec.h"
32 
33 // DEFINES
34 // MACROS
35 // EXTERNAL FUNCTIONS
36 // EXTERNAL VARIABLES
37 // CONSTANTS
38 // STRUCTS
39 // TYPEDEFS
40 typedef void (*TOSPEAKERHOOK)(const int nLength, short* samples) ;
41 // FORWARD DECLARATIONS
42 
47 class MprToSpkr : public MpAudioResource
48 {
49 /* //////////////////////////// PUBLIC //////////////////////////////////// */
50 public:
52  enum{MIN_SPKR_DtoA=-32767};
53  enum{MAX_SPKR_DtoA= 32767};
54 
55 /* ============================ CREATORS ================================== */
57 
58 
60  MprToSpkr(const UtlString& rName, OsMsgQ *pSpkQ, OsMsgQ *pEchoQ);
61 
63  virtual
64  ~MprToSpkr();
65 
66  // I had to increase this on Win/NT because of the bursty nature of
67  // the completion callbacks: the waveOut operations send completion
68  // acknowledgements in bursts covering 60 to 100 msecs at once. At
69  // 10 msec per buffer, this resulted in frequent starvation.
70  enum { MAX_SPKR_BUFFERS = 12 };
71  enum { MIN_SPKR_BUFFERS = 1 };
72  enum { SKIP_SPKR_BUFFERS = 1 };
73 
74 #ifdef REIMPLEMENT_CLARISIS_EQ /* [ */
75  enum {EqFilterLen_ix = 24};
76 
77  static int smClarisisHandsetSpeakerEq[EqFilterLen_ix];
78  int* mpEqSave_ix;
79  int mLastSpkr_ix;
80  int* mpCurEq_ix;
81 
82  void SpeakerEqualization_ix(MpAudioSample* samples, int iLength);
83 #endif /* REIMPLEMENT_CLARISIS_EQ ] */
84 
85  typedef enum {
88  } AttenValues;
89 
91 
92 /* ============================ MANIPULATORS ============================== */
94 
95 
97 
98 #ifdef DETECT_SPKR_OVERFLOW /* [ */
99  static int spkrStats();
100 #endif /* DETECT_SPKR_OVERFLOW ] */
101 
102 /* ============================ ACCESSORS ================================= */
104 
105 
107 
108 /* ============================ INQUIRY =================================== */
110 
111 
113 
114 /* //////////////////////////// PROTECTED ///////////////////////////////// */
115 protected:
116 
117 /* //////////////////////////// PRIVATE /////////////////////////////////// */
118 private:
119  typedef enum
120  {
122  } AddlMsgTypes;
123 
124  enum{EqFilterLen = 24};
125 
126 
127  OsMsgQ* mpSpkQ;
128  OsMsgQ* mpEchoQ;
129 
132  static int slInitVol;
133  static int slVolStep;
134  uint32_t mulNoiseLevel;
135 
136  enum{MAX_SUPPRESSION = 7};
139 
140 #ifdef DETECT_SPKR_OVERFLOW // [
141 
142  static int smStatsReports;
143 
144  int mOverflowsIn;
145  int mUnderflowsIn;
146  int mOverflowsOut;
147  int mUnderflowsOut;
148  int mTotalSamples;
149  int mMaxIn;
150  int mMinIn;
151  int mMaxOut;
152  int mMinOut;
153  int mReport;
154 
155  void stats(void);
156 
157 #endif // DETECT_SPKR_OVERFLOW ]
158 
159  virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
160  MpBufPtr outBufs[],
161  int inBufsSize,
162  int outBufsSize,
163  UtlBoolean isEnabled,
164  int samplesPerFrame=80,
165  int samplesPerSecond=8000);
166 
167  void initVolTable(void);
168 
170  MprToSpkr(const MprToSpkr& rMprToSpkr);
171 
173  MprToSpkr& operator=(const MprToSpkr& rhs);
174 
175 public:
177 
178 };
179 
180 /* ============================ INLINE METHODS ============================ */
181 
182 #endif // _MprToSpkr_h_
Definition: MprToSpkr.h:136
Definition: MprToSpkr.h:124
Definition: MprToSpkr.h:72
void(* TOSPEAKERHOOK)(const int nLength, short *samples)
Definition: MprToSpkr.h:40
The "To Speaker" media processing resource.
Definition: MprToSpkr.h:47
static TOSPEAKERHOOK s_fnToSpeakerHook
Definition: MprToSpkr.h:176
int samplesPerFrame
virtual ~MprToSpkr()
Destructor.
Definition: MprToSpkr.cpp:145
Definition: MprToSpkr.h:121
Definition: MprToSpkr.h:51
AttenValues
Definition: MprToSpkr.h:85
int mlpVolTable[VOLUME_CONTROL_TABLE_SIZE]
volume levels + a mute level
Definition: MprToSpkr.h:137
uint32_t mulNoiseLevel
Used in comfort noise generation.
Definition: MprToSpkr.h:134
Definition: MprToSpkr.h:53
int samplesPerSecond
void initVolTable(void)
Definition: MprToSpkr.cpp:193
MprToSpkr & operator=(const MprToSpkr &rhs)
Assignment operator (not implemented for this class)
MprToSpkr(const UtlString &rName, OsMsgQ *pSpkQ, OsMsgQ *pEchoQ)
Constructor.
Definition: MprToSpkr.cpp:93
int16_t MpAudioSample
Definition: MpTypes.h:44
OsMsgQ * mpSpkQ
Audio data will be sent to this queue.
Definition: MprToSpkr.h:127
0 dB, no attenuation
Definition: MprToSpkr.h:86
Definition: MprToSpkr.h:71
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
Please do not make this lower than -48.
Definition: MprToSpkr.h:87
Definition: MprToSpkr.h:70
static int slVolStep
Definition: MprToSpkr.h:133
virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[], MpBufPtr outBufs[], int inBufsSize, int outBufsSize, UtlBoolean isEnabled, int samplesPerFrame=80, int samplesPerSecond=8000)
This method does the real work for the media processing resource and must be defined in each class de...
Definition: MprToSpkr.cpp:259
Smart pointer to MpBuf.
Definition: MpBuf.h:160
Definition: MprToSpkr.h:52
static int slInitVol
Definition: MprToSpkr.h:132
OsMsgQ * mpEchoQ
Definition: MprToSpkr.h:128
AddlMsgTypes
Definition: MprToSpkr.h:119
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
start of resource-specific messages
Definition: MpFlowGraphMsg.h:67