1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Get rid of bad interface design in statistic collectors.

This commit is contained in:
Antti Seppälä 2008-01-19 21:08:02 +00:00
parent 1e2d0955de
commit 18c2962cd9
7 changed files with 35 additions and 61 deletions

View File

@ -33,7 +33,8 @@ VDR Plugin 'iptv' Revision History
2008-01-20: Version 0.0.6
- Fixed lint warnings.
- Fixed some lint warnings.
- Added Italian translation (Thanks to Gringo).
- Added '-Wno-parentheses' to the compiler options.
- Mapped 'kInfo' as help key in setup menu.
- Refactored statistic collecting code.

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.77 2008/01/04 23:36:37 ajhseppa Exp $
* $Id: device.c,v 1.78 2008/01/19 21:08:02 ajhseppa Exp $
*/
#include "config.h"
@ -102,15 +102,15 @@ cString cIptvDevice::GetGeneralInformation(void)
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
deviceIndex, CardIndex(),
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
*cIptvBufferStatistics::GetStatistic(),
pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
*GetBufferStatistic(),
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
}
cString cIptvDevice::GetPidsInformation(void)
{
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
return cIptvPidStatistics::GetStatistic();
return GetPidStatistic();
}
cString cIptvDevice::GetFiltersInformation(void)
@ -122,7 +122,7 @@ cString cIptvDevice::GetFiltersInformation(void)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i]) {
info = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *info, i,
*secfilters[i]->GetStatistic(), secfilters[i]->GetPid(),
*secfilters[i]->GetSectionStatistic(), secfilters[i]->GetPid(),
id_pid(secfilters[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
@ -359,7 +359,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
tsBuffer->Del(TS_SIZE);
isPacketDelivered = false;
// Update buffer statistics
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
AddBufferStatistic(TS_SIZE, tsBuffer->Available());
}
uchar *p = tsBuffer->Get(Count);
if (p && Count >= TS_SIZE) {
@ -377,7 +377,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
isPacketDelivered = true;
Data = p;
// Update pid statistics
cIptvPidStatistics::AddStatistic(ts_pid(p), payload(p));
AddPidStatistic(ts_pid(p), payload(p));
// Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i])

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.c,v 1.16 2008/01/04 23:36:37 ajhseppa Exp $
* $Id: sectionfilter.c,v 1.17 2008/01/19 21:08:02 ajhseppa Exp $
*/
#include "sectionfilter.h"
@ -106,7 +106,7 @@ int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t b
retval = write(fifoDescriptor, buffer1, buffer1_len);
ERROR_IF(retval < 0, "write()");
// Update statistics
AddStatistic(retval, 1);
AddSectionStatistic(retval, 1);
}
#ifdef DEBUG_PRINTF
else if (retval)

View File

@ -1,25 +0,0 @@
/*
* statisticif.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statisticif.h,v 1.4 2007/10/07 19:06:33 ajhseppa Exp $
*/
#ifndef __IPTV_STATISTICIF_H
#define __IPTV_STATISTICIF_H
#include <vdr/tools.h>
class cIptvStatisticIf {
public:
cIptvStatisticIf() {}
virtual ~cIptvStatisticIf() {}
virtual cString GetStatistic() = 0;
private:
cIptvStatisticIf(const cIptvStatisticIf&);
cIptvStatisticIf& operator=(const cIptvStatisticIf&);
};
#endif // __IPTV_STATISTICIF_H

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statistics.c,v 1.21 2008/01/04 23:36:37 ajhseppa Exp $
* $Id: statistics.c,v 1.22 2008/01/19 21:08:03 ajhseppa Exp $
*/
#include <limits.h>
@ -27,7 +27,7 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
}
cString cIptvSectionStatistics::GetStatistic()
cString cIptvSectionStatistics::GetSectionStatistic()
{
//debug("cIptvSectionStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@ -43,7 +43,7 @@ cString cIptvSectionStatistics::GetStatistic()
return info;
}
void cIptvSectionStatistics::AddStatistic(long Bytes, long Calls)
void cIptvSectionStatistics::AddSectionStatistic(long Bytes, long Calls)
{
//debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
cMutexLock MutexLock(&mutex);
@ -67,7 +67,7 @@ cIptvPidStatistics::~cIptvPidStatistics()
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
}
cString cIptvPidStatistics::GetStatistic()
cString cIptvPidStatistics::GetPidStatistic()
{
//debug("cIptvPidStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@ -100,7 +100,7 @@ int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
return 0;
}
void cIptvPidStatistics::AddStatistic(u_short Pid, long Payload)
void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload)
{
//debug("cIptvPidStatistics::AddStatistic(pid=%ld, payload=%ld)\n", Pid, Payload);
cMutexLock MutexLock(&mutex);
@ -140,7 +140,7 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
}
cString cIptvStreamerStatistics::GetStatistic()
cString cIptvStreamerStatistics::GetStreamerStatistic()
{
//debug("cIptvStreamerStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@ -154,7 +154,7 @@ cString cIptvStreamerStatistics::GetStatistic()
return info;
}
void cIptvStreamerStatistics::AddStatistic(long Bytes)
void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
{
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
cMutexLock MutexLock(&mutex);
@ -177,7 +177,7 @@ cIptvBufferStatistics::~cIptvBufferStatistics()
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
}
cString cIptvBufferStatistics::GetStatistic()
cString cIptvBufferStatistics::GetBufferStatistic()
{
//debug("cIptvBufferStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@ -201,7 +201,7 @@ cString cIptvBufferStatistics::GetStatistic()
return info;
}
void cIptvBufferStatistics::AddStatistic(long Bytes, long Used)
void cIptvBufferStatistics::AddBufferStatistic(long Bytes, long Used)
{
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
cMutexLock MutexLock(&mutex);

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statistics.h,v 1.10 2007/10/11 23:06:49 rahrenbe Exp $
* $Id: statistics.h,v 1.11 2008/01/19 21:08:03 ajhseppa Exp $
*/
#ifndef __IPTV_STATISTICS_H
@ -11,17 +11,15 @@
#include <vdr/thread.h>
#include "statisticif.h"
// Section statistics
class cIptvSectionStatistics : public cIptvStatisticIf {
class cIptvSectionStatistics {
public:
cIptvSectionStatistics();
virtual ~cIptvSectionStatistics();
cString GetStatistic();
cString GetSectionStatistic();
protected:
void AddStatistic(long Bytes, long Calls);
void AddSectionStatistic(long Bytes, long Calls);
private:
long filteredData;
@ -31,14 +29,14 @@ private:
};
// Pid statistics
class cIptvPidStatistics : public cIptvStatisticIf {
class cIptvPidStatistics {
public:
cIptvPidStatistics();
virtual ~cIptvPidStatistics();
cString GetStatistic();
cString GetPidStatistic();
protected:
void AddStatistic(u_short Pid, long Payload);
void AddPidStatistic(u_short Pid, long Payload);
private:
struct pidStruct {
@ -54,14 +52,14 @@ private:
};
// Streamer statistics
class cIptvStreamerStatistics : public cIptvStatisticIf {
class cIptvStreamerStatistics {
public:
cIptvStreamerStatistics();
virtual ~cIptvStreamerStatistics();
cString GetStatistic();
cString GetStreamerStatistic();
protected:
void AddStatistic(long Bytes);
void AddStreamerStatistic(long Bytes);
private:
long dataBytes;
@ -70,14 +68,14 @@ private:
};
// Buffer statistics
class cIptvBufferStatistics : public cIptvStatisticIf {
class cIptvBufferStatistics {
public:
cIptvBufferStatistics();
virtual ~cIptvBufferStatistics();
cString GetStatistic();
cString GetBufferStatistic();
protected:
void AddStatistic(long Bytes, long Used);
void AddBufferStatistic(long Bytes, long Used);
private:
long dataBytes;

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.c,v 1.28 2008/01/04 23:36:37 ajhseppa Exp $
* $Id: streamer.c,v 1.29 2008/01/19 21:08:03 ajhseppa Exp $
*/
#include <vdr/thread.h>
@ -38,7 +38,7 @@ void cIptvStreamer::Action(void)
mutex->Lock();
int length = protocol->Read(&buffer);
if (length >= 0) {
AddStatistic(length);
AddStreamerStatistic(length);
int p = ringBuffer->Put(buffer, length);
if (p != length && Running())
ringBuffer->ReportOverflow(length - p);