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

namespace skyscraper5.Dvb.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x6b,"PMT")]
    public class AncillaryDataDescriptor : TsDescriptor
    {
        public AncillaryDataDescriptor(byte[] buffer)
        {
            if (buffer.Length != 1)
            {
                return;
            }

            AncillaryDataIdentifier = buffer[0];
            this.Valid = true;
        }
        
        public byte AncillaryDataIdentifier { get; private set; }

        //ETSI TS 101 154 seems like a fun read.
        public bool RdsOnly => AncillaryDataIdentifier == 0x40;
        public bool RDS => (AncillaryDataIdentifier & 0x40) != 0;
        public bool Mpeg4AncillaryData => (AncillaryDataIdentifier & 0x20) != 0;
        public bool ScaleFactorErrorCheck => (AncillaryDataIdentifier & 0x10) != 0;
        public bool DabAncillaryData => (AncillaryDataIdentifier & 0x08) != 0;
        public bool AnnouncementSwitchingData => (AncillaryDataIdentifier & 0x04) != 0;
        public bool ExtendedAncillaryData => (AncillaryDataIdentifier & 0x02) != 0;
        public bool DvdVideoAncillaryData => (AncillaryDataIdentifier & 0x01) != 0;
    }
}
