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

namespace skyscraper5.Dvb.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x4b,"SDT")]
    public class NvodReferenceDescriptor : TsDescriptor
    {
        public NvodReferenceDescriptor(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer, false);
            NvodReferences = new NvodReference[buffer.Length / 6];
            for (int i = 0; i < NvodReferences.Length; i++)
            {
                NvodReferences[i] = new NvodReference();
                NvodReferences[i].TransportStreamId = ms.ReadUInt16BE();
                NvodReferences[i].OriginalNetworkId = ms.ReadUInt16BE();
                NvodReferences[i].ServiceId = ms.ReadUInt16BE();
            }
        }

        public class NvodReference
        {
            public ushort TransportStreamId { get; set; }
            public ushort OriginalNetworkId { get; set; }
            public ushort ServiceId { get; set; }
        }

        public NvodReference[] NvodReferences { get; private set; }
    }
}
