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/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/renderer/media/media_stream_audio_processor_options.h" | 10 #include "content/renderer/media/media_stream_audio_processor_options.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 base::subtle::Release_Store(&render_delay_ms_, audio_delay_milliseconds); | 204 base::subtle::Release_Store(&render_delay_ms_, audio_delay_milliseconds); |
205 | 205 |
206 InitializeRenderConverterIfNeeded(sample_rate, audio_bus->channels(), | 206 InitializeRenderConverterIfNeeded(sample_rate, audio_bus->channels(), |
207 audio_bus->frames()); | 207 audio_bus->frames()); |
208 | 208 |
209 render_converter_->Push(audio_bus); | 209 render_converter_->Push(audio_bus); |
210 while (render_converter_->Convert(&render_frame_)) | 210 while (render_converter_->Convert(&render_frame_)) |
211 audio_processing_->AnalyzeReverseStream(&render_frame_); | 211 audio_processing_->AnalyzeReverseStream(&render_frame_); |
212 } | 212 } |
213 | 213 |
| 214 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { |
| 215 stats->typing_noise_detected = |
| 216 (base::subtle::Acquire_Load(&typing_detected_) != false); |
| 217 GetAecStats(audio_processing_.get(), stats); |
| 218 } |
| 219 |
214 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( | 220 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
215 const blink::WebMediaConstraints& constraints, int effects) { | 221 const blink::WebMediaConstraints& constraints, int effects) { |
216 DCHECK(!audio_processing_); | 222 DCHECK(!audio_processing_); |
217 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 223 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
218 switches::kEnableAudioTrackProcessing)) { | 224 switches::kEnableAudioTrackProcessing)) { |
219 return; | 225 return; |
220 } | 226 } |
221 | 227 |
222 RTCMediaConstraints native_constraints(constraints); | 228 RTCMediaConstraints native_constraints(constraints); |
223 ApplyFixedAudioConstraints(&native_constraints); | 229 ApplyFixedAudioConstraints(&native_constraints); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // TODO(xians): Add support for typing detection, audio level calculation. | 405 // TODO(xians): Add support for typing detection, audio level calculation. |
400 | 406 |
401 if (audio_mirroring_ && audio_frame->num_channels_ == 2) { | 407 if (audio_mirroring_ && audio_frame->num_channels_ == 2) { |
402 // TODO(xians): Swap the stereo channels after switching to media::AudioBus. | 408 // TODO(xians): Swap the stereo channels after switching to media::AudioBus. |
403 } | 409 } |
404 | 410 |
405 if (typing_detector_ && | 411 if (typing_detector_ && |
406 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { | 412 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { |
407 bool vad_active = | 413 bool vad_active = |
408 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); | 414 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); |
409 // TODO(xians): Pass this |typing_detected_| to peer connection. | 415 bool typing_detected = typing_detector_->Process(key_pressed, vad_active); |
410 typing_detected_ = typing_detector_->Process(key_pressed, vad_active); | 416 base::subtle::Release_Store(&typing_detected_, typing_detected); |
411 } | 417 } |
412 | 418 |
413 // Return 0 if the volume has not been changed, otherwise return the new | 419 // Return 0 if the volume has not been changed, otherwise return the new |
414 // volume. | 420 // volume. |
415 return (agc->stream_analog_level() == volume) ? | 421 return (agc->stream_analog_level() == volume) ? |
416 0 : agc->stream_analog_level(); | 422 0 : agc->stream_analog_level(); |
417 } | 423 } |
418 | 424 |
419 void MediaStreamAudioProcessor::StopAudioProcessing() { | 425 void MediaStreamAudioProcessor::StopAudioProcessing() { |
420 if (!audio_processing_.get()) | 426 if (!audio_processing_.get()) |
421 return; | 427 return; |
422 | 428 |
423 if (playout_data_source_) | 429 if (playout_data_source_) |
424 playout_data_source_->RemovePlayoutSink(this); | 430 playout_data_source_->RemovePlayoutSink(this); |
425 | 431 |
426 audio_processing_.reset(); | 432 audio_processing_.reset(); |
427 } | 433 } |
428 | 434 |
429 } // namespace content | 435 } // namespace content |
OLD | NEW |