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

namespace skyscraper5.Mpeg2.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x04,"PMT")]
    [BannedTable("BAT","TSDT","NIT")]
    class HierarchyDescriptor : TsDescriptor
    {
        public HierarchyDescriptor(byte[] buffer)
        {
            if (buffer.Length != 4)
            {
                Valid = false;
                return;
            }

            NoViewScalabilityFlag = (buffer[0] & 0x80) != 0;
            NoTemporalScalabilityFlag = (buffer[0] & 0x40) != 0;
            NoSpatialScalabilityFlag = (buffer[0] & 0x20) != 0;
            NoQualityScalabilityFlag = (buffer[0] & 0x10) != 0;
            HierarchyType = (buffer[0] & 0x0f);
            HierarchyLayerType = (buffer[1] & 0x3f);
            TrefPresentFlag = (buffer[2] & 0x80) != 0;
            HierarchyEmbeddedLayerIndex = (buffer[3] & 0x3f);
            HierarchyChannel = (buffer[4] & 0x3f);
            Valid = true;
        }

        public int HierarchyChannel { get; private set; }

        public int HierarchyEmbeddedLayerIndex { get; private set; }

        public bool TrefPresentFlag { get; private set; }

        public int HierarchyLayerType { get; private set; }

        public int HierarchyType { get; private set; }

        public bool NoQualityScalabilityFlag { get; private set; }

        public bool NoSpatialScalabilityFlag { get; private set; }

        public bool NoTemporalScalabilityFlag { get; private set; }

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