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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc

Issue 1263383002: Changed loopback transport in RtxNackTest to not store sequence numbers for retransmitted packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 3 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 | « no previous file | no next file » | 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 consecutive_drop_end_ = start + total; 95 consecutive_drop_end_ = start + total;
96 packet_loss_ = 0; 96 packet_loss_ = 0;
97 } 97 }
98 98
99 int SendPacket(int channel, const void* data, size_t len) override { 99 int SendPacket(int channel, const void* data, size_t len) override {
100 count_++; 100 count_++;
101 const unsigned char* ptr = static_cast<const unsigned char*>(data); 101 const unsigned char* ptr = static_cast<const unsigned char*>(data);
102 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; 102 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11];
103 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++; 103 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++;
104 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; 104 uint16_t sequence_number = (ptr[2] << 8) + ptr[3];
105 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(),
106 sequence_number);
107 if (packet_loss_ > 0) {
108 if ((count_ % packet_loss_) == 0) {
109 return static_cast<int>(len);
110 }
111 } else if (count_ >= consecutive_drop_start_ &&
112 count_ < consecutive_drop_end_) {
113 return static_cast<int>(len);
114 }
115 size_t packet_length = len; 105 size_t packet_length = len;
116 // TODO(pbos): Figure out why this needs to be initialized. Likely this 106 // TODO(pbos): Figure out why this needs to be initialized. Likely this
117 // is hiding a bug either in test setup or other code. 107 // is hiding a bug either in test setup or other code.
118 // https://code.google.com/p/webrtc/issues/detail?id=3183 108 // https://code.google.com/p/webrtc/issues/detail?id=3183
119 uint8_t restored_packet[1500] = {0}; 109 uint8_t restored_packet[1500] = {0};
120 uint8_t* restored_packet_ptr = restored_packet; 110 uint8_t* restored_packet_ptr = restored_packet;
121 RTPHeader header; 111 RTPHeader header;
122 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); 112 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
123 if (!parser->Parse(ptr, len, &header)) { 113 if (!parser->Parse(ptr, len, &header)) {
124 return -1; 114 return -1;
125 } 115 }
116
117 if (!rtp_payload_registry_->IsRtx(header)) {
118 // Don't store retransmitted packets since we compare it to the list
119 // created by the receiver.
120 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(),
121 sequence_number);
122 }
123 if (packet_loss_ > 0) {
124 if ((count_ % packet_loss_) == 0) {
125 return static_cast<int>(len);
126 }
127 } else if (count_ >= consecutive_drop_start_ &&
128 count_ < consecutive_drop_end_) {
129 return static_cast<int>(len);
130 }
126 if (rtp_payload_registry_->IsRtx(header)) { 131 if (rtp_payload_registry_->IsRtx(header)) {
127 // Remove the RTX header and parse the original RTP header. 132 // Remove the RTX header and parse the original RTP header.
128 EXPECT_TRUE(rtp_payload_registry_->RestoreOriginalPacket( 133 EXPECT_TRUE(rtp_payload_registry_->RestoreOriginalPacket(
129 &restored_packet_ptr, ptr, &packet_length, rtp_receiver_->SSRC(), 134 &restored_packet_ptr, ptr, &packet_length, rtp_receiver_->SSRC(),
130 header)); 135 header));
131 if (!parser->Parse(restored_packet_ptr, packet_length, &header)) { 136 if (!parser->Parse(restored_packet_ptr, packet_length, &header)) {
132 return -1; 137 return -1;
133 } 138 }
134 } else { 139 } else {
135 rtp_payload_registry_->SetIncomingPayloadType(header); 140 rtp_payload_registry_->SetIncomingPayloadType(header);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 255 }
251 return n; 256 return n;
252 } 257 }
253 258
254 bool ExpectedPacketsReceived() { 259 bool ExpectedPacketsReceived() {
255 std::list<uint16_t> received_sorted; 260 std::list<uint16_t> received_sorted;
256 std::copy(receiver_.sequence_numbers_.begin(), 261 std::copy(receiver_.sequence_numbers_.begin(),
257 receiver_.sequence_numbers_.end(), 262 receiver_.sequence_numbers_.end(),
258 std::back_inserter(received_sorted)); 263 std::back_inserter(received_sorted));
259 received_sorted.sort(); 264 received_sorted.sort();
260 return std::equal(received_sorted.begin(), received_sorted.end(), 265 return received_sorted.size() ==
266 transport_.expected_sequence_numbers_.size() &&
267 std::equal(received_sorted.begin(), received_sorted.end(),
261 transport_.expected_sequence_numbers_.begin()); 268 transport_.expected_sequence_numbers_.begin());
262 } 269 }
263 270
264 void RunRtxTest(RtxMode rtx_method, int loss) { 271 void RunRtxTest(RtxMode rtx_method, int loss) {
265 rtp_payload_registry_.SetRtxSsrc(kTestSsrc + 1); 272 rtp_payload_registry_.SetRtxSsrc(kTestSsrc + 1);
266 rtp_rtcp_module_->SetRtxSendStatus(rtx_method); 273 rtp_rtcp_module_->SetRtxSendStatus(rtx_method);
267 rtp_rtcp_module_->SetRtxSsrc(kTestSsrc + 1); 274 rtp_rtcp_module_->SetRtxSsrc(kTestSsrc + 1);
268 transport_.DropEveryNthPacket(loss); 275 transport_.DropEveryNthPacket(loss);
269 uint32_t timestamp = 3000; 276 uint32_t timestamp = 3000;
270 uint16_t nack_list[kVideoNackListSize]; 277 uint16_t nack_list[kVideoNackListSize];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 346
340 TEST_F(RtpRtcpRtxNackTest, RtxNack) { 347 TEST_F(RtpRtcpRtxNackTest, RtxNack) {
341 RunRtxTest(kRtxRetransmitted, 10); 348 RunRtxTest(kRtxRetransmitted, 10);
342 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); 349 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin()));
343 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, 350 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1,
344 *(receiver_.sequence_numbers_.rbegin())); 351 *(receiver_.sequence_numbers_.rbegin()));
345 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); 352 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size());
346 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); 353 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_);
347 EXPECT_TRUE(ExpectedPacketsReceived()); 354 EXPECT_TRUE(ExpectedPacketsReceived());
348 } 355 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698