mirror of
				https://github.com/rofafor/vdr-plugin-iptv.git
				synced 2023-10-10 11:37:03 +00:00 
			
		
		
		
	Modified cIptvBufferStatistics() and general statistics menu.
This commit is contained in:
		
							
								
								
									
										13
									
								
								device.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								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.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"
 | 
					#include "config.h"
 | 
				
			||||||
@@ -97,11 +97,12 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
 | 
				
			|||||||
cString cIptvDevice::GetGeneralInformation(void)
 | 
					cString cIptvDevice::GetGeneralInformation(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  //debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
 | 
					  //debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
 | 
				
			||||||
  return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s\n%s%s",
 | 
					  return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
 | 
				
			||||||
                          deviceIndex, CardIndex(), pIptvStreamer ?
 | 
					                          deviceIndex, CardIndex(),
 | 
				
			||||||
                          *pIptvStreamer->GetInformation() : "",
 | 
					                          pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
 | 
				
			||||||
                          pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
 | 
					                          pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
 | 
				
			||||||
			  *cIptvBufferStatistics::GetStatistic());
 | 
								  *cIptvBufferStatistics::GetStatistic(),
 | 
				
			||||||
 | 
					                          *Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cString cIptvDevice::GetPidsInformation(void)
 | 
					cString cIptvDevice::GetPidsInformation(void)
 | 
				
			||||||
@@ -347,7 +348,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(), tsBuffer->Free());
 | 
					        cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
     uchar *p = tsBuffer->Get(Count);
 | 
					     uchar *p = tsBuffer->Get(Count);
 | 
				
			||||||
     if (p && Count >= TS_SIZE) {
 | 
					     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.
 | 
					 * 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>
 | 
					#include <limits.h>
 | 
				
			||||||
@@ -165,7 +165,6 @@ void cIptvStreamerStatistics::AddStatistic(long Bytes)
 | 
				
			|||||||
// Buffer statistic class
 | 
					// Buffer statistic class
 | 
				
			||||||
cIptvBufferStatistics::cIptvBufferStatistics()
 | 
					cIptvBufferStatistics::cIptvBufferStatistics()
 | 
				
			||||||
: dataBytes(0),
 | 
					: dataBytes(0),
 | 
				
			||||||
  freeSpace(0),
 | 
					 | 
				
			||||||
  usedSpace(0),
 | 
					  usedSpace(0),
 | 
				
			||||||
  timer(),
 | 
					  timer(),
 | 
				
			||||||
  mutex()
 | 
					  mutex()
 | 
				
			||||||
@@ -185,30 +184,28 @@ cString cIptvBufferStatistics::GetStatistic()
 | 
				
			|||||||
  uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
 | 
					  uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
 | 
				
			||||||
  timer.Set();
 | 
					  timer.Set();
 | 
				
			||||||
  long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * dataBytes / elapsed) : 0L;
 | 
					  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 usedKilos = usedSpace / KILOBYTE(1);
 | 
				
			||||||
  long freeKilos = freeSpace / KILOBYTE(1);
 | 
					 | 
				
			||||||
  if (!IptvConfig.GetUseBytes()) {
 | 
					  if (!IptvConfig.GetUseBytes()) {
 | 
				
			||||||
     bitrate *= 8;
 | 
					     bitrate *= 8;
 | 
				
			||||||
     freeKilos *= 8;
 | 
					     totalKilos *= 8;
 | 
				
			||||||
     usedKilos *= 8;
 | 
					     usedKilos *= 8;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
  cString info = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate,
 | 
					  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);
 | 
					                                  IptvConfig.GetUseBytes() ? "B" : "bit", percentage);
 | 
				
			||||||
  dataBytes = 0;
 | 
					  dataBytes = 0;
 | 
				
			||||||
  freeSpace = 0;
 | 
					 | 
				
			||||||
  usedSpace = 0;
 | 
					  usedSpace = 0;
 | 
				
			||||||
  return info;
 | 
					  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);
 | 
					  cMutexLock MutexLock(&mutex);
 | 
				
			||||||
  dataBytes += Bytes;
 | 
					  dataBytes += Bytes;
 | 
				
			||||||
  if (Used > usedSpace) {
 | 
					  if (Used > usedSpace)
 | 
				
			||||||
     freeSpace = Free;
 | 
					 | 
				
			||||||
     usedSpace = Used;
 | 
					     usedSpace = Used;
 | 
				
			||||||
     }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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.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
 | 
					#ifndef __IPTV_STATISTICS_H
 | 
				
			||||||
@@ -77,7 +77,7 @@ public:
 | 
				
			|||||||
  cString GetStatistic();
 | 
					  cString GetStatistic();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
  void AddStatistic(long Bytes, long Used, long Free);
 | 
					  void AddStatistic(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.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>
 | 
					#include <vdr/thread.h>
 | 
				
			||||||
@@ -101,6 +101,6 @@ cString cIptvStreamer::GetInformation(void)
 | 
				
			|||||||
  //debug("cIptvStreamer::GetInformation()");
 | 
					  //debug("cIptvStreamer::GetInformation()");
 | 
				
			||||||
  cString info("Stream:");
 | 
					  cString info("Stream:");
 | 
				
			||||||
  if (protocol)
 | 
					  if (protocol)
 | 
				
			||||||
     return cString::sprintf("%s %s", *info, *protocol->GetInformation());
 | 
					     info = cString::sprintf("%s %s", *info, *protocol->GetInformation());
 | 
				
			||||||
  return NULL;
 | 
					  return cString::sprintf("%s\n", *info);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user