RTP Audio System
2.0.0
|
00001 // ########################################################################## 00002 // #### #### 00003 // #### RTP Audio Server Project #### 00004 // #### ============================ #### 00005 // #### #### 00006 // #### RTCP Packet #### 00007 // #### #### 00008 // #### Copyright (C) 1999-2012 by Thomas Dreibholz #### 00009 // #### #### 00010 // #### Contact: #### 00011 // #### EMail: dreibh@iem.uni-due.de #### 00012 // #### WWW: https://www.nntb.no/~dreibh/rtpaudio #### 00013 // #### #### 00014 // #### ---------------------------------------------------------------- #### 00015 // #### #### 00016 // #### This program is free software: you can redistribute it and/or #### 00017 // #### modify it under the terms of the GNU General Public License as #### 00018 // #### published by the Free Software Foundation, either version 3 of #### 00019 // #### the License, or (at your option) any later version. #### 00020 // #### #### 00021 // #### This program is distributed in the hope that it will be useful, #### 00022 // #### but WITHOUT ANY WARRANTY; without even the implied warranty of #### 00023 // #### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #### 00024 // #### GNU General Public License for more details. #### 00025 // #### #### 00026 // #### You should have received a copy of the GNU General Public #### 00027 // #### License along with this program. If not, see #### 00028 // #### <http://www.gnu.org/licenses/>. #### 00029 // #### #### 00030 // ########################################################################## 00031 // $Id: rtcppacket.h 1315 2011-12-23 11:33:17Z dreibh $ 00032 00033 00034 #ifndef RTCPPACKET_H 00035 #define RTCPPACKET_H 00036 00037 00038 #include "tdsystem.h" 00039 #include "rtppacket.h" 00040 00041 00045 enum RTCP_Type 00046 { 00047 RTCP_SR = 200, 00048 RTCP_RR = 201, 00049 RTCP_SDES = 202, 00050 RTCP_BYE = 203, 00051 RTCP_APP = 204 00052 }; 00053 00054 00058 enum RTCP_SDES_Type 00059 { 00060 RTCP_SDES_END = 0, 00061 RTCP_SDES_CNAME = 1, 00062 RTCP_SDES_NAME = 2, 00063 RTCP_SDES_EMAIL = 3, 00064 RTCP_SDES_PHONE = 4, 00065 RTCP_SDES_LOC = 5, 00066 RTCP_SDES_TOOL = 6, 00067 RTCP_SDES_NOTE = 7, 00068 RTCP_SDES_PRIV = 8 00069 }; 00070 00071 00083 struct RTCPCommonHeader 00084 { 00085 // ====== Constructor ==================================================== 00086 public: 00090 RTCPCommonHeader(); 00091 00092 00093 // ====== Get methods ==================================================== 00099 inline card8 getVersion() const; 00100 00106 inline card8 getPadding() const; 00107 00113 inline card8 getCount() const; 00114 00120 inline card8 getPacketType() const; 00121 00127 inline card16 getLength() const; 00128 00129 00130 // ====== Set methods ==================================================== 00136 inline void setVersion(const card8 version); 00137 00143 inline void setPadding(const card8 padding); 00144 00150 inline void setCount(const card8 count); 00151 00157 inline void setPacketType(const card8 packetType); 00158 00164 inline void setLength(const card16 length); 00165 00166 00167 // ====== Protected data ================================================= 00168 protected: 00169 #if BYTE_ORDER == BIG_ENDIAN 00170 card8 V:2; // Protocol Version 00171 card8 P:1; // Padding Flag 00172 card8 C:5; // Count varies by Packet Type (RC/SC) 00173 #elif BYTE_ORDER == LITTLE_ENDIAN 00174 card8 C:5; // Count varies by Packet Type (RC/SC) 00175 card8 P:1; // Padding Flag 00176 card8 V:2; // Protocol Version 00177 #else 00178 #error "Unknown CPU_BYTEORDER setting!" 00179 #endif 00180 card8 PT:8; // RTCP Packet Type 00181 card16 Length; // Packet length in words minus one 00182 } __attribute__((packed)); 00183 00184 00196 struct RTCPSenderInfoBlock 00197 { 00198 // ====== Constructor ==================================================== 00199 public: 00203 RTCPSenderInfoBlock(); 00204 00205 00206 // ====== Get methods ==================================================== 00212 inline card64 getNTPTimeStamp() const; 00213 00219 inline card32 getRTPTimeStamp() const; 00220 00221 00227 inline card32 getPacketsSent() const; 00228 00234 inline card32 getOctetsSent() const; 00235 00236 00237 // ====== Set methods ==================================================== 00243 inline void setNTPTimeStamp(const card64 timeStamp); 00244 00250 inline void setRTPTimeStamp(const card32 timeStamp); 00251 00257 inline void setPacketsSent(const card32 packets); 00258 00264 inline void setOctetsSent(const card32 octets); 00265 00266 00267 // ====== Protected data ================================================= 00268 protected: 00269 card32 NTP_MostSignificant; // NTP Timestamp (most significant word) 00270 card32 NTP_LeastSignificant; // NTP Timestamp (least significant word) 00271 card32 RTPTimeStamp; // RTP Timestamp 00272 card32 PacketsSent; // Packets sent 00273 card32 OctetsSent; // Octets sent 00274 } __attribute__((packed)); 00275 00276 00288 struct RTCPReceptionReportBlock 00289 { 00290 // ====== Constructor ==================================================== 00291 public: 00295 RTCPReceptionReportBlock(); 00296 00302 RTCPReceptionReportBlock(const card32 ssrc); 00303 00304 00310 void init(const card32 ssrc); 00311 00312 00313 // ====== Get methods ==================================================== 00319 inline card32 getSSRC() const; 00320 00326 inline double getFractionLost() const; 00327 00333 inline card32 getPacketsLost() const; 00334 00340 inline card32 getLastSeqNum() const; 00341 00347 inline card32 getJitter() const; 00348 00354 inline card32 getLSR() const; 00355 00361 inline card32 getDLSR() const; 00362 00363 00364 // ====== Set methods ==================================================== 00370 inline void setSSRC(card32 ssrc); 00371 00377 inline void setFractionLost(const double fraction); 00378 00384 inline void setPacketsLost(const card32 packetsLost); 00385 00391 inline void setLastSeqNum(const card32 lastSeq); 00392 00398 inline void setJitter(const card32 jitter); 00399 00405 inline void setLSR(const card32 lsr); 00406 00412 inline void setDLSR(const card32 dlsr); 00413 00414 00415 // ====== Protected data ================================================= 00416 protected: 00417 card32 SSRC; // Data Source being reported 00418 card32 Fraction:8; // Fraction lost since last SR/RR 00419 card32 Lost:24; // Cumulative no. of Packets lost (signed!) 00420 card32 LastSeq; // Extended last sequence no. received 00421 card32 Jitter; // Interarrival Jitter 00422 card32 LSR; // Last SR Packet from this source 00423 card32 DLSR; // Delay since last SR Packet 00424 } __attribute__((packed)); 00425 00426 00438 struct RTCPReport : public RTCPCommonHeader 00439 { 00440 // ====== Constructor ==================================================== 00441 public: 00445 RTCPReport(); 00446 00447 00448 // ====== Get methods ==================================================== 00454 inline card32 getSSRC() const; 00455 00456 00457 // ====== Set methods ==================================================== 00463 inline void setSSRC(const card32 ssrc); 00464 00465 00466 // ====== Protected data ================================================= 00467 protected: 00468 card32 SSRC; // Sender or Receiver generating this report 00469 } __attribute__((packed)); 00470 00471 00483 struct RTCPSenderReport : public RTCPReport, public RTCPSenderInfoBlock 00484 { 00485 // ====== Constructor ==================================================== 00486 public: 00490 RTCPSenderReport(); 00491 00498 RTCPSenderReport(const card32 syncSource, const card8 count = 0); 00499 00500 00507 void init(const card32 syncSource, const card8 count = 0); 00508 00509 00513 RTCPReceptionReportBlock rr[]; // Variable length RR list 00514 } __attribute__((packed)); 00515 00516 00528 struct RTCPReceiverReport : public RTCPReport 00529 { 00530 // ====== Constructor ==================================================== 00531 public: 00535 RTCPReceiverReport(); 00536 00543 RTCPReceiverReport(const card32 syncSource, const card8 count = 0); 00544 00545 00552 void init(const card32 syncSource, const card8 count = 0); 00553 00554 00558 RTCPReceptionReportBlock rr[]; // Variable length RR list 00559 } __attribute__((packed)); 00560 00561 00573 struct RTCPSourceDescriptionItem 00574 { 00575 public: 00579 card8 Type; 00580 00584 card8 Length; 00585 00589 char Data[]; 00590 } __attribute__((packed)); 00591 00592 00604 struct RTCPSourceDescriptionChunk 00605 { 00606 public: 00610 card32 SRC; 00611 00615 RTCPSourceDescriptionItem Item[]; 00616 } __attribute__((packed)); 00617 00618 00630 struct RTCPSourceDescription : public RTCPCommonHeader 00631 { 00632 // ====== Constructor ==================================================== 00633 public: 00637 RTCPSourceDescription(); 00638 00644 RTCPSourceDescription(const card8 count); 00645 00646 00652 void init(const card8 count); 00653 00654 00658 RTCPSourceDescriptionChunk Chunk[1]; 00659 } __attribute__((packed)); 00660 00661 00673 struct RTCPBye : public RTCPCommonHeader 00674 { 00675 // ====== Constructor ==================================================== 00676 public: 00680 RTCPBye(); 00681 00687 RTCPBye(const card8 count); 00688 00689 00695 void init(const card8 count); 00696 00697 00698 // ====== Get methods ==================================================== 00705 inline card32 getSource(const cardinal index) const; 00706 00707 00708 // ====== Set methods ==================================================== 00715 inline void setSource(const cardinal index, const card32 source); 00716 00717 00718 // ====== Private data =================================================== 00719 private: 00720 card32 Source[]; 00721 } __attribute__((packed)); 00722 00723 00735 struct RTCPApp : public RTCPCommonHeader 00736 { 00737 // ====== Constructor ==================================================== 00738 public: 00742 RTCPApp(); 00743 00748 RTCPApp(const card8 subtype); 00749 00750 00751 /* 00752 * Initialize. 00753 * @param subtype RTCP APP subtype. 00754 */ 00755 void init(const card8 subtype); 00756 00757 00758 // ====== Get methods ==================================================== 00764 inline card32 getSource() const; 00765 00771 inline char* getName(); 00772 00778 inline char* getData(); 00779 00780 00781 // ====== Set methods ==================================================== 00787 inline void setSource(const card32 source); 00788 00794 inline void setName(const char* name); 00795 00796 00797 // ====== Private data =================================================== 00798 private: 00799 card32 Source; 00800 char Name[4]; 00801 char Data[]; 00802 } __attribute__((packed)); 00803 00804 00805 #include "rtcppacket.icc" 00806 00807 00808 #endif