Container for SDP/RTP codec specification. More...
#include <SdpCodec.h>
Public Member Functions | |
Creators | |
SdpCodec (enum SdpCodecTypes sdpCodecType=SDP_CODEC_UNKNOWN, int payloadFormat=-1, const char *mimeType=MIME_TYPE_AUDIO, const char *mimeSubtype="", int sampleRate=8000, int preferredPacketLength=20000, int numChannels=1, const char *formatSpecificData="", const SdpCodecCPUCost CPUCost=SDP_CODEC_CPU_LOW, const int BWCost=SDP_CODEC_BANDWIDTH_NORMAL, const int videoFormat=SDP_VIDEO_FORMAT_QCIF, const int videoFmtp=0) | |
Default constructor. More... | |
SdpCodec (int payloadFormat, const char *mimeType, const char *mimeSubType, int sampleRate, int preferredPacketLength, int numChannels, const char *formatSpecificData) | |
SdpCodec (const SdpCodec &rSdpCodec) | |
Copy constructor. More... | |
virtual | ~SdpCodec () |
Destructor. More... | |
Manipulators | |
SdpCodec & | operator= (const SdpCodec &rhs) |
Assignment operator. More... | |
UtlCopyableContainable * | clone () const |
void | setCodecPayloadFormat (int formatId) |
Set the SDP/RTP payload id to be used for this codec. More... | |
void | setVideoFmtp (const int videoFmtp) |
Set the video format bitmap. More... | |
void | setVideoFmtpString (int videoFmtp) |
Set the video format string. More... | |
void | clearVideoFmtpString () |
Clears the format string. More... | |
void | setPacketSize (const int packetSize) |
Set the packet size. More... | |
Private Attributes | |
int | mCodecPayloadFormat |
UtlString | mMimeType |
audio, video, etc. More... | |
UtlString | mMimeSubtype |
a=rtpmap mime subtype value More... | |
int | mSampleRate |
samples per second More... | |
int | mPacketLength |
micro seconds More... | |
int | mNumChannels |
UtlString | mFormatSpecificData |
a=fmtp parameter More... | |
SdpCodecCPUCost | mCPUCost |
relative cost of a SDP codec More... | |
int | mBWCost |
int | mVideoFormat |
int | mVideoFmtp |
UtlString | mVideoFmtpString |
video format string More... | |
Accessors | |
enum SdpCodecTypes | getCodecType () const |
Get the internal/sipX codec type id. More... | |
int | getCodecPayloadFormat () const |
Get the SDP/RTP payload id to be used for this codec. More... | |
virtual void | getSdpFmtpField (UtlString &formatSpecificData) const |
Get the format specific parameters for the SDP. More... | |
virtual void | setSdpFmtpField (const UtlString &formatSpecificData) |
Set the format specific parameters for the SDP. More... | |
virtual UtlBoolean | getFmtpParameter (const UtlString ¶meterName, UtlString ¶meterValue, char nameValueSeperator= '=') const |
Get the named parameter in the format field (fmtp parameter) More... | |
void | getMediaType (UtlString &mimeMajorType) const |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>". More... | |
void | getEncodingName (UtlString &mimeSubtype) const |
MimeSubtype used as encoding name. More... | |
int | getSampleRate () const |
Get the number of samples per second. More... | |
int | getVideoFormat () const |
Return the video format. More... | |
int | getNumChannels () const |
Get the number of channels. More... | |
int | getPacketLength () const |
Get the preferred packet size in micro seconds. More... | |
void | toString (UtlString &sdpCodecContents) const |
Get a string dump of this codecs definition. More... | |
SdpCodecCPUCost | getCPUCost () const |
Get the CPU cost for this codec. More... | |
int | getBWCost () const |
Get the bandwidth cost for this codec. More... | |
int | getVideoFmtp () const |
Get the video format bitmap. More... | |
void | getVideoFmtpString (UtlString &fmtpString) const |
Get the video format string. More... | |
static UtlBoolean | getFmtpParameter (const UtlString &fmtpField, const UtlString ¶meterName, UtlString ¶meterValue, char nameValueSeperator= '=') |
Get the named parameter from the given format field (fmtp parameter) More... | |
static UtlBoolean | getFmtpParameter (const UtlString &fmtpField, const UtlString ¶meterName, int ¶meterValue, char nameValueSeperator= '=') |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>". More... | |
static OsStatus | getVideoSizes (const UtlString &fmtpField, int maxSizes, int &numSizes, int videoSizes[]) |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>". More... | |
Inquiry | |
UtlBoolean | isSameDefinition (const SdpCodec &codec) const |
Returns TRUE if this codec is the same definition as the given codec. More... | |
UtlBoolean | isFmtpParameterSame (const SdpCodec &codec, const UtlString &fmtpParameterName, const UtlString &fmtpParameterDefaultValue, const char nameValueSeperater= '=') const |
Returns TRUE if the named fmtp parameters are the same in this and the given codec. More... | |
UtlBoolean | isFmtpParameterSame (const UtlString &fmtp, const UtlString &fmtpParameterName, const UtlString &fmtpParameterDefaultValue, const char nameValueSeperater= '=') const |
Returns TRUE if the named fmtp parameters are the same in this and the given fmtp field string. More... | |
UtlBoolean | compareFmtp (const SdpCodec &codec, int &compares) const |
UtlBoolean | compareFmtp (const UtlString &fmtp, int &compares) const |
static UtlBoolean | isFmtpParameterSame (const UtlString &fmtp1, const UtlString &fmtp2, const UtlString &fmtpParameterName, const UtlString &fmtpParameterDefaultValue, const char nameValueSeperater= '=') |
static UtlBoolean | compareFmtp (const UtlString &mimeType, const UtlString &mimeSubtype, const UtlString &fmpt1, const UtlString &fmtp2, int &compares) |
Assumes mime type of provided fmtp string is same as this. More... | |
Container for SDP/RTP codec specification.
This class holds the SDP definition of a codec. Included information is: sample rate, number of channels, the mapping from an internal codec id to the public SDP format and RTP payload type id.
This is the base class. Specific codec types may implement sub classes which define the codec specific parameters. All specific codec types MUST be registered with the SdpCodecFactory to be usable. Generally codecs are constructed ONLY by the SdpCodecFactory.
The method that is used on SdpCodec::getCodecType() retrieves the static codec type/id. Now there is defined an enum in SdpCodec which contains the current values as well as some additional ones. The idea is that these are private, internally assigned ids to the codecs we support.
A new method SdpCodec::getCodecPayloadFormat() has been added which returns the RTP payload id to be used in RTP and the SDP. For static codec ID, the returned value for both of these methods would typically be the same, however for the dynamic codecs they will mostly be different.
The intent is that eventually we will support a factory which will allow registration of new codec types.
enum SdpCodecCPUCost |
enum SdpCodecTypes |
Unique identifier used for each supported codec.
Note it is possible that the format id/type used in the SDP "m" field and RTP header is different than these internally used ids.
SdpCodec | ( | enum SdpCodecTypes | sdpCodecType = SDP_CODEC_UNKNOWN , |
int | payloadFormat = -1 , |
||
const char * | mimeType = MIME_TYPE_AUDIO , |
||
const char * | mimeSubtype = "" , |
||
int | sampleRate = 8000 , |
||
int | preferredPacketLength = 20000 , |
||
int | numChannels = 1 , |
||
const char * | formatSpecificData = "" , |
||
const SdpCodecCPUCost | CPUCost = SDP_CODEC_CPU_LOW , |
||
const int | BWCost = SDP_CODEC_BANDWIDTH_NORMAL , |
||
const int | videoFormat = SDP_VIDEO_FORMAT_QCIF , |
||
const int | videoFmtp = 0 |
||
) |
Default constructor.
sampleRate | samples per second |
preferredPacketLength | micro seconds |
SdpCodec | ( | int | payloadFormat, |
const char * | mimeType, | ||
const char * | mimeSubType, | ||
int | sampleRate, | ||
int | preferredPacketLength, | ||
int | numChannels, | ||
const char * | formatSpecificData | ||
) |
|
virtual |
Destructor.
void clearVideoFmtpString | ( | ) |
Clears the format string.
|
inline |
UtlBoolean compareFmtp | ( | const SdpCodec & | codec, |
int & | compares | ||
) | const |
UtlBoolean compareFmtp | ( | const UtlString & | fmtp, |
int & | compares | ||
) | const |
compares | greater than, equal or less than zero based upon how the fmtp parameters compare |
|
static |
Assumes mime type of provided fmtp string is same as this.
compares | greater than, equal or less than zero based upon how the fmtp parameters compare |
int getBWCost | ( | ) | const |
Get the bandwidth cost for this codec.
int getCodecPayloadFormat | ( | ) | const |
Get the SDP/RTP payload id to be used for this codec.
This is the id used in the SDP "m" format sub-field and RTP header.
SdpCodec::SdpCodecTypes getCodecType | ( | ) | const |
Get the internal/sipX codec type id.
SdpCodec::SdpCodecCPUCost getCPUCost | ( | ) | const |
Get the CPU cost for this codec.
void getEncodingName | ( | UtlString & | mimeSubtype | ) | const |
MimeSubtype used as encoding name.
This is the encoding name used in the SDP "a=rtpmap: <payloadFormat> <mimeSubtype/sampleRate[/numChannels]" field.
|
virtual |
Get the named parameter in the format field (fmtp parameter)
|
static |
Get the named parameter from the given format field (fmtp parameter)
|
static |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>".
Get the named parameter from the given format field (fmtp parameter)
void getMediaType | ( | UtlString & | mimeMajorType | ) | const |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>".
Get the media type for the codec This is the mime major type (i.e. video, audio, etc)
int getNumChannels | ( | ) | const |
Get the number of channels.
int getPacketLength | ( | ) | const |
Get the preferred packet size in micro seconds.
Get the preferred (not mandated) packet size. This measure is in microseconds and is independent of whether this is frame or sample based codec
int getSampleRate | ( | ) | const |
Get the number of samples per second.
|
virtual |
Get the format specific parameters for the SDP.
This is what goes in the SDP "a" field in the format: "a=fmtp <payloadFormat> <formatSpecificData>"
int getVideoFmtp | ( | ) | const |
Get the video format bitmap.
void getVideoFmtpString | ( | UtlString & | fmtpString | ) | const |
Get the video format string.
int getVideoFormat | ( | ) | const |
Return the video format.
|
static |
Assumes the "a=fmtp:<payloadType>" of the fmtp field has be stripped off "a=fmtp:<payloadType> <fmtpdata>".
Get the video video sizes from the FMTP parameter
UtlBoolean isFmtpParameterSame | ( | const SdpCodec & | codec, |
const UtlString & | fmtpParameterName, | ||
const UtlString & | fmtpParameterDefaultValue, | ||
const char | nameValueSeperater = '=' |
||
) | const |
Returns TRUE if the named fmtp parameters are the same in this and the given codec.
UtlBoolean isFmtpParameterSame | ( | const UtlString & | fmtp, |
const UtlString & | fmtpParameterName, | ||
const UtlString & | fmtpParameterDefaultValue, | ||
const char | nameValueSeperater = '=' |
||
) | const |
Returns TRUE if the named fmtp parameters are the same in this and the given fmtp field string.
|
static |
UtlBoolean isSameDefinition | ( | const SdpCodec & | codec | ) | const |
Returns TRUE if this codec is the same definition as the given codec.
That is the encoding type and its characteristics, not the payload type.
void setCodecPayloadFormat | ( | int | formatId | ) |
Set the SDP/RTP payload id to be used for this codec.
void setPacketSize | ( | const int | packetSize | ) |
Set the packet size.
|
virtual |
Set the format specific parameters for the SDP.
This is what goes in the SDP "a" field in the format: "a=fmtp <payloadFormat> <formatSpecificData>"
void setVideoFmtp | ( | const int | videoFmtp | ) |
Set the video format bitmap.
void setVideoFmtpString | ( | int | videoFmtp | ) |
Set the video format string.
void toString | ( | UtlString & | sdpCodecContents | ) | const |
Get a string dump of this codecs definition.
|
private |
|
private |
mimeType | - Mime major type |
mimeSubtype | - Mime sub type |
fmpt1 | - fmtp string from 1st codec (Must have "a:fmtp <payloadId>" removed) |
fmpt2 | - fmtp string from 2nd codec (Must have "a:fmtp <payloadId>" removed) |
compares | greater than, equal or less than zero based upon how the fmtp parameters compare |
|
private |
relative cost of a SDP codec
|
private |
a=fmtp parameter
|
private |
a=rtpmap mime subtype value
|
private |
audio, video, etc.
|
private |
|
private |
micro seconds
|
private |
samples per second
|
private |
|
private |
video format string
|
private |