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

namespace skyscraper8.DvbSis
{
    internal class FtiHandler : ITsPacketProcessor, IPayloadUnitDecoder, T2MIEventHandler
    {
        public FtiHandler(int pid, SisHandler sisOutput, T2MIEventHandler t2miOutput) 
        {
            this.t2miProxy = new T2MIDecoder(pid, this);
            this.t2miOutput = t2miOutput;
            this.sisOutput = sisOutput;
        }

        private SisHandler sisOutput;
        private T2MIEventHandler t2miOutput;
        private T2MIDecoder t2miProxy;

        public void PacketLoss()
        {
            t2miProxy.PacketLoss();
        }

        public void PushPacket(TsPacket packet)
        {
           t2miProxy.PushPacket(packet);
        }

        public void OnT2MiPacketLoss(int pid, byte expectedPacket, T2MIHeader header)
        {
        }

        public void OnT2MiPacket(int pid, byte basebandFramePlpId, byte[] basebandPacket)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiTimestamp(int pid, _0x20_DvbT2Timestamp t2Timestamp)
        {
            sisOutput.OnSisTimestamp(pid, t2Timestamp);
        }

        public void OnT2MiIqData(int relatedPid, _0x31_IqData iqData)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiIqData(int relatedPid, _0x01_IqData iqData2)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiError(int relatedPid, int skyscraperErrorCode)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiL1Current(int relatedPid, _0x10_L1Current l1Current)
        {
            t2miOutput.OnT2MiL1Current(relatedPid, l1Current);
        }

        public void OnT2MiArbitraryCellInsertion(int relatedPid, _0x02_ArbitraryCellInsertion arbitraryCellInsertion)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiBalancingCells(int relatedPid, byte frameIndex, uint numActiveBiasCellsPerP2)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiL1Future(int relatedPid, _0x11_L1Future l1Future)
        {
            throw new NotImplementedException();
        }

        public void OnT2MiIndividualAddressing(int relatedPid, _0x21_IndividualAddressing individualAddressing)
        {
            throw new NotImplementedException();
        }

        public void OnFramingAndTimingInformation(int relatedPid, _0xF0_FramingTimingInformation fti)
        {
            sisOutput.OnSisFti(relatedPid, fti);
        }
    }
}
