bandwidthfield.cs

来自「pureIRCd是一个用c语音写的irc(RFC459)服务,可以给您带来很多的」· CS 代码 · 共 66 行

CS
66
字号
using System;
namespace SDP
{
    /// <summary>
    /// A Bandwidth represents the b= field within MediaDescriptions and SessionDescriptions.
    /// 
    /// This specifies the proposed bandwidth to be used by the session or media, and is optional.
    /// Multiple bandwidth specifiers of different types may be associated with the same
    /// SessionDescription. Each consists of a token type and an integer value measuring the
    /// bandwidth in kilobits per second.
    /// </summary>
    public class BandwidthField : Field
    {
        private string modifier;
        /// <summary>
        /// Gets the bandwidth modifier.
        /// </summary>
        public string Modifier
        {
            get { return this.modifier; }
        }

        private int bandwidth;
        /// <summary>
        /// Gets the bandwidth value in kilobits per second.
        /// </summary>
        public int Bandwidth
        {
            get { return this.bandwidth; }
        }

        /// <summary>
        /// Creates a new BandwidthField
        /// </summary>
        /// <param name="modifier">The bandwidth modifier. Usually either "CT" or "AS".</param>
        /// <param name="bandwidth">The maximum bandwidth in kilobits per second.</param>
        public BandwidthField(string modifier, int bandwidth)
            : base("b", modifier + ":" + bandwidth)
        {
            this.modifier = modifier;
            this.bandwidth = bandwidth;
        }

        /// <summary>
        /// Creates a new BandwidthField
        /// </summary>
        /// <param name="value">The field's value.</param>
        public BandwidthField(string value)
            : base("b=" + value)
        {
            string val = base.Value;
            string[] parts = val.Split(':');
            if (parts.Length != 2) throw new ArgumentException("Invalid bandwidth field.");
            this.modifier = parts[0];
            this.bandwidth = int.Parse(parts[1]);
        }

        /// <summary>
        /// Gets the value portion of the field.
        /// </summary>
        public override string Value
        {
            get { return modifier + ":" + bandwidth; }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?