using System; using System.Globalization; namespace Inspectron.HawkEye.RTSP.Sdp { /// /// Object ot represent orgin in an Session Description Protocol /// public class Origin { public Origin() { } /// /// Parses the specified origin string. /// /// The string to convert to origin object. /// public static Origin Parse(string originString) { if (originString == null) throw new ArgumentNullException("originString"); string[] parts = originString.Split(' '); if (parts.Length != 6) throw new FormatException("Number of element invalid in origin string."); Origin result = new Origin(); result.Username = parts[0]; result.SessionId = parts[1]; result.SessionVersion = parts[2]; result.NetType = parts[3]; result.AddressType = parts[4]; result.UnicastAddress = parts[5]; return result; } /// /// Gets or sets the username. /// /// It is the user's login on the originating host, or it is "-" /// if the originating host does not support the concept of user IDs. /// This MUST NOT contain spaces /// The username. public string Username { get; set; } /// /// Gets or sets the session id. /// /// It is a numeric string such that the tuple of , /// , , , and forms a /// globally unique identifier for the session. The method of /// allocation is up to the creating tool, but it has been /// suggested that a Network Time Protocol (NTP) format timestamp be /// used to ensure uniqueness /// The session id. public string SessionId { get; set; } /// /// Gets or sets the session version. /// /// The session version. public string SessionVersion { get; set; } /// /// Gets or sets the type of the net. /// /// The type of the net. public string NetType { get; set; } /// /// Gets or sets the type of the address. /// /// The type of the address. public string AddressType { get; set; } /// /// Gets or sets the unicast address (IP or FDQN). /// /// The unicast address. public string UnicastAddress { get; set; } public override string ToString() { return String.Join(" ", new string[] { Username, SessionId, SessionVersion.ToString(CultureInfo.InvariantCulture), NetType, AddressType, UnicastAddress, } ); } } }