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 <memory> | 11 #include <memory> |
12 | 12 |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
| 16 #include "webrtc/base/rate_limiter.h" |
16 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
17 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_observer.h" | 18 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_observer.h" |
18 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" |
19 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 20 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 }; | 74 }; |
74 | 75 |
75 class RtcpReceiverTest : public ::testing::Test { | 76 class RtcpReceiverTest : public ::testing::Test { |
76 protected: | 77 protected: |
77 RtcpReceiverTest() | 78 RtcpReceiverTest() |
78 : over_use_detector_options_(), | 79 : over_use_detector_options_(), |
79 system_clock_(1335900000), | 80 system_clock_(1335900000), |
80 remote_bitrate_observer_(), | 81 remote_bitrate_observer_(), |
81 remote_bitrate_estimator_( | 82 remote_bitrate_estimator_( |
82 new RemoteBitrateEstimatorSingleStream(&remote_bitrate_observer_, | 83 new RemoteBitrateEstimatorSingleStream(&remote_bitrate_observer_, |
83 &system_clock_)) { | 84 &system_clock_)), |
84 test_transport_ = new TestTransport(); | 85 retransmission_rate_limiter_(&system_clock_, 1000) { |
| 86 test_transport_.reset(new TestTransport()); |
85 | 87 |
86 RtpRtcp::Configuration configuration; | 88 RtpRtcp::Configuration configuration; |
87 configuration.audio = false; | 89 configuration.audio = false; |
88 configuration.clock = &system_clock_; | 90 configuration.clock = &system_clock_; |
89 configuration.outgoing_transport = test_transport_; | 91 configuration.outgoing_transport = test_transport_.get(); |
90 configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get(); | 92 configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get(); |
91 rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); | 93 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
92 rtcp_receiver_ = new RTCPReceiver(&system_clock_, false, nullptr, nullptr, | 94 rtp_rtcp_impl_.reset(new ModuleRtpRtcpImpl(configuration)); |
93 nullptr, nullptr, rtp_rtcp_impl_); | 95 rtcp_receiver_.reset(new RTCPReceiver(&system_clock_, false, nullptr, |
94 test_transport_->SetRTCPReceiver(rtcp_receiver_); | 96 nullptr, nullptr, nullptr, |
| 97 rtp_rtcp_impl_.get())); |
| 98 test_transport_->SetRTCPReceiver(rtcp_receiver_.get()); |
95 } | 99 } |
96 ~RtcpReceiverTest() { | 100 |
97 delete rtcp_receiver_; | 101 ~RtcpReceiverTest() {} |
98 delete rtp_rtcp_impl_; | |
99 delete test_transport_; | |
100 } | |
101 | 102 |
102 // Injects an RTCP packet into the receiver. | 103 // Injects an RTCP packet into the receiver. |
103 // Returns 0 for OK, non-0 for failure. | 104 // Returns 0 for OK, non-0 for failure. |
104 int InjectRtcpPacket(const uint8_t* packet, | 105 int InjectRtcpPacket(const uint8_t* packet, |
105 uint16_t packet_len) { | 106 uint16_t packet_len) { |
106 RTCPUtility::RTCPParserV2 rtcpParser(packet, | 107 RTCPUtility::RTCPParserV2 rtcpParser(packet, |
107 packet_len, | 108 packet_len, |
108 true); // Allow non-compound RTCP | 109 true); // Allow non-compound RTCP |
109 | 110 |
110 RTCPHelp::RTCPPacketInformation rtcpPacketInformation; | 111 RTCPHelp::RTCPPacketInformation rtcpPacketInformation; |
(...skipping 24 matching lines...) Expand all Loading... |
135 rtcp_packet_info_.xr_dlrr_item = rtcpPacketInformation.xr_dlrr_item; | 136 rtcp_packet_info_.xr_dlrr_item = rtcpPacketInformation.xr_dlrr_item; |
136 if (rtcpPacketInformation.VoIPMetric) | 137 if (rtcpPacketInformation.VoIPMetric) |
137 rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric.get()); | 138 rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric.get()); |
138 rtcp_packet_info_.transport_feedback_.reset( | 139 rtcp_packet_info_.transport_feedback_.reset( |
139 rtcpPacketInformation.transport_feedback_.release()); | 140 rtcpPacketInformation.transport_feedback_.release()); |
140 return 0; | 141 return 0; |
141 } | 142 } |
142 | 143 |
143 OverUseDetectorOptions over_use_detector_options_; | 144 OverUseDetectorOptions over_use_detector_options_; |
144 SimulatedClock system_clock_; | 145 SimulatedClock system_clock_; |
145 ModuleRtpRtcpImpl* rtp_rtcp_impl_; | 146 std::unique_ptr<TestTransport> test_transport_; |
146 RTCPReceiver* rtcp_receiver_; | 147 std::unique_ptr<ModuleRtpRtcpImpl> rtp_rtcp_impl_; |
147 TestTransport* test_transport_; | 148 std::unique_ptr<RTCPReceiver> rtcp_receiver_; |
148 RTCPHelp::RTCPPacketInformation rtcp_packet_info_; | 149 RTCPHelp::RTCPPacketInformation rtcp_packet_info_; |
149 MockRemoteBitrateObserver remote_bitrate_observer_; | 150 MockRemoteBitrateObserver remote_bitrate_observer_; |
150 std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; | 151 std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; |
| 152 RateLimiter retransmission_rate_limiter_; |
151 }; | 153 }; |
152 | 154 |
153 | 155 |
154 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) { | 156 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) { |
155 const uint8_t bad_packet[] = {0, 0, 0, 0}; | 157 const uint8_t bad_packet[] = {0, 0, 0, 0}; |
156 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | 158 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
157 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | 159 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
158 } | 160 } |
159 | 161 |
160 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { | 162 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 | 1291 |
1290 // Transport feedback should be ignored, but next packet should work. | 1292 // Transport feedback should be ignored, but next packet should work. |
1291 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); | 1293 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); |
1292 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); | 1294 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); |
1293 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); | 1295 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); |
1294 } | 1296 } |
1295 | 1297 |
1296 } // Anonymous namespace | 1298 } // Anonymous namespace |
1297 | 1299 |
1298 } // namespace webrtc | 1300 } // namespace webrtc |
OLD | NEW |