ccRTP 2.1.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
OutgoingDataQueue Class Reference

A generic outgoing RTP data queue supporting multiple destinations. More...

#include <oqueue.h>

Inheritance diagram for OutgoingDataQueue:
Inheritance graph
[legend]
Collaboration diagram for OutgoingDataQueue:
Collaboration graph
[legend]

Data Structures

struct  OutgoingRTPPktLink
 

Public Member Functions

bool addDestination (const InetHostAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0)
 
bool addDestination (const InetMcastAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0)
 
bool forgetDestination (const InetHostAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0)
 
bool forgetDestination (const InetMcastAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0)
 
void addContributor (uint32 csrc)
 Add csrc as the CSRC identifier of a new contributor. More...
 
bool removeContributor (uint32 csrc)
 Remove CSRC from the list of contributors. More...
 
bool isSending () const
 Determine if outgoing packets are waiting to send. More...
 
void putData (uint32 stamp, const unsigned char *data=NULL, size_t len=0)
 This is used to create a data packet in the send queue. More...
 
void sendImmediate (uint32 stamp, const unsigned char *data=NULL, size_t len=0)
 This is used to create a data packet and send it immediately. More...
 
void setPadding (uint8 paddinglen)
 Set padding. More...
 
void setMark (bool mark)
 Set marker bit for the packet in which the next data provided will be send. More...
 
bool getMark () const
 Get wheter the mark bit will be set in the next packet. More...
 
size_t setPartial (uint32 timestamp, unsigned char *data, size_t offset, size_t max)
 Set partial data for an already queued packet. More...
 
microtimeout_t getDefaultSchedulingTimeout () const
 
void setSchedulingTimeout (microtimeout_t to)
 Set the default scheduling timeout to use when no data packets are waiting to be sent. More...
 
microtimeout_t getDefaultExpireTimeout () const
 
void setExpireTimeout (microtimeout_t to)
 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...
 
microtimeout_t getExpireTimeout () const
 
uint32 getSendPacketCount () const
 Get the total number of packets sent so far. More...
 
uint32 getSendOctetCount () const
 Get the total number of octets (payload only) sent so far. More...
 
uint16 getSequenceNumber () const
 Get the sequence number of the next outgoing packet. More...
 
void setOutQueueCryptoContext (CryptoContext *cc)
 Set ouput queue CryptoContext. More...
 
void removeOutQueueCryptoContext (CryptoContext *cc)
 Remove output queue CryptoContext. More...
 
CryptoContextgetOutQueueCryptoContext (uint32 ssrc)
 Get an output queue CryptoContext identified by SSRC. More...
 
size_t getDefaultMaxSendSegmentSize ()
 
void setMaxSendSegmentSize (size_t size)
 Set maximum payload segment size before fragmenting sends. More...
 
size_t getMaxSendSegmentSize ()
 
bool setPayloadFormat (const PayloadFormat &pf)
 Set the payload format in use, for timing and payload type identification purposes. More...
 
uint32 getLocalSSRC () const
 
uint32 getCurrentRTPClockRate () const
 Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU, or 90000 units per second for MP2T). More...
 
PayloadType getCurrentPayloadType () const
 
timeval getInitialTime () const
 

Protected Member Functions

 OutgoingDataQueue ()
 
virtual ~OutgoingDataQueue ()
 
void dispatchImmediate (OutgoingRTPPkt *packet)
 This is used to write the RTP data packet to one or more destinations. More...
 
microtimeout_t getSchedulingTimeout ()
 This computes the timeout period for scheduling transmission of the next packet at the "head" of the send buffer. More...
 
size_t dispatchDataPacket ()
 This function is used by the service thread to process the next outgoing packet pending in the sending queue. More...
 
void setNextSeqNum (uint32 seqNum)
 For thoses cases in which the application requires a method to set the sequence number for the outgoing stream (such as for implementing the RTSP PLAY command). More...
 
uint32 getCurrentSeqNum (void)
 
void setInitialTimestamp (uint32 ts)
 
uint32 getInitialTimestamp ()
 
void purgeOutgoingQueue ()
 
virtual void setControlPeer (const InetAddress &host, tpport_t port)
 
void setLocalSSRC (uint32 ssrc)
 
