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 <stdlib.h> | 11 #include <stdlib.h> |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
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/rtp_payload_registry.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" |
24 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 25 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 const unsigned char kPayloadType = 100; | 29 const unsigned char kPayloadType = 100; |
29 | 30 |
30 }; | 31 }; |
31 | 32 |
32 namespace webrtc { | 33 namespace webrtc { |
33 | 34 |
34 class RtpRtcpVideoTest : public ::testing::Test { | 35 class RtpRtcpVideoTest : public ::testing::Test { |
35 protected: | 36 protected: |
36 RtpRtcpVideoTest() | 37 RtpRtcpVideoTest() |
37 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), | 38 : rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), |
38 test_ssrc_(3456), | 39 test_ssrc_(3456), |
39 test_timestamp_(4567), | 40 test_timestamp_(4567), |
40 test_sequence_number_(2345), | 41 test_sequence_number_(2345), |
41 fake_clock(123456) {} | 42 fake_clock(123456), |
| 43 retransmission_rate_limiter_(&fake_clock, 1000) {} |
42 ~RtpRtcpVideoTest() {} | 44 ~RtpRtcpVideoTest() {} |
43 | 45 |
44 virtual void SetUp() { | 46 virtual void SetUp() { |
45 transport_ = new LoopBackTransport(); | 47 transport_ = new LoopBackTransport(); |
46 receiver_ = new TestRtpReceiver(); | 48 receiver_ = new TestRtpReceiver(); |
47 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); | 49 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); |
48 RtpRtcp::Configuration configuration; | 50 RtpRtcp::Configuration configuration; |
49 configuration.audio = false; | 51 configuration.audio = false; |
50 configuration.clock = &fake_clock; | 52 configuration.clock = &fake_clock; |
51 configuration.outgoing_transport = transport_; | 53 configuration.outgoing_transport = transport_; |
| 54 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
52 | 55 |
53 video_module_ = RtpRtcp::CreateRtpRtcp(configuration); | 56 video_module_ = RtpRtcp::CreateRtpRtcp(configuration); |
54 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( | 57 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( |
55 &fake_clock, receiver_, NULL, &rtp_payload_registry_)); | 58 &fake_clock, receiver_, NULL, &rtp_payload_registry_)); |
56 | 59 |
57 video_module_->SetRTCPStatus(RtcpMode::kCompound); | 60 video_module_->SetRTCPStatus(RtcpMode::kCompound); |
58 video_module_->SetSSRC(test_ssrc_); | 61 video_module_->SetSSRC(test_ssrc_); |
59 video_module_->SetStorePacketsStatus(true, 600); | 62 video_module_->SetStorePacketsStatus(true, 600); |
60 EXPECT_EQ(0, video_module_->SetSendingStatus(true)); | 63 EXPECT_EQ(0, video_module_->SetSendingStatus(true)); |
61 | 64 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 std::unique_ptr<RtpReceiver> rtp_receiver_; | 135 std::unique_ptr<RtpReceiver> rtp_receiver_; |
133 RtpRtcp* video_module_; | 136 RtpRtcp* video_module_; |
134 LoopBackTransport* transport_; | 137 LoopBackTransport* transport_; |
135 TestRtpReceiver* receiver_; | 138 TestRtpReceiver* receiver_; |
136 uint32_t test_ssrc_; | 139 uint32_t test_ssrc_; |
137 uint32_t test_timestamp_; | 140 uint32_t test_timestamp_; |
138 uint16_t test_sequence_number_; | 141 uint16_t test_sequence_number_; |
139 uint8_t video_frame_[65000]; | 142 uint8_t video_frame_[65000]; |
140 size_t payload_data_length_; | 143 size_t payload_data_length_; |
141 SimulatedClock fake_clock; | 144 SimulatedClock fake_clock; |
| 145 RateLimiter retransmission_rate_limiter_; |
142 }; | 146 }; |
143 | 147 |
144 TEST_F(RtpRtcpVideoTest, BasicVideo) { | 148 TEST_F(RtpRtcpVideoTest, BasicVideo) { |
145 uint32_t timestamp = 3000; | 149 uint32_t timestamp = 3000; |
146 EXPECT_EQ(0, video_module_->SendOutgoingData(kVideoFrameDelta, 123, | 150 EXPECT_EQ(0, video_module_->SendOutgoingData(kVideoFrameDelta, 123, |
147 timestamp, | 151 timestamp, |
148 timestamp / 90, | 152 timestamp / 90, |
149 video_frame_, | 153 video_frame_, |
150 payload_data_length_)); | 154 payload_data_length_)); |
151 } | 155 } |
(...skipping 30 matching lines...) Expand all Loading... |
182 payload_specific, true)); | 186 payload_specific, true)); |
183 EXPECT_EQ(0u, receiver_->payload_size()); | 187 EXPECT_EQ(0u, receiver_->payload_size()); |
184 EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength); | 188 EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength); |
185 } | 189 } |
186 timestamp += 3000; | 190 timestamp += 3000; |
187 fake_clock.AdvanceTimeMilliseconds(33); | 191 fake_clock.AdvanceTimeMilliseconds(33); |
188 } | 192 } |
189 } | 193 } |
190 | 194 |
191 } // namespace webrtc | 195 } // namespace webrtc |
OLD | NEW |