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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 return ret; | 53 return ret; |
54 } | 54 } |
55 int WebRtcAudioDeviceImpl::CaptureData(const std::vector<int>& channels, | 55 int WebRtcAudioDeviceImpl::CaptureData(const std::vector<int>& channels, |
56 const int16* audio_data, | 56 const int16* audio_data, |
57 int sample_rate, | 57 int sample_rate, |
58 int number_of_channels, | 58 int number_of_channels, |
59 int number_of_frames, | 59 int number_of_frames, |
60 int audio_delay_milliseconds, | 60 int audio_delay_milliseconds, |
61 int current_volume, | 61 int current_volume, |
62 bool need_audio_processing) { | 62 bool need_audio_processing, |
| 63 bool key_pressed) { |
63 int total_delay_ms = 0; | 64 int total_delay_ms = 0; |
64 { | 65 { |
65 base::AutoLock auto_lock(lock_); | 66 base::AutoLock auto_lock(lock_); |
66 if (!recording_) | 67 if (!recording_) |
67 return 0; | 68 return 0; |
68 | 69 |
69 // Store the reported audio delay locally. | 70 // Store the reported audio delay locally. |
70 input_delay_ms_ = audio_delay_milliseconds; | 71 input_delay_ms_ = audio_delay_milliseconds; |
71 total_delay_ms = input_delay_ms_ + output_delay_ms_; | 72 total_delay_ms = input_delay_ms_ + output_delay_ms_; |
72 DVLOG(2) << "total delay: " << input_delay_ms_ + output_delay_ms_; | 73 DVLOG(2) << "total delay: " << input_delay_ms_ + output_delay_ms_; |
73 } | 74 } |
74 | 75 |
75 // Write audio samples in blocks of 10 milliseconds to the registered | 76 // Write audio samples in blocks of 10 milliseconds to the registered |
76 // webrtc::AudioTransport sink. Keep writing until our internal byte | 77 // webrtc::AudioTransport sink. Keep writing until our internal byte |
77 // buffer is empty. | 78 // buffer is empty. |
78 // TODO(niklase): Wire up the key press detection. | |
79 const int16* audio_buffer = audio_data; | 79 const int16* audio_buffer = audio_data; |
80 const int samples_per_10_msec = (sample_rate / 100); | 80 const int samples_per_10_msec = (sample_rate / 100); |
81 int accumulated_audio_samples = 0; | 81 int accumulated_audio_samples = 0; |
82 bool key_pressed = false; | |
83 uint32_t new_volume = 0; | 82 uint32_t new_volume = 0; |
84 while (accumulated_audio_samples < number_of_frames) { | 83 while (accumulated_audio_samples < number_of_frames) { |
85 // Deliver 10ms of recorded 16-bit linear PCM audio. | 84 // Deliver 10ms of recorded 16-bit linear PCM audio. |
86 int new_mic_level = audio_transport_callback_->OnDataAvailable( | 85 int new_mic_level = audio_transport_callback_->OnDataAvailable( |
87 &channels[0], | 86 &channels[0], |
88 channels.size(), | 87 channels.size(), |
89 audio_buffer, | 88 audio_buffer, |
90 sample_rate, | 89 sample_rate, |
91 number_of_channels, | 90 number_of_channels, |
92 samples_per_10_msec, | 91 samples_per_10_msec, |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 for (CapturerList::const_iterator iter = capturers_.begin(); | 479 for (CapturerList::const_iterator iter = capturers_.begin(); |
481 iter != capturers_.end(); ++iter) { | 480 iter != capturers_.end(); ++iter) { |
482 if (!(*iter)->device_id().empty()) | 481 if (!(*iter)->device_id().empty()) |
483 return *iter; | 482 return *iter; |
484 } | 483 } |
485 | 484 |
486 return NULL; | 485 return NULL; |
487 } | 486 } |
488 | 487 |
489 } // namespace content | 488 } // namespace content |
OLD | NEW |