sipxmedialib  Version 3.3
MprSpeakerSelector.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2008 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Alexander Chemeris <Alexander DOT Chemeris AT sipez DOT com>
12 
13 #ifndef _MprSpeakerSelector_h_
14 #define _MprSpeakerSelector_h_
15 
16 // SYSTEM INCLUDES
17 // APPLICATION INCLUDES
18 #include <mp/MpAudioResource.h>
19 #include <mp/MpResourceMsg.h>
20 
21 // DEFINES
22 // EXTERNAL FUNCTIONS
23 // EXTERNAL VARIABLES
24 // CONSTANTS
25 // STRUCTS
26 // TYPEDEFS
27 // MACROS
28 // FORWARD DECLARATIONS
30 
36 {
37 /* //////////////////////////// PUBLIC //////////////////////////////////// */
38 public:
39 
40 /* ============================ CREATORS ================================== */
42 
43 
45  MprSpeakerSelector(const UtlString& rName,
46  int maxInputs,
47  int maxOutputs,
48  int maxActiveSpeakers,
49  const UtlString &algorithmName = "");
50 
52  MprSpeakerSelector(const UtlString& rName,
53  int maxInputs,
54  int maxOutputs,
55  int maxActiveSpeakers,
56  MpSpeakerSelectBase *pSS);
62  virtual ~MprSpeakerSelector();
64 
66 
67 /* ============================ MANIPULATORS ============================== */
69 
70 
72  OsStatus chageAlgorithm(const UtlString& namedResource,
73  OsMsgQ& fgQ,
74  const UtlString &algorithmName);
83 
84 /* ============================ ACCESSORS ================================= */
86 
87 
89 
90 /* ============================ INQUIRY =================================== */
92 
93 
95 
96 /* //////////////////////////// PROTECTED ///////////////////////////////// */
97 protected:
98 
99  typedef enum
100  {
102  } AddlMsgTypes;
103 
105  {
106  unsigned mRank;
107  int mIndex;
108  };
109 
110  UtlBoolean mDynamicInputMapping;
111  int mNumStreams;
114  UtlBoolean mSsFresh;
116  int mMaxActiveSpeakers;
119  int *mInToOutMap;
120  int *mOutToInMap;
121  uint32_t mMapTime;
123 
125  UtlBoolean connectInput(MpResource& rFrom, int fromPortIdx, int toPortIdx);
126 
128  UtlBoolean connectOutput(MpResource& rTo, int toPortIdx, int fromPortIdx);
129 
131  UtlBoolean disconnectInput(int outPortIdx);
132 
134  UtlBoolean disconnectOutput(int outPortIdx);
135 
137  OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
138 
140  UtlBoolean doProcessFrame(MpBufPtr inBufs[],
141  MpBufPtr outBufs[],
142  int inBufsSize,
143  int outBufsSize,
144  UtlBoolean isEnabled,
145  int samplesPerFrame,
146  int samplesPerSecond);
147 
149  UtlBoolean handleMessage(MpResourceMsg& rMsg);
150 
152  UtlBoolean handleEnable();
153 
155  UtlBoolean handleDisable();
156 
158  UtlBoolean handleChangeAlgorithm(const UtlString &algorithmName);
159 
161  void enableConnectedStreams();
167  static void peekTopSpeakers(MpSpeechParams **frameParams, int frameParamsNum,
169  RankIndexPair *topRanks, int topRanksNum);
170 
171  void updateMapping(RankIndexPair *topRanks, int topRanksNum);
172  inline int getOldestOutput();
173  inline int getOutputForInput(int inputNum);
174 
175 /* //////////////////////////// PRIVATE /////////////////////////////////// */
176 private:
177 
179  MprSpeakerSelector(const MprSpeakerSelector& rMprSpeakerSelector);
180 
183 
184 };
185 
186 /* ============================ INLINE METHODS ============================ */
187 
188 #endif // _MprSpeakerSelector_h_
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
int * mInToOutMap
Mapping of inputs to outputs.
Definition: MprSpeakerSelector.h:119
UtlBoolean handleEnable()
perform the enable operation on the resource
Definition: MprSpeakerSelector.cpp:460
int samplesPerFrame
UtlBoolean disconnectOutput(int outPortIdx)
Removes the connection to the outPortIdx output port of this resource.
Definition: MprSpeakerSelector.cpp:207
Definition: MpTypes.h:74
MprSpeakerSelector & operator=(const MprSpeakerSelector &rhs)
Assignment operator (not implemented for this class)
Definition: MpResourceMsg.h:56
AddlMsgTypes
Definition: MprSpeakerSelector.h:99
int * mOutToInMap
Mapping of outputs to inputs.
Definition: MprSpeakerSelector.h:120
MpSpeakerSelectBase * mpSS
Instance of Speaker Selection algorithm.
Definition: MprSpeakerSelector.h:113
void enableConnectedStreams()
Enable participants in algorithm whose streams are connected.
Definition: MprSpeakerSelector.cpp:500
Definition: MpSpeakerSelectBase.h:41
OsStatus chageAlgorithm(const UtlString &namedResource, OsMsgQ &fgQ, const UtlString &algorithmName)
Change Speaker Selection algorithm to the given one.
Definition: MprSpeakerSelector.cpp:146
UtlBoolean mDynamicInputMapping
or statically one-to-one?
Definition: MprSpeakerSelector.h:110
UtlBoolean handleDisable()
perform the disable operation on the resource
Definition: MprSpeakerSelector.cpp:476
int mMaxActiveSpeakers
Number of speakers we want to mix.
Definition: MprSpeakerSelector.h:117
int getOldestOutput()
Definition: MprSpeakerSelector.cpp:654
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
int samplesPerSecond
RankIndexPair * mTopRanks
Array of top ranked speakers, sorted by rank.
Definition: MprSpeakerSelector.h:118
UtlBoolean mSsFresh
Have algorithm been just initialized or reseted?
Definition: MprSpeakerSelector.h:114
int mIndex
Index of a speaker in mpFrameParams array.
Definition: MprSpeakerSelector.h:107
MprSpeakerSelector(const UtlString &rName, int maxInputs, int maxOutputs, int maxActiveSpeakers, const UtlString &algorithmName="")
Constructor.
Definition: MprSpeakerSelector.cpp:45
Abstract base class for all audio processing objects.
Definition: MpAudioResource.h:38
UtlBoolean handleChangeAlgorithm(const UtlString &algorithmName)
Handle MPRM_CHANGE_ALGORITHM message.
Definition: MprSpeakerSelector.cpp:487
UtlBoolean handleMessage(MpResourceMsg &rMsg)
Handles an incoming flowgraph message for this media processing object.
Definition: MprSpeakerSelector.cpp:245
The Speaker Selection resource.
Definition: MprSpeakerSelector.h:35
void updateMapping(RankIndexPair *topRanks, int topRanksNum)
Definition: MprSpeakerSelector.cpp:581
UtlBoolean connectOutput(MpResource &rTo, int toPortIdx, int fromPortIdx)
Connects the fromPortIdx output port on this resource to the toPortIdx input port of the rTo resource...
Definition: MprSpeakerSelector.cpp:179
Definition: MprSpeakerSelector.h:101
Smart pointer to MpBuf.
Definition: MpBuf.h:160
int maxOutputs() const
Returns the maximum number of outputs supported by this resource.
Definition: MpResource.cpp:357
static void peekTopSpeakers(MpSpeechParams **frameParams, int frameParamsNum, RankIndexPair *topRanks, int topRanksNum)
Peek top ranked speakers from the list.
Definition: MprSpeakerSelector.cpp:512
int getOutputForInput(int inputNum)
Definition: MprSpeakerSelector.cpp:689
Definition: MprSpeakerSelector.h:104
OsStatus setFlowGraph(MpFlowGraphBase *pFlowGraph)
Associates this resource with the indicated flow graph.
Definition: MprSpeakerSelector.cpp:222
int maxInputs() const
Returns the maximum number of inputs supported by this resource.
Definition: MpResource.cpp:351
int * mChangeMapTime
Definition: MprSpeakerSelector.h:122
virtual ~MprSpeakerSelector()
Destructor.
Definition: MprSpeakerSelector.cpp:134
UtlBoolean connectInput(MpResource &rFrom, int fromPortIdx, int toPortIdx)
Connects the toPortIdx input port on this resource to the fromPortIdx output port of the rFrom resour...
Definition: MprSpeakerSelector.cpp:162
Abstract base class for all media processing objects.
Definition: MpResource.h:56
unsigned mRank
Rank of a speaker, as set by Speaker Selection algorithm.
Definition: MprSpeakerSelector.h:106
MpSpeechParams ** mpFrameParams
for incoming frames.
Definition: MprSpeakerSelector.h:115
UtlBoolean disconnectInput(int outPortIdx)
Removes the connection to the inPortIdx input port of this resource.
Definition: MprSpeakerSelector.cpp:196
int mNumStreams
Maximum number of speakers we can process.
Definition: MprSpeakerSelector.h:112
uint32_t mMapTime
Definition: MprSpeakerSelector.h:121
UtlBoolean isEnabled() const
Returns TRUE is this resource is currently enabled, FALSE otherwise.
Definition: MpResource.cpp:440
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: MprSpeakerSelector.cpp:267