00001 // Red5 server side support for the oflaDemo_test via RTMP 00002 // 00003 // Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 #ifndef _FITCDEMO_H_ 00020 #define _FITCDEMO_H_ 00021 00022 #include <string> 00023 #include <vector> 00024 #include <boost/shared_ptr.hpp> 00025 #include <boost/shared_array.hpp> 00026 #include <boost/scoped_array.hpp> 00027 #include <sstream> 00028 00029 // gnash headers 00030 #include "amf.h" 00031 #include "buffer.h" 00032 #include "element.h" 00033 #include "http.h" 00034 #include "cygnal.h" 00035 00036 // cygnal headers 00037 #include "rtmp_server.h" 00038 00039 namespace cygnal 00040 { 00041 00045 class demoService { 00046 public: 00047 00048 typedef struct { 00049 std::string name; 00050 std::string last; 00051 std::string size; 00052 } filestats_t ; 00053 demoService(); 00054 ~demoService(); 00055 00057 std::vector<boost::shared_ptr<filestats_t> > &getListOfAvailableFiles(const std::string &path); 00058 00060 std::vector<boost::shared_ptr<filestats_t> > &getListOfAvailableFiles(const std::string &path, 00061 const std::string &type); 00062 std::vector<boost::shared_ptr<filestats_t> > &getFileStats() { return _stats; }; 00063 00064 private: 00065 std::string _path; 00066 std::vector<boost::shared_ptr<filestats_t> > _stats; 00067 }; 00068 00069 class OflaDemoTest : public cygnal::RTMPServer 00070 { 00071 public: 00072 OflaDemoTest (); 00073 ~OflaDemoTest (); 00074 00075 // Parse an OflaDemo Request message coming from the Red5 oflaDemo_test. 00076 std::vector<boost::shared_ptr<cygnal::Element > > parseOflaDemoRequest(cygnal::Buffer &buf) 00077 { return parseOflaDemoRequest(buf.reference(), buf.size()); }; 00078 std::vector<boost::shared_ptr<cygnal::Element > > parseOflaDemoRequest(boost::uint8_t *buf, size_t size); 00079 00080 // format a response to the 'oflaDemo' test used for testing Gnash. 00081 boost::shared_ptr<cygnal::Buffer> formatOflaDemoResponse(double num, cygnal::Element &el); 00082 boost::shared_ptr<cygnal::Buffer> formatOflaDemoResponse(double num, cygnal::Buffer &data); 00083 boost::shared_ptr<cygnal::Buffer> formatOflaDemoResponse(double num, boost::uint8_t *data, size_t size); 00084 00085 boost::shared_ptr<cygnal::Buffer> getResponse() { return _response; }; 00086 void setResponse(boost::shared_ptr<cygnal::Buffer> &x) { _response = x; }; 00087 00088 void setNetConnection(gnash::RTMPMsg *msg) { _netconnect.reset(msg); }; 00089 void setNetConnection(boost::shared_ptr<gnash::RTMPMsg> msg) { _netconnect = msg; }; 00090 boost::shared_ptr<gnash::RTMPMsg> getNetConnection() { return _netconnect;}; 00091 00097 boost::shared_ptr<gnash::RTMPMsg> _netconnect; 00098 private: 00099 boost::shared_ptr<cygnal::Buffer> _response; 00100 boost::shared_ptr<Handler::cygnal_init_t> _info; 00101 }; 00102 00103 // the standard API 00104 extern "C" { 00105 boost::shared_ptr<Handler::cygnal_init_t>oflaDemo_init_func(boost::shared_ptr<gnash::RTMPMsg> &msg); 00106 00107 boost::shared_ptr<cygnal::Buffer> oflaDemo_read_func(); 00108 size_t oflaDemo_write_func(boost::uint8_t *data, size_t size); 00109 } 00110 00111 } // end of cygnal namespace 00112 #endif // end of __FITCDEMO_H__ 00113 00114 // local Variables: 00115 // mode: C++ 00116 // indent-tabs-mode: t 00117 // End: