sipxmedialib  Version 3.3
Classes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MprSpeakerSelector Class Reference

The Speaker Selection resource. More...

#include <MprSpeakerSelector.h>

Inheritance diagram for MprSpeakerSelector:
Inheritance graph
[legend]
Collaboration diagram for MprSpeakerSelector:
Collaboration graph
[legend]

Classes

struct  RankIndexPair
 

Public Member Functions

Creators
 MprSpeakerSelector (const UtlString &rName, int maxInputs, int maxOutputs, int maxActiveSpeakers, const UtlString &algorithmName="")
 Constructor. More...
 
 MprSpeakerSelector (const UtlString &rName, int maxInputs, int maxOutputs, int maxActiveSpeakers, MpSpeakerSelectBase *pSS)
 Constructor. More...
 
virtual ~MprSpeakerSelector ()
 Destructor. More...
 
Manipulators
OsStatus chageAlgorithm (const UtlString &namedResource, OsMsgQ &fgQ, const UtlString &algorithmName)
 Change Speaker Selection algorithm to the given one. More...
 
- Public Member Functions inherited from MpAudioResource
 MpAudioResource (const UtlString &rName, int minInputs, int maxInputs, int minOutputs, int maxOutputs)
 Constructor. More...
 
virtual ~MpAudioResource ()
 Destructor. More...
 
virtual UtlBoolean processFrame (void)
 Wrapper around doProcessFrame(). More...
 
- Public Member Functions inherited from MpResource
 MpResource (const UtlString &rName, int minInputs, int maxInputs, int minOutputs, int maxOutputs)
 Constructor. More...
 
virtual ~MpResource ()
 Destructor. More...
 
virtual UtlBoolean disable ()
 Disable this resource. More...
 
virtual UtlBoolean enable ()
 Enable this resource. More...
 
virtual void reset ()
 This method is invoked for resources that care about stream discontinuities. More...
 
UtlBoolean handleMessages (OsMsgQ &msgQ)
 Handles a queue full of incoming messages for this media processing object. More...
 
void setVisitState (int newState)
 Sets the visit state for this resource. More...
 
OsStatus sendNotification (MpResNotificationMsg::RNMsgType msgType)
 Send a notification with the given message type if notifications are enabled. More...
 
OsStatus sendNotification (MpResNotificationMsg &msg)
 Send the given notification message if notifications are enabled. More...
 
virtual void setConnectionId (MpConnectionID connectionId)
 Set the ID of a connection this resource belongs to. More...
 
virtual void setStreamId (int streamId)
 Set the ID of a stream inside of the connection this resource belongs to. More...
 
virtual int getStreamId (void)
 Get the ID of a stream within the connection this resource belongs to. More...
 
virtual OsStatus pushBuffer (int inputPort, MpBufPtr &inputBuffer)
 Receive buffer asynchronously from resource at given input port. More...
 
virtual void reassignSSRC (void)
 Broadcast announcement that we are changing our SSRC. More...
 
MpFlowGraphBasegetFlowGraph () const
 Returns parent flowgraph. More...
 
void getInputInfo (int inPortIdx, MpResource *&rpUpstreamResource, int &rUpstreamPortIdx)
 Returns information about the upstream end of a connection. More...
 
const UtlString & getName () const
 Returns the name associated with this resource. More...
 
void getOutputInfo (int outPortIdx, MpResource *&rpDownstreamResource, int &rDownstreamPortIdx)
 Returns information about the downstream end of a connection. More...
 
int getVisitState ()
 Returns the current visit state for this resource. More...
 
int maxInputs () const
 Returns the maximum number of inputs supported by this resource. More...
 
int maxOutputs () const
 Returns the maximum number of outputs supported by this resource. More...
 
int minInputs () const
 Returns the minimum number of inputs required by this resource. More...
 
int minOutputs () const
 Returns the minimum number of outputs required by this resource. More...
 
int numInputs () const
 Returns the number of resource inputs that are currently connected. More...
 
int numOutputs () const
 Returns the number of resource outputs that are currently connected. More...
 
virtual MpConnectionID getConnectionId (void) const
 Get the ID of a connection this resource belongs to. More...
 
int reserveFirstUnconnectedInput ()
 Find the first unconnected input port and reserve it. More...
 
int reserveFirstUnconnectedOutput ()
 Find the first unconnected output port and reserve it. More...
 
UtlContainableType getContainableType () const
 Get the ContainableType for a UtlContainable derived class. More...
 
