diff --git a/device.c b/device.c index 430552b..ee8db60 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.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) { diff --git a/statistics.c b/statistics.c index 3544c0b..5792839 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.19 2007/10/11 19:44:46 ajhseppa Exp $ + * $Id: statistics.c,v 1.20 2007/10/11 23:06:49 rahrenbe Exp $ */ #include @@ -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; - } } diff --git a/statistics.h b/statistics.h index 37ddaee..1495047 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.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; diff --git a/streamer.c b/streamer.c index cc6a655..dab6fb8 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.22 2007/10/11 21:05:35 rahrenbe Exp $ + * $Id: streamer.c,v 1.23 2007/10/11 23:06:49 rahrenbe Exp $ */ #include @@ -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); }