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

MNRTP.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 MNRTP_H 00025 #define MNRTP_H 00026 00027 #include "MNArrayList.h" 00028 #include "MNRTPbase.h" 00029 #include "MNRTCP.h" 00030 #include "MNRTPSendCsrcList.h" 00031 #include "MNRTPSsrcCollisionList.h" 00032 #include "MNSocketQueue.h" 00033 #include "sdp/PayloadTypes.h" 00034 #include "sdp/TransportTypes.h" 00035 00036 00037 struct addr_list_item; 00038 00039 /*********************************************************************** 00040 * MNRTP 00041 * Beschreibung: enthaelt die basis funktionalitaet von RTP 00042 * September 99 00043 ***********************************************************************/ 00044 00045 class MNRTP : public MNRTPbase 00046 , public MNRTP_RTCPbye_callback 00047 , public MNRTP_Collision_callback 00048 { 00049 /* Constructor and destructor section */ 00050 00052 MNRTP& operator=( const MNRTP& ); 00053 00055 MNRTP( const MNRTP& ); 00056 00057 public: 00082 MNRTP( MNSelector& sel, 00083 MNSocket* rtpsock, 00084 MNSocket* rtcpsock, 00085 int remote_port, 00086 const char* targetaddr_, 00087 int payload_t, 00088 u_int32 bw, 00089 RTSP::TransportTypes requested_transport = RTSP::RTP_AVP_UDP, 00090 int dpt_ts_rate = -1); 00091 00092 virtual ~MNRTP(); 00093 00094 protected: 00095 /******vars******/ 00096 00101 SendCsrcList _send_csrcs; 00102 00108 SsrcCollisionList ssrc_coll_list; 00109 00111 struct sockaddr_in* _target_save; 00112 00114 ProtectedU_int32 ssrc_collission_counter; 00115 00116 ProtectedInt32 rtcp_port; 00117 00119 struct sockaddr_in rtp_my_addr; 00120 00121 // ProtectedU_int32 rtp_last_ts; /* last timestamp */ 00122 00124 ProtectedU_int16 rtp_seq; 00125 00126 // MNRTCP* RTCPslave_ptr; 00127 00128 MNMutex rtp_initialized; 00129 MNMutex send_mutex; 00130 00131 /****** functions ******/ 00132 00133 private: 00139 int make_even(int port); 00140 00141 void rtp_resolve_ssrc_col(struct sockaddr_in *dest); /* resolves a ssrc collision */ 00142 00143 virtual RTP_RC process_data( MNRope* rope, struct sockaddr_in *dest); 00144 00145 void notify_write_enabled(); 00146 void rtp_timeout_check(); /* checks the ssrc_coll list for timed out items */ 00147 void rtp_lock(); 00148 void rtp_unlock(); 00149 00150 /****** call back ******/ 00151 virtual void RTPcollission_cb(struct sockaddr_in *dest); 00152 00154 RTSP::TransportTypes _requested_transport; 00155 00156 /****** The queue of not sent RTP data during a RTP/TCP transfer ******/ 00157 MNSocketQueue* _data_queue; 00158 00159 /****** RTCP ******/ 00160 /* starts if rtcp_allowed is true*/ 00161 MNRTCP* _rtcp_server; 00162 MNMutex rtcp_mutex; 00163 // ProtectedBool rtcp_ok; 00164 virtual void RTCPbye_cb(u_int32 ssrc, text_item_t *bye_text); 00165 00166 public: 00167 /****** Standard functions ******/ 00168 00174 RTP_RC rtp_start( bool sender = false); 00175 00194 int rtp_send( MNRope* buf, 00195 int marker, 00196 int ts_in_value, 00197 rtp_math tstamp ); 00198 00225 int rtp_send_ext( MNRope* buf, 00226 char* ext_buf, 00227 int ext_len, 00228 u_int16 ext_type, 00229 int marker, 00230 int ts_inc_value, 00231 rtp_math tstamp); 00232 00233 /* times a collision occurred */ 00234 u_int32 get_collision_counter(); 00235 00236 /* sets the time to live (ttl) size */ 00237 virtual void set_mc_ttl(int val); 00238 00245 SendCsrcList& rtp_csrcs() { 00246 return _send_csrcs; 00247 } 00248 // void rtp_csrc_add(u_int32 csrc); 00249 // void rtp_csrc_del(u_int32 csrc); 00250 // bool rtp_csrc_find(u_int32 csrc); 00251 // void rtp_csrc_clear(); 00252 // u_int16 rtp_csrc_get_count(); 00253 // u_int32 rtp_csrc_get_first(); 00254 // u_int32 rtp_csrc_get_next(u_int32 csrc); 00255 00256 /****** non standard functions ******/ 00257 00258 /* set ssrc to a defined value, if a collission is detected (and 00259 * ssrc_collision == true) a random ssrc is reset!!*/ 00260 virtual void rt_set_ssrc(u_int32 ssrc); 00261 00264 void disable_collision_detection(); 00265 00268 void enable_collision_detection(); 00269 00277 void rt_set_bandwidth(u_int32 bw); 00278 00283 u_int32 rt_get_bandwidth(); 00284 00285 /****** RTCP ******/ 00286 00287 /* get the rtcp base pointer, needed for init slaves */ 00288 virtual MNRTCP* rt_get_rtcp_ptr(); 00289 00300 void rtcp_stop( bool bye, const char* reason ); 00301 00302 /* new RTCPServer is created (if no one is active) */ 00303 bool rtcp_start( MNSocket* rtcpsock ); 00304 00308 void enable_rtcp(); 00309 00313 void disable_rtcp(); 00314 00315 /* send app defined packet, app must be multiple of u_int32, len is in u_int32 words*/ 00316 int rtcp_send_app(char* app, int len, int subtype); 00317 00320 void rtcp_set_app_name( const char* name ); 00321 00322 void stopRTPUdpServer( ); 00323 00324 /* register the app reader call back*/ 00325 void rtcp_register_RTCPreader_cb(MNRTP_RTCPreader_callback* p); 00326 00327 /* prio gives the messages priority - after prio packets the message is sent */ 00328 void rtcp_set_sdes(rtcp_sdes_type_t type, char* text, int prio); 00329 00330 /* returns the text of a stored sdes message, NULL if not in the list */ 00331 const sdes_list_item* rtcp_get_sdes_text(rtcp_sdes_type_t type); 00332 00333 u_int32 rtcp_get_first_ssrc(); 00334 u_int32 rtcp_get_next_ssrc(u_int32 ssrc); 00335 private: 00336 SSRCEntry* rtcp_get_ssrc_info_ptr(u_int32 ssrc); 00337 public: 00338 SSRCEntry rtcp_get_ssrc_info(u_int32 ssrc); 00339 00340 /****** custom bandwidth methods ******/ 00341 virtual u_int64 GetBytesSent(); 00342 virtual u_int64 GetBytesRecv(); 00343 00344 private: 00348 bool is_rtcp_running() const; 00349 }; 00350 00351 #endif

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