OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/synchronization/condition_variable.h" | 7 #include "base/synchronization/condition_variable.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/cast/audio_receiver/audio_decoder.h" | |
12 #include "media/cast/cast_config.h" | 11 #include "media/cast/cast_config.h" |
| 12 #include "media/cast/receiver/audio_decoder.h" |
13 #include "media/cast/test/utility/audio_utility.h" | 13 #include "media/cast/test/utility/audio_utility.h" |
14 #include "media/cast/test/utility/default_config.h" | |
15 #include "media/cast/test/utility/standalone_cast_environment.h" | 14 #include "media/cast/test/utility/standalone_cast_environment.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/opus/src/include/opus.h" | 16 #include "third_party/opus/src/include/opus.h" |
18 | 17 |
19 namespace media { | 18 namespace media { |
20 namespace cast { | 19 namespace cast { |
21 | 20 |
22 namespace { | 21 namespace { |
23 struct TestScenario { | 22 struct TestScenario { |
24 transport::AudioCodec codec; | 23 transport::AudioCodec codec; |
25 int num_channels; | 24 int num_channels; |
26 int sampling_rate; | 25 int sampling_rate; |
27 | 26 |
28 TestScenario(transport::AudioCodec c, int n, int s) | 27 TestScenario(transport::AudioCodec c, int n, int s) |
29 : codec(c), num_channels(n), sampling_rate(s) {} | 28 : codec(c), num_channels(n), sampling_rate(s) {} |
30 }; | 29 }; |
31 } // namespace | 30 } // namespace |
32 | 31 |
33 class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { | 32 class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { |
34 public: | 33 public: |
35 AudioDecoderTest() | 34 AudioDecoderTest() |
36 : cast_environment_(new StandaloneCastEnvironment()), | 35 : cast_environment_(new StandaloneCastEnvironment()), |
37 cond_(&lock_) {} | 36 cond_(&lock_) {} |
38 | 37 |
39 protected: | 38 protected: |
40 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() OVERRIDE { |
41 FrameReceiverConfig decoder_config = GetDefaultAudioReceiverConfig(); | 40 audio_decoder_.reset(new AudioDecoder(cast_environment_, |
42 decoder_config.frequency = GetParam().sampling_rate; | 41 GetParam().num_channels, |
43 decoder_config.channels = GetParam().num_channels; | 42 GetParam().sampling_rate, |
44 decoder_config.codec.audio = GetParam().codec; | 43 GetParam().codec)); |
45 audio_decoder_.reset(new AudioDecoder(cast_environment_, decoder_config)); | |
46 CHECK_EQ(STATUS_AUDIO_INITIALIZED, audio_decoder_->InitializationResult()); | 44 CHECK_EQ(STATUS_AUDIO_INITIALIZED, audio_decoder_->InitializationResult()); |
47 | 45 |
48 audio_bus_factory_.reset( | 46 audio_bus_factory_.reset( |
49 new TestAudioBusFactory(GetParam().num_channels, | 47 new TestAudioBusFactory(GetParam().num_channels, |
50 GetParam().sampling_rate, | 48 GetParam().sampling_rate, |
51 TestAudioBusFactory::kMiddleANoteFreq, | 49 TestAudioBusFactory::kMiddleANoteFreq, |
52 0.5f)); | 50 0.5f)); |
53 last_frame_id_ = 0; | 51 last_frame_id_ = 0; |
54 seen_a_decoded_frame_ = false; | 52 seen_a_decoded_frame_ = false; |
55 | 53 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 INSTANTIATE_TEST_CASE_P(AudioDecoderTestScenarios, | 232 INSTANTIATE_TEST_CASE_P(AudioDecoderTestScenarios, |
235 AudioDecoderTest, | 233 AudioDecoderTest, |
236 ::testing::Values( | 234 ::testing::Values( |
237 TestScenario(transport::kPcm16, 1, 8000), | 235 TestScenario(transport::kPcm16, 1, 8000), |
238 TestScenario(transport::kPcm16, 2, 48000), | 236 TestScenario(transport::kPcm16, 2, 48000), |
239 TestScenario(transport::kOpus, 1, 8000), | 237 TestScenario(transport::kOpus, 1, 8000), |
240 TestScenario(transport::kOpus, 2, 48000))); | 238 TestScenario(transport::kOpus, 2, 48000))); |
241 | 239 |
242 } // namespace cast | 240 } // namespace cast |
243 } // namespace media | 241 } // namespace media |
OLD | NEW |