OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" | 10 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <limits> | 13 #include <limits> |
14 #include <utility> | 14 #include <utility> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" | 17 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace { |
20 | 20 |
21 constexpr size_t kMtu = 1200; | 21 constexpr size_t kMtu = 1200; |
22 constexpr uint32_t kAcceptedBitrateErrorBps = 50000; | 22 constexpr uint32_t kAcceptedBitrateErrorBps = 50000; |
23 | 23 |
24 // Number of packets needed before we have a valid estimate. | 24 // Number of packets needed before we have a valid estimate. |
25 constexpr int kNumInitialPackets = 2; | 25 constexpr int kNumInitialPackets = 2; |
26 | 26 |
27 constexpr int kInitialProbingPackets = 5; | 27 constexpr int kInitialProbingPackets = 5; |
28 | 28 |
| 29 constexpr size_t kRtpHeadersSize = 12; |
| 30 constexpr size_t kTransportHeadersSize = 20; |
| 31 |
| 32 } // namespace |
| 33 |
| 34 namespace webrtc { |
| 35 |
29 namespace test { | 36 namespace test { |
30 | 37 |
31 void TestBitrateObserver::OnReceiveBitrateChanged( | 38 void TestBitrateObserver::OnReceiveBitrateChanged( |
32 const std::vector<uint32_t>& ssrcs, | 39 const std::vector<uint32_t>& ssrcs, |
33 uint32_t bitrate) { | 40 uint32_t bitrate) { |
34 latest_bitrate_ = bitrate; | 41 latest_bitrate_ = bitrate; |
35 updated_ = true; | 42 updated_ = true; |
36 } | 43 } |
37 | 44 |
38 RtpStream::RtpStream(int fps, int bitrate_bps) | 45 RtpStream::RtpStream(int fps, int bitrate_bps) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 PacedPacketInfo()); | 178 PacedPacketInfo()); |
172 } | 179 } |
173 | 180 |
174 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, | 181 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, |
175 int64_t send_time_ms, | 182 int64_t send_time_ms, |
176 uint16_t sequence_number, | 183 uint16_t sequence_number, |
177 size_t payload_size, | 184 size_t payload_size, |
178 const PacedPacketInfo& pacing_info) { | 185 const PacedPacketInfo& pacing_info) { |
179 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); | 186 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); |
180 PacketFeedback packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, | 187 PacketFeedback packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, |
181 sequence_number, payload_size, pacing_info); | 188 sequence_number, payload_size, kRtpHeadersSize, |
| 189 kTransportHeadersSize, pacing_info); |
182 std::vector<PacketFeedback> packets; | 190 std::vector<PacketFeedback> packets; |
183 packets.push_back(packet); | 191 packets.push_back(packet); |
184 DelayBasedBwe::Result result = | 192 DelayBasedBwe::Result result = |
185 bitrate_estimator_->IncomingPacketFeedbackVector(packets); | 193 bitrate_estimator_->IncomingPacketFeedbackVector(packets); |
186 const uint32_t kDummySsrc = 0; | 194 const uint32_t kDummySsrc = 0; |
187 if (result.updated) { | 195 if (result.updated) { |
188 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, | 196 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, |
189 result.target_bitrate_bps); | 197 result.target_bitrate_bps); |
190 } | 198 } |
191 } | 199 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, | 504 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, |
497 sequence_number++, 1000); | 505 sequence_number++, 1000); |
498 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); | 506 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); |
499 send_time_ms += kFrameIntervalMs; | 507 send_time_ms += kFrameIntervalMs; |
500 } | 508 } |
501 uint32_t bitrate_after = 0; | 509 uint32_t bitrate_after = 0; |
502 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); | 510 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); |
503 EXPECT_LT(bitrate_after, bitrate_before); | 511 EXPECT_LT(bitrate_after, bitrate_before); |
504 } | 512 } |
505 } // namespace webrtc | 513 } // namespace webrtc |
OLD | NEW |