virtual OsStatus getCurrentLatency (int &latency, int input=0, int output=0) const
 Get current input to output latency (in samples) More...
 
UtlBoolean isEnabled () const
 Returns TRUE is this resource is currently enabled, FALSE otherwise. More...
 
UtlBoolean isInputConnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated input is connected, FALSE otherwise. More...
 
UtlBoolean isInputUnconnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated input is not connected, FALSE otherwise. More...
 
UtlBoolean isOutputConnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated output is connected, FALSE otherwise. More...
 
UtlBoolean isOutputUnconnected (int portIdx)
 Returns TRUE if portIdx is valid and the indicated output is not connected, FALSE otherwise. More...
 
UtlBoolean areNotificationsEnabled () const
 Returns TRUE if notification sending is enabled on this resource. More...
 
virtual UtlBoolean isAsynchInput (int inputIndex)
 Takes asynchronous input (pushBuffer). More...
 

Protected Types

enum  AddlMsgTypes { MPRM_CHANGE_ALGORITHM = MpResourceMsg::MPRM_EXTERNAL_MESSAGE_START }
 

Protected Member Functions

UtlBoolean connectInput (MpResource &rFrom, int fromPortIdx, int toPortIdx)
 Connects the toPortIdx input port on this resource to the fromPortIdx output port of the rFrom resource. More...
 
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. More...
 
UtlBoolean disconnectInput (int outPortIdx)
 Removes the connection to the inPortIdx input port of this resource. More...
 
UtlBoolean disconnectOutput (int outPortIdx)
 Removes the connection to the outPortIdx output port of this resource. More...
 
OsStatus setFlowGraph (MpFlowGraphBase *pFlowGraph)
 Associates this resource with the indicated flow graph. More...
 
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 derived from this one. More...
 
UtlBoolean handleMessage (MpResourceMsg &rMsg)
 Handles an incoming flowgraph message for this media processing object. More...
 
UtlBoolean handleEnable ()
 perform the enable operation on the resource More...
 
UtlBoolean handleDisable ()
 perform the disable operation on the resource More...
 
UtlBoolean handleChangeAlgorithm (const UtlString &algorithmName)
 Handle MPRM_CHANGE_ALGORITHM message. More...
 
void enableConnectedStreams ()
 Enable participants in algorithm whose streams are connected. More...
 
void updateMapping (RankIndexPair *topRanks, int topRanksNum)
 
int getOldestOutput ()
 
int getOutputForInput (int inputNum)
 
- Protected Member Functions inherited from MpResource
virtual UtlBoolean handleMessage (MpFlowGraphMsg &fgMsg)
 Handles an incoming flowgraph message for this media processing object. More...
 
void setInputBuffer (int inPortIdx, const MpBufPtr &pBuf)
 If there already is a buffer stored for this input port, delete it. Then store pBuf for the indicated input port. More...
 
OsStatus postMessage (MpFlowGraphMsg &rMsg)
 Post a message from this resource. More...
 
OsStatus postMessage (MpResourceMsg &rMsg)
 Post a message for this resource. More...
 
UtlBoolean pushBufferDownsream (int outPortIdx, const MpBufPtr &pBuf)
 Makes pBuf available to resource connected to the outPortIdx output port of this resource. More...
 
virtual OsStatus setNotificationsEnabled (UtlBoolean enable)
 Sets whether or not this resource should send notifications. More...
 
void setName (const UtlString &rName)
 Sets the name that is associated with this resource. More...
 

Static Protected Member Functions

static void peekTopSpeakers (MpSpeechParams **frameParams, int frameParamsNum, RankIndexPair *topRanks, int topRanksNum)
 Peek top ranked speakers from the list. More...
 

Protected Attributes

UtlBoolean mDynamicInputMapping
 or statically one-to-one? More...
 
int mNumStreams
 Maximum number of speakers we can process. More...
 
MpSpeakerSelectBasempSS
 Instance of Speaker Selection algorithm. More...
 
UtlBoolean mSsFresh
 Have algorithm been just initialized or reseted? More...
 
MpSpeechParams ** mpFrameParams
 for incoming frames. More...
 
int mMaxActiveSpeakers
 Number of speakers we want to mix. More...
 
RankIndexPairmTopRanks
 Array of top ranked speakers, sorted by rank. More...
 
int * mInToOutMap
 Mapping of inputs to outputs. More...
 
int * mOutToInMap
 Mapping of outputs to inputs. More...
 
uint32_t mMapTime
 
