Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1974)

Unified Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 11369171: Add chromium support for MediaStreamAudioDestinationNode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_audio_capturer.cc
===================================================================
--- content/renderer/media/webrtc_audio_capturer.cc (revision 176961)
+++ content/renderer/media/webrtc_audio_capturer.cc (working copy)
@@ -100,7 +100,9 @@
}
void WebRtcAudioCapturer::SetCapturerSource(
- const scoped_refptr<media::AudioCapturerSource>& source) {
+ const scoped_refptr<media::AudioCapturerSource>& source,
+ media::ChannelLayout channel_layout,
+ float sample_rate) {
DVLOG(1) << "SetCapturerSource()";
scoped_refptr<media::AudioCapturerSource> old_source;
{
@@ -113,9 +115,33 @@
}
// Detach the old source from normal recording.
- if (old_source)
+ if (old_source) {
old_source->Stop();
+ // Dispatch the new parameters both to the sink(s) and to the new source.
+ // The idea is to get rid of any dependency of the microphone parameters
+ // which would normally be used by default.
+
+ int buffer_size = GetBufferSizeForSampleRate(sample_rate);
+ if (!buffer_size) {
+ DLOG(ERROR) << "Unsupported sample-rate: " << sample_rate;
+ return;
+ }
+
+ params_.Reset(params_.format(),
+ channel_layout,
+ sample_rate,
+ 16, // ignored since the audio stack uses float32.
+ buffer_size);
+
+ buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]);
+
+ for (SinkList::const_iterator it = sinks_.begin();
+ it != sinks_.end(); ++it) {
+ (*it)->SetCaptureFormat(params_);
+ }
+ }
+
if (source)
source->Initialize(params_, this, this);
}
@@ -212,7 +238,8 @@
// Create and configure the default audio capturing source. The |source_|
// will be overwritten if the client call the source calls
// SetCapturerSource().
- SetCapturerSource(AudioDeviceFactory::NewInputDevice());
+ SetCapturerSource(
+ AudioDeviceFactory::NewInputDevice(), channel_layout, sample_rate);
UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout",
channel_layout, media::CHANNEL_LAYOUT_MAX);

Powered by Google App Engine
This is Rietveld 408576698