ccRTP
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OutgoingDataQueue Class Reference

#include <oqueue.h>

Inheritance diagram for OutgoingDataQueue:
OutgoingDataQueueBase DestinationListHandler RTPQueueBase RTPDataQueue QueueRTCPManager RTPDuplex AVPQueue TRTPSessionBase< RTPDataChannel, RTCPChannel, ServiceQueue > TRTPSessionBase< DualRTPUDPIPv4Channel, DualRTPUDPIPv4Channel, AVPQueue > SingleThreadRTPSession< RTPDataChannel, RTCPChannel, ServiceQueue >

Classes

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...
 
- Public Member Functions inherited from OutgoingDataQueueBase
size_t getDefaultMaxSendSegmentSize ()
 
void setMaxSendSegmentSize (size_t size)
 Set maximum payload segment size before fragmenting sends. More...
 
size_t getMaxSendSegmentSize ()
 
- Public Member Functions inherited from RTPQueueBase
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)
 
- Protected Member Functions inherited from OutgoingDataQueueBase
 OutgoingDataQueueBase ()
 
virtual ~OutgoingDataQueueBase ()
 
- Protected Member Functions inherited from RTPQueueBase
 RTPQueueBase (uint32 *ssrc=NULL)
 
void setLocalSSRC (uint32 ssrc)
 
uint32 getLocalSSRCNetwork () const
 
virtual ~RTPQueueBase ()
 
virtual size_t dispatchBYE (const std::string &)
 A plugin point for posting of BYE messages. More...
 
virtual void renewLocalSSRC ()
 
- Protected Member Functions inherited from DestinationListHandler
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...
 
 DestinationListHandler ()
 
 ~DestinationListHandler ()
 
bool isSingleDestination () const
 Get whether there is only a destination in the list. More...
 
TransportAddressgetFirstDestination () const
 
void lockDestinationList () const
 
void unlockDestinationList () const
 

Protected Attributes

Mutex cryptoMutex
 
std::list< CryptoContext * > cryptoContexts
 
- Protected Attributes inherited from DestinationListHandler
std::list< TransportAddress * > destList
 

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

Constructor & Destructor Documentation

◆ OutgoingDataQueue()

OutgoingDataQueue::OutgoingDataQueue ( )
protected

◆ ~OutgoingDataQueue()

virtual OutgoingDataQueue::~OutgoingDataQueue ( )
inlineprotectedvirtual

Member Function Documentation

◆ addContributor()

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.

◆ addDestination() [1/2]

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

◆ addDestination() [2/2]

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

◆ dispatchDataPacket()

size_t OutgoingDataQueue::dispatchDataPacket ( )
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.

◆ dispatchImmediate()

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.

◆ forgetDestination() [1/2]

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

◆ forgetDestination() [2/2]

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

◆ getCurrentSeqNum()

uint32 OutgoingDataQueue::getCurrentSeqNum ( void  )
inlineprotected

◆ getDefaultExpireTimeout()

microtimeout_t OutgoingDataQueue::getDefaultExpireTimeout ( ) const
inline

◆ getDefaultSchedulingTimeout()

microtimeout_t OutgoingDataQueue::getDefaultSchedulingTimeout ( ) const
inline

◆ getExpireTimeout()

microtimeout_t OutgoingDataQueue::getExpireTimeout ( ) const
inline

◆ getInitialTimestamp()

uint32 OutgoingDataQueue::getInitialTimestamp ( )
inlineprotected

◆ getMark()

bool OutgoingDataQueue::getMark ( ) const
inline

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

◆ getOutQueueCryptoContext()

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.

◆ getSchedulingTimeout()

microtimeout_t OutgoingDataQueue::getSchedulingTimeout ( )
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.

◆ getSendOctetCount()

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.

◆ getSendPacketCount()

uint32 OutgoingDataQueue::getSendPacketCount ( ) const
inline

Get the total number of packets sent so far.

Returns
total number of packets sent

◆ getSequenceNumber()

uint16 OutgoingDataQueue::getSequenceNumber ( ) const
inline

Get the sequence number of the next outgoing packet.

Returns
the 16 bit sequence number.

◆ isSending()

bool OutgoingDataQueue::isSending ( ) const

Determine if outgoing packets are waiting to send.

Returns
true if there are packets waiting to be send.

◆ purgeOutgoingQueue()

void OutgoingDataQueue::purgeOutgoingQueue ( )
protected

◆ putData()

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.
Examples
audiotx.cpp, ccrtptest.cpp, rtpduphello.cpp, and rtphello.cpp.

◆ removeContributor()

bool OutgoingDataQueue::removeContributor ( uint32  csrc)

Remove CSRC from the list of contributors.

◆ removeOutQueueCryptoContext()

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.

◆ sendImmediate()

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.

◆ setControlPeer()

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

◆ setExpireTimeout()

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.
Examples
ccrtptest.cpp, rtpduphello.cpp, and rtphello.cpp.

◆ setInitialTimestamp()

void OutgoingDataQueue::setInitialTimestamp ( uint32  ts)
inlineprotected

◆ setMark()

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.

◆ setNextSeqNum()

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.

◆ setOutQueueCryptoContext()

void OutgoingDataQueue::setOutQueueCryptoContext ( CryptoContext cc)

Set ouput queue CryptoContext.

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

Parameters
ccPointer to initialized CryptoContext.

◆ setPadding()

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.

◆ setPartial()

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.

◆ setSchedulingTimeout()

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.
Examples
audiorx.cpp, audiotx.cpp, ccrtptest.cpp, rtpduphello.cpp, and rtphello.cpp.

Member Data Documentation

◆ complete

bool OutgoingDataQueue::complete

◆ cryptoContexts

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

◆ cryptoMutex

Mutex OutgoingDataQueue::cryptoMutex
mutableprotected

◆ marked

bool OutgoingDataQueue::marked

◆ octetCount

uint32 OutgoingDataQueue::octetCount

◆ overflowTime

timeval OutgoingDataQueue::overflowTime

◆ packetCount

uint32 OutgoingDataQueue::packetCount

◆ paddinglen

uint8 OutgoingDataQueue::paddinglen

◆ sendCC

uint16 OutgoingDataQueue::sendCC

◆ sendSeq

uint16 OutgoingDataQueue::sendSeq

◆ sendSources

uint32 OutgoingDataQueue::sendSources[16]

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