Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webrtc/processed_local_audio_source.h" | 5 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/renderer/media/audio_device_factory.h" | 10 #include "content/renderer/media/audio_device_factory.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 void ProcessedLocalAudioSource::OnCaptureError(const std::string& message) { | 340 void ProcessedLocalAudioSource::OnCaptureError(const std::string& message) { |
| 341 WebRtcLogMessage("ProcessedLocalAudioSource::OnCaptureError: " + message); | 341 WebRtcLogMessage("ProcessedLocalAudioSource::OnCaptureError: " + message); |
| 342 StopSourceOnError(message); | 342 StopSourceOnError(message); |
| 343 } | 343 } |
| 344 | 344 |
| 345 media::AudioParameters ProcessedLocalAudioSource::GetInputFormat() const { | 345 media::AudioParameters ProcessedLocalAudioSource::GetInputFormat() const { |
| 346 return audio_processor_ ? audio_processor_->InputFormat() | 346 return audio_processor_ ? audio_processor_->InputFormat() |
| 347 : media::AudioParameters(); | 347 : media::AudioParameters(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void ProcessedLocalAudioSource::getSettings( | |
| 351 blink::WebMediaStreamTrack::Settings& settings) { | |
| 352 // TODO(hta): Give the correct value. | |
|
Guido Urdaneta
2017/01/19 15:28:06
nit: add crbug.com reference
| |
| 353 settings.setEchoCancellation(true); | |
| 354 } | |
| 355 | |
| 350 int ProcessedLocalAudioSource::GetBufferSize(int sample_rate) const { | 356 int ProcessedLocalAudioSource::GetBufferSize(int sample_rate) const { |
| 351 DCHECK(thread_checker_.CalledOnValidThread()); | 357 DCHECK(thread_checker_.CalledOnValidThread()); |
| 352 #if defined(OS_ANDROID) | 358 #if defined(OS_ANDROID) |
| 353 // TODO(henrika): Re-evaluate whether to use same logic as other platforms. | 359 // TODO(henrika): Re-evaluate whether to use same logic as other platforms. |
| 354 // http://crbug.com/638081 | 360 // http://crbug.com/638081 |
| 355 return (2 * sample_rate / 100); | 361 return (2 * sample_rate / 100); |
| 356 #endif | 362 #endif |
| 357 | 363 |
| 358 // If audio processing is turned on, require 10ms buffers. | 364 // If audio processing is turned on, require 10ms buffers. |
| 359 if (audio_processor_->has_audio_processing()) | 365 if (audio_processor_->has_audio_processing()) |
| 360 return (sample_rate / 100); | 366 return (sample_rate / 100); |
| 361 | 367 |
| 362 // If audio processing is off and the native hardware buffer size was | 368 // If audio processing is off and the native hardware buffer size was |
| 363 // provided, use it. It can be harmful, in terms of CPU/power consumption, to | 369 // provided, use it. It can be harmful, in terms of CPU/power consumption, to |
| 364 // use smaller buffer sizes than the native size (http://crbug.com/362261). | 370 // use smaller buffer sizes than the native size (http://crbug.com/362261). |
| 365 if (int hardware_buffer_size = device_info().device.input.frames_per_buffer) | 371 if (int hardware_buffer_size = device_info().device.input.frames_per_buffer) |
| 366 return hardware_buffer_size; | 372 return hardware_buffer_size; |
| 367 | 373 |
| 368 // If the buffer size is missing from the StreamDeviceInfo, provide 10ms as a | 374 // If the buffer size is missing from the StreamDeviceInfo, provide 10ms as a |
| 369 // fall-back. | 375 // fall-back. |
| 370 // | 376 // |
| 371 // TODO(miu): Identify where/why the buffer size might be missing, fix the | 377 // TODO(miu): Identify where/why the buffer size might be missing, fix the |
| 372 // code, and then require it here. http://crbug.com/638081 | 378 // code, and then require it here. http://crbug.com/638081 |
| 373 return (sample_rate / 100); | 379 return (sample_rate / 100); |
| 374 } | 380 } |
| 375 | 381 |
| 376 } // namespace content | 382 } // namespace content |
| OLD | NEW |