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

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

Issue 259663005: Use AudioProcessing::Initialize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/renderer/media/media_stream_audio_processor.h" 5 #include "content/renderer/media/media_stream_audio_processor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 15 matching lines...) Expand all
26 26
27 using webrtc::AudioProcessing; 27 using webrtc::AudioProcessing;
28 using webrtc::MediaConstraintsInterface; 28 using webrtc::MediaConstraintsInterface;
29 29
30 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
31 const int kAudioProcessingSampleRate = 16000; 31 const int kAudioProcessingSampleRate = 16000;
32 #else 32 #else
33 const int kAudioProcessingSampleRate = 32000; 33 const int kAudioProcessingSampleRate = 32000;
34 #endif 34 #endif
35 const int kAudioProcessingNumberOfChannels = 1; 35 const int kAudioProcessingNumberOfChannels = 1;
36 const AudioProcessing::ChannelLayout kAudioProcessingChannelLayout =
37 AudioProcessing::kMono;
36 38
37 const int kMaxNumberOfBuffersInFifo = 2; 39 const int kMaxNumberOfBuffersInFifo = 2;
38 40
39 // Used by UMA histograms and entries shouldn't be re-ordered or removed. 41 // Used by UMA histograms and entries shouldn't be re-ordered or removed.
40 enum AudioTrackProcessingStates { 42 enum AudioTrackProcessingStates {
41 AUDIO_PROCESSING_ENABLED = 0, 43 AUDIO_PROCESSING_ENABLED = 0,
42 AUDIO_PROCESSING_DISABLED, 44 AUDIO_PROCESSING_DISABLED,
43 AUDIO_PROCESSING_IN_WEBRTC, 45 AUDIO_PROCESSING_IN_WEBRTC,
44 AUDIO_PROCESSING_MAX 46 AUDIO_PROCESSING_MAX
45 }; 47 };
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 346
345 // Return immediately if no audio processing component is enabled. 347 // Return immediately if no audio processing component is enabled.
346 if (!enable_aec && !enable_experimental_aec && !enable_ns && 348 if (!enable_aec && !enable_experimental_aec && !enable_ns &&
347 !enable_high_pass_filter && !enable_typing_detection && !enable_agc && 349 !enable_high_pass_filter && !enable_typing_detection && !enable_agc &&
348 !enable_experimental_ns) { 350 !enable_experimental_ns) {
349 RecordProcessingState(AUDIO_PROCESSING_DISABLED); 351 RecordProcessingState(AUDIO_PROCESSING_DISABLED);
350 return; 352 return;
351 } 353 }
352 354
353 // Create and configure the webrtc::AudioProcessing. 355 // Create and configure the webrtc::AudioProcessing.
354 audio_processing_.reset(webrtc::AudioProcessing::Create(0)); 356 audio_processing_.reset(webrtc::AudioProcessing::Create());
355 // TODO(ajm): Replace with AudioProcessing::Initialize() when this rolls to 357 CHECK_EQ(0, audio_processing_->Initialize(kAudioProcessingSampleRate,
356 // Chromium: http://review.webrtc.org/9919004/ 358 kAudioProcessingSampleRate,
357 CHECK_EQ(0, 359 kAudioProcessingSampleRate,
358 audio_processing_->set_sample_rate_hz(kAudioProcessingSampleRate)); 360 kAudioProcessingChannelLayout,
361 kAudioProcessingChannelLayout,
362 kAudioProcessingChannelLayout));
359 363
360 // Enable the audio processing components. 364 // Enable the audio processing components.
361 if (enable_aec) { 365 if (enable_aec) {
362 EnableEchoCancellation(audio_processing_.get()); 366 EnableEchoCancellation(audio_processing_.get());
363 if (enable_experimental_aec) 367 if (enable_experimental_aec)
364 EnableExperimentalEchoCancellation(audio_processing_.get()); 368 EnableExperimentalEchoCancellation(audio_processing_.get());
365 369
366 if (playout_data_source_) 370 if (playout_data_source_)
367 playout_data_source_->AddPlayoutSink(this); 371 playout_data_source_->AddPlayoutSink(this);
368 } 372 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 456
453 int MediaStreamAudioProcessor::ProcessData(webrtc::AudioFrame* audio_frame, 457 int MediaStreamAudioProcessor::ProcessData(webrtc::AudioFrame* audio_frame,
454 base::TimeDelta capture_delay, 458 base::TimeDelta capture_delay,
455 int volume, 459 int volume,
456 bool key_pressed) { 460 bool key_pressed) {
457 DCHECK(capture_thread_checker_.CalledOnValidThread()); 461 DCHECK(capture_thread_checker_.CalledOnValidThread());
458 if (!audio_processing_) 462 if (!audio_processing_)
459 return 0; 463 return 0;
460 464
461 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessData"); 465 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessData");
462 DCHECK_EQ(audio_processing_->sample_rate_hz(), 466 DCHECK_EQ(audio_processing_->input_sample_rate_hz(),
463 capture_converter_->sink_parameters().sample_rate()); 467 capture_converter_->sink_parameters().sample_rate());
464 DCHECK_EQ(audio_processing_->num_input_channels(), 468 DCHECK_EQ(audio_processing_->num_input_channels(),
465 capture_converter_->sink_parameters().channels()); 469 capture_converter_->sink_parameters().channels());
466 DCHECK_EQ(audio_processing_->num_output_channels(), 470 DCHECK_EQ(audio_processing_->num_output_channels(),
467 capture_converter_->sink_parameters().channels()); 471 capture_converter_->sink_parameters().channels());
468 472
469 base::subtle::Atomic32 render_delay_ms = 473 base::subtle::Atomic32 render_delay_ms =
470 base::subtle::Acquire_Load(&render_delay_ms_); 474 base::subtle::Acquire_Load(&render_delay_ms_);
471 int64 capture_delay_ms = capture_delay.InMilliseconds(); 475 int64 capture_delay_ms = capture_delay.InMilliseconds();
472 DCHECK_LT(capture_delay_ms, 476 DCHECK_LT(capture_delay_ms,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 513
510 StopAecDump(); 514 StopAecDump();
511 515
512 if (playout_data_source_) 516 if (playout_data_source_)
513 playout_data_source_->RemovePlayoutSink(this); 517 playout_data_source_->RemovePlayoutSink(this);
514 518
515 audio_processing_.reset(); 519 audio_processing_.reset();
516 } 520 }
517 521
518 } // namespace content 522 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698