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