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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_unittest.cc

Issue 139303016: Feed the render data to MediaStreamAudioProcessor and used AudioBus in render callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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()) {
84 data_ptr, 84 static_cast<WebRtcAudioRendererSource*>(audio_processor)->RenderData(
miu 2014/01/24 22:27:19 This threw me off a bit. I see that you're trying
no longer working on chromium 2014/01/27 17:09:33 Actually MediaStreamAudioProcessorTest had been ma
85 params_.sample_rate(), params_.channels(), 85 data_bus.get(), params_.sample_rate(), 10);
86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); 86 }
87 87
88 int16* output = NULL; 88 int16* output = NULL;
89 while(audio_processor->ProcessAndConsumeData( 89 while(audio_processor->ProcessAndConsumeData(
90 base::TimeDelta::FromMilliseconds(10), 255, false, &output)) { 90 base::TimeDelta::FromMilliseconds(10), 255, false, &output)) {
91 EXPECT_TRUE(output != NULL); 91 EXPECT_TRUE(output != NULL);
92 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), 92 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(),
93 expected_output_sample_rate); 93 expected_output_sample_rate);
94 EXPECT_EQ(audio_processor->OutputFormat().channels(), 94 EXPECT_EQ(audio_processor->OutputFormat().channels(),
95 expected_output_channels); 95 expected_output_channels);
96 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(), 96 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(),
97 expected_output_buffer_size); 97 expected_output_buffer_size);
98 } 98 }
99 99
100 data_ptr += params_.frames_per_buffer() * params_.channels(); 100 data_ptr += params_.frames_per_buffer() * params_.channels();
101 } 101 }
102 } 102 }
103 103
104 media::AudioParameters params_; 104 media::AudioParameters params_;
105 }; 105 };
106 106
107 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { 107 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) {
108 // Setup the audio processor without enabling the flag. 108 // Setup the audio processor without enabling the flag.
109 blink::WebMediaConstraints constraints; 109 blink::WebMediaConstraints constraints;
110 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 110 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
111 new MediaStreamAudioProcessor(params_, constraints, 0)); 111 new MediaStreamAudioProcessor(params_, constraints, 0, NULL));
112 EXPECT_FALSE(audio_processor->has_audio_processing()); 112 EXPECT_FALSE(audio_processor->has_audio_processing());
113 113
114 ProcessDataAndVerifyFormat(audio_processor, 114 ProcessDataAndVerifyFormat(audio_processor,
115 params_.sample_rate(), 115 params_.sample_rate(),
116 params_.channels(), 116 params_.channels(),
117 params_.sample_rate() / 100); 117 params_.sample_rate() / 100);
118 } 118 }
119 119
120 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { 120 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) {
121 // Setup the audio processor with enabling the flag. 121 // Setup the audio processor with enabling the flag.
122 CommandLine::ForCurrentProcess()->AppendSwitch( 122 CommandLine::ForCurrentProcess()->AppendSwitch(
123 switches::kEnableAudioTrackProcessing); 123 switches::kEnableAudioTrackProcessing);
124 blink::WebMediaConstraints constraints; 124 blink::WebMediaConstraints constraints;
125 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 125 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
126 new MediaStreamAudioProcessor(params_, constraints, 0)); 126 new MediaStreamAudioProcessor(params_, constraints, 0, NULL));
127 EXPECT_TRUE(audio_processor->has_audio_processing()); 127 EXPECT_TRUE(audio_processor->has_audio_processing());
128 128
129 ProcessDataAndVerifyFormat(audio_processor, 129 ProcessDataAndVerifyFormat(audio_processor,
130 kAudioProcessingSampleRate, 130 kAudioProcessingSampleRate,
131 kAudioProcessingNumberOfChannel, 131 kAudioProcessingNumberOfChannel,
132 kAudioProcessingSampleRate / 100); 132 kAudioProcessingSampleRate / 100);
133 } 133 }
134 134
135 } // namespace content 135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698