uint32 getLocalSSRCNetwork () const
 
virtual size_t dispatchBYE (const std::string &)
 A plugin point for posting of BYE messages. More...
 
virtual void renewLocalSSRC ()
 
bool isSingleDestination () const
 Get whether there is only a destination in the list. More...
 
TransportAddressgetFirstDestination () const
 
void lockDestinationList () const
 
void unlockDestinationList () const
 
void writeLockDestinationList () const
 
bool addDestinationToList (const InetAddress &ia, tpport_t data, tpport_t control)
 Locks the object before modifying it. More...
 
bool removeDestinationFromList (const InetAddress &ia, tpport_t dataPort, tpport_t controlPort)
 Locks the object before modifying it. More...
 

Protected Attributes

Mutex cryptoMutex
 
std::list< CryptoContext * > cryptoContexts
 
std::list< TransportAddress * > destList
 

Private Member Functions

virtual void onExpireSend (OutgoingRTPPkt &)
 A hook to filter packets being sent that have been expired. More...
 
virtual void setDataPeer (const InetAddress &host, tpport_t port)
 
virtual size_t sendData (const unsigned char *const buffer, size_t len)
 This function performs the physical I/O for writing a packet to the destination. More...
 

Private Attributes

ThreadLock sendLock
 
OutgoingRTPPktLinksendFirst
 
OutgoingRTPPktLinksendLast
 
uint32 initialTimestamp
 
microtimeout_t schedulingTimeout
 
microtimeout_t expireTimeout
 
struct {
   uint32   packetCount
 
   uint32   octetCount
 
   uint16   sendSeq
 
   uint32   sendSources [16]
 
   uint16   sendCC
 
   uint8   paddinglen
 
   bool   marked
 
   bool   complete
 
   uint32   initialTimestamp
 
   timeval   overflowTime
 
sendInfo
 

Static Private Attributes

static const microtimeout_t defaultSchedulingTimeout = 8000
 Schedule at 8 ms. More...
 
static const microtimeout_t defaultExpireTimeout = 40000
 Packets unsent will expire after 40 ms. More...
 

Detailed Description

A generic outgoing RTP data queue supporting multiple destinations.

Author
Federico Montesino Pouzols fedem.nosp@m.p@al.nosp@m.tern..nosp@m.org

Definition at line 219 of file oqueue.h.

Constructor & Destructor Documentation

OutgoingDataQueue::OutgoingDataQueue ( )
protected

Definition at line 177 of file outqueue.cpp.

virtual OutgoingDataQueue::~OutgoingDataQueue ( )
inlineprotectedvirtual

Definition at line 448 of file oqueue.h.

Member Function Documentation

void OutgoingDataQueue::addContributor ( uint32  csrc)

Add csrc as the CSRC identifier of a new contributor.

This method adds the CSRC identifier to a list of contributors that will be inserted in every packet enqueued from now on.

bool OutgoingDataQueue::addDestination ( const InetHostAddress &  ia,
tpport_t  dataPort = DefaultRTPDataPort,
tpport_t  controlPort = 0 
)

Definition at line 219 of file outqueue.cpp.

bool OutgoingDataQueue::addDestination ( const InetMcastAddress &  ia,
tpport_t  dataPort = DefaultRTPDataPort,
tpport_t  controlPort = 0 
)

Definition at line 233 of file outqueue.cpp.

bool DestinationListHandler::addDestinationToList ( const InetAddress &  ia,
tpport_t  data,
tpport_t  control 
)
protectedinherited

Locks the object before modifying it.

Definition at line 74 of file outqueue.cpp.

virtual size_t RTPQueueBase::dispatchBYE ( const std::string &  )
inlineprotectedvirtualinherited

A plugin point for posting of BYE messages.

Parameters
-reason to leave the RTP session.
Returns
number of octets sent.

Reimplemented in QueueRTCPManager.

Definition at line 228 of file queuebase.h.

size_t OutgoingDataQueue::dispatchDataPacket ( void  )
protected

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

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

Definition at line 549 of file outqueue.cpp.

void OutgoingDataQueue::dispatchImmediate ( OutgoingRTPPkt packet)
protected

This is used to write the RTP data packet to one or more destinations.

It is used by both sendImmediate and by dispatchDataPacket.

Parameters
RTPpacket to send.

Definition at line 505 of file outqueue.cpp.

bool OutgoingDataQueue::forgetDestination ( const InetHostAddress &  ia,
tpport_t  dataPort = DefaultRTPDataPort,
tpport_t  controlPort = 0 
)

Definition at line 247 of file outqueue.cpp.

bool OutgoingDataQueue::forgetDestination ( const InetMcastAddress &  ia,
tpport_t  dataPort = DefaultRTPDataPort,
tpport_t  controlPort = 0 
)

Definition at line 257 of file outqueue.cpp.

PayloadType RTPQueueBase::getCurrentPayloadType ( ) const
inlineinherited

Definition at line 198 of file queuebase.h.

uint32 RTPQueueBase::getCurrentRTPClockRate ( ) const
inlineinherited

Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU, or 90000 units per second for MP2T).

