Пример #1
0
        public static SdpTimeZone ParseInvariant(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            Contract.EndContractBlock();

            SdpTimeZone returnValue = new SdpTimeZone();

            throw new NotImplementedException();
            // return returnValue;
        }
Пример #2
0
        /// <summary>
        /// Reads the specified SDP stream.
        /// As define in RFC 4566
        /// </summary>
        /// <param name="sdpStream">The SDP stream.</param>
        /// <returns></returns>
        public static SdpFile Read(TextReader sdpStream)
        {
            SdpFile returnValue = new SdpFile();
            KeyValuePair <string, string> value = GetKeyValue(sdpStream);

            // Version mandatory
            if (value.Key == "v")
            {
                returnValue.Version = int.Parse(value.Value, CultureInfo.InvariantCulture);
                value = GetKeyValue(sdpStream);
            }
            else
            {
                throw new InvalidDataException();
            }

            // Origin mandatory
            if (value.Key == "o")
            {
                returnValue.Origin = Origin.Parse(value.Value);
                value = GetKeyValue(sdpStream);
            }
            else
            {
                throw new InvalidDataException();
            }

            // Session mandatory.
            // However the MuxLab HDMI Encoder (TX-500762) Firmware 1.0.6
            // does not include the 'Session' so supress InvalidDatarException
            if (value.Key == "s")
            {
                returnValue.Session = value.Value;
                value = GetKeyValue(sdpStream);
            }
            else
            {
                // throw new InvalidDataException(); // we should throw, but instead we just ignore the error
            }

            // Session Information optional
            if (value.Key == "i")
            {
                returnValue.SessionInformation = value.Value;
                value = GetKeyValue(sdpStream);
            }

            // Uri optional
            if (value.Key == "u")
            {
                returnValue.Url = new Uri(value.Value);
                value           = GetKeyValue(sdpStream);
            }

            // Email optional
            if (value.Key == "e")
            {
                returnValue.Email = value.Value;
                value             = GetKeyValue(sdpStream);
            }

            // Phone optional
            if (value.Key == "p")
            {
                returnValue.Phone = value.Value;
                value             = GetKeyValue(sdpStream);
            }

            // Connection optional
            if (value.Key == "c")
            {
                returnValue.Connection = Connection.Parse(value.Value);
                value = GetKeyValue(sdpStream);
            }

            // bandwidth optional
            if (value.Key == "b")
            {
                returnValue.Bandwidth = Bandwidth.Parse(value.Value);
                value = GetKeyValue(sdpStream);
            }

            // Timing mandatory
            while (value.Key == "t")
            {
                string timing = value.Value;
                string repeat = string.Empty;
                value = GetKeyValue(sdpStream);
                if (value.Key == "r")
                {
                    repeat = value.Value;
                    value  = GetKeyValue(sdpStream);
                }
                returnValue.Timings.Add(new Timing(timing, repeat));
            }

            // timezone optional
            if (value.Key == "z")
            {
                returnValue.TimeZone = SdpTimeZone.ParseInvariant(value.Value);
                value = GetKeyValue(sdpStream);
            }

            // encryption key optional
            if (value.Key == "k")
            {
                returnValue.EncriptionKey = EncriptionKey.ParseInvariant(value.Value);
                value = GetKeyValue(sdpStream);
            }

            //Attribute optional multiple
            while (value.Key == "a")
            {
                returnValue.Attributs.Add(Attribut.ParseInvariant(value.Value));
                value = GetKeyValue(sdpStream);
            }

            // Hack for MuxLab HDMI Encoder (TX-500762) Firmware 1.0.6
            // Skip over all other Key/Value pairs until the 'm=' key
            while (value.Key != "m")
            {
                value = GetKeyValue(sdpStream);
            }

            // Media
            while (value.Key == "m")
            {
                Media newMedia = ReadMedia(sdpStream, ref value);
                returnValue.Medias.Add(newMedia);
            }


            return(returnValue);
        }