int * mChangeMapTime
 
- Protected Attributes inherited from MpResource
MpFlowGraphBasempFlowGraph
 flow graph this resource belongs to More...
 
MpConnectionID mConnectionId
 The ID of connection this resource belongs to. More...
 
int mStreamId
 
UtlBoolean mIsEnabled
 TRUE if resource is enabled, FALSE otherwise. More...
 
OsRWMutex mRWMutex
 reader/writer lock for synchronization More...
 
MpBufPtrmpInBufs
 input buffers for this resource More...
 
MpBufPtrmpOutBufs
 output buffers for this resource More...
 
ConnmpInConns
 input connections for this resource More...
 
ConnmpOutConns
 output connections for this resource More...
 
int mMaxInputs
 maximum number of inputs More...
 
int mMaxOutputs
 maximum number of outputs More...
 
int mMinInputs
 number of required inputs More...
 
int mMinOutputs
 number of required outputs More...
 
int mNumActualInputs
 actual number of connected inputs More...
 
int mNumActualOutputs
 actual number of connected outputs More...
 
int mVisitState
 (used by flow graph topological sort alg.) More...
 
UtlBoolean mNotificationsEnabled
 Whether we should send notifications or not. More...
 
OsBSem mLock
 used mainly to make safe changes to ports More...
 

Private Member Functions

 MprSpeakerSelector (const MprSpeakerSelector &rMprSpeakerSelector)
 Copy constructor (not implemented for this class) More...
 
MprSpeakerSelectoroperator= (const MprSpeakerSelector &rhs)
 Assignment operator (not implemented for this class) More...
 

Additional Inherited Members

- Public Types inherited from MpResource
enum  VisitState { NOT_VISITED, IN_PROGRESS, FINISHED }
 Graph traversal states that are used when running a topological sort to order resources within a flow graph. More...
 
enum  { ASSOCIATED_LATENCY =-1, INF_LATENCY =-1 }
 
