00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
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
00129
00130
public:
00131
virtual SinkEndpoint**
getSinkSpecs();
00132
virtual SourceEndpoint**
getSourceSpecs();
00133
00134
00135
00136
00146
virtual bool isConnected() const;
00147
00148 private:
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 private:
00162
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
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
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
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
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
00288
MNRope* createExtensionHeaderData( );
00289 };
00290
00292
00293 };
00294
00295 #endif
00296