00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _RTSP_OVER_HTTP_SERVER_HH
00024 #define _RTSP_OVER_HTTP_SERVER_HH
00025
00026 #include "Media.hh"
00027 #include "NetInterface.hh"
00028
00029 #define HTTP_BUFFER_SIZE 10000 // for incoming requests, and outgoing responses
00030
00031 class RTSPOverHTTPServer: public Medium {
00032 public:
00033 static RTSPOverHTTPServer* createNew(UsageEnvironment& env, Port ourHTTPPort = 80,
00034 Port rtspServerPort = 554,
00035 char const* rtspServerHostName = "localhost");
00036
00037 protected:
00038 RTSPOverHTTPServer(UsageEnvironment& env, int ourSocket,
00039 Port rtspServerPort, char const* rtspServerHostName);
00040
00041 virtual ~RTSPOverHTTPServer();
00042
00043 static int setUpOurSocket(UsageEnvironment& env, Port& ourPort);
00044
00045 private:
00046 static void incomingConnectionHandler(void*, int );
00047 void incomingConnectionHandler1();
00048
00049
00050 class HTTPClientConnection {
00051 public:
00052 HTTPClientConnection(RTSPOverHTTPServer& ourServer, int clientSocket);
00053 virtual ~HTTPClientConnection();
00054 private:
00055 static void incomingRequestHandler(void*, int );
00056 void incomingRequestHandler1();
00057 UsageEnvironment& envir() { return fOurServer.envir(); }
00058 void resetRequestBuffer();
00059 Boolean parseHTTPRequestString(char* resultCmdName,
00060 unsigned resultCmdNameMaxSize,
00061 char* sessionCookie,
00062 unsigned sessionCookieMaxSize,
00063 char* acceptStr,
00064 unsigned acceptStrMaxSize,
00065 char* contentTypeStr,
00066 unsigned contentTypeStrMaxSize);
00067 void handleCmd_bad();
00068 #if 0 //#####@@@@@
00069 void handleCmd_notSupported(char const* cseq);
00070 void handleCmd_notFound(char const* cseq);
00071 void handleCmd_unsupportedTransport(char const* cseq);
00072 void handleCmd_OPTIONS(char const* cseq);
00073 void handleCmd_DESCRIBE(char const* cseq, char const* urlSuffix,
00074 char const* fullRequestStr);
00075 void handleCmd_SETUP(char const* cseq,
00076 char const* urlPreSuffix, char const* urlSuffix,
00077 char const* fullRequestStr);
00078 void handleCmd_withinSession(char const* cmdName,
00079 char const* urlPreSuffix, char const* urlSuffix,
00080 char const* cseq, char const* fullRequestStr);
00081 void handleCmd_TEARDOWN(ServerMediaSubsession* subsession,
00082 char const* cseq);
00083 void handleCmd_PLAY(ServerMediaSubsession* subsession,
00084 char const* cseq, char const* fullRequestStr);
00085 void handleCmd_PAUSE(ServerMediaSubsession* subsession,
00086 char const* cseq);
00087 void handleCmd_GET_PARAMETER(ServerMediaSubsession* subsession,
00088 char const* cseq, char const* fullRequestStr);
00089 Boolean authenticationOK(char const* cmdName, char const* cseq,
00090 char const* fullRequestStr);
00091 void noteLiveness();
00092 Boolean isMulticast() const { return fIsMulticast; }
00093 static void noteClientLiveness(HTTPClientConnection* clientConnection);
00094 static void livenessTimeoutTask(HTTPClientConnection* clientConnection);
00095 #endif
00096
00097 private:
00098 RTSPOverHTTPServer& fOurServer;
00099 #if 0 //#####@@@@@
00100 unsigned fOurSessionId;
00101 ServerMediaSession* fOurServerMediaSession;
00102 #endif
00103 int fClientSocket;
00104 #if 0 //#####@@@@@
00105 struct sockaddr_in fClientAddr;
00106 TaskToken fLivenessCheckTask;
00107 #endif
00108 unsigned char fRequestBuffer[HTTP_BUFFER_SIZE];
00109 unsigned fRequestBytesAlreadySeen, fRequestBufferBytesLeft;
00110 unsigned char* fLastCRLF;
00111 unsigned char fResponseBuffer[HTTP_BUFFER_SIZE];
00112 Boolean fSessionIsActive;
00113 #if 0 //#####@@@@@
00114 Authenticator fCurrentAuthenticator;
00115 unsigned char fTCPStreamIdCount;
00116 unsigned fNumStreamStates;
00117 struct streamState {
00118 ServerMediaSubsession* subsession;
00119 void* streamToken;
00120 } * fStreamStates;
00121 #endif
00122 };
00123
00124 private:
00125 friend class RTSPOverHTTPTunnel;
00126 int fServerSocket;
00127 Port fRTSPServerPort;
00128 char* fRTSPServerHostName;
00129 };
00130
00131 #endif