Yate
Public Types | Public Member Functions | Protected Member Functions | List of all members
RTPSession Class Reference

Full RTP session. More...

#include <yatertp.h>

Inheritance diagram for RTPSession:
UDPSession Mutex RTPProcessor Lockable GenObject RTPDebug

Public Types

enum  Direction { FullStop = 0 , RecvOnly = 1 , SendOnly = 2 , SendRecv = 3 }
 

Public Member Functions

 RTPSession (DebugEnabler *dbg=0, const char *traceId=0)
 
virtual ~RTPSession ()
 
virtual void getStats (String &stats) const
 
virtual void rtpData (const void *data, int len)
 
virtual void rtcpData (const void *data, int len)
 
virtual bool rtpRecvData (bool marker, unsigned int timestamp, const void *data, int len)
 
virtual bool rtpRecvEvent (int event, char key, int duration, int volume, unsigned int timestamp)
 
virtual void rtpNewPayload (int payload, unsigned int timestamp)
 
virtual void rtpNewSSRC (u_int32_t newSsrc, bool marker)
 
virtual RTPSendercreateSender ()
 
virtual RTPReceivercreateReceiver ()
 
virtual CiphercreateCipher (const String &name, Cipher::Direction dir)
 
virtual bool checkCipher (const String &name)
 
bool rtpSend (bool marker, int payload, unsigned int timestamp, const void *data, int len)
 
bool rtpSendData (bool marker, unsigned int timestamp, const void *data, int len)
 
bool rtpSendEvent (int event, int duration, int volume=0, unsigned int timestamp=0)
 
bool rtpSendKey (char key, int duration, int volume=0, unsigned int timestamp=0)
 
u_int32_t ioPacketsLost () const
 
int padding () const
 
bool padding (int chunk)
 
void setDejitter (unsigned int mindelay=20, unsigned int maxdelay=50)
 
virtual void transport (RTPTransport *trans)
 
RTPSendersender () const
 
void sender (RTPSender *send)
 
RTPReceiverreceiver () const
 
void receiver (RTPReceiver *recv)
 
Direction direction () const
 
bool direction (Direction dir)
 
bool addDirection (Direction dir)
 
bool delDirection (Direction dir)
 
bool dataPayload (int type)
 
bool eventPayload (int type)
 
bool silencePayload (int type)
 
bool localAddr (SocketAddr &addr, bool rtcp=true)
 
RTPSecuresecurity () const
 
void security (RTPSecure *secure)
 
void setReports (int interval)
 
virtual void getStats (NamedList &stats) const
 
virtual void incWrongSrc ()
 
void setWarnSeq (bool on)
 
void initDebugData (const NamedList &params)
 
- Public Member Functions inherited from UDPSession
virtual ~UDPSession ()
 
virtual RTPTransportcreateTransport ()
 
bool initTransport ()
 
bool initGroup (int msec=0, Thread::Priority prio=Thread::Normal, const String &affinity=String::empty())
 
bool remoteAddr (SocketAddr &addr, bool sniff=false)
 
bool setBuffer (int bufLen=4096)
 
bool setTOS (int tos)
 
SocketrtpSock ()
 
bool drillHole ()
 
void setTimeout (int interval)
 
RTPTransporttransport () const
 
virtual void transport (RTPTransport *trans)
 
- Public Member Functions inherited from RTPProcessor
 RTPProcessor (DebugEnabler *dbg=0, const char *traceId=0)
 
virtual ~RTPProcessor ()
 
RTPGroupgroup () const
 
virtual void rtpData (const void *data, int len)
 
virtual void rtcpData (const void *data, int len)
 
virtual void getStats (String &stats) const
 
virtual void incWrongSrc ()
 
unsigned int wrongSrc ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from RTPDebug
 RTPDebug (DebugEnabler *dbg, const char *traceId)
 
 RTPDebug (RTPSession *session)
 
DebugEnablerdbg () const
 
