Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RTPQueue Class Reference

A thread serviced packet queue handler for building different kinds of RTP protocol systems. RTP protocol queue handler. More...

#include <rtp.h>

Inheritance diagram for RTPQueue:

Thread RTPDuplex RTPSocket List of all members.

Public Methods

 RTPQueue (int pri)
 ~RTPQueue ()
void putPacket (unsigned long stamp, payload_t payload, unsigned char *data = NULL, unsigned len = 0)
 This is used to create a data packet in the send queue. More...

unsigned getPacket (unsigned long stamp, unsigned char *data, unsigned max)
 Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer. More...

payload_t getPayload (unsigned long timestamp)
 Get the payload type of a specific packet by timestamp. More...

unsigned setPartial (unsigned long timestamp, unsigned char *data, unsigned offset, unsigned max)
 Set partial data for an already queued packet. More...

unsigned getPartial (unsigned long timestamp, unsigned char *data, unsigned int offset, unsigned int max)
 Get partial data from a packet. More...

bool isActive (void)
 Get active connection state flag. More...

void setTimeout (timeout_t t)
 Set the default scheduling timeout to use when no data packets are waiting to be sent. More...

void setExpired (timeout_t t)
 Set the "expired" timer for expiring packets pending in the send queue which have gone unsent and are already "too late" to be sent now. More...

void setSegmentSize (unsigned size)
 Set maximum packet segment size before fragmenting sends. More...

bool isComplete (void)
 Is last packet processed "complete" or are sequences missing? More...

bool isMarked (void)
 Is last packet processed "marked" (used to signal end on multi-sequence sends). More...


Protected Methods

virtual time_t getControlTimer (void)
 A plugin for RTCP packet scheduling based on the number of contributing sources in a RTP session. More...

virtual unsigned getControl (void)
 A plugin point for picking up incoming RTCP packets if they are waiting. More...

virtual void Bye (void)
 A plugin point for posting of BYE messages.

virtual void putControl (void)
 A plugin point for posting of RTCP messages.

timeout_t getTimeout (void)
 This computes the timeout period for scheduling transmission of the next packet at the "head" of the send buffer. More...

virtual bool isPendingArrival (timeout_t timeout)
 This function is used to check for and schedule against arriving packets based on the derived connection type. More...

int sendPacket (void)
 This function is used by the service thread to process the next outgoing packet pending in the send queue. More...

virtual int writePacket (unsigned char *packet, unsigned len)
 This function performs the physical I/O for writing a packet to the destination. More...

int recvPacket (void)
 This function is used by the service thread to process the next incoming packet and place it in the receive list. More...

virtual int readPacket (unsigned char *buffer, unsigned len)
 This function performs the physical I/O for reading a packet from the source. More...

RTPPacketgetWaiting (unsigned long timestamp)
 This is used to fetch a packet in the receive queue and to expire packets older than the current timestamp. More...

void endQueue (void)
 This function ends the queues and service threads.


Protected Attributes

struct timeval starttimer
volatile bool active

Detailed Description

A thread serviced packet queue handler for building different kinds of RTP protocol systems. RTP protocol queue handler.

By making the queue handler a seperate base class it becomes possible to define RTP classes for RTP profiles and sessions of different types.

Author(s):
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

RTPQueue::RTPQueue ( int pri )
 

RTPQueue::~RTPQueue ( ) [inline]
 


Member Function Documentation

void RTPQueue::Bye ( void ) [inline, protected, virtual]
 

A plugin point for posting of BYE messages.

void RTPQueue::endQueue ( void ) [protected]
 

This function ends the queues and service threads.

unsigned RTPQueue::getControl ( void ) [inline, protected, virtual]
 

A plugin point for picking up incoming RTCP packets if they are waiting.

This is used as a simple "check"; if packets are pending, they are processed in the derived class. A timeout for the maximum interval since the last RTCP packet had been received is also returned. This is checked once a second.

Returns:
number of seconds since last RTCP arrival.

time_t RTPQueue::getControlTimer ( void ) [inline, protected, virtual]
 

A plugin for RTCP packet scheduling based on the number of contributing sources in a RTP session.

The default interval is to use 5 seconds for posting RTCP reports. If no RTCP interface is used, this should return 0.

Returns:
number of seconds in RTCP intervals.

unsigned RTPQueue::getPacket ( unsigned long stamp,
unsigned char * data,
unsigned max )
 

Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer.

Returns:
number of packet data bytes retrieved.
Parameters:
timestamp   of packet desired.
data   buffer to copy into.
maximum   data size.

unsigned RTPQueue::getPartial ( unsigned long timestamp,
unsigned char * data,
unsigned int offset,
unsigned int max )
 

Get partial data from a packet.

This is often used to support oddball hardware that has unusual or non-standard codec buffering intervals.

