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

Side by Side Diff: trunk/src/content/renderer/media/webrtc_audio_capturer_unittest.cc

Issue 318373002: Revert 273044 "Change kEnableAudioTrackProcessing to a disable f..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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/logging.h" 6 #include "base/logging.h"
7 #include "content/public/common/content_switches.h" 7 #include "content/public/common/content_switches.h"
8 #include "content/renderer/media/mock_media_constraint_factory.h" 8 #include "content/renderer/media/mock_media_constraint_factory.h"
9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
10 #include "content/renderer/media/webrtc_audio_capturer.h" 10 #include "content/renderer/media/webrtc_audio_capturer.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #if defined(OS_ANDROID) 77 #if defined(OS_ANDROID)
78 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 78 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
79 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 960) { 79 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 960) {
80 // Android works with a buffer size bigger than 20ms. 80 // Android works with a buffer size bigger than 20ms.
81 #else 81 #else
82 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 82 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
83 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128) { 83 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128) {
84 #endif 84 #endif
85 } 85 }
86 86
87 void DisableAudioTrackProcessing() { 87 void EnableAudioTrackProcessing() {
88 CommandLine::ForCurrentProcess()->AppendSwitch( 88 CommandLine::ForCurrentProcess()->AppendSwitch(
89 switches::kDisableAudioTrackProcessing); 89 switches::kEnableAudioTrackProcessing);
90 } 90 }
91 91
92 void VerifyAudioParams(const blink::WebMediaConstraints& constraints, 92 void VerifyAudioParams(const blink::WebMediaConstraints& constraints,
93 bool need_audio_processing) { 93 bool need_audio_processing) {
94 capturer_ = WebRtcAudioCapturer::CreateCapturer( 94 capturer_ = WebRtcAudioCapturer::CreateCapturer(
95 -1, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, 95 -1, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE,
96 "", "", params_.sample_rate(), 96 "", "", params_.sample_rate(),
97 params_.channel_layout(), 97 params_.channel_layout(),
98 params_.frames_per_buffer()), 98 params_.frames_per_buffer()),
99 constraints, NULL, NULL); 99 constraints, NULL, NULL);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 media::AudioParameters params_; 151 media::AudioParameters params_;
152 scoped_refptr<MockCapturerSource> capturer_source_; 152 scoped_refptr<MockCapturerSource> capturer_source_;
153 scoped_refptr<WebRtcAudioCapturer> capturer_; 153 scoped_refptr<WebRtcAudioCapturer> capturer_;
154 scoped_ptr<WebRtcLocalAudioTrack> track_; 154 scoped_ptr<WebRtcLocalAudioTrack> track_;
155 }; 155 };
156 156
157 // Pass the delay value, volume and key_pressed info via capture callback, and 157 // Pass the delay value, volume and key_pressed info via capture callback, and
158 // those values should be correctly stored and passed to the track. 158 // those values should be correctly stored and passed to the track.
159 TEST_F(WebRtcAudioCapturerTest, VerifyAudioParamsWithoutAudioProcessing) { 159 TEST_F(WebRtcAudioCapturerTest, VerifyAudioParams) {
160 DisableAudioTrackProcessing();
161 // Use constraints with default settings. 160 // Use constraints with default settings.
162 MockMediaConstraintFactory constraint_factory; 161 MockMediaConstraintFactory constraint_factory;
163 VerifyAudioParams(constraint_factory.CreateWebMediaConstraints(), true); 162 VerifyAudioParams(constraint_factory.CreateWebMediaConstraints(), true);
164 } 163 }
165 164
166 TEST_F(WebRtcAudioCapturerTest, VerifyAudioParamsWithAudioProcessing) { 165 TEST_F(WebRtcAudioCapturerTest, VerifyAudioParamsWithAudioProcessing) {
166 EnableAudioTrackProcessing();
167 // Turn off the default constraints to verify that the sink will get packets 167 // Turn off the default constraints to verify that the sink will get packets
168 // with a buffer size smaller than 10ms. 168 // with a buffer size smaller than 10ms.
169 MockMediaConstraintFactory constraint_factory; 169 MockMediaConstraintFactory constraint_factory;
170 constraint_factory.DisableDefaultAudioConstraints(); 170 constraint_factory.DisableDefaultAudioConstraints();
171 VerifyAudioParams(constraint_factory.CreateWebMediaConstraints(), false); 171 VerifyAudioParams(constraint_factory.CreateWebMediaConstraints(), false);
172 } 172 }
173 173
174 TEST_F(WebRtcAudioCapturerTest, FailToCreateCapturerWithWrongConstraints) { 174 TEST_F(WebRtcAudioCapturerTest, FailToCreateCapturerWithWrongConstraints) {
175 EnableAudioTrackProcessing();
175 MockMediaConstraintFactory constraint_factory; 176 MockMediaConstraintFactory constraint_factory;
176 const std::string dummy_constraint = "dummy"; 177 const std::string dummy_constraint = "dummy";
177 constraint_factory.AddMandatory(dummy_constraint, true); 178 constraint_factory.AddMandatory(dummy_constraint, true);
178 179
179 scoped_refptr<WebRtcAudioCapturer> capturer( 180 scoped_refptr<WebRtcAudioCapturer> capturer(
180 WebRtcAudioCapturer::CreateCapturer( 181 WebRtcAudioCapturer::CreateCapturer(
181 0, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, 182 0, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE,
182 "", "", params_.sample_rate(), 183 "", "", params_.sample_rate(),
183 params_.channel_layout(), 184 params_.channel_layout(),
184 params_.frames_per_buffer()), 185 params_.frames_per_buffer()),
185 constraint_factory.CreateWebMediaConstraints(), NULL, NULL) 186 constraint_factory.CreateWebMediaConstraints(), NULL, NULL)
186 ); 187 );
187 EXPECT_TRUE(capturer == NULL); 188 EXPECT_TRUE(capturer == NULL);
188 } 189 }
189 190
190 191
191 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698