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

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

Issue 2960363002: Implement RTP keepalive in native stack. (Closed)
Patch Set: Cleanup Created 3 years, 5 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') | webrtc/video/replay.cc » ('j') | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const uint8_t kAudioLevelExtensionId = 9; 50 const uint8_t kAudioLevelExtensionId = 9;
51 const int kAudioPayload = 103; 51 const int kAudioPayload = 103;
52 const uint64_t kStartTime = 123456789; 52 const uint64_t kStartTime = 123456789;
53 const size_t kMaxPaddingSize = 224u; 53 const size_t kMaxPaddingSize = 224u;
54 const int kVideoRotationExtensionId = 5; 54 const int kVideoRotationExtensionId = 5;
55 const size_t kGenericHeaderLength = 1; 55 const size_t kGenericHeaderLength = 1;
56 const uint8_t kPayloadData[] = {47, 11, 32, 93, 89}; 56 const uint8_t kPayloadData[] = {47, 11, 32, 93, 89};
57 57
58 using ::testing::_; 58 using ::testing::_;
59 using ::testing::ElementsAreArray; 59 using ::testing::ElementsAreArray;
60 using ::testing::Invoke;
60 61
61 uint64_t ConvertMsToAbsSendTime(int64_t time_ms) { 62 uint64_t ConvertMsToAbsSendTime(int64_t time_ms) {
62 return (((time_ms << 18) + 500) / 1000) & 0x00ffffff; 63 return (((time_ms << 18) + 500) / 1000) & 0x00ffffff;
63 } 64 }
64 65
65 class LoopbackTransportTest : public webrtc::Transport { 66 class LoopbackTransportTest : public webrtc::Transport {
66 public: 67 public:
67 LoopbackTransportTest() : total_bytes_sent_(0), last_packet_id_(-1) { 68 LoopbackTransportTest() : total_bytes_sent_(0), last_packet_id_(-1) {
68 receivers_extensions_.Register(kRtpExtensionTransmissionTimeOffset, 69 receivers_extensions_.Register(kRtpExtensionTransmissionTimeOffset,
69 kTransmissionTimeOffsetExtensionId); 70 kTransmissionTimeOffsetExtensionId);
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 1705
1705 // Requested padding size is too small, will send a larger one. 1706 // Requested padding size is too small, will send a larger one.
1706 const size_t kMinPaddingSize = 50; 1707 const size_t kMinPaddingSize = 50;
1707 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _)) 1708 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _))
1708 .WillOnce(testing::Return(true)); 1709 .WillOnce(testing::Return(true));
1709 EXPECT_EQ( 1710 EXPECT_EQ(
1710 kMinPaddingSize, 1711 kMinPaddingSize,
1711 rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo())); 1712 rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo()));
1712 } 1713 }
1713 1714
1715 TEST_P(RtpSenderTest, SendsKeepAlive) {
1716 MockTransport transport;
1717 rtp_sender_.reset(new RTPSender(false, &fake_clock_, &transport, nullptr,
1718 nullptr, nullptr, nullptr, nullptr, nullptr,
1719 nullptr, &mock_rtc_event_log_, nullptr,
1720 &retransmission_rate_limiter_, nullptr));
1721 rtp_sender_->SetSendPayloadType(kPayload);
1722 rtp_sender_->SetSequenceNumber(kSeqNum);
1723 rtp_sender_->SetTimestampOffset(0);
1724 rtp_sender_->SetSSRC(kSsrc);
1725
1726 const uint8_t kKeepalivePayloadType = 20;
1727 RTC_CHECK_NE(kKeepalivePayloadType, kPayload);
1728
1729 EXPECT_CALL(transport, SendRtp(_, _, _))
1730 .WillOnce(
1731 Invoke([&kKeepalivePayloadType](const uint8_t* packet, size_t len,
1732 const PacketOptions& options) {
1733 webrtc::RTPHeader rtp_header;
1734 RtpUtility::RtpHeaderParser parser(packet, len);
1735 EXPECT_TRUE(parser.Parse(&rtp_header, nullptr));
1736 EXPECT_FALSE(rtp_header.markerBit);
1737 EXPECT_EQ(0U, rtp_header.paddingLength);
1738 EXPECT_EQ(kKeepalivePayloadType, rtp_header.payloadType);
1739 EXPECT_EQ(kSeqNum, rtp_header.sequenceNumber);
1740 EXPECT_EQ(kSsrc, rtp_header.ssrc);
1741 EXPECT_EQ(0u, len - rtp_header.headerLength);
1742 return true;
1743 }));
1744
1745 rtp_sender_->SendKeepAlive(kKeepalivePayloadType);
1746 EXPECT_EQ(kSeqNum + 1, rtp_sender_->SequenceNumber());
1747 }
1748
1714 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1749 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1715 RtpSenderTest, 1750 RtpSenderTest,
1716 ::testing::Bool()); 1751 ::testing::Bool());
1717 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1752 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1718 RtpSenderTestWithoutPacer, 1753 RtpSenderTestWithoutPacer,
1719 ::testing::Bool()); 1754 ::testing::Bool());
1720 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1755 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1721 RtpSenderVideoTest, 1756 RtpSenderVideoTest,
1722 ::testing::Bool()); 1757 ::testing::Bool());
1723 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1758 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1724 RtpSenderAudioTest, 1759 RtpSenderAudioTest,
1725 ::testing::Bool()); 1760 ::testing::Bool());
1726 } // namespace webrtc 1761 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/video/replay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698