OpalMediaFormat Class Reference

#include <mediafmt.h>

List of all members.

Public Types

enum  { DefaultAudioSessionID = 1, DefaultVideoSessionID = 2, DefaultDataSessionID = 3, DefaultH224SessionID = 4 }
enum  StandardClockRate { AudioClockRate = 8000, VideoClockRate = 90000 }

Public Member Functions

 OpalMediaFormat ()
 OpalMediaFormat (const char *fullName, unsigned defaultSessionID, RTP_DataFrame::PayloadTypes rtpPayloadType, const char *encodingName, BOOL needsJitter, unsigned bandwidth, PINDEX frameSize, unsigned frameTime, unsigned clockRate, time_t timeStamp=0)
 OpalMediaFormat (RTP_DataFrame::PayloadTypes rtpPayloadType, unsigned clockRate, const char *rtpEncodingName=NULL, const char *protocol=NULL)
 OpalMediaFormat (const char *wildcard)
 OpalMediaFormat (const PString &wildcard)
 OpalMediaFormat (const OpalMediaFormat &mediaFormat)
virtual BOOL IsValid () const
BOOL IsTransportable () const
OpalMediaFormatoperator= (const OpalMediaFormat &fmt)
OpalMediaFormatoperator= (RTP_DataFrame::PayloadTypes rtpPayloadType)
OpalMediaFormatoperator= (const char *wildcard)
OpalMediaFormatoperator= (const PString &wildcard)
virtual PObject * Clone () const
virtual bool Merge (const OpalMediaFormat &mediaFormat)
RTP_DataFrame::PayloadTypes GetPayloadType () const
const char * GetEncodingName () const
unsigned GetDefaultSessionID () const
bool NeedsJitterBuffer () const
unsigned GetBandwidth () const
PINDEX GetFrameSize () const
unsigned GetFrameTime () const
unsigned GetTimeUnits () const
unsigned GetClockRate () const
PINDEX GetOptionCount () const
const OpalMediaOptionGetOption (PINDEX index) const
bool GetOptionValue (const PString &name, PString &value) const
bool SetOptionValue (const PString &name, const PString &value)
bool GetOptionBoolean (const PString &name, bool dflt=FALSE) const
bool SetOptionBoolean (const PString &name, bool value)
int GetOptionInteger (const PString &name, int dflt=0) const
bool SetOptionInteger (const PString &name, int value)
double GetOptionReal (const PString &name, double dflt=0) const
bool SetOptionReal (const PString &name, double value)
PINDEX GetOptionEnum (const PString &name, PINDEX dflt=0) const
bool SetOptionEnum (const PString &name, PINDEX value)
PString GetOptionString (const PString &name, const PString &dflt=PString::Empty()) const
bool SetOptionString (const PString &name, const PString &value)
bool GetOptionOctets (const PString &name, PBYTEArray &octets) const
bool SetOptionOctets (const PString &name, const PBYTEArray &octets)
bool SetOptionOctets (const PString &name, const BYTE *data, PINDEX length)
bool AddOption (OpalMediaOption *option, BOOL overwrite=FALSE)
bool HasOption (const PString &name) const
OpalMediaOptionFindOption (const PString &name) const
virtual bool IsValidForProtocol (const PString &protocol) const
virtual time_t GetCodecBaseTime () const
virtual ostream & PrintOptions (ostream &strm) const

Static Public Member Functions

static const PString & NeedsJitterOption ()
static const PString & MaxBitRateOption ()
static const PString & MaxFrameSizeOption ()
static const PString & FrameTimeOption ()
static const PString & ClockRateOption ()
static OpalMediaFormatList GetAllRegisteredMediaFormats ()
static void GetAllRegisteredMediaFormats (OpalMediaFormatList &copy)
static bool SetRegisteredMediaFormat (const OpalMediaFormat &mediaFormat)

Protected Attributes

RTP_DataFrame::PayloadTypes rtpPayloadType
PString rtpEncodingName
unsigned defaultSessionID
PMutex media_format_mutex
PSortedList< OpalMediaOptionoptions
time_t codecBaseTime

Friends

class OpalPluginCodecManager
class OpalMediaFormatList


Detailed Description

This class describes a media format as used in the OPAL system. A media format is the type of any media data that is trasferred between OPAL entities. For example an audio codec such as G.723.1 is a media format, a video codec such as H.261 is also a media format.


Member Enumeration Documentation

anonymous enum