This value depends on what payload format has been selected using setPayloadFormat().

Returns
clock rate in RTP clock units.

Definition at line 195 of file queuebase.h.

uint32 OutgoingDataQueue::getCurrentSeqNum ( void  )
inlineprotected

Definition at line 522 of file oqueue.h.

microtimeout_t OutgoingDataQueue::getDefaultExpireTimeout ( ) const
inline

Definition at line 368 of file oqueue.h.

size_t OutgoingDataQueueBase::getDefaultMaxSendSegmentSize ( )
inlineinherited

Definition at line 259 of file queuebase.h.

microtimeout_t OutgoingDataQueue::getDefaultSchedulingTimeout ( ) const
inline

Definition at line 354 of file oqueue.h.

microtimeout_t OutgoingDataQueue::getExpireTimeout ( ) const
inline

Definition at line 382 of file oqueue.h.

TransportAddress* DestinationListHandler::getFirstDestination ( ) const
inlineinherited

Definition at line 82 of file oqueue.h.

timeval RTPQueueBase::getInitialTime ( ) const
inlineinherited

Definition at line 201 of file queuebase.h.

uint32 OutgoingDataQueue::getInitialTimestamp ( )
inlineprotected

Definition at line 534 of file oqueue.h.

uint32 RTPQueueBase::getLocalSSRC ( ) const
inlineinherited

Definition at line 184 of file queuebase.h.

uint32 RTPQueueBase::getLocalSSRCNetwork ( ) const
inlineprotectedinherited

Definition at line 214 of file queuebase.h.

bool OutgoingDataQueue::getMark ( ) const
inline

Get wheter the mark bit will be set in the next packet.

Definition at line 337 of file oqueue.h.

size_t OutgoingDataQueueBase::getMaxSendSegmentSize ( )
inlineinherited

Definition at line 273 of file queuebase.h.

CryptoContext * OutgoingDataQueue::getOutQueueCryptoContext ( uint32  ssrc)

Get an output queue CryptoContext identified by SSRC.

Parameters
ssrcRequest CryptoContext for this incoming SSRC
Returns
Pointer to CryptoContext of the SSRC of NULL if no context available for this SSRC.

Definition at line 661 of file outqueue.cpp.

