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(0x27,"PMT")]
    class MetadataStdDescriptor : TsDescriptor
    {
        public MetadataStdDescriptor(byte[] buffer)
        {
            MetadataInputLeakRate = buffer[0] & 0x3f;
            MetadataInputLeakRate <<= 8;
            MetadataInputLeakRate += buffer[1];
            MetadataInputLeakRate <<= 8;
            MetadataInputLeakRate += buffer[2];

            MetadataBufferSize = buffer[3] & 0x3f;
            MetadataBufferSize <<= 8;
            MetadataBufferSize += buffer[4];
            MetadataBufferSize <<= 8;
            MetadataBufferSize += buffer[5];

            MetadataOutputLeakRate = buffer[6] & 0x3f;
            MetadataOutputLeakRate <<= 8;
            MetadataOutputLeakRate += buffer[7];
            MetadataOutputLeakRate <<= 8;
            MetadataOutputLeakRate += buffer[8];
        }

        public int MetadataOutputLeakRate { get; private set; }

        public int MetadataBufferSize { get; private set; }

        public int MetadataInputLeakRate { get; private set; }
    }
}
