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/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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 // True when |destination_| contains the data to be returned by the next call | 238 // True when |destination_| contains the data to be returned by the next call |
239 // to Consume(). Only used when the FIFO is disabled. | 239 // to Consume(). Only used when the FIFO is disabled. |
240 bool data_available_; | 240 bool data_available_; |
241 }; | 241 }; |
242 | 242 |
243 MediaStreamAudioProcessor::MediaStreamAudioProcessor( | 243 MediaStreamAudioProcessor::MediaStreamAudioProcessor( |
244 const blink::WebMediaConstraints& constraints, | 244 const blink::WebMediaConstraints& constraints, |
245 const MediaStreamDevice::AudioDeviceParameters& input_params, | 245 const MediaStreamDevice::AudioDeviceParameters& input_params, |
246 WebRtcPlayoutDataSource* playout_data_source) | 246 WebRtcPlayoutDataSource* playout_data_source) |
247 : render_delay_ms_(0), | 247 : render_delay_ms_(0), |
248 repetition_detector_(new RepetitionDetector()), | |
248 playout_data_source_(playout_data_source), | 249 playout_data_source_(playout_data_source), |
249 audio_mirroring_(false), | 250 audio_mirroring_(false), |
250 typing_detected_(false), | 251 typing_detected_(false), |
251 stopped_(false) { | 252 stopped_(false) { |
252 capture_thread_checker_.DetachFromThread(); | 253 capture_thread_checker_.DetachFromThread(); |
253 render_thread_checker_.DetachFromThread(); | 254 render_thread_checker_.DetachFromThread(); |
254 InitializeAudioProcessingModule(constraints, input_params); | 255 InitializeAudioProcessingModule(constraints, input_params); |
255 | 256 |
256 aec_dump_message_filter_ = AecDumpMessageFilter::Get(); | 257 aec_dump_message_filter_ = AecDumpMessageFilter::Get(); |
257 // In unit tests not creating a message filter, |aec_dump_message_filter_| | 258 // In unit tests not creating a message filter, |aec_dump_message_filter_| |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 DCHECK(processed_data); | 298 DCHECK(processed_data); |
298 DCHECK(capture_delay); | 299 DCHECK(capture_delay); |
299 DCHECK(new_volume); | 300 DCHECK(new_volume); |
300 | 301 |
301 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessAndConsumeData"); | 302 TRACE_EVENT0("audio", "MediaStreamAudioProcessor::ProcessAndConsumeData"); |
302 | 303 |
303 MediaStreamAudioBus* process_bus; | 304 MediaStreamAudioBus* process_bus; |
304 if (!capture_fifo_->Consume(&process_bus, capture_delay)) | 305 if (!capture_fifo_->Consume(&process_bus, capture_delay)) |
305 return false; | 306 return false; |
306 | 307 |
308 // Detect if bit-exact repetition of audio present in the captured audio. | |
Henrik Grunell
2015/09/23 10:36:41
Nit: "Detect bit-exact repetition of audio."
minyue
2015/09/25 14:40:06
Done.
| |
309 // We detect only one channel. | |
310 if (repetition_detector_) { | |
311 repetition_detector_->Detect(process_bus->bus()->channel(0), | |
Henrik Grunell
2015/09/23 06:54:15
How much complexity does this add? Would be good t
minyue
2015/09/23 08:48:07
It is O(n), n for number of samples. Each sample c
| |
312 process_bus->bus()->frames(), | |
313 1, // number of channels | |
314 input_format_.sample_rate()); | |
Henrik Grunell
2015/09/23 06:54:15
Does the |process_bus| contain the sample rate?
minyue
2015/09/23 08:48:07
Unfortunately not. and that is why other places us
Henrik Grunell
2015/09/23 10:36:41
I looked into this more. The MediaStreamAudioBus w
minyue
2015/09/25 14:40:06
It is good for me to know that AudioBus has all in
| |
315 } | |
316 | |
307 // Use the process bus directly if audio processing is disabled. | 317 // Use the process bus directly if audio processing is disabled. |
308 MediaStreamAudioBus* output_bus = process_bus; | 318 MediaStreamAudioBus* output_bus = process_bus; |
309 *new_volume = 0; | 319 *new_volume = 0; |
310 if (audio_processing_) { | 320 if (audio_processing_) { |
311 output_bus = output_bus_.get(); | 321 output_bus = output_bus_.get(); |
312 *new_volume = ProcessData(process_bus->channel_ptrs(), | 322 *new_volume = ProcessData(process_bus->channel_ptrs(), |
313 process_bus->bus()->frames(), *capture_delay, | 323 process_bus->bus()->frames(), *capture_delay, |
314 volume, key_pressed, output_bus->channel_ptrs()); | 324 volume, key_pressed, output_bus->channel_ptrs()); |
315 } | 325 } |
316 | 326 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 if (echo_information_) { | 695 if (echo_information_) { |
686 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation()); | 696 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation()); |
687 } | 697 } |
688 | 698 |
689 // Return 0 if the volume hasn't been changed, and otherwise the new volume. | 699 // Return 0 if the volume hasn't been changed, and otherwise the new volume. |
690 return (agc->stream_analog_level() == volume) ? | 700 return (agc->stream_analog_level() == volume) ? |
691 0 : agc->stream_analog_level(); | 701 0 : agc->stream_analog_level(); |
692 } | 702 } |
693 | 703 |
694 } // namespace content | 704 } // namespace content |
OLD | NEW |