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

namespace skyscraper5.Skyscraper.Scraper.StreamAutodetection.Contestants
{
	[SkyscraperPlugin]
	class SubtitleContestant : Contestant, ISubtitleEventHandler, IDisposable
    {
        public SubtitleContestant(int pid) : base("DVBSubtitle", pid)
        {
            PacketProcessor = new PesDecoder(new SubtitleDecoder(this));
        }

        public void NotifyOfSubtitleLine(Page page)
        {
            Score++;
        }

        public override void Dispose()
        {
            
        }

        public override void DeclareWinner(SkyscraperContext skyscraperContext, int pid, ProgramContext programContext)
        {
			PesDecoder pesDecoder = new PesDecoder(new SubtitleDecoder(skyscraperContext));
			pesDecoder.Tag = "subs";
			skyscraperContext.DvbContext.RegisterPacketProcessor(pid, pesDecoder);
		}

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