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

Reformated info menu.

This commit is contained in:
Rolf Ahrenberg 2007-10-07 22:54:09 +00:00
parent a4ba034795
commit 382e575cb5
13 changed files with 85 additions and 52 deletions

View File

@ -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: common.h,v 1.5 2007/10/07 20:08:44 rahrenbe Exp $ * $Id: common.h,v 1.6 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_COMMON_H #ifndef __IPTV_COMMON_H
@ -22,13 +22,15 @@ uint8_t payload(const uint8_t *tsp);
#define error(x...) esyslog("IPTV: " x); #define error(x...) esyslog("IPTV: " x);
#endif #endif
#define IPTV_STATS_UNIT_IN_BYTES 0 #define IPTV_STATS_UNIT_IN_BYTES 0
#define IPTV_STATS_UNIT_IN_KBYTES 1 #define IPTV_STATS_UNIT_IN_KBYTES 1
#define IPTV_STATS_UNIT_IN_BITS 2 #define IPTV_STATS_UNIT_IN_BITS 2
#define IPTV_STATS_UNIT_IN_KBITS 3 #define IPTV_STATS_UNIT_IN_KBITS 3
#define IPTV_STATS_UNIT_COUNT 4 #define IPTV_STATS_UNIT_COUNT 4
#define SECTION_FILTER_TABLE_SIZE 7 #define IPTV_STATS_ACTIVE_PIDS_COUNT 10
#define SECTION_FILTER_TABLE_SIZE 7
typedef struct _section_filter_table_type { typedef struct _section_filter_table_type {
const char *description; const char *description;

View File

@ -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.56 2007/10/07 19:06:33 ajhseppa Exp $ * $Id: device.c,v 1.57 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -98,9 +98,20 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
cString cIptvDevice::GetInformation() cString cIptvDevice::GetInformation()
{ {
return cString::sprintf("Device:\n%s\nStreamer:\n%s\nSection Filter 0:\n%s", *GetStatistic(), // 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');
}
// generate information string
return cString::sprintf("IPTV device #%d (CardIndex: %d)\nSource: %s\n%s\n%s%s",
deviceIndex, CardIndex(), pIptvStreamer ?
*pIptvStreamer->GetInformation() : "", *GetStatistic(),
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "", pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
secfilters[0] ? *secfilters[0]->GetStatistic() : ""); *filterInfo);
} }
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol) cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol)

View File

@ -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: protocolfile.c,v 1.9 2007/09/29 18:15:31 rahrenbe Exp $ * $Id: protocolfile.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include <fcntl.h> #include <fcntl.h>
@ -119,3 +119,9 @@ bool cIptvProtocolFile::Set(const char* Address, const int Port)
} }
return true; return true;
} }
cString cIptvProtocolFile::GetInformation(void)
{
//debug("cIptvProtocolFile::GetInformation()");
return cString::sprintf("file://%s:%d", streamAddr, streamPort);
}

View File

@ -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: protocolfile.h,v 1.4 2007/09/28 16:44:59 rahrenbe Exp $ * $Id: protocolfile.h,v 1.5 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_PROTOCOLFILE_H #ifndef __IPTV_PROTOCOLFILE_H
@ -32,6 +32,7 @@ public:
virtual bool Set(const char* Address, const int Port); virtual bool Set(const char* Address, const int Port);
virtual bool Open(void); virtual bool Open(void);
virtual bool Close(void); virtual bool Close(void);
virtual cString GetInformation(void);
}; };
#endif // __IPTV_PROTOCOLFILE_H #endif // __IPTV_PROTOCOLFILE_H

View File

@ -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: protocolhttp.c,v 1.9 2007/09/29 16:21:05 rahrenbe Exp $ * $Id: protocolhttp.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -365,9 +365,15 @@ bool cIptvProtocolHttp::Set(const char* Address, const int Port)
else else
streamPath = strcpyrealloc(streamPath, "/"); streamPath = strcpyrealloc(streamPath, "/");
streamPort = Port; streamPort = Port;
debug("iptv://%s:%d%s\n", streamAddr, streamPort, streamPath); debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
// Re-connect the socket // Re-connect the socket
Connect(); Connect();
} }
return true; return true;
} }
cString cIptvProtocolHttp::GetInformation(void)
{
//debug("cIptvProtocolHttp::GetInformation()");
return cString::sprintf("http://%s:%d%s", streamAddr, streamPort, streamPath);
}

View File

@ -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: protocolhttp.h,v 1.6 2007/09/29 10:55:14 ajhseppa Exp $ * $Id: protocolhttp.h,v 1.7 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_PROTOCOLHTTP_H #ifndef __IPTV_PROTOCOLHTTP_H
@ -39,6 +39,7 @@ public:
virtual bool Set(const char* Address, const int Port); virtual bool Set(const char* Address, const int Port);
virtual bool Open(void); virtual bool Open(void);
virtual bool Close(void); virtual bool Close(void);
virtual cString GetInformation(void);
}; };
#endif // __IPTV_PROTOCOLHTTP_H #endif // __IPTV_PROTOCOLHTTP_H

