using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;

namespace skyscraper5.Skyscraper.Scraper.StreamAutodetection
{
    public class ProgramContext
    {
        public ProgramMapping Program { get; set; }

        public ushort ProgramNumber
        {
	        get
	        {
		        return Program.ProgramNumber;
	        }
        }

        public ProgramMappingStream Stream { get; set; }

        public uint? PrivateDataSpecifier
        {
            get
            {
	            if (Stream == null)
		            return null;
                if (Stream.PrivateDataSpecifier.HasValue)
                    return Stream.PrivateDataSpecifier;
                if (Program.PrivateDataSpecifier.HasValue)
                    return Program.PrivateDataSpecifier;
                return null;
            }
        }

        public UserDefinedDescriptor GetFirstUserDefinedDescriptor()
        {
	        if (Stream == null)
		        return null;
	        if (Stream.UnknownUserDefines == null)
		        return null;
	        if (Stream.UnknownUserDefines.Count == 0)
		        return null;
	        return Stream.UnknownUserDefines[0];
        }
    }
}
