sipxmedialib  Version 3.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MpFlowGraphBase Class Reference

Flow graph for coordinating the execution of media processing resources. More...

#include <MpFlowGraphBase.h>

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

Public Types

enum  FlowGraphState { STARTED, STOPPED }
 
enum  FlowGraphType { BASE_FLOWGRAPH = 0, CALL_FLOWGRAPH = 1, TOPOLOGY_FLOWGRAPH = 2 }
 

Public Member Functions

void synchronize (const char *tag=NULL, int val=0)
 Sends a message to self, and waits for reply. More...
 
Creators
 MpFlowGraphBase (int samplesPerFrame=0, int samplesPerSec=0, OsMsgDispatcher *pNotifDispatcher=NULL)
 Constructor. More...
 
virtual ~MpFlowGraphBase ()
 Destructor. More...
 
Manipulators
OsStatus addLink (MpResource &rFrom, int outPortIdx, MpResource &rTo, int inPortIdx)
 Creates a link between resources. More...
 
OsMsgDispatcher * setNotificationDispatcher (OsMsgDispatcher *notifyDispatcher)
 Adds a dispatcher for notifications to the flowgraph. More...
 
OsStatus addResource (MpResource &rResource, UtlBoolean makeNameUnique=TRUE)
 Adds the indicated media processing object to the flow graph. More...
 
OsStatus destroyResources (void)
 Stops the flow graph, removes all of the resources in the flow graph and destroys them. More...
 
OsStatus disable (void)
 Invokes the disable() method for each resource in the flow graph. More...
 
OsStatus enable (void)
 Invokes the enable() method for each resource in the flow graph. More...
 
virtual OsStatus gainFocus (void)
 Informs the flow graph that it now has the MpMediaTask focus. More...
 
OsStatus insertResourceAfter (MpResource &rResource, MpResource &rUpstreamResource, int outPortIdx)
 Inserts rResource into the flow graph downstream of the designated rUpstreamResource resource. More...
 
OsStatus insertResourceBefore (MpResource &rResource, MpResource &rDownstreamResource, int inPortIdx)
 
virtual OsStatus loseFocus (void)
 Informs the flow graph that it has lost the MpMediaTask focus. More...
 
virtual OsStatus postNotification (const MpResNotificationMsg &msg)
 posts a resource notification message to the Notification dispatcher. More...
 
virtual OsStatus processNextFrame (void)
 Processes the next frame interval's worth of media for the flow graph. More...
 
OsStatus removeLink (MpResource &rFrom, int outPortIdx)
 Removes the link between the outPortIdx port of the rFrom resource and its downstream counterpart. More...
 
OsStatus removeResource (MpResource &rResource)
 Removes the indicated media processing object from the flow graph. More...
 
OsStatus destroyResource (const UtlString &resourceName)
 Removes the indicated media processing object from the flowgraph and destroys it. More...
 
OsStatus setNotificationsEnabled (bool enabled, const UtlString &resourceName=NULL)
 
OsStatus start (void)
 Start this flow graph. More...
 
OsStatus stop (void)
 Stop this flow graph. More...
 
Accessors
virtual FlowGraphType getType ()
 Returns the type of this flow graph. More...
 
int getSamplesPerFrame (void) const
 Returns the number of samples expected per frame. More...
 
int getSamplesPerSec (void) const
 Returns the number of samples expected per second. More...
 
int getState (void) const
 Returns the current state of flow graph. More...
 
OsMsgDispatcher * getNotificationDispatcher () const
 Returns the current notification dispatcher, if any. If none, returns NULL. More...
 
OsStatus lookupResource (const UtlString &name, MpResource *&rpResource)
 Sets rpResource to point to the resource that corresponds to name or to NULL if no matching resource is found. More...
 
int numLinks (void) const
 Returns the number of links in the flow graph. More...
 
int numFramesProcessed (void) const
 Returns the number of frames this flow graph has processed. More...
 
int numResources (void) const
 Returns the number of resources in the flow graph. More...
 
