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 ScrambleCounter : IPacketFilter
	{
		public bool PassPacket(TsPacket packet)
		{
			if (scrambled == null)
				scrambled = new byte[0x2000];

			if (packet.TSC != 0)
			{
				if (scrambled[packet.PID] != 255)
					scrambled[packet.PID]++;
			}

			return true;
		}

		private byte[] scrambled;

		public bool IsScrambled(int pid)
		{
			return scrambled[pid] > 0;
		}
	}
}