- Static Public Member Functions inherited from MpResource
static OsStatus disable (const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to disable the resource named. More...
 
static OsStatus enable (const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to enable the resource named. More...
 
static OsStatus setNotificationsEnabled (UtlBoolean enable, const UtlString &namedResource, OsMsgQ &fgQ)
 Post a message to enable or disable resource notifications on the named resource. More...
 
static void resourceInfo (MpResource *pResource, int index)
 Displays information on the console about the specified resource. More...
 
- Static Public Attributes inherited from MpResource
static const UtlContainableType TYPE = "MpResource"
 Class name, used for run-time checks. More...
 
- Static Protected Attributes inherited from MpResource
static const OsTime sOperationQueueTimeout = OsTime::OS_INFINITY
 The timeout for message operations for all resources when posting to the flowgraph queue. More...
 

Detailed Description

The Speaker Selection resource.

Member Enumeration Documentation

enum AddlMsgTypes
protected
Enumerator
MPRM_CHANGE_ALGORITHM 

Constructor & Destructor Documentation

MprSpeakerSelector ( const UtlString &  rName,
int  maxInputs,
int  maxOutputs,
int  maxActiveSpeakers,
const UtlString &  algorithmName = "" 
)

Constructor.

MprSpeakerSelector ( const UtlString &  rName,
int  maxInputs,
int  maxOutputs,
int  maxActiveSpeakers,
MpSpeakerSelectBase pSS 
)

Constructor.

Use this constructor for debug purposes only! Usage of constructor specifying Speaker Selection algorithm by name is strongly encouraged.

~MprSpeakerSelector ( )
virtual

Destructor.

MprSpeakerSelector ( const MprSpeakerSelector rMprSpeakerSelector)
private

Copy constructor (not implemented for this class)

Member Function Documentation

OsStatus chageAlgorithm ( const UtlString &  namedResource,
OsMsgQ &  fgQ,
const UtlString &  algorithmName 
)

Change Speaker Selection algorithm to the given one.

Parameters
[in]algorithmName- name of the Speaker Selection algorithm to use. If empty string of incorrect name is given, default Speaker Selection algorithm will be used and no error is generated.
UtlBoolean connectInput ( MpResource rFrom,
int  fromPortIdx,
int  toPortIdx 
)
protectedvirtual

Connects the toPortIdx input port on this resource to the fromPortIdx output port of the rFrom resource.

Note
This method locks to avoid contention over port allocation. It SHOULD NOT be used in process frame.
Returns
TRUE if successful, FALSE otherwise.

Reimplemented from MpResource.

UtlBoolean connectOutput ( MpResource rTo,
int  toPortIdx,
int  fromPortIdx 
)
protectedvirtual

Connects the fromPortIdx output port on this resource to the toPortIdx input port of the rTo resource.

Note
This method locks to avoid contention over port allocation. It SHOULD NOT be used in process frame.
Returns
TRUE if successful, FALSE otherwise.

Reimplemented from MpResource.

UtlBoolean disconnectInput ( int  outPortIdx)
protectedvirtual

Removes the connection to the inPortIdx input port of this resource.

Note
This method locks to avoid contention over port allocation. It SHOULD NOT be used in process frame.
Returns
TRUE if successful, FALSE otherwise.

Reimplemented from MpResource.

UtlBoolean disconnectOutput ( int  outPortIdx)
protectedvirtual

Removes the connection to the outPortIdx output port of this resource.

Note
This method locks to avoid contention over port allocation. It SHOULD NOT be used in process frame.
Returns
TRUE if successful, FALSE otherwise.

Reimplemented from MpResource.

OsStatus setFlowGraph ( MpFlowGraphBase pFlowGraph)
protectedvirtual

Associates this resource with the indicated flow graph.

Parameters
[in]pFlowGraph- pointer to a flowgraph owning this resource.
Return values
OS_SUCCESS- for now, this method always returns success

Reimplemented from MpResource.

UtlBoolean doProcessFrame ( MpBufPtr  inBufs[],
MpBufPtr  outBufs[],
int  inBufsSize,
int  outBufsSize,
UtlBoolean  isEnabled,
int  samplesPerFrame,
int  samplesPerSecond 
)
protectedvirtual

This method does the real work for the media processing resource and must be defined in each class derived from this one.

Parameters
inBufs(in) array of pointers to input buffers for the resource
outBufs(out) array of pointers to output buffers produce by the resource
inBufsSize(in) size of the inBufs array
outBufsSize(in) size of the outBufs array
isEnabled(in) indicates whether this resource has been enabled
samplesPerFrame(in) samples to produce per frame processing interval
samplesPerSecond(in) samples to produce per second
Returns
TRUE if successful, FALSE otherwise.

Implements MpAudioResource.

UtlBoolean handleMessage ( MpResourceMsg rMsg)
protectedvirtual

Handles an incoming flowgraph message for this media processing object.

Returns
TRUE if the message was handled, otherwise FALSE.

Reimplemented from MpResource.

UtlBoolean handleEnable ( void  )
protectedvirtual

perform the enable operation on the resource

Reimplemented from MpResource.

UtlBoolean handleDisable ( void  )
protectedvirtual

perform the disable operation on the resource

Reimplemented from MpResource.

UtlBoolean handleChangeAlgorithm ( const UtlString &  algorithmName)
protected

Handle MPRM_CHANGE_ALGORITHM message.

void enableConnectedStreams ( )
protected

Enable participants in algorithm whose streams are connected.

This method is usually called when algorithm is reseted or changed when resource is already connected.

void peekTopSpeakers ( MpSpeechParams **  frameParams,
int  frameParamsNum,
RankIndexPair topRanks,
int  topRanksNum 
)
staticprotected

Peek top ranked speakers from the list.

void updateMapping ( MprSpeakerSelector::RankIndexPair topRanks,
int  topRanksNum 
)
protected
int getOldestOutput ( )
inlineprotected
int getOutputForInput ( int  inputNum)
inlineprotected
MprSpeakerSelector& operator= ( const MprSpeakerSelector rhs)
private

Assignment operator (not implemented for this class)

Member Data Documentation

UtlBoolean mDynamicInputMapping
protected

or statically one-to-one?

Are inputs to outputs mapped dynamically

int mNumStreams
protected

Maximum number of speakers we can process.

MpSpeakerSelectBase* mpSS
protected

Instance of Speaker Selection algorithm.

UtlBoolean mSsFresh
protected

Have algorithm been just initialized or reseted?

MpSpeechParams** mpFrameParams
protected

for incoming frames.

Array of pointers to frame parameters

int mMaxActiveSpeakers
protected

Number of speakers we want to mix.

RankIndexPair* mTopRanks
protected

Array of top ranked speakers, sorted by rank.

int* mInToOutMap
protected

Mapping of inputs to outputs.

int* mOutToInMap
protected

Mapping of outputs to inputs.

uint32_t mMapTime
protected
int* mChangeMapTime
protected