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; } } }