Yate
SDPMedia Class Reference

SDP media description. More...

#include <yatesdp.h>

Inheritance diagram for SDPMedia:
NamedList String GenObject

Public Member Functions

 SDPMedia (const char *media, const char *transport, const char *formats, int rport=-1, int lport=-1)
 
virtual ~SDPMedia ()
 
bool isAudio () const
 
bool isVideo () const
 
bool isModified () const
 
void setModified (bool modified=true)
 
const Stringsuffix () const
 
bool isStarted () const
 
const Stringtransport () const
 
const Stringid () const
 
const Stringformat () const
 
const Stringformats () const
 
const StringremotePort () const
 
const StringlocalPort () const
 
const Stringmappings () const
 
void mappings (const char *newMap)
 
const Stringrfc2833 () const
 
void rfc2833 (int payload)
 
const StringremoteCrypto () const
 
const StringlocalCrypto () const
 
bool securable () const
 
bool sameAs (const SDPMedia *other, bool ignorePort=false, bool checkStarted=false) const
 
bool localChanged () const
 
void setLocalChanged (bool chg=false)
 
const char * fmtList () const
 
bool update (const char *formats, int rport=-1, int lport=-1, bool force=false)
 
void update (const NamedList &msg, bool pickFormat)
 
void parameter (const char *name, const char *value, bool append)
 
void parameter (NamedString *param, bool append)
 
void crypto (const char *desc, bool remote)
 
void putMedia (NamedList &msg, bool putPort=true)
 
void keepRtp (const SDPMedia &other)
 
- Public Member Functions inherited from NamedList
 NamedList (const char *name)
 
 NamedList (const NamedList &original)
 
 NamedList (const char *name, const NamedList &original, const String &prefix)
 
NamedListoperator= (const NamedList &value)
 
virtual void * getObject (const String &name) const
 
unsigned int length () const
 
unsigned int count () const
 
void clearParams ()
 
NamedListaddParam (NamedString *param)
 
NamedListaddParam (const char *name, const char *value, bool emptyOK=true)
 
NamedListsetParam (NamedString *param)
 
NamedListsetParam (const String &name, const char *value)
 
NamedListclearParam (const String &name, char childSep=0)
 
NamedListclearParam (NamedString *param, bool delParam=true)
 
NamedListcopyParam (const NamedList &original, const String &name, char childSep=0)
 
NamedListcopyParams (const NamedList &original)
 
NamedListcopyParams (const NamedList &original, ObjList *list, char childSep=0)
 
NamedListcopyParams (const NamedList &original, const String &list, char childSep=0)
 
NamedListcopySubParams (const NamedList &original, const String &prefix, bool skipPrefix=true, bool replace=false)
 
bool hasSubParams (const char *prefix) const
 
int getIndex (const NamedString *param) const
 
int getIndex (const String &name) const
 
NamedStringgetParam (const String &name) const
 
NamedStringgetParam (unsigned int index) const
 
const Stringoperator[] (const String &name) const
 
const char * getValue (const String &name, const char *defvalue=0) const
 
int getIntValue (const String &name, int defvalue=0, int minvalue=INT_MIN, int maxvalue=INT_MAX, bool clamp=true) const
 
int getIntValue (const String &name, const TokenDict *tokens, int defvalue=0) const
 
int64_t getInt64Value (const String &name, int64_t defvalue=0, int64_t minvalue=LLONG_MIN, int64_t maxvalue=LLONG_MAX, bool clamp=true) const
 
uint64_t getUInt64Value (const String &name, uint64_t defvalue=0, uint64_t minvalue=0, uint64_t maxvalue=ULLONG_MAX, bool clamp=true) const
 
double getDoubleValue (const String &name, double defvalue=0.0) const
 
bool getBoolValue (const String &name, bool defvalue=false) const
 
int replaceParams (String &str, bool sqlEsc=false, char extraEsc=0) const
 
void dump (String &str, const char *separator, char quote=0, bool force=false) const
 
ObjListparamList ()
 
const ObjListparamList () const
 
- Public Member Functions inherited from String
 String ()
 
 String (const char *value, int len=-1)
 
 String (char value, unsigned int repeat=1)
 
 String (int32_t value)
 
 String (uint32_t value)
 
 String (int64_t value)
 
 String (uint64_t value)
 
 String (bool value)
 
 String (double value)
 
 String (const String &value)
 
 String (const String *value)
 
virtual ~String ()
 
const char * c_str () const
 