Enumerator:
DefaultAudioSessionID 
DefaultVideoSessionID 
DefaultDataSessionID 
DefaultH224SessionID 

enum OpalMediaFormat::StandardClockRate

Enumerator:
AudioClockRate  8kHz sample rate
VideoClockRate  90kHz sample rate


Constructor & Destructor Documentation

OpalMediaFormat::OpalMediaFormat (  ) 

Default constructor creates a PCM-16 media format.

OpalMediaFormat::OpalMediaFormat ( const char *  fullName,
unsigned  defaultSessionID,
RTP_DataFrame::PayloadTypes  rtpPayloadType,
const char *  encodingName,
BOOL  needsJitter,
unsigned  bandwidth,
PINDEX  frameSize,
unsigned  frameTime,
unsigned  clockRate,
time_t  timeStamp = 0 
)

This form of the constructor will register the full details of the media format into an internal database. This would typically be used as a static global. In fact it would be very dangerous for an instance to use this constructor in any other way, especially local variables.

If the rtpPayloadType is RTP_DataFrame::DynamicBase, then the RTP payload type is actually set to teh first unused dynamic RTP payload type that is in the registers set of media formats.

The frameSize parameter indicates that the media format has a maximum size for each data frame, eg G.723.1 frames are no more than 24 bytes long. If zero then there is no intrinsic maximum, eg G.711.

Parameters:
fullName  Full name of media format
defaultSessionID  Default session for codec type
rtpPayloadType  RTP payload type code
encodingName  RTP encoding name
needsJitter  Indicate format requires a jitter buffer
bandwidth  Bandwidth in bits/second
frameSize  Size of frame in bytes (if applicable)
frameTime  Time for frame in RTP units (if applicable)
clockRate  Clock rate for data (if applicable)
timeStamp  timestamp (for versioning)

OpalMediaFormat::OpalMediaFormat ( RTP_DataFrame::PayloadTypes  rtpPayloadType,
unsigned  clockRate,
const char *  rtpEncodingName = NULL,
const char *  protocol = NULL 
)

Construct a media format, searching database for information. This constructor will search through the RegisteredMediaFormats list for the match of the payload type, if found the other information fields are set from the database. If not found then the ancestor string is set to the empty string.

Note it is impossible to determine the order of registration so this should not be relied on.

Parameters:
rtpPayloadType  RTP payload type code
clockRate  clock rate
rtpEncodingName  RTP payload type name
protocol  valid protocol (if NULL, then all)

OpalMediaFormat::OpalMediaFormat ( const char *  wildcard  ) 

Construct a media format, searching database for information. This constructor will search through the RegisteredMediaFormats list for the wildcard match of the parameter string, if found the other information fields are set from the database. If not found then the ancestor string is set to the empty string.

The wildcard string is a simple substring match using the '*' character. For example: "G.711*" would match the first of "G.711-uLaw-64k" and "G.711-ALaw-64k" to have been registered.

Note it is impossible to determine the order of registration so this should not be relied on.

Parameters:
wildcard  Wildcard name to search for

OpalMediaFormat::OpalMediaFormat ( const PString &  wildcard  ) 

Construct a media format, searching database for information. This constructor will search through the RegisteredMediaFormats list for the wildcard match of the parameter string, if found the other information fields are set from the database. If not found then the ancestor string is set to the empty string.

The wildcard string is a simple substring match using the '*' character. For example: "G.711*" would match the first of "G.711-uLaw-64k" and "G.711-ALaw-64k" to have been registered.

Note it is impossible to determine the order of registration so this should not be relied on.

Parameters:
wildcard  Wildcard name to search for

OpalMediaFormat::OpalMediaFormat ( const OpalMediaFormat mediaFormat  ) 

Copy Constructor

Parameters:
mediaFormat  other media format


Member Function Documentation

virtual BOOL OpalMediaFormat::IsValid (  )  const [inline, virtual]

Return TRUE if media format info is valid. This may be used if the single string constructor is used to check that it matched something in the registered media formats database.

BOOL OpalMediaFormat::IsTransportable (  )  const [inline]

Return TRUE if media format info may be sent via RTP. Some formats are internal use only and are never transported "over the wire".

OpalMediaFormat& OpalMediaFormat::operator= ( const OpalMediaFormat fmt  ) 

Copy a media format

Parameters:
fmt  other media format

OpalMediaFormat& OpalMediaFormat::operator= ( RTP_DataFrame::PayloadTypes  rtpPayloadType  ) 

Search for the specified format type. This is equivalent to going fmt = OpalMediaFormat(rtpPayloadType);

