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

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

Issue 1557593002: [rtp_rtcp] rtcp::ExtenededReports packet got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase & fix win compile errors Created 4 years, 10 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 595 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
596 596
597 const uint8_t kLossRate = 123; 597 const uint8_t kLossRate = 123;
598 rtcp::VoipMetric voip_metric; 598 rtcp::VoipMetric voip_metric;
599 voip_metric.To(kSourceSsrc); 599 voip_metric.To(kSourceSsrc);
600 RTCPVoIPMetric metric; 600 RTCPVoIPMetric metric;
601 metric.lossRate = kLossRate; 601 metric.lossRate = kLossRate;
602 voip_metric.WithVoipMetric(metric); 602 voip_metric.WithVoipMetric(metric);
603 rtcp::ExtendedReports xr; 603 rtcp::ExtendedReports xr;
604 xr.From(0x2345); 604 xr.From(0x2345);
605 xr.WithVoipMetric(&voip_metric); 605 xr.WithVoipMetric(voip_metric);
606 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 606 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
607 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 607 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
608 ASSERT_TRUE(rtcp_packet_info_.VoIPMetric != nullptr); 608 ASSERT_TRUE(rtcp_packet_info_.VoIPMetric != nullptr);
609 EXPECT_EQ(kLossRate, rtcp_packet_info_.VoIPMetric->lossRate); 609 EXPECT_EQ(kLossRate, rtcp_packet_info_.VoIPMetric->lossRate);
610 EXPECT_EQ(kRtcpXrVoipMetric, rtcp_packet_info_.rtcpPacketTypeFlags); 610 EXPECT_EQ(kRtcpXrVoipMetric, rtcp_packet_info_.rtcpPacketTypeFlags);
611 } 611 }
612 612
613 TEST_F(RtcpReceiverTest, ExtendedReportsVoipPacketNotToUsIgnored) { 613 TEST_F(RtcpReceiverTest, ExtendedReportsVoipPacketNotToUsIgnored) {
614 const uint32_t kSourceSsrc = 0x123456; 614 const uint32_t kSourceSsrc = 0x123456;
615 std::set<uint32_t> ssrcs; 615 std::set<uint32_t> ssrcs;
616 ssrcs.insert(kSourceSsrc); 616 ssrcs.insert(kSourceSsrc);
617 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 617 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
618 618
619 rtcp::VoipMetric voip_metric; 619 rtcp::VoipMetric voip_metric;
620 voip_metric.To(kSourceSsrc + 1); 620 voip_metric.To(kSourceSsrc + 1);
621 rtcp::ExtendedReports xr; 621 rtcp::ExtendedReports xr;
622 xr.From(0x2345); 622 xr.From(0x2345);
623 xr.WithVoipMetric(&voip_metric); 623 xr.WithVoipMetric(voip_metric);
624 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 624 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
625 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 625 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
626 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); 626 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
627 } 627 }
628 628
629 TEST_F(RtcpReceiverTest, InjectExtendedReportsReceiverReferenceTimePacket) { 629 TEST_F(RtcpReceiverTest, InjectExtendedReportsReceiverReferenceTimePacket) {
630 rtcp::Rrtr rrtr; 630 rtcp::Rrtr rrtr;
631 rrtr.WithNtp(NtpTime(0x10203, 0x40506)); 631 rrtr.WithNtp(NtpTime(0x10203, 0x40506));
632 rtcp::ExtendedReports xr; 632 rtcp::ExtendedReports xr;
633 xr.From(0x2345); 633 xr.From(0x2345);
634 xr.WithRrtr(&rrtr); 634 xr.WithRrtr(rrtr);
635 635
636 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 636 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
637 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 637 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
638 EXPECT_EQ(kRtcpXrReceiverReferenceTime, 638 EXPECT_EQ(kRtcpXrReceiverReferenceTime,
639 rtcp_packet_info_.rtcpPacketTypeFlags); 639 rtcp_packet_info_.rtcpPacketTypeFlags);
640 } 640 }
641 641
642 TEST_F(RtcpReceiverTest, ExtendedReportsDlrrPacketNotToUsIgnored) { 642 TEST_F(RtcpReceiverTest, ExtendedReportsDlrrPacketNotToUsIgnored) {
643 const uint32_t kSourceSsrc = 0x123456; 643 const uint32_t kSourceSsrc = 0x123456;
644 std::set<uint32_t> ssrcs; 644 std::set<uint32_t> ssrcs;
645 ssrcs.insert(kSourceSsrc); 645 ssrcs.insert(kSourceSsrc);
646 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 646 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
647 647
648 rtcp::Dlrr dlrr; 648 rtcp::Dlrr dlrr;
649 dlrr.WithDlrrItem(kSourceSsrc + 1, 0x12345, 0x67890); 649 dlrr.WithDlrrItem(kSourceSsrc + 1, 0x12345, 0x67890);
650 rtcp::ExtendedReports xr; 650 rtcp::ExtendedReports xr;
651 xr.From(0x2345); 651 xr.From(0x2345);
652 xr.WithDlrr(&dlrr); 652 xr.WithDlrr(dlrr);
653 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 653 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
654 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 654 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
655 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); 655 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
656 EXPECT_FALSE(rtcp_packet_info_.xr_dlrr_item); 656 EXPECT_FALSE(rtcp_packet_info_.xr_dlrr_item);
657 } 657 }
658 658
659 TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithSubBlock) { 659 TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithSubBlock) {
660 const uint32_t kSourceSsrc = 0x123456; 660 const uint32_t kSourceSsrc = 0x123456;
661 std::set<uint32_t> ssrcs; 661 std::set<uint32_t> ssrcs;
662 ssrcs.insert(kSourceSsrc); 662 ssrcs.insert(kSourceSsrc);
663 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 663 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
664 664
665 rtcp::Dlrr dlrr; 665 rtcp::Dlrr dlrr;
666 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890); 666 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890);
667 rtcp::ExtendedReports xr; 667 rtcp::ExtendedReports xr;
668 xr.From(0x2345); 668 xr.From(0x2345);
669 xr.WithDlrr(&dlrr); 669 xr.WithDlrr(dlrr);
670 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 670 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
671 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 671 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
672 // The parser should note the DLRR report block item, but not flag the packet 672 // The parser should note the DLRR report block item, but not flag the packet
673 // since the RTT is not estimated. 673 // since the RTT is not estimated.
674 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item); 674 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item);
675 } 675 }
676 676
677 TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithMultipleSubBlocks) { 677 TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithMultipleSubBlocks) {
678 const uint32_t kSourceSsrc = 0x123456; 678 const uint32_t kSourceSsrc = 0x123456;
679 std::set<uint32_t> ssrcs; 679 std::set<uint32_t> ssrcs;
680 ssrcs.insert(kSourceSsrc); 680 ssrcs.insert(kSourceSsrc);
681 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 681 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
682 682
683 rtcp::Dlrr dlrr; 683 rtcp::Dlrr dlrr;
684 dlrr.WithDlrrItem(kSourceSsrc + 1, 0x12345, 0x67890); 684 dlrr.WithDlrrItem(kSourceSsrc + 1, 0x12345, 0x67890);
685 dlrr.WithDlrrItem(kSourceSsrc + 2, 0x12345, 0x67890); 685 dlrr.WithDlrrItem(kSourceSsrc + 2, 0x12345, 0x67890);
686 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890); 686 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890);
687 rtcp::ExtendedReports xr; 687 rtcp::ExtendedReports xr;
688 xr.From(0x2345); 688 xr.From(0x2345);
689 xr.WithDlrr(&dlrr); 689 xr.WithDlrr(dlrr);
690 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 690 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
691 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 691 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
692 // The parser should note the DLRR report block item, but not flag the packet 692 // The parser should note the DLRR report block item, but not flag the packet
693 // since the RTT is not estimated. 693 // since the RTT is not estimated.
694 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item); 694 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item);
695 } 695 }
696 696
697 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithMultipleReportBlocks) { 697 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithMultipleReportBlocks) {
698 const uint32_t kSourceSsrc = 0x123456; 698 const uint32_t kSourceSsrc = 0x123456;
699 std::set<uint32_t> ssrcs; 699 std::set<uint32_t> ssrcs;
700 ssrcs.insert(kSourceSsrc); 700 ssrcs.insert(kSourceSsrc);
701 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 701 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
702 702
703 rtcp::Rrtr rrtr; 703 rtcp::Rrtr rrtr;
704 rtcp::Dlrr dlrr; 704 rtcp::Dlrr dlrr;
705 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890); 705 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890);
706 rtcp::VoipMetric metric; 706 rtcp::VoipMetric metric;
707 metric.To(kSourceSsrc); 707 metric.To(kSourceSsrc);
708 rtcp::ExtendedReports xr; 708 rtcp::ExtendedReports xr;
709 xr.From(0x2345); 709 xr.From(0x2345);
710 xr.WithRrtr(&rrtr); 710 xr.WithRrtr(rrtr);
711 xr.WithDlrr(&dlrr); 711 xr.WithDlrr(dlrr);
712 xr.WithVoipMetric(&metric); 712 xr.WithVoipMetric(metric);
713 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 713 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
714 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 714 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
715 EXPECT_EQ(static_cast<unsigned int>(kRtcpXrReceiverReferenceTime + 715 EXPECT_EQ(static_cast<unsigned int>(kRtcpXrReceiverReferenceTime +
716 kRtcpXrVoipMetric), 716 kRtcpXrVoipMetric),
717 rtcp_packet_info_.rtcpPacketTypeFlags); 717 rtcp_packet_info_.rtcpPacketTypeFlags);
718 // The parser should note the DLRR report block item, but not flag the packet 718 // The parser should note the DLRR report block item, but not flag the packet
719 // since the RTT is not estimated. 719 // since the RTT is not estimated.
720 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item); 720 EXPECT_TRUE(rtcp_packet_info_.xr_dlrr_item);
721 } 721 }
722 722
723 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithUnknownReportBlock) { 723 TEST_F(RtcpReceiverTest, InjectExtendedReportsPacketWithUnknownReportBlock) {
724 const uint32_t kSourceSsrc = 0x123456; 724 const uint32_t kSourceSsrc = 0x123456;
725 std::set<uint32_t> ssrcs; 725 std::set<uint32_t> ssrcs;
726 ssrcs.insert(kSourceSsrc); 726 ssrcs.insert(kSourceSsrc);
727 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 727 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
728 std::vector<uint32_t> remote_ssrcs; 728 std::vector<uint32_t> remote_ssrcs;
729 remote_ssrcs.push_back(kSourceSsrc); 729 remote_ssrcs.push_back(kSourceSsrc);
730 730
731 rtcp::Rrtr rrtr; 731 rtcp::Rrtr rrtr;
732 rtcp::Dlrr dlrr; 732 rtcp::Dlrr dlrr;
733 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890); 733 dlrr.WithDlrrItem(kSourceSsrc, 0x12345, 0x67890);
734 rtcp::VoipMetric metric; 734 rtcp::VoipMetric metric;
735 metric.To(kSourceSsrc); 735 metric.To(kSourceSsrc);
736 rtcp::ExtendedReports xr; 736 rtcp::ExtendedReports xr;
737 xr.From(0x2345); 737 xr.From(0x2345);
738 xr.WithRrtr(&rrtr); 738 xr.WithRrtr(rrtr);
739 xr.WithDlrr(&dlrr); 739 xr.WithDlrr(dlrr);
740 xr.WithVoipMetric(&metric); 740 xr.WithVoipMetric(metric);
741 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 741 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
742 // Modify the DLRR block to have an unsupported block type, from 5 to 6. 742 // Modify the DLRR block to have an unsupported block type, from 5 to 6.
743 uint8_t* buffer = const_cast<uint8_t*>(packet->Buffer()); 743 uint8_t* buffer = const_cast<uint8_t*>(packet->Buffer());
744 EXPECT_EQ(5, buffer[20]); 744 EXPECT_EQ(5, buffer[20]);
745 buffer[20] = 6; 745 buffer[20] = 6;
746 746
747 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 747 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
748 EXPECT_EQ(static_cast<unsigned int>(kRtcpXrReceiverReferenceTime + 748 EXPECT_EQ(static_cast<unsigned int>(kRtcpXrReceiverReferenceTime +
749 kRtcpXrVoipMetric), 749 kRtcpXrVoipMetric),
750 rtcp_packet_info_.rtcpPacketTypeFlags); 750 rtcp_packet_info_.rtcpPacketTypeFlags);
(...skipping 13 matching lines...) Expand all
764 TEST_F(RtcpReceiverTest, GetLastReceivedExtendedReportsReferenceTimeInfo) { 764 TEST_F(RtcpReceiverTest, GetLastReceivedExtendedReportsReferenceTimeInfo) {
765 const uint32_t kSenderSsrc = 0x123456; 765 const uint32_t kSenderSsrc = 0x123456;
766 const NtpTime kNtp(0x10203, 0x40506); 766 const NtpTime kNtp(0x10203, 0x40506);
767 const uint32_t kNtpMid = 767 const uint32_t kNtpMid =
768 RTCPUtility::MidNtp(kNtp.seconds(), kNtp.fractions()); 768 RTCPUtility::MidNtp(kNtp.seconds(), kNtp.fractions());
769 769
770 rtcp::Rrtr rrtr; 770 rtcp::Rrtr rrtr;
771 rrtr.WithNtp(kNtp); 771 rrtr.WithNtp(kNtp);
772 rtcp::ExtendedReports xr; 772 rtcp::ExtendedReports xr;
773 xr.From(kSenderSsrc); 773 xr.From(kSenderSsrc);
774 xr.WithRrtr(&rrtr); 774 xr.WithRrtr(rrtr);
775 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build()); 775 rtc::scoped_ptr<rtcp::RawPacket> packet(xr.Build());
776 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); 776 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length()));
777 EXPECT_EQ(kRtcpXrReceiverReferenceTime, 777 EXPECT_EQ(kRtcpXrReceiverReferenceTime,
778 rtcp_packet_info_.rtcpPacketTypeFlags); 778 rtcp_packet_info_.rtcpPacketTypeFlags);
779 779
780 RtcpReceiveTimeInfo info; 780 RtcpReceiveTimeInfo info;
781 EXPECT_TRUE(rtcp_receiver_->LastReceivedXrReferenceTimeInfo(&info)); 781 EXPECT_TRUE(rtcp_receiver_->LastReceivedXrReferenceTimeInfo(&info));
782 EXPECT_EQ(kSenderSsrc, info.sourceSSRC); 782 EXPECT_EQ(kSenderSsrc, info.sourceSSRC);
783 EXPECT_EQ(kNtpMid, info.lastRR); 783 EXPECT_EQ(kNtpMid, info.lastRR);
784 EXPECT_EQ(0U, info.delaySinceLastRR); 784 EXPECT_EQ(0U, info.delaySinceLastRR);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 // Transport feedback should be ignored, but next packet should work. 1100 // Transport feedback should be ignored, but next packet should work.
1101 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); 1101 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback);
1102 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); 1102 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb);
1103 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); 1103 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate);
1104 } 1104 }
1105 1105
1106 } // Anonymous namespace 1106 } // Anonymous namespace
1107 1107
1108 } // namespace webrtc 1108 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698