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

namespace skyscraper5.Dvb.DataBroadcasting.Dsm.Stream
{
    public class Info_T
    {
        public Info_T(MemoryStream ms)
        {
            N2 = ms.ReadUInt8();
            ADescripton = ms.ReadBytes(N2);
            uint aSeconds = ms.ReadUInt32BE();
            if (aSeconds > Int32.MaxValue)
                throw new NotImplementedException(String.Format("{0} > {1}", nameof(aSeconds), Int32.MaxValue));
            ushort aMicroSeconds = ms.ReadUInt16BE();
            Duration = new TimeSpan(0, 0, 0, (int)aSeconds, aMicroSeconds);
            Audio = ms.ReadUInt8();
            Video = ms.ReadUInt8();
            Data = ms.ReadUInt8();
        }

        public byte N2 { get; private set; }

        public byte Data { get; private set; }

        public byte Video { get; private set; }

        public byte Audio { get; private set; }

        public TimeSpan Duration { get; private set; }

        public byte[] ADescripton { get; private set; }
    }
}
