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 <algorithm> | 11 #include <algorithm> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/base/rate_limiter.h" |
17 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
18 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" |
22 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 23 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void OnIncomingSSRCChanged(const uint32_t ssrc) override { | 60 void OnIncomingSSRCChanged(const uint32_t ssrc) override { |
60 rtp_rtcp_->SetRemoteSSRC(ssrc); | 61 rtp_rtcp_->SetRemoteSSRC(ssrc); |
61 } | 62 } |
62 | 63 |
63 private: | 64 private: |
64 RtpRtcp* rtp_rtcp_; | 65 RtpRtcp* rtp_rtcp_; |
65 }; | 66 }; |
66 | 67 |
67 class RtpRtcpRtcpTest : public ::testing::Test { | 68 class RtpRtcpRtcpTest : public ::testing::Test { |
68 protected: | 69 protected: |
69 RtpRtcpRtcpTest() : fake_clock(123456) { | 70 RtpRtcpRtcpTest() |
| 71 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) { |
70 test_csrcs.push_back(1234); | 72 test_csrcs.push_back(1234); |
71 test_csrcs.push_back(2345); | 73 test_csrcs.push_back(2345); |
72 test_ssrc = 3456; | 74 test_ssrc = 3456; |
73 test_timestamp = 4567; | 75 test_timestamp = 4567; |
74 test_sequence_number = 2345; | 76 test_sequence_number = 2345; |
75 } | 77 } |
76 ~RtpRtcpRtcpTest() {} | 78 ~RtpRtcpRtcpTest() {} |
77 | 79 |
78 virtual void SetUp() { | 80 virtual void SetUp() { |
79 receiver = new TestRtpReceiver(); | 81 receiver = new TestRtpReceiver(); |
80 transport1 = new LoopBackTransport(); | 82 transport1 = new LoopBackTransport(); |
81 transport2 = new LoopBackTransport(); | 83 transport2 = new LoopBackTransport(); |
82 myRTCPFeedback1 = new RtcpCallback(); | 84 myRTCPFeedback1 = new RtcpCallback(); |
83 myRTCPFeedback2 = new RtcpCallback(); | 85 myRTCPFeedback2 = new RtcpCallback(); |
84 | 86 |
85 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); | 87 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); |
86 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); | 88 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); |
87 | 89 |
88 RtpRtcp::Configuration configuration; | 90 RtpRtcp::Configuration configuration; |
89 configuration.audio = true; | 91 configuration.audio = true; |
90 configuration.clock = &fake_clock; | 92 configuration.clock = &fake_clock; |
91 configuration.receive_statistics = receive_statistics1_.get(); | 93 configuration.receive_statistics = receive_statistics1_.get(); |
92 configuration.outgoing_transport = transport1; | 94 configuration.outgoing_transport = transport1; |
93 configuration.intra_frame_callback = myRTCPFeedback1; | 95 configuration.intra_frame_callback = myRTCPFeedback1; |
| 96 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
94 | 97 |
95 rtp_payload_registry1_.reset(new RTPPayloadRegistry( | 98 rtp_payload_registry1_.reset(new RTPPayloadRegistry( |
96 RTPPayloadStrategy::CreateStrategy(true))); | 99 RTPPayloadStrategy::CreateStrategy(true))); |
97 rtp_payload_registry2_.reset(new RTPPayloadRegistry( | 100 rtp_payload_registry2_.reset(new RTPPayloadRegistry( |
98 RTPPayloadStrategy::CreateStrategy(true))); | 101 RTPPayloadStrategy::CreateStrategy(true))); |
99 | 102 |
100 module1 = RtpRtcp::CreateRtpRtcp(configuration); | 103 module1 = RtpRtcp::CreateRtpRtcp(configuration); |
101 | 104 |
102 rtp_feedback1_.reset(new TestRtpFeedback(module1)); | 105 rtp_feedback1_.reset(new TestRtpFeedback(module1)); |
103 | 106 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 LoopBackTransport* transport1; | 193 LoopBackTransport* transport1; |
191 LoopBackTransport* transport2; | 194 LoopBackTransport* transport2; |
192 RtcpCallback* myRTCPFeedback1; | 195 RtcpCallback* myRTCPFeedback1; |
193 RtcpCallback* myRTCPFeedback2; | 196 RtcpCallback* myRTCPFeedback2; |
194 | 197 |
195 uint32_t test_ssrc; | 198 uint32_t test_ssrc; |
196 uint32_t test_timestamp; | 199 uint32_t test_timestamp; |
197 uint16_t test_sequence_number; | 200 uint16_t test_sequence_number; |
198 std::vector<uint32_t> test_csrcs; | 201 std::vector<uint32_t> test_csrcs; |
199 SimulatedClock fake_clock; | 202 SimulatedClock fake_clock; |
| 203 RateLimiter retransmission_rate_limiter_; |
200 }; | 204 }; |
201 | 205 |
202 TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) { | 206 TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) { |
203 EXPECT_EQ(0, module1->SendRTCPReferencePictureSelection(kTestPictureId)); | 207 EXPECT_EQ(0, module1->SendRTCPReferencePictureSelection(kTestPictureId)); |
204 EXPECT_EQ(0, module1->SendRTCPSliceLossIndication(kSliPictureId)); | 208 EXPECT_EQ(0, module1->SendRTCPSliceLossIndication(kSliPictureId)); |
205 } | 209 } |
206 | 210 |
207 TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { | 211 TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { |
208 uint32_t testOfCSRC[webrtc::kRtpCsrcSize]; | 212 uint32_t testOfCSRC[webrtc::kRtpCsrcSize]; |
209 EXPECT_EQ(2, rtp_receiver2_->CSRCs(testOfCSRC)); | 213 EXPECT_EQ(2, rtp_receiver2_->CSRCs(testOfCSRC)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 EXPECT_EQ(test_ssrc, report_blocks[0].sourceSSRC); | 267 EXPECT_EQ(test_ssrc, report_blocks[0].sourceSSRC); |
264 | 268 |
265 EXPECT_EQ(0u, report_blocks[0].cumulativeLost); | 269 EXPECT_EQ(0u, report_blocks[0].cumulativeLost); |
266 EXPECT_LT(0u, report_blocks[0].delaySinceLastSR); | 270 EXPECT_LT(0u, report_blocks[0].delaySinceLastSR); |
267 EXPECT_EQ(test_sequence_number, report_blocks[0].extendedHighSeqNum); | 271 EXPECT_EQ(test_sequence_number, report_blocks[0].extendedHighSeqNum); |
268 EXPECT_EQ(0u, report_blocks[0].fractionLost); | 272 EXPECT_EQ(0u, report_blocks[0].fractionLost); |
269 } | 273 } |
270 | 274 |
271 } // namespace | 275 } // namespace |
272 } // namespace webrtc | 276 } // namespace webrtc |
OLD | NEW |