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

namespace skyscraper5.Mpeg2.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x28,"PMT")]
    class AvcVideoDescriptor : TsDescriptor
    {
        public AvcVideoDescriptor(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer);
            ProfileRdc = ms.ReadUInt8();
            byte readUInt8 = ms.ReadUInt8();
            ConstraintSet0Flag = (readUInt8 & 0x80) != 0;
            ConstraintSet1Flag = (readUInt8 & 0x40) != 0;
            ConstraintSet2Flag = (readUInt8 & 0x20) != 0;
            ConstraintSet3Flag = (readUInt8 & 0x10) != 0;
            ConstraintSet4Flag = (readUInt8 & 0x08) != 0;
            ConstraintSet5Flag = (readUInt8 & 0x04) != 0;
            AvcCompatibleFlags = (readUInt8 & 0x03);
            LevelIdc = ms.ReadUInt8();
            byte uInt8 = ms.ReadUInt8();
            AvcStillPresent = (readUInt8 & 0x80) != 0;
            Avc24HourPictureFlag = (readUInt8 & 0x40) != 0;
            FramePackingSeiNotPresent = (readUInt8 & 0x20) != 0;
        }

        public bool FramePackingSeiNotPresent { get; private set; }

        public bool Avc24HourPictureFlag { get; private set; }

        public bool AvcStillPresent { get; private set; }

        public byte LevelIdc { get; private set; }

        public int AvcCompatibleFlags { get; private set; }

        public bool ConstraintSet5Flag { get; private set; }

        public bool ConstraintSet4Flag { get; private set; }

        public bool ConstraintSet3Flag { get; private set; }

        public bool ConstraintSet2Flag { get; private set; }

        public bool ConstraintSet1Flag { get; private set; }

        public bool ConstraintSet0Flag { get; private set; }

        public byte ProfileRdc { get; private set; }
    }
}