Returns:
number of packet data bytes retrieved.
Parameters:
timestamp   of packet desired.
data   buffer to copy into.
offset   to copy from.
maximum   data size.

payload_t RTPQueue::getPayload ( unsigned long timestamp )
 

Get the payload type of a specific packet by timestamp.

Returns:
payload of specified packet if found.
Parameters:
timestamp   to find.

timeout_t RTPQueue::getTimeout ( void ) [protected]
 

This computes the timeout period for scheduling transmission of the next packet at the "head" of the send buffer.

If no packets are waiting, a default timeout is used. This actually forms the "isPending()" timeout of the rcp receiver in the service thread.

Returns:
timeout until next packet is scheduled to send.

RTPPacket * RTPQueue::getWaiting ( unsigned long timestamp ) [protected]
 

This is used to fetch a packet in the receive queue and to expire packets older than the current timestamp.

Returns:
packet buffer object for current timestamp if found.
Parameters:
timestamp   requested.

bool RTPQueue::isActive ( void ) [inline]
 

Get active connection state flag.

Returns:
true if connection "active".

bool RTPQueue::isComplete ( void ) [inline]
 

Is last packet processed "complete" or are sequences missing?

Returns:
true if complete.

bool RTPQueue::isMarked ( void ) [inline]
 

Is last packet processed "marked" (used to signal end on multi-sequence sends).

Returns:
true if marked.

bool RTPQueue::isPendingArrival ( timeout_t timeout ) [protected, virtual]
 

This function is used to check for and schedule against arriving packets based on the derived connection type.

Returns:
true if packet waiting for processing.
Parameters:
number   of milliseconds to wait.

Reimplemented in RTPSocket, and RTPDuplex.

void RTPQueue::putControl ( void ) [inline, protected, virtual]
 

A plugin point for posting of RTCP messages.

void RTPQueue::putPacket ( unsigned long stamp,
payload_t payload,
unsigned char * data = NULL,
unsigned len = 0 )
 

This is used to create a data packet in the send queue.

Sometimes a "NULL" or empty packet will be used instead, and these are known as "silent" packets. "Silent" packets are used simply to "push" the scheduler along more accurately by giving the appearence that a next packet is waiting to be sent and to provide a valid timestamp for that packet.

Parameters:
payload   format of this packet.
timestamp   for expected send time of packet.
data   value or NULL if special "silent" packet.
length, may   be 0 to indicate a default by payload type.

int RTPQueue::readPacket ( unsigned char * buffer,
unsigned len ) [protected, virtual]
 

This function performs the physical I/O for reading a packet from the source.

It is a virtual that is overriden in the derived class.

Returns:
number of bytes read.
Parameters:
packet   read buffer.
length   of data to read.

Reimplemented in RTPSocket, and RTPDuplex.

int RTPQueue::recvPacket ( void ) [protected]
 

This function is used by the service thread to process the next incoming packet and place it in the receive list.

Returns:
number of payload bytes received. <0 if error.

int RTPQueue::sendPacket ( void ) [protected]
 

This function is used by the service thread to process the next outgoing packet pending in the send queue.

Returns:
number of bytes sent. 0 if silent, <0 if error.

void RTPQueue::setExpired ( timeout_t t ) [inline]
 

Set the "expired" timer for expiring packets pending in the send queue which have gone unsent and are already "too late" to be sent now.

Parameters:
timeout   to expire unsent packets in milliseconds.

unsigned RTPQueue::setPartial ( unsigned long timestamp,
unsigned char * data,
unsigned offset,
unsigned max )
 

Set partial data for an already queued packet.

This is often used for multichannel data.

Returns:
number of packet data bytes set.
Parameters:
timestamp   of packet desired.
data   buffer to copy from.
offset   to copy from.
maximum   data size.

void RTPQueue::setSegmentSize ( unsigned size ) [inline]
 

Set maximum packet segment size before fragmenting sends.

Parameters:
maximum   packet size.

void RTPQueue::setTimeout ( timeout_t t ) [inline]
 

Set the default scheduling timeout to use when no data packets are waiting to be sent.

Parameters:
timeout   in milliseconds.

int RTPQueue::writePacket ( unsigned char * buffer,
unsigned len ) [protected, virtual]
 

This function performs the physical I/O for writing a packet to the destination.

It is a virtual that is overriden in the derived class.

Returns:
number of bytes sent.
Parameters:
packet   to write.
length   of data to write.

Reimplemented in RTPSocket, and RTPDuplex.


Member Data Documentation

volatile bool RTPQueue::active [protected]
 

Reimplemented in RTPSocket.

struct timeval RTPQueue::starttimer [protected]
 


The documentation for this class was generated from the following file:
Generated at Fri Dec 15 11:45:38 2000 for CommonC++ by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000