const StringdbgTraceId () const
 
- Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 
 Mutex (const Mutex &original)
 
 ~Mutex ()
 
Mutexoperator= (const Mutex &original)
 
virtual bool lock (long maxwait=-1)
 
virtual bool unlock ()
 
virtual bool locked () const
 
const char * owner () const
 
bool recursive () const
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool lock (long maxwait=-1)=0
 
virtual bool unlock ()=0
 
virtual bool locked () const =0
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Protected Member Functions

virtual void timerTick (const Time &when)
 
void sendRtcpReport (const Time &when)
 
void sendRtcpBye ()
 
- Protected Member Functions inherited from UDPSession
 UDPSession (DebugEnabler *dbg=0, const char *traceId=0)
 
virtual void timeout (bool initial)
 
- Protected Member Functions inherited from RTPProcessor
void group (RTPGroup *newgrp)
 
virtual void timerTick (const Time &when)=0
 
- Protected Member Functions inherited from RTPDebug
void setDebug (DebugEnabler *dbg, const char *traceId)
 

Additional Inherited Members

- 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 ()
 
- Static Public Member Functions inherited from Mutex
static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 
- Protected Attributes inherited from UDPSession
RTPTransportm_transport
 
u_int64_t m_timeoutTime
 
u_int64_t m_timeoutInterval
 
- Protected Attributes inherited from RTPProcessor
unsigned int m_wrongSrc
 
- Protected Attributes inherited from RTPDebug
DebugEnablerm_dbg
 
String m_traceId
 

Detailed Description

Full RTP session.

An unidirectional or bidirectional RTP session

Member Enumeration Documentation

◆ Direction

enum Direction

Direction of the session

Constructor & Destructor Documentation

◆ RTPSession()

RTPSession ( DebugEnabler dbg = 0,
const char *  traceId = 0 
)

Default constructor, creates a detached session

Parameters
dbgSession DebugEnabler
traceIdSession trace ID

◆ ~RTPSession()

virtual ~RTPSession ( )
virtual

Destructor - shuts down the session and destroys the transport

Member Function Documentation

◆ addDirection()

bool addDirection ( Direction  dir)
inline

Add a direction of this session. A transport must exist for this method to succeed.

Parameters
dirNew Direction to add for this session
Returns
True if direction was set, false if a failure occured

◆ checkCipher()

virtual bool checkCipher ( const String name)
virtual

Check if a cipher is supported for SRTP

Parameters
nameName of the cipher to check
Returns
True if the specified cipher is supported

◆ createCipher()

virtual Cipher * createCipher ( const String name,
Cipher::Direction  dir 
)
virtual

Create a cipher when required for SRTP

Parameters
nameName of the cipher to create
dirDirection the cipher must be able to handle
Returns
Pointer to newly allocated Cipher or NULL

◆ createReceiver()

virtual RTPReceiver * createReceiver ( )
virtual

Create a new RTP receiver for this session. Override this method to create objects derived from RTPReceiver.

Returns
Pointer to the new receiver or NULL on failure

◆ createSender()

virtual RTPSender * createSender ( )
virtual

Create a new RTP sender for this session. Override this method to create objects derived from RTPSender.

Returns
Pointer to the new sender or NULL on failure

◆ dataPayload()

bool dataPayload ( int  type)

Set the data payload type for both receiver and sender.

Parameters
typePayload type, -1 to disable
Returns
True if changed, false if invalid payload type

◆ delDirection()

bool delDirection ( Direction  dir)
inline

Delete a direction of this session. A transport must exist for this method to succeed.

Parameters
dirDirection to remove for this session
Returns
True if direction was set, false if a failure occured

◆ direction() [1/2]

Direction direction ( ) const
inline

Get the direction of this session

Returns
Session's direction as a Direction enum

◆ direction() [2/2]

bool direction ( Direction  dir)

Set the direction of this session. A transport must exist for this method to succeed.

