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

The MpStreamFeed coordinates with the data source and decoder to ready the input stream and then plugs into the MprFromStream resource to supply audio info the flowgraph. More...

#include <MpStreamFeeder.h>

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

Public Member Functions

Creators
 MpStreamFeeder (Url resource, int flags)
 Constructor accepting a url resource, type, and cache all flag. More...
 
 MpStreamFeeder (UtlString *pBuffer, int flags)
 Constructor accepting a pre-populated buffer, type and cache all flag. More...
 
virtual ~MpStreamFeeder ()
 Destructor. More...
 
OsStatus realize ()
 Initiates the connection with the outbound party to validate the connection. Buffers are allocated at this point. More...
 
OsStatus render ()
 Begin downloading and decoding data. More...
 
OsStatus rewind ()
 Rewind the data source to the prefetched state. More...
 
OsStatus stop ()
 
OsStatus setEventHandler (OsNotification *pEventHandler)
 Stop collecting/rendering data. More...
 
void markPaused (UtlBoolean bPaused)
 
Accessors
OsStatus getFrame (unsigned short *samples)
 Get a frames worth of data (80 samples per frame) ;. More...
 
UtlBoolean isMarkedPaused ()
 Has the rendered been marked as paused? More...
 
OsStatus getFlags (int &flags)
 Get the flags for this renderer. More...
 
FeederState getState ()
 Query the state for this renderer. More...
 
void fromStreamUpdate (FeederEvent event)
 Called by the MprFromStream resource when events changes. More...
 
Inquiry
UtlBoolean isValidStateChange (FeederState source, FeederState target)
 Is the transition from state source to target valid? More...
 
- Public Member Functions inherited from StreamDataSourceListener
 StreamDataSourceListener ()
 
virtual ~StreamDataSourceListener ()
 
- Public Member Functions inherited from StreamDecoderListener
 StreamDecoderListener ()
 
virtual ~StreamDecoderListener ()
 

Protected Member Functions

void fireEvent (FeederEvent eventType)
 Fires renderer event to interested consumers. More...
 
void setState (FeederState state)
 Sets the internal renderer state. More...
 
virtual void decoderUpdate (StreamFormatDecoder *pDecoder, StreamDecoderEvent event)
 Call back for decoder updates. More...
 
virtual void dataSourceUpdate (StreamDataSource *pDataSource, StreamDataSourceEvent event)
 Call back for data source updates. More...
 
- Protected Member Functions inherited from StreamDataSourceListener
 StreamDataSourceListener (const StreamDataSourceListener &rStreamDataSourceListener)
 
StreamDataSourceListeneroperator= (const StreamDataSourceListener &rhs)
 
- Protected Member Functions inherited from StreamDecoderListener
 StreamDecoderListener (const StreamDecoderListener &rStreamDecoderListener)
 
StreamDecoderListeneroperator= (const StreamDecoderListener &rhs)
 

Private Member Functions

void initDecodingSource ()
 Construction helper: initialize the decoding source. More...
 

Private Attributes

FeederState m_state
 State of the Feeder. More...
 
StreamFormatDecoderm_pFormatDecoder
 Decoder. More...
 
StreamDataSourcem_pDataSource
 Data Source. More...
 
int mFlags
 Flags given at creation. More...
 
UtlBoolean m_bMarkedPaused
 Is this marked as paused? More...
 
OsNotification * m_pEventHandler
 Event sink. More...
 
int m_iInstanceId
 
OsMutex m_eventGuard
 

Static Private Attributes

static int s_iInstanceCount = 0
 

Detailed Description

The MpStreamFeed coordinates with the data source and decoder to ready the input stream and then plugs into the MprFromStream resource to supply audio info the flowgraph.


+-> | StreamDataSource |


| MprFromStream | 1..N -> | MpStreamFeeder |


+-> | StreamFormatDecoder |

The MpStreamFeeder has its own state table that mostly matches the generic player's state table:

Unrealized -> Realized -> Prefetching -> Prefetched -> Rendering -> Stopped

       *->FailedState

Communications:

Events are send to the MpStreamPlayer resource indirectly through a settable OsNotifyEvent (setEventHandler).

Events are received from the MprFromStream object by the fromStreamUpdate callback function.

Constructor & Destructor Documentation

MpStreamFeeder ( Url  resource,
int  flags 
)

Constructor accepting a url resource, type, and cache all flag.

MpStreamFeeder ( UtlString *  pBuffer,
int  flags 
)

Constructor accepting a pre-populated buffer, type and cache all flag.

~MpStreamFeeder ( )
virtual

Destructor.

As part of destroying the task, flush all messages from the incoming OsMsgQ.

Member Function Documentation

OsStatus realize ( )

Initiates the connection with the outbound party to validate the connection. Buffers are allocated at this point.

OsStatus render ( )

Begin downloading and decoding data.

The state is not moved to prefetched until a sensible amount of data has been received and decoded.

OsStatus rewind ( )

Rewind the data source to the prefetched state.

OsStatus stop ( void  )
OsStatus setEventHandler ( OsNotification *  pEventHandler)

Stop collecting/rendering data.

Set the event handler for this renderer. All events will be delievered to this handler.

void markPaused ( UtlBoolean  bPaused)

Marks that playing is pauses; however, continues to render and stream.

OsStatus getFrame ( unsigned short *  samples)

Get a frames worth of data (80 samples per frame) ;.

UtlBoolean isMarkedPaused ( )

Has the rendered been marked as paused?

OsStatus getFlags ( int &  flags)

Get the flags for this renderer.

FeederState getState ( void  )

Query the state for this renderer.

void fromStreamUpdate ( FeederEvent  event)

Called by the MprFromStream resource when events changes.

UtlBoolean isValidStateChange ( FeederState  source,
FeederState  target 
)

Is the transition from state source to target valid?

void fireEvent ( FeederEvent  eventType)
protected

Fires renderer event to interested consumers.

void setState ( FeederState  state)
protected

Sets the internal renderer state.

void decoderUpdate ( StreamFormatDecoder pDecoder,
StreamDecoderEvent  event 
)
protectedvirtual

Call back for decoder updates.

Implements StreamDecoderListener.

void dataSourceUpdate ( StreamDataSource pDataSource,
StreamDataSourceEvent  event 
)
protectedvirtual

Call back for data source updates.

Implements StreamDataSourceListener.

void initDecodingSource ( )
private

Construction helper: initialize the decoding source.

Member Data Documentation

int s_iInstanceCount = 0
staticprivate
FeederState m_state
private

State of the Feeder.

StreamFormatDecoder* m_pFormatDecoder
private

Decoder.

StreamDataSource* m_pDataSource
private

Data Source.

int mFlags
private

Flags given at creation.

UtlBoolean m_bMarkedPaused
private

Is this marked as paused?

OsNotification* m_pEventHandler
private

Event sink.

int m_iInstanceId
private
OsMutex m_eventGuard
private

Guards multiple threads from calling fireEvent at same time