const char * safe () const
 
const char * safe (const char *defStr) const
 
unsigned int length () const
 
bool null () const
 
int lenUtf8 (uint32_t maxChar=0x10ffff, bool overlong=false) const
 
int fixUtf8 (const char *replace=0, uint32_t maxChar=0x10ffff, bool overlong=false)
 
unsigned int encodeFlags (const TokenDict *tokens) const
 
uint64_t encodeFlags (const TokenDict64 *tokens) const
 
const StringdecodeFlags (unsigned int flags, const TokenDict *tokens, bool unknownflag=true)
 
const StringdecodeFlags (uint64_t flags, const TokenDict64 *tokens, bool unknownflag=true)
 
bool checkBOM () const
 
bool stripBOM ()
 
unsigned int hash () const
 
void clear ()
 
char at (int index) const
 
String substr (int offs, int len=-1) const
 
StringtrimBlanks ()
 
StringtrimSpaces ()
 
virtual const StringtoString () const
 
int toInteger (int defvalue=0, int base=0, int minvalue=INT_MIN, int maxvalue=INT_MAX, bool clamp=true) const
 
int toInteger (const TokenDict *tokens, int defvalue=0, int base=0) const
 
long int toLong (long int defvalue=0, int base=0, long int minvalue=LONG_MIN, long int maxvalue=LONG_MAX, bool clamp=true) const
 
int64_t toInt64 (int64_t defvalue=0, int base=0, int64_t minvalue=LLONG_MIN, int64_t maxvalue=LLONG_MAX, bool clamp=true) const
 
uint64_t toUInt64 (uint64_t defvalue=0, int base=0, uint64_t minvalue=0, uint64_t maxvalue=ULLONG_MAX, bool clamp=true) const
 
double toDouble (double defvalue=0.0) const
 
bool toBoolean (bool defvalue=false) const
 
bool isBoolean () const
 
StringtoUpper ()
 
StringtoLower ()
 
char operator[] (signed int index) const
 
char operator[] (unsigned int index) const
 
 operator const char * () const
 
Stringassign (const char *value, int len=-1)
 
Stringassign (char value, unsigned int repeat=1)
 
Stringhexify (void *data, unsigned int len, char sep=0, bool upCase=false)
 
Stringoperator= (const String &value)
 
Stringoperator= (const String *value)
 
Stringoperator= (const char *value)
 
Stringoperator= (char value)
 
Stringoperator= (int32_t value)
 
Stringoperator= (uint32_t value)
 
Stringoperator= (int64_t value)
 
Stringoperator= (uint64_t value)
 
Stringoperator= (bool value)
 
Stringoperator= (double value)
 
Stringoperator+= (const char *value)
 
Stringoperator+= (char value)
 
Stringoperator+= (int32_t value)
 
Stringoperator+= (uint32_t value)
 
Stringoperator+= (int64_t value)
 
Stringoperator+= (uint64_t value)
 
Stringoperator+= (bool value)
 
Stringoperator+= (double value)
 
bool operator== (const char *value) const
 
bool operator!= (const char *value) const
 
bool operator== (const String &value) const
 
bool operator!= (const String &value) const
 
bool operator&= (const char *value) const
 
bool operator|= (const char *value) const
 
Stringoperator<< (const char *value)
 
Stringoperator<< (char value)
 
Stringoperator<< (int32_t value)
 
Stringoperator<< (uint32_t value)
 
Stringoperator<< (int64_t value)
 
Stringoperator<< (uint64_t value)
 
Stringoperator<< (bool value)
 
Stringoperator<< (double value)
 
Stringoperator>> (const char *skip)
 
Stringoperator>> (char &store)
 
Stringoperator>> (UChar &store)
 
Stringoperator>> (int &store)
 
Stringoperator>> (unsigned int &store)
 
Stringoperator>> (bool &store)
 
Stringappend (const char *value, int len)
 
Stringappend (const char *value, const char *separator=0, bool force=false)
 
Stringappend (const ObjList *list, const char *separator=0, bool force=false)
 
Stringappend (const ObjList &list, const char *separator=0, bool force=false)
 
Stringappend (double value, unsigned int decimals=3)
 
Stringprintf (const char *format,...)
 
Stringprintf (unsigned int length, const char *format,...)
 
StringappendFixed (unsigned int fixedLength, const char *str, unsigned int len=-1, char fill=' ', int align=Left)
 
StringappendFixed (unsigned int fixedLength, const String &str, char fill=' ', int align=Left)
 
