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:
parent
1e2d0955de
commit
18c2962cd9
3
HISTORY
3
HISTORY
@ -33,7 +33,8 @@ VDR Plugin 'iptv' Revision History
|
|||||||
|
|
||||||
2008-01-20: Version 0.0.6
|
2008-01-20: Version 0.0.6
|
||||||
|
|
||||||
- Fixed lint warnings.
|
- Fixed some lint warnings.
|
||||||
- Added Italian translation (Thanks to Gringo).
|
- Added Italian translation (Thanks to Gringo).
|
||||||
- Added '-Wno-parentheses' to the compiler options.
|
- Added '-Wno-parentheses' to the compiler options.
|
||||||
- Mapped 'kInfo' as help key in setup menu.
|
- Mapped 'kInfo' as help key in setup menu.
|
||||||
|
- Refactored statistic collecting code.
|
||||||
|
14
device.c
14
device.c
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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"
|
#include "config.h"
|
||||||
@ -102,15 +102,15 @@ cString cIptvDevice::GetGeneralInformation(void)
|
|||||||
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
|
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
|
||||||
deviceIndex, CardIndex(),
|
deviceIndex, CardIndex(),
|
||||||
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
|
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
|
||||||
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
|
pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
|
||||||
*cIptvBufferStatistics::GetStatistic(),
|
*GetBufferStatistic(),
|
||||||
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
|
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetPidsInformation(void)
|
cString cIptvDevice::GetPidsInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
|
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
|
||||||
return cIptvPidStatistics::GetStatistic();
|
return GetPidStatistic();
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetFiltersInformation(void)
|
cString cIptvDevice::GetFiltersInformation(void)
|
||||||
@ -122,7 +122,7 @@ cString cIptvDevice::GetFiltersInformation(void)
|
|||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (secfilters[i]) {
|
if (secfilters[i]) {
|
||||||
info = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *info, 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()));
|
id_pid(secfilters[i]->GetPid()));
|
||||||
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
|
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
|
||||||
break;
|
break;
|
||||||
@ -359,7 +359,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
|||||||
tsBuffer->Del(TS_SIZE);
|
tsBuffer->Del(TS_SIZE);
|
||||||
isPacketDelivered = false;
|
isPacketDelivered = false;
|
||||||
// Update buffer statistics
|
// Update buffer statistics
|
||||||
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
|
AddBufferStatistic(TS_SIZE, tsBuffer->Available());
|
||||||
}
|
}
|
||||||
uchar *p = tsBuffer->Get(Count);
|
uchar *p = tsBuffer->Get(Count);
|
||||||
if (p && Count >= TS_SIZE) {
|
if (p && Count >= TS_SIZE) {
|
||||||
@ -377,7 +377,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
|||||||
isPacketDelivered = true;
|
isPacketDelivered = true;
|
||||||
Data = p;
|
Data = p;
|
||||||
// Update pid statistics
|
// Update pid statistics
|
||||||
cIptvPidStatistics::AddStatistic(ts_pid(p), payload(p));
|
AddPidStatistic(ts_pid(p), payload(p));
|
||||||
// Run the data through all filters
|
// Run the data through all filters
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (secfilters[i])
|
if (secfilters[i])
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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"
|
#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);
|
retval = write(fifoDescriptor, buffer1, buffer1_len);
|
||||||
ERROR_IF(retval < 0, "write()");
|
ERROR_IF(retval < 0, "write()");
|
||||||
// Update statistics
|
// Update statistics
|
||||||
AddStatistic(retval, 1);
|
AddSectionStatistic(retval, 1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PRINTF
|
#ifdef DEBUG_PRINTF
|
||||||
else if (retval)
|
else if (retval)
|
||||||
|
@ -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
|
|
18
statistics.c
18
statistics.c
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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>
|
#include <limits.h>
|
||||||
@ -27,7 +27,7 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
|
|||||||
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
|
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvSectionStatistics::GetStatistic()
|
cString cIptvSectionStatistics::GetSectionStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::GetStatistic()\n");
|
//debug("cIptvSectionStatistics::GetStatistic()\n");
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -43,7 +43,7 @@ cString cIptvSectionStatistics::GetStatistic()
|
|||||||
return info;
|
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);
|
//debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -67,7 +67,7 @@ cIptvPidStatistics::~cIptvPidStatistics()
|
|||||||
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
|
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvPidStatistics::GetStatistic()
|
cString cIptvPidStatistics::GetPidStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::GetStatistic()\n");
|
//debug("cIptvPidStatistics::GetStatistic()\n");
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -100,7 +100,7 @@ int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
|
|||||||
return 0;
|
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);
|
//debug("cIptvPidStatistics::AddStatistic(pid=%ld, payload=%ld)\n", Pid, Payload);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -140,7 +140,7 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
|||||||
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
|
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvStreamerStatistics::GetStatistic()
|
cString cIptvStreamerStatistics::GetStreamerStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::GetStatistic()\n");
|
//debug("cIptvStreamerStatistics::GetStatistic()\n");
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -154,7 +154,7 @@ cString cIptvStreamerStatistics::GetStatistic()
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvStreamerStatistics::AddStatistic(long Bytes)
|
void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
|
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -177,7 +177,7 @@ cIptvBufferStatistics::~cIptvBufferStatistics()
|
|||||||
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
|
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvBufferStatistics::GetStatistic()
|
cString cIptvBufferStatistics::GetBufferStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvBufferStatistics::GetStatistic()\n");
|
//debug("cIptvBufferStatistics::GetStatistic()\n");
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
@ -201,7 +201,7 @@ cString cIptvBufferStatistics::GetStatistic()
|
|||||||
return info;
|
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);
|
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
|
28
statistics.h
28
statistics.h
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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
|
#ifndef __IPTV_STATISTICS_H
|
||||||
@ -11,17 +11,15 @@
|
|||||||
|
|
||||||
#include <vdr/thread.h>
|
#include <vdr/thread.h>
|
||||||
|
|
||||||
#include "statisticif.h"
|
|
||||||
|
|
||||||
// Section statistics
|
// Section statistics
|
||||||
class cIptvSectionStatistics : public cIptvStatisticIf {
|
class cIptvSectionStatistics {
|
||||||
public:
|
public:
|
||||||
cIptvSectionStatistics();
|
cIptvSectionStatistics();
|
||||||
virtual ~cIptvSectionStatistics();
|
virtual ~cIptvSectionStatistics();
|
||||||
cString GetStatistic();
|
cString GetSectionStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddStatistic(long Bytes, long Calls);
|
void AddSectionStatistic(long Bytes, long Calls);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long filteredData;
|
long filteredData;
|
||||||
@ -31,14 +29,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Pid statistics
|
// Pid statistics
|
||||||
class cIptvPidStatistics : public cIptvStatisticIf {
|
class cIptvPidStatistics {
|
||||||
public:
|
public:
|
||||||
cIptvPidStatistics();
|
cIptvPidStatistics();
|
||||||
virtual ~cIptvPidStatistics();
|
virtual ~cIptvPidStatistics();
|
||||||
cString GetStatistic();
|
cString GetPidStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddStatistic(u_short Pid, long Payload);
|
void AddPidStatistic(u_short Pid, long Payload);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct pidStruct {
|
struct pidStruct {
|
||||||
@ -54,14 +52,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Streamer statistics
|
// Streamer statistics
|
||||||
class cIptvStreamerStatistics : public cIptvStatisticIf {
|
class cIptvStreamerStatistics {
|
||||||
public:
|
public:
|
||||||
cIptvStreamerStatistics();
|
cIptvStreamerStatistics();
|
||||||
virtual ~cIptvStreamerStatistics();
|
virtual ~cIptvStreamerStatistics();
|
||||||
cString GetStatistic();
|
cString GetStreamerStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddStatistic(long Bytes);
|
void AddStreamerStatistic(long Bytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long dataBytes;
|
long dataBytes;
|
||||||
@ -70,14 +68,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Buffer statistics
|
// Buffer statistics
|
||||||
class cIptvBufferStatistics : public cIptvStatisticIf {
|
class cIptvBufferStatistics {
|
||||||
public:
|
public:
|
||||||
cIptvBufferStatistics();
|
cIptvBufferStatistics();
|
||||||
virtual ~cIptvBufferStatistics();
|
virtual ~cIptvBufferStatistics();
|
||||||
cString GetStatistic();
|
cString GetBufferStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddStatistic(long Bytes, long Used);
|
void AddBufferStatistic(long Bytes, long Used);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long dataBytes;
|
long dataBytes;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* 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>
|
#include <vdr/thread.h>
|
||||||
@ -38,7 +38,7 @@ void cIptvStreamer::Action(void)
|
|||||||
mutex->Lock();
|
mutex->Lock();
|
||||||
int length = protocol->Read(&buffer);
|
int length = protocol->Read(&buffer);
|
||||||
if (length >= 0) {
|
if (length >= 0) {
|
||||||
AddStatistic(length);
|
AddStreamerStatistic(length);
|
||||||
int p = ringBuffer->Put(buffer, length);
|
int p = ringBuffer->Put(buffer, length);
|
||||||
if (p != length && Running())
|
if (p != length && Running())
|
||||||
ringBuffer->ReportOverflow(length - p);
|
ringBuffer->ReportOverflow(length - p);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user