View File

@ -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: protocolif.h,v 1.4 2007/09/29 16:21:05 rahrenbe Exp $ * $Id: protocolif.h,v 1.5 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_PROTOCOLIF_H #ifndef __IPTV_PROTOCOLIF_H
@ -17,6 +17,7 @@ public:
virtual bool Set(const char* Address, const int Port) = 0; virtual bool Set(const char* Address, const int Port) = 0;
virtual bool Open(void) = 0; virtual bool Open(void) = 0;
virtual bool Close(void) = 0; virtual bool Close(void) = 0;
virtual cString GetInformation(void) = 0;
private: private:
cIptvProtocolIf(const cIptvProtocolIf&); cIptvProtocolIf(const cIptvProtocolIf&);

View File

@ -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: protocoludp.c,v 1.10 2007/09/29 16:21:05 rahrenbe Exp $ * $Id: protocoludp.c,v 1.11 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -246,3 +246,9 @@ bool cIptvProtocolUdp::Set(const char* Address, const int Port)
} }
return true; return true;
} }
cString cIptvProtocolUdp::GetInformation(void)
{
//debug("cIptvProtocolUdp::GetInformation()");
return cString::sprintf("udp://%s:%d", streamAddr, streamPort);
}

View File

@ -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: protocoludp.h,v 1.7 2007/09/29 16:21:05 rahrenbe Exp $ * $Id: protocoludp.h,v 1.8 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_PROTOCOLUDP_H #ifndef __IPTV_PROTOCOLUDP_H
@ -35,6 +35,7 @@ public:
virtual bool Set(const char* Address, const int Port); virtual bool Set(const char* Address, const int Port);
virtual bool Open(void); virtual bool Open(void);
virtual bool Close(void); virtual bool Close(void);
virtual cString GetInformation(void);
}; };
#endif // __IPTV_PROTOCOLUDP_H #endif // __IPTV_PROTOCOLUDP_H

View File