OsMsgQ * getMsgQ (void)
 Returns the message queue used by the flow graph. More...
 
int getFlowgraphNum () const
 Get flowgraph's sequence number (use for debug purposes only!) More...
 
UtlString getFlowgraphName () const
 Get flowgraph's name based on its sequence number (use for debug purposes only!) More...
 
OsStatus getLatencyForPath (MpResource *pStartResource, int startResourceInput, const UtlString &endResourceName, int endResourceOutput, UtlBoolean includeEndResourceLatency, int &latency)
 Get latency for main path from one resource to another in forward direction. More...
 
OsStatus getLatencyForPathReverse (MpResource *pStartResource, int startResourceOutput, const UtlString &endResourceName, int endResourceInput, UtlBoolean includeEndResourceLatency, int &latency)
 Get latency for main path from one resource to another in reverse direction. More...
 
Inquiry
UtlBoolean isStarted (void) const
 Is flow graph in STARTED state. More...
 

Static Public Member Functions

static void flowGraphInfo (MpFlowGraphBase *pFlowGraph)
 Displays information on the console about the specified flow graph. More...
 

Protected Member Functions

virtual OsStatus postMessage (const MpFlowGraphMsg &rMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)
 Posts a message to this flow graph. More...
 
virtual UtlBoolean handleMessage (OsMsg &rMsg)
 Handles an incoming message for the flow graph. More...
 
UtlBoolean handleRemoveLink (MpResource *pFrom, int outPortIdx)
 Handle the FLOWGRAPH_REMOVE_LINK message. More...
 
UtlBoolean handleRemoveResource (MpResource *pResource)
 Handle the FLOWGRAPH_REMOVE_RESOURCE message. More...
 
UtlBoolean handleDestroyResource (const UtlString &name)
 Handle the FLOWGRAPH_DESTROY_RESOURCE message. More...
 
UtlBoolean handleSynchronize (MpFlowGraphMsg &rMsg)
 Handle the FLOWGRAPH_SYNCHRONIZE message. More...
 

Protected Attributes

OsRWMutex mRWMutex
 

Private Types

enum  { MAX_FLOWGRAPH_MESSAGES = 150 }
 
enum  { MAX_FLOWGRAPH_RESOURCES = 50 }
 

Private Member Functions

OsStatus computeOrder (void)
 Computes the execution order for the flow graph by performing a topological sort on the resource graph. More...
 
int getExecOrderIndex (const MpResource *resource) const
 Find the index of the given resource in the compute order array. More...
 
UtlBoolean disconnectAllInputs (MpResource *pResource)
 Disconnects all inputs (and the corresponding upstream outputs) for the indicated resource. More...
 
UtlBoolean disconnectAllOutputs (MpResource *pResource)
 Disconnects all outputs (and the corresponding downstream inputs) for the indicated resource. More...
 
UtlBoolean handleAddLink (MpResource *pFrom, int outPortIdx, MpResource *pTo, int inPortIdx)
 Handle the FLOWGRAPH_ADD_LINK message. More...
 
UtlBoolean handleAddResource (MpResource *pResource, UtlBoolean makeNameUnique)
 Handle the FLOWGRAPH_ADD_RESOURCE message. More...
 
UtlBoolean handleDestroyResources (void)
 Handle the FLOWGRAPH_DESTROY_RESOURCES message. More...
 
UtlBoolean handleDisable (void)
 Handle the FLOWGRAPH_DISABLE message. More...
 
UtlBoolean handleEnable (void)
 Handle the FLOWGRAPH_ENABLE message. More...
 
UtlBoolean handleStart (void)
 Handle the FLOWGRAPH_START message. More...
 
UtlBoolean handleStop (void)
 Handle the FLOWGRAPH_STOP message. More...
 
OsStatus handleGetLatencyForPath (MpResource *pStartResource, int startResourceInput, const UtlString &endResourceName, int endResourceOutput, UtlBoolean includeEndResourceLatency, int &latency)
 Do the real work for getLatencyForPath() More...
 
