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

Side by Side Diff: media/cast/sender/congestion_control_unittest.cc

Issue 1829163002: Lazily prune the multibuffer block cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no export Created 4 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
« no previous file with comments | « media/cast/sender/audio_sender_unittest.cc ('k') | media/cast/sender/video_encoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/test/simple_test_tick_clock.h" 12 #include "base/test/simple_test_tick_clock.h"
13 #include "media/base/fake_single_thread_task_runner.h"
13 #include "media/cast/sender/congestion_control.h" 14 #include "media/cast/sender/congestion_control.h"
14 #include "media/cast/test/fake_single_thread_task_runner.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace media { 17 namespace media {
18 namespace cast { 18 namespace cast {
19 19
20 static const int kMaxBitrateConfigured = 5000000; 20 static const int kMaxBitrateConfigured = 5000000;
21 static const int kMinBitrateConfigured = 500000; 21 static const int kMinBitrateConfigured = 500000;
22 static const int64_t kFrameDelayMs = 33; 22 static const int64_t kFrameDelayMs = 33;
23 static const double kMaxFrameRate = 1000.0 / kFrameDelayMs; 23 static const double kMaxFrameRate = 1000.0 / kFrameDelayMs;
24 static const int64_t kStartMillisecond = INT64_C(12345678900000); 24 static const int64_t kStartMillisecond = INT64_C(12345678900000);
25 static const double kTargetEmptyBufferFraction = 0.9; 25 static const double kTargetEmptyBufferFraction = 0.9;
26 26
27 class CongestionControlTest : public ::testing::Test { 27 class CongestionControlTest : public ::testing::Test {
28 protected: 28 protected:
29 CongestionControlTest() 29 CongestionControlTest()
30 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)) { 30 : task_runner_(new FakeSingleThreadTaskRunner(&testing_clock_)) {
31 testing_clock_.Advance( 31 testing_clock_.Advance(
32 base::TimeDelta::FromMilliseconds(kStartMillisecond)); 32 base::TimeDelta::FromMilliseconds(kStartMillisecond));
33 congestion_control_.reset(NewAdaptiveCongestionControl( 33 congestion_control_.reset(NewAdaptiveCongestionControl(
34 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured, 34 &testing_clock_, kMaxBitrateConfigured, kMinBitrateConfigured,
35 kMaxFrameRate)); 35 kMaxFrameRate));
36 const int max_unacked_frames = 10; 36 const int max_unacked_frames = 10;
37 const base::TimeDelta target_playout_delay = 37 const base::TimeDelta target_playout_delay =
38 (max_unacked_frames - 1) * base::TimeDelta::FromSeconds(1) / 38 (max_unacked_frames - 1) * base::TimeDelta::FromSeconds(1) /
39 kMaxFrameRate; 39 kMaxFrameRate;
40 congestion_control_->UpdateTargetPlayoutDelay(target_playout_delay); 40 congestion_control_->UpdateTargetPlayoutDelay(target_playout_delay);
(...skipping 16 matching lines...) Expand all
57 base::Bind(&CongestionControlTest::AckFrame, 57 base::Bind(&CongestionControlTest::AckFrame,
58 base::Unretained(this), 58 base::Unretained(this),
59 frame_id_), 59 frame_id_),
60 ack_time); 60 ack_time);
61 task_runner_->Sleep(frame_delay); 61 task_runner_->Sleep(frame_delay);
62 } 62 }
63 } 63 }
64 64
65 base::SimpleTestTickClock testing_clock_; 65 base::SimpleTestTickClock testing_clock_;
66 scoped_ptr<CongestionControl> congestion_control_; 66 scoped_ptr<CongestionControl> congestion_control_;
67 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; 67 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
68 uint32_t frame_id_; 68 uint32_t frame_id_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(CongestionControlTest); 70 DISALLOW_COPY_AND_ASSIGN(CongestionControlTest);
71 }; 71 };
72 72
73 // Tests that AdaptiveCongestionControl returns reasonable bitrates based on 73 // Tests that AdaptiveCongestionControl returns reasonable bitrates based on
74 // estimations of network bandwidth and how much is in-flight (i.e, using the 74 // estimations of network bandwidth and how much is in-flight (i.e, using the
75 // "target buffer fill" model). 75 // "target buffer fill" model).
76 TEST_F(CongestionControlTest, SimpleRun) { 76 TEST_F(CongestionControlTest, SimpleRun) {
77 uint32_t frame_size = 10000 * 8; 77 uint32_t frame_size = 10000 * 8;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Results should show that we have ~200ms to send. 137 // Results should show that we have ~200ms to send.
138 bitrate = congestion_control_->GetBitrate( 138 bitrate = congestion_control_->GetBitrate(
139 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), 139 testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300),
140 base::TimeDelta::FromMilliseconds(300)); 140 base::TimeDelta::FromMilliseconds(300));
141 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 2 / 3, bitrate, 141 EXPECT_NEAR(safe_bitrate / kTargetEmptyBufferFraction * 2 / 3, bitrate,
142 safe_bitrate * 0.05); 142 safe_bitrate * 0.05);
143 } 143 }
144 144
145 } // namespace cast 145 } // namespace cast
146 } // namespace media 146 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender_unittest.cc ('k') | media/cast/sender/video_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698