00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef MN_RTP_ENCODER_STREAM_HANDLER_H
00025
#define MN_RTP_ENCODER_STREAM_HANDLER_H
00026
00027
#include <sys/types.h>
00028
#include <sys/time.h>
00029
00030
#include "SH.h"
00031
#include "SHEndpoint.h"
00032
#include "SHEndpointSpec.h"
00033
#include "MNTimerCall.h"
00034
#include "MNValid.h"
00035
#include "var_type.h"
00036
#include "MNRTPutildefs.h"
00037
#include "lcrtp/MNLCRTPdefs.h"
00038
#include "lcrtp/MNLCRTPLossList.h"
00039
#include "MNTFRCSend.h"
00040
#include "sdp/PayloadTypes.h"
00041
#include "sdp/PayloadTypeEntry.h"
00042
00043
class MNRTP;
00044
class MNUDPSocket;
00045
class MNRTPEncoderBase;
00046
class RetransBase;
00047
class MNRope;
00048
class MNRTPPacket;
00049
class MNStreamer;
00050
00051
#define RTP_NAME "LCTZ"
00052
#define TIMED_OUT 200
00053
#define PACK_SIZE 512
00054
00055
namespace SH
00056 {
00057
00058
class RTPEncoderSH;
00059
class RTPEncoderSinkEndpointSpec;
00060
class RTPEncoderSourceEndpointSpec;
00061
class RTPEncoderSinkEndpoint;
00062
class RTPEncoderSourceEndpoint;
00063
00068 class CBPointer :
public TimerCall<RTPEncoderSH>
00069 {
00070
typedef void (RTPEncoderSH::*callback)(
void* data,
TimerCallBase*
self );
00071
int _idx;
00072
public:
00073
CBPointer(
int idx,
RTPEncoderSH* encSH, callback cb );
00074 virtual ~CBPointer( ) { };
00075
00076 int getIndex( ) {
return _idx; }
00077 };
00078
00079
00080
00081
00082
00086 class RTPEncoderSinkEndpoint
00087 :
public SinkEndpoint
00088 {
00089
public:
00090
RTPEncoderSinkEndpoint(
RTPEncoderSH* mySH );
00091
virtual ~RTPEncoderSinkEndpoint( );
00092 };
00093
00094
00095
00096
00097
00101 class RTPEncoderSourceEndpoint
00102 :
public SourceEndpoint
00103 {
00104
public:
00105
RTPEncoderSourceEndpoint(
RTPEncoderSH* mySH );
00106
virtual ~RTPEncoderSourceEndpoint( );
00107 };
00108
00109
00110
00111
00112
00113 class RTPEncoderSH
00114 :
public Base
00115 {
00116 DECLARE_VALID
00117
00118
MNRTPEncoderBase* _codec;
00119
RetransBase* _retrans;
00120
00121
CBPointer** _cbp;
00122
00125
MNTimer _timer;
00126
Timeval _last_playtime_packet;
00127
00131
SH_RC verify_codec( );
00132
00134
SA_RTP_MAX_PACKET_SIZE _max_packet_size;
00135
00136
SA_RTP_RTP_PAYLOAD_TYPE _rtp_pt;
00137
SA_RTP_INT_PAYLOAD_TYPE _int_pt;
00138
SA_RTP_INT_RETRANS_TYPE _int_rt;
00139
00142
SA_ACTIVE_DELAY _delay;
00143
00152
SA_RTP_PLAYOUT_SCALE _playout_scale;
00153
SA_RTP_BANDWIDTH _bandwidth;
00154
SA_HAS_ORDERED_DATA _hasOrderedData;
00155
SA_RTP_SSRC _ssrc;
00156
SA_TCPF _tcpf;
00157
SA_CLIENT_MAX_BW _client_max_bw;
00158
00164
SA_LCRTP_REPEAT_TIMES _repeat_times_attr;
00165
00186
struct timeval _media_time;
00187
MNMutex _block_pull;
00188
bool _resync_required;
00189
00194
struct timeval _construction_time;
00195
00199
struct timeval _pause_time;
00200
00205
struct timeval _delta_paused;
00206
00207
00208
MNTFRCSend* _tfrc;
00209
MNMutex _tfrc_mutex;
00210
00211
00214
MediaState _streamer_state;
00215
00216
struct timeval _timeneu;
00217
00218
00219
MNMutex _send_mutex;
00220
Timeval _resend_timeout;
00221
ProtectedU_int32 _repeat_timeouts;
00222
bool _isEndReached;
00223
00224
void evalRTCPPacket(
u_int32 ssrc,
00225
void* data,
00226
int len,
00227
int subtype,
00228
char* name,
00229
bool inCallback );
00230
00231
00232
00233
SH_RC pull_encode(
DataPtr& item );
00234
00235
void set_retrans( );
00236
00237
00238
public:
00239
RTPEncoderSH(
SHGraphManager* mgr,
00240
u_int32_t runtimeId,
00241
MNSelector& sel );
00242
00243
virtual ~RTPEncoderSH();
00244
void send_end();
00245
00246
private:
00247
00252
RTPEncoderSH(
const RTPEncoderSH& );
00253
00258
RTPEncoderSH& operator=(
const RTPEncoderSH& );
00259
00260
public:
00263
virtual SH_RC initSH();
00266
virtual SH_RC uninitSH();
00267
00270
virtual SH_RC startStreaming();
00273
virtual SH_RC stopStreaming();
00274
00275
00276
00277
public:
00280
SH_RC pause( );
00281
00282
bool isEndReached()
const;
00283
void setEndIsReached();
00284
00285
00286
00287
00288
protected:
00289
friend class RTPEncoderSinkEndpoint;
00290
friend class RTPEncoderSourceEndpoint;
00291
00292 SinkEndpoint*
_in_ep_a[1];
00293 SourceEndpoint*
_out_ep_a[1];
00294 RTPEncoderSinkEndpoint _inEP;
00295 RTPEncoderSourceEndpoint _outEP;
00296
00297
void pushReport(
ReportPtr report, Base::Direction d );
00298
00299
public:
00300
virtual SinkEndpoint**
getSinkSpecs();
00301
virtual SourceEndpoint**
getSourceSpecs();
00302
00312
virtual bool isConnected() const;
00313
00316
void send_timer_callback(
void* timer,
TimerCallBase* ptr );
00317
00320
void resend_timer_callback(
void* timer,
TimerCallBase* ptr );
00321
00322
void notifyEndIsReached(
void* timer,
TimerCallBase* ptr);
00323 };
00324
00326
00327 };
00328
00329 #endif
00330