Chromium Code Reviews| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 ReadDataFromSpeechFile(capture_data.get(), length); | 73 ReadDataFromSpeechFile(capture_data.get(), length); |
| 74 const int16* data_ptr = reinterpret_cast<const int16*>(capture_data.get()); | 74 const int16* data_ptr = reinterpret_cast<const int16*>(capture_data.get()); |
| 75 scoped_ptr<media::AudioBus> data_bus = media::AudioBus::Create( | 75 scoped_ptr<media::AudioBus> data_bus = media::AudioBus::Create( |
| 76 params_.channels(), params_.frames_per_buffer()); | 76 params_.channels(), params_.frames_per_buffer()); |
| 77 for (int i = 0; i < kNumberOfPacketsForTest; ++i) { | 77 for (int i = 0; i < kNumberOfPacketsForTest; ++i) { |
| 78 data_bus->FromInterleaved(data_ptr, data_bus->frames(), 2); | 78 data_bus->FromInterleaved(data_ptr, data_bus->frames(), 2); |
| 79 audio_processor->PushCaptureData(data_bus.get()); | 79 audio_processor->PushCaptureData(data_bus.get()); |
| 80 | 80 |
| 81 // |audio_processor| does nothing when the audio processing is off in | 81 // |audio_processor| does nothing when the audio processing is off in |
| 82 // the processor. | 82 // the processor. |
| 83 audio_processor->PushRenderData( | 83 if (audio_processor->has_audio_processing()) { |
|
tommi (sloooow) - chröme
2014/01/31 13:58:32
nit: no {}
no longer working on chromium
2014/02/02 16:50:16
Done.
| |
| 84 data_ptr, | 84 audio_processor->RenderData(data_bus.get(), params_.sample_rate(), 10); |
| 85 params_.sample_rate(), params_.channels(), | 85 } |
| 86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); | |
| 87 | 86 |
| 88 int16* output = NULL; | 87 int16* output = NULL; |
| 89 int new_volume = 0; | 88 int new_volume = 0; |
| 90 while(audio_processor->ProcessAndConsumeData( | 89 while(audio_processor->ProcessAndConsumeData( |
| 91 base::TimeDelta::FromMilliseconds(10), 255, false, &new_volume, | 90 base::TimeDelta::FromMilliseconds(10), 255, false, &new_volume, |
| 92 &output)) { | 91 &output)) { |
| 93 EXPECT_TRUE(output != NULL); | 92 EXPECT_TRUE(output != NULL); |
| 94 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), | 93 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), |
| 95 expected_output_sample_rate); | 94 expected_output_sample_rate); |
| 96 EXPECT_EQ(audio_processor->OutputFormat().channels(), | 95 EXPECT_EQ(audio_processor->OutputFormat().channels(), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 #endif | 137 #endif |
| 139 } | 138 } |
| 140 | 139 |
| 141 media::AudioParameters params_; | 140 media::AudioParameters params_; |
| 142 }; | 141 }; |
| 143 | 142 |
| 144 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { | 143 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
| 145 // Setup the audio processor without enabling the flag. | 144 // Setup the audio processor without enabling the flag. |
| 146 blink::WebMediaConstraints constraints; | 145 blink::WebMediaConstraints constraints; |
| 147 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 146 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| 148 new MediaStreamAudioProcessor(params_, constraints, 0)); | 147 new MediaStreamAudioProcessor(params_, constraints, 0, NULL)); |
| 149 EXPECT_FALSE(audio_processor->has_audio_processing()); | 148 EXPECT_FALSE(audio_processor->has_audio_processing()); |
| 150 | 149 |
| 151 ProcessDataAndVerifyFormat(audio_processor, | 150 ProcessDataAndVerifyFormat(audio_processor, |
| 152 params_.sample_rate(), | 151 params_.sample_rate(), |
| 153 params_.channels(), | 152 params_.channels(), |
| 154 params_.sample_rate() / 100); | 153 params_.sample_rate() / 100); |
| 155 } | 154 } |
| 156 | 155 |
| 157 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 156 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
| 158 // Setup the audio processor with enabling the flag. | 157 // Setup the audio processor with enabling the flag. |
| 159 CommandLine::ForCurrentProcess()->AppendSwitch( | 158 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 160 switches::kEnableAudioTrackProcessing); | 159 switches::kEnableAudioTrackProcessing); |
| 161 blink::WebMediaConstraints constraints; | 160 blink::WebMediaConstraints constraints; |
| 162 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 161 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| 163 new MediaStreamAudioProcessor(params_, constraints, 0)); | 162 new MediaStreamAudioProcessor(params_, constraints, 0, NULL)); |
| 164 EXPECT_TRUE(audio_processor->has_audio_processing()); | 163 EXPECT_TRUE(audio_processor->has_audio_processing()); |
| 165 VerifyDefaultComponents(audio_processor); | 164 VerifyDefaultComponents(audio_processor); |
| 166 | 165 |
| 167 ProcessDataAndVerifyFormat(audio_processor, | 166 ProcessDataAndVerifyFormat(audio_processor, |
| 168 kAudioProcessingSampleRate, | 167 kAudioProcessingSampleRate, |
| 169 kAudioProcessingNumberOfChannel, | 168 kAudioProcessingNumberOfChannel, |
| 170 kAudioProcessingSampleRate / 100); | 169 kAudioProcessingSampleRate / 100); |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace content | 172 } // namespace content |
| OLD | NEW |