1
// statistics.cpp: Network performance stats for Cygnal, for Gnash.
3
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "gnashconfig.h"
25
#include <boost/thread/mutex.hpp>
32
#include "statistics.h"
34
using namespace gnash;
37
static boost::mutex io_mutex;
39
// The string versions of the codec, used for debugging. If you add
40
// another enum type to codec_e, you have to add the string
41
// representation here or you'll get the wrong output.
42
const char *codec_names[] = {
57
// The string versions of the file type, used for debugging. If you add
58
// another enum type to filetypes_e, you have to add the string
59
// representation here or you'll get the wrong output.
60
const char *filetype_names[] = {
79
Statistics::Statistics() {
82
Statistics::~Statistics() {
87
Statistics::getFPS() {
88
return 0.0; // TODO: FIXME !
92
Statistics::getBitRate() {
94
return (getStartTime() - getStopTime()).seconds() / getBytes();
98
Statistics::addStats() {
99
NetStats *st = new NetStats;
101
st->setStartTime(getStartTime());
102
st->setStopTime(getStopTime());
103
st->setBytes(getBytes());
104
st->setFileType(getFileType());
106
boost::mutex::scoped_lock lock(io_mutex);
107
_netstats.push_back(st);
109
return _netstats.size();
114
boost::mutex::scoped_lock lock(io_mutex);
115
list<NetStats *>::iterator it;
117
for (it = _netstats.begin(); it != _netstats.end(); it++) {
118
NetStats *stats = (*it);
119
if (stats->getFileType() <= VIDEO) {
120
log_debug (_("Stream type is: %s"), filetype_names[stats->getFileType()]);
122
// if (((stats->getFileType() == VIDEO) || (stats->getFileType() == AUDIO)) &&
123
// stats->getCodec() <= VP7) {
124
// log_debug (_("Stream codec is: %s"), codec_names[stats->getCodec()]);
126
log_debug (_("%d bytes were transfered in %s seconds"),
128
to_simple_string(stats->getTimeSpan()).c_str());
132
} // end of gnash namespace
136
// indent-tabs-mode: t