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

namespace skyscraper8.SatIp.RtspResponses
{
	internal class RtspDescribeResponse : RtspResponse
	{
		public RtspDescribeResponse(RtspResponseHeader header) : base(header)
		{
		}

		public uint CSeq
		{
			get
			{
				return uint.Parse(base.args["CSeq"]);
			}
		}

		public string ContentType
		{
			get
			{
				return base.args["Content-Type"];
			}
		}

		public long ContentLength
		{
			get
			{
				return long.Parse(base.args["Content-Length"]);
			}
		}

		public SessionDescriptionProtocol GetSessionDescriptionProtocol()
		{
			if (!ContentType.Equals("application/sdp"))
			{
				throw new RtspException(String.Format("Invalid MIME Type. Expected {0}, got {1}.", "application/sdp", ContentType));
			}

			MemoryStream ms = new MemoryStream(base.payload, false);
			StreamReader sr = new StreamReader(ms);
			SessionDescriptionProtocol result = new SessionDescriptionProtocol(sr);
			ms.Close();
			sr.Close();
			return result;
		}
	}
}