int find (char what, unsigned int offs=0) const
 
int find (const char *what, unsigned int offs=0) const
 
int rfind (char what) const
 
int rfind (const char *what) const
 
bool startsWith (const char *what, bool wordBreak=false, bool caseInsensitive=false) const
 
bool endsWith (const char *what, bool wordBreak=false, bool caseInsensitive=false) const
 
bool startSkip (const char *what, bool wordBreak=true, bool caseInsensitive=false)
 
StringextractTo (const char *sep, String &store)
 
StringextractTo (const char *sep, bool &store)
 
StringextractTo (const char *sep, int &store, int base=0)
 
StringextractTo (const char *sep, int &store, const TokenDict *tokens, int base=0)
 
StringextractTo (const char *sep, double &store)
 
virtual bool matches (const String &value) const
 
bool matches (const Regexp &rexp)
 
int matchOffset (int index=0) const
 
int matchLength (int index=0) const
 
String matchString (int index=0) const
 
String replaceMatches (const String &templ) const
 
int matchCount () const
 
ObjListsplit (char separator, bool emptyOK=true) const
 
ObjListsplit (const Regexp &reg, bool emptyOK=true) const
 
String msgEscape (char extraEsc=0) const
 
String msgUnescape (int *errptr=0, char extraEsc=0) const
 
String sqlEscape (char extraEsc=0) const
 
String uriEscape (char extraEsc=0, const char *noEsc=0) const
 
String uriUnescape (int *errptr=0) const
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static int payloadMapping (const String &mappings, const String &fmt)
 
- Static Public Member Functions inherited from NamedList
static const NamedListempty ()
 
- Static Public Member Functions inherited from String
static const Stringempty ()
 
static const char * boolText (bool value)
 
static int lenUtf8 (const char *value, uint32_t maxChar=0x10ffff, bool overlong=false)
 
static bool checkBOM (const char *str)
 
static bool stripBOM (const char *&str)
 
static bool stripBOM (char *&str)
 
static unsigned int hash (const char *value, unsigned int h=0)
 
static String msgEscape (const char *str, char extraEsc=0)
 
static String msgUnescape (const char *str, int *errptr=0, char extraEsc=0)
 
static String sqlEscape (const char *str, char extraEsc=0)
 
static String uriEscape (const char *str, char extraEsc=0, const char *noEsc=0)
 
static String uriEscape (const char *str, const char *extraEsc, const char *noEsc=0)
 
static String uriUnescape (const char *str, int *errptr=0)
 
static const Stringatom (const String *&str, const char *val)
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Additional Inherited Members

- Public Types inherited from String
enum  Align { Left = 0 , Center , Right }
 
- Protected Member Functions inherited from String
virtual void changed ()
 

Detailed Description

SDP media description.

This class holds a single SDP media description

Constructor & Destructor Documentation

◆ SDPMedia()

SDPMedia ( const char * media,
const char * transport,
const char * formats,
int rport = -1,
int lport = -1 )

Constructor

Parameters
mediaMedia type name
transportTransport name
formatsComma separated list of formats
rportOptional remote media port
lportOptional local media port

References formats(), and transport().

Referenced by keepRtp(), and sameAs().

◆ ~SDPMedia()

virtual ~SDPMedia ( )
virtual

Destructor

Member Function Documentation

◆ crypto()

void crypto ( const char * desc,
bool remote )

Set a new crypto description, set the modified flag if changed. Reset the media securable flag if the remote crypto is empty

Parameters
descThe new crypto description
remoteTrue to set the remote crypto, false to set the local one

◆ fmtList()

const char * fmtList ( ) const

Retrieve a formats list from this media

