Esempio n. 1
0
        /// <summary>
        /// Serialises a compound RTCP packet to a byte array ready for transmission.
        /// </summary>
        /// <returns>A byte array representing a serialised compound RTCP packet.</returns>
        public byte[] GetBytes()
        {
            if (SenderReport == null && ReceiverReport == null)
            {
                throw new ApplicationException("An RTCP compound packet must have either a Sender or Receiver report set.");
            }
            else if (SDesReport == null)
            {
                throw new ApplicationException("An RTCP compound packet must have an SDES report set.");
            }

            List <byte> compoundBuffer = new List <byte>();

            compoundBuffer.AddRange((SenderReport != null) ? SenderReport.GetBytes() : ReceiverReport.GetBytes());
            compoundBuffer.AddRange(SDesReport.GetBytes());

            if (Bye != null)
            {
                compoundBuffer.AddRange(Bye.GetBytes());
            }

            return(compoundBuffer.ToArray());
        }
Esempio n. 2
0
        public void updateSenderState(SenderReport report, long when)
        {
            if (when <= lastSendUpdate)
            {
                return; // duplicate
            }
            if (lastSendUpdate != 0)
            {
                double bytesSentThisInterval   = (report.BytesSent - this.bytesSent);
                double packetsSentThisInterval = (report.PacketCount - this.packetsSent);

                double seconds = ((double)(when - lastSendUpdate)) / TimeSpan.TicksPerSecond;

                // convert to bits and kilobits
                dataRate   = 8 * bytesSentThisInterval / seconds / 1000.0;
                packetRate = packetsSentThisInterval / seconds;
            }

            // update state
            this.bytesSent      = report.BytesSent;
            this.packetsSent    = report.PacketCount;
            this.lastSendUpdate = when;
        }