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

Side by Side Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 11669004: Add chromium support for MediaStreamAudioDestinationNode - part II (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/webaudio_capturer_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 10 #include "base/string_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 { 106 {
107 base::AutoLock auto_lock(lock_); 107 base::AutoLock auto_lock(lock_);
108 if (source_ == source) 108 if (source_ == source)
109 return; 109 return;
110 110
111 source_.swap(old_source); 111 source_.swap(old_source);
112 source_ = source; 112 source_ = source;
113 } 113 }
114 114
115 // Detach the old source from normal recording. 115 // Detach the old source from normal recording.
116 if (old_source) 116 if (old_source) {
117 old_source->Stop(); 117 old_source->Stop();
118 118
119 // TODO(henrika, crogers): I have hard coded parameters given knowledge
120 // of a file source (44.1kHz, mono) here and use these parameters to reset
121 // our member parameters. I then dispatch the new parameters both to the
122 // sink(s) and to the new source. The idea is to get rid of any dependency
123 // of the microphone parameters which are uses as base otherwise.
124
125 // I guess we could add this info to AudioCapturerSource to enable a
126 // query here. E.g.:
127
128 // source->ModifyAudioParameters(&params_);
129
130 params_.Reset(params_.format(),
131 media::CHANNEL_LAYOUT_MONO, // <-- get this from WebKit?
132 44100, // <-- get this from WebKit?
133 16, // <-- get this from WebKit?
134 440); // requires knowledge about WebRTC @ 10ms
135
136 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]);
137
138 for (SinkList::const_iterator it = sinks_.begin();
139 it != sinks_.end(); ++it) {
140 (*it)->SetCaptureFormat(params_);
141 }
142 }
143
119 if (source) 144 if (source)
120 source->Initialize(params_, this, this); 145 source->Initialize(params_, this, this);
121 } 146 }
122 147
123 void WebRtcAudioCapturer::SetStopCallback( 148 void WebRtcAudioCapturer::SetStopCallback(
124 const base::Closure& on_device_stopped_cb) { 149 const base::Closure& on_device_stopped_cb) {
125 DVLOG(1) << "WebRtcAudioCapturer::SetStopCallback()"; 150 DVLOG(1) << "WebRtcAudioCapturer::SetStopCallback()";
126 base::AutoLock auto_lock(lock_); 151 base::AutoLock auto_lock(lock_);
127 on_device_stopped_cb_ = on_device_stopped_cb; 152 on_device_stopped_cb_ = on_device_stopped_cb;
128 } 153 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Inform the local renderer about the stopped device. 395 // Inform the local renderer about the stopped device.
371 // The renderer can then save resources by not asking for more data from 396 // The renderer can then save resources by not asking for more data from
372 // the stopped source. We are on the IO thread but the callback task will 397 // the stopped source. We are on the IO thread but the callback task will
373 // be posted on the message loop of the main render thread thanks to 398 // be posted on the message loop of the main render thread thanks to
374 // usage of BindToLoop() when the callback was initialized. 399 // usage of BindToLoop() when the callback was initialized.
375 if (!on_device_stopped_cb_.is_null()) 400 if (!on_device_stopped_cb_.is_null())
376 on_device_stopped_cb_.Run(); 401 on_device_stopped_cb_.Run();
377 } 402 }
378 403
379 } // namespace content 404 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webaudio_capturer_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698