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

Moved pidStruct and SortFunc inside class.

This commit is contained in:
Rolf Ahrenberg 2007-10-08 12:25:30 +00:00
parent c8a882f8b1
commit e4730e4e66
2 changed files with 12 additions and 11 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: statistics.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $ * $Id: statistics.c,v 1.11 2007/10/08 12:25:30 rahrenbe Exp $
*/ */
#include <limits.h> #include <limits.h>
@ -93,9 +93,9 @@ cString cIptvDeviceStatistics::GetStatistic()
return info; return info;
} }
static int SortFunc(const void* data1, const void* data2) int cIptvDeviceStatistics::SortPids(const void* data1, const void* data2)
{ {
//debug("cIptvDeviceStatistics::SortFunc()\n"); //debug("cIptvDeviceStatistics::SortPids()\n");
pidStruct *comp1 = (pidStruct*)data1; pidStruct *comp1 = (pidStruct*)data1;
pidStruct *comp2 = (pidStruct*)data2; pidStruct *comp2 = (pidStruct*)data2;
if (comp1->DataAmount > comp2->DataAmount) if (comp1->DataAmount > comp2->DataAmount)
@ -114,7 +114,7 @@ void cIptvDeviceStatistics::UpdateActivePids(u_short pid, long payload)
if (mostActivePids[i].pid == pid) { if (mostActivePids[i].pid == pid) {
mostActivePids[i].DataAmount += payload; mostActivePids[i].DataAmount += payload;
// Now re-sort the array and quit // Now re-sort the array and quit
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortFunc); qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
return; return;
} }
} }
@ -124,7 +124,7 @@ void cIptvDeviceStatistics::UpdateActivePids(u_short pid, long payload)
mostActivePids[numberOfElements - 1].pid = pid; mostActivePids[numberOfElements - 1].pid = pid;
mostActivePids[numberOfElements - 1].DataAmount = payload; mostActivePids[numberOfElements - 1].DataAmount = payload;
// Re-sort // Re-sort
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortFunc); qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
} }
} }

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.5 2007/10/07 22:54:09 rahrenbe Exp $ * $Id: statistics.h,v 1.6 2007/10/08 12:25:30 rahrenbe Exp $
*/ */
#ifndef __IPTV_STATISTICS_H #ifndef __IPTV_STATISTICS_H
@ -11,11 +11,6 @@
#include "statisticif.h" #include "statisticif.h"
struct pidStruct {
u_short pid;
long DataAmount;
};
// Section statistics // Section statistics
class cIptvSectionStatistics : public cIptvStatisticIf { class cIptvSectionStatistics : public cIptvStatisticIf {
protected: protected:
@ -47,8 +42,14 @@ protected:
void UpdateActivePids(u_short pid, long payload); void UpdateActivePids(u_short pid, long payload);
private: private:
struct pidStruct {
u_short pid;
long DataAmount;
};
pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT]; pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timer; cTimeMs timer;
static int SortPids(const void* data1, const void* data2);
}; };
// Streamer statistics // Streamer statistics