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

namespace skyscraper5.src.Mpeg2.PacketFilter
{

	/// <summary>
	/// Nukes the first n Packets, lets all others through
	/// </summary>
	/// 
	[PluginPriority(10)]
	public class SkipFilter : IPacketFilter
	{
		/// <summary>
		/// The amount of packets that fit into CrazyScan's default buffer size.
		/// </summary>
		public const ulong CRAZYSCAN_BUFFER = 512;

		private ulong _toSkip, _skipped;

		public SkipFilter(ulong toSkip = CRAZYSCAN_BUFFER)
		{
			this._toSkip = toSkip;
		}

		public ulong ToSkip { get { return _toSkip; } }
		public ulong Skipped { get { return _skipped; } }

		public bool PassPacket(TsPacket packet)
		{
			if (_toSkip > _skipped)
			{
				_skipped++;
				return false;
			}
			return true;
		}
	}
}
