OpalMediaStream Class Reference

#include <mediastrm.h>

Inheritance diagram for OpalMediaStream:

OpalFaxMediaStream OpalIAX2MediaStream OpalLineMediaStream OpalNullMediaStream OpalRawMediaStream OpalRTPMediaStream OpalUDPMediaStream OpalT38MediaStream OpalFileMediaStream List of all members.

Public Member Functions

PMutex & GetDeleteMutex () const
PString GetID () const
virtual BOOL IsNull () const
Overrides from PObject
void PrintOn (ostream &strm) const
Operations
virtual OpalMediaFormat GetMediaFormat () const
virtual BOOL UpdateMediaFormat (const OpalMediaFormat &mediaFormat)
virtual BOOL ExecuteCommand (const OpalMediaCommand &command)
virtual void SetCommandNotifier (const PNotifier &notifier)
virtual BOOL Open ()
virtual BOOL Start ()
virtual BOOL Close ()
virtual void OnPatchStart ()
virtual BOOL WritePackets (RTP_DataFrameList &packets)
virtual BOOL ReadPacket (RTP_DataFrame &packet)
virtual BOOL WritePacket (RTP_DataFrame &packet)
virtual BOOL ReadData (BYTE *data, PINDEX size, PINDEX &length)
virtual BOOL WriteData (const BYTE *data, PINDEX length, PINDEX &written)
BOOL PushPacket (RTP_DataFrame &packet)
virtual BOOL SetDataSize (PINDEX dataSize)
PINDEX GetDataSize () const
virtual BOOL IsSynchronous () const=0
virtual BOOL RequiresPatch () const
virtual BOOL RequiresPatchThread () const
virtual void EnableJitterBuffer () const
Member variable access
BOOL IsSource () const
BOOL IsSink () const
unsigned GetSessionID () const
unsigned GetTimestamp () const
void SetTimestamp (unsigned ts)
BOOL GetMarker () const
void SetMarker (BOOL m)
BOOL IsPaused () const
void SetPaused (BOOL p)
BOOL IsOpen ()
virtual BOOL SetPatch (OpalMediaPatch *patch)
virtual void RemovePatch (OpalMediaPatch *patch)
OpalMediaPatchGetPatch () const
void AddFilter (const PNotifier &Filter, const OpalMediaFormat &Stage=OpalMediaFormat())
BOOL RemoveFilter (const PNotifier &Filter, const OpalMediaFormat &Stage)

Protected Attributes

OpalMediaFormat mediaFormat
unsigned sessionID
BOOL paused
BOOL isSource
BOOL isOpen
PINDEX defaultDataSize
unsigned timestamp
BOOL marker
unsigned mismatchedPayloadTypes
OpalMediaPatchmediaPatch
PMutex patchMutex
PNotifier commandNotifier
PMutex deleteMutex
PString id

Detailed Description

This class describes a media stream as used in the OPAL system. A media stream is the channel through which media data is trasferred between OPAL entities. For example, data being sent to an RTP session over a network would be through a media stream.


Constructor & Destructor Documentation

OpalMediaStream::OpalMediaStream ( OpalConnection conn,
const OpalMediaFormat mediaFormat,
unsigned  sessionID,
BOOL  isSource 
) [protected]

Construct a new media stream.

Parameters:
mediaFormat  Media format for stream
sessionID  Session number for stream
isSource  Is a source stream

OpalMediaStream::~OpalMediaStream (  ) 

Destroy the media stream. Make sure the patch, if present, has been stopped and deleted.

OpalMediaStream::OpalMediaStream ( OpalConnection conn,
const OpalMediaFormat mediaFormat,
unsigned  sessionID,
BOOL  isSource 
) [protected]

Construct a new media stream.

Parameters:
mediaFormat  Media format for stream
sessionID  Session number for stream
isSource  Is a source stream

OpalMediaStream::~OpalMediaStream (  ) 

Destroy the media stream. Make sure the patch, if present, has been stopped and deleted.


Member Function Documentation

void OpalMediaStream::PrintOn ( ostream &  strm  )  const

Standard stream print function. The PObject class has a << operator defined that calls this function polymorphically.

Parameters:
strm  Stream to output text representation

virtual OpalMediaFormat OpalMediaStream::GetMediaFormat (  )  const [virtual]

Get the currently selected media format. The media data format is a string representation of the format being transferred by the media channel. It is typically a value as provided by the RTP_PayloadType class.

The default behaviour simply returns the member variable "mediaFormat".

virtual BOOL OpalMediaStream::UpdateMediaFormat ( const OpalMediaFormat mediaFormat  )  [virtual]

Update the media format. This can be used to adjust the parameters of a codec at run time. Note you cannot change the basic media format, eg change GSM0610 to G.711, only options for that format, eg 6k3 mode to 5k3 mode in G.723.1.

