cqueue.h
Go to the documentation of this file.
// Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.org>.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// This exception applies only to the code released under the name GNU
// ccRTP. If you copy code from other releases into a copy of GNU
// ccRTP, as the General Public License permits, the exception does
// not apply to the code that you add in this way. To avoid misleading
// anyone as to the status of such modified files, you must delete
// this exception notice from them.
//
// If you write modifications of your own for GNU ccRTP, it is your choice
// whether to permit this exception to apply to your modifications.
// If you do not wish that, delete this exception notice.
//
#ifndef CCXX_RTP_CQUEUE_H_
#define CCXX_RTP_CQUEUE_H_
#include <ccrtp/ioqueue.h>
#include <ccrtp/CryptoContextCtrl.h>
#include <list>
NAMESPACE_COMMONCPP
class __EXPORT QueueRTCPManager : public RTPDataQueue,
protected RTCPCompoundHandler
{
public:
RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
void setLeavingDelay(microtimeout_t delay)
{ leavingDelay = delay; }
inline void
setEnd2EndDelay(microtimeout_t t)
{ end2EndDelay = t; }
inline microtimeout_t
getDefaultEnd2EndDelay() const
{ return defaultEnd2EndDelay; }
inline microtimeout_t
getEnd2EndDelay() const
{ return end2EndDelay; }
inline void
setSendersControlFraction(float fraction)
{ sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
void
setMinRTCPInterval(microtimeout_t interval)
{ rtcpMinInterval = interval; }
inline uint32
getSendRTCPPacketCount() const
{ return ctrlSendCount; }
void
setOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
void
removeOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
CryptoContextCtrl*
getOutQueueCryptoContextCtrl(uint32 ssrc);
void
setInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
void
removeInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
CryptoContextCtrl*
getInQueueCryptoContextCtrl(uint32 ssrc);
protected:
QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
RTPApplication& app = defaultApplication());
QueueRTCPManager(uint32 ssrc,
uint32 size = RTPDataQueue::defaultMembersHashSize,
RTPApplication& app = defaultApplication());
virtual
~QueueRTCPManager();
const RTPApplication&
getApplication()
{ return queueApplication; }
inline void
setControlBandwidth(float fraction)
{ controlBwFract = fraction; }
float
getControlBandwidth() const
{ return controlBwFract; }
void
controlTransmissionService();
void
controlReceptionService();
bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
InetAddress& na, tpport_t tp);
void
endQueueRTCPManager();
virtual void
onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
virtual void
onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
bool
onGotSDES(SyncSource& source, RTCPPacket& pkt);
virtual bool
onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
inline virtual void
onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
size_t)
{ return; }
inline timeval
getRTCPCheckInterval()
{ return rtcpCheckInterval; }
uint32
getLastSendPacketCount() const
{ return lastSendPacketCount; }
inline void
setPrevMembersNum(uint32 n)
{ reconsInfo.rtcpPMembers = n; }
inline uint32
getPrevMembersCount() const
{ return reconsInfo.rtcpPMembers; }
size_t
dispatchBYE(const std::string& reason);
size_t
sendControlToDestinations(unsigned char* buffer, size_t len);
private:
QueueRTCPManager(const QueueRTCPManager &o);
QueueRTCPManager&
operator=(const QueueRTCPManager &o);
size_t
dispatchControlPacket();
void
takeInControlPacket();
virtual timeval
computeRTCPInterval();
virtual SDESItemType
scheduleSDESItem();
inline virtual void
onSSRCCollision(const SyncSource&)
{ }
virtual bool
end2EndDelayed(IncomingRTPPktLink& p);
inline virtual void
onGotRRSRExtension(unsigned char*, size_t)
{ return; }
inline virtual void
onGotGoodbye(const SyncSource&, const std::string&)
{ return; }
bool
getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
uint8
packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
void
packSDES(uint16& len);
void
updateAvgRTCPSize(size_t len);
void
reverseReconsideration();
bool
timerReconsideration();
void
expireSSRCs();
void
getOnlyBye();
void
setSDESItem(Participant* part, SDESItemType type,
const char* const value, size_t len);
void
setPRIVPrefix(Participant* part, const char* const value, size_t len);
inline virtual uint16
networkHeaderSize()
{ return 20; }
inline virtual uint16
transportHeaderSize()
{ return 8; }
int32 protect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
int32 unprotect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
SDESItemType
nextSDESType(SDESItemType t);
virtual size_t
sendControl(const unsigned char* const buffer, size_t len) = 0;
virtual size_t
recvControl(unsigned char* buffer, size_t len,
InetHostAddress& na, tpport_t& tp) = 0;
virtual bool
isPendingControl(microtimeout_t timeout) = 0;
// whether the RTCP service is active
volatile bool controlServiceActive;
float controlBwFract, sendControlBwFract, recvControlBwFract;
// number of RTCP packets sent since the beginning
uint32 ctrlSendCount;
// Network + transport headers size, typically size of IP +
// UDP headers
uint16 lowerHeadersSize;
SDESItemType nextScheduledSDESItem;
static const SDESItemType firstSchedulable;
static const SDESItemType lastSchedulable;
// state for rtcp timing. Its meaning is defined in
// draft-ietf-avt-rtp-new, 6.3.
// Parameters for timer reconsideration algorithm
struct {
timeval rtcpTp, rtcpTc, rtcpTn;
uint32 rtcpPMembers;
} reconsInfo;
bool rtcpWeSent;
uint16 rtcpAvgSize;
bool rtcpInitial;
// last time we checked if there were incoming RTCP packets
timeval rtcpLastCheck;
// interval to check if there are incoming RTCP packets
timeval rtcpCheckInterval;
// next time to check if there are incoming RTCP packets
timeval rtcpNextCheck;
// number of RTP data packets sent at the time of the last
// RTCP packet transmission.
uint32 lastSendPacketCount;
// minimum interval for transmission of RTCP packets. The
// result of computeRTCPInterval will always be >= (times a
// random number between 0.5 and 1.5).
microtimeout_t rtcpMinInterval;
microtimeout_t leavingDelay;
static const microtimeout_t defaultEnd2EndDelay;
// Maximum delay allowed between packet timestamping and
// packet availability for the application.
microtimeout_t end2EndDelay;
// Application this queue is bound to.
RTPApplication& queueApplication;
// an empty RTPData
static const uint16 TIMEOUT_MULTIPLIER;
static const double RECONSIDERATION_COMPENSATION;
mutable Mutex outCryptoMutex;
std::list<CryptoContextCtrl *> outCryptoContexts;
uint32 srtcpIndex;
mutable Mutex inCryptoMutex;
std::list<CryptoContextCtrl *> inCryptoContexts;
};
class __EXPORT AVPQueue : public QueueRTCPManager
{
public:
inline void
setControlBandwidth(float fraction)
{ QueueRTCPManager::setControlBandwidth(fraction); }
float
getControlBandwidth() const
{ return QueueRTCPManager::getControlBandwidth(); }
protected:
AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
RTPApplication& app = defaultApplication()) :
QueueRTCPManager(size,app)
{ }
AVPQueue(uint32 ssrc, uint32 size =
RTPDataQueue::defaultMembersHashSize,
RTPApplication& app = defaultApplication()) :
QueueRTCPManager(ssrc,size,app)
{ }
inline virtual ~AVPQueue()
{ }
};
// cqueue
END_NAMESPACE
#endif //CCXX_RTP_CQUEUE_H_
ioqueue.h
Generic RTP input/output queues.
RTCPCompoundHandler::SendReport
Struct for SR (sender report) RTCP packets.
Definition: rtcppkt.h:164
QueueRTCPManager::rtcpPMembers
uint32 rtcpPMembers
Definition: cqueue.h:660
AVPQueue::setControlBandwidth
void setControlBandwidth(float fraction)
Specify the bandwith available for control (RTCP) packets.
Definition: cqueue.h:728
QueueRTCPManager::getApplication
const RTPApplication & getApplication()
Definition: cqueue.h:260
QueueRTCPManager::getRTCPCheckInterval
timeval getRTCPCheckInterval()
Definition: cqueue.h:363
microtimeout_t
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:68
RTCPCompoundHandler::RRBlock
Struct for a receiver info block in a SR (sender report) or an RR (receiver report) RTCP packet...
Definition: rtcppkt.h:126
ParticipantHandler::setPRIVPrefix
void setPRIVPrefix(Participant *part, const std::string val)
Definition: iqueue.h:189
IncomingDataQueue::end2EndDelayed
virtual bool end2EndDelayed(IncomingRTPPktLink &)
Definition: iqueue.h:1239
QueueRTCPManager::getLastSendPacketCount
uint32 getLastSendPacketCount() const
Get the number of data packets sent at the time the last SR was generated.
Definition: cqueue.h:371
RTCPReceiverInfo
Report block information of SR/RR RTCP reports.
Definition: rtcppkt.h:374
AVPQueue::AVPQueue
AVPQueue(uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Definition: cqueue.h:736
QueueRTCPManager::getDefaultEnd2EndDelay
microtimeout_t getDefaultEnd2EndDelay() const
Definition: cqueue.h:137
CryptoContextCtrl.h
RTPQueueBase::dispatchBYE
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition: queuebase.h:229
QueueRTCPManager::getSendRTCPPacketCount
uint32 getSendRTCPPacketCount() const
Get the total number of RTCP packets sent until now.
Definition: cqueue.h:178
RTCPCompoundHandler::SDESChunk
Struct for a chunk of items in a SDES RTCP packet.
Definition: rtcppkt.h:188
SyncSource
Synchronization source in an RTP session.
Definition: sources.h:194
CryptoContextCtrl
The implementation for a SRTCP cryptographic context.
Definition: CryptoContextCtrl.h:62
AVPQueue
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:709
QueueRTCPManager::setMinRTCPInterval
void setMinRTCPInterval(microtimeout_t interval)
Manually set the minimum interval for sending RTP compound packets.
Definition: cqueue.h:171
QueueRTCPManager::onGotAPP
virtual void onGotAPP(SyncSource &, RTCPCompoundHandler::APPPacket &, size_t)
Plug-in for handling of APP (application specific) RTCP packets.
Definition: cqueue.h:358
QueueRTCPManager::setPrevMembersNum
void setPrevMembersNum(uint32 n)
Definition: cqueue.h:378
QueueRTCPManager::setSendersControlFraction
void setSendersControlFraction(float fraction)
Specify the fraction of the total control bandwith to be dedicated to senders reports.
Definition: cqueue.h:158
QueueRTCPManager::setLeavingDelay
void setLeavingDelay(microtimeout_t delay)
Set how much time the stack will wait before deleting a synchronization source that has sent an RTCP ...
Definition: cqueue.h:115
AVPQueue::~AVPQueue
virtual ~AVPQueue()
Definition: cqueue.h:749
RTCPCompoundHandler
low level structs and RTCP packet parsing and building methods.
Definition: rtcppkt.h:90
RTCPSenderInfo
Sender block information of SR RTCP reports.
Definition: rtcppkt.h:454
RTPApplication
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:366
MembershipBookkeeping::IncomingRTPPktLink
Incoming RTP data packets control structure within the incoming packet queue class.
Definition: iqueue.h:352
RTCPCompoundHandler::RTCPPacket
Struct representing general RTCP packet headers as they are sent through the network.
Definition: rtcppkt.h:278
QueueRTCPManager::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:268
QueueRTCPManager::getPrevMembersCount
uint32 getPrevMembersCount() const
Definition: cqueue.h:382
MembershipBookkeeping::defaultMembersHashSize
static const size_t defaultMembersHashSize
Definition: iqueue.h:855
RTCPCompoundHandler::APPPacket
Struct for APP (application specific) RTCP packets.
Definition: rtcppkt.h:213
QueueRTCPManager::setControlBandwidth
void setControlBandwidth(float fraction)
Definition: cqueue.h:264
QueueRTCPManager::setEnd2EndDelay
void setEnd2EndDelay(microtimeout_t t)
This method sets the maximum end to end delay allowed.
Definition: cqueue.h:133
AVPQueue::AVPQueue
AVPQueue(uint32 ssrc, uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Local SSRC is given instead of computed by the queue.
Definition: cqueue.h:744
QueueRTCPManager
Adds generic management of RTCP functions to an RTP data queue.
Definition: cqueue.h:80
ParticipantHandler::setSDESItem
void setSDESItem(Participant *part, SDESItemType item, const std::string &val)
Definition: iqueue.h:184
RTPDataQueue
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:75
QueueRTCPManager::getEnd2EndDelay
microtimeout_t getEnd2EndDelay() const
Definition: cqueue.h:141
defaultApplication
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
QueueRTCPManager::rtcpTp
timeval rtcpTp
Definition: cqueue.h:659
Participant
A class of objects representing remote participants (RTP applications) in a multimedia session...
Definition: sources.h:126
SDESItemType
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Definition: rtcppkt.h:65
MembershipBookkeeping::SyncSourceLink
Synchronization Source internal handler within the incoming packets queue.
Definition: iqueue.h:470
AVPQueue::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:732
RTCPCompoundHandler::RecvReport
raw structure of the source and every receiver report in an SR or RR RTCP packet. ...
Definition: rtcppkt.h:138