OsStatus handleGetLatencyForPathReverse (MpResource *pStartResource, int startResourceOutput, const UtlString &endResourceName, int endResourceInput, UtlBoolean includeEndResourceLatency, int &latency)
 Do the real work for getLatencyForPathReverse() More...
 
OsStatus lookupResourcePrivate (const UtlString &name, MpResource *&rpResource)
 Sets rpResource to point to the resource that corresponds to name or to NULL if no matching resource is found. More...
 
OsStatus processMessages (void)
 Processes all of the messages currently queued for this flow graph. More...
 
 MpFlowGraphBase (const MpFlowGraphBase &rMpFlowGraph)
 Copy constructor (not implemented for this task) More...
 
MpFlowGraphBaseoperator= (const MpFlowGraphBase &rhs)
 Assignment operator (not implemented for this task) More...
 

Private Attributes

int mFgNumber
 
UtlHashMap mResourceDict
 resource dictionary More...
 
MpResourcemExecOrder [MAX_FLOWGRAPH_RESOURCES]
 resource execution order More...
 
MpResourcemUnsorted [MAX_FLOWGRAPH_RESOURCES]
 unsorted resources More...
 
int mCurState
 current flow graph state More...
 
OsMsgQ mMessages
 message queue for this flow graph More...
 
OsMsgDispatcher * mNotifyDispatcher
 Dispatcher for notification messages. More...
 
int mPeriodCnt
 number of frames processed by this flow graph More...
 
int mLinkCnt
 number of links in this flow graph More...
 
int mResourceCnt
 number of resources in this flow graph More...
 
UtlBoolean mRecomputeOrder
 TRUE ==> the execution order needs computing. More...
 
int mSamplesPerFrame
 number of samples per frame More...
 
int mSamplesPerSec
 number of samples per second More...
 
MpResourcempResourceInProcess
 For debugging, keep track of what. More...
 

Static Private Attributes

static int gFgMaxNumber = 0
 mFgNumber (for debug purposes only!) More...
 
static const OsTime smProcessMessagesTimeout = OsTime::OS_INFINITY
 from the flowgraph queue. More...
 

Friends

OsStatus MpResource::postMessage (MpFlowGraphMsg &rMsg)
 

Detailed Description

Flow graph for coordinating the execution of media processing resources.

The media processing for a call is modeled as a directed graph of media processing resources (e.g., dejitter, mixer, encode, decode).

Frame Interval Processing

The media processing subsystem works on blocks of data. Every frame processing interval (typically 10 milliseconds), one frame interval's worth of media is processed.

At the start of the interval, the media task calls the processNextFrame() method for the flow graph. This method first calls processMessages() to handle any messages that have been posted to the flow graph. Next, if any resources or links have been added or removed since the last frame processing interval, the computeOrder() method is invoked. computeOrder() performs a topological sort on the resources in the flow graph to determine the correct resource execution order. This is done to ensure that resources producing output buffers are executed before other resources in the flow graph that expect to consume those buffers. Once the execution order has been determined, the processFrame() method for each of the resources in the flow graph is executed.

Stopped vs. Started States

A flow graph must be in the STARTED state in order to process media streams. For safety, the methods that modify the state of the flow graph only take effect when the flow graph is in a quiescent state. If the flow graph is in the STOPPED state, such methods take effect immediately. However, when the flow graph is in the STARTED state, changes take effect at the start of the next frame processing interval.

Synchronization

A reader/writer lock is used to seialize access to the object's internal data. A write lock is taken before executing any method that changes the object's internal state or posts a message to the flow graph's message queue. A read lock is taken before invoking any method that reads the object's internal state information. When reading internal state that is stored in 32 bits or less, the read lock is not acquired since such reads are assumed to be atomic.

Member Enumeration Documentation

Enumerator
STARTED 

flow graph has been started (is processing media streams)

STOPPED 

flow graph is stopped (not processing media streams)