Parameters
dirNew Direction for this session
Returns
True if direction was set, false if a failure occured

◆ eventPayload()

bool eventPayload ( int  type)

Set the event payload type for both receiver and sender.

Parameters
typePayload type, -1 to disable
Returns
True if changed, false if invalid payload type

◆ getStats() [1/2]

virtual void getStats ( NamedList stats) const
virtual

Put the collected statistical data

Parameters
statsNamedList to populate with the data

◆ getStats() [2/2]

virtual void getStats ( String stats) const
virtual

Retrieve MGCP P: style comma separated session parameters

Parameters
statsString to append parameters to

Reimplemented from RTPProcessor.

◆ incWrongSrc()

virtual void incWrongSrc ( )
virtual

Increase the counter for number of RTP packets received from a wrong source

Reimplemented from RTPProcessor.

◆ initDebugData()

void initDebugData ( const NamedList params)
inline

Initialize data debug

Parameters
paramsParameters list

◆ ioPacketsLost()

u_int32_t ioPacketsLost ( ) const
inline

Retrieve the number of lost packets in current received

Returns
Number of packets in sequence gaps

◆ localAddr()

bool localAddr ( SocketAddr addr,
bool  rtcp = true 
)
inline

Set the local network address of the RTP transport of this session

Parameters
addrNew local RTP transport address
rtcpEnable RTCP in this session
Returns
True if address set, false if a failure occured

◆ padding() [1/2]

int padding ( ) const
inline

Get the payload padding size

Returns
Chunk size to pad the payload to a multiple of

◆ padding() [2/2]

bool padding ( int  chunk)
inline

Set the padding to a multiple of a data chunk

Parameters
chunkSize to pad the payload to a multiple of
Returns
True if the new chunk size is valid

◆ receiver() [1/2]

RTPReceiver * receiver ( ) const
inline

Get the RTP/RTCP receiver of this session

Returns
A pointer to the RTPReceiver of this session

◆ receiver() [2/2]

void receiver ( RTPReceiver recv)

Set the RTP/RTCP receiver of this session

Parameters
recvA pointer to the new RTPReceiver of this session or NULL

◆ rtcpData()

virtual void rtcpData ( const void *  data,
int  len 
)
virtual

This method is called to process a RTCP packet.

Parameters
dataPointer to raw RTCP data
lenLength of the data packet

Reimplemented from RTPProcessor.

◆ rtpData()

virtual void rtpData ( const void *  data,
int  len 
)
virtual

This method is called to process a RTP packet.

Parameters
dataPointer to raw RTP data
lenLength of the data packet

Reimplemented from RTPProcessor.

◆ rtpNewPayload()

virtual void rtpNewPayload ( int  payload,
unsigned int  timestamp 
)
virtual

Method called for unknown payload types just before attempting to call rtpRecvData(). This is a good opportunity to change the payload type and continue.

Parameters
payloadPayload number
timestampSampling instant of the unexpected packet data

◆ rtpNewSSRC()

virtual void rtpNewSSRC ( u_int32_t  newSsrc,
bool  marker 
)
virtual

Method called when a packet with an unexpected SSRC is received just before processing further. This is a good opportunity to change the SSRC and continue

Parameters
newSsrcSSRC received in packet
markerTrue if marker bit is set in the RTP packet

◆ rtpRecvData()

virtual bool rtpRecvData ( bool  marker,
unsigned int  timestamp,
const void *  data,
int  len 
)
virtual

Process one RTP data packet

Parameters
markerSet to true if the marker bit is set
timestampSampling instant of the packet data
dataPointer to data block to process
lenLength of the data block in bytes
Returns
True if data was handled

◆ rtpRecvEvent()

virtual bool rtpRecvEvent ( int  event,
char  key,
int  duration,
int  volume,
unsigned int  timestamp 
)
virtual

Process one RTP event

