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

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

Issue 185413009: Implements the GetSignalLevel and GetStats interface for the local audio track. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased https://codereview.chromium.org/178223013 and used scope_refpt Created 6 years, 9 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/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
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // TODO(xians): Add support for typing detection, audio level calculation. 415 // TODO(xians): Add support for typing detection, audio level calculation.
410 416
411 if (audio_mirroring_ && audio_frame->num_channels_ == 2) { 417 if (audio_mirroring_ && audio_frame->num_channels_ == 2) {
412 // TODO(xians): Swap the stereo channels after switching to media::AudioBus. 418 // TODO(xians): Swap the stereo channels after switching to media::AudioBus.
413 } 419 }
414 420
415 if (typing_detector_ && 421 if (typing_detector_ &&
416 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { 422 audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) {
417 bool vad_active = 423 bool vad_active =
418 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); 424 (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive);
419 // TODO(xians): Pass this |typing_detected_| to peer connection. 425 bool typing_detected = typing_detector_->Process(key_pressed, vad_active);
420 typing_detected_ = typing_detector_->Process(key_pressed, vad_active); 426 base::subtle::Release_Store(&typing_detected_, typing_detected);
421 } 427 }
422 428
423 // Return 0 if the volume has not been changed, otherwise return the new 429 // Return 0 if the volume has not been changed, otherwise return the new
424 // volume. 430 // volume.
425 return (agc->stream_analog_level() == volume) ? 431 return (agc->stream_analog_level() == volume) ?
426 0 : agc->stream_analog_level(); 432 0 : agc->stream_analog_level();
427 } 433 }
428 434
429 void MediaStreamAudioProcessor::StopAudioProcessing() { 435 void MediaStreamAudioProcessor::StopAudioProcessing() {
430 if (!audio_processing_.get()) 436 if (!audio_processing_.get())
431 return; 437 return;
432 438
433 if (playout_data_source_) 439 if (playout_data_source_)
434 playout_data_source_->RemovePlayoutSink(this); 440 playout_data_source_->RemovePlayoutSink(this);
435 441
436 audio_processing_.reset(); 442 audio_processing_.reset();
437 } 443 }
438 444
439 } // namespace content 445 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698