00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software 00003 // 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 00020 #ifndef __NETSTATS_H__ 00021 #define __NETSTATS_H__ 00022 00023 //include all types plus i/o 00024 #include <boost/date_time/posix_time/posix_time.hpp> 00025 00026 // This is what the ActionScript 'Client' class returns: 00027 // 00028 // bytes_in Total number of bytes received. 00029 // bytes_out Total number of bytes sent. 00030 // msg_in Total number of RTMP messages received. 00031 // msg_out Total number of RTMP messages sent. 00032 // msg_dropped Total number of dropped RTMP messages. 00033 // ping_rtt Length of time the client takes to respond to a ping message. 00034 // audio_queue_msgs Current number of audio messages in the queue waiting to be delivered to the client. 00035 // video_queue_msgs Current number of video messages in the queue waiting to be delivered to the client. 00036 // so_queue_msgs Current number of shared object messages in the queue waiting to be delivered to the client. 00037 // data_queue_msgs Current number of data messages in the queue waiting to be delivered to the client. 00038 // dropped_audio_msgs Number of audio messages that were dropped. 00039 // dropped_video_msgs Number of video messages that were dropped. 00040 // audio_queue_bytes Total size of all audio messages (in bytes) in the queue waiting to be delivered to the client. 00041 // video_queue_bytes Total size of all video messages (in bytes) in the queue waiting to be delivered to the client. 00042 // so_queue_bytes Total size of all shared object messages (in bytes) in the queue waiting to be delivered to the client. 00043 // data_queue_bytes Total size of all data messages (in bytes) in the queue waiting to be delivered to the client. 00044 // dropped_audio_bytes Total size of all audio messages (in bytes) that were dropped. 00045 // dropped_video_bytes Total size of all video messages (in bytes) that were dropped. 00046 // bw_out Current upstream (client to server) bandwidth for this client. 00047 // bw_in Current downstream (server to client) bandwidth for this client. 00048 // client_id A unique ID issued by the server for this client. 00049 // 00050 // samples are taken every 3 seconds, or the interval supplied in Client::setInterval() 00051 00052 namespace gnash 00053 { 00054 00055 class NetStats { 00056 public: 00057 NetStats(); 00058 virtual ~NetStats(); 00059 typedef enum { 00060 NO_CODEC, 00061 OGG, 00062 THEORA, 00063 DIRAC, 00064 SNOW, 00065 MP3, 00066 MPEG4, 00067 H264, 00068 H263, 00069 FLV, 00070 VP6, 00071 VP7 00072 } codec_e; 00073 typedef enum { 00074 NO_FILETYPE, 00075 HTTP, 00076 RTMP, 00077 RTMPT, 00078 RTMPTS, 00079 SWF, 00080 SWF6, 00081 SWF7, 00082 SWF8, 00083 SWF9, 00084 AUDIO, 00085 VIDEO 00086 } filetypes_e; 00087 // This is what the ActionScript 'Client' class returns: 00088 typedef struct { 00089 int bytes_in; // Total number of bytes received. 00090 int bytes_out; // Total number of bytes sent. 00091 int msg_in; // Total number of RTMP messages received. 00092 int msg_out; // Total number of RTMP messages sent. 00093 int msg_dropped; // Total number of dropped RTMP messages. 00094 int ping_rtt; // Length of time the client takes to respond to a ping message. 00095 int audio_queue_msgs; // Current number of audio messages in the queue waiting to be delivered to the client. 00096 int video_queue_msgs; // Current number of video messages in the queue waiting to be delivered to the client. 00097 int so_queue_msgs; // Current number of shared object messages in the queue waiting to be delivered to the client. 00098 int data_queue_msgs; // Current number of data messages in the queue waiting to be delivered to the client. 00099 int dropped_audio_msgs; // Number of audio messages that were dropped. 00100 int dropped_video_msgs; // Number of video messages that were dropped. 00101 int audio_queue_bytes; // Total size of all audio messages (in bytes) in the queue waiting to be delivered to the client. 00102 int video_queue_bytes; // Total size of all video messages (in bytes) in the queue waiting to be delivered to the client. 00103 int so_queue_bytes; // Total size of all shared object messages (in bytes) in the queue waiting to be delivered to the client. 00104 int data_queue_bytes; // Total size of all data messages (in bytes) in the queue waiting to be delivered to the client. 00105 int dropped_audio_bytes;// Total size of all audio messages (in bytes) that were dropped. 00106 int dropped_video_bytes;// Total size of all video messages (in bytes) that were dropped. 00107 int bw_out; // Current upstream (client to server) bandwidth for this client. 00108 int bw_in; // Current downstream (server to client) bandwidth for this client. 00109 int client_id; // A unique ID issued by the server for this client. 00110 } netstats_t; 00111 // start the clock counting down 00112 boost::posix_time::ptime startClock(); 00113 // stop the clock from counting down 00114 boost::posix_time::ptime stopClock(); 00115 00116 // Accessors to set to the private data 00117 void setStartTime(boost::posix_time::ptime x) { _starttime = x; }; 00118 void setStopTime(boost::posix_time::ptime x) { _stoptime = x; }; 00119 void setBytes(int x) { _bytes = x; }; 00120 void setFileType(filetypes_e x) { _type = x; }; 00121 // Accumulate the byts transferred 00122 int addBytes(int x) { _bytes += x; return _bytes; }; 00123 00124 // Accessors to get to the private data 00125 int getBytes() { return _bytes; }; 00126 filetypes_e getFileType() { return _type; }; 00127 boost::posix_time::ptime getStartTime() { return _starttime; }; 00128 boost::posix_time::ptime getStopTime() { return _stoptime; }; 00129 boost::posix_time::time_duration getTimeSpan() { return _stoptime - _starttime; }; 00130 NetStats &operator = (NetStats &stats); 00131 private: 00132 boost::posix_time::ptime _starttime; 00133 boost::posix_time::ptime _stoptime; 00134 int _bytes; 00135 filetypes_e _type; 00136 }; 00137 00138 } // end of gnash namespace 00139 00140 #endif // __NETSTATS_H__ 00141 00142 // local Variables: 00143 // mode: C++ 00144 // indent-tabs-mode: t 00145 // End: