#include <RTCP_Packet.h>
Inheritance diagram for RTCP_BYE_Packet:
Public Member Functions | |
RTCP_BYE_Packet (ACE_UINT32 *srcList, unsigned char length, const char *text=0) | |
RTCP_BYE_Packet (char *buffer, int *len) | |
Constructor for incoming BYE RTCP packets. | |
virtual | ~RTCP_BYE_Packet (void) |
Destructor. | |
unsigned int | packet_size (void) |
Returns the size of the packet in bytes. | |
void | ssrc_list (ACE_UINT32 **ssrc_list, unsigned char &length) |
const char * | reason (void) |
Returns the reason for leaving the session. | |
void | dump (void) |
Prints the contents of the packet. | |
Private Member Functions | |
void | build_packet () |
Used to create the byte representation of the RTCP packet. | |
Private Attributes | |
ACE_UINT32 * | ssrc_list_ |
List of synchronization source ids that are leaving the session. | |
unsigned char | ssrc_list_length_ |
The number of ssrc's that are leaving the session (1 for non-mixers). | |
char | reason_ [256] |
An optional reason for leaving the session. | |
unsigned char | reason_length_ |
The number of bytes in the reason for leaving the session. |
Definition at line 85 of file RTCP_Packet.h.
RTCP_BYE_Packet::RTCP_BYE_Packet | ( | ACE_UINT32 * | srcList, | |
unsigned char | length, | |||
const char * | text = 0 | |||
) |
Constructor for outgoing BYE RTCP packets. Takes a synchronization source id list, the list length (1 for non-mixers), and an optional reason for leaving the session.
Definition at line 75 of file RTCP_Packet.cpp.
References ACE_NEW, RTCP_Packet::chd_, RTCP_Common_Header::count_, RTCP_Common_Header::length_, ACE_OS::memcpy(), ACE_OS::memset(), RTCP_Packet::packet_data_, RTCP_Common_Header::pt_, reason_length_, RTCP_PT_BYE, ssrc_list_length_, ACE_OS::strlen(), and RTCP_Common_Header::ver_.
00078 { 00079 this->chd_.ver_ = 2; 00080 this->chd_.count_ = length; 00081 this->chd_.pt_ = RTCP_PT_BYE; 00082 00083 if (length) 00084 { 00085 ACE_NEW (this->ssrc_list_, 00086 ACE_UINT32[length]); 00087 00088 this->ssrc_list_length_ = length; 00089 00090 for (int i=0; i<length; i++) 00091 this->ssrc_list_[i] = ssrc_list[i]; 00092 } 00093 00094 // Optional - if there is a reason for leaving, store it. 00095 // The reason is padded with extra zeros because the packet must 00096 // end on an even 32-bit boundary. 00097 ACE_OS::memset(this->reason_, 0, sizeof(this->reason_)); 00098 if (text) 00099 { 00100 size_t text_length = ACE_OS::strlen(text); 00101 ACE_OS::memcpy(this->reason_, text, text_length); 00102 this->reason_length_ = static_cast<unsigned char> (text_length); 00103 } 00104 else 00105 this->reason_length_ = 0; 00106 00107 // Set the packet length 00108 this->chd_.length_ = static_cast<ACE_UINT16> (this->chd_.count_ + (this->reason_length_+1)/4); 00109 if ((this->reason_length_+1)%4) 00110 this->chd_.length_++; 00111 00112 this->packet_data_ = 0; 00113 }
RTCP_BYE_Packet::RTCP_BYE_Packet | ( | char * | buffer, | |
int * | len | |||
) |
Constructor for incoming BYE RTCP packets.
Definition at line 117 of file RTCP_Packet.cpp.
References ACE_NEW, ACE_NTOHL, RTCP_Packet::chd_, RTCP_Common_Header::count_, RTCP_Common_Header::length_, ACE_OS::memcpy(), ACE_OS::memset(), RTCP_Packet::packet_data_, reason_length_, and ssrc_list_length_.
00118 : RTCP_Packet(buffer) 00119 { 00120 unsigned int index = 0; 00121 unsigned int j; 00122 00123 // The common part of the header is initialized in the parent. 00124 index=4; 00125 00126 ACE_NEW (this->ssrc_list_, 00127 ACE_UINT32[this->chd_.count_]); 00128 this->ssrc_list_length_ = this->chd_.count_; 00129 00130 // Store the source ids of the sources leaving the session 00131 for (j=0; j<this->chd_.count_; j++) 00132 { 00133 this->ssrc_list_[j] = ACE_NTOHL(*(ACE_UINT32*)&buffer[index]); 00134 index+=4; 00135 } 00136 00137 // Optional - store the reason for leaving 00138 unsigned int temp = this->chd_.length_; // Borland reports a warning on the 00139 // following line with out this. 00140 ACE_OS::memset(this->reason_, 0, sizeof(this->reason_)); 00141 if (temp > this->chd_.count_) 00142 { 00143 this->reason_length_ = buffer[index]; 00144 index++; 00145 ACE_OS::memcpy(this->reason_, &buffer[index], this->reason_length_); 00146 index+=this->reason_length_; 00147 00148 } 00149 else 00150 this->reason_length_ = 0; 00151 00152 // Decrement the length by the size of this message. This is necessary 00153 // because multiple RTCP packets may be contained in a single UDP packet. 00154 *len-=(chd_.length_+1)*4; 00155 00156 this->packet_data_ = 0; 00157 }
RTCP_BYE_Packet::~RTCP_BYE_Packet | ( | void | ) | [virtual] |
Destructor.
Definition at line 161 of file RTCP_Packet.cpp.
References RTCP_Packet::packet_data_, and ssrc_list_.
00162 { 00163 if (this->ssrc_list_) 00164 delete []this->ssrc_list_; 00165 if (this->packet_data_) 00166 delete []this->packet_data_; 00167 }
void RTCP_BYE_Packet::build_packet | ( | ) | [private, virtual] |
Used to create the byte representation of the RTCP packet.
Implements RTCP_Packet.
Definition at line 208 of file RTCP_Packet.cpp.
References ACE_HTONL, ACE_HTONS, ACE_NEW, RTCP_Packet::chd_, RTCP_Common_Header::count_, ACE_OS::memcpy(), RTCP_Packet::packet_data_, packet_size(), RTCP_Common_Header::pt_, and RTCP_Common_Header::ver_.
00209 { 00210 unsigned int index; 00211 unsigned int i; 00212 00213 if (this->packet_data_) 00214 delete []this->packet_data_; 00215 00216 ACE_NEW (this->packet_data_, 00217 char[this->packet_size()]); 00218 00219 index = 0; 00220 this->packet_data_[index] = static_cast<char> ((this->chd_.ver_ << 6) | 00221 (this->chd_.pad_ << 5) | 00222 this->chd_.count_); 00223 index++; 00224 this->packet_data_[index] = this->chd_.pt_; 00225 index++; 00226 *((ACE_UINT16*)&this->packet_data_[index]) = ACE_HTONS(this->chd_.length_); 00227 index+=2; 00228 00229 for (i=0; i<this->chd_.count_; i++) 00230 { 00231 *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->ssrc_list_[i]); 00232 index+=4; 00233 } 00234 00235 if (this->reason_) 00236 { 00237 this->packet_data_[index] = this->reason_length_; 00238 index++; 00239 ACE_OS::memcpy(&this->packet_data_[index], this->reason_, this->reason_length_); 00240 index += this->reason_length_; 00241 while (index < this->packet_size()) 00242 { 00243 this->packet_data_[index] = 0; 00244 index ++; 00245 } 00246 } 00247 }
void RTCP_BYE_Packet::dump | ( | void | ) |
Prints the contents of the packet.
Definition at line 250 of file RTCP_Packet.cpp.
References ACE_DEBUG, LM_DEBUG, and ssrc_list_length_.
Referenced by TAO_AV_RTCP_Callback::receive_control_frame().
00251 { 00252 ACE_DEBUG ((LM_DEBUG, 00253 "\nRTCP_BYE_Packet:: from ssrc(s) ")); 00254 for (int i=0; i< this->ssrc_list_length_; i++) 00255 ACE_DEBUG ((LM_DEBUG, 00256 "%u ", 00257 this->ssrc_list_[i])); 00258 ACE_DEBUG ((LM_DEBUG, 00259 "\n Reason '%s'\n", 00260 this->reason_)); 00261 }
unsigned int RTCP_BYE_Packet::packet_size | ( | void | ) | [virtual] |
Returns the size of the packet in bytes.
Implements RTCP_Packet.
Definition at line 172 of file RTCP_Packet.cpp.
References RTCP_Packet::chd_, RTCP_Common_Header::count_, and reason_length_.
Referenced by build_packet().
00173 { 00174 ACE_UINT16 size = static_cast<ACE_UINT16> ((1+chd_.count_) * 4); 00175 00176 if (this->reason_length_ > 0) 00177 { 00178 size += this->reason_length_ + 1; 00179 if (size%4) 00180 size += 4 - size%4; // pad with zeros to even 32 bit bound 00181 } 00182 00183 return size; 00184 }
const char * RTCP_BYE_Packet::reason | ( | void | ) |
Returns the reason for leaving the session.
Definition at line 198 of file RTCP_Packet.cpp.
00199 { 00200 ACE_CString reason = (const char *)this->reason_; 00201 00202 return reason.c_str(); 00203 }
void RTCP_BYE_Packet::ssrc_list | ( | ACE_UINT32 ** | ssrc_list, | |
unsigned char & | length | |||
) |
Returns a pointer to a local list of synchronization source ids that are leaving the session.
Definition at line 189 of file RTCP_Packet.cpp.
References ssrc_list_, and ssrc_list_length_.
Referenced by TAO_AV_RTCP_Callback::receive_control_frame().
00190 { 00191 *ssrc_list = this->ssrc_list_; 00192 length = this->ssrc_list_length_; 00193 }
char RTCP_BYE_Packet::reason_[256] [private] |
unsigned char RTCP_BYE_Packet::reason_length_ [private] |
The number of bytes in the reason for leaving the session.
Definition at line 130 of file RTCP_Packet.h.
Referenced by packet_size(), and RTCP_BYE_Packet().
ACE_UINT32* RTCP_BYE_Packet::ssrc_list_ [private] |
List of synchronization source ids that are leaving the session.
Definition at line 121 of file RTCP_Packet.h.
Referenced by ssrc_list(), and ~RTCP_BYE_Packet().
unsigned char RTCP_BYE_Packet::ssrc_list_length_ [private] |
The number of ssrc's that are leaving the session (1 for non-mixers).
Definition at line 124 of file RTCP_Packet.h.
Referenced by dump(), RTCP_BYE_Packet(), and ssrc_list().