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_RTSP_CLIENT_H
00025
#define MN_RTSP_CLIENT_H
00026
00027
#include <stdio.h>
00028
00029
#include "MNSessionState.h"
00030
#include "RTSPClient.h"
00031
#include "MNList.h"
00032
#include "MNString.h"
00033
#include "MNValid.h"
00034
#include "TimeDefs.h"
00035
#include "GMUser.h"
00036
00037
class GUIPanel;
00038
class RTSPParserBase;
00039
class MNRTSPClient;
00040
class KomPlayer;
00041
class RTSPClientSocket;
00042
class MNSelector;
00043
class MNPipeNotifier;
00044
class MNSocketBase;
00045
class TimerCallBase;
00046
00047
00048
00049
00050
00051 class MNRTSPClient
00052 :
public RTSPClient
00053 ,
public GMUser
00054 {
00055 DECLARE_VALID
00056
00057
struct CurrentRequest
00058 {
00059
int cseq;
00060 u_short type;
00061 };
00062
00063
private:
00064
MNSessionState _session_state;
00065
RTSPClientSocket* _socket;
00066 CurrentRequest _last_request;
00067
00072
MNSelector& _selector;
00073
00074
int _multicastPort;
00075
bool _encrypt;
00076
00079
int _sessionsSetup;
00082
int _numSessions;
00085
MNString _setupUrl;
00086
00101
struct sockaddr_in* _client_interface_address;
00102
MNString _destination;
00103
bool _isRealServer;
00104
bool _isDarwinServer;
00105
bool _isJVCCamera;
00106
ParseTimeRange* _play_time;
00107
00108
00109
00110
00111
private:
00112
00113
00114
00115
00116
int handle_describe_reply(
int status,
RTSPParserBase* base );
00117
void handle_setup_reply(
int status,
RTSPParserBase* base );
00118
void handle_pause_reply(
int status,
RTSPParserBase* base );
00119
void handle_teardown_reply(
int status,
RTSPParserBase* base);
00120
void handle_play_reply(
int status,
RTSPParserBase* base );
00121
00130
virtual void init_stage_2( ) = 0;
00131
virtual void open_stage_2( ) = 0;
00132
virtual void play_stage_2( ) = 0;
00133
virtual void pause_stage_2( ) = 0;
00134
virtual void stop_stage_2( ) = 0;
00135
00147
virtual void init_stage_2_failed(
const char* file,
00148
int line,
00149
const char* text ) = 0;
00150
virtual void open_stage_2_failed(
const char* file,
00151
int line,
00152
const char* text ) = 0;
00153
virtual void play_stage_2_failed(
const char* file,
00154
int line,
00155
const char* text ) = 0;
00156
virtual void pause_stage_2_failed(
const char* file,
00157
int line,
00158
const char* text ) = 0;
00159
virtual void stop_stage_2_failed(
const char* file,
00160
int line,
00161
const char* text ) = 0;
00162
00174
virtual void unknown_stage_2(
const char* file,
00175
int line,
00176
const char* text ) = 0;
00177
00178
public:
00179
00180
00181
MNRTSPClient(
MNSelector& selector );
00182
virtual ~MNRTSPClient ( );
00183
00184 inline MNSelector&
mainSelector( ) {
00185
return _selector;
00186 }
00187
00190
void insert(
MNSocketBase* sock );
00191
void remove(
MNSocketBase* sock );
00192
00198
void set_local_sockaddr(
const struct sockaddr_in& addr );
00199
00200
void send_options_request(
const char* url );
00204
void send_teardown_request(
int idx,
const MNString& url );
00205
void send_describe_request(
const MNString& url );
00212
void send_setup_request(
int rtpPort,
const MNString&
Url );
00218
void send_play_request(
int startpos,
int endpos,
const MNString&
Url );
00219
void send_pause_request(
const MNString& url );
00220
00221
00222
private:
00223
bool private_parse_url(
const char* url,
00224
MNString& server,
00225 u_short& port,
00226
MNString& file_name );
00227
void private_store_last_request(
int cseq, u_short req );
00228
void send_play_range_request(
char *range,
const MNString&
Url );
00229
00230
virtual void handle_event(
int seq,
RTSPParserBase* base);
00231
00232
00233
00234
protected:
00235
bool protected_connect(
const char* url );
00236
void protected_disconnect( );
00237
00238
bool isConnected( ) const;
00239
bool isInitialized( ) const;
00240
bool isPlaying( ) const;
00241
00242
int getServerPort();
00243
00244
00245
00246
00247
00248
00249
bool getMulticast() const;
00250
int getMulticastPort() const;
00251
bool getBandwidth() const;
00252 const
char* getServerHostname() const;
00253 const
char* getHostName();
00254
00269
int getPlayTimeSeconds() const;
00270
00274
MDescPtr getMediaDesc() const;
00275
MDescPtr getMediaDesc(
int i) const;
00276
00280
int getNumSessions() const;
00281
00282 protected:
00283
00285 virtual const SDP::PayloadTypeTable* getPayloadTypes(
int idx);
00287 virtual SDP::PayloadTypes getInternalPayloadType(
int idx);
00289 virtual
int getRTPPayloadType(
int idx);
00290
00291 protected:
00299
bool setNotifyEnd( );
00300 private:
00309
void notifyEndTimeout(
void* data,
TimerCallBase* self );
00310 };
00311
00312 #endif