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

#include <MpStreamPlaylistPlayer.h>

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

Classes

struct  PlaylistDb
 Definition for a playlist entry. More...
 

Public Types

enum  SourceType { SourceUrl, SourceBuffer }
 
- Public Types inherited from MpPlayer
enum  playerType { STREAM_PLAYER, STREAM_PLAYLIST_PLAYER, STREAM_QUEUE_PLAYER }
 

Public Member Functions

Creators
 MpStreamPlaylistPlayer (OsMsgQ *pMsgQ, const char *pTarget=NULL)
 Constructor accepting a flow graph. More...
 
virtual ~MpStreamPlaylistPlayer ()
 Destructor. More...
 
Manipulators
virtual OsStatus add (Url &url, int flags)
 Adds a url to the playlist. More...
 
virtual OsStatus add (UtlString *pBuffer, int flags)
 Adds a buffer to the playlist. More...
 
virtual OsStatus realize (UtlBoolean bBlock=TRUE)
 Realizes the player by initiating a connection to the target, allocates buffers, etc. More...
 
virtual OsStatus prefetch (UtlBoolean bBlock=TRUE)
 Prefetch enough of the data source to ensure a smooth playback. More...
 
virtual OsStatus play (UtlBoolean bBlock=TRUE)
 Plays the media stream. This will play all play lists from start to finish. More...
 
virtual OsStatus wait (const OsTime &rTimeout=OsTime::OS_INFINITY)
 Waits for the media stream(s) to finish playing. This will block the caller until all play lists have finished or rTimeout is reached. More...
 
virtual OsStatus rewind (UtlBoolean bBlock=TRUE)
 Rewinds a previously played media stream. In some cases this may result in a re-connect/refetch. More...
 
virtual OsStatus reset ()
 Resets the playlist player state by stopping and removing all entries. More...
 
virtual OsStatus stop ()
 Stops play the media stream and resources used for buffering and streaming. More...
 
virtual OsStatus destroy ()
 
virtual OsStatus pause ()
 Pauses the media stream temporarily. More...
 
Accessors
virtual OsStatus getCount (int &count) const
 Gets the number of play list entries. More...
 
virtual OsStatus getSourceType (int index, int &type) const
 Gets the source type for playlist entry 'index'. More...
 
virtual OsStatus getSourceUrl (int index, Url url) const
 Gets the source url for playlist entry 'index'. More...
 
virtual OsStatus getSourceBuffer (int index, UtlString *&netBuffer) const
 Gets the source buffer for playlist entry 'index'. More...
 
virtual OsStatus getSourceState (int index, PlayerState &state) const
 Gets the state for the playlist entry 'index'. More...
 
virtual OsStatus getCurrentIndex (int &iIndex) const
 Gets the current playing index if playing or the next index to play if playNext() was invoked. More...
 
virtual OsStatus getState (PlayerState &state)
 Gets the aggregate playerlist player state. More...
 
- Public Member Functions inherited from MpPlayer
 MpPlayer ()
 
virtual ~MpPlayer ()
 
OsStatus addListener (MpPlayerListener *pListener, void *pUserData=NULL)
 
OsStatus removeListener (MpPlayerListener *pListener)
 

Protected Member Functions

 MpStreamPlaylistPlayer (const MpStreamPlaylistPlayer &rMpStreamPlaylistPlayer)
 Copy constructor. More...
 
MpStreamPlaylistPlayeroperator= (const MpStreamPlaylistPlayer &rhs)
 Assignment operator. More...
 
virtual OsStatus first ()
 Selects the first playlist entry as the next index to play. More...
 
virtual OsStatus last ()
 Selects the last playlist entry as the next index to play. More...
 
virtual OsStatus playNext (UtlBoolean bBlock=TRUE)
 Plays the next playlist entry without wrapping. More...
 
virtual OsStatus playPrevious (UtlBoolean bBlock=TRUE)
 Plays the previous playlist entry without wrapping. More...
 
void setEntryState (int index, PlayerState iState)
 Sets the state for a specific entry. More...
 
OsStatus playEntry (int iEntry, UtlBoolean bBlock=TRUE)
 Starts playing a specific entry. More...
 
OsStatus rewindEntry (int iEntry, UtlBoolean bBlock=TRUE)
 Rewinds a specific entry. More...
 
OsStatus stopEntry (int index, UtlBoolean bBlock=TRUE)
 Stops playing a specific entry. More...
 
OsStatus pauseEntry (int index)
 Pauses a specific entry. More...
 
