| OLD | NEW |
| 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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 8 #if defined(OS_MACOSX) | |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #endif | |
| 11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/renderer/media/media_stream_audio_processor_options.h" | 12 #include "content/renderer/media/media_stream_audio_processor_options.h" |
| 13 #include "content/renderer/media/rtc_media_constraints.h" | 13 #include "content/renderer/media/rtc_media_constraints.h" |
| 14 #include "content/renderer/media/webrtc_audio_device_impl.h" | 14 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 15 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
| 16 #include "media/base/audio_converter.h" | 16 #include "media/base/audio_converter.h" |
| 17 #include "media/base/audio_fifo.h" | 17 #include "media/base/audio_fifo.h" |
| 18 #include "media/base/channel_layout.h" | 18 #include "media/base/channel_layout.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 20 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 20 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
| 21 #include "third_party/webrtc/modules/audio_processing/typing_detection.h" | 21 #include "third_party/webrtc/modules/audio_processing/typing_detection.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 AUDIO_PROCESSING_DISABLED, | 70 AUDIO_PROCESSING_DISABLED, |
| 71 AUDIO_PROCESSING_IN_WEBRTC, | 71 AUDIO_PROCESSING_IN_WEBRTC, |
| 72 AUDIO_PROCESSING_MAX | 72 AUDIO_PROCESSING_MAX |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 void RecordProcessingState(AudioTrackProcessingStates state) { | 75 void RecordProcessingState(AudioTrackProcessingStates state) { |
| 76 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates", | 76 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates", |
| 77 state, AUDIO_PROCESSING_MAX); | 77 state, AUDIO_PROCESSING_MAX); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool isDelayAgnosticAecEnabled() { |
| 81 // Note: It's important to query the field trial state first, to ensure that |
| 82 // UMA reports the correct group. |
| 83 const std::string group_name = |
| 84 base::FieldTrialList::FindFullName("NoReportedDelayOnMac"); |
| 85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 86 if (command_line->HasSwitch(switches::kEnableDelayAgnosticAec)) |
| 87 return true; |
| 88 |
| 89 return (!group_name.empty() && group_name == "Enabled"); |
| 90 } |
| 80 } // namespace | 91 } // namespace |
| 81 | 92 |
| 82 // Wraps AudioBus to provide access to the array of channel pointers, since this | 93 // Wraps AudioBus to provide access to the array of channel pointers, since this |
| 83 // is the type webrtc::AudioProcessing deals in. The array is refreshed on every | 94 // is the type webrtc::AudioProcessing deals in. The array is refreshed on every |
| 84 // channel_ptrs() call, and will be valid until the underlying AudioBus pointers | 95 // channel_ptrs() call, and will be valid until the underlying AudioBus pointers |
| 85 // are changed, e.g. through calls to SetChannelData() or SwapChannels(). | 96 // are changed, e.g. through calls to SetChannelData() or SwapChannels(). |
| 86 // | 97 // |
| 87 // All methods are called on one of the capture or render audio threads | 98 // All methods are called on one of the capture or render audio threads |
| 88 // exclusively. | 99 // exclusively. |
| 89 class MediaStreamAudioBus { | 100 class MediaStreamAudioBus { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 RecordProcessingState(AUDIO_PROCESSING_DISABLED); | 472 RecordProcessingState(AUDIO_PROCESSING_DISABLED); |
| 462 return; | 473 return; |
| 463 } | 474 } |
| 464 | 475 |
| 465 // Experimental options provided at creation. | 476 // Experimental options provided at creation. |
| 466 webrtc::Config config; | 477 webrtc::Config config; |
| 467 if (goog_experimental_aec) | 478 if (goog_experimental_aec) |
| 468 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | 479 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); |
| 469 if (goog_experimental_ns) | 480 if (goog_experimental_ns) |
| 470 config.Set<webrtc::ExperimentalNs>(new webrtc::ExperimentalNs(true)); | 481 config.Set<webrtc::ExperimentalNs>(new webrtc::ExperimentalNs(true)); |
| 471 #if defined(OS_MACOSX) | 482 if (isDelayAgnosticAecEnabled()) |
| 472 if (base::FieldTrialList::FindFullName("NoReportedDelayOnMac") == "Enabled") | |
| 473 config.Set<webrtc::ReportedDelay>(new webrtc::ReportedDelay(false)); | 483 config.Set<webrtc::ReportedDelay>(new webrtc::ReportedDelay(false)); |
| 474 #endif | |
| 475 if (goog_beamforming) { | 484 if (goog_beamforming) { |
| 476 ConfigureBeamforming(&config); | 485 ConfigureBeamforming(&config); |
| 477 } | 486 } |
| 478 | 487 |
| 479 // Create and configure the webrtc::AudioProcessing. | 488 // Create and configure the webrtc::AudioProcessing. |
| 480 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); | 489 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); |
| 481 | 490 |
| 482 // Enable the audio processing components. | 491 // Enable the audio processing components. |
| 483 if (echo_cancellation) { | 492 if (echo_cancellation) { |
| 484 EnableEchoCancellation(audio_processing_.get()); | 493 EnableEchoCancellation(audio_processing_.get()); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 vad->stream_has_voice()); | 679 vad->stream_has_voice()); |
| 671 base::subtle::Release_Store(&typing_detected_, detected); | 680 base::subtle::Release_Store(&typing_detected_, detected); |
| 672 } | 681 } |
| 673 | 682 |
| 674 // Return 0 if the volume hasn't been changed, and otherwise the new volume. | 683 // Return 0 if the volume hasn't been changed, and otherwise the new volume. |
| 675 return (agc->stream_analog_level() == volume) ? | 684 return (agc->stream_analog_level() == volume) ? |
| 676 0 : agc->stream_analog_level(); | 685 0 : agc->stream_analog_level(); |
| 677 } | 686 } |
| 678 | 687 |
| 679 } // namespace content | 688 } // namespace content |
| OLD | NEW |