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
48 #include <list>
49
50 NAMESPACE_COMMONCPP
51
81 {
82 public:
93
105
115 { leavingDelay = delay; }
116
131 inline void
133 { end2EndDelay = t; }
134
137 { return defaultEnd2EndDelay; }
138
141 { return end2EndDelay; }
142
156 inline void
158 { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
159
169 void
171 { rtcpMinInterval = interval; }
172
176 inline uint32
178 { return ctrlSendCount; }
179
188 void
190
199 void
201
210 getOutQueueCryptoContextCtrl(uint32 ssrc);
211
212
221 void
223
234 void
236
245 getInQueueCryptoContextCtrl(uint32 ssrc);
246
247 protected:
250
254
255 virtual
257
260 { return queueApplication; }
261
262 inline void
264 { controlBwFract = fraction; }
265
266 float
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
358 size_t)
359 { return; }
360
361 inline timeval
363 { return rtcpCheckInterval; }
364
369 uint32
371 { return lastSendPacketCount; }
372
376 inline void
378 { reconsInfo.rtcpPMembers = n; }
379
380 inline uint32
382 { return reconsInfo.rtcpPMembers; }
383
402 size_t
404
405 size_t
406 sendControlToDestinations(unsigned char* buffer, size_t len);
407
408 private:
410
413
419 size_t
420 dispatchControlPacket();
421
433 void
434 takeInControlPacket();
435
449 virtual timeval
450 computeRTCPInterval();
451
460 scheduleSDESItem();
461
467 inline virtual void
469 { }
470
474 virtual bool
476
485 inline virtual void
487 { return; }
488
498 inline virtual void
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
582 const char* const value, size_t len);
583
588 void
590
602 inline virtual uint16
604 { return 20; }
605
617 inline virtual uint16
619 { return 8; }
620
621
624
625
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
638
639 // whether the RTCP service is active
642 // number of RTCP packets sent since the beginning
644
645 // Network + transport headers size, typically size of IP +
646 // UDP headers
648
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 {
660 } reconsInfo;
664 // last time we checked if there were incoming RTCP packets
666 // interval to check if there are incoming RTCP packets
668 // next time to check if there are incoming RTCP packets
670
671 // number of RTP data packets sent at the time of the last
672 // RTCP packet transmission.
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).
679
682 // Maximum delay allowed between packet timestamping and
683 // packet availability for the application.
685 // Application this queue is bound to.
687
688 // an empty RTPData
691
695
698
699 };
700
709 {
710 public:
726 inline void
729
730 float
733
734 protected:
738 { }
739
747 { }
749 { }
750 };
751 // cqueue
753
754 END_NAMESPACE
755
756 #endif //CCXX_RTP_CQUEUE_H_
757
Generic RTP input/output queues.
uint32 getLastSendPacketCount() const
Get the number of data packets sent at the time the last SR was generated.
microtimeout_t getDefaultEnd2EndDelay() const
The implementation for a SRTCP cryptographic context.
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
microtimeout_t getEnd2EndDelay() const
low level structs and RTCP packet parsing and building methods.
std::list< CryptoContextCtrl * > outCryptoContexts
An RTP application, holding identifying RTCP SDES item values.
float getControlBandwidth() const
Synchronization source in an RTP session.
static const SDESItemType firstSchedulable
float getControlBandwidth() const
void setPRIVPrefix(Participant *part, const std::string val)
uint32 getPrevMembersCount() const
volatile bool controlServiceActive
uint32 microtimeout_t
Time interval expressed in microseconds.
Sender block information of SR RTCP reports.
microtimeout_t end2EndDelay
Adds generic management of RTCP functions to an RTP data queue.
virtual bool end2EndDelayed(IncomingRTPPktLink &)
void setMinRTCPInterval(microtimeout_t interval)
Manually set the minimum interval for sending RTP compound packets.
timeval rtcpCheckInterval
void setLeavingDelay(microtimeout_t delay)
Set how much time the stack will wait before deleting a synchronization source that has sent an RTCP ...
AVPQueue(uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
static const microtimeout_t defaultEnd2EndDelay
maximum end to end delay: unlimited
AVPQueue(uint32 ssrc, uint32 size=RTPDataQueue::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Local SSRC is given instead of computed by the queue.
virtual void onGotAPP(SyncSource &, RTCPCompoundHandler::APPPacket &, size_t)
Plug-in for handling of APP (application specific) RTCP packets.
timeval getRTCPCheckInterval()
virtual void onGotGoodbye(const SyncSource &, const std::string &)
A plugin point for goodbye message.
uint32 getSendRTCPPacketCount() const
Get the total number of RTCP packets sent until now.
static const double RECONSIDERATION_COMPENSATION
A class of objects representing remote participants (RTP applications) in a multimedia session...
RTPDataQueue & operator=(const RTPDataQueue &o)
virtual uint16 transportHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
microtimeout_t rtcpMinInterval
void setSDESItem(Participant *part, SDESItemType item, const std::string &val)
static const size_t defaultMembersHashSize
void setControlBandwidth(float fraction)
Specify the bandwith available for control (RTCP) packets.
void setControlBandwidth(float fraction)
SDESItemType nextScheduledSDESItem
const RTPApplication & getApplication()
static const SDESItemType lastSchedulable
virtual uint16 networkHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
void setSendersControlFraction(float fraction)
Specify the fraction of the total control bandwith to be dedicated to senders reports.
static const uint16 TIMEOUT_MULTIPLIER
Report block information of SR/RR RTCP reports.
microtimeout_t leavingDelay
std::list< CryptoContextCtrl * > inCryptoContexts
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 ...
Struct for APP (application specific) RTCP packets.
void setPrevMembersNum(uint32 n)
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
virtual void onSSRCCollision(const SyncSource &)
Plug-in for SSRC collision handling.
uint32 lastSendPacketCount
void setEnd2EndDelay(microtimeout_t t)
This method sets the maximum end to end delay allowed.
A packet queue handler for building different kinds of RTP protocol systems.
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
RTPApplication & queueApplication
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...