Parameters
eventReceived event code
keyReceived key (for events 0-16) or zero
durationDuration of the event as number of samples
volumeAttenuation of the tone, zero for don't care
timestampSampling instant of the initial packet data
Returns
True if data was handled

◆ rtpSend()

bool rtpSend ( bool  marker,
int  payload,
unsigned int  timestamp,
const void *  data,
int  len 
)
inline

Send one RTP payload packet

Parameters
markerSet to true if the marker bit must be set
payloadPayload number
timestampSampling instant of the packet data
dataPointer to data block to send
lenLength of the data block
Returns
True if data sending was attempted

◆ rtpSendData()

bool rtpSendData ( bool  marker,
unsigned int  timestamp,
const void *  data,
int  len 
)
inline

Send one RTP data packet

Parameters
markerSet to true if the marker bit must be set
timestampSampling instant of the packet data
dataPointer to data block to send
lenLength of the data block
Returns
True if data sending was attempted

◆ rtpSendEvent()

bool rtpSendEvent ( int  event,
int  duration,
int  volume = 0,
unsigned int  timestamp = 0 
)
inline

Send one RTP event

Parameters
eventEvent code to send
durationDuration of the event as number of samples
volumeAttenuation of the tone, zero for don't care
timestampSampling instant of the packet data, zero to use current
Returns
True if data sending was attempted

◆ rtpSendKey()

bool rtpSendKey ( char  key,
int  duration,
int  volume = 0,
unsigned int  timestamp = 0 
)
inline

Send one RTP key event

Parameters
keyKey to send
durationDuration of the event as number of samples
volumeAttenuation of the tone, zero for don't care
timestampSampling instant of the packet data, zero to use current
Returns
True if data sending was attempted

◆ security() [1/2]

RTPSecure * security ( ) const
inline

Get the stored security provider or of the sender

Returns
A pointer to the RTPSecure or NULL

◆ security() [2/2]

void security ( RTPSecure secure)

Store a security provider for the sender

Parameters
securePointer to the new RTPSecure or NULL

◆ sender() [1/2]

RTPSender * sender ( ) const
inline

Get the RTP/RTCP sender of this session

Returns
A pointer to the RTPSender of this session

◆ sender() [2/2]

void sender ( RTPSender send)

Set the RTP/RTCP sender of this session

Parameters
sendA pointer to the new RTPSender of this session or NULL

◆ sendRtcpBye()

void sendRtcpBye ( )
protected

Send a RTCP BYE when the sender is stopped or replaced

◆ sendRtcpReport()

void sendRtcpReport ( const Time when)
protected

Send a RTCP report

Parameters
whenTime to use as base for timestamps

◆ setDejitter()

void setDejitter ( unsigned int  mindelay = 20,
unsigned int  maxdelay = 50 
)
inline

Allocate and set a new dejitter buffer for the receiver in the session

Parameters
mindelayMinimum length of the dejitter buffer in microseconds
maxdelayMaximum length of the dejitter buffer in microseconds

◆ setReports()

void setReports ( int  interval)

Set the RTCP report interval

Parameters
intervalAverage interval between reports in msec, zero to disable

◆ setWarnSeq()

void setWarnSeq ( bool  on)
inline

Set the packet with invalid sequence warn mode

Parameters
onTrue to show a message at DebugWarn level, false to show at DebugInfo level

◆ silencePayload()

bool silencePayload ( int  type)

Set the silence payload type for both receiver and sender.

Parameters
typePayload type, -1 to disable
Returns
True if changed, false if invalid payload type

◆ timerTick()

virtual void timerTick ( const Time when)
protectedvirtual

Method called periodically to push any asynchronous data or statistics

Parameters
whenTime to use as base in all computing

Implements RTPProcessor.

◆ transport()

virtual void transport ( RTPTransport trans)
virtual

Set the RTP/RTCP transport of data handled by this session

Parameters
transA pointer to the new RTPTransport for this session

Reimplemented from UDPSession.


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