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 "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 11 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <memory> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "webrtc/test/null_transport.h" | 17 #include "webrtc/test/null_transport.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, | 21 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, |
21 RTPPayloadRegistry* payload_registry, | 22 RTPPayloadRegistry* payload_registry, |
22 RtpReceiver* receiver, | 23 RtpReceiver* receiver, |
23 ReceiveStatistics* receive_statistics) { | 24 ReceiveStatistics* receive_statistics) { |
(...skipping 10 matching lines...) Expand all Loading... |
34 bool LoopBackTransport::SendRtp(const uint8_t* data, | 35 bool LoopBackTransport::SendRtp(const uint8_t* data, |
35 size_t len, | 36 size_t len, |
36 const PacketOptions& options) { | 37 const PacketOptions& options) { |
37 count_++; | 38 count_++; |
38 if (packet_loss_ > 0) { | 39 if (packet_loss_ > 0) { |
39 if ((count_ % packet_loss_) == 0) { | 40 if ((count_ % packet_loss_) == 0) { |
40 return true; | 41 return true; |
41 } | 42 } |
42 } | 43 } |
43 RTPHeader header; | 44 RTPHeader header; |
44 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 45 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
45 if (!parser->Parse(static_cast<const uint8_t*>(data), len, &header)) { | 46 if (!parser->Parse(static_cast<const uint8_t*>(data), len, &header)) { |
46 return false; | 47 return false; |
47 } | 48 } |
48 PayloadUnion payload_specific; | 49 PayloadUnion payload_specific; |
49 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, | 50 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, |
50 &payload_specific)) { | 51 &payload_specific)) { |
51 return false; | 52 return false; |
52 } | 53 } |
53 receive_statistics_->IncomingPacket(header, len, false); | 54 receive_statistics_->IncomingPacket(header, len, false); |
54 if (!rtp_receiver_->IncomingRtpPacket(header, | 55 if (!rtp_receiver_->IncomingRtpPacket(header, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 configuration.audio = true; | 94 configuration.audio = true; |
94 configuration.clock = &fake_clock_; | 95 configuration.clock = &fake_clock_; |
95 configuration.outgoing_transport = &null_transport_; | 96 configuration.outgoing_transport = &null_transport_; |
96 module_.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 97 module_.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
97 rtp_payload_registry_.reset(new RTPPayloadRegistry( | 98 rtp_payload_registry_.reset(new RTPPayloadRegistry( |
98 RTPPayloadStrategy::CreateStrategy(true))); | 99 RTPPayloadStrategy::CreateStrategy(true))); |
99 rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver( | 100 rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver( |
100 &fake_clock_, NULL, NULL, rtp_payload_registry_.get())); | 101 &fake_clock_, NULL, NULL, rtp_payload_registry_.get())); |
101 } | 102 } |
102 | 103 |
103 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 104 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
104 rtc::scoped_ptr<RtpReceiver> rtp_receiver_; | 105 std::unique_ptr<RtpReceiver> rtp_receiver_; |
105 rtc::scoped_ptr<RtpRtcp> module_; | 106 std::unique_ptr<RtpRtcp> module_; |
106 uint32_t test_ssrc_; | 107 uint32_t test_ssrc_; |
107 uint32_t test_timestamp_; | 108 uint32_t test_timestamp_; |
108 uint16_t test_sequence_number_; | 109 uint16_t test_sequence_number_; |
109 std::vector<uint32_t> test_csrcs_; | 110 std::vector<uint32_t> test_csrcs_; |
110 SimulatedClock fake_clock_; | 111 SimulatedClock fake_clock_; |
111 test::NullTransport null_transport_; | 112 test::NullTransport null_transport_; |
112 }; | 113 }; |
113 | 114 |
114 TEST_F(RtpRtcpAPITest, Basic) { | 115 TEST_F(RtpRtcpAPITest, Basic) { |
115 module_->SetSequenceNumber(test_sequence_number_); | 116 module_->SetSequenceNumber(test_sequence_number_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 rtx_header.payloadType = kRtxPayloadType; | 182 rtx_header.payloadType = kRtxPayloadType; |
182 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 183 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
183 rtx_header.ssrc = 0; | 184 rtx_header.ssrc = 0; |
184 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); | 185 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); |
185 rtx_header.ssrc = kRtxSsrc; | 186 rtx_header.ssrc = kRtxSsrc; |
186 rtx_header.payloadType = 0; | 187 rtx_header.payloadType = 0; |
187 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 188 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
188 } | 189 } |
189 | 190 |
190 } // namespace webrtc | 191 } // namespace webrtc |
OLD | NEW |