Пример #1
0
        private string GetProperty(Rtcp.SDESType type)
        {
            string ret = null;

            if (data[(int)type] != null)
            {
                lock (utf8)
                {
                    ret = utf8.GetString(data[(int)type]);
                }
            }

            return(ret);
        }
Пример #2
0
        private void WritePropertyToBuffer(Rtcp.SDESType type, byte[] data, BufferChunk buffer)
        {
            if (data != null)
            {
                // Type
                buffer += (byte)type;

                // Length
                buffer += (byte)data.Length;

                // Data
                if (data.Length != 0)
                {
                    buffer += data;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// ---------------------------------------------------------------------------------------
        /// 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                 ...
        /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        /// </summary>
        /// <param name="data"></param>
        private void SetProperty(string data, Rtcp.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;
        }
Пример #4
0
        /// <summary>
        /// ---------------------------------------------------------------------------------------
        /// 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                 ...
        /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        /// </summary>
        /// <param name="data"></param>
        private void SetProperty(string data, Rtcp.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("An SDES item's data can not exceed " +
                                                              "{0} UTF8 bytes: {1}, {2}",
                                                              MAX_PROPERTY_LENGTH, bytes.Length, data));
                }
            }

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