OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
10 #include "media/cast/sender/congestion_control.h" | 10 #include "media/cast/sender/congestion_control.h" |
11 #include "media/cast/test/fake_single_thread_task_runner.h" | 11 #include "media/cast/test/fake_single_thread_task_runner.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 namespace cast { | 15 namespace cast { |
16 | 16 |
17 static const uint32 kMaxBitrateConfigured = 5000000; | 17 static const uint32 kMaxBitrateConfigured = 5000000; |
18 static const uint32 kMinBitrateConfigured = 500000; | 18 static const uint32 kMinBitrateConfigured = 500000; |
19 static const int64 kStartMillisecond = INT64_C(12345678900000); | 19 static const int64 kStartMillisecond = INT64_C(12345678900000); |
20 static const double kTargetEmptyBufferFraction = 0.9; | 20 static const double kTargetEmptyBufferFraction = 0.9; |
21 | 21 |
22 class CongestionControlTest : public ::testing::Test { | 22 class CongestionControlTest : public ::testing::Test { |
23 protected: | 23 protected: |
24 CongestionControlTest() | 24 CongestionControlTest() |
25 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)) { | 25 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)) { |
26 testing_clock_.Advance( | 26 testing_clock_.Advance( |
27 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 27 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
28 congestion_control_.reset(new CongestionControl( | 28 congestion_control_.reset(NewAdaptiveCongestionControl( |
29 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured, 10)); | 29 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured, 10)); |
30 } | 30 } |
31 | 31 |
32 void AckFrame(uint32 frame_id) { | 32 void AckFrame(uint32 frame_id) { |
33 congestion_control_->AckFrame(frame_id, testing_clock_.NowTicks()); | 33 congestion_control_->AckFrame(frame_id, testing_clock_.NowTicks()); |
34 } | 34 } |
35 | 35 |
36 void Run(uint32 frames, | 36 void Run(uint32 frames, |
37 size_t frame_size, | 37 size_t frame_size, |
38 base::TimeDelta rtt, | 38 base::TimeDelta rtt, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), | 112 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), |
113 base::TimeDelta::FromMilliseconds(300)); | 113 base::TimeDelta::FromMilliseconds(300)); |
114 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 1 / 3, | 114 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 1 / 3, |
115 bitrate, | 115 bitrate, |
116 safe_bitrate * 0.05); | 116 safe_bitrate * 0.05); |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 } // namespace cast | 120 } // namespace cast |
121 } // namespace media | 121 } // namespace media |
OLD | NEW |