using skyscraper5.Mhp.Si;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.StreamAutodetection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Ses
{
	[SkyscraperPlugin]
	public class SgtCandidate : Contestant, SgtEventHandler, IDisposable
	{
		public SgtCandidate(int pid)
			: base("Asta SGT",pid)
		{
			PacketProcessor = new PsiDecoder(pid, new SgtParser(this));
		}

		public override void DeclareWinner(SkyscraperContext skyscraperContext, int pid, ProgramContext programContext)
		{
			skyscraperContext.DvbContext.RegisterPacketProcessor(pid, new PsiDecoder(pid, new SgtParser(skyscraperContext)));
		}

		public override void Introduce(ProgramContext programContext)
		{
			
		}

		public override void Dispose()
		{
		}

		void SgtEventHandler.AnnounceSgtList(SgtList list)
		{
			if (list.CountryAvailabilities.Count > 0 || list.Names != null || list.PrivateDataSpecifier != 0x01)
				Score++;
		}

		void SgtEventHandler.OnSgtError(SgtError invalidTableId)
		{
			Score--;
		}

		void SgtEventHandler.OnSgtService(SgtService child)
		{
			Score++;
		}
	}
}
