Bayonne2 / Common C++ 2 Framework: cqueue.h Source File

Bayonne2 / Common C++ 2 Framework
cqueue.h
Go to the documentation of this file.
1 // Copyright (C) 2001,2002,2004 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 General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccRTP. If you copy code from other releases into a copy of GNU
28 // ccRTP, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccRTP, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
44 #ifndef CCXX_RTP_CQUEUE_H_
45 #define CCXX_RTP_CQUEUE_H_
46 
47 #include <ccrtp/ioqueue.h>
48 
49 #ifdef CCXX_NAMESPACES
50 namespace ost {
51 #endif
52 
80  class __EXPORT QueueRTCPManager : public RTPDataQueue,
81  protected RTCPCompoundHandler
82 {
83 public:
93  RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
94 
105  RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
106 
115   void setLeavingDelay(microtimeout_t delay)
116  { leavingDelay = delay; }
117 
132  inline void
133   setEnd2EndDelay(microtimeout_t t)
134  { end2EndDelay = t; }
135 
136  inline microtimeout_t
137   getDefaultEnd2EndDelay() const
138 { return defaultEnd2EndDelay; }
139 
140  inline microtimeout_t
141   getEnd2EndDelay() const
142 { return end2EndDelay; }
143 
157  inline void
158   setSendersControlFraction(float fraction)
159  { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
160 
170  void
171   setMinRTCPInterval(microtimeout_t interval)
172  { rtcpMinInterval = interval; }
173 
177  inline uint32
178   getSendRTCPPacketCount() const
179 { return ctrlSendCount; }
180 
181 protected:
182  QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
183  RTPApplication& app = defaultApplication());
184 
185  QueueRTCPManager(uint32 ssrc,
186  uint32 size = RTPDataQueue::defaultMembersHashSize,
187  RTPApplication& app = defaultApplication());
188 
189  virtual
190  ~QueueRTCPManager();
191 
192  const RTPApplication&
193   getApplication()
194  { return queueApplication; }
195 
196  inline void
197   setControlBandwidth(float fraction)
198  { controlBwFract = fraction; }
199 
200  float
201   getControlBandwidth() const
202 { return controlBwFract; }
203 
208  void
209  controlTransmissionService();
210 
215  void
216  controlReceptionService();
217 
230  bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
231  InetAddress& na, tpport_t tp);
232 
233  void
234  endQueueRTCPManager();
235 
246  virtual void
247  onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
248 
259  virtual void
260  onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
261 
266  bool
267  onGotSDES(SyncSource& source, RTCPPacket& pkt);
268 
278  virtual bool
279  onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
280 
290  inline virtual void
291   onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
292  size_t)
293  { return; }
294 
295  inline timeval
296   getRTCPCheckInterval()
297  { return rtcpCheckInterval; }
298 
303  uint32
304   getLastSendPacketCount() const
305 { return lastSendPacketCount; }
306 
310  inline void
311   setPrevMembersNum(uint32 n)
312  { reconsInfo.rtcpPMembers = n; }
313 
314  inline uint32
315   getPrevMembersCount() const
316 { return reconsInfo.rtcpPMembers; }
317 
336  size_t
337  dispatchBYE(const std::string& reason);
338 
339  size_t
340  sendControlToDestinations(unsigned char* buffer, size_t len);
341 
342 private:
343  QueueRTCPManager(const QueueRTCPManager &o);
344 
345  QueueRTCPManager&
346  operator=(const QueueRTCPManager &o);
347 
353  size_t
354  dispatchControlPacket();
355 
367  void
368  takeInControlPacket();
369 
383  virtual timeval
384  computeRTCPInterval();
385 
393  virtual SDESItemType
394  scheduleSDESItem();
395 
401  inline virtual void
402   onSSRCCollision(const SyncSource&)
403  { }
404 
408  virtual bool
409  end2EndDelayed(IncomingRTPPktLink& p);
410 
419  inline virtual void
420   onGotRRSRExtension(unsigned char*, size_t)
421  { return; }
422 
432  inline virtual void
433   onGotGoodbye(const SyncSource&, const std::string&)
434  { return; }
435 
448  bool
449  getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
450 
454  uint8
455  packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
456 
465  void
466  packSDES(uint16& len);
467 
479  void
480  updateAvgRTCPSize(size_t len);
481 
487  void
488  reverseReconsideration();
489 
490  bool
491  timerReconsideration();
492 
501  void
502  expireSSRCs();
503 
507  void
508  getOnlyBye();
509 
514  void
515  setSDESItem(Participant* part, SDESItemType type,
516  const char* const value, size_t len);
517 
522  void
523  setPRIVPrefix(Participant* part, const char* const value, size_t len);
524 
536  inline virtual uint16
537   networkHeaderSize()
538  { return 20; }
539 
551  inline virtual uint16
552   transportHeaderSize()
553  { return 8; }
554 
555  SDESItemType
556  nextSDESType(SDESItemType t);
557 
558  virtual size_t
559  sendControl(const unsigned char* const buffer, size_t len) = 0;
560 
561  virtual size_t
562  recvControl(unsigned char* buffer, size_t len,
563  InetHostAddress& na, tpport_t& tp) = 0;
564 
565  virtual bool
566  isPendingControl(microtimeout_t timeout) = 0;
567 
568  // whether the RTCP service is active
569   volatile bool controlServiceActive;
570   float controlBwFract, sendControlBwFract, recvControlBwFract;
571  // number of RTCP packets sent since the beginning
572   uint32 ctrlSendCount;
573 
574  // Network + transport headers size, typically size of IP +
575  // UDP headers
576   uint16 lowerHeadersSize;
577 
578   SDESItemType nextScheduledSDESItem;
579   static const SDESItemType firstSchedulable;
580   static const SDESItemType lastSchedulable;
581 
582  // state for rtcp timing. Its meaning is defined in
583  // draft-ietf-avt-rtp-new, 6.3.
584 
585  // Parameters for timer reconsideration algorithm
586  struct {
587   timeval rtcpTp, rtcpTc, rtcpTn;
588   uint32 rtcpPMembers;
589  } reconsInfo;
590   bool rtcpWeSent;
591   uint16 rtcpAvgSize;
592   bool rtcpInitial;
593  // last time we checked if there were incoming RTCP packets
594   timeval rtcpLastCheck;
595  // interval to check if there are incoming RTCP packets
596   timeval rtcpCheckInterval;
597  // next time to check if there are incoming RTCP packets
598   timeval rtcpNextCheck;
599 
600  // number of RTP data packets sent at the time of the last
601  // RTCP packet transmission.
602   uint32 lastSendPacketCount;
603 
604  // minimum interval for transmission of RTCP packets. The
605  // result of computeRTCPInterval will always be >= (times a
606  // random number between 0.5 and 1.5).
607   microtimeout_t rtcpMinInterval;
608 
609   microtimeout_t leavingDelay;
610   static const microtimeout_t defaultEnd2EndDelay;
611  // Maximum delay allowed between packet timestamping and
612  // packet availability for the application.
613   microtimeout_t end2EndDelay;
614  // Application this queue is bound to.
615   RTPApplication& queueApplication;
616 
617  // an empty RTPData
618   static const uint16 TIMEOUT_MULTIPLIER;
619   static const double RECONSIDERATION_COMPENSATION;
620 };
621 
629  class AVPQueue : public QueueRTCPManager
630 {
631 public:
647  inline void
648   setControlBandwidth(float fraction)
649  { QueueRTCPManager::setControlBandwidth(fraction); }
650 
651  float
652   getControlBandwidth() const
653 { return QueueRTCPManager::getControlBandwidth(); }
654 
655 protected:
656   AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
657  RTPApplication& app = defaultApplication()) :
658  QueueRTCPManager(size,app)
659  { }
660 
664   AVPQueue(uint32 ssrc, uint32 size =
665  RTPDataQueue::defaultMembersHashSize,
666  RTPApplication& app = defaultApplication()) :
667  QueueRTCPManager(ssrc,size,app)
668  { }
669   inline virtual ~AVPQueue()
670  { }
671 };
672  // cqueue
674 
675 #ifdef CCXX_NAMESPACES
676 }
677 #endif
678 
679 #endif //CCXX_RTP_CQUEUE_H_
680 
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:304
QueueRTCPManager::rtcpPMembers
uint32 rtcpPMembers
Definition: cqueue.h:588
QueueRTCPManager::getDefaultEnd2EndDelay
microtimeout_t getDefaultEnd2EndDelay() const
Definition: cqueue.h:137
QueueRTCPManager::getEnd2EndDelay
microtimeout_t getEnd2EndDelay() const
Definition: cqueue.h:141
RTCPCompoundHandler
low level structs and RTCP packet parsing and building methods.
Definition: rtcppkt.h:92
RTPApplication
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:367
AVPQueue::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:652
SyncSource
Synchronization source in an RTP session.
Definition: sources.h:195
QueueRTCPManager::firstSchedulable
static const SDESItemType firstSchedulable
Definition: cqueue.h:579
QueueRTCPManager::getControlBandwidth
float getControlBandwidth() const
Definition: cqueue.h:201
QueueRTCPManager::getPrevMembersCount
uint32 getPrevMembersCount() const
Definition: cqueue.h:315
QueueRTCPManager::controlServiceActive
volatile bool controlServiceActive
Definition: cqueue.h:569
microtimeout_t
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:69
RTCPSenderInfo
Sender block information of SR RTCP reports.
Definition: rtcppkt.h:456
QueueRTCPManager::rtcpTp
timeval rtcpTp
Definition: cqueue.h:587
QueueRTCPManager::end2EndDelay
microtimeout_t end2EndDelay
Definition: cqueue.h:613
QueueRTCPManager
Adds generic management of RTCP functions to an RTP data queue.
Definition: cqueue.h:80
QueueRTCPManager::lowerHeadersSize
uint16 lowerHeadersSize
Definition: cqueue.h:576
tpport_t
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
QueueRTCPManager::setMinRTCPInterval
void setMinRTCPInterval(microtimeout_t interval)
Manually set the minimum interval for sending RTP compound packets.
Definition: cqueue.h:171
QueueRTCPManager::rtcpCheckInterval
timeval rtcpCheckInterval
Definition: cqueue.h:596
QueueRTCPManager::ctrlSendCount
uint32 ctrlSendCount
Definition: cqueue.h:572
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
QueueRTCPManager::rtcpNextCheck
timeval rtcpNextCheck
Definition: cqueue.h:598
AVPQueue::AVPQueue
AVPQueue(uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Definition: cqueue.h:656
QueueRTCPManager::defaultEnd2EndDelay
static const microtimeout_t defaultEnd2EndDelay
Definition: cqueue.h:610
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:664
QueueRTCPManager::onGotAPP
virtual void onGotAPP(SyncSource &, RTCPCompoundHandler::APPPacket &, size_t)
Plug-in for handling of APP (application specific) RTCP packets.
Definition: cqueue.h:291
QueueRTCPManager::getRTCPCheckInterval
timeval getRTCPCheckInterval()
Definition: cqueue.h:296
QueueRTCPManager::rtcpWeSent
bool rtcpWeSent
Definition: cqueue.h:590
QueueRTCPManager::onGotGoodbye
virtual void onGotGoodbye(const SyncSource &, const std::string &)
A plugin point for goodbye message.
Definition: cqueue.h:433
QueueRTCPManager::getSendRTCPPacketCount
uint32 getSendRTCPPacketCount() const
Get the total number of RTCP packets sent until now.
Definition: cqueue.h:178
QueueRTCPManager::RECONSIDERATION_COMPENSATION
static const double RECONSIDERATION_COMPENSATION
Definition: cqueue.h:619
Participant
A class of objects representing remote participants (RTP applications) in a multimedia session...
Definition: sources.h:127
InetHostAddress
#define InetHostAddress
Definition: address.h:76
QueueRTCPManager::transportHeaderSize
virtual uint16 transportHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
Definition: cqueue.h:552
QueueRTCPManager::rtcpMinInterval
microtimeout_t rtcpMinInterval
Definition: cqueue.h:607
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:648
QueueRTCPManager::setControlBandwidth
void setControlBandwidth(float fraction)
Definition: cqueue.h:197
QueueRTCPManager::nextScheduledSDESItem
SDESItemType nextScheduledSDESItem
Definition: cqueue.h:578
QueueRTCPManager::getApplication
const RTPApplication & getApplication()
Definition: cqueue.h:193
InetAddress
#define InetAddress
Definition: address.h:75
QueueRTCPManager::rtcpAvgSize
uint16 rtcpAvgSize
Definition: cqueue.h:591
QueueRTCPManager::rtcpInitial
bool rtcpInitial
Definition: cqueue.h:592
QueueRTCPManager::rtcpLastCheck
timeval rtcpLastCheck
Definition: cqueue.h:594
QueueRTCPManager::lastSchedulable
static const SDESItemType lastSchedulable
Definition: cqueue.h:580
QueueRTCPManager::networkHeaderSize
virtual uint16 networkHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
Definition: cqueue.h:537
QueueRTCPManager::setSendersControlFraction
void setSendersControlFraction(float fraction)
Specify the fraction of the total control bandwith to be dedicated to senders reports.
Definition: cqueue.h:158
__EXPORT
#define __EXPORT
Definition: audio2.h:51
QueueRTCPManager::TIMEOUT_MULTIPLIER
static const uint16 TIMEOUT_MULTIPLIER
Definition: cqueue.h:618
QueueRTCPManager::sendControlBwFract
float sendControlBwFract
Definition: cqueue.h:570
RTCPReceiverInfo
Report block information of SR/RR RTCP reports.
Definition: rtcppkt.h:376
QueueRTCPManager::leavingDelay
microtimeout_t leavingDelay
Definition: cqueue.h:609
AVPQueue::~AVPQueue
virtual ~AVPQueue()
Definition: cqueue.h:669
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:420
RTCPCompoundHandler::APPPacket
Struct for APP (application specific) RTCP packets.
Definition: rtcppkt.h:215
QueueRTCPManager::setPrevMembersNum
void setPrevMembersNum(uint32 n)
Definition: cqueue.h:311
defaultApplication
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
QueueRTCPManager::onSSRCCollision
virtual void onSSRCCollision(const SyncSource &)
Plug-in for SSRC collision handling.
Definition: cqueue.h:402
QueueRTCPManager::lastSendPacketCount
uint32 lastSendPacketCount
Definition: cqueue.h:602
QueueRTCPManager::setEnd2EndDelay
void setEnd2EndDelay(microtimeout_t t)
This method sets the maximum end to end delay allowed.
Definition: cqueue.h:133
RTPDataQueue
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:77
SDESItemType
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Definition: rtcppkt.h:67
QueueRTCPManager::queueApplication
RTPApplication & queueApplication
Definition: cqueue.h:615
AVPQueue
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:629

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

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