X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2Fjpg-httpd.hxx;h=95568c054161d1fdd981783768076c675a05fbe6;hb=b0dcb657e77579ecc79798ff365737095f96f9e2;hp=e4fde9e9b9a835a026fd04446b32db7c69326d85;hpb=f2a817d1370cde5a94474344a65bacb2f7845352;p=flightgear.git diff --git a/src/Network/jpg-httpd.hxx b/src/Network/jpg-httpd.hxx index e4fde9e9b..95568c054 100644 --- a/src/Network/jpg-httpd.hxx +++ b/src/Network/jpg-httpd.hxx @@ -1,5 +1,4 @@ -// httpd.hxx -- FGFS http property manager interface / external script -// and control class +// jpg-httpd.hxx -- FGFS jpg-http interface // // Written by Curtis Olson, started June 2001. // @@ -24,114 +23,28 @@ // // $Id$ - #ifndef _FG_JPEG_HTTPD_HXX #define _FG_JPEG_HTTPD_HXX -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#ifdef FG_JPEG_SERVER -# include -#else -// dummy it in to keep the compiler happy -class trJpgFactory { -public: - trJpgFactory(); - void init(int, int); - void destroy(); - int render(); - void setFrustum(double,double,double,double,double,double); - void *data(); -}; -#endif +#include // for auto_ptr +#include #include "protocol.hxx" -class trJpgFactory; +// forward decls +class HttpdThread; - -/* simple httpd server that makes an hasty stab at following the http - 1.1 rfc. */ - -class HttpdImageChannel : public simgear::NetChat +class FGJpegHttpd : public FGProtocol { + std::auto_ptr _imageServer; - simgear::NetBuffer buffer ; - trJpgFactory *JpgFactory; - public: - - HttpdImageChannel() : buffer(512) { - - int nWidth = fgGetInt( "/sim/startup/xsize", 800 ); - int nHeight = fgGetInt( "/sim/startup/ysize", 600 ); - - setTerminator("\r\n"); - JpgFactory = new trJpgFactory(); - JpgFactory -> init( nWidth, nHeight ); - } - - ~HttpdImageChannel() { - JpgFactory -> destroy(); - delete JpgFactory; - } - - virtual void collectIncomingData (const char* s, int n) { - buffer.append(s,n); - } - - // Handle the actual http request - virtual void foundTerminator (void); -}; - - -class HttpdImageServer : private simgear::NetChannel -{ - virtual bool writable (void) { return false ; } - - virtual void handleAccept (void) { - simgear::IPAddress addr ; - int handle = accept ( &addr ) ; - SG_LOG( SG_IO, SG_INFO, "Client " << addr.getHost() << ":" << addr.getPort() << " connected" ); - - HttpdImageChannel *hc = new HttpdImageChannel; - hc->setHandle ( handle ) ; - } - -public: - - HttpdImageServer ( int port ) { - open (); - bind( "", port ); - listen( 5 ); - - printf( "HttpdImage server started on port %d\n", port ) ; - } - -}; - - -class FGJpegHttpd : public FGProtocol { - - int port; - HttpdImageServer *imageServer; - -public: - - inline FGJpegHttpd( int p ) { port = p; } - - inline ~FGJpegHttpd() { } + FGJpegHttpd( int p, int hz, const std::string& type ); + ~FGJpegHttpd(); bool open(); - bool process(); - bool close(); }; - #endif // _FG_JPEG_HTTPD_HXX