OLD | NEW |
---|---|
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 |
11 | 11 |
12 /* | 12 /* |
13 * This file includes unit tests for the RTCPSender. | 13 * This file includes unit tests for the RTCPSender. |
14 */ | 14 */ |
15 | 15 |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
23 #include "webrtc/test/mock_transport.h" | |
22 #include "webrtc/test/rtcp_packet_parser.h" | 24 #include "webrtc/test/rtcp_packet_parser.h" |
23 | 25 |
26 using ::testing::_; | |
24 using ::testing::ElementsAre; | 27 using ::testing::ElementsAre; |
28 using ::testing::Invoke; | |
29 using webrtc::RTCPUtility::RtcpCommonHeader; | |
25 | 30 |
26 namespace webrtc { | 31 namespace webrtc { |
27 | 32 |
28 TEST(NACKStringBuilderTest, TestCase1) { | 33 TEST(NACKStringBuilderTest, TestCase1) { |
29 NACKStringBuilder builder; | 34 NACKStringBuilder builder; |
30 builder.PushNACK(5); | 35 builder.PushNACK(5); |
31 builder.PushNACK(7); | 36 builder.PushNACK(7); |
32 builder.PushNACK(9); | 37 builder.PushNACK(9); |
33 builder.PushNACK(10); | 38 builder.PushNACK(10); |
34 builder.PushNACK(11); | 39 builder.PushNACK(11); |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound); | 759 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound); |
755 rtcp_sender_->SetREMBData(kBitrate, ssrcs); | 760 rtcp_sender_->SetREMBData(kBitrate, ssrcs); |
756 std::set<RTCPPacketType> packet_types; | 761 std::set<RTCPPacketType> packet_types; |
757 packet_types.insert(kRtcpRemb); | 762 packet_types.insert(kRtcpRemb); |
758 packet_types.insert(kRtcpPli); | 763 packet_types.insert(kRtcpPli); |
759 EXPECT_EQ(0, rtcp_sender_->SendCompoundRTCP(feedback_state(), packet_types)); | 764 EXPECT_EQ(0, rtcp_sender_->SendCompoundRTCP(feedback_state(), packet_types)); |
760 EXPECT_EQ(1, parser()->remb_item()->num_packets()); | 765 EXPECT_EQ(1, parser()->remb_item()->num_packets()); |
761 EXPECT_EQ(1, parser()->pli()->num_packets()); | 766 EXPECT_EQ(1, parser()->pli()->num_packets()); |
762 } | 767 } |
763 | 768 |
769 | |
770 // This test is written to verify that BYE is always the last packet | |
771 // type in a RTCP compoud packet. The rtcp_sender_ is recreated with | |
772 // mock_transport, which is used to check for whether BYE at the end | |
773 // of a RTCP compound packet. | |
774 // See https://bugs.chromium.org/p/webrtc/issues/detail?id=5498 for | |
775 // details. | |
stefan-webrtc
2016/02/17 09:47:04
I think we can remove the link to the bug, as this
| |
776 TEST_F(RtcpSenderTest, ByeMustBeLast) { | |
777 MockTransport mock_transport; | |
778 EXPECT_CALL(mock_transport, SendRtcp(_, _)) | |
779 .WillOnce(Invoke([](const uint8_t* data, size_t len) { | |
780 const uint8_t* next_packet = data; | |
781 while (next_packet < data + len) { | |
782 RtcpCommonHeader header; | |
783 RtcpParseCommonHeader(next_packet, len - (next_packet - data), &header); | |
784 next_packet = next_packet + | |
785 header.payload_size_bytes + | |
786 RtcpCommonHeader::kHeaderSizeBytes; | |
787 if (header.packet_type == RTCPUtility::PT_BYE) { | |
788 bool is_last_packet = (data + len == next_packet); | |
789 EXPECT_TRUE(is_last_packet) << | |
790 "Bye packet should be last in a compound RTCP packet."; | |
791 } | |
792 } | |
793 | |
794 return true; | |
795 })); | |
796 | |
797 // Re-configure rtcp_sender_ with mock_transport_ | |
798 rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(), | |
799 nullptr, nullptr, &mock_transport)); | |
800 rtcp_sender_->SetSSRC(kSenderSsrc); | |
801 rtcp_sender_->SetRemoteSSRC(kRemoteSsrc); | |
802 | |
803 // Set up XR VoIP metric to be included with BYE | |
804 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound); | |
805 RTCPVoIPMetric metric; | |
806 EXPECT_EQ(0, rtcp_sender_->SetRTCPVoIPMetrics(&metric)); | |
807 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpBye)); | |
808 } | |
809 | |
764 } // namespace webrtc | 810 } // namespace webrtc |
OLD | NEW |