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

namespace skyscraper5.Skyscraper.Scraper.StreamAutodetection.Contestants
{
    [SkyscraperPlugin]
    class AitContestant : Contestant, IAitEventHandler
    {
        public AitContestant(int pid) : base("AIT", pid)
        {
            PacketProcessor = new PsiDecoder(pid, new AitParser(this, 0));
        }

        public void OnAitApplication(AitApplication aitApplication, ushort programNumber)
        {
            Score++;
        }

        public override void Dispose()
        {
            
        }

        public override void DeclareWinner(SkyscraperContext skyscraperContext, int pid, ProgramContext programContext)
        {
	        if (programContext.Program == null)
	        {
		        programContext.Program = new ProgramMapping(0x1fff, 0x1ff);
	        }
			skyscraperContext.DvbContext.RegisterPacketProcessor(pid, new PsiDecoder(pid, new AitParser(skyscraperContext, programContext.ProgramNumber)));
		}

        public override void Introduce(ProgramContext programContext)
        {
	        
        }
    }
}
