skyscraper8/GUIs/skyscraper5.UI/Overrides/PacketsPerSecondCounter.cs
feyris-tan ef86554f9a Import
2025-05-12 22:09:16 +02:00

52 lines
997 B
C#

using skyscraper5.Mpeg2;
using skyscraper5.src.Mpeg2.PacketFilter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.UI.Overrides
{
internal class PacketsPerSecondCounter : IPacketFilter
{
public bool PassPacket(TsPacket packet)
{
DateTime now = DateTime.Now;
if (lastPacket.Second != now.Second)
{
countedPacketLastSecond = countedPacketThisSecond;
countedPacketThisSecond = 0;
Ready = true;
}
lastPacket = now;
countedPacketThisSecond++;
totalPacketsOverall++;
return true;
}
private DateTime lastPacket;
private long countedPacketThisSecond;
private long countedPacketLastSecond;
private ulong totalPacketsOverall;
public long PacketsPerSecond
{
get
{
return countedPacketThisSecond;
}
}
public ulong TotalPacketsOverall
{
get
{
return totalPacketsOverall;
}
}
public bool Ready { get; private set; }
}
}