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
42
43 #ifdef CCXX_NAMESPACES
44 namespace ost {
45 #endif
46
68 {
81
93 {
94 public:
96 { pathMTU = mtu; }
97
99 { return pathMTU; }
100
101 #ifdef CCXX_PACKED
102 #pragma pack(1)
103 #endif
104
112 {
120 };
121
129 {
132 };
133
141 {
144 };
145
153 {
159 };
160
167 {
171 };
172
179 {
183 };
184
191 {
193 { return (ntohl(ssrc)); }
194
197 };
198
205 {
208 };
209
216 {
219 unsigned char data[1];
222 };
223
231 {
233 };
234
242 {
246 };
247
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
268 };
269
281 {
296 } Type;
297
303 { return ((ntohs(fh.length) + 1) << 2); }
304
310 {
return (ntohl(
info.RR.ssrc)); }
// SSRC is always the first
311 // word after fh.
312
314
315 // An RTCP packet may be of any of the types defined
316 // above, including APP specific ones.
317 union
318 {
327 };
328 #ifdef CCXX_PACKED
329 #pragma pack()
330 #endif
331
332 protected:
333 enum { defaultPathMTU = 1500 };
334
336
338
350 bool
351 checkCompoundRTCPHeader(size_t len);
352
353 // buffer to hold RTCP compound packets being sent. Allocated
354 // in construction time
356 // buffer to hold RTCP compound packets being
357 // received. Allocated at construction time
359
362 private:
363 // path MTU. RTCP packets should not be greater than this
365 // masks for RTCP header validation;
368 };
369
377 {
378 public:
380 { memcpy(&receiverInfo,&ri,
382
384 : receiverInfo( si )
385 {
386 }
387
389 { }
390
395 inline uint8
397 { return receiverInfo.fractionLost; }
398
399 inline uint32
401 { return ( ((uint32)ntohs(receiverInfo.lostLSW)) +
402 (((uint32)receiverInfo.lostMSB) << 16) ); }
403
404 inline uint32
406 { return ntohl(receiverInfo.highestSeqNum); }
407
414 uint32
416 { return ntohl(receiverInfo.jitter); }
417
423 uint16
425 { return (uint16)((ntohl(receiverInfo.lsr) & 0xFFFF0000) >> 16); }
426
432 uint16
434 { return (uint16)(ntohl(receiverInfo.lsr) & 0xFFFF); }
435
442 uint32
444 { return ntohl(receiverInfo.dlsr); }
445
446 private:
448 };
449
457 {
458 public:
460 { memcpy(&senderInfo,&si,
462
464 : senderInfo( si )
465 {
466 }
467
469 { }
470
475 uint32
477 { return ntohl(senderInfo.NTPMSW); }
478
483 uint32
485 { return ntohl(senderInfo.NTPLSW); }
486
487 inline uint32
489 { return ntohl(senderInfo.RTPTimestamp); }
490
494 inline uint32
496 { return ntohl(senderInfo.packetCount); }
497
498 inline uint32
500 { return ntohl(senderInfo.octetCount); }
501
502 private:
504 };
505
514 timeval
516
524 uint32
526 // rtcppacket
528
529 #ifdef CCXX_NAMESPACES
530 }
531 #endif
532
533 #endif // ndef CCXX_RTP_RTCPPKT_H_
534
Struct for a receiver info block in a SR (sender report) or an RR (receiver report) RTCP packet...
uint32 lsr
last sender report timestamp.
uint32 getNTPTimestampFrac() const
Get fractional part of the NTP timestamp of this packet.
uint32 getNTPTimestampInt() const
Get integer part of the NTP timestamp of this packet.
RTCPReceiverInfo(RTCPCompoundHandler::ReceiverInfo &si)
unsigned char * rtcpSendBuffer
low level structs and RTCP packet parsing and building methods.
ReceiverInfo rinfo
info about the source.
uint32 highestSeqNum
highest sequence number.
uint32 ssrc
ssrc identifier of source leaving.
uint32 jitter
arrival jitter.
uint32 octetCount
cumulative octet counter.
static const uint16 RTCP_VALID_MASK
Sender block information of SR RTCP reports.
Canonical end-point identifier.
uint16 getLastSRNTPTimestampFrac() const
Get the fractional part of the NTP timestamp of the last SR RTCP packet received from the source this...
Comment usually reporting state.
static const uint16 RTCP_VALID_VALUE
uint32 getLength() const
Get the packet length specified in its header, in octets and in host order.
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
void setPathMTU(uint16 mtu)
RTCPReceiverInfo(void *ri)
uint32 dlsr
delay since last sender report.
Fixed RTCP packet header.
uint16 getLastSRNTPTimestampInt() const
Get the integer part of the NTP timestamp of the last SR RTCP packet received from the source this re...
Phone number of the user.
uint16 lostLSW
cumulative lost two LSB.
Struct for BYE (leaving session) RTCP packets.
uint8 lostMSB
cumulative lost MSB of 3 octets.
uint8 len
item len in octets.
uint8 type
type of RTCP packet.
uint32 ssrc
SSRC identifer from sender.
uint32 NTPMSW
NTP timestamp higher octets.
uint32 ssrc
ssrc identifier of source.
uint32 getOctetCount() const
Struct for the sender info block in a SR (sender report) RTCP packet.
Struct for SR (sender report) RTCP packets.
uint8 length
[optional] length of reason.
uint16 blp
Bitmask of following Lost Packets.
uint8 type
item identifier.
SenderInfo sinfo
actual sender info.
SDESItem item
SDES item from sender.
Struct for a chunk of items in a SDES RTCP packet.
Struct representing general RTCP packet headers as they are sent through the network.
uint32 timevalIntervalTo65536(timeval &t)
Convert a time interval, expressed as a timeval, into a 32-bit time interval expressed in units of 1/...
uint32 getPacketCount() const
Get count of sent data packets.
RTCPCompoundHandler::SenderInfo senderInfo
Struct for Full Intra-frame Request (FIR) RTCP packet.
Personal NAME of the user.
uint32 RTPTimestamp
RTP timestamp.
uint16 fsn
First Sequence Number lost.
raw structure of the source and every receiver report in an SR or RR RTCP packet. ...
unsigned char * rtcpRecvBuffer
uint32 ssrc
source identifier.
uint32 getSSRC() const
Get the SSRC identifier specified in the packet header, in host order.
uint16 length
number of 32-bit words in the packet (minus one).
Struct for an item description of a SDES packet.
Base elements for RTP stacks: constants, types and global functions.
uint32 getRTPTimestamp() const
RTCPSenderInfo(RTCPCompoundHandler::SenderInfo &si)
Struct for Negative ACKnowledgements (NACK) RTCP packet.
uint8 fractionLost
packet fraction lost.
Report block information of SR/RR RTCP reports.
timeval NTP2Timeval(uint32 msw, uint32 lsw)
Convert a NTP timestamp, expressed as two 32-bit long words, into a timeval value.
uint32 getDelayLastSR() const
Get the delay between the last SR packet received and the transmission of this report.
RTCPCompoundHandler::ReceiverInfo receiverInfo
uint32 ssrc
ssrc identifier of source.
uint32 ssrc
source identifier.
uint32 getCumulativePacketLost() const
Struct for APP (application specific) RTCP packets.
uint8 getFractionLost() const
Get fraction of lost packets, as a number between 0 and 255.
uint32 getJitter() const
Get the statistical variance of the RTP data packets interarrival time.
RTCPFixedHeader fh
Fixed RTCP header.
uint32 packetCount
cumulative packet counter.
uint32 ssrc
ssrc identifier of source.
uint32 NTPLSW
NTP timestamp lower octets.
uint32 getExtendedSeqNum() const
EMAIL address of the user.
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Struct for the data contained in a receiver info block.
Location where the user is.
uint32 ssrc
source identifier.