Exemplo n.º 1
0
 private static void ParseAttributes(Rtsp.Sdp.SdpFile sdpData, int x, out string control, out Rtsp.Sdp.AttributFmtp fmtp, out Rtsp.Sdp.AttributRtpMap rtpmap)
 {
     control = "";
     fmtp    = null;
     rtpmap  = null;
     foreach (Rtsp.Sdp.Attribut attrib in sdpData.Medias[x].Attributs)
     {
         if (attrib.Key.Equals("control"))
         {
             control = attrib.Value;
         }
         if (attrib.Key.Equals("fmtp"))
         {
             fmtp = attrib as Rtsp.Sdp.AttributFmtp;
         }
         if (attrib.Key.Equals("rtpmap"))
         {
             rtpmap = attrib as Rtsp.Sdp.AttributRtpMap;
         }
     }
 }
Exemplo n.º 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);
            }
            else
                throw new InvalidDataException();
            value = GetKeyValue(sdpStream);

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

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

            // Session 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);
            }

            // Connexion 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
            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);
            }

            // enkription key optional
            if (value.Key == "k")
            {

                returnValue.EncriptionKey = EncriptionKey.ParseInvariant(value.Value);
                value = GetKeyValue(sdpStream);
            }

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

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

            return returnValue;
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
            }
            else
            {
                throw new InvalidDataException();
            }
            value = GetKeyValue(sdpStream);

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

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

            // Session 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);
            }

            // Connexion 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
            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);
            }

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

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

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


            return(returnValue);
        }