# RTPDataQueue Class Reference
[Generic RTP input/output queues.]

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

`#include <ioqueue.h>`

Inheritance diagram for RTPDataQueue:

List of all members.

## Public Types

enum | Tos { tosBestEffort, tosEnhanced }
| rtp.h cc++/rtp.h More...

## Public Member Functions

void | setTypeOfService (Tos tos)
| Specify the kind of service the application expects to use.
void | enableStack ()
| Enable packet queue processing in the stack.
void | disableStack ()
| Disable packet queue processing in the stack.
bool | isActive () const
| Get active connection state flag.
uint32 | getCurrentTimestamp () const
| Get the timestamp that should be given for a packet whose payload sampling instant corresponds to the current system time.
void | setSessionBandwidth (uint32 bw)
| Specify the bandwidth of the current session.
uint32 | getDefaultSessionBandwidth () const
uint32 | getSessionBandwidth () const
void | setTimeclock ()
| Set the packet timeclock for synchronizing timestamps.
timeout_t | getTimeclock () const
| Get the packet timeclock for synchronizing timestamps.

## Protected Member Functions

| RTPDataQueue (uint32 size=defaultMembersHashSize)
| Constructor.
| RTPDataQueue (uint32 *ssrc, uint32 size=defaultMembersHashSize)
| Using this constructor you can start a session with the given ssrc, instead of the usual randomly generated one.
virtual | ~RTPDataQueue ()
| The queue destructor flushes the queue and stops all services.
virtual void | timerTick ()
| A plugin point for timer tick driven events.
void | renewLocalSSRC ()
void | endQueue ()
| This method ends the queue.
virtual bool | isPendingData (microtimeout_t timeout)=0
| This function is used to check for and schedule against arriving packets based on the derived connection type.

## Detailed Description

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

The queue manages both incoming and outgoing RTP packets, as well as synchronization and transmission/reception timers. By making the queue handler a seperate base class it becomes possible to define RTP classes for RTP profiles and sessions of different types.

Outgoing packets are sent via the OutgoingDataQueue::putData method.

Incoming packets can be retrieved via IncomingDataQueue::getData method.

Author:
  David Sugar <dyfet@ostel.com> RTP data queue handler.

## Member Enumeration Documentation

enum RTPDataQueue::Tos

rtp.h cc++/rtp.h

Type of network service the application uses.

If the application uses enhanced network service, for instance Integrated Services or Differentiated Services, it has not to ensure fair competition with TCP, provided that the requested service is actually being delivered. Whenever the application uses best-effort service or the requested enhanced service is not actually being delivered, it has to ensure fair competition with TCP. By default, best-effot is assumed.

Note:
  Although not required, RTP packets are always sent on top of UDP segments. No other underlying transport protocol is supported at present.

Enumerator:

  tosBestEffort | Best-effort network service.
  tosEnhanced | Enhanced network service.

## Constructor & Destructor Documentation

RTPDataQueue::RTPDataQueue | ( | uint32 | size = `defaultMembersHashSize` ) | `[protected]`

Constructor.

This will generate a random application SSRC identifier.

Parameters:

  size | an estimation of the number of participants in the session

RTPDataQueue::RTPDataQueue | ( | uint32 * | ssrc,
|  | uint32 | size = `defaultMembersHashSize`
| ) |  | `[protected]`

Using this constructor you can start a session with the given ssrc, instead of the usual randomly generated one.

This is necessary when you need to initiate several sessions having the same SSRC identifier, for instance, to implement layered encoding, in which case each layer is managed through a different session but all sessions share the same SSRC identifier.

Warning:
  This doesn't seem to be a good solution

Parameters:

  ssrc | Synchronization SouRCe identifier for this session
  size | an estimation of the number of participants in the session

virtual RTPDataQueue::~RTPDataQueue | ( | ) | `[inline, protected, virtual]`

The queue destructor flushes the queue and stops all services.

## Member Function Documentation

void RTPDataQueue::disableStack | ( | ) | `[inline]`

Disable packet queue processing in the stack.