Parameters:
rtpPayloadType  RTP payload type code

OpalMediaFormat& OpalMediaFormat::operator= ( const char *  wildcard  ) 

Search for the specified format name. This is equivalent to going fmt = OpalMediaFormat(search);

Parameters:
wildcard  Wildcard name to search for

OpalMediaFormat& OpalMediaFormat::operator= ( const PString &  wildcard  ) 

Search for the specified format name. This is equivalent to going fmt = OpalMediaFormat(search);

Parameters:
wildcard  Wildcard name to search for

virtual PObject* OpalMediaFormat::Clone (  )  const [virtual]

Create a copy of the media format.

virtual bool OpalMediaFormat::Merge ( const OpalMediaFormat mediaFormat  )  [virtual]

Merge with another media format. This will alter and validate the options for this media format according to the merge rule for each option. The parameter is typically a "capability" while the current object isthe proposed channel format. This if the current object has a tx number of frames of 3, but the parameter has a value of 1, then the current object will be set to 1.

Returns FALSE if the media formats are incompatible and cannot be merged.

RTP_DataFrame::PayloadTypes OpalMediaFormat::GetPayloadType (  )  const [inline]

Get the RTP payload type that is to be used for this media format. This will either be an intrinsic one for the media format eg GSM or it will be automatically calculated as a dynamic media format that will be uniqueue amongst the registered media formats.

const char* OpalMediaFormat::GetEncodingName (  )  const [inline]

Get the RTP encoding name that is to be used for this media format.

unsigned OpalMediaFormat::GetDefaultSessionID (  )  const [inline]

Get the default session ID for media format.

bool OpalMediaFormat::NeedsJitterBuffer (  )  const [inline]

Determine if the media format requires a jitter buffer. As a rule an audio codec needs a jitter buffer and all others do not.

static const PString& OpalMediaFormat::NeedsJitterOption (  )  [static]

unsigned OpalMediaFormat::GetBandwidth (  )  const [inline]

Get the average bandwidth used in bits/second.

static const PString& OpalMediaFormat::MaxBitRateOption (  )  [static]

PINDEX OpalMediaFormat::GetFrameSize (  )  const [inline]

Get the maximum frame size in bytes. If this returns zero then the media format has no intrinsic maximum frame size, eg G.711 would return zero but G.723.1 whoud return 24.

static const PString& OpalMediaFormat::MaxFrameSizeOption (  )  [static]

unsigned OpalMediaFormat::GetFrameTime (  )  const [inline]

Get the frame time in RTP timestamp units. If this returns zero then the media format is not real time and has no intrinsic timing eg T.120

static const PString& OpalMediaFormat::FrameTimeOption (  )  [static]

unsigned OpalMediaFormat::GetTimeUnits (  )  const [inline]

Get the number of RTP timestamp units per millisecond.

unsigned OpalMediaFormat::GetClockRate (  )  const [inline]

Get the clock rate in Hz for this format.

static const PString& OpalMediaFormat::ClockRateOption (  )  [static]

PINDEX OpalMediaFormat::GetOptionCount (  )  const [inline]

Get the number of options this media format has.

const OpalMediaOption& OpalMediaFormat::GetOption ( PINDEX  index  )  const [inline]

Get the option instance at the specified index. This contains the description and value for the option.

Parameters:
index  Index of option in list to get

bool OpalMediaFormat::GetOptionValue ( const PString &  name,
PString &  value 
) const

Get the option value of the specified name as a string.

Returns false of the option is not present.

Parameters:
name  Option name
value  String to receive option value

bool OpalMediaFormat::SetOptionValue ( const PString &  name,
const PString &  value 
)

Set the option value of the specified name as a string. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present.

Parameters:
name  Option name
value  New option value as string

bool OpalMediaFormat::GetOptionBoolean ( const PString &  name,
bool  dflt = FALSE 
) const

Get the option value of the specified name as a boolean. The default value is returned if the option is not present.

Parameters:
name  Option name
dflt  Default value if option not present

bool OpalMediaFormat::SetOptionBoolean ( const PString &  name,
bool  value 
)

Set the option value of the specified name as a boolean. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present or is not of the same type.

Parameters:
name  Option name
value  New value for option

int OpalMediaFormat::GetOptionInteger ( const PString &  name,
int  dflt = 0 
) const

Get the option value of the specified name as an integer. The default value is returned if the option is not present.

Parameters:
name  Option name
dflt  Default value if option not present

