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

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

Issue 1246283003: Split out audio debug recording from RenderProcessHostImpl. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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 "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/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 WebRtcPlayoutDataSource* playout_data_source) 239 WebRtcPlayoutDataSource* playout_data_source)
240 : render_delay_ms_(0), 240 : render_delay_ms_(0),
241 playout_data_source_(playout_data_source), 241 playout_data_source_(playout_data_source),
242 audio_mirroring_(false), 242 audio_mirroring_(false),
243 typing_detected_(false), 243 typing_detected_(false),
244 stopped_(false) { 244 stopped_(false) {
245 capture_thread_checker_.DetachFromThread(); 245 capture_thread_checker_.DetachFromThread();
246 render_thread_checker_.DetachFromThread(); 246 render_thread_checker_.DetachFromThread();
247 InitializeAudioProcessingModule(constraints, input_params); 247 InitializeAudioProcessingModule(constraints, input_params);
248 248
249 aec_dump_message_filter_ = AecDumpMessageFilter::Get(); 249 audio_debug_recorder_ = AudioDebugRecorder::Get();
250 // In unit tests not creating a message filter, |aec_dump_message_filter_| 250 // In unit tests not creating a message filter, |audio_debug_recorder_|
251 // will be NULL. We can just ignore that. Other unit tests and browser tests 251 // will be NULL. We can just ignore that. Other unit tests and browser tests
252 // ensure that we do get the filter when we should. 252 // ensure that we do get the filter when we should.
253 if (aec_dump_message_filter_.get()) 253 if (audio_debug_recorder_.get())
254 aec_dump_message_filter_->AddDelegate(this); 254 audio_debug_recorder_->AddDelegate(this);
255 } 255 }
256 256
257 MediaStreamAudioProcessor::~MediaStreamAudioProcessor() { 257 MediaStreamAudioProcessor::~MediaStreamAudioProcessor() {
258 DCHECK(main_thread_checker_.CalledOnValidThread()); 258 DCHECK(main_thread_checker_.CalledOnValidThread());
259 Stop(); 259 Stop();
260 } 260 }
261 261
262 void MediaStreamAudioProcessor::OnCaptureFormatChanged( 262 void MediaStreamAudioProcessor::OnCaptureFormatChanged(
263 const media::AudioParameters& input_format) { 263 const media::AudioParameters& input_format) {
264 DCHECK(main_thread_checker_.CalledOnValidThread()); 264 DCHECK(main_thread_checker_.CalledOnValidThread());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return true; 319 return true;
320 } 320 }
321 321
322 void MediaStreamAudioProcessor::Stop() { 322 void MediaStreamAudioProcessor::Stop() {
323 DCHECK(main_thread_checker_.CalledOnValidThread()); 323 DCHECK(main_thread_checker_.CalledOnValidThread());
324 if (stopped_) 324 if (stopped_)
325 return; 325 return;
326 326
327 stopped_ = true; 327 stopped_ = true;
328 328
329 if (aec_dump_message_filter_.get()) { 329 if (audio_debug_recorder_.get()) {
330 aec_dump_message_filter_->RemoveDelegate(this); 330 audio_debug_recorder_->RemoveDelegate(this);
331 aec_dump_message_filter_ = NULL; 331 audio_debug_recorder_ = NULL;
332 } 332 }
333 333
334 if (!audio_processing_.get()) 334 if (!audio_processing_.get())
335 return; 335 return;
336 336
337 audio_processing_.get()->UpdateHistogramsOnCallEnd(); 337 audio_processing_.get()->UpdateHistogramsOnCallEnd();
338 StopEchoCancellationDump(audio_processing_.get()); 338 StopEchoCancellationDump(audio_processing_.get());
339 339
340 if (playout_data_source_) { 340 if (playout_data_source_) {
341 playout_data_source_->RemovePlayoutSink(this); 341 playout_data_source_->RemovePlayoutSink(this);
342 playout_data_source_ = NULL; 342 playout_data_source_ = NULL;
343 } 343 }
344 } 344 }
345 345
346 const media::AudioParameters& MediaStreamAudioProcessor::InputFormat() const { 346 const media::AudioParameters& MediaStreamAudioProcessor::InputFormat() const {
347 return input_format_; 347 return input_format_;
348 } 348 }
349 349
350 const media::AudioParameters& MediaStreamAudioProcessor::OutputFormat() const { 350 const media::AudioParameters& MediaStreamAudioProcessor::OutputFormat() const {
351 return output_format_; 351 return output_format_;
352 } 352 }
353 353
354 void MediaStreamAudioProcessor::OnAecDumpFile( 354 void MediaStreamAudioProcessor::OnAecDumpFile(base::PlatformFile file_handle) {
355 const IPC::PlatformFileForTransit& file_handle) {
356 DCHECK(main_thread_checker_.CalledOnValidThread()); 355 DCHECK(main_thread_checker_.CalledOnValidThread());
357 356
358 base::File file = IPC::PlatformFileForTransitToFile(file_handle); 357 base::File file(file_handle);
359 DCHECK(file.IsValid()); 358 DCHECK(file.IsValid());
360 359
361 if (audio_processing_) 360 if (audio_processing_)
362 StartEchoCancellationDump(audio_processing_.get(), file.Pass()); 361 StartEchoCancellationDump(audio_processing_.get(), file.Pass());
363 else 362 else
364 file.Close(); 363 file.Close();
365 } 364 }
366 365
367 void MediaStreamAudioProcessor::OnDisableAecDump() { 366 void MediaStreamAudioProcessor::OnDisableAecDump() {
368 DCHECK(main_thread_checker_.CalledOnValidThread()); 367 DCHECK(main_thread_checker_.CalledOnValidThread());
369 if (audio_processing_) 368 if (audio_processing_)
370 StopEchoCancellationDump(audio_processing_.get()); 369 StopEchoCancellationDump(audio_processing_.get());
371 } 370 }
372 371
373 void MediaStreamAudioProcessor::OnIpcClosing() { 372 void MediaStreamAudioProcessor::OnIpcClosing() {
374 DCHECK(main_thread_checker_.CalledOnValidThread()); 373 DCHECK(main_thread_checker_.CalledOnValidThread());
375 aec_dump_message_filter_ = NULL; 374 audio_debug_recorder_ = NULL;
376 } 375 }
377 376
378 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus, 377 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
379 int sample_rate, 378 int sample_rate,
380 int audio_delay_milliseconds) { 379 int audio_delay_milliseconds) {
381 DCHECK(render_thread_checker_.CalledOnValidThread()); 380 DCHECK(render_thread_checker_.CalledOnValidThread());
382 DCHECK(audio_processing_->echo_control_mobile()->is_enabled() ^ 381 DCHECK(audio_processing_->echo_control_mobile()->is_enabled() ^
383 audio_processing_->echo_cancellation()->is_enabled()); 382 audio_processing_->echo_cancellation()->is_enabled());
384 383
385 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::OnPlayoutData"); 384 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::OnPlayoutData");
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (echo_information_) { 678 if (echo_information_) {
680 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation()); 679 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation());
681 } 680 }
682 681
683 // Return 0 if the volume hasn't been changed, and otherwise the new volume. 682 // Return 0 if the volume hasn't been changed, and otherwise the new volume.
684 return (agc->stream_analog_level() == volume) ? 683 return (agc->stream_analog_level() == volume) ?
685 0 : agc->stream_analog_level(); 684 0 : agc->stream_analog_level();
686 } 685 }
687 686
688 } // namespace content 687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698