コード例 #1
0
ファイル: SdpRtpMap.cs プロジェクト: tuanvinhtl/gsDemo
        public static SdpRtpMap Parse(string str)
        {
            var match = REGEX.Match(str);

            if (!match.Success)
            {
                throw new SdpParseException($"Unable to parse malformed rtpmap attriute '{str}'");
            }

            try
            {
                var builder = SdpRtpMap.CreateBuilder()
                              .PayloadType(ushort.Parse(match.Groups[1].Value))
                              .EncodingName(match.Groups[2].Value.Trim())
                              .ClockRate(uint.Parse(match.Groups[3].Value));

                if (match.Groups.Count == 6)
                {
                    builder.EncodingParameters(match.Groups[5].Value.Trim());
                }

                return(builder.Build());
            }
            catch (Exception e)
            {
                throw new SdpParseException($"Unable to parse rtpmap attribute '{str}'", e);
            }
        }
コード例 #2
0
ファイル: MediaDescription.cs プロジェクト: tuanvinhtl/gsDemo
        /// <summary>
        /// Returns the assocciated rtpmap attributes as a list of <see cref="SdpRtpMap"/>
        /// instances.
        /// </summary>
        /// <exception cref="SdpParseException">If a rtpmap attribuet is malformed.</exception>
        /// <returns></returns>
        public ImmutableList <SdpRtpMap> GetRtpMaps()
        {
            var builder = ImmutableList.CreateBuilder <SdpRtpMap>();

            Attributes.Where(a => "rtpmap" == a.Name).ToList().ForEach(a =>
            {
                builder.Add(SdpRtpMap.Parse(a.Value));
            });

            return(builder.ToImmutable());
        }