#include <cc++/rtp.h>
Inheritance diagram for RTPQueue::
Public Methods | |
const RTPSource & | getLocalInfo () const |
Get the application description. More... | |
bool | isWaiting (const RTPSource &src=dummysource) const |
Determine if packets are waiting in the reception queue. More... | |
bool | isCookedWaiting (void) const |
Determine if cooked packets are waiting in the reception queue. More... | |
bool | isSending (void) const |
Determine if outgoing packets are waiting to send. More... | |
void | putPacket (uint32 stamp, rtp_payload_t payload, unsigned char *data=NULL, size_t len=0, bool mark=false) |
This is used to create a data packet in the send queue. More... | |
const RTPData & | getCookedPacket (const RTPSource &src=dummysource) |
Attempt to get a cooked packet. More... | |
uint32 | getFirstTimestamp (const RTPSource &src=dummysource) |
Get timestamp of first packet waiting in the queue. More... | |
uint16 | getFirstSequence (const RTPSource &src=dummysource) |
Get the sequence id of the first packet waiting. More... | |
const RTPData & | getPacket (uint32 stamp, const RTPSource &src=dummysource) |
Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer. More... | |
size_t | getPacket (uint32 stamp, unsigned char *data, size_t max, const RTPSource &src=dummysource) |
Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer. More... | |
rtp_payload_t | getPayloadType (uint32 timestamp, const RTPSource &src=dummysource) |
Get the payload type of a specific packet by timestamp. More... | |
uint32 | getCurrentTimestamp (rtp_payload_t pt) const |
Get the timestamp for a packet whose payload sampling instant corresponds to the current system time. More... | |
uint32 | getTimestampIncrement (size_t packet_size) const |
If your application uses a fixed sampling rate and a fixed payload format, given the size of the next packet to be sent, this method provides the timestamp increment for the next packet. More... | |
void | setSessionBandwidth (uint32 bw) |
Specify the bandwidth of the current session. More... | |
uint32 | getRate (rtp_payload_t pt=RTP_PAYLOAD_EMPTY) const |
Get the transmission rate for a payload type. More... | |
rtp_payload_t | getPayloadType (const RTPSource &src) const |
Get the payload type of the first available packet. More... | |
const RTPSource & | getSource (uint32 ssrc) const |
Get the representation of a session participant by its Synchronization SouRCe identifier. More... | |
void | setTypeOfService (type_of_service_t tos) |
Specify the kind of service the application expects to use. More... | |
size_t | setPartial (uint32 timestamp, unsigned char *data, size_t offset, size_t max) |
Set partial data for an already queued packet. More... | |
size_t | getPartial (uint32 timestamp, unsigned char *data, size_t offset, size_t max) |
Get partial data from a packet. More... | |
bool | isActive (void) const |
Get active connection state flag. More... | |
void | setTimeout (microtimeout_t t) |
Set the default scheduling timeout to use when no data packets are waiting to be sent. More... | |
void | setExpired (microtimeout_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 | setGlobalKitchenDuration (microtimeout_t t) |
Specify how much time the incoming packets will be buffered for each and every source. More... | |
void | setGlobalKitchenSize (uint32 s) |
microtimeout_t | getGlobalKitchenDuration () const |
Get the current global kitchen size. More... | |
void | setEndToEndDelay (microtimeout_t t) |
This method sets the maximun end to end delay allowed. More... | |
void | setSegmentSize (size_t 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... | |
void | setTimeclock (void) |
Set the packet timeclock for synchronizing timestamps. More... | |
timeout_t | getTimeclock (void) |
Get the packet timeclock for synchronizing timestamps. More... | |
uint32 | RTPSendCount () const |
Get the total number of packets sent so far. More... | |
uint32 | RTPOctetCount () const |
Get the total number of octets (payload only) sent so far. More... | |
Protected Methods | |
RTPQueue (int pri, uint32 size=7) | |
Constructor. More... | |
RTPQueue (uint32 ssrc, int pri, uint32 size=7) | |
Using this constructor you can start a session with the given ssrc, instead of the usual randomly generated one. More... | |
virtual | ~RTPQueue () |
The queue destructor flush the queue and stop all services. More... | |
virtual void | RTCPService (microtimeout_t &wait) |
A plugin point for a scheduler of RTCP packets. More... | |
virtual void | Bye (const char *const reason) |
A plugin point for posting of BYE messages. More... | |
virtual void | timerTick (void) |
A plugin point for timer tick driven events. More... | |
microtimeout_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 | isPendingData (microtimeout_t timeout)=0 |
This function is used to check for and schedule against arriving packets based on the derived connection type. More... | |
void | Purge (rtp_purge_t flag) |
This function is used to purge the queue(s). More... | |
size_t | sendPacket (void) |
This function is used by the service thread to process the next outgoing packet pending in the sending queue. More... | |
virtual size_t | writeData (const unsigned char *const packet, size_t len)=0 |
This function performs the physical I/O for writing a packet to the destination. More... | |
size_t | 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 size_t | readData (unsigned char *buffer, size_t len)=0 |
This function performs the physical I/O for reading a packet from the source. More... | |
virtual bool | gotPacket (IncomingRTPPkt *packet) |
A virtual function to support parsing of arriving packets to determine if they should be kept in the queue and to dispatch events. More... | |
virtual void | expireSend (OutgoingRTPPkt *packet) |
A hook to filter packets being sent that have been expired. More... | |
virtual void | expireRecv (IncomingRTPPkt *packet) |
A hook to filter packets in the receive queue that are being expired. More... | |
IncomingRTPPkt * | getWaiting (uint32 timestamp, const RTPSource &src=dummysource) |
This is used to fetch a packet in the receive queue and to expire packets older than the current timestamp. More... | |
void | endQueue () |
This method ends the queue and service threads. More... | |
void | Final () |
The queue removes itself when the service thread is detached. More... | |
Protected Attributes | |
volatile bool | active |
RTPSource * | localsrc |
timeval | initial_time |
uint32 | current_rate |
uint32 | initial_timestamp |
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 RTPQueue::putPacket method.
Incoming packets can be retrieved via:
|
Constructor. This will generate a random application SSRC identifier.
|
|
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.
|
|
The queue destructor flush the queue and stop all services.
|
|
A plugin point for posting of BYE messages.
Reimplemented in QueueRTCPManager. |
|
The queue removes itself when the service thread is detached.
|
|
This function is used to purge the queue(s). Depending on the flag value, it purges the packets waiting to be sent, waiting to be picked up from the reception queue, or both. |
|
A plugin point for a scheduler of RTCP packets. The default implementation in RTPQueue is to do nothing.
Reimplemented in QueueRTCPManager. |
|
Get the total number of octets (payload only) sent so far.
|
|
Get the total number of packets sent so far.
|
|
This method ends the queue and service threads.
|
|
A hook to filter packets in the receive queue that are being expired.
|
|
A hook to filter packets being sent that have been expired.
|
|
Attempt to get a cooked packet. If available, thid method will retrieve the first cooked packet. A packet is said to be cooked if:
If the queue has not yet reached its maximun size (that can be set with RTPQueue::setKitchenSize), ccRTP will try to cook the packets before allowing the application to pick them up. Note that if there are more packets than the maximun, they will not be thrown away. In order to accomplish this task, at the beginning no packet will be released until the queue reaches the kitchen size (this will provide a buffer to ccRTP where to cook the packets). Then, provided that there is no disorder, ccRTP will release every packet when asked (note that usual applications will try to retrieve packets, broadly speaking, at the same rate they are received, so the kitchen will remain the same (maximun) size if there is no lost). If the newest packet (the one with the minor timestamp) in the queue is disordered, ccRTP will not release it until the kitchen reaches at least it maximun size. When the maximun size is reached, if disorder could not be fixed, ccRTP will then release the packet. Thus, unrepairable disorder implies the queue will stop providing packets for a while and then provide a disordered packet. If a lost packet arrives after newer packets have been retrieved, it will be silently discarded. Summary: If the next packet is ordered, it will be released wheter or not the kitchen is full. If the next packet is disordered, it will be released only when the kitchen has at least its maximun size.
|
|
Get the timestamp 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 RTPQueue::getTimestampIncrement() method rather than computing it by hand in the application.
|
|
Get the sequence id of the first packet waiting.
|
|
Get timestamp of first packet waiting in the queue.
|
|
Get the current global kitchen size. Note that the kitchen size can be modified individually for every source, so it is not guaranteed that this is the current kitchen for all sources.
|
|
Get the application description.
|
|
Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer.
|
|
Retreive data from a specific timestamped packet if such a packet is currently available in the receive buffer.
|
|
Get partial data from a packet. This is often used to support oddball hardware that has unusual or non-standard codec buffering intervals.
|
|
Get the payload type of the first available packet.
|
|
Get the payload type of a specific packet by timestamp.
|
|
Get the transmission rate for a payload type. Note that for some payload types, the transmission rate corresponds to the timestamp rate, but this is not true for all payload types.
|
|
Get the representation of a session participant by its Synchronization SouRCe identifier.
Reimplemented from MembershipControl. |
|
Get the packet timeclock for synchronizing timestamps.
|
|
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.
|
|
If your application uses a fixed sampling rate and a fixed payload format, given the size of the next packet to be sent, this method provides the timestamp increment for the next packet.
|
|
This is used to fetch a packet in the receive queue and to expire packets older than the current timestamp.
|
|
A virtual function to support parsing of arriving packets to determine if they should be kept in the queue and to dispatch events.
|
|
Get active connection state flag.
|
|
Is last packet processed "complete" or are sequences missing?
|
|
Determine if cooked packets are waiting in the reception queue. Note that isCookedWaiting() == true implies isWaiting() == true.
|
|
Is last packet processed "marked" (used to signal end on multi-sequence sends).
|
|
This function is used to check for and schedule against arriving packets based on the derived connection type.
Reimplemented in RTPDuplex. |
|
Determine if outgoing packets are waiting to send.
|
|
Determine if packets are waiting in the reception queue.
|
|
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.
|
|
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.
Reimplemented in RTPDuplex. |
|
This function is used by the service thread to process the next incoming packet and place it in the receive list.
|
|
This function is used by the service thread to process the next outgoing packet pending in the sending queue.
|
|
This method sets the maximun end to end delay allowed. If the processing delay plus the trip time for a packet is greater than the end to end delay, the packet is discarded, and the application cannot get it. This is a way of setting an upper bound to the end to end delay, computed as the elapsed time between the packet timestamping at the sender side, and the picking of the packet at the receiver side.
|
|
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.
|
|
Specify how much time the incoming packets will be buffered for each and every source. Note that the size is specified in temporal units, thus the internal queue will usually hold as many packets as necessary to fill the specified amount of time. The default size is 0 us. If using only the "high level" method for retrieving packets, RTPQueue::getCookedPacket(), before providing disordered packets to the application, ccRTP will try to cook them. The bigger the specified time, the higher the probability of reordering and recomposing the stream in case of corruption is.
|
|
|
|
Set partial data for an already queued packet. This is often used for multichannel data.
|
|
Set maximum packet segment size before fragmenting sends.
|
|
Specify the bandwidth of the current session.
|
|
Set the packet timeclock for synchronizing timestamps.
|
|
Set the default scheduling timeout to use when no data packets are waiting to be sent.
|
|
Specify the kind of service the application expects to use.
|
|
A plugin point for timer tick driven events.
|
|
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.
Reimplemented in RTPDuplex. |
|
|
|
|
|
|
|
|
|
|