microtimeout_t OutgoingDataQueue::getSchedulingTimeout ( 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 rtp receiver in the service thread.

Returns
timeout until next packet is scheduled to send.

Definition at line 303 of file outqueue.cpp.

uint32 OutgoingDataQueue::getSendOctetCount ( ) const
inline

Get the total number of octets (payload only) sent so far.

Returns
total number of payload octets sent in RTP packets.

Definition at line 400 of file oqueue.h.

uint32 OutgoingDataQueue::getSendPacketCount ( ) const
inline

Get the total number of packets sent so far.

Returns
total number of packets sent

Definition at line 391 of file oqueue.h.

uint16 OutgoingDataQueue::getSequenceNumber ( ) const
inline

Get the sequence number of the next outgoing packet.

Returns
the 16 bit sequence number.

Definition at line 409 of file oqueue.h.

bool OutgoingDataQueue::isSending ( void  ) const

Determine if outgoing packets are waiting to send.

Returns
true if there are packets waiting to be send.

Definition at line 294 of file outqueue.cpp.

bool DestinationListHandler::isSingleDestination ( ) const
inlineinherited

Get whether there is only a destination in the list.

Definition at line 79 of file oqueue.h.

void DestinationListHandler::lockDestinationList ( ) const
inlineinherited

Definition at line 85 of file oqueue.h.

virtual void OutgoingDataQueue::onExpireSend ( OutgoingRTPPkt )
inlineprivatevirtual

A hook to filter packets being sent that have been expired.

Parameters
-expired packet from the send queue.

Definition at line 557 of file oqueue.h.

void OutgoingDataQueue::purgeOutgoingQueue ( )
protected

Definition at line 203 of file outqueue.cpp.

void OutgoingDataQueue::putData ( uint32  stamp,
const unsigned char *  data = NULL,
size_t  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
stampTimestamp for expected send time of packet.
dataValue or NULL if special "silent" packet.
lenMay be 0 to indicate a default by payload type.

Definition at line 404 of file outqueue.cpp.

bool OutgoingDataQueue::removeContributor ( uint32  csrc)

Remove CSRC from the list of contributors.

bool DestinationListHandler::removeDestinationFromList ( const InetAddress &  ia,
tpport_t  dataPort,
tpport_t  controlPort 
)
protectedinherited

Locks the object before modifying it.

Definition at line 85 of file outqueue.cpp.

void OutgoingDataQueue::removeOutQueueCryptoContext ( CryptoContext cc)

Remove output queue CryptoContext.

The endQueue method (provided by RTPQueue) also deletes all registered CryptoContexts.

Parameters
ccPointer to initialized CryptoContext to remove.

Definition at line 636 of file outqueue.cpp.

virtual void RTPQueueBase::renewLocalSSRC ( )
inlineprotectedvirtualinherited

Reimplemented in IncomingDataQueue, and RTPDataQueue.

Definition at line 232 of file queuebase.h.

virtual size_t OutgoingDataQueue::sendData ( const unsigned char *const  buffer,
size_t  len 
)
inlineprivatevirtual

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.

Parameters
bufferPointer to data to write.
lenLength of data to write.
Returns
number of bytes sent.

Reimplemented in RTPDuplex.

Definition at line 578 of file oqueue.h.

void OutgoingDataQueue::sendImmediate ( uint32  stamp,
const unsigned char *  data = NULL,
size_t  len = 0 
)

This is used to create a data packet and send it immediately.

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
stampTimestamp immediate send time of packet.
dataValue or NULL if special "silent" packet.
lenMay be 0 to indicate a default by payload type.

Definition at line 464 of file outqueue.cpp.

virtual void OutgoingDataQueue::setControlPeer ( const InetAddress &  host,
tpport_t  port 
)
inlineprotectedvirtual

Reimplemented in RTPDuplex.

Definition at line 540 of file oqueue.h.

virtual void OutgoingDataQueue::setDataPeer ( const InetAddress &  host,
tpport_t  port 
)
inlineprivatevirtual

Reimplemented in RTPDuplex.

Definition at line 561 of file oqueue.h.

void OutgoingDataQueue::setExpireTimeout ( microtimeout_t  to)
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
totimeout to expire unsent packets in milliseconds.

Definition at line 379 of file oqueue.h.

void OutgoingDataQueue::setInitialTimestamp ( uint32  ts)
inlineprotected

Definition at line 528 of file oqueue.h.

void RTPQueueBase::setLocalSSRC ( uint32  ssrc)
inlineprotectedinherited

Definition at line 211 of file queuebase.h.

void OutgoingDataQueue::setMark ( bool  mark)
inline

Set marker bit for the packet in which the next data provided will be send.

When transmitting audio, should be set for the first packet of a talk spurt. When transmitting video, should be set for the last packet for a video frame.

Parameters
markMarker bit value for next packet.

Definition at line 331 of file oqueue.h.

void OutgoingDataQueueBase::setMaxSendSegmentSize ( size_t  size)
inlineinherited

Set maximum payload segment size before fragmenting sends.

Parameters
sizeMaximum payload size.
Returns
Whether segment size was successfully set.

Definition at line 269 of file queuebase.h.

void OutgoingDataQueue::setNextSeqNum ( uint32  seqNum)
inlineprotected

For thoses cases in which the application requires a method to set the sequence number for the outgoing stream (such as for implementing the RTSP PLAY command).

Parameters
seqNumnext sequence number to be used for outgoing packets.

Definition at line 518 of file oqueue.h.

void OutgoingDataQueue::setOutQueueCryptoContext ( CryptoContext cc)

Set ouput queue CryptoContext.

The endQueue method (provided by RTPQueue) deletes all registered CryptoContexts.

Parameters
ccPointer to initialized CryptoContext.

Definition at line 617 of file outqueue.cpp.

void OutgoingDataQueue::setPadding ( uint8  paddinglen)
inline

Set padding.

All outgoing packets will be transparently padded to a multiple of paddinglen.

Parameters
paddinglenpad packets to a length multiple of paddinglen.

Definition at line 320 of file oqueue.h.

size_t OutgoingDataQueue::setPartial ( uint32  timestamp,
unsigned char *  data,
size_t  offset,
size_t  max 
)

Set partial data for an already queued packet.

This is often used for multichannel data.

Parameters
timestampTimestamp of packet.
dataBuffer to copy from.
offsetOffset to copy from.
maxMaximum data size.
Returns
Number of packet data bytes set.

Definition at line 581 of file outqueue.cpp.

bool RTPQueueBase::setPayloadFormat ( const PayloadFormat pf)
inlineinherited

Set the payload format in use, for timing and payload type identification purposes.

Parameters
pfpayload format to use from now on.
Returns
whether the payload format has been successfully set.

Definition at line 177 of file queuebase.h.

void OutgoingDataQueue::setSchedulingTimeout ( microtimeout_t  to)
inline

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

Parameters
totimeout in milliseconds.

Definition at line 364 of file oqueue.h.

void DestinationListHandler::unlockDestinationList ( ) const
inlineinherited

Definition at line 88 of file oqueue.h.

void DestinationListHandler::writeLockDestinationList ( ) const
inlineprotectedinherited

Definition at line 92 of file oqueue.h.

Field Documentation

bool OutgoingDataQueue::complete

Definition at line 615 of file oqueue.h.

std::list<CryptoContext *> OutgoingDataQueue::cryptoContexts
protected

Definition at line 549 of file oqueue.h.

Mutex OutgoingDataQueue::cryptoMutex
mutableprotected

Definition at line 548 of file oqueue.h.

const microtimeout_t OutgoingDataQueue::defaultExpireTimeout = 40000
staticprivate

Packets unsent will expire after 40 ms.

Definition at line 586 of file oqueue.h.

const microtimeout_t OutgoingDataQueue::defaultSchedulingTimeout = 8000
staticprivate

Schedule at 8 ms.

Definition at line 585 of file oqueue.h.

std::list<TransportAddress*> DestinationListHandler::destList
protectedinherited

Definition at line 68 of file oqueue.h.

microtimeout_t OutgoingDataQueue::expireTimeout
private

Definition at line 594 of file oqueue.h.

uint32 OutgoingDataQueue::initialTimestamp
private

Definition at line 590 of file oqueue.h.

bool OutgoingDataQueue::marked

Definition at line 613 of file oqueue.h.

uint32 OutgoingDataQueue::octetCount

Definition at line 601 of file oqueue.h.

timeval OutgoingDataQueue::overflowTime

Definition at line 620 of file oqueue.h.

uint32 OutgoingDataQueue::packetCount

Definition at line 599 of file oqueue.h.

uint8 OutgoingDataQueue::paddinglen

Definition at line 609 of file oqueue.h.

microtimeout_t OutgoingDataQueue::schedulingTimeout
private

Definition at line 592 of file oqueue.h.

uint16 OutgoingDataQueue::sendCC

Definition at line 607 of file oqueue.h.

OutgoingRTPPktLink* OutgoingDataQueue::sendFirst
private

Definition at line 589 of file oqueue.h.

struct { ... } OutgoingDataQueue::sendInfo
OutgoingRTPPktLink * OutgoingDataQueue::sendLast
private

Definition at line 589 of file oqueue.h.

ThreadLock OutgoingDataQueue::sendLock
mutableprivate

Definition at line 587 of file oqueue.h.

uint16 OutgoingDataQueue::sendSeq

Definition at line 603 of file oqueue.h.

uint32 OutgoingDataQueue::sendSources[16]

Definition at line 605 of file oqueue.h.


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