The default behaviour updates the mediaFormat member variable and pases the value on to the OpalMediaPatch.

Parameters:
mediaFormat  New media format

virtual BOOL OpalMediaStream::ExecuteCommand ( const OpalMediaCommand command  )  [virtual]

Execute the command specified to the transcoder. The commands are highly context sensitive, for example VideoFastUpdate would only apply to a video transcoder.

The default behaviour passes the command on to the OpalMediaPatch.

Parameters:
command  Command to execute.

virtual void OpalMediaStream::SetCommandNotifier ( const PNotifier &  notifier  )  [virtual]

Set a notifier to receive commands generated by the transcoder. The commands are highly context sensitive, for example VideoFastUpdate would only apply to a video transcoder.

The default behaviour passes the command on to the OpalMediaPatch and sets the member variable commandNotifier.

Parameters:
notifier  Command to execute.

virtual BOOL OpalMediaStream::Open (  )  [virtual]

Open the media stream using the media format.

The default behaviour simply sets the isOpen variable to TRUE.

Reimplemented in OpalIAX2MediaStream, OpalLineMediaStream, OpalRTPMediaStream, and OpalFaxMediaStream.

virtual BOOL OpalMediaStream::Start (  )  [virtual]

Start the media stream.

The default behaviour calls Resume() on the associated OpalMediaPatch thread if it was suspended.

Reimplemented in OpalIAX2MediaStream, and OpalFaxMediaStream.

virtual BOOL OpalMediaStream::Close (  )  [virtual]

Close the media stream.

The default does nothing.

Reimplemented in OpalIAX2MediaStream, OpalLineMediaStream, OpalRTPMediaStream, OpalRawMediaStream, OpalUDPMediaStream, and OpalFaxMediaStream.

virtual void OpalMediaStream::OnPatchStart (  )  [inline, virtual]

Callback that is called on the source stream once the media patch has started. The default behaviour does nothing

virtual BOOL OpalMediaStream::WritePackets ( RTP_DataFrameList &  packets  )  [virtual]

Write a list of RTP frames of data to the sink media stream. The default behaviour simply calls WritePacket() on each of the elements in the list.

virtual BOOL OpalMediaStream::ReadPacket ( RTP_DataFrame packet  )  [virtual]

Read an RTP frame of data from the source media stream. The default behaviour simply calls ReadData() on the data portion of the RTP_DataFrame and sets the frames timestamp and marker from the internal member variables of the media stream class.

Reimplemented in OpalIAX2MediaStream, OpalRTPMediaStream, OpalUDPMediaStream, OpalFaxMediaStream, and OpalT38MediaStream.

virtual BOOL OpalMediaStream::WritePacket ( RTP_DataFrame packet  )  [virtual]

Write an RTP frame of data to the sink media stream. The default behaviour simply calls WriteData() on the data portion of the RTP_DataFrame and and sets the internal timestamp and marker from the member variables of the media stream class.

Reimplemented in OpalRTPMediaStream, OpalUDPMediaStream, OpalFaxMediaStream, and OpalT38MediaStream.

virtual BOOL OpalMediaStream::ReadData ( BYTE *  data,
PINDEX  size,
PINDEX &  length 
) [virtual]

Read raw media data from the source media stream. The default behaviour simply calls ReadPacket() on the data portion of the RTP_DataFrame and sets the frames timestamp and marker from the internal member variables of the media stream class.

Parameters:
data  Data buffer to read to
size  Size of buffer
length  Length of data actually read

Reimplemented in OpalLineMediaStream, OpalNullMediaStream, OpalRawMediaStream, and OpalFileMediaStream.

virtual BOOL OpalMediaStream::WriteData ( const BYTE *  data,
PINDEX  length,
PINDEX &  written 
) [virtual]

Write raw media data to the sink media stream. The default behaviour calls WritePacket() on the data portion of the RTP_DataFrame and and sets the internal timestamp and marker from the member variables of the media stream class.

Parameters:
data  Data to write
length  Length of data to read.
written  Length of data actually written

Reimplemented in OpalIAX2MediaStream, OpalLineMediaStream, OpalNullMediaStream, OpalRawMediaStream, and OpalFileMediaStream.

BOOL OpalMediaStream::PushPacket ( RTP_DataFrame packet  ) 

Pushes a frame to the patch

virtual BOOL OpalMediaStream::SetDataSize ( PINDEX  dataSize  )  [virtual]

Set the data size in bytes that is expected to be used. Some media streams can make use of this information to perform optimisations.

The default behaviour does nothing.

Parameters:
dataSize  New data size

Reimplemented in OpalLineMediaStream, and OpalRTPMediaStream.

