| 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/webrtc_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (ret == 0) { | 56 if (ret == 0) { |
| 57 delete this; | 57 delete this; |
| 58 } | 58 } |
| 59 return ret; | 59 return ret; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WebRtcAudioDeviceImpl::CaptureData(const int16* audio_data, | 62 void WebRtcAudioDeviceImpl::CaptureData(const int16* audio_data, |
| 63 int number_of_channels, | 63 int number_of_channels, |
| 64 int number_of_frames, | 64 int number_of_frames, |
| 65 int audio_delay_milliseconds, | 65 int audio_delay_milliseconds, |
| 66 double volume) { | 66 double volume, |
| 67 bool key_pressed) { |
| 67 DCHECK_LE(number_of_frames, input_buffer_size()); | 68 DCHECK_LE(number_of_frames, input_buffer_size()); |
| 68 #if defined(OS_WIN) || defined(OS_MACOSX) | 69 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 69 DCHECK_LE(volume, 1.0); | 70 DCHECK_LE(volume, 1.0); |
| 70 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 71 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 71 // We have a special situation on Linux where the microphone volume can be | 72 // We have a special situation on Linux where the microphone volume can be |
| 72 // "higher than maximum". The input volume slider in the sound preference | 73 // "higher than maximum". The input volume slider in the sound preference |
| 73 // allows the user to set a scaling that is higher than 100%. It means that | 74 // allows the user to set a scaling that is higher than 100%. It means that |
| 74 // even if the reported maximum levels is N, the actual microphone level can | 75 // even if the reported maximum levels is N, the actual microphone level can |
| 75 // go up to 1.5x*N and that corresponds to a normalized |volume| of 1.5x. | 76 // go up to 1.5x*N and that corresponds to a normalized |volume| of 1.5x. |
| 76 DCHECK_LE(volume, 1.6); | 77 DCHECK_LE(volume, 1.6); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 int bytes_per_sample = input_audio_parameters.bits_per_sample() / 8; | 106 int bytes_per_sample = input_audio_parameters.bits_per_sample() / 8; |
| 106 const int bytes_per_10_msec = | 107 const int bytes_per_10_msec = |
| 107 channels * samples_per_10_msec * bytes_per_sample; | 108 channels * samples_per_10_msec * bytes_per_sample; |
| 108 int accumulated_audio_samples = 0; | 109 int accumulated_audio_samples = 0; |
| 109 | 110 |
| 110 const uint8* audio_byte_buffer = reinterpret_cast<const uint8*>(audio_data); | 111 const uint8* audio_byte_buffer = reinterpret_cast<const uint8*>(audio_data); |
| 111 | 112 |
| 112 // Write audio samples in blocks of 10 milliseconds to the registered | 113 // Write audio samples in blocks of 10 milliseconds to the registered |
| 113 // webrtc::AudioTransport sink. Keep writing until our internal byte | 114 // webrtc::AudioTransport sink. Keep writing until our internal byte |
| 114 // buffer is empty. | 115 // buffer is empty. |
| 115 // TODO(niklase): Wire up the key press detection. | |
| 116 bool key_pressed = false; | |
| 117 while (accumulated_audio_samples < number_of_frames) { | 116 while (accumulated_audio_samples < number_of_frames) { |
| 118 // Deliver 10ms of recorded 16-bit linear PCM audio. | 117 // Deliver 10ms of recorded 16-bit linear PCM audio. |
| 119 audio_transport_callback_->RecordedDataIsAvailable( | 118 audio_transport_callback_->RecordedDataIsAvailable( |
| 120 audio_byte_buffer, | 119 audio_byte_buffer, |
| 121 samples_per_10_msec, | 120 samples_per_10_msec, |
| 122 bytes_per_sample, | 121 bytes_per_sample, |
| 123 channels, | 122 channels, |
| 124 samples_per_sec, | 123 samples_per_sec, |
| 125 input_delay_ms_ + output_delay_ms, | 124 input_delay_ms_ + output_delay_ms, |
| 126 0, // TODO(henrika): |clock_drift| parameter is not utilized today. | 125 0, // TODO(henrika): |clock_drift| parameter is not utilized today. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 return false; | 496 return false; |
| 498 | 497 |
| 499 if (!renderer->Initialize(this)) | 498 if (!renderer->Initialize(this)) |
| 500 return false; | 499 return false; |
| 501 | 500 |
| 502 renderer_ = renderer; | 501 renderer_ = renderer; |
| 503 return true; | 502 return true; |
| 504 } | 503 } |
| 505 | 504 |
| 506 } // namespace content | 505 } // namespace content |
| OLD | NEW |