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
00161 void
00162 setMinRTCPInterval(microtimeout_t);
00163
00167 inline uint32
00168 getSendRTCPPacketCount() const
00169 { return ctrlSendCount; }
00170
00171 protected:
00172 QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
00173 RTPApplication& app = defaultApplication());
00174
00175 QueueRTCPManager(uint32 ssrc,
00176 uint32 size = RTPDataQueue::defaultMembersHashSize,
00177 RTPApplication& app = defaultApplication());
00178
00179 virtual
00180 ~QueueRTCPManager();
00181
00182 const RTPApplication&
00183 getApplication()
00184 { return queueApplication; }
00185
00186 inline void
00187 setControlBandwidth(float fraction)
00188 { controlBwFract = fraction; }
00189
00190 float
00191 getControlBandwidth() const
00192 { return controlBwFract; }
00193
00198 void
00199 controlTransmissionService();
00200
00205 void
00206 controlReceptionService();
00207
00220 bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
00221 InetAddress& na, tpport_t tp);
00222
00223 void
00224 endQueueRTCPManager();
00225
00236 virtual void
00237 onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
00238
00249 virtual void
00250 onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
00251
00256 bool
00257 onGotSDES(SyncSource& source, RTCPPacket& pkt);
00258
00268 virtual bool
00269 onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
00270
00280 inline virtual void
00281 onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
00282 size_t)
00283 { return; }
00284
00285 inline timeval
00286 getRTCPCheckInterval()
00287 { return rtcpCheckInterval; }
00288
00293 uint32
00294 getLastSendPacketCount() const
00295 { return lastSendPacketCount; }
00296
00300 inline void
00301 setPrevMembersNum(uint32 n)
00302 { reconsInfo.rtcpPMembers = n; };
00303
00304 inline uint32
00305 getPrevMembersCount() const
00306 { return reconsInfo.rtcpPMembers; };
00307
00326 size_t
00327 dispatchBYE(const std::string& reason);
00328
00329 size_t
00330 sendControlToDestinations(unsigned char* buffer, size_t len);
00331
00332 private:
00333 QueueRTCPManager(const QueueRTCPManager &o);
00334
00335 QueueRTCPManager&
00336 operator=(const QueueRTCPManager &o);
00337
00343 size_t
00344 dispatchControlPacket();
00345
00357 void
00358 takeInControlPacket();
00359
00373 virtual timeval
00374 computeRTCPInterval();
00375
00383 virtual SDESItemType
00384 scheduleSDESItem();
00385
00391 inline virtual void
00392 onSSRCCollision(const SyncSource&)
00393 { }
00394
00398 virtual bool
00399 end2EndDelayed(IncomingRTPPktLink& p);
00400
00409 inline virtual void
00410 onGotRRSRExtension(unsigned char*, size_t)
00411 { return; }
00412
00422 inline virtual void
00423 onGotGoodbye(const SyncSource&, const std::string&)
00424 { return; }
00425
00438 bool
00439 getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
00440
00444 uint8
00445 packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
00446
00455 void
00456 packSDES(uint16& len);
00457
00469 void
00470 updateAvgRTCPSize(size_t len);
00471
00477 void
00478 reverseReconsideration();
00479
00480 bool
00481 timerReconsideration();
00482
00491 void
00492 expireSSRCs();
00493
00497 void
00498 getOnlyBye();
00499
00504 void
00505 setSDESItem(Participant* part, SDESItemType type,
00506 const char* const value, size_t len);
00507
00512 void
00513 setPRIVPrefix(Participant* part, const char* const value, size_t len);
00514
00526 inline virtual uint16
00527 networkHeaderSize()
00528 { return 20; }
00529
00541 inline virtual uint16
00542 transportHeaderSize()
00543 { return 8; }
00544
00545 SDESItemType
00546 nextSDESType(SDESItemType t);
00547
00548 virtual size_t
00549 sendControl(const unsigned char* const buffer, size_t len) = 0;
00550
00551 virtual size_t
00552 recvControl(unsigned char* buffer, size_t len,
00553 InetHostAddress& na, tpport_t& tp) = 0;
00554
00555 virtual bool
00556 isPendingControl(microtimeout_t timeout) = 0;
00557
00558
00559 volatile bool controlServiceActive;
00560 float controlBwFract, sendControlBwFract, recvControlBwFract;
00561
00562 uint32 ctrlSendCount;
00563
00564
00565
00566 uint16 lowerHeadersSize;
00567
00568 SDESItemType nextScheduledSDESItem;
00569 static const SDESItemType firstSchedulable;
00570 static const SDESItemType lastSchedulable;
00571
00572
00573
00574
00575
00576 struct {
00577 timeval rtcpTp, rtcpTc, rtcpTn;
00578 uint32 rtcpPMembers;
00579 } reconsInfo;
00580 bool rtcpWeSent;
00581 uint16 rtcpAvgSize;
00582 bool rtcpInitial;
00583
00584 timeval rtcpLastCheck;
00585
00586 timeval rtcpCheckInterval;
00587
00588 timeval rtcpNextCheck;
00589
00590
00591
00592 uint32 lastSendPacketCount;
00593
00594
00595
00596
00597 microtimeout_t rtcpMinInterval;
00598
00599 microtimeout_t leavingDelay;
00600 static const microtimeout_t defaultEnd2EndDelay;
00601
00602
00603 microtimeout_t end2EndDelay;
00604
00605 RTPApplication& queueApplication;
00606
00607
00608 static const uint16 TIMEOUT_MULTIPLIER;
00609 static const double RECONSIDERATION_COMPENSATION;
00610 };
00611
00619 class AVPQueue : public QueueRTCPManager
00620 {
00621 public:
00637 inline void
00638 setControlBandwidth(float fraction)
00639 { QueueRTCPManager::setControlBandwidth(fraction); }
00640
00641 float
00642 getControlBandwidth() const
00643 { return QueueRTCPManager::getControlBandwidth(); }
00644
00645 protected:
00646 AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
00647 RTPApplication& app = defaultApplication()) :
00648 QueueRTCPManager(size,app)
00649 { }
00650
00654 AVPQueue(uint32 ssrc, uint32 size =
00655 RTPDataQueue::defaultMembersHashSize,
00656 RTPApplication& app = defaultApplication()) :
00657 QueueRTCPManager(ssrc,size,app)
00658 { }
00659 inline virtual ~AVPQueue()
00660 { }
00661 };
00662
00664
00665 #ifdef CCXX_NAMESPACES
00666 }
00667 #endif
00668
00669 #endif //CCXX_RTP_CQUEUE_H_
00670