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

Bayonne2 / Common C++ 2 Framework
rtcppkt.h
Go to the documentation of this file.
1 // Copyright (C) 2001,2002,2004,2007 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 
38 #ifndef CCXX_RTP_RTCPPKT_H_
39 #define CCXX_RTP_RTCPPKT_H_
40 
41 #include <ccrtp/base.h>
42 
43 #ifdef CCXX_NAMESPACES
44 namespace ost {
45 #endif
46 
67  typedef enum
68 {
69   SDESItemTypeEND = 0,
70   SDESItemTypeCNAME,
71   SDESItemTypeNAME,
72   SDESItemTypeEMAIL,
73   SDESItemTypePHONE,
74   SDESItemTypeLOC,
75   SDESItemTypeTOOL,
76   SDESItemTypeNOTE,
77   SDESItemTypePRIV,
78   SDESItemTypeH323CADDR,
79   SDESItemTypeLast = SDESItemTypeH323CADDR
80 } SDESItemType;
81 
92  class __EXPORT RTCPCompoundHandler
93 {
94 public:
95   inline void setPathMTU(uint16 mtu)
96  { pathMTU = mtu; }
97 
98   inline uint16 getPathMTU()
99  { return pathMTU; }
100 
101 #ifdef CCXX_PACKED
102 #pragma pack(1)
103 #endif
104 
111   struct ReceiverInfo
112  {
113   uint8 fractionLost;
114   uint8 lostMSB;
115   uint16 lostLSW;
116   uint32 highestSeqNum;
117   uint32 jitter;
118   uint32 lsr;
119   uint32 dlsr;
120  };
121 
128   struct RRBlock
129  {
130   uint32 ssrc;
131   ReceiverInfo rinfo;
132  };
133 
140   struct RecvReport
141  {
142   uint32 ssrc;
143   RRBlock blocks[1];
144  };
145 
152   struct SenderInfo
153  {
154   uint32 NTPMSW;
155   uint32 NTPLSW;
156   uint32 RTPTimestamp;
157   uint32 packetCount;
158   uint32 octetCount;
159  };
160 
166   struct SendReport
167  {
168   uint32 ssrc;
169   SenderInfo sinfo;
170   RRBlock blocks[1];
171  };
172 
178   struct SDESItem
179  {
180   uint8 type;
181   uint8 len;
182   char data[1];
183  };
184 
190   struct SDESChunk
191  {
192   uint32 getSSRC() const
193 { return (ntohl(ssrc)); }
194 
195   uint32 ssrc;
196   SDESItem item;
197  };
198 
204   struct BYEPacket
205  {
206   uint32 ssrc;
207   uint8 length;
208  };
209 
215   struct APPPacket
216  {
217   uint32 ssrc;
218   char name [4];
219  unsigned char data[1];
222  };
223 
230   struct FIRPacket
231  {
232   uint32 ssrc;
233  };
234 
241   struct NACKPacket
242  {
243   uint32 ssrc;
244   uint16 fsn;
245   uint16 blp;
246  };
247 
253   struct RTCPFixedHeader
254  {
255 #if __BYTE_ORDER == __BIG_ENDIAN
256  unsigned char version:2;
258   unsigned char padding:1;
259   unsigned char block_count:5;
260 #else
261  unsigned char block_count:5;
263  unsigned char padding:1;
264  unsigned char version:2;
265 #endif
266   uint8 type;
267   uint16 length;
268  };
269 
280   struct RTCPPacket
281  {
287   typedef enum {
288   tSR = 200,
289   tRR,
290   tSDES,
291   tBYE,
292   tAPP,
293   tFIR = 192,
294   tNACK = 193,
295   tXR
296  } Type;
297 
302   uint32 getLength() const
303 { return ((ntohs(fh.length) + 1) << 2); }
304 
309   uint32 getSSRC() const
310 { return (ntohl(info.RR.ssrc)); } // SSRC is always the first
311  // word after fh.
312 
313   RTCPFixedHeader fh;
314 
315  // An RTCP packet may be of any of the types defined
316  // above, including APP specific ones.
317  union
318  {
319   SendReport SR;
320   RecvReport RR;
321   SDESChunk SDES;
322   BYEPacket BYE;
323   APPPacket APP;
324   NACKPacket NACK;
325   FIRPacket FIR;
326  } info;
327  };
328 #ifdef CCXX_PACKED
329 #pragma pack()
330 #endif
331 
332 protected:
333   enum { defaultPathMTU = 1500 };
334 
335  RTCPCompoundHandler(uint16 mtu = defaultPathMTU);
336 
337  ~RTCPCompoundHandler();
338 
350  bool
351  checkCompoundRTCPHeader(size_t len);
352 
353  // buffer to hold RTCP compound packets being sent. Allocated
354  // in construction time
355   unsigned char* rtcpSendBuffer;
356  // buffer to hold RTCP compound packets being
357  // received. Allocated at construction time
358   unsigned char* rtcpRecvBuffer;
359 
360   friend class RTCPSenderInfo;
361   friend class RTCPReceiverInfo;
362 private:
363  // path MTU. RTCP packets should not be greater than this
364   uint16 pathMTU;
365  // masks for RTCP header validation;
366   static const uint16 RTCP_VALID_MASK;
367   static const uint16 RTCP_VALID_VALUE;
368 };
369 
376  class __EXPORT RTCPReceiverInfo
377 {
378 public:
379   RTCPReceiverInfo(void* ri)
380  { memcpy(&receiverInfo,&ri,
381  sizeof(RTCPCompoundHandler::ReceiverInfo));}
382 
383   RTCPReceiverInfo(RTCPCompoundHandler::ReceiverInfo& si)
384  : receiverInfo( si )
385  {
386  }
387 
388   ~RTCPReceiverInfo()
389  { }
390 
395  inline uint8
396   getFractionLost() const
397 { return receiverInfo.fractionLost; }
398 
399  inline uint32
400   getCumulativePacketLost() const
401 { return ( ((uint32)ntohs(receiverInfo.lostLSW)) +
402  (((uint32)receiverInfo.lostMSB) << 16) ); }
403 
404  inline uint32
405   getExtendedSeqNum() const
406 { return ntohl(receiverInfo.highestSeqNum); }
407 
414  uint32
415   getJitter() const
416 { return ntohl(receiverInfo.jitter); }
417 
423  uint16
424   getLastSRNTPTimestampInt() const
425 { return (uint16)((ntohl(receiverInfo.lsr) & 0xFFFF0000) >> 16); }
426 
432  uint16
433   getLastSRNTPTimestampFrac() const
434 { return (uint16)(ntohl(receiverInfo.lsr) & 0xFFFF); }
435 
442  uint32
443   getDelayLastSR() const
444 { return ntohl(receiverInfo.dlsr); }
445 
446 private:
447   RTCPCompoundHandler::ReceiverInfo receiverInfo;
448 };
449 
456  class __EXPORT RTCPSenderInfo
457 {
458 public:
459   RTCPSenderInfo(void* si)
460  { memcpy(&senderInfo,&si,
461  sizeof(RTCPCompoundHandler::SenderInfo));}
462 
463   RTCPSenderInfo(RTCPCompoundHandler::SenderInfo& si)
464  : senderInfo( si )
465  {
466  }
467 
468   ~RTCPSenderInfo()
469  { }
470 
475  uint32
476   getNTPTimestampInt() const
477 { return ntohl(senderInfo.NTPMSW); }
478 
483  uint32
484   getNTPTimestampFrac() const
485 { return ntohl(senderInfo.NTPLSW); }
486 
487  inline uint32
488   getRTPTimestamp() const
489 { return ntohl(senderInfo.RTPTimestamp); }
490 
494  inline uint32
495   getPacketCount() const
496 { return ntohl(senderInfo.packetCount); }
497 
498  inline uint32
499   getOctetCount() const
500 { return ntohl(senderInfo.octetCount); }
501 
502 private:
503   RTCPCompoundHandler::SenderInfo senderInfo;
504 };
505 
514 timeval
515 NTP2Timeval(uint32 msw, uint32 lsw);
516 
524 uint32
525 timevalIntervalTo65536(timeval& t);
526  // rtcppacket
528 
529 #ifdef CCXX_NAMESPACES
530 }
531 #endif
532 
533 #endif // ndef CCXX_RTP_RTCPPKT_H_
534 
RTCPCompoundHandler::RRBlock
Struct for a receiver info block in a SR (sender report) or an RR (receiver report) RTCP packet...
Definition: rtcppkt.h:128
RTCPCompoundHandler::ReceiverInfo::lsr
uint32 lsr
last sender report timestamp.
Definition: rtcppkt.h:118
RTCPSenderInfo::getNTPTimestampFrac
uint32 getNTPTimestampFrac() const
Get fractional part of the NTP timestamp of this packet.
Definition: rtcppkt.h:484
RTCPSenderInfo::getNTPTimestampInt
uint32 getNTPTimestampInt() const
Get integer part of the NTP timestamp of this packet.
Definition: rtcppkt.h:476
RTCPReceiverInfo::RTCPReceiverInfo
RTCPReceiverInfo(RTCPCompoundHandler::ReceiverInfo &si)
Definition: rtcppkt.h:383
RTCPCompoundHandler::rtcpSendBuffer
unsigned char * rtcpSendBuffer
Definition: rtcppkt.h:355
RTCPCompoundHandler
low level structs and RTCP packet parsing and building methods.
Definition: rtcppkt.h:92
SDESItemTypeLast
Last defined code.
Definition: rtcppkt.h:79
RTCPCompoundHandler::RTCPPacket::tBYE
End of participation.
Definition: rtcppkt.h:291
RTCPCompoundHandler::RRBlock::rinfo
ReceiverInfo rinfo
info about the source.
Definition: rtcppkt.h:131
RTCPCompoundHandler::ReceiverInfo::highestSeqNum
uint32 highestSeqNum
highest sequence number.
Definition: rtcppkt.h:116
RTCPCompoundHandler::BYEPacket::ssrc
uint32 ssrc
ssrc identifier of source leaving.
Definition: rtcppkt.h:206
RTCPCompoundHandler::ReceiverInfo::jitter
uint32 jitter
arrival jitter.
Definition: rtcppkt.h:117
RTCPCompoundHandler::SenderInfo::octetCount
uint32 octetCount
cumulative octet counter.
Definition: rtcppkt.h:158
RTCPCompoundHandler::RTCP_VALID_MASK
static const uint16 RTCP_VALID_MASK
Definition: rtcppkt.h:366
RTCPSenderInfo
Sender block information of SR RTCP reports.
Definition: rtcppkt.h:456
RTCPCompoundHandler::RTCPPacket::tAPP
APPlication specific.
Definition: rtcppkt.h:292
SDESItemTypeCNAME
Canonical end-point identifier.
Definition: rtcppkt.h:70
RTCPReceiverInfo::getLastSRNTPTimestampFrac
uint16 getLastSRNTPTimestampFrac() const
Get the fractional part of the NTP timestamp of the last SR RTCP packet received from the source this...
Definition: rtcppkt.h:433
SDESItemTypeNOTE
Comment usually reporting state.
Definition: rtcppkt.h:76
RTCPCompoundHandler::pathMTU
uint16 pathMTU
Definition: rtcppkt.h:364
RTCPCompoundHandler::RTCP_VALID_VALUE
static const uint16 RTCP_VALID_VALUE
Definition: rtcppkt.h:367
RTCPCompoundHandler::RTCPPacket::getLength
uint32 getLength() const
Get the packet length specified in its header, in octets and in host order.
Definition: rtcppkt.h:302
info
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
Definition: applog.h:581
RTCPCompoundHandler::setPathMTU
void setPathMTU(uint16 mtu)
Definition: rtcppkt.h:95
RTCPReceiverInfo::RTCPReceiverInfo
RTCPReceiverInfo(void *ri)
Definition: rtcppkt.h:379
RTCPCompoundHandler::ReceiverInfo::dlsr
uint32 dlsr
delay since last sender report.
Definition: rtcppkt.h:119
RTCPCompoundHandler::RTCPFixedHeader
Fixed RTCP packet header.
Definition: rtcppkt.h:253
RTCPReceiverInfo::getLastSRNTPTimestampInt
uint16 getLastSRNTPTimestampInt() const
Get the integer part of the NTP timestamp of the last SR RTCP packet received from the source this re...
Definition: rtcppkt.h:424
SDESItemTypePHONE
Phone number of the user.
Definition: rtcppkt.h:73
RTCPCompoundHandler::ReceiverInfo::lostLSW
uint16 lostLSW
cumulative lost two LSB.
Definition: rtcppkt.h:115
RTCPSenderInfo::~RTCPSenderInfo
~RTCPSenderInfo()
Definition: rtcppkt.h:468
RTCPCompoundHandler::BYEPacket
Struct for BYE (leaving session) RTCP packets.
Definition: rtcppkt.h:204
RTCPCompoundHandler::ReceiverInfo::lostMSB
uint8 lostMSB
cumulative lost MSB of 3 octets.
Definition: rtcppkt.h:114
RTCPCompoundHandler::SDESItem::len
uint8 len
item len in octets.
Definition: rtcppkt.h:181
RTCPCompoundHandler::RTCPFixedHeader::type
uint8 type
type of RTCP packet.
Definition: rtcppkt.h:266
RTCPCompoundHandler::SDESChunk::ssrc
uint32 ssrc
SSRC identifer from sender.
Definition: rtcppkt.h:195
RTCPCompoundHandler::SenderInfo::NTPMSW
uint32 NTPMSW
NTP timestamp higher octets.
Definition: rtcppkt.h:154
RTCPCompoundHandler::NACKPacket::ssrc
uint32 ssrc
ssrc identifier of source.
Definition: rtcppkt.h:243
RTCPSenderInfo::getOctetCount
uint32 getOctetCount() const
Definition: rtcppkt.h:499
RTCPCompoundHandler::SenderInfo
Struct for the sender info block in a SR (sender report) RTCP packet.
Definition: rtcppkt.h:152
RTCPCompoundHandler::SendReport
Struct for SR (sender report) RTCP packets.
Definition: rtcppkt.h:166
RTCPCompoundHandler::BYEPacket::length
uint8 length
[optional] length of reason.
Definition: rtcppkt.h:207
RTCPCompoundHandler::SDESChunk::getSSRC
uint32 getSSRC() const
Definition: rtcppkt.h:192
RTCPCompoundHandler::NACKPacket::blp
uint16 blp
Bitmask of following Lost Packets.
Definition: rtcppkt.h:245
RTCPCompoundHandler::SDESItem::type
uint8 type
item identifier.
Definition: rtcppkt.h:180
RTCPCompoundHandler::SendReport::sinfo
SenderInfo sinfo
actual sender info.
Definition: rtcppkt.h:169
RTCPSenderInfo::RTCPSenderInfo
RTCPSenderInfo(void *si)
Definition: rtcppkt.h:459
RTCPCompoundHandler::SDESChunk::item
SDESItem item
SDES item from sender.
Definition: rtcppkt.h:196
RTCPCompoundHandler::SDESChunk
Struct for a chunk of items in a SDES RTCP packet.
Definition: rtcppkt.h:190
SDESItemTypeEND
END of SDES item list.
Definition: rtcppkt.h:69
RTCPCompoundHandler::RTCPPacket
Struct representing general RTCP packet headers as they are sent through the network.
Definition: rtcppkt.h:280
SDESItemTypePRIV
Private extension.
Definition: rtcppkt.h:77
timevalIntervalTo65536
uint32 timevalIntervalTo65536(timeval &t)
Convert a time interval, expressed as a timeval, into a 32-bit time interval expressed in units of 1/...
RTCPSenderInfo::getPacketCount
uint32 getPacketCount() const
Get count of sent data packets.
Definition: rtcppkt.h:495
RTCPSenderInfo::senderInfo
RTCPCompoundHandler::SenderInfo senderInfo
Definition: rtcppkt.h:503
RTCPCompoundHandler::FIRPacket
Struct for Full Intra-frame Request (FIR) RTCP packet.
Definition: rtcppkt.h:230
SDESItemTypeNAME
Personal NAME of the user.
Definition: rtcppkt.h:71
RTCPCompoundHandler::getPathMTU
uint16 getPathMTU()
Definition: rtcppkt.h:98
RTCPCompoundHandler::SenderInfo::RTPTimestamp
uint32 RTPTimestamp
RTP timestamp.
Definition: rtcppkt.h:156
SDESItemTypeH323CADDR
H323 callable address.
Definition: rtcppkt.h:78
RTCPCompoundHandler::NACKPacket::fsn
uint16 fsn
First Sequence Number lost.
Definition: rtcppkt.h:244
RTCPCompoundHandler::RecvReport
raw structure of the source and every receiver report in an SR or RR RTCP packet. ...
Definition: rtcppkt.h:140
RTCPReceiverInfo::~RTCPReceiverInfo
~RTCPReceiverInfo()
Definition: rtcppkt.h:388
__EXPORT
#define __EXPORT
Definition: audio2.h:51
RTCPCompoundHandler::rtcpRecvBuffer
unsigned char * rtcpRecvBuffer
Definition: rtcppkt.h:358
RTCPCompoundHandler::RecvReport::ssrc
uint32 ssrc
source identifier.
Definition: rtcppkt.h:142
RTCPCompoundHandler::RTCPPacket::getSSRC
uint32 getSSRC() const
Get the SSRC identifier specified in the packet header, in host order.
Definition: rtcppkt.h:309
RTCPCompoundHandler::RTCPFixedHeader::length
uint16 length
number of 32-bit words in the packet (minus one).
Definition: rtcppkt.h:267
RTCPCompoundHandler::SDESItem
Struct for an item description of a SDES packet.
Definition: rtcppkt.h:178
base.h
Base elements for RTP stacks: constants, types and global functions.
RTCPSenderInfo::getRTPTimestamp
uint32 getRTPTimestamp() const
Definition: rtcppkt.h:488
RTCPSenderInfo::RTCPSenderInfo
RTCPSenderInfo(RTCPCompoundHandler::SenderInfo &si)
Definition: rtcppkt.h:463
RTCPCompoundHandler::NACKPacket
Struct for Negative ACKnowledgements (NACK) RTCP packet.
Definition: rtcppkt.h:241
RTCPCompoundHandler::ReceiverInfo::fractionLost
uint8 fractionLost
packet fraction lost.
Definition: rtcppkt.h:113
RTCPReceiverInfo
Report block information of SR/RR RTCP reports.
Definition: rtcppkt.h:376
NTP2Timeval
timeval NTP2Timeval(uint32 msw, uint32 lsw)
Convert a NTP timestamp, expressed as two 32-bit long words, into a timeval value.
RTCPReceiverInfo::getDelayLastSR
uint32 getDelayLastSR() const
Get the delay between the last SR packet received and the transmission of this report.
Definition: rtcppkt.h:443
RTCPReceiverInfo::receiverInfo
RTCPCompoundHandler::ReceiverInfo receiverInfo
Definition: rtcppkt.h:447
RTCPCompoundHandler::APPPacket::ssrc
uint32 ssrc
ssrc identifier of source.
Definition: rtcppkt.h:217
RTCPCompoundHandler::RRBlock::ssrc
uint32 ssrc
source identifier.
Definition: rtcppkt.h:130
RTCPReceiverInfo::getCumulativePacketLost
uint32 getCumulativePacketLost() const
Definition: rtcppkt.h:400
RTCPCompoundHandler::APPPacket
Struct for APP (application specific) RTCP packets.
Definition: rtcppkt.h:215
RTCPReceiverInfo::getFractionLost
uint8 getFractionLost() const
Get fraction of lost packets, as a number between 0 and 255.
Definition: rtcppkt.h:396
RTCPReceiverInfo::getJitter
uint32 getJitter() const
Get the statistical variance of the RTP data packets interarrival time.
Definition: rtcppkt.h:415
RTCPCompoundHandler::RTCPPacket::tSDES
Source DEScription.
Definition: rtcppkt.h:290
RTCPCompoundHandler::RTCPPacket::fh
RTCPFixedHeader fh
Fixed RTCP header.
Definition: rtcppkt.h:313
SDESItemTypeTOOL
Application or tool.
Definition: rtcppkt.h:75
RTCPCompoundHandler::SenderInfo::packetCount
uint32 packetCount
cumulative packet counter.
Definition: rtcppkt.h:157
RTCPCompoundHandler::FIRPacket::ssrc
uint32 ssrc
ssrc identifier of source.
Definition: rtcppkt.h:232
RTCPCompoundHandler::SenderInfo::NTPLSW
uint32 NTPLSW
NTP timestamp lower octets.
Definition: rtcppkt.h:155
RTCPReceiverInfo::getExtendedSeqNum
uint32 getExtendedSeqNum() const
Definition: rtcppkt.h:405
SDESItemTypeEMAIL
EMAIL address of the user.
Definition: rtcppkt.h:72
SDESItemType
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Definition: rtcppkt.h:67
RTCPCompoundHandler::ReceiverInfo
Struct for the data contained in a receiver info block.
Definition: rtcppkt.h:111
SDESItemTypeLOC
Location where the user is.
Definition: rtcppkt.h:74
RTCPCompoundHandler::SendReport::ssrc
uint32 ssrc
source identifier.
Definition: rtcppkt.h:168

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 によって変換されたページ (->オリジナル) /