#include <RTP.h>
Public Member Functions | |
RTP_Packet (char *buffer, int length) | |
Constructor for incoming RTP packets. | |
RTP_Packet (unsigned char padding, unsigned char marker, unsigned char payloadType, ACE_UINT32 sequenceNumber, ACE_UINT32 timeStamp, ACE_UINT32 syncSource, unsigned char contribSourcCount, ACE_UINT32 contribSourceList[], char *data, ACE_UINT16 dataSize) | |
Constructor for outgoing RTP packets. | |
~RTP_Packet (void) | |
Destructor. | |
ACE_UINT16 | packet_size (void) |
Returns the size of the RTP packet in bytes. | |
ACE_UINT16 | payload_size (void) |
Returns the size of the payload in bytes. | |
void | get_frame_info (TAO_AV_frame_info *frame_info) |
Populates the passed in frame_info. | |
int | is_valid (void) |
Returns 1 if packet is valid and 0 if not. | |
unsigned int | ver (void) |
Returns the RTP version of the packet. | |
unsigned int | pad (void) |
Returns 1 if the padding bit is set, 0 if not. | |
unsigned int | ext (void) |
Returns 1 if the header extension bit is set, 0 if not. | |
unsigned int | ext_bytes (void) |
Returns the number of bytes in the header extension or 0 if no extension. | |
unsigned int | cc (void) |
unsigned int | mrk (void) |
Returns 1 if the marker bit is set, 0 if not. | |
unsigned int | pt (void) |
Returns the payload type of the packet. | |
ACE_UINT16 | sn (void) |
Returns the sequence number of the packet. | |
ACE_UINT32 | ts (void) |
Returns the timestamp of the packet. | |
ACE_UINT32 | ssrc (void) |
Returns the synchronization source id of the packet. | |
void | get_csrc_list (ACE_UINT32 **csrc_list, ACE_UINT16 &length) |
void | get_payload (char **payload, ACE_UINT16 &size) |
void | get_packet_data (char **packet, ACE_UINT16 &size) |
Private Attributes | |
char | packet_ [RTP_MTU] |
Local buffer to hold the RTP packet. | |
ACE_UINT32 | host_byte_order_csrc_list_ [15] |
char | host_byte_order_payload_ [RTP_MTU] |
Local buffer to hold the payload with the values stored in host byte order. | |
unsigned int | extension_bytes_ |
The number of bytes in the header extension - 0 if no extension. | |
ACE_UINT16 | packet_size_ |
The size of the overall data packet. | |
ACE_UINT16 | payload_size_ |
The size of the payload portion of the packet. |
Definition at line 254 of file RTP.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL RTP_Packet::RTP_Packet | ( | char * | buffer, | |
int | length | |||
) |
Constructor for incoming RTP packets.
Definition at line 49 of file RTP.cpp.
References extension_bytes_, host_byte_order_payload_, ACE_OS::memcpy(), packet_size_, payload_size_, RTP_PT_L16_MONO, RTP_PT_L16_OTHER, and RTP_PT_L16_STEREO.
00050 { 00051 // skip the standard header info 00052 int index = 12; 00053 00054 ACE_OS::memcpy(this->packet_, buffer, length); 00055 00056 for (int j=0; j<(int)this->cc(); j++) 00057 { 00058 this->host_byte_order_csrc_list_[j] = ntohl(*(ACE_UINT32*)&buffer[index]); 00059 index+=4; 00060 } 00061 00062 // ignore the header extension if there is one 00063 if (this->ext()) 00064 { 00065 index+=2; 00066 int extension_data_size = ntohs(*(ACE_UINT16*)&buffer[index]); 00067 index+=2; 00068 index+=extension_data_size; 00069 00070 this->extension_bytes_ = 4 + extension_data_size; 00071 } 00072 else 00073 this->extension_bytes_ = 0; 00074 00075 this->packet_size_ = static_cast<ACE_UINT16> (length); 00076 this->payload_size_ = static_cast<ACE_UINT16> (length-index); 00077 00078 // This is necessary only for payload types that have 16 bit values to correct 00079 // the network byte ordering. 00080 if ((this->pt() == RTP_PT_L16_OTHER) || 00081 (this->pt() == RTP_PT_L16_STEREO) || 00082 (this->pt() == RTP_PT_L16_MONO)) 00083 { 00084 for (int i=0; i < payload_size_; i+=2) 00085 { 00086 *(ACE_UINT16*)&this->host_byte_order_payload_[i] = ntohs(*(ACE_UINT16*)&this->packet_[index]); 00087 index+=2; 00088 } 00089 } 00090 else 00091 for (int i=0; i<this->payload_size_; i++) 00092 { 00093 this->host_byte_order_payload_[i] = this->packet_[index]; 00094 index++; 00095 } 00096 }
RTP_Packet::RTP_Packet | ( | unsigned char | padding, | |
unsigned char | marker, | |||
unsigned char | payloadType, | |||
ACE_UINT32 | sequenceNumber, | |||
ACE_UINT32 | timeStamp, | |||
ACE_UINT32 | syncSource, | |||
unsigned char | contribSourcCount, | |||
ACE_UINT32 | contribSourceList[], | |||
char * | data, | |||
ACE_UINT16 | dataSize | |||
) |
Constructor for outgoing RTP packets.
unsigned int RTP_Packet::cc | ( | void | ) |
Returns the contributing source count. This should only be non-zero for mixers.
Definition at line 213 of file RTP.cpp.
Referenced by get_csrc_list().
unsigned int RTP_Packet::ext | ( | void | ) |
unsigned int RTP_Packet::ext_bytes | ( | void | ) |
Returns the number of bytes in the header extension or 0 if no extension.
Definition at line 249 of file RTP.cpp.
References extension_bytes_.
00250 { 00251 return this->extension_bytes_; 00252 }
void RTP_Packet::get_csrc_list | ( | ACE_UINT32 ** | csrc_list, | |
ACE_UINT16 & | length | |||
) |
Returns a pointer to the local contributing source list and its length. This should be empty except for mixers. RTP_Packet retains ownership.
Definition at line 294 of file RTP.cpp.
References cc(), and host_byte_order_csrc_list_.
00295 { 00296 *csrc_list = this->host_byte_order_csrc_list_; 00297 length = static_cast<ACE_UINT16> (this->cc ()); 00298 }
void RTP_Packet::get_frame_info | ( | TAO_AV_frame_info * | frame_info | ) |
Populates the passed in frame_info.
Definition at line 255 of file RTP.cpp.
References TAO_AV_frame_info::format, mrk(), pt(), TAO_AV_frame_info::sequence_num, sn(), ssrc(), TAO_AV_frame_info::ssrc, TAO_AV_frame_info::timestamp, and ts().
Referenced by TAO_AV_RTP_Object::handle_input().
00256 { 00257 frame_info->timestamp = this->mrk(); 00258 frame_info->timestamp = this->ts(); 00259 frame_info->ssrc = this->ssrc(); 00260 frame_info->sequence_num = this->sn(); 00261 frame_info->format = static_cast<CORBA::Octet> (this->pt()); 00262 }
void RTP_Packet::get_packet_data | ( | char ** | packet, | |
ACE_UINT16 & | size | |||
) |
Returns a pointer to the locally stored rtp packet and its size in bytes. RTP_Packet retains ownership.
Definition at line 308 of file RTP.cpp.
References packet_, and packet_size_.
Referenced by TAO_AV_RTP_Object::send_frame().
00309 { 00310 *packet = this->packet_; 00311 length = this->packet_size_; 00312 }
void RTP_Packet::get_payload | ( | char ** | payload, | |
ACE_UINT16 & | size | |||
) |
Returns a pointer to the locally stored payload and its size in bytes. The payload is returned in host byte order. RTP_Packet retains ownership.
Definition at line 301 of file RTP.cpp.
References host_byte_order_payload_.
Referenced by TAO_AV_RTP_Object::handle_input().
00302 { 00303 *payload = this->host_byte_order_payload_ ; 00304 length = this->payload_size_; 00305 }
int RTP_Packet::is_valid | ( | void | ) |
Returns 1 if packet is valid and 0 if not.
Definition at line 265 of file RTP.cpp.
References extension_bytes_, RTCP_PT_RR, RTCP_PT_SR, and RTP_VERSION.
Referenced by RTCP_Channel_In::recv_rtp_packet().
00266 { 00267 // taken from RFC 1889 - Appendix A.1 00268 00269 // make sure the RTP version is correct 00270 if (this->ver() != RTP_VERSION) 00271 return 0; 00272 00273 // make sure the payload type is not SR or RR 00274 if ((this->pt() == RTCP_PT_SR) || (this->pt() == RTCP_PT_RR)) 00275 return 0; 00276 00277 // if the p bit is set, the last octet of the packet must contain a valid 00278 // octet count, in particular, less than the total packet length minus 00279 // the header size. 00280 if (this->pad() != 0) 00281 if ((unsigned int)this->packet_[this->packet_size_] >= 00282 (this->packet_size_ - (12 + this->cc() + this->extension_bytes_))) 00283 return 0; 00284 00285 // If there is an extension, it is ignored (taken care of in constructor) 00286 00287 // The length of the packet must be consistent with CC and payload type (if 00288 // payloads have a known length) 00289 00290 return 1; 00291 }
unsigned int RTP_Packet::mrk | ( | void | ) |
Returns 1 if the marker bit is set, 0 if not.
Definition at line 219 of file RTP.cpp.
Referenced by get_frame_info().
ACE_UINT16 RTP_Packet::packet_size | ( | void | ) |
Returns the size of the RTP packet in bytes.
Definition at line 183 of file RTP.cpp.
References packet_size_.
00184 { 00185 return this->packet_size_; 00186 }
unsigned int RTP_Packet::pad | ( | void | ) |
ACE_UINT16 RTP_Packet::payload_size | ( | void | ) |
Returns the size of the payload in bytes.
Definition at line 189 of file RTP.cpp.
Referenced by RTCP_Channel_Out::updateStatistics().
00190 { 00191 return this->payload_size_; 00192 }
unsigned int RTP_Packet::pt | ( | void | ) |
Returns the payload type of the packet.
Definition at line 225 of file RTP.cpp.
Referenced by get_frame_info(), and RTCP_Channel_In::updateStatistics().
ACE_UINT16 RTP_Packet::sn | ( | void | ) |
Returns the sequence number of the packet.
Definition at line 231 of file RTP.cpp.
Referenced by get_frame_info(), RTCP_Channel_Out::updateStatistics(), and RTCP_Channel_In::updateStatistics().
ACE_UINT32 RTP_Packet::ssrc | ( | void | ) |
Returns the synchronization source id of the packet.
Definition at line 243 of file RTP.cpp.
Referenced by get_frame_info(), and TAO_AV_RTCP_Callback::receive_frame().
ACE_UINT32 RTP_Packet::ts | ( | void | ) |
Returns the timestamp of the packet.
Definition at line 237 of file RTP.cpp.
Referenced by get_frame_info(), RTCP_Channel_Out::updateStatistics(), and RTCP_Channel_In::updateStatistics().
unsigned int RTP_Packet::ver | ( | void | ) |
unsigned int RTP_Packet::extension_bytes_ [private] |
The number of bytes in the header extension - 0 if no extension.
Definition at line 345 of file RTP.h.
Referenced by ext_bytes(), is_valid(), and RTP_Packet().
ACE_UINT32 RTP_Packet::host_byte_order_csrc_list_[15] [private] |
Local buffer to hold the contributing source list with the values stored in host byte order.
Definition at line 339 of file RTP.h.
Referenced by get_csrc_list().
char RTP_Packet::host_byte_order_payload_[RTP_MTU] [private] |
Local buffer to hold the payload with the values stored in host byte order.
Definition at line 342 of file RTP.h.
Referenced by get_payload(), and RTP_Packet().
char RTP_Packet::packet_[RTP_MTU] [private] |
Local buffer to hold the RTP packet.
Definition at line 335 of file RTP.h.
Referenced by get_packet_data().
ACE_UINT16 RTP_Packet::packet_size_ [private] |
The size of the overall data packet.
Definition at line 348 of file RTP.h.
Referenced by get_packet_data(), packet_size(), and RTP_Packet().
ACE_UINT16 RTP_Packet::payload_size_ [private] |
The size of the payload portion of the packet.
Definition at line 351 of file RTP.h.
Referenced by RTP_Packet().