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 |
11 #include <list> | 11 #include <list> |
12 #include <memory> | |
13 #include <vector> | 12 #include <vector> |
14 | 13 |
15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webrtc/base/buffer.h" | 16 #include "webrtc/base/buffer.h" |
| 17 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/call/mock/mock_rtc_event_log.h" | 18 #include "webrtc/call/mock/mock_rtc_event_log.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
27 #include "webrtc/system_wrappers/include/stl_util.h" | 27 #include "webrtc/system_wrappers/include/stl_util.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 pacer ? &mock_paced_sender_ : nullptr, | 141 pacer ? &mock_paced_sender_ : nullptr, |
142 &seq_num_allocator_, nullptr, nullptr, | 142 &seq_num_allocator_, nullptr, nullptr, |
143 nullptr, nullptr, &mock_rtc_event_log_)); | 143 nullptr, nullptr, &mock_rtc_event_log_)); |
144 rtp_sender_->SetSequenceNumber(kSeqNum); | 144 rtp_sender_->SetSequenceNumber(kSeqNum); |
145 } | 145 } |
146 | 146 |
147 SimulatedClock fake_clock_; | 147 SimulatedClock fake_clock_; |
148 MockRtcEventLog mock_rtc_event_log_; | 148 MockRtcEventLog mock_rtc_event_log_; |
149 MockRtpPacketSender mock_paced_sender_; | 149 MockRtpPacketSender mock_paced_sender_; |
150 MockTransportSequenceNumberAllocator seq_num_allocator_; | 150 MockTransportSequenceNumberAllocator seq_num_allocator_; |
151 std::unique_ptr<RTPSender> rtp_sender_; | 151 rtc::scoped_ptr<RTPSender> rtp_sender_; |
152 int payload_; | 152 int payload_; |
153 LoopbackTransportTest transport_; | 153 LoopbackTransportTest transport_; |
154 const bool kMarkerBit; | 154 const bool kMarkerBit; |
155 uint8_t packet_[kMaxPacketLength]; | 155 uint8_t packet_[kMaxPacketLength]; |
156 | 156 |
157 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header) { | 157 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header) { |
158 VerifyRTPHeaderCommon(rtp_header, kMarkerBit, 0); | 158 VerifyRTPHeaderCommon(rtp_header, kMarkerBit, 0); |
159 } | 159 } |
160 | 160 |
161 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, bool marker_bit) { | 161 void VerifyRTPHeaderCommon(const RTPHeader& rtp_header, bool marker_bit) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 195 }; |
196 | 196 |
197 class RtpSenderVideoTest : public RtpSenderTest { | 197 class RtpSenderVideoTest : public RtpSenderTest { |
198 protected: | 198 protected: |
199 void SetUp() override { | 199 void SetUp() override { |
200 // TODO(pbos): Set up to use pacer. | 200 // TODO(pbos): Set up to use pacer. |
201 SetUpRtpSender(false); | 201 SetUpRtpSender(false); |
202 rtp_sender_video_.reset( | 202 rtp_sender_video_.reset( |
203 new RTPSenderVideo(&fake_clock_, rtp_sender_.get())); | 203 new RTPSenderVideo(&fake_clock_, rtp_sender_.get())); |
204 } | 204 } |
205 std::unique_ptr<RTPSenderVideo> rtp_sender_video_; | 205 rtc::scoped_ptr<RTPSenderVideo> rtp_sender_video_; |
206 | 206 |
207 void VerifyCVOPacket(uint8_t* data, | 207 void VerifyCVOPacket(uint8_t* data, |
208 size_t len, | 208 size_t len, |
209 bool expect_cvo, | 209 bool expect_cvo, |
210 RtpHeaderExtensionMap* map, | 210 RtpHeaderExtensionMap* map, |
211 uint16_t seq_num, | 211 uint16_t seq_num, |
212 VideoRotation rotation) { | 212 VideoRotation rotation) { |
213 webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len); | 213 webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len); |
214 | 214 |
215 webrtc::RTPHeader rtp_header; | 215 webrtc::RTPHeader rtp_header; |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 kRtpExtensionTransmissionTimeOffset, | 842 kRtpExtensionTransmissionTimeOffset, |
843 kTransmissionTimeOffsetExtensionId)); | 843 kTransmissionTimeOffsetExtensionId)); |
844 rtp_header_len += 4; // 4 bytes extension. | 844 rtp_header_len += 4; // 4 bytes extension. |
845 EXPECT_EQ( | 845 EXPECT_EQ( |
846 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 846 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
847 kAbsoluteSendTimeExtensionId)); | 847 kAbsoluteSendTimeExtensionId)); |
848 rtp_header_len += 4; // 4 bytes extension. | 848 rtp_header_len += 4; // 4 bytes extension. |
849 rtp_header_len += 4; // 4 extra bytes common to all extension headers. | 849 rtp_header_len += 4; // 4 extra bytes common to all extension headers. |
850 | 850 |
851 // Create and set up parser. | 851 // Create and set up parser. |
852 std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser( | 852 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser( |
853 webrtc::RtpHeaderParser::Create()); | 853 webrtc::RtpHeaderParser::Create()); |
854 ASSERT_TRUE(rtp_parser.get() != nullptr); | 854 ASSERT_TRUE(rtp_parser.get() != nullptr); |
855 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, | 855 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, |
856 kTransmissionTimeOffsetExtensionId); | 856 kTransmissionTimeOffsetExtensionId); |
857 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 857 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
858 kAbsoluteSendTimeExtensionId); | 858 kAbsoluteSendTimeExtensionId); |
859 webrtc::RTPHeader rtp_header; | 859 webrtc::RTPHeader rtp_header; |
860 | 860 |
861 rtp_sender_->SetTargetBitrate(300000); | 861 rtp_sender_->SetTargetBitrate(300000); |
862 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 862 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 EXPECT_EQ( | 961 EXPECT_EQ( |
962 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 962 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
963 kAbsoluteSendTimeExtensionId)); | 963 kAbsoluteSendTimeExtensionId)); |
964 rtp_header_len += 4; // 4 bytes extension. | 964 rtp_header_len += 4; // 4 bytes extension. |
965 rtp_header_len += 4; // 4 extra bytes common to all extension headers. | 965 rtp_header_len += 4; // 4 extra bytes common to all extension headers. |
966 | 966 |
967 rtp_sender_->SetRtxStatus(kRtxRetransmitted | kRtxRedundantPayloads); | 967 rtp_sender_->SetRtxStatus(kRtxRetransmitted | kRtxRedundantPayloads); |
968 rtp_sender_->SetRtxSsrc(1234); | 968 rtp_sender_->SetRtxSsrc(1234); |
969 | 969 |
970 // Create and set up parser. | 970 // Create and set up parser. |
971 std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser( | 971 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser( |
972 webrtc::RtpHeaderParser::Create()); | 972 webrtc::RtpHeaderParser::Create()); |
973 ASSERT_TRUE(rtp_parser.get() != nullptr); | 973 ASSERT_TRUE(rtp_parser.get() != nullptr); |
974 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, | 974 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, |
975 kTransmissionTimeOffsetExtensionId); | 975 kTransmissionTimeOffsetExtensionId); |
976 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 976 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
977 kAbsoluteSendTimeExtensionId); | 977 kAbsoluteSendTimeExtensionId); |
978 rtp_sender_->SetTargetBitrate(300000); | 978 rtp_sender_->SetTargetBitrate(300000); |
979 const size_t kNumPayloadSizes = 10; | 979 const size_t kNumPayloadSizes = 10; |
980 const size_t kPayloadSizes[kNumPayloadSizes] = {500, 550, 600, 650, 700, | 980 const size_t kPayloadSizes[kNumPayloadSizes] = {500, 550, 600, 650, 700, |
981 750, 800, 850, 900, 950}; | 981 750, 800, 850, 900, 950}; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 // timestamp. So for first call it will skip since the duration is zero. | 1396 // timestamp. So for first call it will skip since the duration is zero. |
1397 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, | 1397 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1398 capture_time_ms, 0, nullptr, 0, | 1398 capture_time_ms, 0, nullptr, 0, |
1399 nullptr)); | 1399 nullptr)); |
1400 // DTMF Sample Length is (Frequency/1000) * Duration. | 1400 // DTMF Sample Length is (Frequency/1000) * Duration. |
1401 // So in this case, it is (8000/1000) * 500 = 4000. | 1401 // So in this case, it is (8000/1000) * 500 = 4000. |
1402 // Sending it as two packets. | 1402 // Sending it as two packets. |
1403 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, | 1403 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1404 capture_time_ms + 2000, 0, nullptr, | 1404 capture_time_ms + 2000, 0, nullptr, |
1405 0, nullptr)); | 1405 0, nullptr)); |
1406 std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser( | 1406 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser( |
1407 webrtc::RtpHeaderParser::Create()); | 1407 webrtc::RtpHeaderParser::Create()); |
1408 ASSERT_TRUE(rtp_parser.get() != nullptr); | 1408 ASSERT_TRUE(rtp_parser.get() != nullptr); |
1409 webrtc::RTPHeader rtp_header; | 1409 webrtc::RTPHeader rtp_header; |
1410 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, | 1410 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, |
1411 transport_.last_sent_packet_len_, &rtp_header)); | 1411 transport_.last_sent_packet_len_, &rtp_header)); |
1412 // Marker Bit should be set to 1 for first packet. | 1412 // Marker Bit should be set to 1 for first packet. |
1413 EXPECT_TRUE(rtp_header.markerBit); | 1413 EXPECT_TRUE(rtp_header.markerBit); |
1414 | 1414 |
1415 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, | 1415 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1416 capture_time_ms + 4000, 0, nullptr, | 1416 capture_time_ms + 4000, 0, nullptr, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), | 1522 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
1523 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); | 1523 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
1524 | 1524 |
1525 // Verify that this packet does have CVO byte. | 1525 // Verify that this packet does have CVO byte. |
1526 VerifyCVOPacket( | 1526 VerifyCVOPacket( |
1527 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), | 1527 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
1528 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, | 1528 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
1529 hdr.rotation); | 1529 hdr.rotation); |
1530 } | 1530 } |
1531 } // namespace webrtc | 1531 } // namespace webrtc |
OLD | NEW |