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 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" |
| 12 |
| 13 #include <memory> |
| 14 |
11 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
12 | |
13 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
14 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
15 #include "webrtc/system_wrappers/include/clock.h" | 18 #include "webrtc/system_wrappers/include/clock.h" |
16 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
17 | 20 |
18 namespace webrtc { | 21 namespace webrtc { |
19 | 22 |
20 class RtpPacketHistoryTest : public ::testing::Test { | 23 class RtpPacketHistoryTest : public ::testing::Test { |
21 protected: | 24 protected: |
22 RtpPacketHistoryTest() | 25 static constexpr uint16_t kSeqNum = 88; |
23 : fake_clock_(123456), | 26 |
24 hist_(new RTPPacketHistory(&fake_clock_)) { | 27 RtpPacketHistoryTest() : fake_clock_(123456), hist_(&fake_clock_) {} |
25 } | |
26 ~RtpPacketHistoryTest() { | |
27 delete hist_; | |
28 } | |
29 | 28 |
30 SimulatedClock fake_clock_; | 29 SimulatedClock fake_clock_; |
31 RTPPacketHistory* hist_; | 30 RtpPacketHistory hist_; |
32 enum {kPayload = 127}; | 31 |
33 enum {kSsrc = 12345678}; | 32 std::unique_ptr<RtpPacketToSend> CreateRtpPacket(uint16_t seq_num) { |
34 enum {kSeqNum = 88}; | 33 // Payload, ssrc, timestamp and extensions are irrelevant for this tests. |
35 enum {kTimestamp = 127}; | 34 std::unique_ptr<RtpPacketToSend> packet(new RtpPacketToSend(nullptr)); |
36 enum {kMaxPacketLength = 1500}; | 35 packet->SetSequenceNumber(seq_num); |
37 uint8_t packet_[kMaxPacketLength]; | 36 packet->set_capture_time_ms(fake_clock_.TimeInMilliseconds()); |
38 uint8_t packet_out_[kMaxPacketLength]; | 37 return packet; |
39 | |
40 void CreateRtpPacket(uint16_t seq_num, uint32_t ssrc, uint8_t payload, | |
41 uint32_t timestamp, uint8_t* array, size_t* cur_pos) { | |
42 array[(*cur_pos)++] = 0x80; | |
43 array[(*cur_pos)++] = payload; | |
44 array[(*cur_pos)++] = seq_num >> 8; | |
45 array[(*cur_pos)++] = seq_num; | |
46 array[(*cur_pos)++] = timestamp >> 24; | |
47 array[(*cur_pos)++] = timestamp >> 16; | |
48 array[(*cur_pos)++] = timestamp >> 8; | |
49 array[(*cur_pos)++] = timestamp; | |
50 array[(*cur_pos)++] = ssrc >> 24; | |
51 array[(*cur_pos)++] = ssrc >> 16; | |
52 array[(*cur_pos)++] = ssrc >> 8; | |
53 array[(*cur_pos)++] = ssrc; | |
54 } | 38 } |
55 }; | 39 }; |
56 | 40 |
57 TEST_F(RtpPacketHistoryTest, SetStoreStatus) { | 41 TEST_F(RtpPacketHistoryTest, SetStoreStatus) { |
58 EXPECT_FALSE(hist_->StorePackets()); | 42 EXPECT_FALSE(hist_.StorePackets()); |
59 hist_->SetStorePacketsStatus(true, 10); | 43 hist_.SetStorePacketsStatus(true, 10); |
60 EXPECT_TRUE(hist_->StorePackets()); | 44 EXPECT_TRUE(hist_.StorePackets()); |
61 hist_->SetStorePacketsStatus(false, 0); | 45 hist_.SetStorePacketsStatus(false, 0); |
62 EXPECT_FALSE(hist_->StorePackets()); | 46 EXPECT_FALSE(hist_.StorePackets()); |
63 } | 47 } |
64 | 48 |
65 TEST_F(RtpPacketHistoryTest, NoStoreStatus) { | 49 TEST_F(RtpPacketHistoryTest, NoStoreStatus) { |
66 EXPECT_FALSE(hist_->StorePackets()); | 50 EXPECT_FALSE(hist_.StorePackets()); |
67 size_t len = 0; | 51 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
68 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 52 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
69 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | |
70 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | |
71 kAllowRetransmission)); | |
72 // Packet should not be stored. | 53 // Packet should not be stored. |
73 len = kMaxPacketLength; | 54 EXPECT_FALSE(hist_.GetPacketAndSetSendTime(kSeqNum, 0, false)); |
74 int64_t time; | |
75 EXPECT_FALSE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_, &len, | |
76 &time)); | |
77 } | |
78 | |
79 TEST_F(RtpPacketHistoryTest, PutRtpPacket_TooLargePacketLength) { | |
80 hist_->SetStorePacketsStatus(true, 10); | |
81 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | |
82 EXPECT_EQ(-1, hist_->PutRTPPacket(packet_, kMaxPacketLength + 1, | |
83 capture_time_ms, kAllowRetransmission)); | |
84 } | 55 } |
85 | 56 |
86 TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) { | 57 TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) { |
87 hist_->SetStorePacketsStatus(true, 10); | 58 hist_.SetStorePacketsStatus(true, 10); |
88 size_t len = kMaxPacketLength; | 59 EXPECT_FALSE(hist_.GetPacketAndSetSendTime(0, 0, false)); |
89 int64_t time; | |
90 EXPECT_FALSE(hist_->GetPacketAndSetSendTime(0, 0, false, packet_, &len, | |
91 &time)); | |
92 } | 60 } |
93 | 61 |
94 TEST_F(RtpPacketHistoryTest, PutRtpPacket) { | 62 TEST_F(RtpPacketHistoryTest, PutRtpPacket) { |
95 hist_->SetStorePacketsStatus(true, 10); | 63 hist_.SetStorePacketsStatus(true, 10); |
96 size_t len = 0; | 64 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
97 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 65 |
98 | 66 EXPECT_FALSE(hist_.HasRtpPacket(kSeqNum)); |
99 EXPECT_FALSE(hist_->HasRTPPacket(kSeqNum)); | 67 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
100 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 68 EXPECT_TRUE(hist_.HasRtpPacket(kSeqNum)); |
101 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | |
102 kAllowRetransmission)); | |
103 EXPECT_TRUE(hist_->HasRTPPacket(kSeqNum)); | |
104 } | 69 } |
105 | 70 |
106 TEST_F(RtpPacketHistoryTest, GetRtpPacket) { | 71 TEST_F(RtpPacketHistoryTest, GetRtpPacket) { |
107 hist_->SetStorePacketsStatus(true, 10); | 72 hist_.SetStorePacketsStatus(true, 10); |
108 size_t len = 0; | |
109 int64_t capture_time_ms = 1; | 73 int64_t capture_time_ms = 1; |
110 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 74 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
111 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | 75 packet->set_capture_time_ms(capture_time_ms); |
112 kAllowRetransmission)); | 76 rtc::CopyOnWriteBuffer buffer = packet->Buffer(); |
113 | 77 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
114 size_t len_out = kMaxPacketLength; | 78 |
115 int64_t time; | 79 std::unique_ptr<RtpPacketToSend> packet_out = |
116 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, | 80 hist_.GetPacketAndSetSendTime(kSeqNum, 0, false); |
117 &len_out, &time)); | 81 EXPECT_TRUE(packet_out); |
118 EXPECT_EQ(len, len_out); | 82 EXPECT_EQ(buffer, packet_out->Buffer()); |
119 EXPECT_EQ(capture_time_ms, time); | 83 EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); |
120 for (size_t i = 0; i < len; i++) { | |
121 EXPECT_EQ(packet_[i], packet_out_[i]); | |
122 } | |
123 } | 84 } |
124 | 85 |
125 TEST_F(RtpPacketHistoryTest, NoCaptureTime) { | 86 TEST_F(RtpPacketHistoryTest, NoCaptureTime) { |
126 hist_->SetStorePacketsStatus(true, 10); | 87 hist_.SetStorePacketsStatus(true, 10); |
127 size_t len = 0; | |
128 fake_clock_.AdvanceTimeMilliseconds(1); | 88 fake_clock_.AdvanceTimeMilliseconds(1); |
129 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 89 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
130 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 90 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
131 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, -1, kAllowRetransmission)); | 91 packet->set_capture_time_ms(-1); |
132 | 92 rtc::CopyOnWriteBuffer buffer = packet->Buffer(); |
133 size_t len_out = kMaxPacketLength; | 93 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
134 int64_t time; | 94 |
135 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, | 95 std::unique_ptr<RtpPacketToSend> packet_out = |
136 &len_out, &time)); | 96 hist_.GetPacketAndSetSendTime(kSeqNum, 0, false); |
137 EXPECT_EQ(len, len_out); | 97 EXPECT_TRUE(packet_out); |
138 EXPECT_EQ(capture_time_ms, time); | 98 EXPECT_EQ(buffer, packet_out->Buffer()); |
139 for (size_t i = 0; i < len; i++) { | 99 EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); |
140 EXPECT_EQ(packet_[i], packet_out_[i]); | |
141 } | |
142 } | 100 } |
143 | 101 |
144 TEST_F(RtpPacketHistoryTest, DontRetransmit) { | 102 TEST_F(RtpPacketHistoryTest, DontRetransmit) { |
145 hist_->SetStorePacketsStatus(true, 10); | 103 hist_.SetStorePacketsStatus(true, 10); |
146 size_t len = 0; | 104 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
147 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 105 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
148 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 106 rtc::CopyOnWriteBuffer buffer = packet->Buffer(); |
149 EXPECT_EQ( | 107 hist_.PutRtpPacket(std::move(packet), kDontRetransmit, false); |
150 0, hist_->PutRTPPacket(packet_, len, capture_time_ms, kDontRetransmit)); | 108 |
151 | 109 std::unique_ptr<RtpPacketToSend> packet_out; |
152 size_t len_out = kMaxPacketLength; | 110 packet_out = hist_.GetPacketAndSetSendTime(kSeqNum, 0, true); |
153 int64_t time; | 111 EXPECT_FALSE(packet_out); |
154 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, | 112 |
155 &len_out, &time)); | 113 packet_out = hist_.GetPacketAndSetSendTime(kSeqNum, 0, false); |
156 EXPECT_EQ(len, len_out); | 114 EXPECT_TRUE(packet_out); |
157 EXPECT_EQ(capture_time_ms, time); | 115 |
| 116 EXPECT_EQ(buffer.size(), packet_out->size()); |
| 117 EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); |
158 } | 118 } |
159 | 119 |
160 TEST_F(RtpPacketHistoryTest, MinResendTime) { | 120 TEST_F(RtpPacketHistoryTest, MinResendTime) { |
161 static const int64_t kMinRetransmitIntervalMs = 100; | 121 static const int64_t kMinRetransmitIntervalMs = 100; |
162 | 122 |
163 hist_->SetStorePacketsStatus(true, 10); | 123 hist_.SetStorePacketsStatus(true, 10); |
164 size_t len = 0; | 124 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
165 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 125 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
166 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 126 size_t len = packet->size(); |
167 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | 127 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
168 kAllowRetransmission)); | |
169 | 128 |
170 // First transmission: TimeToSendPacket() call from pacer. | 129 // First transmission: TimeToSendPacket() call from pacer. |
171 int64_t time; | 130 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum, 0, false)); |
172 len = kMaxPacketLength; | |
173 EXPECT_TRUE( | |
174 hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_, &len, &time)); | |
175 | 131 |
176 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs); | 132 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs); |
177 // Time has elapsed. | 133 // Time has elapsed. |
178 len = kMaxPacketLength; | 134 std::unique_ptr<RtpPacketToSend> packet_out = |
179 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, | 135 hist_.GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, true); |
180 true, packet_, &len, &time)); | 136 EXPECT_TRUE(packet_out); |
181 EXPECT_GT(len, 0u); | 137 EXPECT_EQ(len, packet_out->size()); |
182 EXPECT_EQ(capture_time_ms, time); | 138 EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); |
183 | 139 |
184 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); | 140 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); |
185 // Time has not elapsed. Packet should be found, but no bytes copied. | 141 // Time has not elapsed. Packet should be found, but no bytes copied. |
186 len = kMaxPacketLength; | 142 EXPECT_TRUE(hist_.HasRtpPacket(kSeqNum)); |
187 EXPECT_FALSE(hist_->GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, | 143 EXPECT_FALSE( |
188 true, packet_, &len, &time)); | 144 hist_.GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, true)); |
189 } | 145 } |
190 | 146 |
191 TEST_F(RtpPacketHistoryTest, EarlyFirstResend) { | 147 TEST_F(RtpPacketHistoryTest, EarlyFirstResend) { |
192 static const int64_t kMinRetransmitIntervalMs = 100; | 148 static const int64_t kMinRetransmitIntervalMs = 100; |
193 | 149 |
194 hist_->SetStorePacketsStatus(true, 10); | 150 hist_.SetStorePacketsStatus(true, 10); |
195 size_t len = 0; | 151 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
196 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 152 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
197 CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); | 153 rtc::CopyOnWriteBuffer buffer = packet->Buffer(); |
198 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | 154 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
199 kAllowRetransmission)); | |
200 | 155 |
201 // First transmission: TimeToSendPacket() call from pacer. | 156 // First transmission: TimeToSendPacket() call from pacer. |
202 int64_t time; | 157 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum, 0, false)); |
203 len = kMaxPacketLength; | |
204 EXPECT_TRUE( | |
205 hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_, &len, &time)); | |
206 | 158 |
207 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); | 159 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); |
208 // Time has not elapsed, but this is the first retransmission request so | 160 // Time has not elapsed, but this is the first retransmission request so |
209 // allow anyway. | 161 // allow anyway. |
210 len = kMaxPacketLength; | 162 std::unique_ptr<RtpPacketToSend> packet_out = |
211 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, | 163 hist_.GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, true); |
212 true, packet_, &len, &time)); | 164 EXPECT_TRUE(packet_out); |
213 EXPECT_GT(len, 0u); | 165 EXPECT_EQ(buffer, packet_out->Buffer()); |
214 EXPECT_EQ(capture_time_ms, time); | 166 EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); |
215 | 167 |
216 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); | 168 fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); |
217 // Time has not elapsed. Packet should be found, but no bytes copied. | 169 // Time has not elapsed. Packet should be found, but no bytes copied. |
218 len = kMaxPacketLength; | 170 EXPECT_TRUE(hist_.HasRtpPacket(kSeqNum)); |
219 EXPECT_FALSE(hist_->GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, | 171 EXPECT_FALSE( |
220 true, packet_, &len, &time)); | 172 hist_.GetPacketAndSetSendTime(kSeqNum, kMinRetransmitIntervalMs, true)); |
221 } | 173 } |
222 | 174 |
223 TEST_F(RtpPacketHistoryTest, DynamicExpansion) { | 175 TEST_F(RtpPacketHistoryTest, DynamicExpansion) { |
224 hist_->SetStorePacketsStatus(true, 10); | 176 hist_.SetStorePacketsStatus(true, 10); |
225 size_t len; | |
226 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | |
227 int64_t time; | |
228 | 177 |
229 // Add 4 packets, and then send them. | 178 // Add 4 packets, and then send them. |
230 for (int i = 0; i < 4; ++i) { | 179 for (int i = 0; i < 4; ++i) { |
231 len = 0; | 180 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum + i); |
232 CreateRtpPacket(kSeqNum + i, kSsrc, kPayload, kTimestamp, packet_, &len); | 181 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
233 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | |
234 kAllowRetransmission)); | |
235 } | 182 } |
236 for (int i = 0; i < 4; ++i) { | 183 for (int i = 0; i < 4; ++i) { |
237 len = kMaxPacketLength; | 184 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); |
238 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, | 185 } |
239 &len, &time)); | 186 fake_clock_.AdvanceTimeMilliseconds(33); |
240 } | |
241 capture_time_ms += 33; | |
242 | 187 |
243 // Add 16 packets, and then send them. History should expand to make this | 188 // Add 16 packets, and then send them. History should expand to make this |
244 // work. | 189 // work. |
245 for (int i = 4; i < 20; ++i) { | 190 for (int i = 4; i < 20; ++i) { |
246 len = 0; | 191 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum + i); |
247 CreateRtpPacket(kSeqNum + i, kSsrc, kPayload, kTimestamp, packet_, &len); | 192 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
248 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | |
249 kAllowRetransmission)); | |
250 } | 193 } |
251 for (int i = 4; i < 20; ++i) { | 194 for (int i = 4; i < 20; ++i) { |
252 len = kMaxPacketLength; | 195 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); |
253 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, | |
254 &len, &time)); | |
255 } | 196 } |
256 | 197 |
257 fake_clock_.AdvanceTimeMilliseconds(100); | 198 fake_clock_.AdvanceTimeMilliseconds(100); |
258 | 199 |
259 // Retransmit last 16 packets. | 200 // Retransmit last 16 packets. |
260 for (int i = 4; i < 20; ++i) { | 201 for (int i = 4; i < 20; ++i) { |
261 len = kMaxPacketLength; | 202 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); |
262 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, | |
263 &len, &time)); | |
264 } | 203 } |
265 } | 204 } |
266 | 205 |
267 TEST_F(RtpPacketHistoryTest, FullExpansion) { | 206 TEST_F(RtpPacketHistoryTest, FullExpansion) { |
268 static const int kSendSidePacketHistorySize = 600; | 207 static const int kSendSidePacketHistorySize = 600; |
269 hist_->SetStorePacketsStatus(true, kSendSidePacketHistorySize); | 208 hist_.SetStorePacketsStatus(true, kSendSidePacketHistorySize); |
270 size_t len; | 209 for (size_t i = 0; i < RtpPacketHistory::kMaxCapacity + 1; ++i) { |
271 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 210 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum + i); |
272 int64_t time; | 211 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
273 for (size_t i = 0; i < kMaxHistoryCapacity + 1; ++i) { | |
274 len = 0; | |
275 CreateRtpPacket(kSeqNum + i, kSsrc, kPayload, kTimestamp, packet_, &len); | |
276 EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, capture_time_ms, | |
277 kAllowRetransmission)); | |
278 } | 212 } |
279 | 213 |
280 fake_clock_.AdvanceTimeMilliseconds(100); | 214 fake_clock_.AdvanceTimeMilliseconds(100); |
281 | 215 |
282 // Retransmit all packets currently in buffer. | 216 // Retransmit all packets currently in buffer. |
283 for (size_t i = 1; i < kMaxHistoryCapacity + 1; ++i) { | 217 for (size_t i = 1; i < RtpPacketHistory::kMaxCapacity + 1; ++i) { |
284 len = kMaxPacketLength; | 218 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); |
285 EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum + i, 100, false, packet_, | 219 } |
286 &len, &time)); | 220 } |
287 } | 221 |
288 } | |
289 | |
290 } // namespace webrtc | 222 } // namespace webrtc |
OLD | NEW |