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

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

Issue 1674963004: Always append the BYE packet type at the end (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed Comment 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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
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 TEST_F(RtcpSenderTest, ByeMustBeLast) {
775 MockTransport mock_transport;
776 EXPECT_CALL(mock_transport, SendRtcp(_, _))
777 .WillOnce(Invoke([](const uint8_t* data, size_t len) {
778 const uint8_t* next_packet = data;
779 while (next_packet < data + len) {
780 RtcpCommonHeader header;
781 RtcpParseCommonHeader(next_packet, len - (next_packet - data), &header);
782 next_packet = next_packet +
783 header.payload_size_bytes +
784 RtcpCommonHeader::kHeaderSizeBytes;
785 if (header.packet_type == RTCPUtility::PT_BYE) {
786 bool is_last_packet = (data + len == next_packet);
787 EXPECT_TRUE(is_last_packet) <<
788 "Bye packet should be last in a compound RTCP packet.";
789 }
790 }
791
792 return true;
793 }));
794
795 // Re-configure rtcp_sender_ with mock_transport_
796 rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(),
797 nullptr, nullptr, &mock_transport));
798 rtcp_sender_->SetSSRC(kSenderSsrc);
799 rtcp_sender_->SetRemoteSSRC(kRemoteSsrc);
800
801 // Set up XR VoIP metric to be included with BYE
802 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound);
803 RTCPVoIPMetric metric;
804 EXPECT_EQ(0, rtcp_sender_->SetRTCPVoIPMetrics(&metric));
805 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpBye));
806 }
807
764 } // namespace webrtc 808 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698