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

namespace skyscraper5.Dvb.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x77,"NIT","CAT","INT")]
    [BannedTable("BAT")]
    internal class TimeSliceFecIdentifierDescriptor : TsDescriptor
    {
        public TimeSliceFecIdentifierDescriptor(byte[] buffer)
        {
            TimeSlicing = (buffer[0] & 0x80) != 0;
            MpeFec = (buffer[0] & 0x60) >> 5;
            FrameSize = (buffer[0] & 0x1f);
            MaxBurstDuration = buffer[1];
            MaxAverageRate = (buffer[2] & 0xf0) >> 4;
            TimeSliceFecId = (buffer[2] & 0x0f);
            if (buffer.Length > 3)
            {
                throw new NotImplementedException("id_selector_byte");
            }
        }

        public int TimeSliceFecId { get; private set; }

        public int MaxAverageRate { get; private set; }

        public byte MaxBurstDuration { get; private set; }

        public int FrameSize { get; private set; }

        public int MpeFec { get; private set; }

        public bool TimeSlicing { get; private set; }
    }
}
