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

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

Issue 1586523003: Fixed sending Rtp packets with non zero csrcs and certain extensions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 bool retransmission)); 116 bool retransmission));
117 }; 117 };
118 118
119 class RtpSenderTest : public ::testing::Test { 119 class RtpSenderTest : public ::testing::Test {
120 protected: 120 protected:
121 RtpSenderTest() 121 RtpSenderTest()
122 : fake_clock_(kStartTime), 122 : fake_clock_(kStartTime),
123 mock_paced_sender_(), 123 mock_paced_sender_(),
124 rtp_sender_(), 124 rtp_sender_(),
125 payload_(kPayload), 125 payload_(kPayload),
126 transport_(), 126 transport_() {
127 kMarkerBit(true) {
128 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, _)) 127 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, _))
129 .WillRepeatedly(testing::Return()); 128 .WillRepeatedly(testing::Return());
130 } 129 }
131 130
132 void SetUp() override { SetUpRtpSender(true); } 131 void SetUp() override { SetUpRtpSender(true); }
133 132
134 void SetUpRtpSender(bool pacer) { 133 void SetUpRtpSender(bool pacer) {
135 rtp_sender_.reset(new RTPSender(false, &fake_clock_, &transport_, nullptr, 134 rtp_sender_.reset(new RTPSender(false, &fake_clock_, &transport_, nullptr,
136 pacer ? &mock_paced_sender_ : nullptr, 135 pacer ? &mock_paced_sender_ : nullptr,
137 nullptr, nullptr, nullptr, nullptr, 136 nullptr, nullptr, nullptr, nullptr,
138 nullptr)); 137 nullptr));
139 rtp_sender_->SetSequenceNumber(kSeqNum); 138 rtp_sender_->SetSequenceNumber(kSeqNum);
140 } 139 }
141 140
142 SimulatedClock fake_clock_; 141 SimulatedClock fake_clock_;
143 MockRtpPacketSender mock_paced_sender_; 142 MockRtpPacketSender mock_paced_sender_;
144 rtc::scoped_ptr<RTPSender> rtp_sender_; 143 rtc::scoped_ptr<RTPSender> rtp_sender_;
145 int payload_; 144 int payload_;
146 LoopbackTransportTest transport_; 145 LoopbackTransportTest transport_;
147 const bool kMarkerBit; 146 static const bool kMarkerBit = true;
148 uint8_t packet_[kMaxPacketLength]; 147 uint8_t packet_[kMaxPacketLength];
149 148
150 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header) { 149 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header,
151 VerifyRTPHeaderCommon(rtp_header, kMarkerBit); 150 bool marker_bit = kMarkerBit,
152 } 151 uint8_t number_of_csrcs = 0) {
stefan-webrtc 2016/01/14 14:59:17 No default values please, instead pass in all argu
danilchap 2016/01/14 15:45:04 Done.
153
154 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, bool marker_bit) {
155 EXPECT_EQ(marker_bit, rtp_header.markerBit); 152 EXPECT_EQ(marker_bit, rtp_header.markerBit);
156 EXPECT_EQ(payload_, rtp_header.payloadType); 153 EXPECT_EQ(payload_, rtp_header.payloadType);
157 EXPECT_EQ(kSeqNum, rtp_header.sequenceNumber); 154 EXPECT_EQ(kSeqNum, rtp_header.sequenceNumber);
158 EXPECT_EQ(kTimestamp, rtp_header.timestamp); 155 EXPECT_EQ(kTimestamp, rtp_header.timestamp);
159 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); 156 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc);
160 EXPECT_EQ(0, rtp_header.numCSRCs); 157 EXPECT_EQ(number_of_csrcs, rtp_header.numCSRCs);
161 EXPECT_EQ(0U, rtp_header.paddingLength); 158 EXPECT_EQ(0U, rtp_header.paddingLength);
162 } 159 }
163 160
164 void SendPacket(int64_t capture_time_ms, int payload_length) { 161 void SendPacket(int64_t capture_time_ms, int payload_length) {
165 uint32_t timestamp = capture_time_ms * 90; 162 uint32_t timestamp = capture_time_ms * 90;
166 int32_t rtp_length = rtp_sender_->BuildRTPheader( 163 int32_t rtp_length = rtp_sender_->BuildRTPheader(
167 packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); 164 packet_, kPayload, kMarkerBit, timestamp, capture_time_ms);
168 ASSERT_GE(rtp_length, 0); 165 ASSERT_GE(rtp_length, 0);
169 166
170 // Packet should be stored in a send bucket. 167 // Packet should be stored in a send bucket.
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 const bool valid_rtp_header2 = rtp_parser.Parse(&rtp_header2, nullptr); 542 const bool valid_rtp_header2 = rtp_parser.Parse(&rtp_header2, nullptr);
546 543
547 ASSERT_TRUE(valid_rtp_header2); 544 ASSERT_TRUE(valid_rtp_header2);
548 VerifyRTPHeaderCommon(rtp_header2); 545 VerifyRTPHeaderCommon(rtp_header2);
549 EXPECT_EQ(length, rtp_header2.headerLength); 546 EXPECT_EQ(length, rtp_header2.headerLength);
550 EXPECT_FALSE(rtp_header2.extension.hasAudioLevel); 547 EXPECT_FALSE(rtp_header2.extension.hasAudioLevel);
551 EXPECT_FALSE(rtp_header2.extension.voiceActivity); 548 EXPECT_FALSE(rtp_header2.extension.voiceActivity);
552 EXPECT_EQ(0u, rtp_header2.extension.audioLevel); 549 EXPECT_EQ(0u, rtp_header2.extension.audioLevel);
553 } 550 }
554 551
552 TEST_F(RtpSenderTestWithoutPacer,
553 BuildRTPPacketWithCSRCAndAudioLevelExtension) {
554 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel,
555 kAudioLevelExtensionId));
556 std::vector<uint32_t> csrcs;
557 csrcs.push_back(0x23456789);
558 rtp_sender_->SetCsrcs(csrcs);
stefan-webrtc 2016/01/14 14:59:17 Shouldn't you use at least 2 CSRCs to trigger this
danilchap 2016/01/14 15:45:04 No, one is enough. I checked test was red before c
559 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
560 packet_, kPayload, kMarkerBit, kTimestamp, 0));
561
562 // Verify
563 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
564 webrtc::RTPHeader rtp_header;
565
566 // Updating audio level is done in RTPSenderAudio, so simulate it here.
567 rtp_parser.Parse(&rtp_header);
568 EXPECT_TRUE(rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true,
569 kAudioLevel));
570
571 RtpHeaderExtensionMap map;
572 map.Register(kRtpExtensionAudioLevel, kAudioLevelExtensionId);
573 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map);
574
575 ASSERT_TRUE(valid_rtp_header);
576 ASSERT_FALSE(rtp_parser.RTCP());
577 VerifyRTPHeaderCommon(rtp_header, kMarkerBit, csrcs.size());
578 EXPECT_EQ(length, rtp_header.headerLength);
579 EXPECT_TRUE(rtp_header.extension.hasAudioLevel);
580 EXPECT_TRUE(rtp_header.extension.voiceActivity);
581 EXPECT_EQ(kAudioLevel, rtp_header.extension.audioLevel);
582 EXPECT_EQ(1u, rtp_header.numCSRCs);
583 EXPECT_EQ(csrcs[0], rtp_header.arrOfCSRCs[0]);
584 }
585
555 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) { 586 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) {
556 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset)); 587 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset));
557 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime)); 588 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime));
558 EXPECT_EQ(0, 589 EXPECT_EQ(0,
559 rtp_sender_->SetTransportSequenceNumber(kTransportSequenceNumber)); 590 rtp_sender_->SetTransportSequenceNumber(kTransportSequenceNumber));
560 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( 591 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
561 kRtpExtensionTransmissionTimeOffset, 592 kRtpExtensionTransmissionTimeOffset,
562 kTransmissionTimeOffsetExtensionId)); 593 kTransmissionTimeOffsetExtensionId));
563 EXPECT_EQ( 594 EXPECT_EQ(
564 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, 595 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), 1449 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()),
1419 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); 1450 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation);
1420 1451
1421 // Verify that this packet does have CVO byte. 1452 // Verify that this packet does have CVO byte.
1422 VerifyCVOPacket( 1453 VerifyCVOPacket(
1423 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), 1454 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()),
1424 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, 1455 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1,
1425 hdr.rotation); 1456 hdr.rotation);
1426 } 1457 }
1427 } // namespace webrtc 1458 } // 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