Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNRTPPacket.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_RTP_PACKET_H 00025 #define MN_RTP_PACKET_H 00026 00027 #include <assert.h> 00028 00029 #include "sh/SHData.h" 00030 #include "MNArrayList.h" 00031 #include "MNRTPNetTypes.h" 00032 #include "MNRTPdefs.h" 00033 00034 class MNRope; 00035 00036 class MNRTPPacket; 00037 class MNRTPHdrExt; 00038 00039 /**********************************************************************/ 00040 /* MNRTPPacket */ 00041 /**********************************************************************/ 00042 00043 class MNRTPPacket : public SH::Data 00044 { 00049 bool _is_from_addr; 00050 00052 struct sockaddr_in _addr; 00053 00055 unsigned int version; 00056 00057 // unsigned int p:1; /// Padding flag 00058 00059 // unsigned int x:1; /// Header extension flag 00060 00061 // unsigned int cc:4; /// CSRC (contributing source) count 00062 00064 bool marker; 00065 00067 unsigned int _payload_type; 00068 00070 u_int16 seq; 00071 00073 u_int32 timestamp; 00074 00076 u_int32 ssrc; 00077 00079 MNArrayList<u_int32> _csrc; 00080 00082 MNRTPHdrExt* _ext; 00083 00085 MNRope* _data; 00086 00087 public: 00088 enum DataDirection 00089 { 00090 To = false, 00091 From = true 00092 }; 00093 00094 private: 00101 void copy( const MNRTPPacket& orig ); 00102 00109 void copy( const rtp_hdr_t* pkt ); 00110 00118 void copy( const rtp_hdr_ext* xpkt ); 00119 00131 void copy( const struct sockaddr_in* addr, 00132 bool from_addr ); 00133 00134 public: 00141 MNRTPPacket( MNRope*& data, bool consume_data ); 00142 00145 MNRTPPacket( const MNRTPPacket& orig ); 00146 00166 MNRTPPacket( const rtp_hdr_t* pkt, 00167 const rtp_hdr_ext* xpkt, 00168 MNRope*& data, 00169 const struct sockaddr_in* addr, 00170 bool from_addr ); 00171 00188 MNRTPPacket( MNRope* data, 00189 const struct sockaddr_in* addr, 00190 bool from_addr, 00191 RTP_RC& retCode ); 00192 00195 MNRTPPacket& operator=( const MNRTPPacket& orig ); 00196 00199 virtual ~MNRTPPacket(); 00200 00205 virtual SH::DataPtr clone(); 00206 00208 virtual size_t getByteSize( ) const; 00209 00214 virtual MNRTPHdrExt* parseHeaderExt( const rtp_hdr_ext* xpkt ); 00215 00219 bool check_version() const; 00220 00223 u_int32 get_ssrc( ) const; 00224 00227 int get_payload_type() const; 00228 00231 u_int16 get_seq() const; 00232 00237 int rate() const; 00238 00241 u_int32 get_ts() const; 00242 00245 size_t payload_length() const; 00246 00250 const uchar_t* payload(); 00251 00256 MNRope* extract_payload(); 00257 00260 bool has_ext_hdr() const; 00261 00262 u_int16 get_ext_hdr_byte_len() const; 00263 u_int16 get_ext_hdr_word_len() const; 00264 u_int16 get_ext_hdr_type() const; 00265 const uchar_t* get_ext_hdr_payload(); 00266 00269 virtual void set_data( MNRope* data ); 00270 00273 virtual void set_timestamp( u_int32 tstamp ); 00274 00277 virtual void set_markerbit( bool yesno = true ); 00278 00281 virtual u_int32 get_timestamp( ); 00282 00285 virtual bool get_markerbit( ); 00286 00287 virtual void set_ext_header( MNRTPHdrExt* exthdr ); 00288 00289 virtual bool isPlainData( ) const { return false; } 00290 virtual bool isOrderedData( ) const { return false; } 00291 virtual bool isRTPData( ) const { return true; } 00292 virtual bool isDummyData( ) const { return false; } 00293 virtual bool isSHRTPData( ) const { return false; } 00294 }; 00295 00296 /**********************************************************************/ 00297 /* MNRTPPacketPtr */ 00298 /**********************************************************************/ 00299 00300 typedef SH::RPtr<MNRTPPacket> MNRTPPacketPtr; 00301 00302 /**********************************************************************/ 00303 /* MNRTPHdrExt */ 00304 /**********************************************************************/ 00305 00306 class MNRTPHdrExt 00307 { 00308 protected: 00309 u_int16 _etype; 00310 MNRope* _edata; 00311 private: 00312 void copy( const MNRTPHdrExt& orig ); 00313 void copy( const rtp_hdr_ext* xpkt ); 00314 00315 public: 00316 MNRTPHdrExt( ); 00317 MNRTPHdrExt( const MNRTPHdrExt& orig ); 00318 MNRTPHdrExt( const rtp_hdr_ext* xpkt ); 00319 MNRTPHdrExt( u_int16 type, MNRope*& data ); 00320 00321 virtual ~MNRTPHdrExt( ); 00322 00323 MNRTPHdrExt& operator=( const MNRTPHdrExt& orig ); 00324 00325 virtual MNRTPHdrExt* clone( ); 00326 00327 u_int16 get_byte_len() const; 00328 u_int16 get_word_len() const; 00329 u_int16 get_type() const; 00330 const uchar_t* get_payload(); 00331 }; 00332 /**********************************************************************/ 00333 /* MNLCRTPHdrExt */ 00334 /**********************************************************************/ 00335 00336 class MNLCRTPHdrExt : public MNRTPHdrExt 00337 { 00338 public: 00339 MNLCRTPHdrExt ( u_int16 type, MNRope*& data ); 00340 }; 00341 00342 /**********************************************************************/ 00343 /* MNTFRCRTPHdrExt - Experimental for TFRC - MZ */ 00344 /**********************************************************************/ 00345 00346 struct tfrc_payload 00347 { 00348 u_int32 nrtt; 00349 u_int32 nbitrate; 00350 u_int32 nlmr; 00351 u_int32 nmode; 00352 u_int64 bytecount; 00353 }; 00354 00355 class MNTFRCRTPHdrExt : public MNRTPHdrExt 00356 { 00357 protected: 00358 tfrc_payload _pload; 00359 public: 00360 MNTFRCRTPHdrExt ( u_int16 type, u_int32 rtt, u_int32 bitrate, 00361 u_int32 lmr, u_int32 mode, u_int64 bytecount ); 00362 }; 00363 #endif /* MN_RTP_PACKET_H */ 00364

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8