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

MNRTPList.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 MNRTPLIST_H 00025 #define MNRTPLIST_H 00026 00027 /* 00028 * Jones Lists for storing data related with rtp/rtcp statistics 00029 */ 00030 00031 #include "mnstream.h" 00032 #include "MNList.h" 00033 #include "MNRTPdefs.h" 00034 #include "MNRTPtime.h" 00035 #include "MNRTPPacket.h" 00036 00037 class SSRCEntry; 00038 class MNRTPList; 00039 00040 typedef SSRCEntry* SSRCEntryPtr; 00041 00042 /*********************************************************************** 00043 * SDESItemList 00044 ***********************************************************************/ 00045 00046 class SDESItemList 00047 : private MNList<SDESItem*> 00048 { 00049 int _refCount; 00050 public: 00051 SDESItemList() { 00052 _refCount = 0; 00053 } 00054 00055 void incRefCount() { 00056 _refCount += 1; 00057 } 00058 void decRefCount() { 00059 _refCount -= 1; 00060 } 00061 int refCount() { 00062 return _refCount; 00063 } 00064 00065 void* first() { 00066 return MNList<SDESItem*>::first(); 00067 } 00068 00069 void next( void*& pix ) { 00070 pix = MNList<SDESItem*>::succ(pix); 00071 } 00072 00073 SDESItem* operator()( void* pix ) { 00074 return MNList<SDESItem*>::inf(pix); 00075 } 00076 00077 void append( SDESItem* p ) { 00078 MNList<SDESItem*>::push_back ( p ); 00079 } 00080 00081 void clear() { 00082 MNList<SDESItem*>::clear(); 00083 } 00084 00085 void del( void* pix ) { 00086 MNList<SDESItem*>::del_item(pix); 00087 } 00088 }; 00089 00090 /*********************************************************************** 00091 * SSRCEntry 00092 ***********************************************************************/ 00093 00094 class SSRCEntry 00095 { 00096 /* RTP */ 00097 u_int32 _ssrc; 00098 rtp_sr_state _state; 00099 u_int16 _first_seq; 00100 u_int16 _max_seq; 00101 u_int16 _seq_cycles; /* times seq wraped around */ 00102 u_int32 _packet_count; 00103 u_int32 _packet_ts; 00104 u_int32 _arrive_ts; 00105 ntp64 _arrive_time; 00106 ntp64 _first_time; 00107 float _jitter; 00108 struct sockaddr_in _dest; 00109 00110 /* RTCP SR and SDES*/ 00111 u_int32 _lsr; 00112 u_int32 _lsr_time; 00113 u_int32 _rtt; 00114 u_int32 _sr_packet_count; 00115 u_int32 _sr_octet_count; 00116 u_int32 _sr_ts; 00117 u_int32 _expected_prio; /* expected seq no of the last report */ 00118 u_int32 _received_prio; /* received packets at the last report */ 00119 SDESItemList* _sdes_items; 00120 00121 /* RTCP RR */ 00122 unsigned int _rr_fraction:8; 00123 int _rr_lost:24; 00124 u_int32 _rr_last_seq; 00125 u_int32 _rr_jitter; 00126 u_int32 _rr_lsr; 00127 u_int32 _rr_dlsr; 00128 00129 /* last_heared */ 00130 u_int32 _last_heared; 00131 00132 typedef struct sockaddr_in Sockaddr; 00133 00134 private: 00135 void redo( const SSRCEntry& orig ); 00136 /* 00137 * Note that this function is not called clone() or copy() 00138 * because it is insecure. The contents of the list sdes_items 00139 * are not copied, only the management part is done again. 00140 */ 00141 00142 void clear( ); 00143 00145 SSRCEntry* set_rr_vals( unsigned int fraction, 00146 int lost, 00147 u_int32 last_seq, 00148 u_int32 jitter, 00149 u_int32 lsr, 00150 u_int32 dlsr ); 00151 public: 00152 SSRCEntry() 00153 { 00154 clear(); 00155 } 00156 00157 SSRCEntry( const SSRCEntry& orig ) 00158 { 00159 redo(orig); 00160 } 00161 00162 virtual ~SSRCEntry(); 00163 00164 SSRCEntry& operator=( const SSRCEntry& orig ) 00165 { 00166 redo(orig); 00167 return *this; 00168 } 00169 00170 void logprint( ostream& ostr ); 00171 00172 protected: 00173 friend class MNRTPList; 00174 00175 /* 00176 * Set functions 00177 */ 00178 SSRCEntry* set_ssrc( u_int32 val ); 00179 SSRCEntry* set_state( rtp_sr_state val ); 00180 SSRCEntry* set_first_seq( u_int16 val ); 00181 SSRCEntry* set_max_seq( u_int16 val ); 00182 SSRCEntry* set_seq_cycles( u_int16 val ); 00183 SSRCEntry* set_packet_count( u_int32 val ); 00184 SSRCEntry* set_packet_ts( u_int32 val ); 00185 SSRCEntry* set_arrive_ts( u_int32 val ); 00186 SSRCEntry* set_arrive_time( const ntp64& val ); 00187 SSRCEntry* set_first_time( const ntp64& val ); 00188 SSRCEntry* set_jitter( float val ); 00189 SSRCEntry* set_dest( const struct sockaddr_in& val ); 00190 SSRCEntry* set_lsr( u_int32 val ); 00191 SSRCEntry* set_lsr_time( u_int32 val ); 00192 SSRCEntry* set_rtt( u_int32 val ); 00193 SSRCEntry* set_sr_packet_count( u_int32 val ); 00194 SSRCEntry* set_sr_octet_count( u_int32 val ); 00195 SSRCEntry* set_sr_ts( u_int32 val ); 00196 SSRCEntry* set_expected_prio( u_int32 val ); 00197 SSRCEntry* set_received_prio( u_int32 val ); 00198 SSRCEntry* set_sdes_items( SDESItemList* val ); 00199 SSRCEntry* set_last_heared( u_int32 val ); 00200 00201 /* 00202 * Get functions, note that sdes_items() is not const! 00203 */ 00204 public: 00205 inline u_int32 ssrc() const { return _ssrc; } 00206 inline rtp_sr_state state() const { return _state; } 00207 inline u_int16 first_seq() const { return _first_seq; } 00208 inline u_int16 max_seq() const { return _max_seq; } 00209 inline u_int16 seq_cycles() const { return _seq_cycles; } 00210 inline u_int32 packet_count() const { return _packet_count; } 00211 inline u_int32 packet_ts() const { return _packet_ts; } 00212 inline u_int32 arrive_ts() const { return _arrive_ts; } 00213 inline const ntp64& arrive_time() const { return _arrive_time; } 00214 inline const ntp64& first_time() const { return _first_time; } 00215 inline float jitter() const { return _jitter; } 00216 inline const Sockaddr& dest() const { return _dest; } 00217 inline u_int32 lsr() const { return _lsr; } 00218 inline u_int32 lsr_time() const { return _lsr_time; } 00219 inline u_int32 rtt() const { return _rtt; } 00220 inline u_int32 sr_packet_count() const { return _sr_packet_count; } 00221 inline u_int32 sr_octet_count() const { return _sr_octet_count; } 00222 inline u_int32 sr_ts() const { return _sr_ts; } 00223 inline u_int32 expected_prio() const { return _expected_prio; } 00224 inline u_int32 received_prio() const { return _received_prio; } 00225 protected: 00226 inline SDESItemList* sdes_items() { return _sdes_items; } 00227 inline u_int32 last_heared() const { return _last_heared; } 00228 00229 /* 00230 * Functions that execute several set-functions at a time, or 00231 * functions that performs dedicated operations on a single 00232 * member variable. 00233 */ 00234 00235 SSRCEntry* set_lsr_time_now( ); 00236 00237 void compute_rtt( ); 00238 00239 SSRCEntry* set_arrive_times( u_int32 packet_ts, 00240 u_int32 arrive_ts, 00241 const ntp64& arrive_time ); 00242 00243 SSRCEntry* set_rr_vals( const rtcp_rr_t& report ); 00244 00245 void delete_sdes_items( ); 00246 SDESItem* find_by_type( u_int8 type ); 00247 00248 SSRCEntry* inc_seq_cycles( ); 00249 SSRCEntry* inc_packet_count( ); 00250 SSRCEntry* inc_last_heared( ); 00251 00252 public: 00253 void write_rr_block_to_buffer( void* buffer, 00254 size_t len, 00255 const ntp64& now ); 00256 }; 00257 00258 /*********************************************************************** 00259 * MNRTPList 00260 ***********************************************************************/ 00261 00262 class MNRTPList 00263 { 00264 /******************************************************************* 00265 * SSRCEntryList 00266 *******************************************************************/ 00267 public: 00268 class SSRCEntryList 00269 : private MNList<SSRCEntry*> 00270 { 00271 public: 00272 void* first() { 00273 return MNList<SSRCEntry*>::first(); 00274 } 00275 00276 void next( void*& pix ) { 00277 pix = MNList<SSRCEntry*>::succ(pix); 00278 } 00279 00280 SSRCEntry* inf( void* pix ) { 00281 return MNList<SSRCEntry*>::inf(pix); 00282 } 00283 00284 void append( SSRCEntry* p ) { 00285 MNList<SSRCEntry*>::push_back ( p ); 00286 } 00287 00288 void clear() { 00289 MNList<SSRCEntry*>::clear(); 00290 } 00291 00292 void del( void* pix ) { 00293 MNList<SSRCEntry*>::del_item(pix); 00294 } 00295 00296 size_t length( ) { 00297 return MNList<SSRCEntry*>::length(); 00298 } 00299 00300 private: 00301 SSRCEntry* operator()( void* pix ) { 00302 return MNList<SSRCEntry*>::inf(pix); 00303 } 00304 }; 00305 00306 /******************************************************************* 00307 * SSRCEntriesAll 00308 *******************************************************************/ 00309 private: 00313 class SSRCEntriesAll 00314 { 00315 SSRCEntry** _array; 00316 size_t _size; 00317 00319 SSRCEntriesAll& operator=( const SSRCEntriesAll& ); 00320 00322 SSRCEntriesAll( const SSRCEntriesAll& ); 00323 00324 public: 00325 SSRCEntriesAll( SSRCEntryList& entries ); 00326 00327 ~SSRCEntriesAll(); 00328 00329 inline size_t size() const { 00330 return _size; 00331 } 00332 00333 SSRCEntry* inf( size_t idx ); 00334 }; 00335 00336 private: 00337 SSRCEntryList daten; 00338 int sr_count; 00339 u_int32 my_ssrc; 00340 00341 void clr(); /* clear all Data */ 00342 void update_sdes_item( SSRCEntry* ssrc_entry, 00343 const rtcp_sdes_item_t* item); 00344 00345 public: 00346 MNRTPList(); 00347 ~MNRTPList(); /* clear all Data */ 00348 void update_ssrc( rtp_hdr_t* rtp, 00349 ntp64 arr_time, 00350 struct sockaddr_in dest_ ); 00351 void update_ssrc( MNRTPPacketPtr rtp, 00352 ntp64 arr_time, 00353 struct sockaddr_in dest_ ); 00354 /* insert or update a ssrc, validity of rtp header is not checked */ 00355 void update_sr(rtcp_t* sr, struct sockaddr_in dest_); 00356 void update_rr(rtcp_t* rr, struct sockaddr_in dest_, int& count); 00357 void update_sdes(rtcp_t* sdes); 00358 void update_bye(rtcp_t* bye); 00359 void delete_ssrc(u_int32); /* delete ssrc (as made by bye packet) */ 00360 00361 void set_my_ssrc(u_int32 ssrc); 00362 00363 u_int32 get_first_ssrc(); 00364 u_int32 get_next_ssrc(u_int32 ssrc); 00365 bool find_ssrc(u_int32); 00366 SSRCEntry* get_ssrc_info_ptr(u_int32); 00367 SSRCEntry get_ssrc_info(u_int32); 00368 void make_inactive(); /* make all sources inactive -> after each report (dont change states like old..)*/ 00369 void increment_heared_and_check_old(); /* increment all last_heared */ 00370 struct sockaddr_in get_addr(u_int32 ssrc); /* get address data of ssrc, used for detecting ssrc collissions */ 00371 00372 int get_sr_count(); 00373 int get_active_number(); 00374 void delete_all(); 00375 }; 00376 #endif 00377

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