public void RoundtripRTCPCompoundPacketUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            uint  ssrc        = 23;
            ulong ntpTs       = 1;
            uint  rtpTs       = 2;
            uint  packetCount = 3;
            uint  octetCount  = 4;

            uint rrSsrc           = 5;
            byte fractionLost     = 6;
            int  packetsLost      = 7;
            uint highestSeqNum    = 8;
            uint jitter           = 9;
            uint lastSRTimestamp  = 10;
            uint delaySinceLastSR = 11;

            string cname = "dummy";

            ReceptionReportSample rr = new ReceptionReportSample(rrSsrc, fractionLost, packetsLost, highestSeqNum, jitter, lastSRTimestamp, delaySinceLastSR);
            var sr = new RTCPSenderReport(ssrc, ntpTs, rtpTs, packetCount, octetCount, new List <ReceptionReportSample> {
                rr
            });
            RTCPSDesReport sdesReport = new RTCPSDesReport(ssrc, cname);

            RTCPCompoundPacket compoundPacket = new RTCPCompoundPacket(sr, sdesReport);

            byte[] buffer = compoundPacket.GetBytes();

            RTCPCompoundPacket parsedCP = new RTCPCompoundPacket(buffer);
            RTCPSenderReport   parsedSR = parsedCP.SenderReport;

            Assert.Equal(ssrc, parsedSR.SSRC);
            Assert.Equal(ntpTs, parsedSR.NtpTimestamp);
            Assert.Equal(rtpTs, parsedSR.RtpTimestamp);
            Assert.Equal(packetCount, parsedSR.PacketCount);
            Assert.Equal(octetCount, parsedSR.OctetCount);
            Assert.True(parsedSR.ReceptionReports.Count == 1);

            Assert.Equal(rrSsrc, parsedSR.ReceptionReports.First().SSRC);
            Assert.Equal(fractionLost, parsedSR.ReceptionReports.First().FractionLost);
            Assert.Equal(packetsLost, parsedSR.ReceptionReports.First().PacketsLost);
            Assert.Equal(highestSeqNum, parsedSR.ReceptionReports.First().ExtendedHighestSequenceNumber);
            Assert.Equal(jitter, parsedSR.ReceptionReports.First().Jitter);
            Assert.Equal(lastSRTimestamp, parsedSR.ReceptionReports.First().LastSenderReportTimestamp);
            Assert.Equal(delaySinceLastSR, parsedSR.ReceptionReports.First().DelaySinceLastSenderReport);

            Assert.Equal(cname, parsedCP.SDesReport.CNAME);
        }
示例#2
0
        public void RoundtripRTCPSDesReportOnBoundaryUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            uint   ssrc  = 8;
            string cname = "ab123"; // 5 bytes + 1 byte for the item null termination.

            RTCPSDesReport sdesReport = new RTCPSDesReport(ssrc, cname);

            byte[] buffer = sdesReport.GetBytes();

            RTCPSDesReport parsedReport = new RTCPSDesReport(buffer);

            Assert.Equal(0x00, buffer[buffer.Length - 1]); // Items must be terminated with 0x00.
            Assert.Equal(ssrc, parsedReport.SSRC);
            Assert.Equal(cname, parsedReport.CNAME);
        }