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

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

Issue 2766323006: Correcting the amount of padding when send side bwe includes RTP overhead.
Patch Set: rebasing Created 3 years, 8 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 | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | 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) 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); 600 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs);
601 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false, 601 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false,
602 PacedPacketInfo()); 602 PacedPacketInfo());
603 // Packet should now be sent. This test doesn't verify the regular video 603 // Packet should now be sent. This test doesn't verify the regular video
604 // packet, since it is tested in another test. 604 // packet, since it is tested in another test.
605 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); 605 EXPECT_EQ(++total_packets_sent, transport_.packets_sent());
606 timestamp += 90 * kStoredTimeInMs; 606 timestamp += 90 * kStoredTimeInMs;
607 607
608 // Send padding 4 times, waiting 50 ms between each. 608 // Send padding 4 times, waiting 50 ms between each.
609 for (int i = 0; i < 4; ++i) { 609 for (int i = 0; i < 4; ++i) {
610 const int kPaddingPeriodMs = 50; 610 constexpr int kPaddingPeriodMs = 50;
611 const size_t kPaddingBytes = 100; 611 constexpr size_t kPaddingBytes = 100;
612 const size_t kMaxPaddingLength = 224; // Value taken from rtp_sender.cc. 612 constexpr size_t kMaxPaddingLength =
613 224; // Value taken from rtp_sender.cc.
614
613 // Padding will be forced to full packets. 615 // Padding will be forced to full packets.
614 EXPECT_EQ(kMaxPaddingLength, 616 // If BWE includes overhead, the return value of TimeToSendPadding will also
617 // include overhead.
618 const size_t expected_return =
619 GetParam() ? kMaxPaddingLength + rtp_header_len : kMaxPaddingLength;
620 EXPECT_EQ(expected_return,
615 rtp_sender_->TimeToSendPadding(kPaddingBytes, PacedPacketInfo())); 621 rtp_sender_->TimeToSendPadding(kPaddingBytes, PacedPacketInfo()));
616 622
617 // Process send bucket. Padding should now be sent. 623 // Process send bucket. Padding should now be sent.
618 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); 624 EXPECT_EQ(++total_packets_sent, transport_.packets_sent());
619 EXPECT_EQ(kMaxPaddingLength + rtp_header_len, 625 EXPECT_EQ(kMaxPaddingLength + rtp_header_len,
620 transport_.last_sent_packet().size()); 626 transport_.last_sent_packet().size());
621 627
622 transport_.last_sent_packet().GetHeader(&rtp_header); 628 transport_.last_sent_packet().GetHeader(&rtp_header);
623 EXPECT_EQ(kMaxPaddingLength, rtp_header.paddingLength); 629 EXPECT_EQ(kMaxPaddingLength, rtp_header.paddingLength);
624 630
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 fake_clock_.AdvanceTimeMilliseconds(33); 783 fake_clock_.AdvanceTimeMilliseconds(33);
778 } 784 }
779 785
780 EXPECT_CALL(mock_rtc_event_log_, 786 EXPECT_CALL(mock_rtc_event_log_,
781 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _, _)) 787 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _, _))
782 .Times(::testing::AtLeast(4)); 788 .Times(::testing::AtLeast(4));
783 789
784 // The amount of padding to send it too small to send a payload packet. 790 // The amount of padding to send it too small to send a payload packet.
785 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) 791 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _))
786 .WillOnce(testing::Return(true)); 792 .WillOnce(testing::Return(true));
787 EXPECT_EQ(kMaxPaddingSize, 793
794 // If BWE includes overhead, the return value of TimeToSendPadding will also
795 // include overhead.
796 size_t expected_return =
797 GetParam() ? kMaxPaddingSize + rtp_header_len : kMaxPaddingSize;
798 EXPECT_EQ(expected_return,
788 rtp_sender_->TimeToSendPadding(49, PacedPacketInfo())); 799 rtp_sender_->TimeToSendPadding(49, PacedPacketInfo()));
789 800
790 EXPECT_CALL(transport, 801 EXPECT_CALL(transport,
791 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _)) 802 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _))
792 .WillOnce(testing::Return(true)); 803 .WillOnce(testing::Return(true));
793 EXPECT_EQ(kPayloadSizes[0], 804
805 expected_return =
806 GetParam() ? kPayloadSizes[0] + rtp_header_len : kPayloadSizes[0];
807 EXPECT_EQ(expected_return,
794 rtp_sender_->TimeToSendPadding(500, PacedPacketInfo())); 808 rtp_sender_->TimeToSendPadding(500, PacedPacketInfo()));
795 809
796 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] + 810 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] +
797 rtp_header_len + kRtxHeaderSize, 811 rtp_header_len + kRtxHeaderSize,
798 _)) 812 _))
799 .WillOnce(testing::Return(true)); 813 .WillOnce(testing::Return(true));
800 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) 814 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _))
801 .WillOnce(testing::Return(true)); 815 .WillOnce(testing::Return(true));
802 EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, 816
817 expected_return = GetParam()
818 ? kPayloadSizes[kNumPayloadSizes - 1] +
819 kMaxPaddingSize + rtp_header_len * 2
820 : kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize;
821 EXPECT_EQ(expected_return,
803 rtp_sender_->TimeToSendPadding(999, PacedPacketInfo())); 822 rtp_sender_->TimeToSendPadding(999, PacedPacketInfo()));
804 } 823 }
805 824
806 TEST_P(RtpSenderTestWithoutPacer, SendGenericVideo) { 825 TEST_P(RtpSenderTestWithoutPacer, SendGenericVideo) {
807 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; 826 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC";
808 const uint8_t payload_type = 127; 827 const uint8_t payload_type = 127;
809 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, 828 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000,
810 0, 1500)); 829 0, 1500));
811 uint8_t payload[] = {47, 11, 32, 93, 89}; 830 uint8_t payload[] = {47, 11, 32, 93, 89};
812 831
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 nullptr, nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_, 1529 nullptr, nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_,
1511 nullptr, &retransmission_rate_limiter_, nullptr)); 1530 nullptr, &retransmission_rate_limiter_, nullptr));
1512 rtp_sender_->SetSendPayloadType(kPayload); 1531 rtp_sender_->SetSendPayloadType(kPayload);
1513 rtp_sender_->SetSequenceNumber(kSeqNum); 1532 rtp_sender_->SetSequenceNumber(kSeqNum);
1514 rtp_sender_->SetTimestampOffset(0); 1533 rtp_sender_->SetTimestampOffset(0);
1515 rtp_sender_->SetSSRC(kSsrc); 1534 rtp_sender_->SetSSRC(kSsrc);
1516 1535
1517 const size_t kPaddingSize = 59; 1536 const size_t kPaddingSize = 59;
1518 EXPECT_CALL(transport, SendRtp(_, kPaddingSize + kRtpHeaderSize, _)) 1537 EXPECT_CALL(transport, SendRtp(_, kPaddingSize + kRtpHeaderSize, _))
1519 .WillOnce(testing::Return(true)); 1538 .WillOnce(testing::Return(true));
1520 EXPECT_EQ(kPaddingSize, 1539
1521 rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); 1540 // If BWE includes overhead, the input value to TimeToSendPadding should also
1541 // include overhead.
1542 size_t budget = GetParam() ? kPaddingSize + kRtpHeaderSize : kPaddingSize;
1543 EXPECT_EQ(budget, rtp_sender_->TimeToSendPadding(budget, PacedPacketInfo()));
1522 1544
1523 // Requested padding size is too small, will send a larger one. 1545 // Requested padding size is too small, will send a larger one.
1524 const size_t kMinPaddingSize = 50; 1546 const size_t kMinPaddingSize = 50;
1525 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _)) 1547 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _))
1526 .WillOnce(testing::Return(true)); 1548 .WillOnce(testing::Return(true));
1527 EXPECT_EQ( 1549
1528 kMinPaddingSize, 1550 budget =
1529 rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo())); 1551 GetParam() ? kMinPaddingSize - 5 + kRtpHeaderSize : kMinPaddingSize - 5;
1552 const size_t expected_return =
1553 GetParam() ? kMinPaddingSize + kRtpHeaderSize : kMinPaddingSize;
1554 EXPECT_EQ(expected_return,
1555 rtp_sender_->TimeToSendPadding(budget, PacedPacketInfo()));
1530 } 1556 }
1531 1557
1532 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1558 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1533 RtpSenderTest, 1559 RtpSenderTest,
1534 ::testing::Bool()); 1560 ::testing::Bool());
1535 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1561 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1536 RtpSenderTestWithoutPacer, 1562 RtpSenderTestWithoutPacer,
1537 ::testing::Bool()); 1563 ::testing::Bool());
1538 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1564 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1539 RtpSenderVideoTest, 1565 RtpSenderVideoTest,
1540 ::testing::Bool()); 1566 ::testing::Bool());
1541 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1567 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1542 RtpSenderAudioTest, 1568 RtpSenderAudioTest,
1543 ::testing::Bool()); 1569 ::testing::Bool());
1544 } // namespace webrtc 1570 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698