@ -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.9 2007/10/07 20:08:45 rahrenbe Exp $ * $Id: statistics.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include <limits.h> #include <limits.h>
@ -28,11 +28,9 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
cString cIptvSectionStatistics::GetStatistic() cString cIptvSectionStatistics::GetStatistic()
{ {
debug("cIptvSectionStatistics::GetStatistic()\n"); //debug("cIptvSectionStatistics::GetStatistic()\n");
uint64_t elapsed = timer.Elapsed(); uint64_t elapsed = timer.Elapsed();
timer.Set(); timer.Set();
// Prevent a divide-by-zero error
elapsed ? : elapsed = 1;
float divider = elapsed / 1000; float divider = elapsed / 1000;
char unit[] = { ' ', 'B', '/', 's', '\0' }; char unit[] = { ' ', 'B', '/', 's', '\0' };
if (IptvConfig.IsStatsUnitInKilos()) { if (IptvConfig.IsStatsUnitInKilos()) {
@ -43,10 +41,10 @@ cString cIptvSectionStatistics::GetStatistic()
divider /= sizeof(unsigned short) * 8; divider /= sizeof(unsigned short) * 8;
unit[1] = 'b'; unit[1] = 'b';
} }
long tmpFilteredData = filteredData; cString info = cString::sprintf("%4ld (%4ld %s)", numberOfCalls, divider ?
long tmpNumberOfCalls = numberOfCalls; (long)(filteredData / divider) : 0L, unit);
filteredData = numberOfCalls = 0; filteredData = numberOfCalls = 0;
return cString::sprintf("Filtered data: %ld %s\nData packets passed: %ld\n", (long)(tmpFilteredData / divider), unit, tmpNumberOfCalls); return info;
} }
// --- cIptvDeviceStatistics ------------------------------------------------- // --- cIptvDeviceStatistics -------------------------------------------------
@ -67,13 +65,10 @@ cIptvDeviceStatistics::~cIptvDeviceStatistics()
cString cIptvDeviceStatistics::GetStatistic() cString cIptvDeviceStatistics::GetStatistic()
{ {
debug("cIptvDeviceStatistics::GetStatistic()\n"); //debug("cIptvDeviceStatistics::GetStatistic()\n");
pidStruct tmpMostActivePids[10];
long tmpDataBytes = dataBytes; long tmpDataBytes = dataBytes;
uint64_t elapsed = timer.Elapsed(); uint64_t elapsed = timer.Elapsed();
timer.Set(); timer.Set();
// Prevent a divide-by-zero error
elapsed ? : elapsed = 1;
float divider = elapsed / 1000; float divider = elapsed / 1000;
char unit[] = { ' ', 'B', '/', 's', '\0' }; char unit[] = { ' ', 'B', '/', 's', '\0' };
if (IptvConfig.IsStatsUnitInKilos()) { if (IptvConfig.IsStatsUnitInKilos()) {
@ -84,24 +79,21 @@ cString cIptvDeviceStatistics::GetStatistic()
divider /= sizeof(unsigned short) * 8; divider /= sizeof(unsigned short) * 8;
unit[1] = 'b'; unit[1] = 'b';
} }
cString info = cString::sprintf("Bitrate: %ld %s\n", divider ?
(long)(tmpDataBytes / divider) : 0L, unit);
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
if (mostActivePids[i].pid)
info = cString::sprintf("%sPid %d: %4d (%4ld %s)%c", *info, i,
mostActivePids[i].pid,
(long)(mostActivePids[i].DataAmount / divider),
unit, ((i + 1) % 2) ? '\t' : '\n');
}
dataBytes = 0; dataBytes = 0;
memcpy(&tmpMostActivePids, &mostActivePids, sizeof(tmpMostActivePids));
memset(&mostActivePids, '\0', sizeof(mostActivePids)); memset(&mostActivePids, '\0', sizeof(mostActivePids));
return cString::sprintf("Stream data bytes: %ld %s\n" return info;
" 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) static int SortFunc(const void* data1, const void* data2)
{ {
//debug("cIptvDeviceStatistics::SortFunc()\n"); //debug("cIptvDeviceStatistics::SortFunc()\n");
pidStruct *comp1 = (pidStruct*)data1; pidStruct *comp1 = (pidStruct*)data1;
@ -153,11 +145,9 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
cString cIptvStreamerStatistics::GetStatistic() cString cIptvStreamerStatistics::GetStatistic()
{ {
debug("cIptvStreamerStatistics::GetStatistic()\n"); //debug("cIptvStreamerStatistics::GetStatistic()\n");
uint64_t elapsed = timer.Elapsed(); uint64_t elapsed = timer.Elapsed();
timer.Set(); timer.Set();
// Prevent a divide-by-zero error
elapsed ? : elapsed = 1;
float divider = elapsed / 1000; float divider = elapsed / 1000;
char unit[] = { ' ', 'B', '/', 's', '\0' }; char unit[] = { ' ', 'B', '/', 's', '\0' };
if (IptvConfig.IsStatsUnitInKilos()) { if (IptvConfig.IsStatsUnitInKilos()) {
@ -168,7 +158,7 @@ cString cIptvStreamerStatistics::GetStatistic()
divider /= sizeof(unsigned short) * 8; divider /= sizeof(unsigned short) * 8;
unit[1] = 'b'; unit[1] = 'b';
} }
long tmpDataBytes = (long)(dataBytes / divider); long tmpDataBytes = divider ? (long)(dataBytes / divider) : 0L;
dataBytes = 0; dataBytes = 0;
return cString::sprintf("Stream data bytes: %ld %s\n", tmpDataBytes, unit); return cString::sprintf("Streamer: %ld %s", tmpDataBytes, unit);
} }

View File

@ -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.4 2007/10/07 19:06:33 ajhseppa Exp $ * $Id: statistics.h,v 1.5 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_STATISTICS_H #ifndef __IPTV_STATISTICS_H
@ -47,7 +47,7 @@ protected:
void UpdateActivePids(u_short pid, long payload); void UpdateActivePids(u_short pid, long payload);
private: private:
pidStruct mostActivePids[10]; pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timer; cTimeMs timer;
}; };

View File

@ -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.17 2007/10/05 19:00:44 ajhseppa Exp $ * $Id: streamer.c,v 1.18 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#include <vdr/thread.h> #include <vdr/thread.h>
@ -96,3 +96,10 @@ bool cIptvStreamer::Set(const char* Address, const int Port, cIptvProtocolIf* Pr
return true; return true;
} }
cString cIptvStreamer::GetInformation(void)
{
//debug("cIptvStreamer::GetInformation()");
if (protocol)
return protocol->GetInformation();
return NULL;
}

View File

@ -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.h,v 1.8 2007/10/05 19:00:44 ajhseppa Exp $ * $Id: streamer.h,v 1.9 2007/10/07 22:54:09 rahrenbe Exp $
*/ */
#ifndef __IPTV_STREAMER_H #ifndef __IPTV_STREAMER_H
@ -32,6 +32,7 @@ public:
bool Set(const char* Address, const int Port, cIptvProtocolIf* Protocol); bool Set(const char* Address, const int Port, cIptvProtocolIf* Protocol);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void);
}; };
#endif // __IPTV_STREAMER_H #endif // __IPTV_STREAMER_H