NewTOAPIA.Net.Rtp.SdesData.SetProperty C# (CSharp) Method

SetProperty() private method

--------------------------------------------------------------------------------------- Purpose: --------------------------------------------------------------------------------------- Make sure the data will fit in the 255 bytes (length == 1 byte == byte.MaxValue) available to it when converted to UTF8 for transmission across the wire --------------------------------------------------------------------------------------- General structure of an SDES property: --------------------------------------------------------------------------------------- 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SDES=N | length | data ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
private SetProperty ( string data, SDESType type ) : void
data string
type SDESType
return void
        private void SetProperty(string data, SDESType type)
        {
            byte[] bytes = null;

            if (data != null)
            {
                lock (utf8)
                {
                    bytes = utf8.GetBytes(data);
                }

                // Check to see if it is too long
                if (bytes.Length > MAX_PROPERTY_LENGTH)
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.SDESItemDataBytesExceeded,
                        MAX_PROPERTY_LENGTH, bytes.Length, data));
                }
            }

            this.data[(int)type] = bytes;
        }