Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc

Issue 2827333005: Moving overhead counting to bitrate estimators.
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10
11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" 11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
12 12
13 #include <vector> 13 #include <vector>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 16 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
17 #include "webrtc/test/gmock.h" 17 #include "webrtc/test/gmock.h"
18 #include "webrtc/test/gtest.h" 18 #include "webrtc/test/gtest.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 namespace { 22 namespace {
23 constexpr int kInvalidBitrate = -1; 23 constexpr int kInvalidBitrate = -1;
24 constexpr int kDefaultMinProbes = 5; 24 constexpr int kDefaultMinProbes = 5;
25 constexpr int kDefaultMinBytes = 5000; 25 constexpr int kDefaultMinBytes = 5000;
26 constexpr size_t kRtpHeadersSize = 12;
27 constexpr size_t kTransportHeadersSize = 20;
26 } // anonymous namespace 28 } // anonymous namespace
27 29
28 class TestProbeBitrateEstimator : public ::testing::Test { 30 class TestProbeBitrateEstimator : public ::testing::Test {
29 public: 31 public:
30 TestProbeBitrateEstimator() : probe_bitrate_estimator_(nullptr) {} 32 TestProbeBitrateEstimator() : probe_bitrate_estimator_(nullptr) {}
31 33
32 // TODO(philipel): Use PacedPacketInfo when ProbeBitrateEstimator is rewritten 34 // TODO(philipel): Use PacedPacketInfo when ProbeBitrateEstimator is rewritten
33 // to use that information. 35 // to use that information.
34 void AddPacketFeedback(int probe_cluster_id, 36 void AddPacketFeedback(int probe_cluster_id,
35 size_t size_bytes, 37 size_t payload_size_bytes,
36 int64_t send_time_ms, 38 int64_t send_time_ms,
37 int64_t arrival_time_ms, 39 int64_t arrival_time_ms,
38 int min_probes = kDefaultMinProbes, 40 int min_probes = kDefaultMinProbes,
39 int min_bytes = kDefaultMinBytes) { 41 int min_bytes = kDefaultMinBytes) {
40 PacedPacketInfo pacing_info(probe_cluster_id, min_probes, min_bytes); 42 PacedPacketInfo pacing_info(probe_cluster_id, min_probes, min_bytes);
41 PacketFeedback packet_feedback(arrival_time_ms, send_time_ms, 0, size_bytes, 43 PacketFeedback packet_feedback(arrival_time_ms, send_time_ms, 0,
42 pacing_info); 44 payload_size_bytes, kRtpHeadersSize,
45 kTransportHeadersSize, pacing_info);
43 measured_bps_ = 46 measured_bps_ =
44 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback); 47 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
45 } 48 }
46 49
47 protected: 50 protected:
48 int measured_bps_ = kInvalidBitrate; 51 int measured_bps_ = kInvalidBitrate;
49 ProbeBitrateEstimator probe_bitrate_estimator_; 52 ProbeBitrateEstimator probe_bitrate_estimator_;
50 }; 53 };
51 54
52 TEST_F(TestProbeBitrateEstimator, OneCluster) { 55 TEST_F(TestProbeBitrateEstimator, OneCluster) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 AddPacketFeedback(0, 1000, 30, 40); 207 AddPacketFeedback(0, 1000, 30, 40);
205 208
206 auto estimated_bitrate_bps = 209 auto estimated_bitrate_bps =
207 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); 210 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps();
208 EXPECT_TRUE(estimated_bitrate_bps); 211 EXPECT_TRUE(estimated_bitrate_bps);
209 EXPECT_NEAR(*estimated_bitrate_bps, 800000, 10); 212 EXPECT_NEAR(*estimated_bitrate_bps, 800000, 10);
210 EXPECT_FALSE(probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps()); 213 EXPECT_FALSE(probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps());
211 } 214 }
212 215
213 } // namespace webrtc 216 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698