Yate
MGCPMessage Class Reference

An MGCP command or response. More...

#include <yatemgcp.h>

Inheritance diagram for MGCPMessage:
RefObject GenObject

Public Member Functions

 MGCPMessage (MGCPEngine *engine, const char *name, const char *ep, const char *ver="MGCP 1.0")
 
 MGCPMessage (MGCPTransaction *trans, unsigned int code, const char *comment=0)
 
virtual ~MGCPMessage ()
 
bool valid () const
 
const Stringname () const
 
int code () const
 
const Stringversion () const
 
const Stringcomment () const
 
bool isCommand () const
 
bool isResponse () const
 
bool isAck () const
 
unsigned int transactionId () const
 
const StringendpointId () const
 
void toString (String &dest) const
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static bool parse (MGCPEngine *engine, ObjList &dest, const unsigned char *buffer, unsigned int len, const char *sdpType="application/sdp")
 
- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- 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 ()
 

Public Attributes

NamedList params
 
ObjList sdp
 

Protected Member Functions

 MGCPMessage (MGCPEngine *engine, const char *name, int code, unsigned int transId, const char *epId, const char *ver)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Friends

class MGCPTransaction
 

Detailed Description

An MGCP command or response.

This class holds an MGCP message, either command or response, along with its parameters. The

Constructor & Destructor Documentation

◆ MGCPMessage() [1/3]

MGCPMessage ( MGCPEngine * engine,
const char * name,
const char * ep,
const char * ver = "MGCP 1.0" )

Constructor. Construct an outgoing command message. A transaction id will be requested from the endpoint's engine. The message will be invalidated if failed to get a transaction id or the command name is unknown

Parameters
engineThe engine sending this message
nameCommand name
epThe id of the endpoint issuing this command
verThe protocol version to use

References name().

Referenced by MGCPMessage().

◆ MGCPMessage() [2/3]

MGCPMessage ( MGCPTransaction * trans,
unsigned int code,
const char * comment = 0 )

Constructor. Construct an outgoing response message The message will be invalidated if failed to get a transaction id or the code is greater then 999

Parameters
transThe transaction to respond
codeThe response code ranging from 0 to 999
commentOptional response comment

References code(), and comment().

◆ ~MGCPMessage()

virtual ~MGCPMessage ( )
virtual

Destructor

◆ MGCPMessage() [3/3]

MGCPMessage ( MGCPEngine * engine,
const char * name,
int code,
unsigned int transId,
const char * epId,
const char * ver )
protected

Constructor. Used by the parser to construct an incoming message

Parameters
engineThe engine receiving this message
nameCommand name or response comment
codeThe response code in the range 0 to 999 or -1 if the received message is a command
transIdThe id of the transaction owning this message
epIdThe id of the endpoint issuing this command
verThe protocol version

References code(), MGCPMessage(), name(), and params.

Member Function Documentation

◆ code()

int code ( ) const
inline

Get the response code if this is a response message

Returns
The response code contained in this message

Referenced by isAck(), isCommand(), isResponse(), MGCPMessage(), and MGCPMessage().

◆ comment()

const String & comment ( ) const
inline

Get the comment from a response message

Returns
The comment of this message

Referenced by MGCPMessage().

◆ endpointId()

const String & endpointId ( ) const
inline

Get the message's endpoint id if this is a command

Returns
The message's endpoint id if this is a command

◆ isAck()

bool isAck ( ) const
inline

Check if this message is a response ACK (code is between 0 and 99, including the margins)

Returns
True if this message is a response ACK

References code().

◆ isCommand()

bool isCommand ( ) const
inline

Check if this is a command (code is a negative value)

Returns
True if this message is a command

References code().

◆ isResponse()

bool isResponse ( ) const
inline

Check if this is a response message (code is greater then or equal to 100)

Returns
True if this message is a response

References code().

◆ name()

const String & name ( ) const
inline

Get the command name or response code text representation of this message

Returns
The command name or response text representation of this message

Referenced by MGCPMessage(), and MGCPMessage().

◆ parse()

static bool parse ( MGCPEngine * engine,
ObjList & dest,
const unsigned char * buffer,
unsigned int len,
const char * sdpType = "application/sdp" )
static

Parse a received buffer according to RFC 3435. Command and protocol names are converted to upper case. The enpoint id is converted to lower case. Message parameter names are converted to lower case if the engine's flag is set. Message parameter values and SDP(s) are stored unchanged

Parameters
engineThe receiving engine
destThe list of received messages
bufferThe buffer to parse
lenThe buffer length
sdpTypeThe MIME SDP content type if the message contains any SDP body
Returns
False on failure, true on success. If failed, the destination list may contain a response message to be sent

◆ toString()

void toString ( String & dest) const

Convert this message to a string representation to be sent to the remote endpoint or printed to output

Parameters
destDestination string

◆ transactionId()

unsigned int transactionId ( ) const
inline

Get the message's transaction id

Returns
The message's transaction id

◆ valid()

bool valid ( ) const
inline

Check if this is a valid message

Returns
True if this is a valid message

◆ version()

const String & version ( ) const
inline

Get the protocol version of a command message

Returns
The protocol version of this message

Member Data Documentation

◆ params

NamedList params

Keep the message parameters

Referenced by MGCPMessage().

◆ sdp

ObjList sdp

Keep the SDP(s) carried by this message as MimeSdpBody object(s)


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