Returns
Comma separated list of media formats (from formats list, current format or a default G711, 'alaw,mulaw', list

◆ format()

const String & format ( ) const
inline

Retrieve the current media format

Returns
The current media format

References String::String().

◆ formats()

const String & formats ( ) const
inline

Retrieve the formats set for this media

Returns
Comma separated list of media formats

References String::String().

Referenced by SDPMedia(), and update().

◆ id()

const String & id ( ) const
inline

Retrieve the media id

Returns
The media id

References String::String().

◆ isAudio()

bool isAudio ( ) const
inline

Check if this media type is audio

Returns
True if this media describe an audio one

◆ isModified()

bool isModified ( ) const
inline

Check if a media parameter changed

Returns
True if a media changed

◆ isStarted()

bool isStarted ( ) const
inline

Check if media is started

Returns
True if started, false otherwise

◆ isVideo()

bool isVideo ( ) const
inline

Check if this media type is video

Returns
True if this media describe a video one

◆ keepRtp()

void keepRtp ( const SDPMedia & other)

Copy RTP related data from old media

Parameters
otherSource media

References SDPMedia().

◆ localChanged()

bool localChanged ( ) const
inline

Check if local part of this media changed

Returns
True if local part of this media changed

◆ localCrypto()

const String & localCrypto ( ) const
inline

Retrieve local crypto description

Returns
Local crypto description

References String::String().

◆ localPort()

const String & localPort ( ) const
inline

Retrieve the local media port

Returns
The local media port

References String::String().

◆ mappings() [1/2]

const String & mappings ( ) const
inline

Retrieve rtp payload mappings

Returns
Rtp payload mappings

References String::String().

Referenced by payloadMapping().

◆ mappings() [2/2]

void mappings ( const char * newMap)
inline

Set rtp payload mappings for this media

Parameters
newMapNew rtp payload mappings

◆ parameter() [1/2]

void parameter ( const char * name,
const char * value,
bool append )

Add or replace a parameter by name and value, set the modified flag

Parameters
nameParameter name
valueParameter value
appendTrue to append, false to replace

References String::append().

◆ parameter() [2/2]

void parameter ( NamedString * param,
bool append )

Add or replace a parameter, set the modified flag

Parameters
paramThe parameter
appendTrue to append, false to replace

References String::append().

◆ payloadMapping()

static int payloadMapping ( const String & mappings,
const String & fmt )
static

Retrieve format mapping to payload

Parameters
mappingsMappings list
fmtFormat name
Returns
-1:incorrect mapping value, -2:format not found, payload number otherwise (>=0)

References mappings(), and String::String().

◆ putMedia()

void putMedia ( NamedList & msg,
bool putPort = true )

Put this net media in a parameter list

Parameters
msgDestination list
putPortTrue to add remote media port

References NamedList::NamedList().

◆ remoteCrypto()

const String & remoteCrypto ( ) const
inline

Retrieve remote crypto description

Returns
Remote crypto description

References String::String().

◆ remotePort()

const String & remotePort ( ) const
inline

Retrieve the remote media port

Returns
The remote media port

References String::String().

◆ rfc2833() [1/2]

const String & rfc2833 ( ) const
inline

Retrieve RFC2833 status or payload of this media

Returns
RFC2833 status or payload of this media

References String::String().

◆ rfc2833() [2/2]

void rfc2833 ( int payload)
inline

Set RFC2833 status or payload of this media

Parameters
payloadSDP numeric payload to set. Set it to a negative value to reset RFC2833

References String::boolText().

◆ sameAs()

bool sameAs ( const SDPMedia * other,
bool ignorePort = false,
bool checkStarted = false ) const

Compare this media with another one

Parameters
otherThe media to compare with
ignorePortIgnore differences caused only by port number
checkStartedCheck started related parameters: true when media should be kept if started and matched
Returns
True if both media have the same formats, transport and remote port

References SDPMedia().

◆ securable()

bool securable ( ) const
inline

Check if this media is securable

Returns
True if this media is securable

◆ setLocalChanged()

void setLocalChanged ( bool chg = false)
inline

Set or reset local media changed flag

Parameters
chgThe new value for local media changed flag

◆ setModified()

void setModified ( bool modified = true)
inline

Set or reset media parameter changed flag

Parameters
modifiedThe new value of the media parameter changed flag

◆ suffix()

const String & suffix ( ) const
inline

Retrieve the media suffix (built from type)

Returns
Media suffix

References String::String().

◆ transport()

const String & transport ( ) const
inline

Retrieve the media transport name

Returns
The media transport name

References String::String().

Referenced by SDPMedia().

◆ update() [1/2]

bool update ( const char * formats,
int rport = -1,
int lport = -1,
bool force = false )

Update this media from formats and ports

Parameters
formatsNew media formats
rportOptional remote media port
lportOptional local media port
forceForce updating formats even if incompatible with old ones
Returns
True if media changed

References formats().

◆ update() [2/2]

void update ( const NamedList & msg,
bool pickFormat )

Update from a chan.rtp message (rtp id and local port)

Parameters
msgThe list of parameters
pickFormatTrue to update media format(s) from the list

References NamedList::NamedList().


The documentation for this class was generated from the following file: