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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
11 #include "media/cast/sender/congestion_control.h" | 11 #include "media/cast/sender/congestion_control.h" |
12 #include "media/cast/test/fake_single_thread_task_runner.h" | 12 #include "media/cast/test/fake_single_thread_task_runner.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 namespace cast { | 16 namespace cast { |
17 | 17 |
18 static const int kMaxBitrateConfigured = 5000000; | 18 static const int kMaxBitrateConfigured = 5000000; |
19 static const int kMinBitrateConfigured = 500000; | 19 static const int kMinBitrateConfigured = 500000; |
20 static const int64_t kFrameDelayMs = 33; | 20 static const int64_t kFrameDelayMs = 33; |
21 static const double kMaxFrameRate = 1000.0 / kFrameDelayMs; | 21 static const double kMaxFrameRate = 1000.0 / kFrameDelayMs; |
22 static const int64_t kStartMillisecond = INT64_C(12345678900000); | 22 static const int64_t kStartMillisecond = INT64_C(12345678900000); |
23 static const double kTargetEmptyBufferFraction = 0.9; | 23 static const double kTargetEmptyBufferFraction = 0.9; |
24 | 24 |
25 class CongestionControlTest : public ::testing::Test { | 25 class CongestionControlTest : public ::testing::Test { |
26 protected: | 26 protected: |
27 CongestionControlTest() | 27 CongestionControlTest() |
28 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)) { | 28 : testing_clock_(base::TimeTicks() + |
29 testing_clock_.Advance( | 29 base::TimeDelta::FromMilliseconds(kStartMillisecond)), |
30 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 30 task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)) { |
31 congestion_control_.reset(NewAdaptiveCongestionControl( | 31 congestion_control_.reset(NewAdaptiveCongestionControl( |
32 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured, | 32 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured, |
33 kMaxFrameRate)); | 33 kMaxFrameRate)); |
34 const int max_unacked_frames = 10; | 34 const int max_unacked_frames = 10; |
35 const base::TimeDelta target_playout_delay = | 35 const base::TimeDelta target_playout_delay = |
36 (max_unacked_frames - 1) * base::TimeDelta::FromSeconds(1) / | 36 (max_unacked_frames - 1) * base::TimeDelta::FromSeconds(1) / |
37 kMaxFrameRate; | 37 kMaxFrameRate; |
38 congestion_control_->UpdateTargetPlayoutDelay(target_playout_delay); | 38 congestion_control_->UpdateTargetPlayoutDelay(target_playout_delay); |
39 } | 39 } |
40 | 40 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), | 130 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), |
131 base::TimeDelta::FromMilliseconds(300), | 131 base::TimeDelta::FromMilliseconds(300), |
132 soft_max_bitrate); | 132 soft_max_bitrate); |
133 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 1 / 3, | 133 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 1 / 3, |
134 bitrate, | 134 bitrate, |
135 safe_bitrate * 0.05); | 135 safe_bitrate * 0.05); |
136 } | 136 } |
137 | 137 |
138 } // namespace cast | 138 } // namespace cast |
139 } // namespace media | 139 } // namespace media |
OLD | NEW |