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

MNRTPdefs.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 MNRTPDEFS_H 00025 #define MNRTPDEFS_H 00026 #include <assert.h> 00027 #include <sys/time.h> 00028 #include <unistd.h> 00029 #include <errno.h> 00030 #include <string.h> 00031 #include <stdlib.h> 00032 #include <netinet/in.h> 00033 #include <sys/socket.h> 00034 #include <stdio.h> 00035 #include <dlfcn.h> 00036 #include <net/if.h> 00037 00038 #ifdef sun 00039 #include <sys/sockio.h> 00040 #include <arpa/inet.h> 00041 #endif 00042 00043 #include "mnstream.h" 00044 #include "var_type.h" 00045 #include "protected_var_type.h" 00046 00047 #include "MNRTPNetTypes.h" 00048 #include "MNList.h" 00049 #include "MNMutex.h" 00050 00051 class SDESItem 00052 { 00053 u_int8 _type; /* type of item (rtcp_sdes_type_t) */ 00054 u_int8 _length; /* length of item (in octets) */ 00055 char* data; 00056 public: 00057 SDESItem( const rtcp_sdes_item_t* item ); 00058 SDESItem( u_int8 type, u_int8 len, char* d ); 00059 SDESItem( const SDESItem& orig ); 00060 00061 virtual ~SDESItem( ); 00062 00063 SDESItem& operator=( const SDESItem& orig ); 00064 00065 void reset( const rtcp_sdes_item_t* item ); 00066 void reset( u_int8 type, u_int8 len, char* d ); 00067 void flatten( rtcp_sdes_item_t* item ); 00068 u_int8 type() const; 00069 u_int8 length() const; 00070 00071 friend ostream& operator<<( ostream& ostr, const SDESItem& item ); 00072 }; 00073 00074 /*********************************************************************** 00075 * Class: sdes_list_item 00076 * Desc: This class encapsulates the replacement of LEDA lists with 00077 * medianodes simpler implementation. 00078 ***********************************************************************/ 00079 00080 struct sdes_list_item 00081 { 00082 SDESItem sdes_item; 00083 00087 int prio; 00088 00092 int send; 00093 public: 00094 sdes_list_item( u_int8 type, u_int8 len, char* d ); 00095 sdes_list_item( const sdes_list_item& orig ); 00096 00097 virtual ~sdes_list_item( ); 00098 00099 sdes_list_item& operator=( const sdes_list_item& orig ); 00100 00101 void write_item_to_buffer( u_int8* buffer, size_t len ); 00102 }; 00103 00104 /**********************************************************************/ 00111 class SDESSchedule 00112 : private MNList<sdes_list_item*> 00113 { 00114 MNMutex _lock; 00115 public: 00119 SDESSchedule(); 00120 00122 ~SDESSchedule(); 00123 00124 void* first() { 00125 return MNList<sdes_list_item*>::first(); 00126 } 00127 00128 void next( void*& pix ) { 00129 pix = MNList<sdes_list_item*>::succ(pix); 00130 } 00131 00132 sdes_list_item* operator()( void* pix ) { 00133 return MNList<sdes_list_item*>::inf(pix); 00134 } 00135 00136 void append( sdes_list_item* p ) { 00137 MNList<sdes_list_item*>::push_back ( p ); 00138 } 00139 00140 void clear() { 00141 MNList<sdes_list_item*>::clear(); 00142 } 00143 00144 void del( void* pix ) { 00145 MNList<sdes_list_item*>::del_item(pix); 00146 } 00147 00149 void lock(); 00150 00152 void unlock(); 00153 00161 void decrease_send_counters(); 00162 00175 size_t get_sdes_send_number( size_t& bytecount ); 00176 00187 void set_default_cname(); 00188 00212 void set_sdes( rtcp_sdes_type_t type, char* text, int prio ); 00213 }; 00214 00215 /*************************************************************/ 00216 00217 /* Errors */ 00218 00219 enum RTP_RC 00220 { 00221 RTP_OK = 0, 00222 RTP_ERROR = -1, 00223 RTP_NO_SESSION = -2, 00224 RTP_NO_IP = -3, 00225 RTP_IS_IP = -4, 00226 RTP_NO_NUMBER = -5, 00227 RTP_IS_MC = -6, 00228 RTP_NO_MC = -7, 00229 RTP_ALREADY_CONNECTED = -8, 00230 RTP_RUNNING = -9, 00231 RTP_PORT_INVALID = -10, 00232 RTP_BIND_ERROR = -11, 00233 RTP_MC_AND_DIFF_PORT = -12, 00234 RTP_SHORT_PACKET = -13, 00235 00236 RTCP_ERROR = -50, 00237 RTCP_RUNNING = -51, 00238 RTCP_ALREADY_CONNECTED = -52, 00239 RTCP_BUILD_ERROR = -53, 00240 RTCP_BLD_LEN_ERR = -54 00241 }; 00242 00243 #define RTCP_SSRC_NULL 0 00244 00245 00246 /**************************************************************/ 00247 00248 /* RTP ENUMS and defs */ 00249 00250 enum rtp_math 00251 { 00252 RTP_ABSOLUTE_INC = 0, 00253 RTP_INC = 1 00254 }; 00255 00256 00257 /* States of Senders received by us 00258 * HEARED -> VALID -> ACTIVE <-> INACTIVE 00259 * all -> OLD or INVALID 00260 */ 00261 enum rtp_sr_state 00262 { 00263 RTP_SR_HEARED = 80, 00264 RTP_SR_INVALID = 81, 00265 RTP_SR_OLD = 82, 00266 RTP_SR_ACTIVE = 83, 00267 RTP_SR_INACTIVE = 84 /* is also valid */ 00268 }; 00269 00270 /* After 30 min a source should be timed out and deleted 00271 * from List (about 360 * 5 sec = 1800 sec = 30 min) 00272 */ 00273 #define RTCP_SOURCE_TIMEOUT 360 00274 00275 /* After 5 reports without having received a RTCP report, 00276 * a RTP_SR_HEARED source may be deleted 00277 */ 00278 #define RTCP_INACTIVE_TIMEOUT 5 00279 00280 #define RTP_CSRC_MAX 15 00281 00282 #define RTP_BUFFERSIZE 8192 00283 #define RTCP_BUFFERSIZE 4096 00284 #define RTCP_MAX_TU 2048 00285 00286 #define SDES_PRIO_MIN 1 00287 #define SDES_PRIO_MAX 20 00288 00289 /* defs for RTCP stats */ 00290 // change (VK) testing for faster SR in the proxy 00291 //#define RTCP_MIN_TIME 5. /* Minimum scheduled time for a packet */ 00292 #define RTCP_MIN_TIME 1 /* Minimum scheduled time for a packet */ 00293 #define RTCP_SENDER_BW_FRACTION 0.25 /* sender bandwidth fraction */ 00294 #define RTCP_RECV_BW_FRACTION (1-RTCP_SENDER_BW_FRACTION) 00295 #define RTCP_SIZE_GAIN (1. / 16.) /* used for the estimator of the average packet size */ 00296 #define UDP_OVER_IP_SIZE 28 /* the UDP IP header */ 00297 00298 /* makros oder inlines */ 00299 00300 /* DEBUG functions */ 00301 00302 #undef DEBUGJ 00303 #ifdef DEBUGJ 00304 /* all on */ 00305 #define DEBUG_RTPBASE(a) cerr << __FILE__ << " , " << __LINE__ << ": " << a 00306 #define DEBUG_RTP(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00307 #define DEBUG_RTP_SEND(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00308 #define DEBUG_RTP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00309 #define DEBUG_RTCP(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00310 #define DEBUG_LIST(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00311 #define DEBUG_RTCP_SEND(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00312 #define DEBUG_RTCP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00313 00314 /* send and recv on */ 00315 00316 /* 00317 #define DEBUG_RTPBASE(a) 00318 #define DEBUG_RTP(a) 00319 #define DEBUG_RTP_SEND(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00320 #define DEBUG_RTP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00321 #define DEBUG_RTCP(a) 00322 #define DEBUG_LIST(a) 00323 #define DEBUG_RTCP_SEND(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00324 #define DEBUG_RTCP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00325 */ 00326 00327 /* custom */ 00328 /* 00329 #define DEBUG_RTPBASE(a) 00330 #define DEBUG_RTP(a) 00331 #define DEBUG_RTP_SEND(a) 00332 #define DEBUG_RTP_RECV(a) 00333 #define DEBUG_RTCP(a) 00334 #define DEBUG_LIST(a) 00335 #define DEBUG_RTCP_SEND(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00336 #define DEBUG_RTCP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00337 */ 00338 00339 #else 00340 /* all off */ 00341 00342 #define DEBUG_RTPBASE(a) 00343 #define DEBUG_RTP(a) 00344 #define DEBUG_RTP_SEND(a) 00345 #define DEBUG_RTP_RECV(a) 00346 #define DEBUG_RTCP(a) 00347 #define DEBUG_LIST(a) 00348 #define DEBUG_RTCP_SEND(a) 00349 // #define DEBUG_RTCP_RECV(a) 00350 #endif 00351 00352 #define DEBUG_RTCP_RECV(a) cerr << __FILE__ << ", " << __LINE__ << ": " << a 00353 00354 #endif /* MNRTPDEFS_H */ 00355

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