/// <summary>
        /// Creates a new RTCP compound packet from a serialised buffer.
        /// </summary>
        /// <param name="packet">The serialised RTCP compound packet to parse.</param>
        public RTCPCompoundPacket(byte[] packet)
        {
            int offset = 0;

            while (offset < packet.Length)
            {
                if (packet.Length - offset < RTCPHeader.HEADER_BYTES_LENGTH)
                {
                    // Not enough bytes left for a RTCP header.
                    break;
                }
                else
                {
                    var buffer = packet.Skip(offset).ToArray();

                    // The payload type field is the second byte in the RTCP header.
                    byte packetTypeID = buffer[1];
                    switch (packetTypeID)
                    {
                    case (byte)RTCPReportTypesEnum.SR:
                        SenderReport = new RTCPSenderReport(buffer);
                        int srLength = (SenderReport != null) ? SenderReport.GetBytes().Length : Int32.MaxValue;
                        offset += srLength;
                        break;

                    case (byte)RTCPReportTypesEnum.RR:
                        ReceiverReport = new RTCPReceiverReport(buffer);
                        int rrLength = (ReceiverReport != null) ? ReceiverReport.GetBytes().Length : Int32.MaxValue;
                        offset += rrLength;
                        break;

                    case (byte)RTCPReportTypesEnum.SDES:
                        SDesReport = new RTCPSDesReport(buffer);
                        int sdesLength = (SDesReport != null) ? SDesReport.GetBytes().Length : Int32.MaxValue;
                        offset += sdesLength;
                        break;

                    case (byte)RTCPReportTypesEnum.BYE:
                        Bye = new RTCPBye(buffer);
                        int byeLength = (Bye != null) ? Bye.GetBytes().Length : Int32.MaxValue;
                        offset += byeLength;
                        break;

                    case (byte)RTCPReportTypesEnum.RTPFB:
                        // TODO: Interpret Generic RTP feedback reports.
                        var rtpfbHeader = new RTCPHeader(buffer);
                        offset += rtpfbHeader.Length * 4 + 4;
                        break;

                    case (byte)RTCPReportTypesEnum.PSFB:
                        // TODO: Interpret Payload specific feedback reports.
                        var psfbHeader = new RTCPHeader(buffer);
                        offset += psfbHeader.Length * 4 + 4;
                        break;

                    default:
                        logger.LogWarning($"RTCPCompoundPacket did not recognise packet type ID {packetTypeID}.");
                        offset = Int32.MaxValue;
                        logger.LogWarning(packet.HexStr());
                        break;
                    }
                }
            }
        }
 public RTCPCompoundPacket(RTCPReceiverReport receiverReport, RTCPSDesReport sdesReport)
 {
     ReceiverReport = receiverReport;
     SDesReport     = sdesReport;
 }