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
37 #ifndef CCXX_RTP_RTCPPKT_H_
38 #define CCXX_RTP_RTCPPKT_H_
39
41
42 NAMESPACE_COMMONCPP
43
65 {
78
90 {
91 public:
93 { pathMTU = mtu; }
94
96 { return pathMTU; }
97
98 #ifdef CCXX_PACKED
99 #pragma pack(1)
100 #endif
101
109 {
117 };
118
126 {
129 };
130
138 {
141 };
142
150 {
156 };
157
164 {
168 };
169
176 {
180 };
181
188 {
190 { return (ntohl(ssrc)); }
191
194 };
195
202 {
205 };
206
213 {
216 unsigned char data[1];
219 };
220
228 {
230 };
231
239 {
243 };
244
251 {
252 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
253 unsigned char version:2;
255 unsigned char padding:1;
256 unsigned char block_count:5;
257 #else
258 unsigned char block_count:5;
260 unsigned char padding:1;
261 unsigned char version:2;
262 #endif
265 };
266
278 {
293 } Type;
294
300 { return ((ntohs(fh.length) + 1) << 2); }
301
307 { return (ntohl(info.RR.ssrc)); } // SSRC is always the first
308 // word after fh.
309
311
312 // An RTCP packet may be of any of the types defined
313 // above, including APP specific ones.
314 union
315 {
323 } info;
324 };
325 #ifdef CCXX_PACKED
326 #pragma pack()
327 #endif
328
329 protected:
330 enum { defaultPathMTU = 1500 };
331
333
335
347 bool
348 checkCompoundRTCPHeader(size_t len);
349
350 // buffer to hold RTCP compound packets being sent. Allocated
351 // in construction time
353 // buffer to hold RTCP compound packets being
354 // received. Allocated at construction time
356
359 private:
360 // path MTU. RTCP packets should not be greater than this
362 // masks for RTCP header validation;
365 };
366
374 {
375 public:
377 { memcpy(&receiverInfo,&ri,
379
381 : receiverInfo( si )
382 {
383 }
384
386 { }
387
392 inline uint8
394 { return receiverInfo.fractionLost; }
395
396 inline uint32
398 { return ( ((uint32)ntohs(receiverInfo.lostLSW)) +
399 (((uint32)receiverInfo.lostMSB) << 16) ); }
400
401 inline uint32
403 { return ntohl(receiverInfo.highestSeqNum); }
404
411 uint32
413 { return ntohl(receiverInfo.jitter); }
414
420 uint16
422 { return (uint16)((ntohl(receiverInfo.lsr) & 0xFFFF0000) >> 16); }
423
429 uint16
431 { return (uint16)(ntohl(receiverInfo.lsr) & 0xFFFF); }
432
439 uint32
441 { return ntohl(receiverInfo.dlsr); }
442
443 private:
445 };
446
454 {
455 public:
457 { memcpy(&senderInfo,&si,
459
461 : senderInfo( si )
462 {
463 }
464
466 { }
467
472 uint32
474 { return ntohl(senderInfo.NTPMSW); }
475
480 uint32
482 { return ntohl(senderInfo.NTPLSW); }
483
484 inline uint32
486 { return ntohl(senderInfo.RTPTimestamp); }
487
491 inline uint32
493 { return ntohl(senderInfo.packetCount); }
494
495 inline uint32
497 { return ntohl(senderInfo.octetCount); }
498
499 private:
501 };
502
511 timeval
513
521 uint32
523 // rtcppacket
525
526 END_NAMESPACE
527
528 #endif // ndef CCXX_RTP_RTCPPKT_H_
529
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.
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.
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
static const uint16 RTCP_VALID_MASK
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.