1 // statistics.cpp: Network performance stats for Cygnal, for Gnash.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 // 2011 Free Software Foundation, Inc
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <boost/thread/mutex.hpp>
28 #include "statistics.h"
31 static boost::mutex io_mutex
;
33 // The string versions of the codec, used for debugging. If you add
34 // another enum type to codec_e, you have to add the string
35 // representation here or you'll get the wrong output.
36 const char *codec_names
[] = {
51 // The string versions of the file type, used for debugging. If you add
52 // another enum type to filetypes_e, you have to add the string
53 // representation here or you'll get the wrong output.
54 const char *filetype_names
[] = {
73 Statistics::Statistics() {
76 Statistics::~Statistics() {
81 Statistics::getFPS() {
82 return 0.0; // TODO: FIXME !
86 Statistics::getBitRate() {
88 return (getStartTime() - getStopTime()).seconds() / getBytes();
92 Statistics::addStats() {
93 NetStats
*st
= new NetStats
;
95 st
->setStartTime(getStartTime());
96 st
->setStopTime(getStopTime());
97 st
->setBytes(getBytes());
98 st
->setFileType(getFileType());
100 boost::mutex::scoped_lock
lock(io_mutex
);
101 _netstats
.push_back(st
);
103 return _netstats
.size();
108 boost::mutex::scoped_lock
lock(io_mutex
);
109 std::list
<NetStats
*>::iterator it
;
111 for (it
= _netstats
.begin(); it
!= _netstats
.end(); it
++) {
112 NetStats
*stats
= (*it
);
113 if (stats
->getFileType() <= VIDEO
) {
114 log_debug (_("Stream type is: %s"), filetype_names
[stats
->getFileType()]);
116 // if (((stats->getFileType() == VIDEO) || (stats->getFileType() == AUDIO)) &&
117 // stats->getCodec() <= VP7) {
118 // log_debug (_("Stream codec is: %s"), codec_names[stats->getCodec()]);
120 log_debug (_("%d bytes were transfered in %s seconds"),
122 to_simple_string(stats
->getTimeSpan()).c_str());
126 } // end of gnash namespace
130 // indent-tabs-mode: t