using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Dvb;
using skyscraper5.Mpeg2;
using skyscraper5.PrivateDataSpecifiers.Nordig;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.IO;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.Nordig.Descriptor
{
    [SkyscraperPlugin]
    [UserDefinedDescriptor(0x00000029, 0x87, "NIT")]
    [DescriptorPluginNitHandler(typeof(NordigNitHook))]
    class LogicalChannelDescriptorVersion2 : TsDescriptor
    {
        public LogicalChannelDescriptorVersion2(byte[] buffer)
        {
            LogicalChannels = new LogicalChannelNumberEntry[buffer.Length / 4];
            MemoryStream ms = new MemoryStream(buffer, false);
            for (int i = 0; i < LogicalChannels.Length; i++)
            {
                LogicalChannels[i] = new LogicalChannelNumberEntry();
                LogicalChannels[i].ServiceId = ms.ReadUInt16BE();
                LogicalChannels[i].LogicalChannelNumber = (ms.ReadUInt16BE() & 0x03ff);
            }
        }

        public LogicalChannelNumberEntry[] LogicalChannels { get; private set; }

        public class LogicalChannelNumberEntry : BaseLcn
        {
        }
    }
}
