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

Side by Side Diff: webrtc/modules/pacing/packet_router_unittest.cc

Issue 1705763002: Remove PacketRouter sender distinction. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: revert sending_media_ = false 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/pacing/packet_router.cc ('k') | webrtc/video/vie_channel.cc » ('j') | 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 18 matching lines...) Expand all
29 class PacketRouterTest : public ::testing::Test { 29 class PacketRouterTest : public ::testing::Test {
30 public: 30 public:
31 PacketRouterTest() : packet_router_(new PacketRouter()) {} 31 PacketRouterTest() : packet_router_(new PacketRouter()) {}
32 protected: 32 protected:
33 const rtc::scoped_ptr<PacketRouter> packet_router_; 33 const rtc::scoped_ptr<PacketRouter> packet_router_;
34 }; 34 };
35 35
36 TEST_F(PacketRouterTest, TimeToSendPacket) { 36 TEST_F(PacketRouterTest, TimeToSendPacket) {
37 MockRtpRtcp rtp_1; 37 MockRtpRtcp rtp_1;
38 MockRtpRtcp rtp_2; 38 MockRtpRtcp rtp_2;
39 packet_router_->AddRtpModule(&rtp_1, true); 39 packet_router_->AddRtpModule(&rtp_1);
40 packet_router_->AddRtpModule(&rtp_2, true); 40 packet_router_->AddRtpModule(&rtp_2);
41 41
42 const uint16_t kSsrc1 = 1234; 42 const uint16_t kSsrc1 = 1234;
43 uint16_t sequence_number = 17; 43 uint16_t sequence_number = 17;
44 uint64_t timestamp = 7890; 44 uint64_t timestamp = 7890;
45 bool retransmission = false; 45 bool retransmission = false;
46 46
47 // Send on the first module by letting rtp_1 be sending with correct ssrc. 47 // Send on the first module by letting rtp_1 be sending with correct ssrc.
48 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); 48 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true));
49 EXPECT_CALL(rtp_1, SSRC()).Times(1).WillOnce(Return(kSsrc1)); 49 EXPECT_CALL(rtp_1, SSRC()).Times(1).WillOnce(Return(kSsrc1));
50 EXPECT_CALL(rtp_1, TimeToSendPacket(kSsrc1, sequence_number, timestamp, 50 EXPECT_CALL(rtp_1, TimeToSendPacket(kSsrc1, sequence_number, timestamp,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Add a packet with incorrect ssrc and test it's dropped in the router. 82 // Add a packet with incorrect ssrc and test it's dropped in the router.
83 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); 83 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true));
84 EXPECT_CALL(rtp_1, SSRC()).Times(1).WillOnce(Return(kSsrc1)); 84 EXPECT_CALL(rtp_1, SSRC()).Times(1).WillOnce(Return(kSsrc1));
85 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 85 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
86 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2)); 86 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2));
87 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _)).Times(0); 87 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _)).Times(0);
88 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0); 88 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0);
89 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1 + kSsrc2, sequence_number, 89 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1 + kSsrc2, sequence_number,
90 timestamp, retransmission)); 90 timestamp, retransmission));
91 91
92 packet_router_->RemoveRtpModule(&rtp_1, true); 92 packet_router_->RemoveRtpModule(&rtp_1);
93 93
94 // rtp_1 has been removed, try sending a packet on that ssrc and make sure 94 // rtp_1 has been removed, try sending a packet on that ssrc and make sure
95 // it is dropped as expected by not expecting any calls to rtp_1. 95 // it is dropped as expected by not expecting any calls to rtp_1.
96 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 96 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
97 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2)); 97 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2));
98 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0); 98 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0);
99 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number, 99 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number,
100 timestamp, retransmission)); 100 timestamp, retransmission));
101 101
102 packet_router_->RemoveRtpModule(&rtp_2, true); 102 packet_router_->RemoveRtpModule(&rtp_2);
103 } 103 }
104 104
105 TEST_F(PacketRouterTest, TimeToSendPadding) { 105 TEST_F(PacketRouterTest, TimeToSendPadding) {
106 const uint16_t kSsrc1 = 1234; 106 const uint16_t kSsrc1 = 1234;
107 const uint16_t kSsrc2 = 4567; 107 const uint16_t kSsrc2 = 4567;
108 108
109 MockRtpRtcp rtp_1; 109 MockRtpRtcp rtp_1;
110 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1)); 110 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1));
111 MockRtpRtcp rtp_2; 111 MockRtpRtcp rtp_2;
112 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2)); 112 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2));
113 packet_router_->AddRtpModule(&rtp_1, true); 113 packet_router_->AddRtpModule(&rtp_1);
114 packet_router_->AddRtpModule(&rtp_2, true); 114 packet_router_->AddRtpModule(&rtp_2);
115 115
116 // Default configuration, sending padding on all modules sending media, 116 // Default configuration, sending padding on all modules sending media,
117 // ordered by SSRC. 117 // ordered by SSRC.
118 const size_t requested_padding_bytes = 1000; 118 const size_t requested_padding_bytes = 1000;
119 const size_t sent_padding_bytes = 890; 119 const size_t sent_padding_bytes = 890;
120 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); 120 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true));
121 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)) 121 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes))
122 .Times(1) 122 .Times(1)
123 .WillOnce(Return(sent_padding_bytes)); 123 .WillOnce(Return(sent_padding_bytes));
124 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 124 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
(...skipping 15 matching lines...) Expand all
140 EXPECT_EQ(sent_padding_bytes, 140 EXPECT_EQ(sent_padding_bytes,
141 packet_router_->TimeToSendPadding(requested_padding_bytes)); 141 packet_router_->TimeToSendPadding(requested_padding_bytes));
142 142
143 // No sending module at all. 143 // No sending module at all.
144 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false)); 144 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false));
145 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)).Times(0); 145 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)).Times(0);
146 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false)); 146 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false));
147 EXPECT_CALL(rtp_2, TimeToSendPadding(_)).Times(0); 147 EXPECT_CALL(rtp_2, TimeToSendPadding(_)).Times(0);
148 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes)); 148 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes));
149 149
150 packet_router_->RemoveRtpModule(&rtp_1, true); 150 packet_router_->RemoveRtpModule(&rtp_1);
151 151
152 // rtp_1 has been removed, try sending padding and make sure rtp_1 isn't asked 152 // rtp_1 has been removed, try sending padding and make sure rtp_1 isn't asked
153 // to send by not expecting any calls. Instead verify rtp_2 is called. 153 // to send by not expecting any calls. Instead verify rtp_2 is called.
154 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 154 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
155 EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes)).Times(1); 155 EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes)).Times(1);
156 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes)); 156 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes));
157 157
158 packet_router_->RemoveRtpModule(&rtp_2, true); 158 packet_router_->RemoveRtpModule(&rtp_2);
159 }
160
161 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) {
162 MockRtpRtcp rtp;
163 packet_router_->AddRtpModule(&rtp);
164 static const uint16_t kSsrc = 1234;
165 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc));
166 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false));
167
168 // Verify that TimeToSendPacket does not end up in a receiver.
169 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _)).Times(0);
170 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc, 1, 1, false));
171 // Verify that TimeToSendPadding does not end up in a receiver.
172 EXPECT_CALL(rtp, TimeToSendPadding(_)).Times(0);
173 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(200));
174
175 packet_router_->RemoveRtpModule(&rtp);
159 } 176 }
160 177
161 TEST_F(PacketRouterTest, AllocateSequenceNumbers) { 178 TEST_F(PacketRouterTest, AllocateSequenceNumbers) {
162 const uint16_t kStartSeq = 0xFFF0; 179 const uint16_t kStartSeq = 0xFFF0;
163 const size_t kNumPackets = 32; 180 const size_t kNumPackets = 32;
164 181
165 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1); 182 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1);
166 183
167 for (size_t i = 0; i < kNumPackets; ++i) { 184 for (size_t i = 0; i < kNumPackets; ++i) {
168 uint16_t seq = packet_router_->AllocateSequenceNumber(); 185 uint16_t seq = packet_router_->AllocateSequenceNumber();
169 uint32_t expected_unwrapped_seq = static_cast<uint32_t>(kStartSeq) + i; 186 uint32_t expected_unwrapped_seq = static_cast<uint32_t>(kStartSeq) + i;
170 EXPECT_EQ(static_cast<uint16_t>(expected_unwrapped_seq & 0xFFFF), seq); 187 EXPECT_EQ(static_cast<uint16_t>(expected_unwrapped_seq & 0xFFFF), seq);
171 } 188 }
172 } 189 }
173 190
174 TEST_F(PacketRouterTest, SendFeedback) { 191 TEST_F(PacketRouterTest, SendFeedback) {
175 MockRtpRtcp rtp_1; 192 MockRtpRtcp rtp_1;
176 MockRtpRtcp rtp_2; 193 MockRtpRtcp rtp_2;
177 packet_router_->AddRtpModule(&rtp_1, false); 194 packet_router_->AddRtpModule(&rtp_1);
178 packet_router_->AddRtpModule(&rtp_2, true); 195 packet_router_->AddRtpModule(&rtp_2);
179 196
180 rtcp::TransportFeedback feedback; 197 rtcp::TransportFeedback feedback;
181 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1); 198 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1);
182 packet_router_->SendFeedback(&feedback); 199 packet_router_->SendFeedback(&feedback);
183 packet_router_->RemoveRtpModule(&rtp_1, false); 200 packet_router_->RemoveRtpModule(&rtp_1);
184 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1); 201 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1);
185 packet_router_->SendFeedback(&feedback); 202 packet_router_->SendFeedback(&feedback);
186 packet_router_->RemoveRtpModule(&rtp_2, true); 203 packet_router_->RemoveRtpModule(&rtp_2);
187 } 204 }
188 } // namespace webrtc 205 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/packet_router.cc ('k') | webrtc/video/vie_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698