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.Extension
{
	[SkyscraperPlugin]
	[ExtensionDescriptor(0x06,"PMT")]
    public class SupplemenatryAudioDescriptor : Dvb.ExtensionDescriptor
    {
        public SupplemenatryAudioDescriptor(byte[] buffer)
        {
            MixType = ((buffer[0] & 0x80) != 0);
            EditorialClassification = (EditorialClassificationEnum)((buffer[0] & 0x7c) >> 2);
            LanguageCodePresent = ((buffer[0] & 0x01) != 0);
            if (LanguageCodePresent)
                Iso639LanguageCode = Encoding.ASCII.GetString(buffer, 1, 3);
        }

        public string Iso639LanguageCode { get; private set; }

        public bool LanguageCodePresent { get; private set; }

        public bool MixType { get; private set; }
        public EditorialClassificationEnum EditorialClassification { get; private set; }

        public enum EditorialClassificationEnum
        {
            MainAudio = 0,
            AudioDescriptionVisuallyImpaired = 1,
            CleanAudio = 2,
            SpokenSubtitles = 3,
            DependentParametricDataStream = 4,
            UnspecificSupplementaryAudio = 0x17
        }
    }
}
