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

SendBlockSH.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002 Carsten Griwodz 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, this code may be used in unmodified form 00006 * provided that this copyright notice and this permission notice appear 00007 * in supporting documentation. 00008 * 00009 * The code may be made subject to the terms of the GNU General Public 00010 * License, Version 2, and re-distributed under the terms of this license. 00011 * 00012 * Commercial use other than under the terms of the GNU General Public 00013 * License is allowed only after negotiation of conditions with the authors. 00014 */ 00015 #ifndef SEND_BLOCK_SH_H 00016 #define SEND_BLOCK_SH_H 00017 00018 #include <sys/types.h> 00019 #include <stdio.h> 00020 #include <list> 00021 #include <sys/time.h> 00022 00023 #include "SH.h" 00024 #include "SHEndpoint.h" 00025 #include "SHEndpointSpec.h" 00026 #include "DummyLayerSourceSH.h" 00027 #include "MNTimerCall.h" 00028 #include "var_type.h" 00029 #include "MNRTPutildefs.h" 00030 #include "MNLCRTPdefs.h" 00031 #include "MNLCRTPLossList.h" 00032 #include "MNTFRCSend.h" 00033 #include "sdp/PayloadTypes.h" 00034 #include "sdp/PayloadTypeEntry.h" 00035 #include "MNTimeval.h" 00036 #include "DummyList.h" 00037 #include "var_type.h" 00038 #include "var_type.h" 00039 #include "MNRTPcallback.h" 00040 #include "sh/SHData.h" 00041 #include "MNValid.h" 00042 #include "MNTimeval.h" 00043 00044 #define CLOCKRATE 8000 00045 #define LayerDummy_BANDWIDTH 8000 00046 #define RTP_NAME "LCTZ" 00047 #define TIMED_OUT 200 00048 #define PACK_SIZE 512 00049 00050 class MNRope; 00051 class MNRTP; 00052 class MNRTCPPacket; 00053 class MNRTPPacket; 00054 class MNUDPSocket; 00055 class MNRTPEncoderBase; 00056 class MNStreamer; 00057 00058 namespace SH 00059 { 00060 00061 class SendBlockSH; 00062 00067 class SendBlockSH 00068 : public Base 00069 { 00070 public: 00071 SendBlockSH( SHGraphManager* mgr, 00072 u_int32_t runtimeId, 00073 MNSelector& sel ); 00074 00075 virtual ~SendBlockSH(); 00076 00077 SH_RC getPos ( long &pos ); 00078 00079 private: 00080 00085 SendBlockSH( const SendBlockSH& ); 00086 00091 SendBlockSH& operator=( const SendBlockSH& ); 00092 00093 public: 00094 virtual SH_RC initSH(); 00095 virtual SH_RC uninitSH(); 00096 00097 virtual SH_RC startStreaming(); 00098 virtual SH_RC stopStreaming(); 00099 00100 /******************************************************************/ 00101 /* additional attributes for the set() functions */ 00102 /******************************************************************/ 00103 private: 00104 DummyLayerSourceSH _dls; 00105 00106 public: 00107 SA_RTP_MAX_PACKET_SIZE _max_packet_size; 00108 SA_RTP_RTP_PAYLOAD_TYPE _rtp_pt; 00109 SA_RTP_INT_PAYLOAD_TYPE _int_pt; 00110 SA_RTP_INT_RETRANS_TYPE _int_rt; 00111 SA_ACTIVE_DELAY _delay; 00112 SA_RTP_PLAYOUT_SCALE _playout_scale; 00113 SA_RTP_BANDWIDTH _bandwidth; 00114 SA_HAS_ORDERED_DATA _hasOrderedData; 00115 SA_RTP_SSRC _ssrc; 00116 SA_TCPF _tcpf; 00117 SA_CLIENT_MAX_BW _client_max_bw; 00118 SA_LCRTP_REPEAT_TIMES _repeat_times_attr; 00119 SA_FILE_NAME _filename; 00120 SA_FILESRC_START_POS _start_pos; 00121 SA_FILESRC_STOP_POS _stop_pos; 00122 SA_PUSH_PULL_INITIAL_FILL _initial_fill; 00123 SA_RTPSNK_RTP_SOCK_PORT _rtp_socket; 00124 SA_RTPSNK_RTCP_SOCK_PORT _rtcp_socket; 00125 SA_RTPSNK_CLIENT_NAME _client; 00126 SA_RTPSNK_CLIENT_PORT _port; 00127 00128 // Attributes haved been moved to SH.h 00129 00130 public: 00131 virtual SinkEndpoint** getSinkSpecs(); 00132 virtual SourceEndpoint** getSourceSpecs(); 00133 00134 /******************************************************************/ 00135 /* functions required for SHStatus */ 00136 /******************************************************************/ 00146 virtual bool isConnected() const; 00147 00148 private: 00149 // bool _initialized; ///< check if initSH has already been called 00150 // u_int64_t _bytes_read; ///< pseudo byte pos in pseudo file 00151 // u_int64_t _bytes_sent; ///< number of bytes sent 00152 // u_int32_t _cnt; ///< sent packet counter for debug output 00153 // u_int32_t _null_cnt; ///< number of times pulled from empty queue 00154 00155 // u_int32_t _duration; ///< duration in seconds 00156 // u_int32_t _blk_sz; ///< block size 00157 // u_int32_t _bw; ///< bandwidth 00158 00159 // DummyList _entries; 00160 00161 private: 00162 // from RTPSinkSH 00163 00164 MNRTP* _rtp; 00165 u_int16 _rtp_seq; 00166 u_int32 _rtp_time; 00167 int _file_handle; 00168 00169 SH_RC push_to_net( DataPtr item ); 00170 00171 virtual u_int16 get_rtp_seq(); 00172 virtual u_int32 get_rtp_time(); 00173 public: 00174 virtual u_int32 get_ssrc(); 00175 00176 private: 00177 // from EncLayerDummy 00178 00179 bool _first_run; 00180 Timeval _first_pull; 00181 SH::DataPtr _last_data_ptr; 00182 00183 MNRope* get_data( size_t max_bytes_to_pull, 00184 SH::ReturnCode& except, 00185 size_t& pulled_bytes, 00186 bool& rtp_marker, 00187 u_int32& rtp_timestamp, 00188 Timeval& next_playtime_packet, 00189 int bandwidth, 00190 u_int32 filepos ); 00191 00192 MNRope* get_next_data( size_t max_bytes_to_pull, 00193 SH::ReturnCode& except, 00194 size_t& pulled_bytes, 00195 bool& rtp_marker, 00196 u_int32& rtp_timestamp, 00197 Timeval& next_playtime_packet, 00198 int bandwidth ); 00199 00200 virtual u_int32_t get_std_bw( int fd ); 00201 virtual int get_timer_type( ); 00202 00203 private: 00204 // from RTPEncoderSH 00205 00206 int _fd; 00207 MNTimer _timer; 00208 Timeval _last_playtime_packet; 00209 TimerCall<SendBlockSH> _cb; 00210 TimerCall<SendBlockSH> _resend_cb; 00211 struct timeval _media_time; 00212 MNMutex _block_pull; 00213 bool _resync_required; 00214 u_int64 _offset; 00215 struct timeval _construction_time; 00216 struct timeval _pause_time; 00217 struct timeval _delta_paused; 00218 MNTFRCSend* _tfrc; 00219 MNMutex _tfrc_mutex; 00220 MediaState _streamer_state; 00221 struct timeval _timeneu; 00222 MNMutex _send_mutex; 00223 MNTimer _resend_timer; 00224 Timeval _resend_timeout; 00225 ProtectedInt32 _end_timeout; 00226 ProtectedU_int32 _repeat_timeouts; 00227 lcstreamer_send_t _StreamData; 00228 bool _isEndReached; 00229 00230 SH_RC verify_codec( ); 00231 void evalLCRTCPPacket( u_int32 ssrc, 00232 void* data, 00233 int len, 00234 int subtype, 00235 char* name, 00236 bool inCallback ); 00237 SH_RC pull_encode( DataPtr& item ); 00238 void send_end(); 00239 public: 00240 SH_RC pause( ); 00241 bool isEndReached() const; 00242 void setEndIsReached(); 00243 void send_timer_callback( void* timer, TimerCallBase* ptr ); 00244 void resend_timer_callback( void* timer, TimerCallBase* ptr ); 00245 00246 void pushReport( ReportPtr report, Base::Direction d ); 00247 void rtpsink_pushReport( ReportPtr report, Base::Direction d ); 00248 00249 private: 00250 // from MNRTPEncoderBase 00251 size_t _std_packet_length; 00252 size_t _cur_packet_length; 00253 Timeval _cur_time_offset; 00254 size_t _cur_rtp_timestamp_offset; 00255 enum timer_type 00256 { 00257 TT_PERIODIC, 00258 TT_DYNAMIC 00259 }; 00260 size_t get_std_packetsize() const; 00261 void set_std_packetsize( size_t sz ); 00262 size_t get_packetsize() const; 00263 Timeval get_timeout( ) const; 00264 size_t get_ts_offset() const; 00265 void set_ts_offset( size_t ts ); 00266 00267 private: 00268 // from MNRTPEncoderCommon 00269 Timeval _std_time_offset; 00270 size_t _total_bytes_read; 00271 size_t _absolute_byte_position; 00272 size_t _accum_rtp_timestamp; 00273 size_t _pulled_bytes; 00274 00275 Timeval get_std_timeout() const; 00276 void set_std_timeout( size_t pause ); 00277 void inc_total_bytes_read( size_t sz ); 00278 size_t get_total_bytes_read( ) const; 00279 virtual size_t get_abs_byte_pos() const; 00280 void inc_abs_byte_pos( size_t sz ); 00281 size_t get_accum_rtp_ts() const; 00282 void inc_accum_rtp_ts( size_t sz ); 00283 virtual void update_absolute_position( int32 offset ); 00284 size_t get_pulled_bytes(); 00285 00286 private: 00287 // from LCRetrans 00288 MNRope* createExtensionHeaderData( ); 00289 }; 00290 00292 00293 }; // namespace SH 00294 00295 #endif /* SEND_BLOCK_SH_H */ 00296

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