Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc

Issue 2368983002: Replace RtcpReceiveTimeInfo with rtcp::ReceiveTimeInfo (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 712 }
713 713
714 TEST_F(RtcpReceiverTest, InjectExtendedReportsReceiverReferenceTimePacket) { 714 TEST_F(RtcpReceiverTest, InjectExtendedReportsReceiverReferenceTimePacket) {
715 const NtpTime kNtp(0x10203, 0x40506); 715 const NtpTime kNtp(0x10203, 0x40506);
716 rtcp::Rrtr rrtr; 716 rtcp::Rrtr rrtr;
717 rrtr.SetNtp(kNtp); 717 rrtr.SetNtp(kNtp);
718 rtcp::ExtendedReports xr; 718 rtcp::ExtendedReports xr;
719 xr.SetSenderSsrc(kSenderSsrc); 719 xr.SetSenderSsrc(kSenderSsrc);
720 xr.AddRrtr(rrtr); 720 xr.AddRrtr(rrtr);
721 721
722 RtcpReceiveTimeInfo rrtime; 722 rtcp::ReceiveTimeInfo rrtime;
723 EXPECT_FALSE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime)); 723 EXPECT_FALSE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime));
724 724
725 InjectRtcpPacket(xr); 725 InjectRtcpPacket(xr);
726 726
727 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime)); 727 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime));
728 EXPECT_EQ(rrtime.sourceSSRC, kSenderSsrc); 728 EXPECT_EQ(rrtime.ssrc, kSenderSsrc);
729 EXPECT_EQ(rrtime.lastRR, CompactNtp(kNtp)); 729 EXPECT_EQ(rrtime.last_rr, CompactNtp(kNtp));
730 EXPECT_EQ(0u, rrtime.delaySinceLastRR); 730 EXPECT_EQ(0U, rrtime.delay_since_last_rr);
731 731
732 system_clock_.AdvanceTimeMilliseconds(1500); 732 system_clock_.AdvanceTimeMilliseconds(1500);
733 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime)); 733 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime));
734 EXPECT_NEAR(1500, CompactNtpRttToMs(rrtime.delaySinceLastRR), 1); 734 EXPECT_NEAR(1500, CompactNtpRttToMs(rrtime.delay_since_last_rr), 1);
735 } 735 }
736 736
737 TEST_F(RtcpReceiverTest, ExtendedReportsDlrrPacketNotToUsIgnored) { 737 TEST_F(RtcpReceiverTest, ExtendedReportsDlrrPacketNotToUsIgnored) {
738 // Allow calculate rtt using dlrr/rrtr, simulating media receiver side. 738 // Allow calculate rtt using dlrr/rrtr, simulating media receiver side.
739 rtcp_receiver_.SetRtcpXrRrtrStatus(true); 739 rtcp_receiver_.SetRtcpXrRrtrStatus(true);
740 740
741 rtcp::Dlrr dlrr; 741 rtcp::Dlrr dlrr;
742 dlrr.AddDlrrItem(kNotToUsSsrc, 0x12345, 0x67890); 742 dlrr.AddDlrrItem(kNotToUsSsrc, 0x12345, 0x67890);
743 rtcp::ExtendedReports xr; 743 rtcp::ExtendedReports xr;
744 xr.SetSenderSsrc(kSenderSsrc); 744 xr.SetSenderSsrc(kSenderSsrc);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 rtcp::VoipMetric metric; 802 rtcp::VoipMetric metric;
803 metric.SetMediaSsrc(kReceiverMainSsrc); 803 metric.SetMediaSsrc(kReceiverMainSsrc);
804 rtcp::ExtendedReports xr; 804 rtcp::ExtendedReports xr;
805 xr.SetSenderSsrc(kSenderSsrc); 805 xr.SetSenderSsrc(kSenderSsrc);
806 xr.AddRrtr(rrtr); 806 xr.AddRrtr(rrtr);
807 xr.AddDlrr(dlrr); 807 xr.AddDlrr(dlrr);
808 xr.AddVoipMetric(metric); 808 xr.AddVoipMetric(metric);
809 809
810 InjectRtcpPacket(xr); 810 InjectRtcpPacket(xr);
811 811
812 RtcpReceiveTimeInfo rrtime; 812 rtcp::ReceiveTimeInfo rrtime;
813 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime)); 813 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime));
814 int64_t rtt_ms = 0; 814 int64_t rtt_ms = 0;
815 EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)); 815 EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms));
816 } 816 }
817 817
818 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithUnknownReportBlock) { 818 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithUnknownReportBlock) {
819 rtcp_receiver_.SetRtcpXrRrtrStatus(true); 819 rtcp_receiver_.SetRtcpXrRrtrStatus(true);
820 820
821 rtcp::Rrtr rrtr; 821 rtcp::Rrtr rrtr;
822 rtcp::Dlrr dlrr; 822 rtcp::Dlrr dlrr;
823 dlrr.AddDlrrItem(kReceiverMainSsrc, 0x12345, 0x67890); 823 dlrr.AddDlrrItem(kReceiverMainSsrc, 0x12345, 0x67890);
824 rtcp::VoipMetric metric; 824 rtcp::VoipMetric metric;
825 metric.SetMediaSsrc(kReceiverMainSsrc); 825 metric.SetMediaSsrc(kReceiverMainSsrc);
826 rtcp::ExtendedReports xr; 826 rtcp::ExtendedReports xr;
827 xr.SetSenderSsrc(kSenderSsrc); 827 xr.SetSenderSsrc(kSenderSsrc);
828 xr.AddRrtr(rrtr); 828 xr.AddRrtr(rrtr);
829 xr.AddDlrr(dlrr); 829 xr.AddDlrr(dlrr);
830 xr.AddVoipMetric(metric); 830 xr.AddVoipMetric(metric);
831 831
832 rtc::Buffer packet = xr.Build(); 832 rtc::Buffer packet = xr.Build();
833 // Modify the DLRR block to have an unsupported block type, from 5 to 6. 833 // Modify the DLRR block to have an unsupported block type, from 5 to 6.
834 ASSERT_EQ(5, packet.data()[20]); 834 ASSERT_EQ(5, packet.data()[20]);
835 packet.data()[20] = 6; 835 packet.data()[20] = 6;
836 InjectRtcpPacket(packet); 836 InjectRtcpPacket(packet);
837 837
838 // Validate Rrtr was received and processed. 838 // Validate Rrtr was received and processed.
839 RtcpReceiveTimeInfo rrtime; 839 rtcp::ReceiveTimeInfo rrtime;
840 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime)); 840 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&rrtime));
841 // Validate Dlrr report wasn't processed. 841 // Validate Dlrr report wasn't processed.
842 int64_t rtt_ms = 0; 842 int64_t rtt_ms = 0;
843 EXPECT_FALSE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)); 843 EXPECT_FALSE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms));
844 } 844 }
845 845
846 TEST_F(RtcpReceiverTest, TestExtendedReportsRrRttInitiallyFalse) { 846 TEST_F(RtcpReceiverTest, TestExtendedReportsRrRttInitiallyFalse) {
847 rtcp_receiver_.SetRtcpXrRrtrStatus(true); 847 rtcp_receiver_.SetRtcpXrRrtrStatus(true);
848 848
849 int64_t rtt_ms; 849 int64_t rtt_ms;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 xr.AddDlrr(dlrr); 890 xr.AddDlrr(dlrr);
891 891
892 InjectRtcpPacket(xr); 892 InjectRtcpPacket(xr);
893 893
894 int64_t rtt_ms = 0; 894 int64_t rtt_ms = 0;
895 EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)); 895 EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms));
896 EXPECT_EQ(1, rtt_ms); 896 EXPECT_EQ(1, rtt_ms);
897 } 897 }
898 898
899 TEST_F(RtcpReceiverTest, LastReceivedXrReferenceTimeInfoInitiallyFalse) { 899 TEST_F(RtcpReceiverTest, LastReceivedXrReferenceTimeInfoInitiallyFalse) {
900 RtcpReceiveTimeInfo info; 900 rtcp::ReceiveTimeInfo info;
901 EXPECT_FALSE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info)); 901 EXPECT_FALSE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info));
902 } 902 }
903 903
904 TEST_F(RtcpReceiverTest, GetLastReceivedExtendedReportsReferenceTimeInfo) { 904 TEST_F(RtcpReceiverTest, GetLastReceivedExtendedReportsReferenceTimeInfo) {
905 const NtpTime kNtp(0x10203, 0x40506); 905 const NtpTime kNtp(0x10203, 0x40506);
906 const uint32_t kNtpMid = CompactNtp(kNtp); 906 const uint32_t kNtpMid = CompactNtp(kNtp);
907 907
908 rtcp::Rrtr rrtr; 908 rtcp::Rrtr rrtr;
909 rrtr.SetNtp(kNtp); 909 rrtr.SetNtp(kNtp);
910 rtcp::ExtendedReports xr; 910 rtcp::ExtendedReports xr;
911 xr.SetSenderSsrc(kSenderSsrc); 911 xr.SetSenderSsrc(kSenderSsrc);
912 xr.AddRrtr(rrtr); 912 xr.AddRrtr(rrtr);
913 913
914 InjectRtcpPacket(xr); 914 InjectRtcpPacket(xr);
915 915
916 RtcpReceiveTimeInfo info; 916 rtcp::ReceiveTimeInfo info;
917 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info)); 917 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info));
918 EXPECT_EQ(kSenderSsrc, info.sourceSSRC); 918 EXPECT_EQ(kSenderSsrc, info.ssrc);
919 EXPECT_EQ(kNtpMid, info.lastRR); 919 EXPECT_EQ(kNtpMid, info.last_rr);
920 EXPECT_EQ(0U, info.delaySinceLastRR); 920 EXPECT_EQ(0U, info.delay_since_last_rr);
921 921
922 system_clock_.AdvanceTimeMilliseconds(1000); 922 system_clock_.AdvanceTimeMilliseconds(1000);
923 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info)); 923 EXPECT_TRUE(rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&info));
924 EXPECT_EQ(65536U, info.delaySinceLastRR); 924 EXPECT_EQ(65536U, info.delay_since_last_rr);
925 } 925 }
926 926
927 TEST_F(RtcpReceiverTest, ReceiveReportTimeout) { 927 TEST_F(RtcpReceiverTest, ReceiveReportTimeout) {
928 const int64_t kRtcpIntervalMs = 1000; 928 const int64_t kRtcpIntervalMs = 1000;
929 const uint16_t kSequenceNumber = 1234; 929 const uint16_t kSequenceNumber = 1234;
930 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs); 930 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs);
931 931
932 // No RR received, shouldn't trigger a timeout. 932 // No RR received, shouldn't trigger a timeout.
933 EXPECT_FALSE(rtcp_receiver_.RtcpRrTimeout(kRtcpIntervalMs)); 933 EXPECT_FALSE(rtcp_receiver_.RtcpRrTimeout(kRtcpIntervalMs));
934 EXPECT_FALSE(rtcp_receiver_.RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); 934 EXPECT_FALSE(rtcp_receiver_.RtcpRrSequenceNumberTimeout(kRtcpIntervalMs));
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 TEST_F(RtcpReceiverTest, ForceSenderReport) { 1261 TEST_F(RtcpReceiverTest, ForceSenderReport) {
1262 rtcp::RapidResyncRequest rr; 1262 rtcp::RapidResyncRequest rr;
1263 rr.SetSenderSsrc(kSenderSsrc); 1263 rr.SetSenderSsrc(kSenderSsrc);
1264 rr.SetMediaSsrc(kReceiverMainSsrc); 1264 rr.SetMediaSsrc(kReceiverMainSsrc);
1265 1265
1266 EXPECT_CALL(rtp_rtcp_impl_, OnRequestSendReport()); 1266 EXPECT_CALL(rtp_rtcp_impl_, OnRequestSendReport());
1267 InjectRtcpPacket(rr); 1267 InjectRtcpPacket(rr);
1268 } 1268 }
1269 1269
1270 } // namespace webrtc 1270 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698