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

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

Issue 1357013006: Add detection for repeated audio in capturing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: on tommi's comments 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // True when |destination_| contains the data to be returned by the next call 232 // True when |destination_| contains the data to be returned by the next call
233 // to Consume(). Only used when the FIFO is disabled. 233 // to Consume(). Only used when the FIFO is disabled.
234 bool data_available_; 234 bool data_available_;
235 }; 235 };
236 236
237 MediaStreamAudioProcessor::MediaStreamAudioProcessor( 237 MediaStreamAudioProcessor::MediaStreamAudioProcessor(
238 const blink::WebMediaConstraints& constraints, 238 const blink::WebMediaConstraints& constraints,
239 const MediaStreamDevice::AudioDeviceParameters& input_params, 239 const MediaStreamDevice::AudioDeviceParameters& input_params,
240 WebRtcPlayoutDataSource* playout_data_source) 240 WebRtcPlayoutDataSource* playout_data_source)
241 : render_delay_ms_(0), 241 : render_delay_ms_(0),
242 audio_repetition_detector_(new AudioRepetitionDetector()),
tommi (sloooow) - chröme 2015/09/28 16:13:03 do we always want to create a detector? (what abo
242 playout_data_source_(playout_data_source), 243 playout_data_source_(playout_data_source),
243 audio_mirroring_(false), 244 audio_mirroring_(false),
244 typing_detected_(false), 245 typing_detected_(false),
245 stopped_(false) { 246 stopped_(false) {
246 capture_thread_checker_.DetachFromThread(); 247 capture_thread_checker_.DetachFromThread();
247 render_thread_checker_.DetachFromThread(); 248 render_thread_checker_.DetachFromThread();
248 InitializeAudioProcessingModule(constraints, input_params); 249 InitializeAudioProcessingModule(constraints, input_params);
249 250
250 aec_dump_message_filter_ = AecDumpMessageFilter::Get(); 251 aec_dump_message_filter_ = AecDumpMessageFilter::Get();
251 // In unit tests not creating a message filter, |aec_dump_message_filter_| 252 // In unit tests not creating a message filter, |aec_dump_message_filter_|
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 DCHECK(processed_data); 292 DCHECK(processed_data);
292 DCHECK(capture_delay); 293 DCHECK(capture_delay);
293 DCHECK(new_volume); 294 DCHECK(new_volume);
294 295
295 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessAndConsumeData"); 296 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessAndConsumeData");
296 297
297 MediaStreamAudioBus* process_bus; 298 MediaStreamAudioBus* process_bus;
298 if (!capture_fifo_->Consume(&process_bus, capture_delay)) 299 if (!capture_fifo_->Consume(&process_bus, capture_delay))
299 return false; 300 return false;
300 301
302 // Detect bit-exact repetition of audio present in the captured audio.
303 // We detect only one channel.
304 if (audio_repetition_detector_) {
tommi (sloooow) - chröme 2015/09/28 16:13:03 if we always allocate a repetition detector, we sh
305 audio_repetition_detector_->Detect(process_bus->bus()->channel(0),
306 process_bus->bus()->frames(),
307 1, // number of channels
308 input_format_.sample_rate());
309 }
310
301 // Use the process bus directly if audio processing is disabled. 311 // Use the process bus directly if audio processing is disabled.
302 MediaStreamAudioBus* output_bus = process_bus; 312 MediaStreamAudioBus* output_bus = process_bus;
303 *new_volume = 0; 313 *new_volume = 0;
304 if (audio_processing_) { 314 if (audio_processing_) {
305 output_bus = output_bus_.get(); 315 output_bus = output_bus_.get();
306 *new_volume = ProcessData(process_bus->channel_ptrs(), 316 *new_volume = ProcessData(process_bus->channel_ptrs(),
307 process_bus->bus()->frames(), *capture_delay, 317 process_bus->bus()->frames(), *capture_delay,
308 volume, key_pressed, output_bus->channel_ptrs()); 318 volume, key_pressed, output_bus->channel_ptrs());
309 } 319 }
310 320
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 if (echo_information_) { 690 if (echo_information_) {
681 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation()); 691 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation());
682 } 692 }
683 693
684 // Return 0 if the volume hasn't been changed, and otherwise the new volume. 694 // Return 0 if the volume hasn't been changed, and otherwise the new volume.
685 return (agc->stream_analog_level() == volume) ? 695 return (agc->stream_analog_level() == volume) ?
686 0 : agc->stream_analog_level(); 696 0 : agc->stream_analog_level();
687 } 697 }
688 698
689 } // namespace content 699 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698