OsStatus destroyEntry (int index, UtlBoolean bBlockAndClean=TRUE)
 Destroys a specific entry. More...
 
virtual UtlBoolean handleMessage (OsMsg &rMsg)
 Handle messages directed to this server task. More...
 
void handleRealizedState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the realized state. More...
 
void handlePrefetchedState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the prefetched state. More...
 
void handlePlayingState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the playing state. More...
 
void handlePausedState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the paused state. More...
 
void handleStoppedState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the stopped state. More...
 
void handleFailedState (int index, PlayerState oldState, PlayerState newState)
 Handles processing for the failed state. More...
 
const char * getFeederEventString (int iEvent)
 Handles converting Feeder events into human readable form. More...
 
- Protected Member Functions inherited from MpPlayer
void fireEvent (PlayerState state)
 
UtlBoolean isValidStateChange (PlayerState oldState, PlayerState newState)
 

Private Attributes

int mNumPlayListElements
 number of play list entries More...
 
int mCurrentElement
 next item to play More...
 
int mPlayingElement
 current playing item More...
 
OsQueuedEvent * mpQueueEvent
 event for notifications More...
 
OsBSem mSemStateChange
 used to block for state changes More...
 
OsMsgQ * mpMsgQ
 MsgQ to send commands. More...
 
UtlString mTarget
 target used for MsgQ receive to help dispatch More...
 
OsEvent mWaitEvent
 used to block until player completes More...
 
OsTime mRealizeTimeout
 Timeout for Realize operation. More...
 
OsTime mPrefetchTimeout
 Timeout for Prefetch operation. More...
 
OsTime mPlayTimeout
 Timeout for Play operation. More...
 
OsTime mRewindTimeout
 Timeout for Rewind operation. More...
 
OsTime mStopTimeout
 Timeout for Stop operation. More...
 
OsTime mDestroyTimeout
 Timeout for Destroy operation. More...
 
UtlBoolean mbAutoAdvance
 used to play playlist lists More...
 
struct PlaylistDb mPlayListDb [MAX_PLAYLIST_LENGTH]
 db of entries More...
 
PlayerState mAggregateState
 Aggregate state of the player. More...
 

Member Enumeration Documentation

enum SourceType
Enumerator
SourceUrl 
SourceBuffer 

Constructor & Destructor Documentation

MpStreamPlaylistPlayer ( OsMsgQ *  pMsgQ,
const char *  pTarget = NULL 
)

Constructor accepting a flow graph.

~MpStreamPlaylistPlayer ( )
virtual

Destructor.

MpStreamPlaylistPlayer ( const MpStreamPlaylistPlayer rMpStreamPlaylistPlayer)
protected

Copy constructor.

Member Function Documentation

OsStatus add ( Url &  url,
int  flags 
)
virtual

Adds a url to the playlist.

Parameters
urlUrl identifying the source data stream
flagsPlaying flags (see StreamDefs.h)
OsStatus add ( UtlString *  pBuffer,
int  flags 
)
virtual

Adds a buffer to the playlist.

Parameters
pBuffer- Net Buffer containing buffered audio data. The MpStreamPlayer resource will delete the pBuffer upon destruction of itself.
flags- Playing flags (see StreamDefs.h)
OsStatus realize ( UtlBoolean  bBlock = TRUE)
virtual

Realizes the player by initiating a connection to the target, allocates buffers, etc.

Parameters
bBlock- TRUE if the method should block until completion, otherwise FALSE.

Implements MpPlayer.

OsStatus prefetch ( UtlBoolean  bBlock = TRUE)
virtual

Prefetch enough of the data source to ensure a smooth playback.

Parameters
bBlock- TRUE if the method should block until completion, otherwise FALSE.

Implements MpPlayer.

OsStatus play ( UtlBoolean  bBlock = TRUE)
virtual

Plays the media stream. This will play all play lists from start to finish.

Parameters
bBlock- TRUE if the method should block until completion, otherwise FALSE.

Implements MpPlayer.

OsStatus wait ( const OsTime &  rTimeout = OsTime::OS_INFINITY)
virtual

Waits for the media stream(s) to finish playing. This will block the caller until all play lists have finished or rTimeout is reached.

Parameters
rTimeout- Optional timeout. If not specified, wait forever.
OsStatus rewind ( UtlBoolean  bBlock = TRUE)
virtual

Rewinds a previously played media stream. In some cases this may result in a re-connect/refetch.

