| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 SimulatedClock fake_clock_; | 142 SimulatedClock fake_clock_; |
| 143 MockRtpPacketSender mock_paced_sender_; | 143 MockRtpPacketSender mock_paced_sender_; |
| 144 rtc::scoped_ptr<RTPSender> rtp_sender_; | 144 rtc::scoped_ptr<RTPSender> rtp_sender_; |
| 145 int payload_; | 145 int payload_; |
| 146 LoopbackTransportTest transport_; | 146 LoopbackTransportTest transport_; |
| 147 const bool kMarkerBit; | 147 const bool kMarkerBit; |
| 148 uint8_t packet_[kMaxPacketLength]; | 148 uint8_t packet_[kMaxPacketLength]; |
| 149 | 149 |
| 150 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header) { | 150 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header) { |
| 151 VerifyRTPHeaderCommon(rtp_header, kMarkerBit); | 151 VerifyRTPHeaderCommon(rtp_header, kMarkerBit, 0); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, bool marker_bit) { | 154 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, bool marker_bit) { |
| 155 VerifyRTPHeaderCommon(rtp_header, marker_bit, 0); |
| 156 } |
| 157 |
| 158 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, |
| 159 bool marker_bit, |
| 160 uint8_t number_of_csrcs) { |
| 155 EXPECT_EQ(marker_bit, rtp_header.markerBit); | 161 EXPECT_EQ(marker_bit, rtp_header.markerBit); |
| 156 EXPECT_EQ(payload_, rtp_header.payloadType); | 162 EXPECT_EQ(payload_, rtp_header.payloadType); |
| 157 EXPECT_EQ(kSeqNum, rtp_header.sequenceNumber); | 163 EXPECT_EQ(kSeqNum, rtp_header.sequenceNumber); |
| 158 EXPECT_EQ(kTimestamp, rtp_header.timestamp); | 164 EXPECT_EQ(kTimestamp, rtp_header.timestamp); |
| 159 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); | 165 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); |
| 160 EXPECT_EQ(0, rtp_header.numCSRCs); | 166 EXPECT_EQ(number_of_csrcs, rtp_header.numCSRCs); |
| 161 EXPECT_EQ(0U, rtp_header.paddingLength); | 167 EXPECT_EQ(0U, rtp_header.paddingLength); |
| 162 } | 168 } |
| 163 | 169 |
| 164 void SendPacket(int64_t capture_time_ms, int payload_length) { | 170 void SendPacket(int64_t capture_time_ms, int payload_length) { |
| 165 uint32_t timestamp = capture_time_ms * 90; | 171 uint32_t timestamp = capture_time_ms * 90; |
| 166 int32_t rtp_length = rtp_sender_->BuildRTPheader( | 172 int32_t rtp_length = rtp_sender_->BuildRTPheader( |
| 167 packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); | 173 packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); |
| 168 ASSERT_GE(rtp_length, 0); | 174 ASSERT_GE(rtp_length, 0); |
| 169 | 175 |
| 170 // Packet should be stored in a send bucket. | 176 // Packet should be stored in a send bucket. |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 const bool valid_rtp_header2 = rtp_parser.Parse(&rtp_header2, nullptr); | 551 const bool valid_rtp_header2 = rtp_parser.Parse(&rtp_header2, nullptr); |
| 546 | 552 |
| 547 ASSERT_TRUE(valid_rtp_header2); | 553 ASSERT_TRUE(valid_rtp_header2); |
| 548 VerifyRTPHeaderCommon(rtp_header2); | 554 VerifyRTPHeaderCommon(rtp_header2); |
| 549 EXPECT_EQ(length, rtp_header2.headerLength); | 555 EXPECT_EQ(length, rtp_header2.headerLength); |
| 550 EXPECT_FALSE(rtp_header2.extension.hasAudioLevel); | 556 EXPECT_FALSE(rtp_header2.extension.hasAudioLevel); |
| 551 EXPECT_FALSE(rtp_header2.extension.voiceActivity); | 557 EXPECT_FALSE(rtp_header2.extension.voiceActivity); |
| 552 EXPECT_EQ(0u, rtp_header2.extension.audioLevel); | 558 EXPECT_EQ(0u, rtp_header2.extension.audioLevel); |
| 553 } | 559 } |
| 554 | 560 |
| 561 TEST_F(RtpSenderTestWithoutPacer, |
| 562 BuildRTPPacketWithCSRCAndAudioLevelExtension) { |
| 563 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, |
| 564 kAudioLevelExtensionId)); |
| 565 std::vector<uint32_t> csrcs; |
| 566 csrcs.push_back(0x23456789); |
| 567 rtp_sender_->SetCsrcs(csrcs); |
| 568 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
| 569 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
| 570 |
| 571 // Verify |
| 572 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
| 573 webrtc::RTPHeader rtp_header; |
| 574 |
| 575 // Updating audio level is done in RTPSenderAudio, so simulate it here. |
| 576 rtp_parser.Parse(&rtp_header); |
| 577 EXPECT_TRUE(rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true, |
| 578 kAudioLevel)); |
| 579 |
| 580 RtpHeaderExtensionMap map; |
| 581 map.Register(kRtpExtensionAudioLevel, kAudioLevelExtensionId); |
| 582 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); |
| 583 |
| 584 ASSERT_TRUE(valid_rtp_header); |
| 585 ASSERT_FALSE(rtp_parser.RTCP()); |
| 586 VerifyRTPHeaderCommon(rtp_header, kMarkerBit, csrcs.size()); |
| 587 EXPECT_EQ(length, rtp_header.headerLength); |
| 588 EXPECT_TRUE(rtp_header.extension.hasAudioLevel); |
| 589 EXPECT_TRUE(rtp_header.extension.voiceActivity); |
| 590 EXPECT_EQ(kAudioLevel, rtp_header.extension.audioLevel); |
| 591 EXPECT_EQ(1u, rtp_header.numCSRCs); |
| 592 EXPECT_EQ(csrcs[0], rtp_header.arrOfCSRCs[0]); |
| 593 } |
| 594 |
| 555 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) { | 595 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) { |
| 556 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset)); | 596 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset)); |
| 557 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime)); | 597 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime)); |
| 558 EXPECT_EQ(0, | 598 EXPECT_EQ(0, |
| 559 rtp_sender_->SetTransportSequenceNumber(kTransportSequenceNumber)); | 599 rtp_sender_->SetTransportSequenceNumber(kTransportSequenceNumber)); |
| 560 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 600 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| 561 kRtpExtensionTransmissionTimeOffset, | 601 kRtpExtensionTransmissionTimeOffset, |
| 562 kTransmissionTimeOffsetExtensionId)); | 602 kTransmissionTimeOffsetExtensionId)); |
| 563 EXPECT_EQ( | 603 EXPECT_EQ( |
| 564 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 604 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), | 1458 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
| 1419 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); | 1459 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
| 1420 | 1460 |
| 1421 // Verify that this packet does have CVO byte. | 1461 // Verify that this packet does have CVO byte. |
| 1422 VerifyCVOPacket( | 1462 VerifyCVOPacket( |
| 1423 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), | 1463 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
| 1424 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, | 1464 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
| 1425 hdr.rotation); | 1465 hdr.rotation); |
| 1426 } | 1466 } |
| 1427 } // namespace webrtc | 1467 } // namespace webrtc |
| OLD | NEW |