From 18c2962cd93f2dae2f07ccbcbb1abaa1129df159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Date: Sat, 19 Jan 2008 21:08:02 +0000 Subject: [PATCH] Get rid of bad interface design in statistic collectors. --- HISTORY | 3 ++- device.c | 14 +++++++------- sectionfilter.c | 4 ++-- statisticif.h | 25 ------------------------- statistics.c | 18 +++++++++--------- statistics.h | 28 +++++++++++++--------------- streamer.c | 4 ++-- 7 files changed, 35 insertions(+), 61 deletions(-) delete mode 100644 statisticif.h diff --git a/HISTORY b/HISTORY index 6b81b8c..2954124 100644 --- a/HISTORY +++ b/HISTORY @@ -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. diff --git a/device.c b/device.c index 9418e29..7d0a687 100644 --- a/device.c +++ b/device.c @@ -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]) diff --git a/sectionfilter.c b/sectionfilter.c index 03acd11..784098d 100644 --- a/sectionfilter.c +++ b/sectionfilter.c @@ -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) diff --git a/statisticif.h b/statisticif.h deleted file mode 100644 index 3b5ca88..0000000 --- a/statisticif.h +++ /dev/null @@ -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 - -class cIptvStatisticIf { -public: - cIptvStatisticIf() {} - virtual ~cIptvStatisticIf() {} - virtual cString GetStatistic() = 0; - -private: - cIptvStatisticIf(const cIptvStatisticIf&); - cIptvStatisticIf& operator=(const cIptvStatisticIf&); -}; - -#endif // __IPTV_STATISTICIF_H diff --git a/statistics.c b/statistics.c index 6dd0f33..b32bcb2 100644 --- a/statistics.c +++ b/statistics.c @@ -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 @@ -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); diff --git a/statistics.h b/statistics.h index 1495047..5dcc72b 100644 --- a/statistics.h +++ b/statistics.h @@ -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 -#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; diff --git a/streamer.c b/streamer.c index 99ba5e5..1d5f845 100644 --- a/streamer.c +++ b/streamer.c @@ -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 @@ -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);