PINDEX OpalMediaStream::GetDataSize (  )  const [inline]

Get the data size in bytes that is expected to be used. Some media streams can make use of this information to perform optimisations.

virtual BOOL OpalMediaStream::IsSynchronous (  )  const [pure virtual]

Indicate if the media stream is synchronous. If this returns TRUE then the media stream will block of the amount of time it takes to annunciate the data. For example if the media stream is over a sound card, and 480 bytes of data are to be written it will take 30 milliseconds to complete.

Implemented in OpalIAX2MediaStream, OpalLineMediaStream, OpalNullMediaStream, OpalRTPMediaStream, OpalFileMediaStream, OpalUDPMediaStream, and OpalFaxMediaStream.

virtual BOOL OpalMediaStream::RequiresPatch (  )  const [virtual]

Indicate if the media stream requires a OpalMediaPatch instance. The default behaviour returns TRUE.

Reimplemented in OpalNullMediaStream.

virtual BOOL OpalMediaStream::RequiresPatchThread (  )  const [virtual]

Indicate if the media stream requires a OpalMediaPatch thread (active patch). The default behaviour returns TRUE.

Reimplemented in OpalNullMediaStream.

virtual void OpalMediaStream::EnableJitterBuffer (  )  const [virtual]

Enable jitter buffer for the media stream.

The default behaviour does nothing.

Reimplemented in OpalRTPMediaStream.

BOOL OpalMediaStream::IsSource (  )  const [inline]

Determine of media stream is a source or a sink.

BOOL OpalMediaStream::IsSink (  )  const [inline]

Determine of media stream is a source or a sink.

unsigned OpalMediaStream::GetSessionID (  )  const [inline]

Get the session number of the stream.

unsigned OpalMediaStream::GetTimestamp (  )  const [inline]

Get the timestamp of last read.

void OpalMediaStream::SetTimestamp ( unsigned  ts  )  [inline]

Set timestamp for next write.

BOOL OpalMediaStream::GetMarker (  )  const [inline]

Get the marker bit of last read.

void OpalMediaStream::SetMarker ( BOOL  m  )  [inline]

Set marker bit for next write.

BOOL OpalMediaStream::IsPaused (  )  const [inline]

Get the paused state for writing.

void OpalMediaStream::SetPaused ( BOOL  p  )  [inline]

Set the paused state for writing.

BOOL OpalMediaStream::IsOpen (  )  [inline]

Returns TRUE if the media stream is open.

virtual BOOL OpalMediaStream::SetPatch ( OpalMediaPatch patch  )  [virtual]

Set the patch thread that is using this stream.

Parameters:
patch  Media patch thread

virtual void OpalMediaStream::RemovePatch ( OpalMediaPatch patch  )  [virtual]

Remove the patch thread that is using this stream. This function is useful in case of streams which can be accessed by multiple instances of OpalMediaPatch.

The default behaviour simply sets patchThread to NULL.

OpalMediaPatch* OpalMediaStream::GetPatch (  )  const [inline]

Get the patch thread that is using the stream.

void OpalMediaStream::AddFilter ( const PNotifier &  Filter,
const OpalMediaFormat Stage = OpalMediaFormat() 
)

Add a filter to the owning patch safely.

BOOL OpalMediaStream::RemoveFilter ( const PNotifier &  Filter,
const OpalMediaFormat Stage 
)

Remove a filter from the owning patch safely.

PMutex& OpalMediaStream::GetDeleteMutex (  )  const [inline]

Get the mutex that prevents the destructor from completing.

PString OpalMediaStream::GetID (  )  const [inline]

Get the ID associated with this stream. Used for detecting two the streams associated with a bidirectional media channel

virtual BOOL OpalMediaStream::IsNull (  )  const [inline, virtual]


Member Data Documentation

OpalMediaFormat OpalMediaStream::mediaFormat [protected]

unsigned OpalMediaStream::sessionID [protected]

BOOL OpalMediaStream::paused [protected]

BOOL OpalMediaStream::isSource [protected]

BOOL OpalMediaStream::isOpen [protected]

PINDEX OpalMediaStream::defaultDataSize [protected]

unsigned OpalMediaStream::timestamp [protected]

BOOL OpalMediaStream::marker [protected]

unsigned OpalMediaStream::mismatchedPayloadTypes [protected]

OpalMediaPatch* OpalMediaStream::mediaPatch [protected]

PMutex OpalMediaStream::patchMutex [protected]

PNotifier OpalMediaStream::commandNotifier [protected]

PMutex OpalMediaStream::deleteMutex [mutable, protected]

PString OpalMediaStream::id [protected]


The documentation for this class was generated from the following file:
Generated on Fri Mar 7 06:34:05 2008 for OPAL by  doxygen 1.5.1