using skyscraper5.Mpeg2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper5.src.Mpeg2.PacketFilter
{
	/// <summary>
	/// This filter can be configured at runtime to only let PIDs of certain packets through. By default all PIDs are allowed.
	/// </summary>
	internal class PidWhitelistFilter : IPacketFilter
	{
		public PidWhitelistFilter() 
		{
			Whitelist = new bool[0x1fff];
			SetAll(true);
		}

		public bool[] Whitelist { get; private set; }

		public void SetAll(bool value)
		{
			Array.Fill(Whitelist, value);
		}

		public bool PassPacket(TsPacket packet)
		{
			return Whitelist[packet.PID];
		}
	}
}
