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

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

Issue 2032473002: Revert "Revert of Propagate probing cluster id to SendTimeHistory. (patchset #5 id:80001 of https:/… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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) 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 30 matching lines...) Expand all
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,
51 retransmission)) 51 retransmission, 1))
52 .Times(1) 52 .Times(1)
53 .WillOnce(Return(true)); 53 .WillOnce(Return(true));
54 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0); 54 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _, _)).Times(0);
55 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number, 55 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number,
56 timestamp, retransmission, -1)); 56 timestamp, retransmission, 1));
57 57
58 // Send on the second module by letting rtp_2 be sending, but not rtp_1. 58 // Send on the second module by letting rtp_2 be sending, but not rtp_1.
59 ++sequence_number; 59 ++sequence_number;
60 timestamp += 30; 60 timestamp += 30;
61 retransmission = true; 61 retransmission = true;
62 const uint16_t kSsrc2 = 4567; 62 const uint16_t kSsrc2 = 4567;
63 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false)); 63 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false));
64 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 64 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
65 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2)); 65 EXPECT_CALL(rtp_2, SSRC()).Times(1).WillOnce(Return(kSsrc2));
66 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _)).Times(0); 66 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _, _)).Times(0);
67 EXPECT_CALL(rtp_2, TimeToSendPacket(kSsrc2, sequence_number, timestamp, 67 EXPECT_CALL(rtp_2, TimeToSendPacket(kSsrc2, sequence_number, timestamp,
68 retransmission)) 68 retransmission, 2))
69 .Times(1) 69 .Times(1)
70 .WillOnce(Return(true)); 70 .WillOnce(Return(true));
71 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc2, sequence_number, 71 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc2, sequence_number,
72 timestamp, retransmission, -1)); 72 timestamp, retransmission, 2));
73 73
74 // No module is sending, hence no packet should be sent. 74 // No module is sending, hence no packet should be sent.
75 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false)); 75 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false));
76 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _)).Times(0); 76 EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _, _)).Times(0);
77 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false)); 77 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false));
78 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _)).Times(0); 78 EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _, _)).Times(0);
79 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number, 79 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc1, sequence_number,
80 timestamp, retransmission, -1)); 80 timestamp, retransmission, 1));
81 81
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, -1)); 90 timestamp, retransmission, 1));
91 91
92 packet_router_->RemoveRtpModule(&rtp_1); 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, -1)); 100 timestamp, retransmission,
101 PacketInfo::kNotAProbe));
101 102
102 packet_router_->RemoveRtpModule(&rtp_2); 103 packet_router_->RemoveRtpModule(&rtp_2);
103 } 104 }
104 105
105 TEST_F(PacketRouterTest, TimeToSendPadding) { 106 TEST_F(PacketRouterTest, TimeToSendPadding) {
106 const uint16_t kSsrc1 = 1234; 107 const uint16_t kSsrc1 = 1234;
107 const uint16_t kSsrc2 = 4567; 108 const uint16_t kSsrc2 = 4567;
108 109
109 MockRtpRtcp rtp_1; 110 MockRtpRtcp rtp_1;
110 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1)); 111 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1));
111 MockRtpRtcp rtp_2; 112 MockRtpRtcp rtp_2;
112 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2)); 113 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2));
113 packet_router_->AddRtpModule(&rtp_1); 114 packet_router_->AddRtpModule(&rtp_1);
114 packet_router_->AddRtpModule(&rtp_2); 115 packet_router_->AddRtpModule(&rtp_2);
115 116
116 // Default configuration, sending padding on all modules sending media, 117 // Default configuration, sending padding on all modules sending media,
117 // ordered by SSRC. 118 // ordered by SSRC.
118 const size_t requested_padding_bytes = 1000; 119 const size_t requested_padding_bytes = 1000;
119 const size_t sent_padding_bytes = 890; 120 const size_t sent_padding_bytes = 890;
120 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); 121 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true));
121 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)) 122 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes, 111))
122 .Times(1) 123 .Times(1)
123 .WillOnce(Return(sent_padding_bytes)); 124 .WillOnce(Return(sent_padding_bytes));
124 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 125 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
125 EXPECT_CALL(rtp_2, 126 EXPECT_CALL(rtp_2, TimeToSendPadding(
126 TimeToSendPadding(requested_padding_bytes - sent_padding_bytes)) 127 requested_padding_bytes - sent_padding_bytes, 111))
127 .Times(1) 128 .Times(1)
128 .WillOnce(Return(requested_padding_bytes - sent_padding_bytes)); 129 .WillOnce(Return(requested_padding_bytes - sent_padding_bytes));
129 EXPECT_EQ(requested_padding_bytes, 130 EXPECT_EQ(requested_padding_bytes,
130 packet_router_->TimeToSendPadding(requested_padding_bytes)); 131 packet_router_->TimeToSendPadding(requested_padding_bytes, 111));
131 132
132 // Let only the second module be sending and verify the padding request is 133 // Let only the second module be sending and verify the padding request is
133 // routed there. 134 // routed there.
134 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false)); 135 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false));
135 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)).Times(0); 136 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes, _)).Times(0);
136 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 137 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
137 EXPECT_CALL(rtp_2, TimeToSendPadding(_)) 138 EXPECT_CALL(rtp_2, TimeToSendPadding(_, _))
138 .Times(1) 139 .Times(1)
139 .WillOnce(Return(sent_padding_bytes)); 140 .WillOnce(Return(sent_padding_bytes));
140 EXPECT_EQ(sent_padding_bytes, 141 EXPECT_EQ(sent_padding_bytes,
141 packet_router_->TimeToSendPadding(requested_padding_bytes)); 142 packet_router_->TimeToSendPadding(requested_padding_bytes,
143 PacketInfo::kNotAProbe));
142 144
143 // No sending module at all. 145 // No sending module at all.
144 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false)); 146 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(false));
145 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes)).Times(0); 147 EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes, _)).Times(0);
146 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false)); 148 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false));
147 EXPECT_CALL(rtp_2, TimeToSendPadding(_)).Times(0); 149 EXPECT_CALL(rtp_2, TimeToSendPadding(_, _)).Times(0);
148 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes)); 150 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes,
151 PacketInfo::kNotAProbe));
149 152
150 packet_router_->RemoveRtpModule(&rtp_1); 153 packet_router_->RemoveRtpModule(&rtp_1);
151 154
152 // rtp_1 has been removed, try sending padding and make sure rtp_1 isn't asked 155 // 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. 156 // to send by not expecting any calls. Instead verify rtp_2 is called.
154 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); 157 EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
155 EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes)).Times(1); 158 EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes, _)).Times(1);
156 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes)); 159 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(requested_padding_bytes,
160 PacketInfo::kNotAProbe));
157 161
158 packet_router_->RemoveRtpModule(&rtp_2); 162 packet_router_->RemoveRtpModule(&rtp_2);
159 } 163 }
160 164
161 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) { 165 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) {
162 MockRtpRtcp rtp; 166 MockRtpRtcp rtp;
163 packet_router_->AddRtpModule(&rtp); 167 packet_router_->AddRtpModule(&rtp);
164 static const uint16_t kSsrc = 1234; 168 static const uint16_t kSsrc = 1234;
165 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc)); 169 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc));
166 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false)); 170 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false));
167 171
168 // Verify that TimeToSendPacket does not end up in a receiver. 172 // Verify that TimeToSendPacket does not end up in a receiver.
169 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _)).Times(0); 173 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _, _)).Times(0);
170 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc, 1, 1, false, -1)); 174 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc, 1, 1, false,
175 PacketInfo::kNotAProbe));
171 // Verify that TimeToSendPadding does not end up in a receiver. 176 // Verify that TimeToSendPadding does not end up in a receiver.
172 EXPECT_CALL(rtp, TimeToSendPadding(_)).Times(0); 177 EXPECT_CALL(rtp, TimeToSendPadding(_, _)).Times(0);
173 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(200)); 178 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(200, PacketInfo::kNotAProbe));
174 179
175 packet_router_->RemoveRtpModule(&rtp); 180 packet_router_->RemoveRtpModule(&rtp);
176 } 181 }
177 182
178 TEST_F(PacketRouterTest, AllocateSequenceNumbers) { 183 TEST_F(PacketRouterTest, AllocateSequenceNumbers) {
179 const uint16_t kStartSeq = 0xFFF0; 184 const uint16_t kStartSeq = 0xFFF0;
180 const size_t kNumPackets = 32; 185 const size_t kNumPackets = 32;
181 186
182 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1); 187 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1);
183 188
(...skipping 12 matching lines...) Expand all
196 201
197 rtcp::TransportFeedback feedback; 202 rtcp::TransportFeedback feedback;
198 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1); 203 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1);
199 packet_router_->SendFeedback(&feedback); 204 packet_router_->SendFeedback(&feedback);
200 packet_router_->RemoveRtpModule(&rtp_1); 205 packet_router_->RemoveRtpModule(&rtp_1);
201 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1); 206 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1);
202 packet_router_->SendFeedback(&feedback); 207 packet_router_->SendFeedback(&feedback);
203 packet_router_->RemoveRtpModule(&rtp_2); 208 packet_router_->RemoveRtpModule(&rtp_2);
204 } 209 }
205 } // namespace webrtc 210 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/packet_router.cc ('k') | webrtc/modules/remote_bitrate_estimator/include/send_time_history.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698