mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Statistic improvements. Supports unit calculations and appending of pre-specified unit string to the result.
This commit is contained in:
parent
9ee8c7f4e7
commit
953da1fc50
10
device.c
10
device.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.54 2007/10/06 22:25:49 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.55 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -96,11 +96,11 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetInformation(void)
|
||||
cString cIptvDevice::GetInformation(uint64_t elapsed, const char* unit, const int unitdivider)
|
||||
{
|
||||
return cString::sprintf("Device:\n%s\nStreamer:\n%s\nSection Filter 0:\n%s", *GetStatistic(),
|
||||
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
|
||||
secfilters[0] ? *secfilters[0]->GetStatistic() : "");
|
||||
return cString::sprintf("Device:\n%s\nStreamer:\n%s\nSection Filter 0:\n%s", *GetStatistic(elapsed, unit, unitdivider),
|
||||
pIptvStreamer ? *pIptvStreamer->GetStatistic(elapsed, unit, unitdivider) : "",
|
||||
secfilters[0] ? *secfilters[0]->GetStatistic(elapsed, unit, unitdivider) : "");
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol)
|
||||
|
4
device.h
4
device.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.h,v 1.25 2007/10/06 20:57:53 rahrenbe Exp $
|
||||
* $Id: device.h,v 1.26 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_DEVICE_H
|
||||
@ -48,7 +48,7 @@ private:
|
||||
public:
|
||||
cIptvDevice(unsigned int DeviceIndex);
|
||||
virtual ~cIptvDevice();
|
||||
cString GetInformation(void);
|
||||
cString GetInformation(uint64_t, const char* unit, const int unitdivider);
|
||||
|
||||
// for channel parsing & buffering
|
||||
private:
|
||||
|
4
iptv.c
4
iptv.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: iptv.c,v 1.11 2007/10/06 20:57:53 rahrenbe Exp $
|
||||
* $Id: iptv.c,v 1.12 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
@ -210,7 +210,7 @@ cString cPluginIptv::SVDRPCommand(const char *Command, const char *Option, int &
|
||||
if (strcasecmp(Command, "INFO") == 0) {
|
||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||
if (device)
|
||||
return device->GetInformation();
|
||||
return device->GetInformation(0, "", 0);
|
||||
else {
|
||||
ReplyCode = 550; // Requested action not taken
|
||||
return cString("IPTV information not available!");
|
||||
|
15
setup.c
15
setup.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.c,v 1.22 2007/10/06 22:15:02 rahrenbe Exp $
|
||||
* $Id: setup.c,v 1.23 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -479,7 +479,7 @@ private:
|
||||
};
|
||||
cString text;
|
||||
cTimeMs timeout;
|
||||
void UpdateInfo();
|
||||
void UpdateInfo(uint64_t elapsed, const char* unit, const int unitdivider);
|
||||
|
||||
public:
|
||||
cIptvMenuInfo();
|
||||
@ -491,18 +491,18 @@ public:
|
||||
cIptvMenuInfo::cIptvMenuInfo()
|
||||
:cOsdMenu(tr("IPTV Information")), text(""), timeout(INFO_TIMEOUT)
|
||||
{
|
||||
UpdateInfo();
|
||||
UpdateInfo(0, "kbytes", 1024);
|
||||
}
|
||||
|
||||
cIptvMenuInfo::~cIptvMenuInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void cIptvMenuInfo::UpdateInfo(void)
|
||||
void cIptvMenuInfo::UpdateInfo(uint64_t elapsed, const char* unit, const int unitdivider)
|
||||
{
|
||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||
if (device)
|
||||
text = device->GetInformation();
|
||||
text = device->GetInformation(elapsed, unit, unitdivider);
|
||||
else
|
||||
text = cString(tr("IPTV information not available!"));
|
||||
Display();
|
||||
@ -539,9 +539,10 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
|
||||
if (state == osUnknown) {
|
||||
switch (Key) {
|
||||
case kOk: return osBack;
|
||||
default: if (timeout.TimedOut())
|
||||
UpdateInfo();
|
||||
default: if (timeout.TimedOut()) {
|
||||
UpdateInfo(INFO_TIMEOUT, "kb/s", 1024);
|
||||
return osContinue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statisticif.h,v 1.2 2007/10/06 22:15:02 rahrenbe Exp $
|
||||
* $Id: statisticif.h,v 1.3 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_STATISTICIF_H
|
||||
@ -15,7 +15,7 @@ class cIptvStatisticIf {
|
||||
public:
|
||||
cIptvStatisticIf() {}
|
||||
virtual ~cIptvStatisticIf() {}
|
||||
virtual cString GetStatistic() = 0;
|
||||
virtual cString GetStatistic(uint64_t elapsed, const char* unit, const int unitdivider) = 0;
|
||||
|
||||
private:
|
||||
cIptvStatisticIf(const cIptvStatisticIf&);
|
||||
|
43
statistics.c
43
statistics.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statistics.c,v 1.5 2007/10/07 08:46:34 ajhseppa Exp $
|
||||
* $Id: statistics.c,v 1.6 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -22,13 +22,17 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
|
||||
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
|
||||
}
|
||||
|
||||
cString cIptvSectionStatistics::GetStatistic()
|
||||
cString cIptvSectionStatistics::GetStatistic(uint64_t elapsed, const char* unit, int unitdivider)
|
||||
{
|
||||
debug("cIptvSectionStatistics::GetStatistic()\n");
|
||||
// Prevent a divide-by-zero error
|
||||
elapsed ? : elapsed = 1;
|
||||
unitdivider ? : unitdivider = 1;
|
||||
long tmpFilteredData = filteredData;
|
||||
long tmpNumberOfCalls = numberOfCalls;
|
||||
float divider = unitdivider * elapsed / 1000;
|
||||
filteredData = numberOfCalls = 0;
|
||||
return cString::sprintf("Filtered data: %ld\nData packets passed: %ld\n", tmpFilteredData, tmpNumberOfCalls);
|
||||
return cString::sprintf("Filtered data: %ld %s\nData packets passed: %ld\n", (long)(tmpFilteredData / divider), unit, tmpNumberOfCalls);
|
||||
}
|
||||
|
||||
// --- cIptvDeviceStatistics -------------------------------------------------
|
||||
@ -46,19 +50,30 @@ cIptvDeviceStatistics::~cIptvDeviceStatistics()
|
||||
debug("cIptvDeviceStatistics::~cIptvDeviceStatistics()\n");
|
||||
}
|
||||
|
||||
cString cIptvDeviceStatistics::GetStatistic(void)
|
||||
cString cIptvDeviceStatistics::GetStatistic(uint64_t elapsed, const char* unit, int unitdivider)
|
||||
{
|
||||
debug("cIptvDeviceStatistics::GetStatistic()\n");
|
||||
pidStruct tmpMostActivePids[10];
|
||||
long tmpDataBytes = dataBytes;
|
||||
// Prevent a divide-by-zero error
|
||||
elapsed ? : elapsed = 1;
|
||||
unitdivider ? : unitdivider = 1;
|
||||
float divider = unitdivider * elapsed / 1000;
|
||||
dataBytes = 0;
|
||||
memcpy(&tmpMostActivePids, &mostActivePids, sizeof(tmpMostActivePids));
|
||||
memset(&mostActivePids, '\0', sizeof(mostActivePids));
|
||||
return cString::sprintf("Stream data bytes: %ld\n1. Active Pid: %d %ld\n2. Active Pid: %d %ld\n3. Active Pid: %d %ld\n",
|
||||
tmpDataBytes,
|
||||
tmpMostActivePids[0].pid, tmpMostActivePids[0].DataAmount,
|
||||
tmpMostActivePids[1].pid, tmpMostActivePids[1].DataAmount,
|
||||
tmpMostActivePids[2].pid, tmpMostActivePids[2].DataAmount);
|
||||
return cString::sprintf("Stream data bytes: %ld %s\n"
|
||||
" 1. Active Pid: %d %ld %s\n"
|
||||
" 2. Active Pid: %d %ld %s\n"
|
||||
" 3. Active Pid: %d %ld %s\n"
|
||||
" 4. Active Pid: %d %ld %s\n"
|
||||
" 5. Active Pid: %d %ld %s\n",
|
||||
(long)(tmpDataBytes / divider), unit,
|
||||
tmpMostActivePids[0].pid, (long)(tmpMostActivePids[0].DataAmount / divider), unit,
|
||||
tmpMostActivePids[1].pid, (long)(tmpMostActivePids[1].DataAmount / divider), unit,
|
||||
tmpMostActivePids[2].pid, (long)(tmpMostActivePids[2].DataAmount / divider), unit,
|
||||
tmpMostActivePids[3].pid, (long)(tmpMostActivePids[3].DataAmount / divider), unit,
|
||||
tmpMostActivePids[4].pid, (long)(tmpMostActivePids[4].DataAmount / divider), unit);
|
||||
}
|
||||
|
||||
int SortFunc(const void* data1, const void* data2)
|
||||
@ -110,10 +125,14 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
||||
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
|
||||
}
|
||||
|
||||
cString cIptvStreamerStatistics::GetStatistic(void)
|
||||
cString cIptvStreamerStatistics::GetStatistic(uint64_t elapsed, const char* unit, int unitdivider)
|
||||
{
|
||||
debug("cIptvStreamerStatistics::GetStatistic()\n");
|
||||
long tmpDataBytes = dataBytes;
|
||||
// Prevent a divide-by-zero error
|
||||
elapsed ? : elapsed = 1;
|
||||
unitdivider ? : unitdivider = 1;
|
||||
float divider = unitdivider * elapsed / 1000;
|
||||
long tmpDataBytes = (long)(dataBytes / divider);
|
||||
dataBytes = 0;
|
||||
return cString::sprintf("Stream data bytes: %ld\n", tmpDataBytes);
|
||||
return cString::sprintf("Stream data bytes: %ld %s\n", tmpDataBytes, unit);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statistics.h,v 1.2 2007/10/06 22:15:02 rahrenbe Exp $
|
||||
* $Id: statistics.h,v 1.3 2007/10/07 10:13:45 ajhseppa Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_STATISTICS_H
|
||||
@ -26,7 +26,7 @@ public:
|
||||
cIptvSectionStatistics();
|
||||
virtual ~cIptvSectionStatistics();
|
||||
|
||||
cString GetStatistic();
|
||||
cString GetStatistic(uint64_t elapsed, const char* unit, int unitdivider);
|
||||
};
|
||||
|
||||
// Device statistics
|
||||
@ -38,7 +38,7 @@ public:
|
||||
cIptvDeviceStatistics();
|
||||
virtual ~cIptvDeviceStatistics();
|
||||
|
||||
cString GetStatistic();
|
||||
cString GetStatistic(uint64_t elapsed, const char* unit, int unitdivider);
|
||||
|
||||
protected:
|
||||
void UpdateActivePids(u_short pid, long payload);
|
||||
@ -56,7 +56,7 @@ public:
|
||||
cIptvStreamerStatistics();
|
||||
virtual ~cIptvStreamerStatistics();
|
||||
|
||||
cString GetStatistic();
|
||||
cString GetStatistic(uint64_t elapsed, const char* unit, int unitdivider);
|
||||
};
|
||||
|
||||
#endif // __IPTV_STATISTICS_H
|
||||
|
Loading…
Reference in New Issue
Block a user