using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Mpeg2;
using skyscraper5.Nordig.Descriptor;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.PrivateDataSpecifiers.Nordig
{
	internal class NordigNitHook : DescriptorPluginNitHandler
	{
		public void HandleNit(NitTransportStream output, TsDescriptor unpacked)
		{
			byte descriptorId = unpacked.GetDescriptorId();
			switch (descriptorId)
			{
				case 0x83:
					LogicalChannelDescriptor lcd = (LogicalChannelDescriptor)unpacked;
					output.LogicalChannels.AddRange(lcd.LogicalChannels);
					break;
				case 0x87:
					LogicalChannelDescriptorVersion2 lcdv2 = (LogicalChannelDescriptorVersion2)unpacked;
					output.LogicalChannels.AddRange(lcdv2.LogicalChannels);
					break;
				default:
					throw new NotImplementedException(String.Format("{0:X2}", descriptorId));
			}
		}
	}
}
