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
48
49 #ifdef CCXX_NAMESPACES
50 namespace ost {
51 #endif
52
82 {
83 public:
94
106
116 { leavingDelay = delay; }
117
132 inline void
134 { end2EndDelay = t; }
135
138 { return defaultEnd2EndDelay; }
139
142 { return end2EndDelay; }
143
157 inline void
159 { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
160
170 void
172 { rtcpMinInterval = interval; }
173
177 inline uint32
179 { return ctrlSendCount; }
180
181 protected:
184
188
189 virtual
191
194 { return queueApplication; }
195
196 inline void
198 { controlBwFract = fraction; }
199
200 float
202 { return controlBwFract; }
203
208 void
209 controlTransmissionService();
210
215 void
216 controlReceptionService();
217
230 bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
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
292 size_t)
293 { return; }
294
295 inline timeval
297 { return rtcpCheckInterval; }
298
303 uint32
305 { return lastSendPacketCount; }
306
310 inline void
312 { reconsInfo.rtcpPMembers = n; }
313
314 inline uint32
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:
344
347
353 size_t
354 dispatchControlPacket();
355
367 void
368 takeInControlPacket();
369
383 virtual timeval
384 computeRTCPInterval();
385
394 scheduleSDESItem();
395
401 inline virtual void
403 { }
404
408 virtual bool
409 end2EndDelayed(IncomingRTPPktLink& p);
410
419 inline virtual void
421 { return; }
422
432 inline virtual void
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
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
538 { return 20; }
539
551 inline virtual uint16
553 { return 8; }
554
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,
564
565 virtual bool
567
568 // whether the RTCP service is active
571 // number of RTCP packets sent since the beginning
573
574 // Network + transport headers size, typically size of IP +
575 // UDP headers
577
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 {
589 } reconsInfo;
593 // last time we checked if there were incoming RTCP packets
595 // interval to check if there are incoming RTCP packets
597 // next time to check if there are incoming RTCP packets
599
600 // number of RTP data packets sent at the time of the last
601 // RTCP packet transmission.
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).
608
611 // Maximum delay allowed between packet timestamping and
612 // packet availability for the application.
614 // Application this queue is bound to.
616
617 // an empty RTPData
620 };
621
630 {
631 public:
647 inline void
650
651 float
654
655 protected:
659 { }
660
668 { }
670 { }
671 };
672 // cqueue
674
675 #ifdef CCXX_NAMESPACES
676 }
677 #endif
678
679 #endif //CCXX_RTP_CQUEUE_H_
680
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
microtimeout_t getEnd2EndDelay() const
low level structs and RTCP packet parsing and building methods.
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
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.
unsigned short tpport_t
Transport Protocol Ports.
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
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...
virtual uint16 transportHeaderSize()
For certain control calculations in RTCP, the size of the underlying network and transport protocols ...
microtimeout_t rtcpMinInterval
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
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...