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

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

Issue 1962303002: Added cluster id to PacedSender::Callback::TimeToSendPacket. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addded probing cluster unittest. Created 4 years, 7 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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))
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)); 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))
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)); 72 timestamp, retransmission, -1));
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)); 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)); 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)); 100 timestamp, retransmission, -1));
101 101
102 packet_router_->RemoveRtpModule(&rtp_2); 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));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) { 161 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) {
162 MockRtpRtcp rtp; 162 MockRtpRtcp rtp;
163 packet_router_->AddRtpModule(&rtp); 163 packet_router_->AddRtpModule(&rtp);
164 static const uint16_t kSsrc = 1234; 164 static const uint16_t kSsrc = 1234;
165 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc)); 165 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc));
166 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false)); 166 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false));
167 167
168 // Verify that TimeToSendPacket does not end up in a receiver. 168 // Verify that TimeToSendPacket does not end up in a receiver.
169 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _)).Times(0); 169 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _)).Times(0);
170 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc, 1, 1, false)); 170 EXPECT_TRUE(packet_router_->TimeToSendPacket(kSsrc, 1, 1, false, -1));
171 // Verify that TimeToSendPadding does not end up in a receiver. 171 // Verify that TimeToSendPadding does not end up in a receiver.
172 EXPECT_CALL(rtp, TimeToSendPadding(_)).Times(0); 172 EXPECT_CALL(rtp, TimeToSendPadding(_)).Times(0);
173 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(200)); 173 EXPECT_EQ(0u, packet_router_->TimeToSendPadding(200));
174 174
175 packet_router_->RemoveRtpModule(&rtp); 175 packet_router_->RemoveRtpModule(&rtp);
176 } 176 }
177 177
178 TEST_F(PacketRouterTest, AllocateSequenceNumbers) { 178 TEST_F(PacketRouterTest, AllocateSequenceNumbers) {
179 const uint16_t kStartSeq = 0xFFF0; 179 const uint16_t kStartSeq = 0xFFF0;
180 const size_t kNumPackets = 32; 180 const size_t kNumPackets = 32;
(...skipping 15 matching lines...) Expand all
196 196
197 rtcp::TransportFeedback feedback; 197 rtcp::TransportFeedback feedback;
198 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1); 198 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1);
199 packet_router_->SendFeedback(&feedback); 199 packet_router_->SendFeedback(&feedback);
200 packet_router_->RemoveRtpModule(&rtp_1); 200 packet_router_->RemoveRtpModule(&rtp_1);
201 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1); 201 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1);
202 packet_router_->SendFeedback(&feedback); 202 packet_router_->SendFeedback(&feedback);
203 packet_router_->RemoveRtpModule(&rtp_2); 203 packet_router_->RemoveRtpModule(&rtp_2);
204 } 204 }
205 } // namespace webrtc 205 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/packet_router.cc ('k') | webrtc/modules/remote_bitrate_estimator/test/packet_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698