ccRTP 2.1.2: cqueue.h Source File

ccRTP 2.1.2
cqueue.h
Go to the documentation of this file.
1 // Copyright (C) 2001-2015 Federico Montesino Pouzols <fedemp@altern.org>.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with GNU ccRTP. If not, see <http://www.gnu.org/licenses/>.
15 //
16 // As a special exception, you may use this file as part of a free software
17 // library without restriction. Specifically, if other files instantiate
18 // templates or use macros or inline functions from this file, or you compile
19 // this file and link it with other files to produce an executable, this
20 // file does not by itself cause the resulting executable to be covered by
21 // the GNU General Public License. This exception does not however
22 // invalidate any other reasons why the executable file might be covered by
23 // the GNU General Public License.
24 //
25 // This exception applies only to the code released under the name GNU
26 // ccRTP. If you copy code from other releases into a copy of GNU
27 // ccRTP, as the General Public License permits, the exception does
28 // not apply to the code that you add in this way. To avoid misleading
29 // anyone as to the status of such modified files, you must delete
30 // this exception notice from them.
31 //
32 // If you write modifications of your own for GNU ccRTP, it is your choice
33 // whether to permit this exception to apply to your modifications.
34 // If you do not wish that, delete this exception notice.
35 //
36 
43 #ifndef CCXX_RTP_CQUEUE_H_
44 #define CCXX_RTP_CQUEUE_H_
45 
46 #include <ccrtp/ioqueue.h>
47 #include <ccrtp/CryptoContextCtrl.h>
48 #include <list>
49 
50 NAMESPACE_COMMONCPP
51 
79  class __EXPORT QueueRTCPManager : public RTPDataQueue,
80  protected RTCPCompoundHandler
81 {
82 public:
92  RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
93 
104  RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
105 
114   void setLeavingDelay(microtimeout_t delay)
115  { leavingDelay = delay; }
116 
131  inline void
132   setEnd2EndDelay(microtimeout_t t)
133  { end2EndDelay = t; }
134 
135  inline microtimeout_t
136   getDefaultEnd2EndDelay() const
137 { return defaultEnd2EndDelay; }
138 
139  inline microtimeout_t
140   getEnd2EndDelay() const
141 { return end2EndDelay; }
142 
156  inline void
157   setSendersControlFraction(float fraction)
158  { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
159 
169  void
170   setMinRTCPInterval(microtimeout_t interval)
171  { rtcpMinInterval = interval; }
172 
176  inline uint32
177   getSendRTCPPacketCount() const
178 { return ctrlSendCount; }
179 
188  void
189  setOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
190 
199  void
200  removeOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
201 
209  CryptoContextCtrl*
210  getOutQueueCryptoContextCtrl(uint32 ssrc);
211 
212 
221  void
222  setInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
223 
234  void
235  removeInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
236 
244  CryptoContextCtrl*
245  getInQueueCryptoContextCtrl(uint32 ssrc);
246 
247 protected:
248  QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
249  RTPApplication& app = defaultApplication());
250 
251  QueueRTCPManager(uint32 ssrc,
252  uint32 size = RTPDataQueue::defaultMembersHashSize,
253  RTPApplication& app = defaultApplication());
254 
255  virtual
256  ~QueueRTCPManager();
257 
258  const RTPApplication&
259   getApplication()
260  { return queueApplication; }
261 
262  inline void
263   setControlBandwidth(float fraction)
264  { controlBwFract = fraction; }
265 
266  float
267   getControlBandwidth() const
268 { return controlBwFract; }
269 
274  void
275  controlTransmissionService();
276 
281  void
282  controlReceptionService();
283 
296  bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
297  InetAddress& na, tpport_t tp);
298 
299  void
300  endQueueRTCPManager();
301 
312  virtual void
313  onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
314 
325  virtual void
326  onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
327 
332  bool
333  onGotSDES(SyncSource& source, RTCPPacket& pkt);
334 
344  virtual bool
345  onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
346 
356  inline virtual void
357   onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
358  size_t)
359  { return; }
360 
361  inline timeval
362   getRTCPCheckInterval()
363  { return rtcpCheckInterval; }
364 
369  uint32
370   getLastSendPacketCount() const
371 { return lastSendPacketCount; }
372 
376  inline void
377   setPrevMembersNum(uint32 n)
378  { reconsInfo.rtcpPMembers = n; }
379 
380  inline uint32
381   getPrevMembersCount() const
382 { return reconsInfo.rtcpPMembers; }
383 
402  size_t
403  dispatchBYE(const std::string& reason);
404 
405  size_t
406  sendControlToDestinations(unsigned char* buffer, size_t len);
407 
408 private:
409  QueueRTCPManager(const QueueRTCPManager &o);
410 
411  QueueRTCPManager&
412  operator=(const QueueRTCPManager &o);
413 
419  size_t
420  dispatchControlPacket();
421 
433  void
434  takeInControlPacket();
435 
449  virtual timeval
450  computeRTCPInterval();
451 
459  virtual SDESItemType
460  scheduleSDESItem();
461 
467  inline virtual void
468   onSSRCCollision(const SyncSource&)
469  { }
470 
474  virtual bool
475  end2EndDelayed(IncomingRTPPktLink& p);
476 
485  inline virtual void
486   onGotRRSRExtension(unsigned char*, size_t)
487  { return; }
488 
498  inline virtual void
499   onGotGoodbye(const SyncSource&, const std::string&)
500  { return; }
501 
514  bool
515  getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
516 
520  uint8
521  packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
522 
531  void
532  packSDES(uint16& len);
533 
545  void
546  updateAvgRTCPSize(size_t len);
547 
553  void
554  reverseReconsideration();
555 
556  bool
557  timerReconsideration();
558 
567  void
568  expireSSRCs();
569 
573  void
574  getOnlyBye();
575 
580  void
581  setSDESItem(Participant* part, SDESItemType type,
582  const char* const value, size_t len);
583 
588  void
589  setPRIVPrefix(Participant* part, const char* const value, size_t len);
590 
602  inline virtual uint16
603   networkHeaderSize()
604  { return 20; }
605 
617  inline virtual uint16
618   transportHeaderSize()
619  { return 8; }
620 
621 
622  int32 protect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
623  int32 unprotect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
624 
625 
626  SDESItemType
627  nextSDESType(SDESItemType t);
628 
629  virtual size_t
630  sendControl(const unsigned char* const buffer, size_t len) = 0;
631 
632  virtual size_t
633  recvControl(unsigned char* buffer, size_t len,
634  InetHostAddress& na, tpport_t& tp) = 0;
635 
636  virtual bool
637  isPendingControl(microtimeout_t timeout) = 0;
638 
639  // whether the RTCP service is active
640   volatile bool controlServiceActive;
641   float controlBwFract, sendControlBwFract, recvControlBwFract;
642  // number of RTCP packets sent since the beginning
643   uint32 ctrlSendCount;
644 
645  // Network + transport headers size, typically size of IP +
646  // UDP headers
647   uint16 lowerHeadersSize;
648 
649   SDESItemType nextScheduledSDESItem;
650   static const SDESItemType firstSchedulable;
651   static const SDESItemType lastSchedulable;
652 
653  // state for rtcp timing. Its meaning is defined in
654  // draft-ietf-avt-rtp-new, 6.3.
655 
656  // Parameters for timer reconsideration algorithm
657  struct {
658   timeval rtcpTp, rtcpTc, rtcpTn;
659   uint32 rtcpPMembers;
660  } reconsInfo;
661   bool rtcpWeSent;
662   uint16 rtcpAvgSize;
663   bool rtcpInitial;
664  // last time we checked if there were incoming RTCP packets
665   timeval rtcpLastCheck;
666  // interval to check if there are incoming RTCP packets
667   timeval rtcpCheckInterval;
668  // next time to check if there are incoming RTCP packets
669   timeval rtcpNextCheck;
670 
671  // number of RTP data packets sent at the time of the last
672  // RTCP packet transmission.
673   uint32 lastSendPacketCount;
674 
675  // minimum interval for transmission of RTCP packets. The
676  // result of computeRTCPInterval will always be >= (times a
677  // random number between 0.5 and 1.5).
678   microtimeout_t rtcpMinInterval;
679 
680   microtimeout_t leavingDelay;
681   static const microtimeout_t defaultEnd2EndDelay;
682  // Maximum delay allowed between packet timestamping and
683  // packet availability for the application.
684   microtimeout_t end2EndDelay;
685  // Application this queue is bound to.
686   RTPApplication& queueApplication;
687 
688  // an empty RTPData
689   static const uint16 TIMEOUT_MULTIPLIER;
690   static const double RECONSIDERATION_COMPENSATION;
691 
692   mutable Mutex outCryptoMutex;
693   std::list<CryptoContextCtrl *> outCryptoContexts;
694   uint32 srtcpIndex;
695 
696   mutable Mutex inCryptoMutex;
697   std::list<CryptoContextCtrl *> inCryptoContexts;
698 
699 };
700 
708  class __EXPORT AVPQueue : public QueueRTCPManager
709 {
710 public:
726  inline void
727   setControlBandwidth(float fraction)
728  { QueueRTCPManager::setControlBandwidth(fraction); }
729 
730  float
731   getControlBandwidth() const
732 { return QueueRTCPManager::getControlBandwidth(); }
733 
734 protected:
735   AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
736  RTPApplication& app = defaultApplication()) :
737  QueueRTCPManager(size,app)
738  { }
739 
743   AVPQueue(uint32 ssrc, uint32 size =
744  RTPDataQueue::defaultMembersHashSize,
745  RTPApplication& app = defaultApplication()) :
746  QueueRTCPManager(ssrc,size,app)
747  { }
748   inline virtual ~AVPQueue()
749  { }
750 };
751  // cqueue
753 
754 END_NAMESPACE
755 
756 #endif //CCXX_RTP_CQUEUE_H_
757 
ioqueue.h
Generic RTP input/output queues.
QueueRTCPManager::getLastSendPacketCount
uint32 getLastSendPacketCount() const
Get the number of data packets sent at the time the last SR was generated.
Definition: cqueue.h:370
QueueRTCPManager::rtcpPMembers
uint32 rtcpPMembers
Definition: cqueue.h:659
QueueRTCPManager::getDefaultEnd2EndDelay
microtimeout_t getDefaultEnd2EndDelay() const
Definition: cqueue.h:136
CryptoContextCtrl
The implementation for a SRTCP cryptographic context.
Definition: CryptoContextCtrl.h:61
RTPQueueBase::dispatchBYE
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition: queuebase.h:228
QueueRTCPManager::getEnd2EndDelay
microtimeout_t getEnd2EndDelay() const
Definition: cqueue.h:140
RTCPCompoundHandler
low level structs and RTCP packet parsing and building methods.
Definition: rtcppkt.h:89
QueueRTCPManager::outCryptoContexts
std::list< CryptoContextCtrl * > outCryptoContexts
Definition: cqueue.h:693
RTPApplication
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:364
AVPQueue::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:731
SyncSource
Synchronization source in an RTP session.
Definition: sources.h:192
QueueRTCPManager::firstSchedulable
static const SDESItemType firstSchedulable
Definition: cqueue.h:650
QueueRTCPManager::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:267
ParticipantHandler::setPRIVPrefix
void setPRIVPrefix(Participant *part, const std::string val)
Definition: iqueue.h:188
QueueRTCPManager::getPrevMembersCount
uint32 getPrevMembersCount() const
Definition: cqueue.h:381
QueueRTCPManager::controlServiceActive
volatile bool controlServiceActive
Definition: cqueue.h:640
microtimeout_t
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:67
RTCPSenderInfo
Sender block information of SR RTCP reports.
Definition: rtcppkt.h:453
QueueRTCPManager::rtcpTp
timeval rtcpTp
Definition: cqueue.h:658
QueueRTCPManager::end2EndDelay
microtimeout_t end2EndDelay
Definition: cqueue.h:684
QueueRTCPManager
Adds generic management of RTCP functions to an RTP data queue.
Definition: cqueue.h:79
QueueRTCPManager::lowerHeadersSize
uint16 lowerHeadersSize
Definition: cqueue.h:647
IncomingDataQueue::end2EndDelayed
virtual bool end2EndDelayed(IncomingRTPPktLink &)
Definition: iqueue.h:1238
QueueRTCPManager::setMinRTCPInterval
void setMinRTCPInterval(microtimeout_t interval)
Manually set the minimum interval for sending RTP compound packets.
Definition: cqueue.h:170
QueueRTCPManager::rtcpCheckInterval
timeval rtcpCheckInterval
Definition: cqueue.h:667
QueueRTCPManager::ctrlSendCount
uint32 ctrlSendCount
Definition: cqueue.h:643
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:114
QueueRTCPManager::rtcpNextCheck
timeval rtcpNextCheck
Definition: cqueue.h:669
AVPQueue::AVPQueue
AVPQueue(uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Definition: cqueue.h:735
QueueRTCPManager::defaultEnd2EndDelay
static const microtimeout_t defaultEnd2EndDelay
maximum end to end delay: unlimited
Definition: cqueue.h:681
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:743
QueueRTCPManager::onGotAPP
virtual void onGotAPP(SyncSource &, RTCPCompoundHandler::APPPacket &, size_t)
Plug-in for handling of APP (application specific) RTCP packets.
Definition: cqueue.h:357
QueueRTCPManager::getRTCPCheckInterval
timeval getRTCPCheckInterval()
Definition: cqueue.h:362
QueueRTCPManager::rtcpWeSent
bool rtcpWeSent
Definition: cqueue.h:661
QueueRTCPManager::onGotGoodbye
virtual void onGotGoodbye(const SyncSource &, const std::string &)
A plugin point for goodbye message.
Definition: cqueue.h:499
QueueRTCPManager::getSendRTCPPacketCount
uint32 getSendRTCPPacketCount() const
Get the total number of RTCP packets sent until now.
Definition: cqueue.h:177
QueueRTCPManager::RECONSIDERATION_COMPENSATION
static const double RECONSIDERATION_COMPENSATION
Definition: cqueue.h:690
Participant
A class of objects representing remote participants (RTP applications) in a multimedia session...
Definition: sources.h:124
QueueRTCPManager::outCryptoMutex
Mutex outCryptoMutex
Definition: cqueue.h:692
RTPDataQueue::operator=
RTPDataQueue & operator=(const RTPDataQueue &o)
QueueRTCPManager::transportHeaderSize
virtual uint16 transportHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
Definition: cqueue.h:618
QueueRTCPManager::rtcpMinInterval
microtimeout_t rtcpMinInterval
Definition: cqueue.h:678
ParticipantHandler::setSDESItem
void setSDESItem(Participant *part, SDESItemType item, const std::string &val)
Definition: iqueue.h:183
MembershipBookkeeping::defaultMembersHashSize
static const size_t defaultMembersHashSize
Definition: iqueue.h:854
AVPQueue::setControlBandwidth
void setControlBandwidth(float fraction)
Specify the bandwith available for control (RTCP) packets.
Definition: cqueue.h:727
QueueRTCPManager::setControlBandwidth
void setControlBandwidth(float fraction)
Definition: cqueue.h:263
__EXPORT
#define __EXPORT
Definition: ZrtpCallback.h:40
QueueRTCPManager::nextScheduledSDESItem
SDESItemType nextScheduledSDESItem
Definition: cqueue.h:649
QueueRTCPManager::getApplication
const RTPApplication & getApplication()
Definition: cqueue.h:259
QueueRTCPManager::srtcpIndex
uint32 srtcpIndex
Definition: cqueue.h:694
QueueRTCPManager::rtcpAvgSize
uint16 rtcpAvgSize
Definition: cqueue.h:662
QueueRTCPManager::rtcpInitial
bool rtcpInitial
Definition: cqueue.h:663
QueueRTCPManager::rtcpLastCheck
timeval rtcpLastCheck
Definition: cqueue.h:665
QueueRTCPManager::lastSchedulable
static const SDESItemType lastSchedulable
Definition: cqueue.h:651
QueueRTCPManager::networkHeaderSize
virtual uint16 networkHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
Definition: cqueue.h:603
QueueRTCPManager::setSendersControlFraction
void setSendersControlFraction(float fraction)
Specify the fraction of the total control bandwith to be dedicated to senders reports.
Definition: cqueue.h:157
QueueRTCPManager::TIMEOUT_MULTIPLIER
static const uint16 TIMEOUT_MULTIPLIER
Definition: cqueue.h:689
QueueRTCPManager::inCryptoMutex
Mutex inCryptoMutex
Definition: cqueue.h:696
QueueRTCPManager::sendControlBwFract
float sendControlBwFract
Definition: cqueue.h:641
RTCPReceiverInfo
Report block information of SR/RR RTCP reports.
Definition: rtcppkt.h:373
QueueRTCPManager::leavingDelay
microtimeout_t leavingDelay
Definition: cqueue.h:680
AVPQueue::~AVPQueue
virtual ~AVPQueue()
Definition: cqueue.h:748
QueueRTCPManager::inCryptoContexts
std::list< CryptoContextCtrl * > inCryptoContexts
Definition: cqueue.h:697
QueueRTCPManager::onGotRRSRExtension
virtual void onGotRRSRExtension(unsigned char *, size_t)
Plug-in for processing of SR/RR RTCP packet profile-specific extensions (third part of SR reports or ...
Definition: cqueue.h:486
RTCPCompoundHandler::APPPacket
Struct for APP (application specific) RTCP packets.
Definition: rtcppkt.h:212
QueueRTCPManager::setPrevMembersNum
void setPrevMembersNum(uint32 n)
Definition: cqueue.h:377
defaultApplication
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
Definition: source.cpp:128
QueueRTCPManager::onSSRCCollision
virtual void onSSRCCollision(const SyncSource &)
Plug-in for SSRC collision handling.
Definition: cqueue.h:468
QueueRTCPManager::lastSendPacketCount
uint32 lastSendPacketCount
Definition: cqueue.h:673
QueueRTCPManager::setEnd2EndDelay
void setEnd2EndDelay(microtimeout_t t)
This method sets the maximum end to end delay allowed.
Definition: cqueue.h:132
RTPDataQueue
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:74
SDESItemType
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Definition: rtcppkt.h:64
QueueRTCPManager::queueApplication
RTPApplication & queueApplication
Definition: cqueue.h:686
AVPQueue
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:708

Generated on Dec 15, 2017 for ccrtp-2.1.2 (*.h and *.cpp) and libzrtpcpp-2.3.4 (*.h), by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /