mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Modified cIptvBufferStatistics() and general statistics menu.
This commit is contained in:
parent
8b9cb443b4
commit
6327cbe7ed
13
device.c
13
device.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.66 2007/10/10 19:41:10 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.67 2007/10/11 23:06:49 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -97,11 +97,12 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
|
||||
cString cIptvDevice::GetGeneralInformation(void)
|
||||
{
|
||||
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
|
||||
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s\n%s%s",
|
||||
deviceIndex, CardIndex(), pIptvStreamer ?
|
||||
*pIptvStreamer->GetInformation() : "",
|
||||
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
|
||||
deviceIndex, CardIndex(),
|
||||
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
|
||||
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
|
||||
*cIptvBufferStatistics::GetStatistic());
|
||||
*cIptvBufferStatistics::GetStatistic(),
|
||||
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
|
||||
}
|
||||
|
||||
cString cIptvDevice::GetPidsInformation(void)
|
||||
@ -347,7 +348,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
tsBuffer->Del(TS_SIZE);
|
||||
isPacketDelivered = false;
|
||||
// Update buffer statistics
|
||||
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available(), tsBuffer->Free());
|
||||
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
|
||||
}
|
||||
uchar *p = tsBuffer->Get(Count);
|
||||
if (p && Count >= TS_SIZE) {
|
||||
|
21
statistics.c
21
statistics.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statistics.c,v 1.19 2007/10/11 19:44:46 ajhseppa Exp $
|
||||
* $Id: statistics.c,v 1.20 2007/10/11 23:06:49 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
@ -165,7 +165,6 @@ void cIptvStreamerStatistics::AddStatistic(long Bytes)
|
||||
// Buffer statistic class
|
||||
cIptvBufferStatistics::cIptvBufferStatistics()
|
||||
: dataBytes(0),
|
||||
freeSpace(0),
|
||||
usedSpace(0),
|
||||
timer(),
|
||||
mutex()
|
||||
@ -185,30 +184,28 @@ cString cIptvBufferStatistics::GetStatistic()
|
||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
||||
timer.Set();
|
||||
long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * dataBytes / elapsed) : 0L;
|
||||
float percentage = (float)((1 - (float)freeSpace / (float)(usedSpace + freeSpace)) * 100);
|
||||
long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
|
||||
float percentage = (float)((float)usedSpace / (float)totalSpace * 100.0);
|
||||
long totalKilos = totalSpace / KILOBYTE(1);
|
||||
long usedKilos = usedSpace / KILOBYTE(1);
|
||||
long freeKilos = freeSpace / KILOBYTE(1);
|
||||
if (!IptvConfig.GetUseBytes()) {
|
||||
bitrate *= 8;
|
||||
freeKilos *= 8;
|
||||
totalKilos *= 8;
|
||||
usedKilos *= 8;
|
||||
}
|
||||
cString info = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit", usedKilos, usedKilos + freeKilos,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit", usedKilos, totalKilos,
|
||||
IptvConfig.GetUseBytes() ? "B" : "bit", percentage);
|
||||
dataBytes = 0;
|
||||
freeSpace = 0;
|
||||
usedSpace = 0;
|
||||
return info;
|
||||
}
|
||||
|
||||
void cIptvBufferStatistics::AddStatistic(long Bytes, long Used, long Free)
|
||||
void cIptvBufferStatistics::AddStatistic(long Bytes, long Used)
|
||||
{
|
||||
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld, Free=%ld)\n", Bytes, Used, Free);
|
||||
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
|
||||
cMutexLock MutexLock(&mutex);
|
||||
dataBytes += Bytes;
|
||||
if (Used > usedSpace) {
|
||||
freeSpace = Free;
|
||||
if (Used > usedSpace)
|
||||
usedSpace = Used;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: statistics.h,v 1.9 2007/10/09 22:12:17 rahrenbe Exp $
|
||||
* $Id: statistics.h,v 1.10 2007/10/11 23:06:49 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_STATISTICS_H
|
||||
@ -77,7 +77,7 @@ public:
|
||||
cString GetStatistic();
|
||||
|
||||
protected:
|
||||
void AddStatistic(long Bytes, long Used, long Free);
|
||||
void AddStatistic(long Bytes, long Used);
|
||||
|
||||
private:
|
||||
long dataBytes;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: streamer.c,v 1.22 2007/10/11 21:05:35 rahrenbe Exp $
|
||||
* $Id: streamer.c,v 1.23 2007/10/11 23:06:49 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <vdr/thread.h>
|
||||
@ -101,6 +101,6 @@ cString cIptvStreamer::GetInformation(void)
|
||||
//debug("cIptvStreamer::GetInformation()");
|
||||
cString info("Stream:");
|
||||
if (protocol)
|
||||
return cString::sprintf("%s %s", *info, *protocol->GetInformation());
|
||||
return NULL;
|
||||
info = cString::sprintf("%s %s", *info, *protocol->GetInformation());
|
||||
return cString::sprintf("%s\n", *info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user