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

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

Issue 480233007: Remove implicit conversions from scoped_refptr to T* in content/renderer/media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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/memory/aligned_memory.h" 9 #include "base/memory/aligned_memory.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 MockMediaConstraintFactory constraint_factory; 161 MockMediaConstraintFactory constraint_factory;
162 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 162 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
163 new WebRtcAudioDeviceImpl()); 163 new WebRtcAudioDeviceImpl());
164 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 164 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
165 new rtc::RefCountedObject<MediaStreamAudioProcessor>( 165 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
166 constraint_factory.CreateWebMediaConstraints(), 0, 166 constraint_factory.CreateWebMediaConstraints(), 0,
167 webrtc_audio_device.get())); 167 webrtc_audio_device.get()));
168 EXPECT_FALSE(audio_processor->has_audio_processing()); 168 EXPECT_FALSE(audio_processor->has_audio_processing());
169 audio_processor->OnCaptureFormatChanged(params_); 169 audio_processor->OnCaptureFormatChanged(params_);
170 170
171 ProcessDataAndVerifyFormat(audio_processor, 171 ProcessDataAndVerifyFormat(audio_processor.get(),
172 params_.sample_rate(), 172 params_.sample_rate(),
173 params_.channels(), 173 params_.channels(),
174 params_.sample_rate() / 100); 174 params_.sample_rate() / 100);
175 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 175 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
176 // |audio_processor|. 176 // |audio_processor|.
177 audio_processor = NULL; 177 audio_processor = NULL;
178 } 178 }
179 179
180 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { 180 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) {
181 MockMediaConstraintFactory constraint_factory; 181 MockMediaConstraintFactory constraint_factory;
182 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 182 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
183 new WebRtcAudioDeviceImpl()); 183 new WebRtcAudioDeviceImpl());
184 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 184 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
185 new rtc::RefCountedObject<MediaStreamAudioProcessor>( 185 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
186 constraint_factory.CreateWebMediaConstraints(), 0, 186 constraint_factory.CreateWebMediaConstraints(), 0,
187 webrtc_audio_device.get())); 187 webrtc_audio_device.get()));
188 EXPECT_TRUE(audio_processor->has_audio_processing()); 188 EXPECT_TRUE(audio_processor->has_audio_processing());
189 audio_processor->OnCaptureFormatChanged(params_); 189 audio_processor->OnCaptureFormatChanged(params_);
190 VerifyDefaultComponents(audio_processor); 190 VerifyDefaultComponents(audio_processor.get());
191 191
192 ProcessDataAndVerifyFormat(audio_processor, 192 ProcessDataAndVerifyFormat(audio_processor.get(),
193 kAudioProcessingSampleRate, 193 kAudioProcessingSampleRate,
194 kAudioProcessingNumberOfChannel, 194 kAudioProcessingNumberOfChannel,
195 kAudioProcessingSampleRate / 100); 195 kAudioProcessingSampleRate / 100);
196 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 196 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
197 // |audio_processor|. 197 // |audio_processor|.
198 audio_processor = NULL; 198 audio_processor = NULL;
199 } 199 }
200 200
201 TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { 201 TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) {
202 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 202 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
203 new WebRtcAudioDeviceImpl()); 203 new WebRtcAudioDeviceImpl());
204 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceTab source. 204 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceTab source.
205 MockMediaConstraintFactory tab_constraint_factory; 205 MockMediaConstraintFactory tab_constraint_factory;
206 const std::string tab_string = kMediaStreamSourceTab; 206 const std::string tab_string = kMediaStreamSourceTab;
207 tab_constraint_factory.AddMandatory(kMediaStreamSource, 207 tab_constraint_factory.AddMandatory(kMediaStreamSource,
208 tab_string); 208 tab_string);
209 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 209 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
210 new rtc::RefCountedObject<MediaStreamAudioProcessor>( 210 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
211 tab_constraint_factory.CreateWebMediaConstraints(), 0, 211 tab_constraint_factory.CreateWebMediaConstraints(), 0,
212 webrtc_audio_device.get())); 212 webrtc_audio_device.get()));
213 EXPECT_FALSE(audio_processor->has_audio_processing()); 213 EXPECT_FALSE(audio_processor->has_audio_processing());
214 audio_processor->OnCaptureFormatChanged(params_); 214 audio_processor->OnCaptureFormatChanged(params_);
215 215
216 ProcessDataAndVerifyFormat(audio_processor, 216 ProcessDataAndVerifyFormat(audio_processor.get(),
217 params_.sample_rate(), 217 params_.sample_rate(),
218 params_.channels(), 218 params_.channels(),
219 params_.sample_rate() / 100); 219 params_.sample_rate() / 100);
220 220
221 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceSystem 221 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceSystem
222 // source. 222 // source.
223 MockMediaConstraintFactory system_constraint_factory; 223 MockMediaConstraintFactory system_constraint_factory;
224 const std::string system_string = kMediaStreamSourceSystem; 224 const std::string system_string = kMediaStreamSourceSystem;
225 system_constraint_factory.AddMandatory(kMediaStreamSource, 225 system_constraint_factory.AddMandatory(kMediaStreamSource,
226 system_string); 226 system_string);
(...skipping 13 matching lines...) Expand all
240 constraint_factory.DisableDefaultAudioConstraints(); 240 constraint_factory.DisableDefaultAudioConstraints();
241 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 241 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
242 new WebRtcAudioDeviceImpl()); 242 new WebRtcAudioDeviceImpl());
243 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 243 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
244 new rtc::RefCountedObject<MediaStreamAudioProcessor>( 244 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
245 constraint_factory.CreateWebMediaConstraints(), 0, 245 constraint_factory.CreateWebMediaConstraints(), 0,
246 webrtc_audio_device.get())); 246 webrtc_audio_device.get()));
247 EXPECT_FALSE(audio_processor->has_audio_processing()); 247 EXPECT_FALSE(audio_processor->has_audio_processing());
248 audio_processor->OnCaptureFormatChanged(params_); 248 audio_processor->OnCaptureFormatChanged(params_);
249 249
250 ProcessDataAndVerifyFormat(audio_processor, 250 ProcessDataAndVerifyFormat(audio_processor.get(),
251 params_.sample_rate(), 251 params_.sample_rate(),
252 params_.channels(), 252 params_.channels(),
253 params_.sample_rate() / 100); 253 params_.sample_rate() / 100);
254 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 254 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
255 // |audio_processor|. 255 // |audio_processor|.
256 audio_processor = NULL; 256 audio_processor = NULL;
257 } 257 }
258 258
259 TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) { 259 TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) {
260 static const char* kDefaultAudioConstraints[] = { 260 static const char* kDefaultAudioConstraints[] = {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 static const int kSupportedSampleRates[] = 365 static const int kSupportedSampleRates[] =
366 { 8000, 16000, 22050, 32000, 44100, 48000, 88200, 96000 }; 366 { 8000, 16000, 22050, 32000, 44100, 48000, 88200, 96000 };
367 for (size_t i = 0; i < arraysize(kSupportedSampleRates); ++i) { 367 for (size_t i = 0; i < arraysize(kSupportedSampleRates); ++i) {
368 int buffer_size = (kSupportedSampleRates[i] / 100) < 128 ? 368 int buffer_size = (kSupportedSampleRates[i] / 100) < 128 ?
369 kSupportedSampleRates[i] / 100 : 128; 369 kSupportedSampleRates[i] / 100 : 128;
370 media::AudioParameters params( 370 media::AudioParameters params(
371 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 371 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
372 media::CHANNEL_LAYOUT_STEREO, kSupportedSampleRates[i], 16, 372 media::CHANNEL_LAYOUT_STEREO, kSupportedSampleRates[i], 16,
373 buffer_size); 373 buffer_size);
374 audio_processor->OnCaptureFormatChanged(params); 374 audio_processor->OnCaptureFormatChanged(params);
375 VerifyDefaultComponents(audio_processor); 375 VerifyDefaultComponents(audio_processor.get());
376 376
377 ProcessDataAndVerifyFormat(audio_processor, 377 ProcessDataAndVerifyFormat(audio_processor.get(),
378 kAudioProcessingSampleRate, 378 kAudioProcessingSampleRate,
379 kAudioProcessingNumberOfChannel, 379 kAudioProcessingNumberOfChannel,
380 kAudioProcessingSampleRate / 100); 380 kAudioProcessingSampleRate / 100);
381 } 381 }
382 382
383 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| 383 // Set |audio_processor| to NULL to make sure |webrtc_audio_device|
384 // outlives |audio_processor|. 384 // outlives |audio_processor|.
385 audio_processor = NULL; 385 audio_processor = NULL;
386 } 386 }
387 387
388 // Test that if we have an AEC dump message filter created, we are getting it 388 // Test that if we have an AEC dump message filter created, we are getting it
389 // correctly in MSAP. Any IPC messages will be deleted since no sender in the 389 // correctly in MSAP. Any IPC messages will be deleted since no sender in the
390 // filter will be created. 390 // filter will be created.
391 TEST_F(MediaStreamAudioProcessorTest, GetAecDumpMessageFilter) { 391 TEST_F(MediaStreamAudioProcessorTest, GetAecDumpMessageFilter) {
392 base::MessageLoopForUI message_loop; 392 base::MessageLoopForUI message_loop;
393 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_( 393 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_(
394 new AecDumpMessageFilter(message_loop.message_loop_proxy(), 394 new AecDumpMessageFilter(message_loop.message_loop_proxy(),
395 message_loop.message_loop_proxy())); 395 message_loop.message_loop_proxy()));
396 396
397 MockMediaConstraintFactory constraint_factory; 397 MockMediaConstraintFactory constraint_factory;
398 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 398 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
399 new WebRtcAudioDeviceImpl()); 399 new WebRtcAudioDeviceImpl());
400 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 400 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
401 new rtc::RefCountedObject<MediaStreamAudioProcessor>( 401 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
402 constraint_factory.CreateWebMediaConstraints(), 0, 402 constraint_factory.CreateWebMediaConstraints(), 0,
403 webrtc_audio_device.get())); 403 webrtc_audio_device.get()));
404 404
405 EXPECT_TRUE(audio_processor->aec_dump_message_filter_); 405 EXPECT_TRUE(audio_processor->aec_dump_message_filter_.get());
406 406
407 audio_processor = NULL; 407 audio_processor = NULL;
408 } 408 }
409 409
410 TEST_F(MediaStreamAudioProcessorTest, TestStereoAudio) { 410 TEST_F(MediaStreamAudioProcessorTest, TestStereoAudio) {
411 // Set up the correct constraints to turn off the audio processing and turn 411 // Set up the correct constraints to turn off the audio processing and turn
412 // on the stereo channels mirroring. 412 // on the stereo channels mirroring.
413 MockMediaConstraintFactory constraint_factory; 413 MockMediaConstraintFactory constraint_factory;
414 constraint_factory.AddMandatory(MediaAudioConstraints::kEchoCancellation, 414 constraint_factory.AddMandatory(MediaAudioConstraints::kEchoCancellation,
415 false); 415 false);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_EQ(output_bus->channel(0)[0], 0); 463 EXPECT_EQ(output_bus->channel(0)[0], 0);
464 EXPECT_NE(output_bus->channel(1)[0], 0); 464 EXPECT_NE(output_bus->channel(1)[0], 0);
465 } 465 }
466 466
467 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 467 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
468 // |audio_processor|. 468 // |audio_processor|.
469 audio_processor = NULL; 469 audio_processor = NULL;
470 } 470 }
471 471
472 } // namespace content 472 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.cc ('k') | content/renderer/media/media_stream_audio_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698