sipxmedialib
Version 3.3
|
Defines a stream data source built on top of a Http Stream. More...
#include <StreamHttpDataSource.h>
Public Member Functions | |
Creators | |
StreamHttpDataSource (Url url, int iFlags) | |
Default constructor. More... | |
virtual | ~StreamHttpDataSource () |
Destructor. More... | |
Manipulators | |
virtual OsStatus | open () |
Opens the data source. More... | |
virtual OsStatus | close () |
Closes the data source. More... | |
virtual OsStatus | destroyAndDelete () |
Destroys and deletes the data source object. More... | |
virtual OsStatus | read (char *szBuffer, int iLength, int &iLengthRead) |
virtual OsStatus | peek (char *szBuffer, int iLength, int &iLengthRead) |
Identical to read, except the stream pointer is not advanced. More... | |
virtual OsStatus | interrupt () |
Interrupts any time consuming operation. More... | |
virtual OsStatus | seek (unsigned int iLocation) |
Moves the stream pointer to the an absolute location. More... | |
UtlBoolean | deliverData (char *szData, int iLength, int iMaxLength) |
Callback routine that is invoked whenever new data is available from http socket. More... | |
Accessors | |
virtual OsStatus | getLength (int &iLength) |
Gets the length of the stream (if available) More... | |
virtual OsStatus | getPosition (int &iPosition) |
Gets the current position within the stream. More... | |
virtual OsStatus | toString (UtlString &string) |
Renders a string describing this data source. More... | |
virtual int | getBufferedLength () |
Gets the amount of data presently buffered. More... | |
Public Member Functions inherited from StreamDataSource | |
StreamDataSource (int iFlags=0) | |
Constructors a StreamDataSource given optional flags. More... | |
virtual | ~StreamDataSource () |
Destructor. More... | |
void | setListener (StreamDataSourceListener *pListener) |
int | getFlags () |
Gets the flags specified at time of construction. More... | |
Protected Member Functions | |
StreamHttpDataSource (const StreamHttpDataSource &rStreamHttpDataSource) | |
Copy constructor (not supported) More... | |
StreamHttpDataSource & | operator= (const StreamHttpDataSource &rhs) |
Assignment operator (not supported) More... | |
int | run (void *pArgs) |
Thread entry point. More... | |
Protected Member Functions inherited from StreamDataSource | |
StreamDataSource (const StreamDataSource &rStreamDataSource) | |
Copy constructor (not supported) More... | |
StreamDataSource & | operator= (const StreamDataSource &rhs) |
Assignment operator (not supported) More... | |
void | fireEvent (StreamDataSourceEvent event) |
Fires a data source event to the interested consumer. More... | |
Private Attributes | |
Url | m_url |
Source url. More... | |
UtlString | mBuffer |
Buffered content. More... | |
OsBSem | mSemNeedData |
Used block when we need more data. More... | |
OsBSem | mSemLimitData |
Used to block when need to throttle. More... | |
OsBSem | mSemGuardData |
Protected data structures. More... | |
OsBSem | mSemGuardStartClose |
Protected Opening/Closing the DataSource. More... | |
UtlBoolean | mbDone |
Is the data source complete. More... | |
UtlBoolean | mbQuit |
Are we quiting? More... | |
UtlBoolean | mbDeleteOnCompletion |
Should the run method delete the object? More... | |
unsigned int | miMaxData |
Max amount of data to buffer. More... | |
unsigned int | miDSLength |
Data Stream Length. More... | |
unsigned int | miOffset |
Present offset into the buffer. More... | |
unsigned int | miBufferOffset |
Buffer offset from start of stream. More... | |
UtlBoolean | mbFiredThrottledEvent |
Should fire event on next throttle? More... | |
UtlBoolean | mbClosed |
Have we closed this down? More... | |
UtlBoolean | mbInterrupt |
Interrupt current operation? More... | |
Static Private Attributes | |
static OsBSem | sSemGuardDelete |
Guard deletion of data sources. More... | |
Defines a stream data source built on top of a Http Stream.
Deletion of this class is very problematic, because the thread that pumps the data from the stream may be blocked for a long period of time and most cases the media task is player destroying this resource. Ideally, we would interrupt the socket read, however, that is not possible. So, to avoid blocking the thread context used to destroy this object, we use a variable mbDeleteOnCompletion to mark if/when we need to destroy this class once the run method has completed. This method is wrapped in a static binary semaphore to guard against races.
StreamHttpDataSource | ( | Url | url, |
int | iFlags | ||
) |
Default constructor.
|
virtual |
Destructor.
|
protected |
Copy constructor (not supported)
|
virtual |
Opens the data source.
Implements StreamDataSource.
|
virtual |
Closes the data source.
Implements StreamDataSource.
|
virtual |
Destroys and deletes the data source object.
Implements StreamDataSource.
|
virtual |
Reads iLength bytes of data from the data source and places the data into the passed szBuffer buffer.
szBuffer | - Buffer to place data |
iLength | - Max length to read |
iLengthRead | - The actual amount of data read. |
Implements StreamDataSource.
|
virtual |
Identical to read, except the stream pointer is not advanced.
szBuffer | - Buffer to place data |
iLength | - Max length to read |
iLengthRead | - The actual amount of data read. |
Implements StreamDataSource.
|
virtual |
Interrupts any time consuming operation.
For example, some data sources may require network access (e.g. http) to read or fetch data. Invoking an interrupt() will cause any time consuming or blocking calls to exit with more quickly with an OS_INTERRUPTED return code.
Reimplemented from StreamDataSource.
|
virtual |
Moves the stream pointer to the an absolute location.
iLocation | - The desired seek location |
Implements StreamDataSource.
UtlBoolean deliverData | ( | char * | szData, |
int | iLength, | ||
int | iMaxLength | ||
) |
Callback routine that is invoked whenever new data is available from http socket.
|
virtual |
Gets the length of the stream (if available)
Implements StreamDataSource.
|
virtual |
Gets the current position within the stream.
Implements StreamDataSource.
|
virtual |
Renders a string describing this data source.
Implements StreamDataSource.
|
virtual |
Gets the amount of data presently buffered.
|
protected |
Assignment operator (not supported)
|
protected |
Thread entry point.
|
private |
Source url.
|
private |
Buffered content.
|
private |
Used block when we need more data.
|
private |
Used to block when need to throttle.
|
private |
Protected data structures.
|
private |
Protected Opening/Closing the DataSource.
|
private |
Is the data source complete.
|
private |
Are we quiting?
|
private |
Should the run method delete the object?
|
private |
Max amount of data to buffer.
|
private |
Data Stream Length.
|
private |
Present offset into the buffer.
|
private |
Buffer offset from start of stream.
|
private |
Should fire event on next throttle?
|
private |
Have we closed this down?
|
private |
Interrupt current operation?
|
staticprivate |
Guard deletion of data sources.