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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Dispatch the new parameters both to the sink(s) and to the new source, | 290 // Dispatch the new parameters both to the sink(s) and to the new source, |
291 // also apply the new |constraints|. | 291 // also apply the new |constraints|. |
292 // The idea is to get rid of any dependency of the microphone parameters | 292 // The idea is to get rid of any dependency of the microphone parameters |
293 // which would normally be used by default. | 293 // which would normally be used by default. |
294 // bits_per_sample is always 16 for now. | 294 // bits_per_sample is always 16 for now. |
295 int buffer_size = GetBufferSize(sample_rate); | 295 int buffer_size = GetBufferSize(sample_rate); |
296 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 296 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
297 channel_layout, 0, sample_rate, | 297 channel_layout, 0, sample_rate, |
298 16, buffer_size, effects); | 298 16, buffer_size, effects); |
299 scoped_refptr<MediaStreamAudioProcessor> new_audio_processor( | 299 scoped_refptr<MediaStreamAudioProcessor> new_audio_processor( |
300 new MediaStreamAudioProcessor(params, constraints, effects)); | 300 new MediaStreamAudioProcessor(params, constraints, effects, |
| 301 audio_device_)); |
301 { | 302 { |
302 base::AutoLock auto_lock(lock_); | 303 base::AutoLock auto_lock(lock_); |
303 audio_processor_ = new_audio_processor; | 304 audio_processor_ = new_audio_processor; |
304 need_audio_processing_ = NeedsAudioProcessing(constraints, effects); | 305 need_audio_processing_ = NeedsAudioProcessing(constraints, effects); |
305 | 306 |
306 // Notify all tracks about the new format. | 307 // Notify all tracks about the new format. |
307 tracks_.TagAll(); | 308 tracks_.TagAll(); |
308 } | 309 } |
309 | 310 |
310 if (source.get()) | 311 if (source.get()) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 550 } |
550 | 551 |
551 void WebRtcAudioCapturer::GetAudioProcessingParams( | 552 void WebRtcAudioCapturer::GetAudioProcessingParams( |
552 base::TimeDelta* delay, int* volume, bool* key_pressed) { | 553 base::TimeDelta* delay, int* volume, bool* key_pressed) { |
553 base::AutoLock auto_lock(lock_); | 554 base::AutoLock auto_lock(lock_); |
554 *delay = audio_delay_; | 555 *delay = audio_delay_; |
555 *volume = volume_; | 556 *volume = volume_; |
556 *key_pressed = key_pressed_; | 557 *key_pressed = key_pressed_; |
557 } | 558 } |
558 | 559 |
559 void WebRtcAudioCapturer::FeedRenderDataToAudioProcessor( | |
560 const int16* render_audio, | |
561 int sample_rate, | |
562 int number_of_channels, | |
563 int number_of_frames, | |
564 base::TimeDelta render_delay) { | |
565 scoped_refptr<MediaStreamAudioProcessor> audio_processor; | |
566 { | |
567 base::AutoLock auto_lock(lock_); | |
568 if (!running_) | |
569 return; | |
570 | |
571 audio_processor = audio_processor_; | |
572 } | |
573 | |
574 audio_processor->PushRenderData(render_audio, sample_rate, | |
575 number_of_channels, | |
576 number_of_frames, | |
577 render_delay); | |
578 } | |
579 | |
580 void WebRtcAudioCapturer::SetCapturerSourceForTesting( | 560 void WebRtcAudioCapturer::SetCapturerSourceForTesting( |
581 const scoped_refptr<media::AudioCapturerSource>& source, | 561 const scoped_refptr<media::AudioCapturerSource>& source, |
582 media::AudioParameters params) { | 562 media::AudioParameters params) { |
583 // Create a new audio stream as source which uses the new source. | 563 // Create a new audio stream as source which uses the new source. |
584 SetCapturerSource(source, params.channel_layout(), | 564 SetCapturerSource(source, params.channel_layout(), |
585 static_cast<float>(params.sample_rate()), | 565 static_cast<float>(params.sample_rate()), |
586 params.effects(), | 566 params.effects(), |
587 constraints_); | 567 constraints_); |
588 } | 568 } |
589 | 569 |
590 } // namespace content | 570 } // namespace content |
OLD | NEW |