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

SetPrivateExtension() public method

Add a private extension to the SDES data This method validates the data will fit in the 255 bytes (length = (1 Byte) = 255 max) available when converted to UTF8 for transmission across the wire and then stores it --------------------------------------------------------------------------------------- Structure: --------------------------------------------------------------------------------------- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PRIV=8 | length | prefix length |prefix string... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... | value string ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
public SetPrivateExtension ( string prefix, string data ) : void
prefix string Name of the extension
data string Value of the extension
return void
        public void SetPrivateExtension(string prefix, string data)
        {
            // Prefix cannot be null, it is the hashtable key
            if (prefix == null)
            {
                throw new ArgumentNullException(Strings.Prefix);
            }

            byte[] prefixBytes;

            lock (utf8)
            {
                prefixBytes = utf8.GetBytes(prefix);
            }

            // Data can be null though, if the prefix communicates enough data
            byte[] dataBytes = null;
            int dataLength = 0;

            if (data != null)
            {
                lock (utf8)
                {
                    dataBytes = utf8.GetBytes(data);
                    dataLength = dataBytes.Length;
                }
            }

            // Check to see if it is too long
            if (prefixBytes.Length + dataLength > MAX_PRIV_PROPERTY_LENGTH)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.PrefixAndDataBytesExceeded,
                    MAX_PRIV_PROPERTY_LENGTH));
            }

            SetPrivateExtension(prefixBytes, dataBytes);
        }

Same methods

SdesData::SetPrivateExtension ( byte prefix, byte data ) : void