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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (media::ToAudioSampleRate(device_info_.device.input.sample_rate, &asr)) { | 168 if (media::ToAudioSampleRate(device_info_.device.input.sample_rate, &asr)) { |
169 UMA_HISTOGRAM_ENUMERATION( | 169 UMA_HISTOGRAM_ENUMERATION( |
170 "WebRTC.AudioInputSampleRate", asr, media::kAudioSampleRateMax + 1); | 170 "WebRTC.AudioInputSampleRate", asr, media::kAudioSampleRateMax + 1); |
171 } else { | 171 } else { |
172 UMA_HISTOGRAM_COUNTS("WebRTC.AudioInputSampleRateUnexpected", | 172 UMA_HISTOGRAM_COUNTS("WebRTC.AudioInputSampleRateUnexpected", |
173 device_info_.device.input.sample_rate); | 173 device_info_.device.input.sample_rate); |
174 } | 174 } |
175 | 175 |
176 // Create and configure the default audio capturing source. | 176 // Create and configure the default audio capturing source. |
177 SetCapturerSourceInternal( | 177 SetCapturerSourceInternal( |
178 AudioDeviceFactory::NewInputDevice(render_frame_id_), channel_layout, | 178 AudioDeviceFactory::NewAudioCapturerSource(render_frame_id_), |
179 device_info_.device.input.sample_rate); | 179 channel_layout, device_info_.device.input.sample_rate); |
180 | 180 |
181 // Add the capturer to the WebRtcAudioDeviceImpl since it needs some hardware | 181 // Add the capturer to the WebRtcAudioDeviceImpl since it needs some hardware |
182 // information from the capturer. | 182 // information from the capturer. |
183 if (audio_device_) | 183 if (audio_device_) |
184 audio_device_->AddAudioCapturer(this); | 184 audio_device_->AddAudioCapturer(this); |
185 | 185 |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
189 WebRtcAudioCapturer::WebRtcAudioCapturer( | 189 WebRtcAudioCapturer::WebRtcAudioCapturer( |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } | 344 } |
345 | 345 |
346 // Do nothing if the current buffer size is the WebRtc native buffer size. | 346 // Do nothing if the current buffer size is the WebRtc native buffer size. |
347 if (GetBufferSize(input_params.sample_rate()) == | 347 if (GetBufferSize(input_params.sample_rate()) == |
348 input_params.frames_per_buffer()) { | 348 input_params.frames_per_buffer()) { |
349 return; | 349 return; |
350 } | 350 } |
351 | 351 |
352 // Create a new audio stream as source which will open the hardware using | 352 // Create a new audio stream as source which will open the hardware using |
353 // WebRtc native buffer size. | 353 // WebRtc native buffer size. |
354 SetCapturerSourceInternal(AudioDeviceFactory::NewInputDevice(render_frame_id), | 354 SetCapturerSourceInternal( |
355 input_params.channel_layout(), | 355 AudioDeviceFactory::NewAudioCapturerSource(render_frame_id), |
356 input_params.sample_rate()); | 356 input_params.channel_layout(), input_params.sample_rate()); |
357 } | 357 } |
358 | 358 |
359 void WebRtcAudioCapturer::Start() { | 359 void WebRtcAudioCapturer::Start() { |
360 DCHECK(thread_checker_.CalledOnValidThread()); | 360 DCHECK(thread_checker_.CalledOnValidThread()); |
361 DVLOG(1) << "WebRtcAudioCapturer::Start()"; | 361 DVLOG(1) << "WebRtcAudioCapturer::Start()"; |
362 base::AutoLock auto_lock(lock_); | 362 base::AutoLock auto_lock(lock_); |
363 if (running_ || !source_.get()) | 363 if (running_ || !source_.get()) |
364 return; | 364 return; |
365 | 365 |
366 // Start the data source, i.e., start capturing data from the current source. | 366 // Start the data source, i.e., start capturing data from the current source. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 | 557 |
558 void WebRtcAudioCapturer::SetCapturerSource( | 558 void WebRtcAudioCapturer::SetCapturerSource( |
559 const scoped_refptr<media::AudioCapturerSource>& source, | 559 const scoped_refptr<media::AudioCapturerSource>& source, |
560 media::AudioParameters params) { | 560 media::AudioParameters params) { |
561 // Create a new audio stream as source which uses the new source. | 561 // Create a new audio stream as source which uses the new source. |
562 SetCapturerSourceInternal(source, params.channel_layout(), | 562 SetCapturerSourceInternal(source, params.channel_layout(), |
563 params.sample_rate()); | 563 params.sample_rate()); |
564 } | 564 } |
565 | 565 |
566 } // namespace content | 566 } // namespace content |
OLD | NEW |