OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 <algorithm> | 11 #include <algorithm> |
12 #include <iterator> | 12 #include <iterator> |
13 #include <list> | 13 #include <list> |
14 #include <memory> | 14 #include <memory> |
15 #include <set> | 15 #include <set> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webrtc/base/rate_limiter.h" |
18 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 20 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
25 #include "webrtc/transport.h" | 26 #include "webrtc/transport.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 | 29 |
29 const int kVideoNackListSize = 30; | 30 const int kVideoNackListSize = 30; |
30 const uint32_t kTestSsrc = 3456; | 31 const uint32_t kTestSsrc = 3456; |
31 const uint16_t kTestSequenceNumber = 2345; | 32 const uint16_t kTestSequenceNumber = 2345; |
32 const uint32_t kTestNumberOfPackets = 1350; | 33 const uint32_t kTestNumberOfPackets = 1350; |
33 const int kTestNumberOfRtxPackets = 149; | 34 const int kTestNumberOfRtxPackets = 149; |
34 const int kNumFrames = 30; | 35 const int kNumFrames = 30; |
35 const int kPayloadType = 123; | 36 const int kPayloadType = 123; |
36 const int kRtxPayloadType = 98; | 37 const int kRtxPayloadType = 98; |
| 38 const int64_t kMaxRttMs = 1000; |
37 | 39 |
38 class VerifyingRtxReceiver : public NullRtpData { | 40 class VerifyingRtxReceiver : public NullRtpData { |
39 public: | 41 public: |
40 VerifyingRtxReceiver() {} | 42 VerifyingRtxReceiver() {} |
41 | 43 |
42 int32_t OnReceivedPayloadData( | 44 int32_t OnReceivedPayloadData( |
43 const uint8_t* data, | 45 const uint8_t* data, |
44 size_t size, | 46 size_t size, |
45 const webrtc::WebRtcRTPHeader* rtp_header) override { | 47 const webrtc::WebRtcRTPHeader* rtp_header) override { |
46 if (!sequence_numbers_.empty()) | 48 if (!sequence_numbers_.empty()) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 RTPPayloadRegistry* rtp_payload_registry_; | 163 RTPPayloadRegistry* rtp_payload_registry_; |
162 RtpReceiver* rtp_receiver_; | 164 RtpReceiver* rtp_receiver_; |
163 RtpRtcp* module_; | 165 RtpRtcp* module_; |
164 std::set<uint16_t> expected_sequence_numbers_; | 166 std::set<uint16_t> expected_sequence_numbers_; |
165 }; | 167 }; |
166 | 168 |
167 class RtpRtcpRtxNackTest : public ::testing::Test { | 169 class RtpRtcpRtxNackTest : public ::testing::Test { |
168 protected: | 170 protected: |
169 RtpRtcpRtxNackTest() | 171 RtpRtcpRtxNackTest() |
170 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), | 172 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), |
171 rtp_rtcp_module_(NULL), | 173 rtp_rtcp_module_(nullptr), |
172 transport_(kTestSsrc + 1), | 174 transport_(kTestSsrc + 1), |
173 receiver_(), | 175 receiver_(), |
174 payload_data_length(sizeof(payload_data)), | 176 payload_data_length(sizeof(payload_data)), |
175 fake_clock(123456) {} | 177 fake_clock(123456), |
| 178 retranmission_rate_limiter_(&fake_clock, kMaxRttMs) {} |
176 ~RtpRtcpRtxNackTest() {} | 179 ~RtpRtcpRtxNackTest() {} |
177 | 180 |
178 void SetUp() override { | 181 void SetUp() override { |
179 RtpRtcp::Configuration configuration; | 182 RtpRtcp::Configuration configuration; |
180 configuration.audio = false; | 183 configuration.audio = false; |
181 configuration.clock = &fake_clock; | 184 configuration.clock = &fake_clock; |
182 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); | 185 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); |
183 configuration.receive_statistics = receive_statistics_.get(); | 186 configuration.receive_statistics = receive_statistics_.get(); |
184 configuration.outgoing_transport = &transport_; | 187 configuration.outgoing_transport = &transport_; |
| 188 configuration.retransmission_rate_limiter = &retranmission_rate_limiter_; |
185 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration); | 189 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration); |
186 | 190 |
187 rtp_feedback_.reset(new TestRtpFeedback(rtp_rtcp_module_)); | 191 rtp_feedback_.reset(new TestRtpFeedback(rtp_rtcp_module_)); |
188 | 192 |
189 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( | 193 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( |
190 &fake_clock, &receiver_, rtp_feedback_.get(), &rtp_payload_registry_)); | 194 &fake_clock, &receiver_, rtp_feedback_.get(), &rtp_payload_registry_)); |
191 | 195 |
192 rtp_rtcp_module_->SetSSRC(kTestSsrc); | 196 rtp_rtcp_module_->SetSSRC(kTestSsrc); |
193 rtp_rtcp_module_->SetRTCPStatus(RtcpMode::kCompound); | 197 rtp_rtcp_module_->SetRTCPStatus(RtcpMode::kCompound); |
194 rtp_rtcp_module_->SetStorePacketsStatus(true, 600); | 198 rtp_rtcp_module_->SetStorePacketsStatus(true, 600); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 std::unique_ptr<ReceiveStatistics> receive_statistics_; | 285 std::unique_ptr<ReceiveStatistics> receive_statistics_; |
282 RTPPayloadRegistry rtp_payload_registry_; | 286 RTPPayloadRegistry rtp_payload_registry_; |
283 std::unique_ptr<RtpReceiver> rtp_receiver_; | 287 std::unique_ptr<RtpReceiver> rtp_receiver_; |
284 RtpRtcp* rtp_rtcp_module_; | 288 RtpRtcp* rtp_rtcp_module_; |
285 std::unique_ptr<TestRtpFeedback> rtp_feedback_; | 289 std::unique_ptr<TestRtpFeedback> rtp_feedback_; |
286 RtxLoopBackTransport transport_; | 290 RtxLoopBackTransport transport_; |
287 VerifyingRtxReceiver receiver_; | 291 VerifyingRtxReceiver receiver_; |
288 uint8_t payload_data[65000]; | 292 uint8_t payload_data[65000]; |
289 size_t payload_data_length; | 293 size_t payload_data_length; |
290 SimulatedClock fake_clock; | 294 SimulatedClock fake_clock; |
| 295 RateLimiter retranmission_rate_limiter_; |
291 }; | 296 }; |
292 | 297 |
293 TEST_F(RtpRtcpRtxNackTest, LongNackList) { | 298 TEST_F(RtpRtcpRtxNackTest, LongNackList) { |
294 const int kNumPacketsToDrop = 900; | 299 const int kNumPacketsToDrop = 900; |
295 const int kNumRequiredRtcp = 4; | 300 const int kNumRequiredRtcp = 4; |
296 uint32_t timestamp = 3000; | 301 uint32_t timestamp = 3000; |
297 uint16_t nack_list[kNumPacketsToDrop]; | 302 uint16_t nack_list[kNumPacketsToDrop]; |
298 // Disable StorePackets to be able to set a larger packet history. | 303 // Disable StorePackets to be able to set a larger packet history. |
299 rtp_rtcp_module_->SetStorePacketsStatus(false, 0); | 304 rtp_rtcp_module_->SetStorePacketsStatus(false, 0); |
300 // Enable StorePackets with a packet history of 2000 packets. | 305 // Enable StorePackets with a packet history of 2000 packets. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 RunRtxTest(kRtxRetransmitted, 10); | 337 RunRtxTest(kRtxRetransmitted, 10); |
333 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); | 338 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); |
334 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, | 339 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, |
335 *(receiver_.sequence_numbers_.rbegin())); | 340 *(receiver_.sequence_numbers_.rbegin())); |
336 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); | 341 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); |
337 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); | 342 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); |
338 EXPECT_TRUE(ExpectedPacketsReceived()); | 343 EXPECT_TRUE(ExpectedPacketsReceived()); |
339 } | 344 } |
340 | 345 |
341 } // namespace webrtc | 346 } // namespace webrtc |
OLD | NEW |