liveMedia/include/RTSPOverHTTPServer.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2008 Live Networks, Inc.  All rights reserved.
00018 // A simple HTTP server that acts solely to implement RTSP-over-HTTP tunneling
00019 // (to a separate RTSP server), as described in
00020 // http://developer.apple.com/documentation/QuickTime/QTSS/Concepts/chapter_2_section_14.html
00021 // C++ header
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       // called only by createNew();
00041   virtual ~RTSPOverHTTPServer();
00042 
00043   static int setUpOurSocket(UsageEnvironment& env, Port& ourPort);
00044 
00045 private:
00046   static void incomingConnectionHandler(void*, int /*mask*/);
00047   void incomingConnectionHandler1();
00048 
00049   // The state of each individual connection handled by a HTTP server:
00050   class HTTPClientConnection {
00051   public:
00052     HTTPClientConnection(RTSPOverHTTPServer& ourServer, int clientSocket);
00053     virtual ~HTTPClientConnection();
00054   private:
00055     static void incomingRequestHandler(void*, int /*mask*/);
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; // used if access control is needed
00115     unsigned char fTCPStreamIdCount; // used for (optional) RTP/TCP
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

Generated on Tue Oct 7 15:38:09 2008 for live by  doxygen 1.5.2