void RTPDataQueue::enableStack | ( | ) | `[inline]`

Enable packet queue processing in the stack.

This method will not any thread of execution.

void RTPDataQueue::endQueue | ( | ) | `[protected]`

This method ends the queue.

uint32 RTPDataQueue::getCurrentTimestamp | ( | ) | const

Get the timestamp that should be given for a packet whose payload sampling instant corresponds to the current system time.

The timestamp applications should provide for each packet represents the sampling instant of its payload and should not be a reading of the system clock. Nevertheless, the internal operation of the RTP stack relies on the accuracy of the provided timestamp, since several computations assume that there is a certain degree of correspondence between the timestamp and the system clock.

It is recommended that applications use this method in order to periodically adjust the RTP timestamp.

In particular, it is advisable getting the timestamp corresponding to the first sampling instant or any instant after a period of inactivity through a call to this method.

Applications should use the nominal sampling or any other value provided by the coder in order to compute the next timestamps with minimum computational requirement.

For instance, an application using an RTP profile that specifies a fixed sampling rate of 8 Khz with eight bits per sample, continuously transmitting audio blocks 80 octets long, would transmit 100 packets every second. Every packet would carry a timestamp 80 units greater than the previous one. So, the first timestamp would be obtained from this method, whereas the following ones would be computed adding 80 every time. Also the timestamp should be increased for every block whether it is put in the queue or dropped.

The aforementioned increment can be obtained from the RTPDataQueue::getTimestampIncrement() method rather than computing it by hand in the application.

Note:
  Frame based applications must follow a specific timestamping method, probably specified in a profile.
  You should take into account that by default ccRTP assumes that the application begins sampling at the queue creation time. Moreover, the first sampling instant is assigned a "user visible" timestamp of 0, although the RTP stack will then add internally a ramdom offset unknown to the application. That is to say, the application may count samples from 0 in order to get the timestamp for the next packet, provided that the first sampling instant is the same as the queue creation time. Nevertheless, this simpler way of starting will not be as accurate as it would be if the application got at least the first timestamp through getCurrentTimestamp. We provide this option since ccRTP interface is evolving, but we admit that it is ugly, we could remove this option or even replace uint32 timestamps with a restrictively regulated object; suggestions are gladly welcomed

uint32 RTPDataQueue::getDefaultSessionBandwidth | ( | ) | const`[inline]`

uint32 RTPDataQueue::getSessionBandwidth | ( | ) | const`[inline]`

timeout_t RTPDataQueue::getTimeclock | ( | ) | const`[inline]`

Get the packet timeclock for synchronizing timestamps.

Returns:
  runtime in milliseconds since last set.

bool RTPDataQueue::isActive | ( | ) | const`[inline]`

Get active connection state flag.

Returns:
  true if connection "active".

virtual bool RTPDataQueue::isPendingData | ( | microtimeout_t | timeout ) | `[protected, pure 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 microseconds to wait.

Implemented in RTPDuplex.

void RTPDataQueue::renewLocalSSRC | ( | ) | `[inline, protected, virtual]`

Reimplemented from IncomingDataQueue.

void RTPDataQueue::setSessionBandwidth | ( | uint32 | bw ) | `[inline]`

Specify the bandwidth of the current session.

Parameters:

  bw | bandwidth of the current session, in bits/s.

See also:
  AVPQueue::setControlBandwidth()

void RTPDataQueue::setTimeclock | ( | ) | `[inline]`

Set the packet timeclock for synchronizing timestamps.

void RTPDataQueue::setTypeOfService | ( | Tos | tos ) | `[inline]`

Specify the kind of service the application expects to use.

Parameters:

  tos | type of service the application expects to use

Note:
  If enhanced service is specified but packet loss is high (the requested service does not appear to actually be delivered) ccRTP defaults to best-effort suitable behaviour: guarantee fair competition with TCP.

virtual void RTPDataQueue::timerTick | ( | ) | `[inline, protected, virtual]`

A plugin point for timer tick driven events.

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

- ioqueue.h