00001 // 00002 // Copyright 2003 Sony Corporation 00003 // 00004 // Permission to use, copy, modify, and redistribute this software for 00005 // non-commercial use is hereby granted. 00006 // 00007 // This software is provided "as is" without warranty of any kind, 00008 // either expressed or implied, including but not limited to the 00009 // implied warranties of fitness for a particular purpose. 00010 // 00011 00012 #ifndef W3AIBO_h_DEFINED 00013 #define W3AIBO_h_DEFINED 00014 00015 #include <OPENR/OObject.h> 00016 #include <OPENR/OSubject.h> 00017 #include <OPENR/OObserver.h> 00018 #include "TCPConnection.h" 00019 #include "HTTP.h" 00020 #include "JPEGEncoder.h" 00021 #include "W3AIBOConfig.h" 00022 #include "def.h" 00023 00024 class W3AIBO : public OObject { 00025 public: 00026 W3AIBO(); 00027 virtual ~W3AIBO() {} 00028 00029 OSubject* subject[numOfSubject]; 00030 OObserver* observer[numOfObserver]; 00031 00032 virtual OStatus DoInit (const OSystemEvent& event); 00033 virtual OStatus DoStart (const OSystemEvent& event); 00034 virtual OStatus DoStop (const OSystemEvent& event); 00035 virtual OStatus DoDestroy(const OSystemEvent& event); 00036 00037 void NotifyImage(const ONotifyEvent& event); 00038 00039 void ListenCont (ANTENVMSG msg); 00040 void ReceiveCont (ANTENVMSG msg); 00041 void SendHeaderCont(ANTENVMSG msg); 00042 void SendImageCont (ANTENVMSG msg); 00043 void SendErrorCont (ANTENVMSG msg); 00044 void CloseCont (ANTENVMSG msg); 00045 00046 private: 00047 static const int W3AIBO_CONNECTION_MAX = JPEGEncoder::NUM_JPEG_BUF; 00048 static const size_t W3AIBO_HTTP_BUFSIZE = 4096; 00049 00050 OStatus InitTCPConnection(int index); 00051 OStatus Listen (int index); 00052 OStatus Receive (int index); 00053 OStatus SendHeader(int index); 00054 OStatus SendImage (int index); 00055 OStatus SendError (int index); 00056 OStatus Close (int index); 00057 00058 void ProcessHTTPRequest(int index); 00059 void HTTPResponse (int index, HTTPStatus st); 00060 00061 antStackRef ipstackRef; 00062 HTTP http; 00063 JPEGEncoder jpegEncoder; 00064 TCPConnection connection[W3AIBO_CONNECTION_MAX]; 00065 }; 00066 00067 #endif // W3AIBO_h_DEFINED