00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00044 #ifndef CCXX_RTP_CQUEUE_H_
00045 #define CCXX_RTP_CQUEUE_H_
00046
00047 #include <ccrtp/ioqueue.h>
00048
00049 #ifdef CCXX_NAMESPACES
00050 namespace ost {
00051 #endif
00052
00080 class __EXPORT QueueRTCPManager : public RTPDataQueue,
00081 protected RTCPCompoundHandler
00082 {
00083 public:
00093 RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
00094
00105 RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
00106
00115 void setLeavingDelay(microtimeout_t delay)
00116 { leavingDelay = delay; }
00117
00132 inline void
00133 setEnd2EndDelay(microtimeout_t t)
00134 { end2EndDelay = t; }
00135
00136 inline microtimeout_t
00137 getDefaultEnd2EndDelay() const
00138 { return defaultEnd2EndDelay; }
00139
00140 inline microtimeout_t
00141 getEnd2EndDelay() const
00142 { return end2EndDelay; }
00143
00157 inline void
00158 setSendersControlFraction(float fraction)
00159 { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
00160
00170 void
00171 setMinRTCPInterval(microtimeout_t interval)
00172 { rtcpMinInterval = interval; }
00173
00177 inline uint32
00178 getSendRTCPPacketCount() const
00179 { return ctrlSendCount; }
00180
00181 protected:
00182 QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
00183 RTPApplication& app = defaultApplication());
00184
00185 QueueRTCPManager(uint32 ssrc,
00186 uint32 size = RTPDataQueue::defaultMembersHashSize,
00187 RTPApplication& app = defaultApplication());
00188
00189 virtual
00190 ~QueueRTCPManager();
00191
00192 const RTPApplication&
00193 getApplication()
00194 { return queueApplication; }
00195
00196 inline void
00197 setControlBandwidth(float fraction)
00198 { controlBwFract = fraction; }
00199
00200 float
00201 getControlBandwidth() const
00202 { return controlBwFract; }
00203
00208 void
00209 controlTransmissionService();
00210
00215 void
00216 controlReceptionService();
00217
00230 bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
00231 InetAddress& na, tpport_t tp);
00232
00233 void
00234 endQueueRTCPManager();
00235
00246 virtual void
00247 onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
00248
00259 virtual void
00260 onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
00261
00266 bool
00267 onGotSDES(SyncSource& source, RTCPPacket& pkt);
00268
00278 virtual bool
00279 onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
00280
00290 inline virtual void
00291 onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
00292 size_t)
00293 { return; }
00294
00295 inline timeval
00296 getRTCPCheckInterval()
00297 { return rtcpCheckInterval; }
00298
00303 uint32
00304 getLastSendPacketCount() const
00305 { return lastSendPacketCount; }
00306
00310 inline void
00311 setPrevMembersNum(uint32 n)
00312 { reconsInfo.rtcpPMembers = n; }
00313
00314 inline uint32
00315 getPrevMembersCount() const
00316 { return reconsInfo.rtcpPMembers; }
00317
00336 size_t
00337 dispatchBYE(const std::string& reason);
00338
00339 size_t
00340 sendControlToDestinations(unsigned char* buffer, size_t len);
00341
00342 private:
00343 QueueRTCPManager(const QueueRTCPManager &o);
00344
00345 QueueRTCPManager&
00346 operator=(const QueueRTCPManager &o);
00347
00353 size_t
00354 dispatchControlPacket();
00355
00367 void
00368 takeInControlPacket();
00369
00383 virtual timeval
00384 computeRTCPInterval();
00385
00393 virtual SDESItemType
00394 scheduleSDESItem();
00395
00401 inline virtual void
00402 onSSRCCollision(const SyncSource&)
00403 { }
00404
00408 virtual bool
00409 end2EndDelayed(IncomingRTPPktLink& p);
00410
00419 inline virtual void
00420 onGotRRSRExtension(unsigned char*, size_t)
00421 { return; }
00422
00432 inline virtual void
00433 onGotGoodbye(const SyncSource&, const std::string&)
00434 { return; }
00435
00448 bool
00449 getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
00450
00454 uint8
00455 packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
00456
00465 void
00466 packSDES(uint16& len);
00467
00479 void
00480 updateAvgRTCPSize(size_t len);
00481
00487 void
00488 reverseReconsideration();
00489
00490 bool
00491 timerReconsideration();
00492
00501 void
00502 expireSSRCs();
00503
00507 void
00508 getOnlyBye();
00509
00514 void
00515 setSDESItem(Participant* part, SDESItemType type,
00516 const char* const value, size_t len);
00517
00522 void
00523 setPRIVPrefix(Participant* part, const char* const value, size_t len);
00524
00536 inline virtual uint16
00537 networkHeaderSize()
00538 { return 20; }
00539
00551 inline virtual uint16
00552 transportHeaderSize()
00553 { return 8; }
00554
00555 SDESItemType
00556 nextSDESType(SDESItemType t);
00557
00558 virtual size_t
00559 sendControl(const unsigned char* const buffer, size_t len) = 0;
00560
00561 virtual size_t
00562 recvControl(unsigned char* buffer, size_t len,
00563 InetHostAddress& na, tpport_t& tp) = 0;
00564
00565 virtual bool
00566 isPendingControl(microtimeout_t timeout) = 0;
00567
00568
00569 volatile bool controlServiceActive;
00570 float controlBwFract, sendControlBwFract, recvControlBwFract;
00571
00572 uint32 ctrlSendCount;
00573
00574
00575
00576 uint16 lowerHeadersSize;
00577
00578 SDESItemType nextScheduledSDESItem;
00579 static const SDESItemType firstSchedulable;
00580 static const SDESItemType lastSchedulable;
00581
00582
00583
00584
00585
00586 struct {
00587 timeval rtcpTp, rtcpTc, rtcpTn;
00588 uint32 rtcpPMembers;
00589 } reconsInfo;
00590 bool rtcpWeSent;
00591 uint16 rtcpAvgSize;
00592 bool rtcpInitial;
00593
00594 timeval rtcpLastCheck;
00595
00596 timeval rtcpCheckInterval;
00597
00598 timeval rtcpNextCheck;
00599
00600
00601
00602 uint32 lastSendPacketCount;
00603
00604
00605
00606
00607 microtimeout_t rtcpMinInterval;
00608
00609 microtimeout_t leavingDelay;
00610 static const microtimeout_t defaultEnd2EndDelay;
00611
00612
00613 microtimeout_t end2EndDelay;
00614
00615 RTPApplication& queueApplication;
00616
00617
00618 static const uint16 TIMEOUT_MULTIPLIER;
00619 static const double RECONSIDERATION_COMPENSATION;
00620 };
00621
00629 class AVPQueue : public QueueRTCPManager
00630 {
00631 public:
00647 inline void
00648 setControlBandwidth(float fraction)
00649 { QueueRTCPManager::setControlBandwidth(fraction); }
00650
00651 float
00652 getControlBandwidth() const
00653 { return QueueRTCPManager::getControlBandwidth(); }
00654
00655 protected:
00656 AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
00657 RTPApplication& app = defaultApplication()) :
00658 QueueRTCPManager(size,app)
00659 { }
00660
00664 AVPQueue(uint32 ssrc, uint32 size =
00665 RTPDataQueue::defaultMembersHashSize,
00666 RTPApplication& app = defaultApplication()) :
00667 QueueRTCPManager(ssrc,size,app)
00668 { }
00669 inline virtual ~AVPQueue()
00670 { }
00671 };
00672
00674
00675 #ifdef CCXX_NAMESPACES
00676 }
00677 #endif
00678
00679 #endif //CCXX_RTP_CQUEUE_H_
00680