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

Side by Side Diff: media/cast/sender/audio_encoder_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
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 7
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "media/base/audio_bus.h" 16 #include "media/base/audio_bus.h"
17 #include "media/base/fake_single_thread_task_runner.h"
17 #include "media/base/media.h" 18 #include "media/base/media.h"
18 #include "media/cast/cast_config.h" 19 #include "media/cast/cast_config.h"
19 #include "media/cast/cast_environment.h" 20 #include "media/cast/cast_environment.h"
20 #include "media/cast/common/rtp_time.h" 21 #include "media/cast/common/rtp_time.h"
21 #include "media/cast/sender/audio_encoder.h" 22 #include "media/cast/sender/audio_encoder.h"
22 #include "media/cast/test/fake_single_thread_task_runner.h"
23 #include "media/cast/test/utility/audio_utility.h" 23 #include "media/cast/test/utility/audio_utility.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 25
26 namespace media { 26 namespace media {
27 namespace cast { 27 namespace cast {
28 28
29 static const int kNumChannels = 2; 29 static const int kNumChannels = 2;
30 30
31 namespace { 31 namespace {
32 32
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { 104 class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
105 public: 105 public:
106 AudioEncoderTest() { 106 AudioEncoderTest() {
107 InitializeMediaLibrary(); 107 InitializeMediaLibrary();
108 testing_clock_ = new base::SimpleTestTickClock(); 108 testing_clock_ = new base::SimpleTestTickClock();
109 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); 109 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
110 } 110 }
111 111
112 void SetUp() final { 112 void SetUp() final {
113 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); 113 task_runner_ = new FakeSingleThreadTaskRunner(testing_clock_);
114 cast_environment_ = 114 cast_environment_ =
115 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), 115 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_),
116 task_runner_, task_runner_, task_runner_); 116 task_runner_, task_runner_, task_runner_);
117 } 117 }
118 118
119 virtual ~AudioEncoderTest() {} 119 virtual ~AudioEncoderTest() {}
120 120
121 void RunTestForCodec(Codec codec) { 121 void RunTestForCodec(Codec codec) {
122 const TestScenario& scenario = GetParam(); 122 const TestScenario& scenario = GetParam();
123 SCOPED_TRACE(::testing::Message() << "Durations: " << scenario.ToString()); 123 SCOPED_TRACE(::testing::Message() << "Durations: " << scenario.ToString());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 kDefaultAudioSamplingRate, 164 kDefaultAudioSamplingRate,
165 kDefaultAudioEncoderBitrate, 165 kDefaultAudioEncoderBitrate,
166 codec, 166 codec,
167 base::Bind(&TestEncodedAudioFrameReceiver::FrameEncoded, 167 base::Bind(&TestEncodedAudioFrameReceiver::FrameEncoded,
168 base::Unretained(receiver_.get())))); 168 base::Unretained(receiver_.get()))));
169 169
170 receiver_->SetSamplesPerFrame(audio_encoder_->GetSamplesPerFrame()); 170 receiver_->SetSamplesPerFrame(audio_encoder_->GetSamplesPerFrame());
171 } 171 }
172 172
173 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. 173 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
174 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; 174 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
175 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; 175 scoped_ptr<TestAudioBusFactory> audio_bus_factory_;
176 scoped_ptr<TestEncodedAudioFrameReceiver> receiver_; 176 scoped_ptr<TestEncodedAudioFrameReceiver> receiver_;
177 scoped_ptr<AudioEncoder> audio_encoder_; 177 scoped_ptr<AudioEncoder> audio_encoder_;
178 scoped_refptr<CastEnvironment> cast_environment_; 178 scoped_refptr<CastEnvironment> cast_environment_;
179 179
180 DISALLOW_COPY_AND_ASSIGN(AudioEncoderTest); 180 DISALLOW_COPY_AND_ASSIGN(AudioEncoderTest);
181 }; 181 };
182 182
183 TEST_P(AudioEncoderTest, EncodeOpus) { 183 TEST_P(AudioEncoderTest, EncodeOpus) {
184 RunTestForCodec(CODEC_AUDIO_OPUS); 184 RunTestForCodec(CODEC_AUDIO_OPUS);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), 247 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)),
248 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), 248 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)),
249 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), 249 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)),
250 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)), 250 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)),
251 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)), 251 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)),
252 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)), 252 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)),
253 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns)))); 253 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns))));
254 254
255 } // namespace cast 255 } // namespace cast
256 } // namespace media 256 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/receiver/frame_receiver_unittest.cc ('k') | media/cast/sender/audio_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698