Пример #1
0
        private void Parse(PDUStreamReader reader, SIPMsg msg)
        {
            var tag   = string.Empty;
            var value = string.Empty;

            // message body
            if (reader.Peek() > 0)
            {
                var line = reader.ReadLine();
                //Console.WriteLine("++ BODY ++");
                while (line != null)
                {
                    this.ParseSIPBodyLine(line, ref tag, ref value);
                    //Console.WriteLine("\"" + _tag + "\" : \"" + _value + "\"");
                    //Console.WriteLine(_line.Length.ToString() + ": \"" + _line.ToString() + "\"");
                    string[] values;
                    switch (tag)
                    {
                    case "c":
                        values = value.Split(' ');
                        if (values.Length < 2)
                        {
                            msg.Valid         = false;
                            msg.InvalidReason = "wrong format in message body: '" + line + "'";
                            return;
                        }
                        if (values[1] == "IP4")
                        {
                            this.RTPAddress = values[2];
                        }
                        break;

                    case "m":
                        values = value.Split(' ');
                        if (values.Length < 2)
                        {
                            msg.Valid         = false;
                            msg.InvalidReason = "wrong format in message body: '" + line + "'";
                            return;
                        }
                        this.RTPPort = values[1];
                        break;

                    case "a":
                        values = value.Split(' ');
                        if (values.Count() == 2 && values[0].Contains("rtpmap:"))    // codecs' descriptions
                        {
                            this.PossibleCodecs.Add(values[1] + " (" + values[0].Split(':')[1] + ")");
                        }
                        break;

                    default:
                        break;
                    }
                    line = reader.ReadLine();
                }
                //Console.WriteLine("---------");
            }
        }
Пример #2
0
        private void Parse(PDUStreamReader reader, SIPMsg msg)
        {
            var tag        = string.Empty;
            var value      = string.Empty;
            var parameters = new Dictionary <string, string>();
            var line       = reader.ReadLine();

            if (line == null)
            {
                msg.Valid         = false;
                msg.InvalidReason = "End of stream reached sooner than expected";
                return;
            }
            //Console.WriteLine("++ HEADER ++");
            while (line != null && line != "\n" && line != string.Empty)
            //while (_line != null && _line != "\n" && _line != string.Empty)
            {
                parameters.Clear();
                this.ParseSIPHeaderLine(line, ref tag, ref value, ref parameters);
                switch (tag)
                {
                case "To":
                case "t":
                    this.To += value;
                    break;

                case "From":
                case "f":
                    this.From += value;
                    break;

                case "Contact":
                    this.Contact += value;
                    break;

                case "Call-ID":
                case "CallID":
                case "i":
                    this.CallID += value;
                    //Console.WriteLine(_line);
                    break;

                default:
                    break;
                }
                line = reader.ReadLine();
            }
        }
Пример #3
0
        }                      //EF

        public SIPBody(PDUStreamReader reader, SIPMsg msg)
        {
            this.Parse(reader, msg);
        }