Enumerator
BASE_FLOWGRAPH 
CALL_FLOWGRAPH 
TOPOLOGY_FLOWGRAPH 
anonymous enum
private
Enumerator
MAX_FLOWGRAPH_MESSAGES 
anonymous enum
private
Enumerator
MAX_FLOWGRAPH_RESOURCES 

Constructor & Destructor Documentation

MpFlowGraphBase ( int  samplesPerFrame = 0,
int  samplesPerSec = 0,
OsMsgDispatcher *  pNotifDispatcher = NULL 
)

Constructor.

Parameters
samplesPerFrameZero takes default
samplesPerSecZero takes default
~MpFlowGraphBase ( )
virtual

Destructor.

MpFlowGraphBase ( const MpFlowGraphBase rMpFlowGraph)
private

Copy constructor (not implemented for this task)

Member Function Documentation

OsStatus addLink ( MpResource rFrom,
int  outPortIdx,
MpResource rTo,
int  inPortIdx 
)

Creates a link between resources.

Creates a link between the outPortIdx port of the rFrom resource to the inPortIdx port of the rTo resource.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- successfully added the new link.
OS_INVALID_ARGUMENT- invalid port index.
OS_UNSPECIFIED- add link attempt failed.
OsMsgDispatcher * setNotificationDispatcher ( OsMsgDispatcher *  notifyDispatcher)

Adds a dispatcher for notifications to the flowgraph.

Seta a notification dispatcher to the flowgraph, for use in letting the resources or the flowgraph tell the application any interesting events.

Parameters
[in]notifyDispatcher- a pointer to a notification dispatcher that should be used to post media event notifications.
Return values
NULLif no previous notification dispatcher was set.
pointerto previous notification dispatcher if one was set previously.
OsStatus addResource ( MpResource rResource,
UtlBoolean  makeNameUnique = TRUE 
)

Adds the indicated media processing object to the flow graph.

If makeNameUnique is TRUE, then if a resource with the same name already exists in the flow graph, the name for rResource will be changed (by adding a numeric suffix) to make it unique within the flow graph.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- success.
OS_UNSPECIFIED- add resource attempt failed.
OsStatus destroyResources ( void  )

Stops the flow graph, removes all of the resources in the flow graph and destroys them.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- for now, this method always returns success.
OsStatus disable ( void  )

Invokes the disable() method for each resource in the flow graph.

Resources must be enabled before they will perform any meaningful processing on the media stream.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- for now, this method always returns success.
OsStatus enable ( void  )

Invokes the enable() method for each resource in the flow graph.

Resources must be enabled before they will perform any meaningful processing on the media stream.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- for now, this method always returns success.
OsStatus gainFocus ( void  )
virtual

Informs the flow graph that it now has the MpMediaTask focus.

Only the flow graph that has the focus is permitted to access the audio hardware. This may only be called if this flow graph is managed and started. Also this call is meaningful only if local audio is enabled for this flowgraph.

Return values
OS_SUCCESSon success
OS_FAILEDif flowgraph does not support setting focus.

Reimplemented in MpCallFlowGraph, and MpTopologyGraph.

OsStatus insertResourceAfter ( MpResource rResource,
MpResource rUpstreamResource,
int  outPortIdx 
)

Inserts rResource into the flow graph downstream of the designated rUpstreamResource resource.

The new resource will be inserted on the outPortIdx output link of rUpstreamResource.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- success.
OS_INVALID_ARGUMENT- invalid port index.
OsStatus insertResourceBefore ( MpResource rResource,
MpResource rDownstreamResource,
int  inPortIdx 
)

Inserts rResource into the flow graph upstream of the designated rDownstreamResource resource. The new resource will be inserted on the inPortIdx input link of rDownstreamResource.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- success.
OS_INVALID_ARGUMENT- invalid port index.
OsStatus loseFocus ( void  )
virtual

Informs the flow graph that it has lost the MpMediaTask focus.

Only the flow graph that has the focus is permitted to access the audio hardware. This may only be called if this flow graph is managed and started. Also this call is meaningful only if local audio is enabled for this flowgraph.

Return values
OS_SUCCESSon success
OS_FAILEDif flowgraph does not support setting focus.

