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

namespace skyscraper5.Skyscraper.Scraper.StreamAutodetection
{
    public abstract class Contestant : IPayloadUnitDecoder, IDisposable
    {
        protected Contestant(string tag, int pid)
        {
            Tag = tag;
            Pid = pid;
        }

        public long Score { get; set; }
        public string Tag { get; protected set; }
        public int Pid { get; }
        public ITsPacketProcessor PacketProcessor { get; protected set; }

        public override string ToString()
        {
            return $"{nameof(Tag)}: {Tag}, {nameof(Score)}: {Score}";
        }

        public abstract void Dispose();

        public void PacketLoss()
        {
            IPayloadUnitDecoder payloadUnitDecoder = PacketProcessor as IPayloadUnitDecoder;
            if (payloadUnitDecoder != null)
                payloadUnitDecoder.PacketLoss();
        }

        public abstract void DeclareWinner(SkyscraperContext skyscraperContext, int pid, ProgramContext programContext);

        public abstract void Introduce(ProgramContext programContext);
    }
}
