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 DATA_PUMP_H
00025
#define DATA_PUMP_H
00026
00027
#include "mnstream.h"
00028
#include "MNString.h"
00029
#include "GMUser.h"
00030
#include "MNRTPSockets.h"
00031
#include "RTSPProxySession.h"
00032
#include "var_type.h"
00033
#include "sdp/TransportTypes.h"
00034
00035
#include <vector>
00036
00037
class KomServer;
00038
class SDPSessionDescription;
00039
00040
00041 enum StreamingType
00042 {
00043
StreamingFromFileToPort,
00044
StreamingFromFileToPortTuned,
00045
StreamingFromPortToPortAndFile,
00046
StreamingFromPortToPort,
00047
StreamingFromPortToPortDynReflection,
00048
StreamingFromPortToFile,
00049
PatchStreaming,
00052
PatchGleaning,
00056
NoStreaming
00057 };
00058
00059 ostream&
operator<<( ostream& ostr, StreamingType s );
00060
00061 class DataPumpResponse
00062 {
00063
public:
00064
virtual int stream_started(
int serverport ) = 0;
00065
virtual int formatswitching_suggested(
int new_pt,
long old_ssrc,
long old_bytepos,
00066
long new_ssrc,
long new_bytepos ) = 0;
00067
virtual void fileComplete(
const char* filename,
bool comp ) = 0;
00068 };
00069
00070 class dataPump :
public GMUser
00071 {
00072
MNSelector& _main_selector;
00073
SDPSessionDescription* _sdesc;
00074
00075
typedef std::vector<int> PortVector;
00076
typedef std::vector<MNSocket*> SocketVector;
00077
public:
00078 enum Server_Type
00079 {
00080
MN_SERVER,
00081
VC_SERVER
00082 };
00083
00084 Server_Type _stype;
00085 DataPumpResponse*
_resp;
00086
00087
protected:
00088 StreamingType _StreamingType;
00089
00103
00104 PortVector
_DistantPortDownstream;
00105
00108
00109 PortVector
_DistantPortUpstream;
00110
00111
00112 bool _tfrc;
00113
00115 int _client_bw;
00116 PortVector
_client_bw_vec;
00117
00119 MNString _clientname;
00120
00121 MNString _url;
00122
00123
private:
00125
00126 SocketVector _local_down_rtpsock_vec;
00127
00129
00130 SocketVector _local_down_rtcpsock_vec;
00131
00135
00136 SocketVector _local_up_rtpsock_vec;
00137
00141
00142 SocketVector _local_up_rtcpsock_vec;
00143
00144
public:
00145
dataPump(
MNSelector& sel,
DataPumpResponse* resp,
SDPSessionDescription* sdesc );
00146
virtual ~dataPump ( );
00147
00148
DataPumpResponse*
responder ( );
00149
00150
MNSelector&
mainSelector( );
00151
00152
00153
00154
00155
00156
virtual int init ( KomServer*, StreamingType type ) = 0;
00157
00158
void setUrl(
MNString& url);
00159
00160
virtual void setNptSeek(
int npt);
00161
virtual int getNptSeconds();
00162
virtual void setRTPTimestamp(
int idx,
u_int32 rtptime);
00163
00185
virtual bool createUpstreamSocks(
int idx,
00186
int& requested,
00187
RTPSockets::FactoryMode mode,
00188 RTSP::TransportTypes requested_transport = RTSP::RTP_AVP_UDP ) = 0;
00189
00190
00211
virtual bool createDownstreamSocks(
int idx,
00212
int& requested,
00213
RTPSockets::FactoryMode mode,
00214 RTSP::TransportTypes requested_transport = RTSP::RTP_AVP_UDP ) = 0;
00215
00216
virtual int stream_start (
int idx,
00217
const MNString& filename,
00218
const MNString& DescFileName,
00219
const MNString& client,
00220
const MNString& server,
00221
int ClientPortAnnounced,
00222
int ServerPortAnnounced ) = 0;
00223
virtual void setupNewServerSideReflectorGM(
int idx);
00224
virtual void setupExistingServerSideReflectorGM(
int idx);
00225
virtual int play (
int start,
int stop ) = 0;
00226
virtual int stop ( ) = 0;
00227
virtual int pause ( );
00228
virtual int jump (
int startpos );
00229
virtual void fileComplete(
const char* filename,
bool comp );
00230
00235
virtual long getFilePos();
00236
00237
00238
00239
Server_Type getServerType ( );
00240
void setServerType ( Server_Type stype );
00241
00242
00243
00244
00245
00246
00247
00248 inline bool upStreamReady(
int idx)
const {
00249
return (
getLocalUpRtp(idx) != NULL );
00250 }
00251
00252 inline bool downStreamReady(
int idx)
const {
00253
return (
getLocalDownRtp(idx) != NULL );
00254 }
00255
00256
virtual MNSocket*
getLocalDownRtp(
int idx )
const;
00257
virtual MNSocket*
getLocalDownRtcp(
int idx )
const;
00258
virtual MNSocket*
getLocalUpRtp(
int idx )
const;
00259
virtual MNSocket*
getLocalUpRtcp(
int idx )
const;
00260
00277
virtual bool fillTransportString(
int idx,
MNString& out,
bool mc )
const = 0;
00278
00279
virtual void setLocalDownSocks(
int idx,
MNSocket* rtp,
MNSocket* rtcp );
00280
virtual void setLocalUpSocks(
int idx,
MNSocket* rtp,
MNSocket* rtcp );
00281
00282
virtual int getDistantPortDownstream(
int idx )
const;
00283
virtual void setDistantPortDownstream(
int idx,
int );
00284
virtual int getDistantPortUpstream(
int idx)
const;
00285
virtual void setDistantPortUpstream(
int idx,
int );
00286
00287
virtual int getLocalPortDownstream(
int idx )
const;
00288
virtual int getLocalPortUpstream(
int idx )
const;
00289
00290 virtual StreamingType getStreamingType()
const {
00291
return _StreamingType;
00292 }
00293
00294 virtual void set_client_port(
int ,
int ) {};
00295
00299
virtual long getCorrespondingSsrc(
int payloadtype );
00300
00320
virtual void addFmtSsrcMapping(
SDPSessionDescription* sdesc );
00321
00322 virtual void switchFormat() { };
00323
00324
void setSessionDescription(
SDPSessionDescription* desc );
00325
SDPSessionDescription*
getSessionDescription( );
00326
00328
virtual const SDP::PayloadTypeTable*
getPayloadTypes();
00329
00330
virtual SDP::PayloadTypes
getInternalPayloadType();
00331
virtual int getRTPPayloadType();
00332
virtual const SDP::PayloadTypeTable*
getPayloadTypes(
int idx);
00333
00334
virtual SDP::PayloadTypes
getInternalPayloadType(
int idx);
00335
virtual int getRTPPayloadType(
int idx);
00336
virtual int getPlayTimeSeconds();
00337
00344 virtual bool isPatchingCapable()
const {
00345
return false;
00346 }
00347
00351 virtual void setMulticastInformation(
MNString ,
00352
MNSocket* ,
00353
MNSocket* )
00354 { }
00355
00359 virtual void setBufferInformation(
int ,
00360
int )
00361 { }
00362
00367
static int getLegalEvenPortnum();
00368
00369
private:
00370
unsigned _proxy_formatswitching : 1;
00371
00372
public:
00373
void setProxyFormatswitching(
bool yesno );
00374
bool getProxyFormatswitching( ) const;
00375
void setTCPfriendly(
bool yesno );
00376
void setClientHostname(
MNString client );
00377
bool getTCPfriendly( ) const;
00378
void setClientBandwidth(
int client_bw);
00379
int getClientBandwidth( ) const;
00380
void setClientBandwidth(
int idx,
int client_bw);
00381
int getClientBandwidth(
int idx ) const;
00382 };
00383
00384 #endif
00385