Reimplemented in MpCallFlowGraph, and MpTopologyGraph.

OsStatus postNotification ( const MpResNotificationMsg msg)
virtual

posts a resource notification message to the Notification dispatcher.

If there is a notification dispatcher, this message is posted to it. Otherwise, the message is dropped.

The Notification Dispatcher is used to hold and notify users of notification messages. This is first being created to be used by resources, held here in the flowgraph, and used to pass notification up to the application level. In the future, this could be extended to allow filtering of notification messages - The one setting up the notification dispatcher could set properties on it to enable only certain types of messages to be sent up through it's framework.

Parameters
[in]msg- the notification message to post to the dispatcher.
Return values
OS_SUCCESSif the message was successfully added to the dispatcher.
OS_LIMIT_REACHEDif the queue is full, and no more messages can be accepted.
OS_NOT_FOUNDif there's no dispatcher.

Reimplemented in MpCallFlowGraph.

OsStatus processNextFrame ( void  )
virtual

Processes the next frame interval's worth of media for the flow graph.

Return values
OS_SUCCESS- for now, this method always returns success

Reimplemented in MpTopologyGraph.

OsStatus removeLink ( MpResource rFrom,
int  outPortIdx 
)

Removes the link between the outPortIdx port of the rFrom resource and its downstream counterpart.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- link has been removed.
OS_INVALID_ARGUMENT- invalid port index.
OsStatus removeResource ( MpResource rResource)

Removes the indicated media processing object from the flow graph.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- success, resource has been removed.
OS_UNSPECIFIED- remove resource operation failed.
OsStatus destroyResource ( const UtlString &  resourceName)

Removes the indicated media processing object from the flowgraph and destroys it.

If the flow graph is not "started", this call takes effect immediately. Otherwise, the call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- success, resource has been removed and destroyed.
OS_UNSPECIFIED- destroy resource operation failed.
OsStatus setNotificationsEnabled ( bool  enabled,
const UtlString &  resourceName = NULL 
)

OsStatus start ( void  )

Start this flow graph.

A flow graph must be "started" before it will process media streams. This call takes effect immediately.

Return values
OS_SUCCESS- for now this method always returns success.
OsStatus stop ( void  )

Stop this flow graph.

Stop processing media streams with this flow graph. This call takes effect at the start of the next frame processing interval.

Return values
OS_SUCCESS- for now this method always returns success.
void synchronize ( const char *  tag = NULL,
int  val = 0 
)

Sends a message to self, and waits for reply.

void flowGraphInfo ( MpFlowGraphBase pFlowGraph)
static

Displays information on the console about the specified flow graph.

MpFlowGraphBase::FlowGraphType getType ( )
virtual

Returns the type of this flow graph.

Reimplemented in MpCallFlowGraph, and MpTopologyGraph.

int getSamplesPerFrame ( void  ) const
inline

Returns the number of samples expected per frame.

int getSamplesPerSec ( void  ) const
inline

Returns the number of samples expected per second.

int getState ( void  ) const
inline

Returns the current state of flow graph.

OsMsgDispatcher * getNotificationDispatcher ( void  ) const
inline

Returns the current notification dispatcher, if any. If none, returns NULL.

OsStatus lookupResource ( const UtlString &  name,
MpResource *&  rpResource 
)

Sets rpResource to point to the resource that corresponds to name or to NULL if no matching resource is found.

Parameters
[in]name- the name of the resource to look up.
[out]rpResource- the resource pointer to store the resource in.
Return values
OS_SUCCESS- success
OS_NOT_FOUND- no resource with the specified name rpResource is NULL if OS_NOT_FOUND.
int numLinks ( void  ) const
inline

Returns the number of links in the flow graph.

int numFramesProcessed ( void  ) const
inline

Returns the number of frames this flow graph has processed.

int numResources ( void  ) const
inline

Returns the number of resources in the flow graph.

OsMsgQ * getMsgQ ( void  )
inline

Returns the message queue used by the flow graph.

int getFlowgraphNum ( ) const
inline

