00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #ifndef RTCPBYEPACKET_H
00038
00039 #define RTCPBYEPACKET_H
00040
00041 #include "rtpconfig.h"
00042 #include "rtcppacket.h"
00043 #include "rtpstructs.h"
00044 #if ! (defined(WIN32) || defined (_WIN32_WCE))
00045 #include <netinet/in.h>
00046 #endif // WIN32
00047
00048 class RTCPCompoundPacket;
00049
00051 class RTCPBYEPacket : public RTCPPacket
00052 {
00053 public:
00059 RTCPBYEPacket(uint8_t *data,size_t datalen);
00060 ~RTCPBYEPacket() { }
00061
00063 int GetSSRCCount() const;
00064
00068 uint32_t GetSSRC(int index) const;
00069
00071 bool HasReasonForLeaving() const;
00072
00074 size_t GetReasonLength() const;
00075
00077 uint8_t *GetReasonData();
00078
00079 #ifdef RTPDEBUG
00080 void Dump();
00081 #endif // RTPDEBUG
00082 private:
00083 size_t reasonoffset;
00084 };
00085
00086 inline int RTCPBYEPacket::GetSSRCCount() const
00087 {
00088 if (!knownformat)
00089 return 0;
00090
00091 RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
00092 return (int)(hdr->count);
00093 }
00094
00095 inline uint32_t RTCPBYEPacket::GetSSRC(int index) const
00096 {
00097 if (!knownformat)
00098 return 0;
00099 uint32_t *ssrc = (uint32_t *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)*index);
00100 return ntohl(*ssrc);
00101 }
00102
00103 inline bool RTCPBYEPacket::HasReasonForLeaving() const
00104 {
00105 if (!knownformat)
00106 return false;
00107 if (reasonoffset == 0)
00108 return false;
00109 return true;
00110 }
00111
00112 inline size_t RTCPBYEPacket::GetReasonLength() const
00113 {
00114 if (!knownformat)
00115 return 0;
00116 if (reasonoffset == 0)
00117 return 0;
00118 uint8_t *reasonlen = (data+reasonoffset);
00119 return (size_t)(*reasonlen);
00120 }
00121
00122 inline uint8_t *RTCPBYEPacket::GetReasonData()
00123 {
00124 if (!knownformat)
00125 return 0;
00126 if (reasonoffset == 0)
00127 return 0;
00128 uint8_t *reasonlen = (data+reasonoffset);
00129 if ((*reasonlen) == 0)
00130 return 0;
00131 return (data+reasonoffset+1);
00132 }
00133
00134 #endif // RTCPBYEPACKET_H
00135