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_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/renderer/media/audio_device_factory.h" | |
11 #include "content/renderer/media/audio_hardware.h" | 10 #include "content/renderer/media/audio_hardware.h" |
| 11 #include "content/renderer/media/audio_input_message_filter.h" |
12 #include "content/renderer/media/webrtc_audio_device_impl.h" | 12 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 13 #include "content/renderer/render_thread_impl.h" |
| 14 #include "media/audio/audio_input_device.h" |
13 #include "media/audio/audio_util.h" | 15 #include "media/audio/audio_util.h" |
14 #include "media/audio/sample_rates.h" | 16 #include "media/audio/sample_rates.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 // Supported hardware sample rates for input and output sides. | 20 // Supported hardware sample rates for input and output sides. |
19 #if defined(OS_WIN) || defined(OS_MACOSX) | 21 #if defined(OS_WIN) || defined(OS_MACOSX) |
20 // media::GetAudioInputHardwareSampleRate() asks the audio layer | 22 // media::GetAudioInputHardwareSampleRate() asks the audio layer |
21 // for its current sample rate (set by the user) on Windows and Mac OS X. | 23 // for its current sample rate (set by the user) on Windows and Mac OS X. |
22 // The listed rates below adds restrictions and WebRtcAudioDeviceImpl::Init() | 24 // The listed rates below adds restrictions and WebRtcAudioDeviceImpl::Init() |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 base::AutoLock auto_lock(lock_); | 90 base::AutoLock auto_lock(lock_); |
89 for (SinkList::iterator it = sinks_.begin(); it != sinks_.end(); ++it) { | 91 for (SinkList::iterator it = sinks_.begin(); it != sinks_.end(); ++it) { |
90 if (sink == *it) { | 92 if (sink == *it) { |
91 sinks_.erase(it); | 93 sinks_.erase(it); |
92 break; | 94 break; |
93 } | 95 } |
94 } | 96 } |
95 } | 97 } |
96 | 98 |
97 void WebRtcAudioCapturer::SetCapturerSource( | 99 void WebRtcAudioCapturer::SetCapturerSource( |
98 media::AudioCapturerSource* source) { | 100 scoped_refptr<media::AudioCapturerSource> source) { |
99 DVLOG(1) << "SetCapturerSource()"; | 101 DVLOG(1) << "SetCapturerSource()"; |
100 scoped_refptr<media::AudioCapturerSource> old_source; | 102 scoped_refptr<media::AudioCapturerSource> old_source; |
101 { | 103 { |
102 base::AutoLock auto_lock(lock_); | 104 base::AutoLock auto_lock(lock_); |
103 if (source_ == source) | 105 if (source_ == source) |
104 return; | 106 return; |
105 | 107 |
106 source_.swap(old_source); | 108 source_.swap(old_source); |
107 source_ = source; | 109 source_ = source; |
108 } | 110 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return false; | 150 return false; |
149 } | 151 } |
150 | 152 |
151 params_.Reset(format, channel_layout, sample_rate, 16, buffer_size); | 153 params_.Reset(format, channel_layout, sample_rate, 16, buffer_size); |
152 | 154 |
153 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); | 155 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); |
154 | 156 |
155 // Create and configure the default audio capturing source. The |source_| | 157 // Create and configure the default audio capturing source. The |source_| |
156 // will be overwritten if the client call the source calls | 158 // will be overwritten if the client call the source calls |
157 // SetCapturerSource(). | 159 // SetCapturerSource(). |
158 SetCapturerSource(AudioDeviceFactory::NewInputDevice()); | 160 SetCapturerSource(new media::AudioInputDevice( |
| 161 RenderThreadImpl::current()->audio_input_message_filter(), |
| 162 RenderThreadImpl::current()->GetIOMessageLoopProxy())); |
159 | 163 |
160 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 164 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
161 channel_layout, media::CHANNEL_LAYOUT_MAX); | 165 channel_layout, media::CHANNEL_LAYOUT_MAX); |
162 | 166 |
163 return true; | 167 return true; |
164 } | 168 } |
165 | 169 |
166 void WebRtcAudioCapturer::Start() { | 170 void WebRtcAudioCapturer::Start() { |
167 base::AutoLock auto_lock(lock_); | 171 base::AutoLock auto_lock(lock_); |
168 if (running_) | 172 if (running_) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 252 |
249 void WebRtcAudioCapturer::OnDeviceStarted(const std::string& device_id) { | 253 void WebRtcAudioCapturer::OnDeviceStarted(const std::string& device_id) { |
250 device_id_ = device_id; | 254 device_id_ = device_id; |
251 } | 255 } |
252 | 256 |
253 void WebRtcAudioCapturer::OnDeviceStopped() { | 257 void WebRtcAudioCapturer::OnDeviceStopped() { |
254 NOTIMPLEMENTED(); | 258 NOTIMPLEMENTED(); |
255 } | 259 } |
256 | 260 |
257 } // namespace content | 261 } // namespace content |
OLD | NEW |