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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 | 220 |
221 void MediaStreamAudioProcessor::OnPlayoutDataSourceChanged() { | 221 void MediaStreamAudioProcessor::OnPlayoutDataSourceChanged() { |
222 DCHECK(main_thread_checker_.CalledOnValidThread()); | 222 DCHECK(main_thread_checker_.CalledOnValidThread()); |
223 // There is no need to hold a lock here since the caller guarantees that | 223 // There is no need to hold a lock here since the caller guarantees that |
224 // there is no more OnPlayoutData() callback on the render thread. | 224 // there is no more OnPlayoutData() callback on the render thread. |
225 render_thread_checker_.DetachFromThread(); | 225 render_thread_checker_.DetachFromThread(); |
226 render_converter_.reset(); | 226 render_converter_.reset(); |
227 } | 227 } |
228 | 228 |
| 229 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { |
| 230 stats->typing_noise_detected = |
| 231 (base::subtle::Acquire_Load(&typing_detected_) != false); |
| 232 GetAecStats(audio_processing_.get(), stats); |
| 233 } |
| 234 |
229 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( | 235 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
230 const blink::WebMediaConstraints& constraints, int effects) { | 236 const blink::WebMediaConstraints& constraints, int effects) { |
231 DCHECK(!audio_processing_); | 237 DCHECK(!audio_processing_); |
232 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 238 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
233 switches::kEnableAudioTrackProcessing)) { | 239 switches::kEnableAudioTrackProcessing)) { |
234 return; | 240 return; |
235 } | 241 } |
236 | 242 |
237 RTCMediaConstraints native_constraints(constraints); | 243 RTCMediaConstraints native_constraints(constraints); |
238 ApplyFixedAudioConstraints(&native_constraints); | 244 ApplyFixedAudioConstraints(&native_constraints); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 424 |
419 audio_processing_->set_stream_key_pressed(key_pressed); | 425 audio_processing_->set_stream_key_pressed(key_pressed); |
420 | 426 |
421 err = audio_processing_->ProcessStream(audio_frame); | 427 err = audio_processing_->ProcessStream(audio_frame); |
422 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; | 428 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; |
423 | 429 |
424 if (typing_detector_ && | 430 if (typing_detector_ && |
425 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { | 431 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { |
426 bool vad_active = | 432 bool vad_active = |
427 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); | 433 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); |
428 // TODO(xians): Pass this |typing_detected_| to peer connection. | 434 bool typing_detected = typing_detector_->Process(key_pressed, vad_active); |
429 typing_detected_ = typing_detector_->Process(key_pressed, vad_active); | 435 base::subtle::Release_Store(&typing_detected_, typing_detected); |
430 } | 436 } |
431 | 437 |
432 // Return 0 if the volume has not been changed, otherwise return the new | 438 // Return 0 if the volume has not been changed, otherwise return the new |
433 // volume. | 439 // volume. |
434 return (agc->stream_analog_level() == volume) ? | 440 return (agc->stream_analog_level() == volume) ? |
435 0 : agc->stream_analog_level(); | 441 0 : agc->stream_analog_level(); |
436 } | 442 } |
437 | 443 |
438 void MediaStreamAudioProcessor::StopAudioProcessing() { | 444 void MediaStreamAudioProcessor::StopAudioProcessing() { |
439 if (!audio_processing_.get()) | 445 if (!audio_processing_.get()) |
440 return; | 446 return; |
441 | 447 |
442 if (playout_data_source_) | 448 if (playout_data_source_) |
443 playout_data_source_->RemovePlayoutSink(this); | 449 playout_data_source_->RemovePlayoutSink(this); |
444 | 450 |
445 audio_processing_.reset(); | 451 audio_processing_.reset(); |
446 } | 452 } |
447 | 453 |
448 } // namespace content | 454 } // namespace content |
OLD | NEW |