Get flowgraph's sequence number (use for debug purposes only!)

UtlString getFlowgraphName ( ) const
inline

Get flowgraph's name based on its sequence number (use for debug purposes only!)

OsStatus getLatencyForPath ( MpResource pStartResource,
int  startResourceInput,
const UtlString &  endResourceName,
int  endResourceOutput,
UtlBoolean  includeEndResourceLatency,
int &  latency 
)

Get latency for main path from one resource to another in forward direction.

This method traverses flowgraph from pStartResource following by first outputs (i.e. output 0) to next resources until resource with the name of endResourceName is reached. It sums up latencies of all encountered resources including latency of pStartResource and conditionally including latency of endResourceName.

Parameters
[in]pStartResource- pointer to a resource to start traverse from.
[in]startResourceInput- input number on start resource from which to calculate latency.
[in]endResourceName- name of a resource to end with.
[in]endResourceOutput- output number on end resource to which we should calculate latency. Value is meaningful only if includeEndResourceLatency is TRUE.
[in]includeEndResourceLatency- should the latency of the endResourceName be included in the path latency or not?
[out]latency- calculated latency for the path (in samples).
Return values
OS_SUCCESSif path was traversed successfully and latency was calculated.
OS_NOT_FOUNDif either start or end resource is not found.
OsStatus getLatencyForPathReverse ( MpResource pStartResource,
int  startResourceOutput,
const UtlString &  endResourceName,
int  endResourceInput,
UtlBoolean  includeEndResourceLatency,
int &  latency 
)

Get latency for main path from one resource to another in reverse direction.

Works exactly in the same way as getLatencyForPath(), but traverse resources from downstream to upstream ones.

See also
getLatencyForPath()
UtlBoolean isStarted ( void  ) const

Is flow graph in STARTED state.

Return values
TRUEif the flow graph has been started,
FALSEotherwise.
OsStatus postMessage ( const MpFlowGraphMsg rMsg,
const OsTime &  rTimeout = OsTime::OS_INFINITY 
)
protectedvirtual

Posts a message to this flow graph.

Returns the result of the message send operation.

Reimplemented in MpTopologyGraph.

UtlBoolean handleMessage ( OsMsg &  rMsg)
protectedvirtual

Handles an incoming message for the flow graph.

Return values
TRUEif the message was handled.
FALSEotherwise.

Reimplemented in MpCallFlowGraph, and MpTopologyGraph.

UtlBoolean handleRemoveLink ( MpResource pFrom,
int  outPortIdx 
)
protected

Handle the FLOWGRAPH_REMOVE_LINK message.

Return values
TRUEif the message was handled.
FALSEotherwise.
UtlBoolean handleRemoveResource ( MpResource pResource)
protected

Handle the FLOWGRAPH_REMOVE_RESOURCE message.

Return values
TRUEif the message was handled.
FALSEotherwise.
UtlBoolean handleDestroyResource ( const UtlString &  name)
protected

Handle the FLOWGRAPH_DESTROY_RESOURCE message.

Return values
TRUEif the message was handled.
FALSEotherwise.
UtlBoolean handleSynchronize ( MpFlowGraphMsg rMsg)
protected

Handle the FLOWGRAPH_SYNCHRONIZE message.

Return values
TRUEif the message was handled.
FALSEotherwise.
OsStatus computeOrder ( void  )
private

Computes the execution order for the flow graph by performing a topological sort on the resource graph.

Return values
OS_SUCCESS- successfully computed an execution order.
OS_LOOP_DETECTED- detected a loop in the flow graph.
int getExecOrderIndex ( const MpResource resource) const
private

Find the index of the given resource in the compute order array.

Parameters
[in]resourcepointer to flowgraph resource to find index for
Return values
indexof resource in execute order array or -1 if not found
UtlBoolean disconnectAllInputs ( MpResource pResource)
private

Disconnects all inputs (and the corresponding upstream outputs) for the indicated resource.

Return values
TRUE- if successful.
FALSE- otherwise.
UtlBoolean disconnectAllOutputs ( MpResource pResource)
private

