using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Ietf.Rfc4566_SDP
{
	public class SdpMedia
	{
		private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);

		public SdpMedia(string[] args)
		{
			if (!MediaType.TryParse(args[0], true, out _mediaType))
			{
				logger.ErrorFormat("Unknown Media Type \"{0}\", assuming \"data\"", args[0]);
				_mediaType = MediaType.Data;
			}

			Port = ushort.Parse(args[1]);
			Transport = args[2];

			int numFormats = args.Length - 3;
			FormatList = new string[numFormats];
			Array.Copy(args, 3, FormatList, 0, numFormats);
		}

		public string[] FormatList { get; private set; }

		public string Transport { get; private set; }

		public ushort Port { get; private set; }

		private MediaType _mediaType;
		public MediaType MediaType
		{
			get => _mediaType;
		}
	}

	public enum MediaType
	{
		Audio,
		Video,
		Application,
		Data,
		Control
	}
}
