mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Separated information/statistics into several color button pages.
This commit is contained in:
parent
3ec7e15e40
commit
b0df5006b6
13
common.h
13
common.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: common.h,v 1.6 2007/10/07 22:54:09 rahrenbe Exp $
|
||||
* $Id: common.h,v 1.7 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_COMMON_H
|
||||
@ -22,13 +22,14 @@ uint8_t payload(const uint8_t *tsp);
|
||||
#define error(x...) esyslog("IPTV: " x);
|
||||
#endif
|
||||
|
||||
#define IPTV_STATS_UNIT_IN_BYTES 0
|
||||
#define IPTV_STATS_UNIT_IN_KBYTES 1
|
||||
#define IPTV_STATS_UNIT_IN_BITS 2
|
||||
#define IPTV_STATS_UNIT_IN_KBITS 3
|
||||
#define IPTV_STATS_UNIT_COUNT 4
|
||||
#define IPTV_DEVICE_INFO_ALL 0
|
||||
#define IPTV_DEVICE_INFO_GENERAL 1
|
||||
#define IPTV_DEVICE_INFO_PIDS 2
|
||||
#define IPTV_DEVICE_INFO_FILTERS 3
|
||||
#define IPTV_DEVICE_INFO_BUFFERS 4
|
||||
|
||||
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10
|
||||
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
|
||||
|
||||
#define SECTION_FILTER_TABLE_SIZE 7
|
||||
|
||||
|
4
config.c
4
config.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.c,v 1.14 2007/10/07 20:08:44 rahrenbe Exp $
|
||||
* $Id: config.c,v 1.15 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -14,7 +14,7 @@ cIptvConfig::cIptvConfig(void)
|
||||
: readBufferTsCount(48),
|
||||
tsBufferSize(2),
|
||||
tsBufferPrefillRatio(0),
|
||||
statsUnit(IPTV_STATS_UNIT_IN_KBYTES),
|
||||
useBytes(1),
|
||||
sectionFiltering(1),
|
||||
sidScanning(1)
|
||||
{
|
||||
|
12
config.h
12
config.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.h,v 1.12 2007/10/07 20:08:44 rahrenbe Exp $
|
||||
* $Id: config.h,v 1.13 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_CONFIG_H
|
||||
@ -19,7 +19,7 @@ protected:
|
||||
unsigned int readBufferTsCount;
|
||||
unsigned int tsBufferSize;
|
||||
unsigned int tsBufferPrefillRatio;
|
||||
unsigned int statsUnit;
|
||||
unsigned int useBytes;
|
||||
unsigned int sectionFiltering;
|
||||
unsigned int sidScanning;
|
||||
int disabledFilters[SECTION_FILTER_TABLE_SIZE];
|
||||
@ -29,18 +29,14 @@ public:
|
||||
unsigned int GetReadBufferTsCount(void) { return readBufferTsCount; }
|
||||
unsigned int GetTsBufferSize(void) { return tsBufferSize; }
|
||||
unsigned int GetTsBufferPrefillRatio(void) { return tsBufferPrefillRatio; }
|
||||
unsigned int GetStatsUnit(void) { return statsUnit; }
|
||||
unsigned int IsStatsUnitInBytes(void) { return ((statsUnit == IPTV_STATS_UNIT_IN_BYTES) ||
|
||||
(statsUnit == IPTV_STATS_UNIT_IN_KBYTES)); }
|
||||
unsigned int IsStatsUnitInKilos(void) { return ((statsUnit == IPTV_STATS_UNIT_IN_KBYTES) ||
|
||||
(statsUnit == IPTV_STATS_UNIT_IN_KBITS)); }
|
||||
unsigned int GetUseBytes(void) { return useBytes; }
|
||||
unsigned int GetSectionFiltering(void) { return sectionFiltering; }
|
||||
unsigned int GetSidScanning(void) { return sidScanning; }
|
||||
unsigned int GetDisabledFiltersCount(void);
|
||||
int GetDisabledFilters(unsigned int Index);
|
||||
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
|
||||
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
|
||||
void SetStatsUnit(unsigned int Unit) { statsUnit = Unit; }
|
||||
void SetUseBytes(unsigned int On) { useBytes = On; }
|
||||
void SetSectionFiltering(unsigned int On) { sectionFiltering = On; }
|
||||
void SetSidScanning(unsigned int On) { sidScanning = On; }
|
||||
void SetDisabledFilters(unsigned int Index, int Number);
|
||||
|
86
device.c
86
device.c
@ -3,13 +3,11 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.60 2007/10/08 18:35:10 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.61 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "device.h"
|
||||
#include "sectionfilter.h"
|
||||
|
||||
#define IPTV_MAX_DEVICES 8
|
||||
|
||||
@ -96,25 +94,73 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetInformation()
|
||||
cString cIptvDevice::GetGeneralInformation(void)
|
||||
{
|
||||
// loop through active section filters
|
||||
cString filterInfo("\n");
|
||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||
if (secfilters[i])
|
||||
filterInfo = cString::sprintf("%sSec %d: %s%c", *filterInfo, i,
|
||||
*secfilters[i]->GetStatistic(),
|
||||
((i + 1) % 2) ? '\t' : '\n');
|
||||
}
|
||||
// make sure it ends with linefeed
|
||||
if (!endswith(*filterInfo, "\n"))
|
||||
filterInfo = cString::sprintf("%s%c", *filterInfo, '\n');
|
||||
// generate information string
|
||||
return cString::sprintf("IPTV device #%d (CardIndex: %d)\nSource: %s\n%s%s%s",
|
||||
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
|
||||
return cString::sprintf("IPTV device #%d (CardIndex: %d)\n%s\n%s",
|
||||
deviceIndex, CardIndex(), pIptvStreamer ?
|
||||
*pIptvStreamer->GetInformation() : "", *GetStatistic(),
|
||||
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
|
||||
*filterInfo);
|
||||
*pIptvStreamer->GetInformation() : "",
|
||||
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "");
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetPidsInformation(void)
|
||||
{
|
||||
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
|
||||
cString info("Most active pids:\n");
|
||||
info = cString::sprintf("%s%s", *info, *GetStatistic());
|
||||
return info;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetFiltersInformation(void)
|
||||
{
|
||||
//debug("cIptvDevice::GetFiltersInformation(%d)\n", deviceIndex);
|
||||
unsigned int count = 0;
|
||||
cString info("Active section filters:\n");
|
||||
// loop through active section filters
|
||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||
if (secfilters[i]) {
|
||||
info = cString::sprintf("%sFilter %d: %s Pid=%d\n", *info, i,
|
||||
*secfilters[i]->GetStatistic(), secfilters[i]->GetPid());
|
||||
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetBuffersInformation(void)
|
||||
{
|
||||
//debug("cIptvDevice::GetBuffersInformation(%d)\n", deviceIndex);
|
||||
cString info("Buffers information is not yet implemented!\n");
|
||||
return info;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetInformation(unsigned int Page)
|
||||
{
|
||||
// generate information string
|
||||
cString info;
|
||||
switch (Page) {
|
||||
case IPTV_DEVICE_INFO_GENERAL:
|
||||
info = GetGeneralInformation();
|
||||
break;
|
||||
case IPTV_DEVICE_INFO_PIDS:
|
||||
info = GetPidsInformation();
|
||||
break;
|
||||
case IPTV_DEVICE_INFO_FILTERS:
|
||||
info = GetFiltersInformation();
|
||||
break;
|
||||
case IPTV_DEVICE_INFO_BUFFERS:
|
||||
info = GetBuffersInformation();
|
||||
break;
|
||||
default:
|
||||
info = cString::sprintf("%s%s%s%s",
|
||||
*GetGeneralInformation(),
|
||||
*GetPidsInformation(),
|
||||
*GetFiltersInformation(),
|
||||
*GetBuffersInformation());
|
||||
break;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol)
|
||||
|
12
device.h
12
device.h
@ -3,13 +3,14 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.h,v 1.27 2007/10/07 19:06:33 ajhseppa Exp $
|
||||
* $Id: device.h,v 1.28 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_DEVICE_H
|
||||
#define __IPTV_DEVICE_H
|
||||
|
||||
#include <vdr/device.h>
|
||||
#include "common.h"
|
||||
#include "protocoludp.h"
|
||||
#include "protocolhttp.h"
|
||||
#include "protocolfile.h"
|
||||
@ -48,7 +49,14 @@ private:
|
||||
public:
|
||||
cIptvDevice(unsigned int DeviceIndex);
|
||||
virtual ~cIptvDevice();
|
||||
cString GetInformation();
|
||||
cString GetInformation(unsigned int Page = IPTV_DEVICE_INFO_ALL);
|
||||
|
||||
// for statistics and general information
|
||||
private:
|
||||
cString GetGeneralInformation(void);
|
||||
cString GetPidsInformation(void);
|
||||
cString GetFiltersInformation(void);
|
||||
cString GetBuffersInformation(void);
|
||||
|
||||
// for channel parsing & buffering
|
||||
private:
|
||||
|
6
iptv.c
6
iptv.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: iptv.c,v 1.14 2007/10/07 20:08:44 rahrenbe Exp $
|
||||
* $Id: iptv.c,v 1.15 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
@ -175,8 +175,8 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value)
|
||||
IptvConfig.SetTsBufferSize(atoi(Value));
|
||||
else if (!strcasecmp(Name, "TsBufferPrefill"))
|
||||
IptvConfig.SetTsBufferPrefillRatio(atoi(Value));
|
||||
else if (!strcasecmp(Name, "StatsUnit"))
|
||||
IptvConfig.SetStatsUnit(atoi(Value));
|
||||
else if (!strcasecmp(Name, "UseBytes"))
|
||||
IptvConfig.SetUseBytes(atoi(Value));
|
||||
else if (!strcasecmp(Name, "SectionFiltering"))
|
||||
IptvConfig.SetSectionFiltering(atoi(Value));
|
||||
else if (!strcasecmp(Name, "SidScanning"))
|
||||
|
56
po/fi_FI.po
56
po/fi_FI.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: VDR 1.5.7\n"
|
||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
||||
"POT-Creation-Date: 2007-10-07 22:51+0300\n"
|
||||
"POT-Creation-Date: 2007-10-09 02:46+0300\n"
|
||||
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
|
||||
"Last-Translator: Rolf Ahrenberg\n"
|
||||
"Language-Team: <vdr@linuxtv.org>\n"
|
||||
@ -87,55 +87,55 @@ msgstr "Yksil
|
||||
msgid "IPTV Channels"
|
||||
msgstr "IPTV-kanavat"
|
||||
|
||||
#: setup.c:492
|
||||
#: setup.c:493
|
||||
msgid "IPTV Information"
|
||||
msgstr "IPTV-tiedot"
|
||||
|
||||
#: setup.c:507
|
||||
#: setup.c:496
|
||||
msgid "Buffers"
|
||||
msgstr "Puskurit"
|
||||
|
||||
#: setup.c:496
|
||||
msgid "Filters"
|
||||
msgstr "Suodattimet"
|
||||
|
||||
#: setup.c:496
|
||||
msgid "General"
|
||||
msgstr "Yleiset"
|
||||
|
||||
#: setup.c:496
|
||||
msgid "Pids"
|
||||
msgstr "Pidit"
|
||||
|
||||
#: setup.c:509
|
||||
msgid "IPTV information not available!"
|
||||
msgstr "IPTV-tietoja ei saatavilla!"
|
||||
|
||||
#: setup.c:560
|
||||
msgid "bytes"
|
||||
msgstr "tavuina"
|
||||
|
||||
#: setup.c:561
|
||||
msgid "kbytes"
|
||||
msgstr "kilotavuina"
|
||||
|
||||
#: setup.c:562
|
||||
msgid "bits"
|
||||
msgstr "bitteinä"
|
||||
|
||||
#: setup.c:563
|
||||
msgid "kbits"
|
||||
msgstr "kilobitteinä"
|
||||
|
||||
#: setup.c:581
|
||||
#: setup.c:590
|
||||
msgid "TS buffer size [MB]"
|
||||
msgstr "TS-puskurin koko [MB]"
|
||||
|
||||
#: setup.c:582
|
||||
#: setup.c:591
|
||||
msgid "TS buffer prefill ratio [%]"
|
||||
msgstr "TS-puskurin esitäyttöaste [%]"
|
||||
|
||||
#: setup.c:583
|
||||
msgid "Show statistics in"
|
||||
msgstr "Näytä tilastotiedot"
|
||||
#: setup.c:592
|
||||
msgid "Use bytes in statistics"
|
||||
msgstr "Käytä tavuja tilastotiedoissa"
|
||||
|
||||
#: setup.c:584
|
||||
#: setup.c:593
|
||||
msgid "Use section filtering"
|
||||
msgstr "Käytä sektioiden suodatusta"
|
||||
|
||||
#: setup.c:586
|
||||
#: setup.c:595
|
||||
msgid "Scan Sid automatically"
|
||||
msgstr "Etsi palvelu-ID automaattisesti"
|
||||
|
||||
#: setup.c:587
|
||||
#: setup.c:596
|
||||
msgid "Disable filters"
|
||||
msgstr "Poista suodattimia käytöstä"
|
||||
|
||||
#. TRANSLATORS: note the singular!
|
||||
#: setup.c:590
|
||||
#: setup.c:599
|
||||
msgid "Disable filter"
|
||||
msgstr "Poista suodatin käytöstä"
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: sectionfilter.h,v 1.6 2007/10/05 21:56:02 ajhseppa Exp $
|
||||
* $Id: sectionfilter.h,v 1.7 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_SECTIONFILTER_H
|
||||
@ -98,6 +98,7 @@ public:
|
||||
void ProcessData(const uint8_t* buf);
|
||||
|
||||
int GetReadDesc();
|
||||
uint16_t GetPid() { return pid; }
|
||||
};
|
||||
|
||||
#endif // __IPTV_SECTIONFILTER_H
|
||||
|
37
setup.c
37
setup.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.c,v 1.26 2007/10/07 20:08:44 rahrenbe Exp $
|
||||
* $Id: setup.c,v 1.27 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -479,6 +479,7 @@ private:
|
||||
};
|
||||
cString text;
|
||||
cTimeMs timeout;
|
||||
unsigned int page;
|
||||
void UpdateInfo();
|
||||
|
||||
public:
|
||||
@ -489,9 +490,10 @@ public:
|
||||
};
|
||||
|
||||
cIptvMenuInfo::cIptvMenuInfo()
|
||||
:cOsdMenu(tr("IPTV Information")), text(""), timeout(INFO_TIMEOUT_MS)
|
||||
:cOsdMenu(tr("IPTV Information")), text(""), timeout(INFO_TIMEOUT_MS), page(IPTV_DEVICE_INFO_GENERAL)
|
||||
{
|
||||
UpdateInfo();
|
||||
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Buffers"));
|
||||
}
|
||||
|
||||
cIptvMenuInfo::~cIptvMenuInfo()
|
||||
@ -502,7 +504,7 @@ void cIptvMenuInfo::UpdateInfo()
|
||||
{
|
||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||
if (device)
|
||||
text = device->GetInformation();
|
||||
text = device->GetInformation(page);
|
||||
else
|
||||
text = cString(tr("IPTV information not available!"));
|
||||
Display();
|
||||
@ -539,9 +541,22 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
|
||||
if (state == osUnknown) {
|
||||
switch (Key) {
|
||||
case kOk: return osBack;
|
||||
case kRed: page = IPTV_DEVICE_INFO_GENERAL;
|
||||
UpdateInfo();
|
||||
break;
|
||||
case kGreen: page = IPTV_DEVICE_INFO_PIDS;
|
||||
UpdateInfo();
|
||||
break;
|
||||
case kYellow: page = IPTV_DEVICE_INFO_FILTERS;
|
||||
UpdateInfo();
|
||||
break;
|
||||
case kBlue: page = IPTV_DEVICE_INFO_BUFFERS;
|
||||
UpdateInfo();
|
||||
break;
|
||||
default: if (timeout.TimedOut())
|
||||
UpdateInfo();
|
||||
return osContinue;
|
||||
state = osContinue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
@ -554,13 +569,7 @@ cIptvPluginSetup::cIptvPluginSetup()
|
||||
debug("cIptvPluginSetup::cIptvPluginSetup()\n");
|
||||
tsBufferSize = IptvConfig.GetTsBufferSize();
|
||||
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
|
||||
statsUnit = IptvConfig.GetStatsUnit();
|
||||
if (statsUnit > IPTV_STATS_UNIT_COUNT)
|
||||
statsUnit = IPTV_STATS_UNIT_IN_BYTES;
|
||||
statsUnitNames[IPTV_STATS_UNIT_IN_BYTES] = tr("bytes");
|
||||
statsUnitNames[IPTV_STATS_UNIT_IN_KBYTES] = tr("kbytes");
|
||||
statsUnitNames[IPTV_STATS_UNIT_IN_BITS] = tr("bits");
|
||||
statsUnitNames[IPTV_STATS_UNIT_IN_KBITS] = tr("kbits");
|
||||
useBytes = IptvConfig.GetUseBytes();
|
||||
sectionFiltering = IptvConfig.GetSectionFiltering();
|
||||
sidScanning = IptvConfig.GetSidScanning();
|
||||
numDisabledFilters = IptvConfig.GetDisabledFiltersCount();
|
||||
@ -580,7 +589,7 @@ void cIptvPluginSetup::Setup(void)
|
||||
Clear();
|
||||
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 2, 16));
|
||||
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
|
||||
Add(new cMenuEditStraItem(tr("Show statistics in"), &statsUnit, IPTV_STATS_UNIT_COUNT, statsUnitNames));
|
||||
Add(new cMenuEditBoolItem(tr("Use bytes in statistics"), &useBytes));
|
||||
Add(new cMenuEditBoolItem(tr("Use section filtering"), §ionFiltering));
|
||||
if (sectionFiltering) {
|
||||
Add(new cMenuEditBoolItem(tr("Scan Sid automatically"), &sidScanning));
|
||||
@ -654,14 +663,14 @@ void cIptvPluginSetup::Store(void)
|
||||
// Store values into setup.conf
|
||||
SetupStore("TsBufferSize", tsBufferSize);
|
||||
SetupStore("TsBufferPrefill", tsBufferPrefill);
|
||||
SetupStore("StatsUnit", statsUnit);
|
||||
SetupStore("UseBytes", useBytes);
|
||||
SetupStore("SectionFiltering", sectionFiltering);
|
||||
SetupStore("SidScanning", sidScanning);
|
||||
StoreFilters("DisabledFilters", disabledFilterIndexes);
|
||||
// Update global config
|
||||
IptvConfig.SetTsBufferSize(tsBufferSize);
|
||||
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
|
||||
IptvConfig.SetStatsUnit(statsUnit);
|
||||
IptvConfig.SetUseBytes(useBytes);
|
||||
IptvConfig.SetSectionFiltering(sectionFiltering);
|
||||
IptvConfig.SetSidScanning(sidScanning);
|
||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
|
||||
|
5
setup.h
5
setup.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.h,v 1.13 2007/10/07 20:08:45 rahrenbe Exp $
|
||||
* $Id: setup.h,v 1.14 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_SETUP_H
|
||||
@ -17,10 +17,9 @@ class cIptvPluginSetup : public cMenuSetupPage
|
||||
private:
|
||||
int tsBufferSize;
|
||||
int tsBufferPrefill;
|
||||
int useBytes;
|
||||
int sectionFiltering;
|
||||
int sidScanning;
|
||||
int statsUnit;
|
||||
const char *statsUnitNames[IPTV_STATS_UNIT_COUNT];
|
||||
int numDisabledFilters;
|
||||
int disabledFilterIndexes[SECTION_FILTER_TABLE_SIZE];
|
||||
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
|
||||
|
114
statistics.c
114
statistics.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statistics.c,v 1.14 2007/10/08 18:31:44 ajhseppa Exp $
|
||||
* $Id: statistics.c,v 1.15 2007/10/08 23:51:58 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
@ -30,35 +30,27 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
|
||||
cString cIptvSectionStatistics::GetStatistic()
|
||||
{
|
||||
//debug("cIptvSectionStatistics::GetStatistic()\n");
|
||||
mutex.Lock();
|
||||
long tmpNumberOfCalls = numberOfCalls;
|
||||
long tmpFilteredData = filteredData;
|
||||
filteredData = numberOfCalls = 0;
|
||||
uint64_t elapsed = timer.Elapsed();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
long bitrate = 0;
|
||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
||||
timer.Set();
|
||||
mutex.Unlock();
|
||||
float divider = elapsed / 1000;
|
||||
char unit[] = { ' ', 'B', '/', 's', '\0' };
|
||||
if (IptvConfig.IsStatsUnitInKilos()) {
|
||||
divider *= KILOBYTE(1);
|
||||
unit[0] = 'k';
|
||||
}
|
||||
if (!IptvConfig.IsStatsUnitInBytes()) {
|
||||
divider /= sizeof(unsigned short) * 8;
|
||||
unit[1] = 'b';
|
||||
}
|
||||
cString info = cString::sprintf("%4ld (%4ld %s)", tmpNumberOfCalls, divider ?
|
||||
(long)(tmpFilteredData / divider) : 0L, unit);
|
||||
if (elapsed)
|
||||
bitrate = (long)(1000.0 * filteredData / elapsed / KILOBYTE(1));
|
||||
if (!IptvConfig.GetUseBytes())
|
||||
bitrate *= 8;
|
||||
// no trailing linefeed here!
|
||||
cString info = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCalls, bitrate,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||
filteredData = numberOfCalls = 0;
|
||||
return info;
|
||||
}
|
||||
|
||||
void cIptvSectionStatistics::AddStatistic(long Bytes, long Calls)
|
||||
{
|
||||
//debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
|
||||
mutex.Lock();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
filteredData += Bytes;
|
||||
numberOfCalls += Calls;
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
// --- cIptvDeviceStatistics -------------------------------------------------
|
||||
@ -81,36 +73,28 @@ cIptvDeviceStatistics::~cIptvDeviceStatistics()
|
||||
cString cIptvDeviceStatistics::GetStatistic()
|
||||
{
|
||||
//debug("cIptvDeviceStatistics::GetStatistic()\n");
|
||||
mutex.Lock();
|
||||
long tmpDataBytes = dataBytes;
|
||||
dataBytes = 0;
|
||||
pidStruct tmpMostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
|
||||
memcpy(&tmpMostActivePids, &mostActivePids, sizeof(tmpMostActivePids));
|
||||
memset(&mostActivePids, '\0', sizeof(mostActivePids));
|
||||
uint64_t elapsed = timer.Elapsed();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
long bitrate = 0L;
|
||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
||||
timer.Set();
|
||||
mutex.Unlock();
|
||||
float divider = elapsed / 1000;
|
||||
char unit[] = { ' ', 'B', '/', 's', '\0' };
|
||||
if (IptvConfig.IsStatsUnitInKilos()) {
|
||||
divider *= KILOBYTE(1);
|
||||
unit[0] = 'k';
|
||||
}
|
||||
if (!IptvConfig.IsStatsUnitInBytes()) {
|
||||
divider /= sizeof(unsigned short) * 8;
|
||||
unit[1] = 'b';
|
||||
}
|
||||
cString info = cString::sprintf("Bitrate: %ld %s\n", divider ?
|
||||
(long)(tmpDataBytes / divider) : 0L, unit);
|
||||
if (elapsed)
|
||||
bitrate = (long)(1000.0 * dataBytes / elapsed / KILOBYTE(1));
|
||||
if (!IptvConfig.GetUseBytes())
|
||||
bitrate *= 8;
|
||||
cString info = cString::sprintf("Bitrate: %ld k%s/s\n", bitrate,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
|
||||
if (tmpMostActivePids[i].pid)
|
||||
info = cString::sprintf("%sPid %d: %4d (%4ld %s)%c", *info, i,
|
||||
tmpMostActivePids[i].pid,
|
||||
(long)(tmpMostActivePids[i].DataAmount / divider),
|
||||
unit, ((i + 1) % 2) ? '\t' : '\n');
|
||||
if (mostActivePids[i].pid) {
|
||||
bitrate = (long)(1000.0 * mostActivePids[i].DataAmount / elapsed / KILOBYTE(1));
|
||||
if (!IptvConfig.GetUseBytes())
|
||||
bitrate *= 8;
|
||||
info = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *info, i,
|
||||
mostActivePids[i].pid, bitrate,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||
}
|
||||
if (!endswith(*info, "\n"))
|
||||
info = cString::sprintf("%s%c", *info, '\n');
|
||||
}
|
||||
dataBytes = 0;
|
||||
memset(&mostActivePids, '\0', sizeof(mostActivePids));
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -129,7 +113,7 @@ int cIptvDeviceStatistics::SortPids(const void* data1, const void* data2)
|
||||
void cIptvDeviceStatistics::AddStatistic(long Bytes, u_short pid, long payload)
|
||||
{
|
||||
//debug("cIptvDeviceStatistics::AddStatistic(Bytes=%ld, pid=%ld, payload=%ld)\n", Bytes, pid, payload);
|
||||
mutex.Lock();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
dataBytes += Bytes;
|
||||
const int numberOfElements = sizeof(mostActivePids) / sizeof(pidStruct);
|
||||
// If our statistic already is in the array, update it and quit
|
||||
@ -138,7 +122,6 @@ void cIptvDeviceStatistics::AddStatistic(long Bytes, u_short pid, long payload)
|
||||
mostActivePids[i].DataAmount += payload;
|
||||
// Now re-sort the array and quit
|
||||
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
|
||||
mutex.Unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -150,7 +133,6 @@ void cIptvDeviceStatistics::AddStatistic(long Bytes, u_short pid, long payload)
|
||||
// Re-sort
|
||||
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
|
||||
}
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
// --- cIptvStreamerStatistics -----------------------------------------------
|
||||
@ -172,30 +154,22 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
||||
cString cIptvStreamerStatistics::GetStatistic()
|
||||
{
|
||||
//debug("cIptvStreamerStatistics::GetStatistic()\n");
|
||||
mutex.Lock();
|
||||
long tmpDataBytes = dataBytes;
|
||||
dataBytes = 0;
|
||||
uint64_t elapsed = timer.Elapsed();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
long bitrate = 0;
|
||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
||||
timer.Set();
|
||||
mutex.Unlock();
|
||||
float divider = elapsed / 1000;
|
||||
char unit[] = { ' ', 'B', '/', 's', '\0' };
|
||||
if (IptvConfig.IsStatsUnitInKilos()) {
|
||||
divider *= KILOBYTE(1);
|
||||
unit[0] = 'k';
|
||||
}
|
||||
if (!IptvConfig.IsStatsUnitInBytes()) {
|
||||
divider /= sizeof(unsigned short) * 8;
|
||||
unit[1] = 'b';
|
||||
}
|
||||
return cString::sprintf("Streamer: %ld %s", divider ?
|
||||
(long)(tmpDataBytes / divider) : 0L, unit);
|
||||
if (elapsed)
|
||||
bitrate = (long)(1000.0 * dataBytes / elapsed / KILOBYTE(1));
|
||||
if (!IptvConfig.GetUseBytes())
|
||||
bitrate *= 8;
|
||||
cString info = cString::sprintf("Streamer: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||
dataBytes = 0;
|
||||
return info;
|
||||
}
|
||||
|
||||
void cIptvStreamerStatistics::AddStatistic(long Bytes)
|
||||
{
|
||||
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
|
||||
mutex.Lock();
|
||||
cMutexLock MutexLock(&mutex);
|
||||
dataBytes += Bytes;
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user