sipxmedialib  Version 3.3
MprBridge.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2012 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2008 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 #ifndef _MprBridge_h_
15 #define _MprBridge_h_
16 
17 // SYSTEM INCLUDES
18 // APPLICATION INCLUDES
19 #include <mp/MpAudioResource.h>
20 #include <mp/MpFlowGraphMsg.h>
21 #include <mp/MpDspUtils.h>
22 #include <mp/MpBridgeAlgBase.h>
23 #include <os/OsIntTypes.h>
24 
25 // DEFINES
26 #define TEST_PRINT_CONTRIBUTORS
27 #undef TEST_PRINT_CONTRIBUTORS
28 
29 //#define PRINT_CLIPPING_STATS
30 #define PRINT_CLIPPING_FREQUENCY 100
31 
32 // EXTERNAL FUNCTIONS
33 // EXTERNAL VARIABLES
34 // CONSTANTS
35 // STRUCTS
36 // TYPEDEFS
37 // MACROS
38 // FORWARD DECLARATIONS
39 #ifdef TEST_PRINT_CONTRIBUTORS // [
40 class MpContributorVector;
41 #endif // TEST_PRINT_CONTRIBUTORS ]
42 
57 class MprBridge : public MpAudioResource
58 {
59 /* //////////////////////////// PUBLIC //////////////////////////////////// */
60 public:
61 
63  enum AlgType
64  {
67  };
68 
69 /* ============================ CREATORS ================================== */
71 
72 
74  MprBridge(const UtlString& rName,
75  int maxInOutputs,
76  UtlBoolean mixSilence=TRUE,
77  AlgType algorithm=ALG_LINEAR);
78 
80  virtual
81  ~MprBridge();
82 
84 
85 /* ============================ MANIPULATORS ============================== */
87 
88 
90  OsStatus setMixWeightsForOutput(int bridgeOutputPort,
91  int numWeights,
92  const MpBridgeGain gain[]);
114  static OsStatus setMixWeightsForOutput(const UtlString& namedResource,
116  OsMsgQ& fgQ,
117  int bridgeOutputPort,
118  int numWeights,
119  const MpBridgeGain gains[]);
124  OsStatus setMixWeightsForInput(int bridgeInputPort,
126  int numWeights,
127  const MpBridgeGain gain[]);
133  static OsStatus setMixWeightsForInput(const UtlString& namedResource,
135  OsMsgQ& fgQ,
136  int bridgeInputPort,
137  int numWeights,
138  const MpBridgeGain gains[]);
144 
145 /* ============================ ACCESSORS ================================= */
147 
148 
150 
151 /* ============================ INQUIRY =================================== */
153 
154 
156 
157 /* //////////////////////////// PROTECTED ///////////////////////////////// */
158 protected:
159 
160  typedef enum
161  {
164  } AddlMsgTypes;
165 
166 #ifdef TEST_PRINT_CONTRIBUTORS // [
167  MpContributorVector* mpMixContributors;
168  MpContributorVector** mpLastOutputContributors;
169 #endif // TEST_PRINT_CONTRIBUTORS ]
170 
173  UtlBoolean mMixSilence;
174 
175 #ifdef PRINT_CLIPPING_STATS
176  int mClippedFramesCounted;
177  int* mpOutputClippingCount;
178 #endif
179 
181  OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
189  UtlBoolean doMix(MpBufPtr inBufs[], int inBufsSize,
191  MpBufPtr outBufs[], int outBufsSize,
192  int samplesPerFrame);
193 
194  virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
195  MpBufPtr outBufs[],
196  int inBufsSize,
197  int outBufsSize,
198  UtlBoolean isEnabled,
199  int samplesPerFrame,
200  int samplesPerSecond);
201 
203  virtual UtlBoolean handleMessage(MpFlowGraphMsg& rMsg);
204 
206  virtual UtlBoolean handleMessage(MpResourceMsg& rMsg);
207 
209  virtual UtlBoolean handleSetMixWeightsForOutput(int bridgeOutputPort,
210  int numWeights,
211  const MpBridgeGain gain[]);
216  virtual UtlBoolean handleSetMixWeightsForInput(int bridgeInputPort,
218  int numWeights,
219  const MpBridgeGain gain[]);
224 /* //////////////////////////// PRIVATE /////////////////////////////////// */
225 private:
226 
228  MprBridge(const MprBridge& rMprBridge);
229 
231  MprBridge& operator=(const MprBridge& rhs);
232 
233 };
234 
235 /* ============================ INLINE METHODS ============================ */
236 
237 #endif // _MprBridge_h_
Message object used to communicate with the media processing task.
Definition: MpFlowGraphMsg.h:33
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
OsStatus setMixWeightsForInput(int bridgeInputPort, int numWeights, const MpBridgeGain gain[])
Send message to set mix weights for one input to given number of outputs.
Definition: MprBridge.cpp:274
Definition: MprBridge.h:163
int samplesPerFrame
virtual UtlBoolean handleMessage(MpFlowGraphMsg &rMsg)
Handle flowgraph messages for this resource.
Definition: MprBridge.cpp:350
virtual UtlBoolean handleSetMixWeightsForOutput(int bridgeOutputPort, int numWeights, const MpBridgeGain gain[])
Actually set mix weights for inputs to given output on bridge.
Definition: MprBridge.cpp:421
The conference bridge resource.
Definition: MprBridge.h:57
virtual ~MprBridge()
Destructor.
Definition: MprBridge.cpp:197
OsStatus setMixWeightsForOutput(int bridgeOutputPort, int numWeights, const MpBridgeGain gain[])
Send message to set mix weights for inputs to given output on bridge.
Definition: MprBridge.cpp:221
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
virtual UtlBoolean handleSetMixWeightsForInput(int bridgeInputPort, int numWeights, const MpBridgeGain gain[])
Actually set mix weights for one input to given number of outputs.
Definition: MprBridge.cpp:456
int samplesPerSecond
OsStatus setFlowGraph(MpFlowGraphBase *pFlowGraph)
Associates this resource with the indicated flow graph.
Definition: MprBridge.cpp:305
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: MprBridge.cpp:490
Linear O(n) algorithm (MpBridgeAlgLinear)
Definition: MprBridge.h:66
Simple O(n^2) algorithm (MpBridgeAlgSimple)
Definition: MprBridge.h:65
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
MpBridgeAlgBase * mpBridgeAlg
Instance of algorithm, used to mix data.
Definition: MprBridge.h:172
AddlMsgTypes
Definition: MprBridge.h:160
MprBridge & operator=(const MprBridge &rhs)
Assignment operator (not implemented for this class)
AlgType mAlgType
Type of the bridge algorithm to use.
Definition: MprBridge.h:171
UtlBoolean doMix(MpBufPtr inBufs[], int inBufsSize, MpBufPtr outBufs[], int outBufsSize, int samplesPerFrame)
Mix together inputs onto outputs according to mpGainMatrix matrix.
Definition: MprBridge.cpp:341
Smart pointer to MpBuf.
Definition: MpBuf.h:160
float MpBridgeGain
Definition: MpBridgeAlgBase.h:54
MprBridge(const UtlString &rName, int maxInOutputs, UtlBoolean mixSilence=TRUE, AlgType algorithm=ALG_LINEAR)
Default constructor.
Definition: MprBridge.cpp:149
Base class for the Bridge mixing algorithms.
Definition: MpBridgeAlgBase.h:62
#define TRUE
Definition: PlgDefsV1.h:41
AlgType
Type of the bridge mix algorithm to use.
Definition: MprBridge.h:63
UtlBoolean mMixSilence
Should Bridge ignore or mix frames marked as silence?
Definition: MprBridge.h:173
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
Definition: MprBridge.h:162
start of resource-specific messages
Definition: MpFlowGraphMsg.h:67