Пример #1
0
        /// <summary>
        /// SendAppPacket is used to send application specific data to all other RtpListeners on the network.
        /// </summary>
        /// <param name="name">4 ASCII characters</param>
        /// <param name="subtype">0 to 31, app specific "type of data"</param>
        /// <param name="data">data is size sensitive, the total size of the packet cannot exceed 255 bytes</param>
        public void SendAppPacket(uint ssrc, string name, byte subtype, byte[] data, Rtcp.RtcpInterval when)
        {
            if(participant == null)
            {
                throw new RtcpSendingDisabledException("SendAppPacket not allowed in Rtcp " +
                    "listening only mode.");
            }

            // Add the packet to the AppPacket queue
            cpb.Add_APPReport(ssrc, name, subtype, data);

            if(when == Rtcp.RtcpInterval.Now)
            {
                rtcpSender.SendRtcpDataNow();
            }
        }
Пример #2
0
 /// <summary>
 /// Constructor which initializes header for use by derived packets
 /// </summary>
 protected RtcpPacket(Rtcp.PacketType type)
 {
     header = new RtcpHeader((byte)type);
 }
Пример #3
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;
                }
            }
        }
Пример #4
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;
        }
Пример #5
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;
        }
Пример #6
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;
        }