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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // Store the setting since SetAutomaticGainControl() can be called before | 367 // Store the setting since SetAutomaticGainControl() can be called before |
368 // Initialize(), in this case stored setting will be applied in Start(). | 368 // Initialize(), in this case stored setting will be applied in Start(). |
369 agc_is_enabled_ = enable; | 369 agc_is_enabled_ = enable; |
370 | 370 |
371 if (source_.get()) | 371 if (source_.get()) |
372 source_->SetAutomaticGainControl(enable); | 372 source_->SetAutomaticGainControl(enable); |
373 } | 373 } |
374 | 374 |
375 void WebRtcAudioCapturer::Capture(media::AudioBus* audio_source, | 375 void WebRtcAudioCapturer::Capture(media::AudioBus* audio_source, |
376 int audio_delay_milliseconds, | 376 int audio_delay_milliseconds, |
377 double volume) { | 377 double volume, |
| 378 bool key_pressed) { |
378 // This callback is driven by AudioInputDevice::AudioThreadCallback if | 379 // This callback is driven by AudioInputDevice::AudioThreadCallback if |
379 // |source_| is AudioInputDevice, otherwise it is driven by client's | 380 // |source_| is AudioInputDevice, otherwise it is driven by client's |
380 // CaptureCallback. | 381 // CaptureCallback. |
381 TrackList tracks; | 382 TrackList tracks; |
382 scoped_refptr<ConfiguredBuffer> buffer_ref_while_calling; | 383 scoped_refptr<ConfiguredBuffer> buffer_ref_while_calling; |
383 { | 384 { |
384 base::AutoLock auto_lock(lock_); | 385 base::AutoLock auto_lock(lock_); |
385 if (!running_) | 386 if (!running_) |
386 return; | 387 return; |
387 | 388 |
(...skipping 10 matching lines...) Expand all Loading... |
398 // Interleave, scale, and clip input to int and store result in | 399 // Interleave, scale, and clip input to int and store result in |
399 // a local byte buffer. | 400 // a local byte buffer. |
400 audio_source->ToInterleaved(audio_source->frames(), bytes_per_sample, | 401 audio_source->ToInterleaved(audio_source->frames(), bytes_per_sample, |
401 buffer_ref_while_calling->buffer()); | 402 buffer_ref_while_calling->buffer()); |
402 | 403 |
403 // Feed the data to the tracks. | 404 // Feed the data to the tracks. |
404 for (TrackList::const_iterator it = tracks.begin(); | 405 for (TrackList::const_iterator it = tracks.begin(); |
405 it != tracks.end(); | 406 it != tracks.end(); |
406 ++it) { | 407 ++it) { |
407 (*it)->CaptureData(buffer_ref_while_calling->buffer(), | 408 (*it)->CaptureData(buffer_ref_while_calling->buffer(), |
408 audio_source->channels(), audio_source->frames(), | 409 audio_source->channels(), |
409 audio_delay_milliseconds, volume); | 410 audio_source->frames(), |
| 411 audio_delay_milliseconds, |
| 412 volume, |
| 413 key_pressed); |
410 } | 414 } |
411 } | 415 } |
412 | 416 |
413 void WebRtcAudioCapturer::OnCaptureError() { | 417 void WebRtcAudioCapturer::OnCaptureError() { |
414 NOTIMPLEMENTED(); | 418 NOTIMPLEMENTED(); |
415 } | 419 } |
416 | 420 |
417 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { | 421 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { |
418 base::AutoLock auto_lock(lock_); | 422 base::AutoLock auto_lock(lock_); |
419 // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not | 423 // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not |
420 // been called. | 424 // been called. |
421 return buffer_.get() ? buffer_->params() : media::AudioParameters(); | 425 return buffer_.get() ? buffer_->params() : media::AudioParameters(); |
422 } | 426 } |
423 | 427 |
424 } // namespace content | 428 } // namespace content |
OLD | NEW |