Parameters
bBlock- TRUE if the method should block until completion, otherwise FALSE.
OsStatus reset ( )
virtual

Resets the playlist player state by stopping and removing all entries.

OsStatus stop ( void  )
virtual

Stops play the media stream and resources used for buffering and streaming.

Implements MpPlayer.

OsStatus destroy ( )
virtual

the player as destroy and frees all allocated resources in media processing.

Implements MpPlayer.

OsStatus pause ( )
virtual

Pauses the media stream temporarily.

Implements MpPlayer.

OsStatus getCount ( int &  count) const
virtual

Gets the number of play list entries.

OsStatus getSourceType ( int  index,
int &  type 
) const
virtual

Gets the source type for playlist entry 'index'.

OsStatus getSourceUrl ( int  index,
Url  url 
) const
virtual

Gets the source url for playlist entry 'index'.

OsStatus getSourceBuffer ( int  index,
UtlString *&  netBuffer 
) const
virtual

Gets the source buffer for playlist entry 'index'.

OsStatus getSourceState ( int  index,
PlayerState state 
) const
virtual

Gets the state for the playlist entry 'index'.

OsStatus getCurrentIndex ( int &  iIndex) const
virtual

Gets the current playing index if playing or the next index to play if playNext() was invoked.

OsStatus getState ( PlayerState state)
virtual

Gets the aggregate playerlist player state.

Implements MpPlayer.

MpStreamPlaylistPlayer & operator= ( const MpStreamPlaylistPlayer rhs)
protected

Assignment operator.

OsStatus first ( )
protectedvirtual

Selects the first playlist entry as the next index to play.

Note
If an entry was playing, it will be stopped
OsStatus last ( )
protectedvirtual

Selects the last playlist entry as the next index to play.

Note
If an entry was playing, it will be stopped
OsStatus playNext ( UtlBoolean  bBlock = TRUE)
protectedvirtual

Plays the next playlist entry without wrapping.

OsStatus playPrevious ( UtlBoolean  bBlock = TRUE)
protectedvirtual

Plays the previous playlist entry without wrapping.

void setEntryState ( int  index,
PlayerState  iState 
)
protected

Sets the state for a specific entry.

OsStatus playEntry ( int  iEntry,
UtlBoolean  bBlock = TRUE 
)
protected

Starts playing a specific entry.

OsStatus rewindEntry ( int  iEntry,
UtlBoolean  bBlock = TRUE 
)
protected

Rewinds a specific entry.

OsStatus stopEntry ( int  index,
UtlBoolean  bBlock = TRUE 
)
protected

Stops playing a specific entry.

OsStatus pauseEntry ( int  index)
protected

Pauses a specific entry.

OsStatus destroyEntry ( int  index,
UtlBoolean  bBlockAndClean = TRUE 
)
protected

Destroys a specific entry.

UtlBoolean handleMessage ( OsMsg &  rMsg)
protectedvirtual

Handle messages directed to this server task.

void handleRealizedState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the realized state.

void handlePrefetchedState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the prefetched state.

void handlePlayingState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the playing state.

void handlePausedState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the paused state.

void handleStoppedState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the stopped state.

void handleFailedState ( int  index,
PlayerState  oldState,
PlayerState  newState 
)
protected

Handles processing for the failed state.

const char* getFeederEventString ( int  iEvent)
protected

Handles converting Feeder events into human readable form.

Member Data Documentation

int mNumPlayListElements
private

number of play list entries

int mCurrentElement
private

next item to play

int mPlayingElement
private

current playing item

OsQueuedEvent* mpQueueEvent
private

event for notifications

OsBSem mSemStateChange
private

used to block for state changes

OsMsgQ* mpMsgQ
private

MsgQ to send commands.

UtlString mTarget
private

target used for MsgQ receive to help dispatch

OsEvent mWaitEvent
private

used to block until player completes

OsTime mRealizeTimeout
private

Timeout for Realize operation.

OsTime mPrefetchTimeout
private

Timeout for Prefetch operation.

OsTime mPlayTimeout
private

Timeout for Play operation.

OsTime mRewindTimeout
private

Timeout for Rewind operation.

OsTime mStopTimeout
private

Timeout for Stop operation.

OsTime mDestroyTimeout
private

Timeout for Destroy operation.

UtlBoolean mbAutoAdvance
private

used to play playlist lists

struct PlaylistDb mPlayListDb[MAX_PLAYLIST_LENGTH]
private

db of entries

PlayerState mAggregateState
private

Aggregate state of the player.