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(0x0c,"PMT")]
    [BannedTable("EIT")]
    class MultiplexBufferUtilizationDescriptor : TsDescriptor
    {
        public MultiplexBufferUtilizationDescriptor(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer);
            ushort readUInt16Be = ms.ReadUInt16BE();
            BoundValidFlag = (readUInt16Be & 0x8000) != 0;
            LtwOffsetLowerBound = (readUInt16Be & 0x7fff);
            readUInt16Be = ms.ReadUInt16BE();
            LtwOffsetUpperBound = (readUInt16Be & 0x7ffe) >> 1;
        }

        public int LtwOffsetUpperBound { get; private set; }

        public int LtwOffsetLowerBound { get; private set; }

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