Disconnects all outputs (and the corresponding downstream inputs) for the indicated resource.

Return values
TRUE- if successful.
FALSE- otherwise.
UtlBoolean handleAddLink ( MpResource pFrom,
int  outPortIdx,
MpResource pTo,
int  inPortIdx 
)
private

Handle the FLOWGRAPH_ADD_LINK message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleAddResource ( MpResource pResource,
UtlBoolean  makeNameUnique 
)
private

Handle the FLOWGRAPH_ADD_RESOURCE message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleDestroyResources ( void  )
private

Handle the FLOWGRAPH_DESTROY_RESOURCES message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleDisable ( void  )
private

Handle the FLOWGRAPH_DISABLE message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleEnable ( void  )
private

Handle the FLOWGRAPH_ENABLE message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleStart ( void  )
private

Handle the FLOWGRAPH_START message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
UtlBoolean handleStop ( void  )
private

Handle the FLOWGRAPH_STOP message.

Return values
TRUE- if the message was handled.
FALSE- otherwise.
OsStatus handleGetLatencyForPath ( MpResource pStartResource,
int  startResourceInput,
const UtlString &  endResourceName,
int  endResourceOutput,
UtlBoolean  includeEndResourceLatency,
int &  latency 
)
private

Do the real work for getLatencyForPath()

OsStatus handleGetLatencyForPathReverse ( MpResource pStartResource,
int  startResourceOutput,
const UtlString &  endResourceName,
int  endResourceInput,
UtlBoolean  includeEndResourceLatency,
int &  latency 
)
private

Do the real work for getLatencyForPathReverse()

OsStatus lookupResourcePrivate ( const UtlString &  name,
MpResource *&  rpResource 
)
private

Sets rpResource to point to the resource that corresponds to name or to NULL if no matching resource is found.

Does a lookup of name->resource, and sets rpResource to point to the resource that corresponds to name, or to NULL if no matching resource is found.

This private version does no locking.

Parameters
[in]name- the name of the resource to look up.
[out]rpResource- the resource pointer to store the resource in.
Return values
OS_SUCCESS- success.
OS_NOT_FOUND- no resource with the specified name rpResource is NULL if OS_NOT_FOUND.
OsStatus processMessages ( void  )
private

Processes all of the messages currently queued for this flow graph.

Returns
Always OS_SUCCESS for nows.
MpFlowGraphBase& operator= ( const MpFlowGraphBase rhs)
private

Assignment operator (not implemented for this task)

Friends And Related Function Documentation

OsStatus MpResource::postMessage ( MpFlowGraphMsg rMsg)
friend

Member Data Documentation

OsRWMutex mRWMutex
protected
int gFgMaxNumber = 0
staticprivate

mFgNumber (for debug purposes only!)

Flowgraph counter, used to generate

int mFgNumber
private

Sequence number of this flowgraph (for debug purposes only!)

UtlHashMap mResourceDict
private

resource dictionary

MpResource* mExecOrder[MAX_FLOWGRAPH_RESOURCES]
private

resource execution order

MpResource* mUnsorted[MAX_FLOWGRAPH_RESOURCES]
private

unsorted resources

int mCurState
private

current flow graph state

OsMsgQ mMessages
private

message queue for this flow graph

OsMsgDispatcher* mNotifyDispatcher
private

Dispatcher for notification messages.

int mPeriodCnt
private

number of frames processed by this flow graph

int mLinkCnt
private

number of links in this flow graph

int mResourceCnt
private

number of resources in this flow graph

UtlBoolean mRecomputeOrder
private

TRUE ==> the execution order needs computing.

int mSamplesPerFrame
private

number of samples per frame

int mSamplesPerSec
private

number of samples per second

MpResource* mpResourceInProcess
private

For debugging, keep track of what.

resource we are working on in processNextFrame().

const OsTime smProcessMessagesTimeout = OsTime::OS_INFINITY
staticprivate

from the flowgraph queue.

Timeout for receiving messages