OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/safe_conversions.h" |
16 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" | 17 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" |
17 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" | 18 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" |
18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
20 #include "webrtc/system_wrappers/include/clock.h" | 21 #include "webrtc/system_wrappers/include/clock.h" |
21 #include "webrtc/test/gmock.h" | 22 #include "webrtc/test/gmock.h" |
22 #include "webrtc/test/gtest.h" | 23 #include "webrtc/test/gtest.h" |
23 | 24 |
24 using ::testing::_; | 25 using ::testing::_; |
25 using ::testing::Invoke; | 26 using ::testing::Invoke; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 122 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
122 packet.arrival_time_ms * 1000)); | 123 packet.arrival_time_ms * 1000)); |
123 } | 124 } |
124 | 125 |
125 feedback.Build(); | 126 feedback.Build(); |
126 | 127 |
127 adapter_->OnTransportFeedback(feedback); | 128 adapter_->OnTransportFeedback(feedback); |
128 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); | 129 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
129 } | 130 } |
130 | 131 |
| 132 TEST_F(TransportFeedbackAdapterTest, Timeout) { |
| 133 const int64_t kFeedbackTimeoutMs = 60001; |
| 134 { |
| 135 std::vector<PacketInfo> packets; |
| 136 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); |
| 137 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); |
| 138 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); |
| 139 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); |
| 140 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); |
| 141 |
| 142 for (const PacketInfo& packet : packets) |
| 143 OnSentPacket(packet); |
| 144 |
| 145 rtcp::TransportFeedback feedback; |
| 146 feedback.SetBase(packets[0].sequence_number, |
| 147 packets[0].arrival_time_ms * 1000); |
| 148 |
| 149 for (const PacketInfo& packet : packets) { |
| 150 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
| 151 packet.arrival_time_ms * 1000)); |
| 152 } |
| 153 |
| 154 feedback.Build(); |
| 155 |
| 156 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs); |
| 157 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, |
| 158 5, 1500, 1); |
| 159 OnSentPacket(later_packet); |
| 160 |
| 161 adapter_->OnTransportFeedback(feedback); |
| 162 EXPECT_EQ(0, rtc::checked_cast<int>( |
| 163 adapter_->GetTransportFeedbackVector().size())); |
| 164 } |
| 165 |
| 166 { |
| 167 std::vector<PacketInfo> packets; |
| 168 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); |
| 169 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); |
| 170 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); |
| 171 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); |
| 172 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); |
| 173 |
| 174 for (const PacketInfo& packet : packets) |
| 175 OnSentPacket(packet); |
| 176 |
| 177 rtcp::TransportFeedback feedback; |
| 178 feedback.SetBase(packets[0].sequence_number, |
| 179 packets[0].arrival_time_ms * 1000); |
| 180 |
| 181 for (const PacketInfo& packet : packets) { |
| 182 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
| 183 packet.arrival_time_ms * 1000)); |
| 184 } |
| 185 |
| 186 feedback.Build(); |
| 187 |
| 188 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1); |
| 189 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, |
| 190 5, 1500, 1); |
| 191 OnSentPacket(later_packet); |
| 192 |
| 193 adapter_->OnTransportFeedback(feedback); |
| 194 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
| 195 } |
| 196 } |
| 197 |
131 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { | 198 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { |
132 std::vector<PacketInfo> packets; | 199 std::vector<PacketInfo> packets; |
133 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); | 200 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); |
134 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); | 201 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); |
135 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); | 202 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); |
136 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); | 203 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); |
137 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); | 204 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); |
138 | 205 |
139 const uint16_t kSendSideDropBefore = 1; | 206 const uint16_t kSendSideDropBefore = 1; |
140 const uint16_t kReceiveSideDropAfter = 3; | 207 const uint16_t kReceiveSideDropAfter = 3; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 EXPECT_TRUE(feedback.get() != nullptr); | 413 EXPECT_TRUE(feedback.get() != nullptr); |
347 adapter_->OnTransportFeedback(*feedback.get()); | 414 adapter_->OnTransportFeedback(*feedback.get()); |
348 clock_.AdvanceTimeMilliseconds(50); | 415 clock_.AdvanceTimeMilliseconds(50); |
349 ++seq_num; | 416 ++seq_num; |
350 } | 417 } |
351 EXPECT_GT(target_bitrate_bps_, 0u); | 418 EXPECT_GT(target_bitrate_bps_, 0u); |
352 } | 419 } |
353 | 420 |
354 } // namespace test | 421 } // namespace test |
355 } // namespace webrtc | 422 } // namespace webrtc |
OLD | NEW |