bool OpalMediaFormat::SetOptionInteger ( const PString &  name,
int  value 
)

Set the option value of the specified name as an integer. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present, not of the same type or is putside the allowable range.

Parameters:
name  Option name
value  New value for option

double OpalMediaFormat::GetOptionReal ( const PString &  name,
double  dflt = 0 
) const

Get the option value of the specified name as a real. The default value is returned if the option is not present.

Parameters:
name  Option name
dflt  Default value if option not present

bool OpalMediaFormat::SetOptionReal ( const PString &  name,
double  value 
)

Set the option value of the specified name as a real. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present or is not of the same type.

Parameters:
name  Option name
value  New value for option

PINDEX OpalMediaFormat::GetOptionEnum ( const PString &  name,
PINDEX  dflt = 0 
) const

Get the option value of the specified name as an index into an enumeration list. The default value is returned if the option is not present.

Parameters:
name  Option name
dflt  Default value if option not present

bool OpalMediaFormat::SetOptionEnum ( const PString &  name,
PINDEX  value 
)

Set the option value of the specified name as an index into an enumeration. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present or is not of the same type.

Parameters:
name  Option name
value  New value for option

PString OpalMediaFormat::GetOptionString ( const PString &  name,
const PString &  dflt = PString::Empty() 
) const

Get the option value of the specified name as a string. The default value is returned if the option is not present.

Parameters:
name  Option name
dflt  Default value if option not present

bool OpalMediaFormat::SetOptionString ( const PString &  name,
const PString &  value 
)

Set the option value of the specified name as a string. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present or is not of the same type.

Parameters:
name  Option name
value  New value for option

bool OpalMediaFormat::GetOptionOctets ( const PString &  name,
PBYTEArray &  octets 
) const

Get the option value of the specified name as an octet array. Returns FALSE if not present.

Parameters:
name  Option name
octets  Octets in option

bool OpalMediaFormat::SetOptionOctets ( const PString &  name,
const PBYTEArray &  octets 
)

Set the option value of the specified name as an octet array. Note the option will not be added if it does not exist, the option must be explicitly added using AddOption().

Returns false of the option is not present or is not of the same type.

Parameters:
name  Option name
octets  Octets in option

bool OpalMediaFormat::SetOptionOctets ( const PString &  name,
const BYTE *  data,
PINDEX  length 
)

Parameters:
name  Option name
data  Octets in option
length  Number of octets

static OpalMediaFormatList OpalMediaFormat::GetAllRegisteredMediaFormats (  )  [static]

Get a copy of the list of media formats that have been registered.

static void OpalMediaFormat::GetAllRegisteredMediaFormats ( OpalMediaFormatList copy  )  [static]

Parameters:
copy  List to receive the copy of the master list

static bool OpalMediaFormat::SetRegisteredMediaFormat ( const OpalMediaFormat mediaFormat  )  [static]

Set the options on the master format list entry. The media format must already be registered. Returns false if not.

Parameters:
mediaFormat  Media format to copy to master list

bool OpalMediaFormat::AddOption ( OpalMediaOption option,
BOOL  overwrite = FALSE 
)

Add a new option to this media format

bool OpalMediaFormat::HasOption ( const PString &  name  )  const [inline]

Determine if media format has the specified option.

OpalMediaOption* OpalMediaFormat::FindOption ( const PString &  name  )  const

Get a pointer to the specified media format option. Returns NULL if thee option does not exist.

virtual bool OpalMediaFormat::IsValidForProtocol ( const PString &  protocol  )  const [virtual]

Returns TRUE if the media format is valid for the protocol specified This allow plugin codecs to customise which protocols they are valid for The default implementation returns true unless the protocol is H.323 and the rtpEncodingName is NULL

virtual time_t OpalMediaFormat::GetCodecBaseTime (  )  const [virtual]

virtual ostream& OpalMediaFormat::PrintOptions ( ostream &  strm  )  const [virtual]


Friends And Related Function Documentation

friend class OpalPluginCodecManager [friend]

friend class OpalMediaFormatList [friend]


Member Data Documentation

RTP_DataFrame::PayloadTypes OpalMediaFormat::rtpPayloadType [protected]

PString OpalMediaFormat::rtpEncodingName [protected]

unsigned OpalMediaFormat::defaultSessionID [protected]

PMutex OpalMediaFormat::media_format_mutex [protected]

PSortedList<OpalMediaOption> OpalMediaFormat::options [protected]

time_t OpalMediaFormat::codecBaseTime [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