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 |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 EXPECT_EQ(rtx_stats.transmitted.TotalBytes(), | 1341 EXPECT_EQ(rtx_stats.transmitted.TotalBytes(), |
1342 rtx_stats.transmitted.payload_bytes + | 1342 rtx_stats.transmitted.payload_bytes + |
1343 rtx_stats.transmitted.header_bytes + | 1343 rtx_stats.transmitted.header_bytes + |
1344 rtx_stats.transmitted.padding_bytes); | 1344 rtx_stats.transmitted.padding_bytes); |
1345 | 1345 |
1346 EXPECT_EQ(transport_.total_bytes_sent_, | 1346 EXPECT_EQ(transport_.total_bytes_sent_, |
1347 rtp_stats.transmitted.TotalBytes() + | 1347 rtp_stats.transmitted.TotalBytes() + |
1348 rtx_stats.transmitted.TotalBytes()); | 1348 rtx_stats.transmitted.TotalBytes()); |
1349 } | 1349 } |
1350 | 1350 |
| 1351 TEST_F(RtpSenderTest, RespectsNackBitrateLimit) { |
| 1352 const int32_t kPacketSize = 1400; |
| 1353 const int32_t kNumPackets = 30; |
| 1354 |
| 1355 rtp_sender_->SetStorePacketsStatus(true, kNumPackets); |
| 1356 // Set bitrate (in kbps) to fit kNumPackets รก kPacketSize bytes in one second. |
| 1357 rtp_sender_->SetTargetBitrate(kNumPackets * kPacketSize * 8); |
| 1358 const uint16_t kStartSequenceNumber = rtp_sender_->SequenceNumber(); |
| 1359 std::list<uint16_t> sequence_numbers; |
| 1360 for (int32_t i = 0; i < kNumPackets; ++i) { |
| 1361 sequence_numbers.push_back(kStartSequenceNumber + i); |
| 1362 fake_clock_.AdvanceTimeMilliseconds(1); |
| 1363 SendPacket(fake_clock_.TimeInMilliseconds(), kPacketSize); |
| 1364 } |
| 1365 EXPECT_EQ(kNumPackets, transport_.packets_sent_); |
| 1366 |
| 1367 fake_clock_.AdvanceTimeMilliseconds(1000 - kNumPackets); |
| 1368 |
| 1369 // Resending should work - brings the bandwidth up to the limit. |
| 1370 // NACK bitrate is capped to the same bitrate as the encoder, since the max |
| 1371 // protection overhead is 50% (see MediaOptimization::SetTargetRates). |
| 1372 rtp_sender_->OnReceivedNACK(sequence_numbers, 0); |
| 1373 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent_); |
| 1374 |
| 1375 // Resending should not work, bandwidth exceeded. |
| 1376 rtp_sender_->OnReceivedNACK(sequence_numbers, 0); |
| 1377 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent_); |
| 1378 } |
| 1379 |
1351 // Verify that all packets of a frame have CVO byte set. | 1380 // Verify that all packets of a frame have CVO byte set. |
1352 TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { | 1381 TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { |
1353 RTPVideoHeader hdr = {0}; | 1382 RTPVideoHeader hdr = {0}; |
1354 hdr.rotation = kVideoRotation_90; | 1383 hdr.rotation = kVideoRotation_90; |
1355 | 1384 |
1356 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 1385 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
1357 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 1386 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
1358 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); | 1387 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); |
1359 | 1388 |
1360 EXPECT_EQ( | 1389 EXPECT_EQ( |
(...skipping 12 matching lines...) Expand all Loading... |
1373 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), | 1402 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
1374 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); | 1403 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
1375 | 1404 |
1376 // Verify that this packet does have CVO byte. | 1405 // Verify that this packet does have CVO byte. |
1377 VerifyCVOPacket( | 1406 VerifyCVOPacket( |
1378 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), | 1407 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
1379 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, | 1408 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
1380 hdr.rotation); | 1409 hdr.rotation); |
1381 } | 1410 } |
1382 } // namespace webrtc | 1411 } // namespace webrtc |
OLD | NEW |