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

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

Issue 11783059: Ensures that WebRTC works for device selection using a different sample rate than default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed content_unittests 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.h
diff --git a/content/renderer/media/webrtc_audio_capturer.h b/content/renderer/media/webrtc_audio_capturer.h
index a3a22b13b7c218a0df7c39f1cfbe5fe1f772fcd9..44a5dcbcbafb5ff642ec0c486adcb3e4a44c2dfb 100644
--- a/content/renderer/media/webrtc_audio_capturer.h
+++ b/content/renderer/media/webrtc_audio_capturer.h
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
+#include "base/threading/thread_checker.h"
#include "content/renderer/media/webrtc_audio_device_impl.h"
#include "content/renderer/media/webrtc_local_audio_renderer.h"
#include "media/audio/audio_input_device.h"
@@ -32,42 +33,59 @@ class WebRtcLocalAudioRenderer;
// SetCapturerSource(). It is also possible to enable a local sink and
// register a callback which the sink can call when it wants to read captured
// data cached in a FIFO for local loopback rendering.
-// The threading model for this class is rather messy since it will be
-// created on a Libjingle thread, captured data is provided on a dedicated
+// The threading model for this class is rather complex since it will be
+// created on the main render thread, captured data is provided on a dedicated
// AudioInputDevice thread, and methods can be called either on the Libjingle
// thread or on the main render thread but also other client threads
// if an alternative AudioCapturerSource has been set. In addition, the
// AudioCapturerSource::CaptureEventHandler methods are called on the IO thread
// and requests for data to render is done on the AudioOutputDevice thread.
-class WebRtcAudioCapturer
+class CONTENT_EXPORT WebRtcAudioCapturer
: public base::RefCountedThreadSafe<WebRtcAudioCapturer>,
- public media::AudioCapturerSource::CaptureCallback,
- public media::AudioCapturerSource::CaptureEventHandler,
- public content::WebRtcLocalAudioRenderer::LocalRenderCallback {
+ NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback),
+ NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureEventHandler),
+ NON_EXPORTED_BASE(public content::WebRtcLocalAudioRenderer::LocalRenderCallback) {
tommi (sloooow) - chröme 2013/01/15 17:43:49 80+
henrika (OOO until Aug 14) 2013/01/16 16:37:17 Done.
public:
// Use to construct the audio capturer.
+ // Called on the main render thread.
static scoped_refptr<WebRtcAudioCapturer> CreateCapturer();
+ // Creates and configures the default audio capturing source using the
+ // provided audio parameters.
+ // Called on the main render thread.
+ bool Initialize(media::ChannelLayout channel_layout, int sample_rate);
+
// Called by the client on the sink side to add a sink.
+ // WebRtcAudioDeviceImpl calls this method on the main render thread but
+ // other clients may call it from other threads. The current implementation
+ // does not support multi-thread calling.
+ // TODO(henrika): add lock if we extend number of supported sinks.
+ // Called on the main render thread.
void AddCapturerSink(WebRtcAudioCapturerSink* sink);
// Called by the client on the sink side to remove a sink.
+ // Called on the main render thread.
+ // TODO(henrika): add lock if we extend number of supported sinks.
+ // Called on the main render thread.
void RemoveCapturerSink(WebRtcAudioCapturerSink* sink);
// SetCapturerSource() is called if the client on the source side desires to
// provide their own captured audio data. Client is responsible for calling
// Start() on its own source to have the ball rolling.
+ // Called on the main render thread.
void SetCapturerSource(
const scoped_refptr<media::AudioCapturerSource>& source);
// The |on_device_stopped_cb| callback will be called in OnDeviceStopped().
+ // Called on the main render thread.
void SetStopCallback(const base::Closure& on_device_stopped_cb);
// Informs this class that a local sink shall be used in addition to the
// registered WebRtcAudioCapturerSink sink(s). The capturer will enter a
// buffering mode and store all incoming audio frames in a local FIFO.
// The renderer will read data from this buffer using the ProvideInput()
- // method. Called on the main render thread.
+ // method.
+ // Called on the main render thread.
void PrepareLoopback();
// Cancels loopback mode and stops buffering local copies of captured
@@ -86,24 +104,30 @@ class WebRtcAudioCapturer
void ResumeBuffering();
// Starts recording audio.
+ // Called on the main render thread or a Libjingle working thread.
void Start();
// Stops recording audio.
+ // Called on the main render thread or a Libjingle working thread.
void Stop();
// Sets the microphone volume.
+ // Called on the AudioInputDevice audio thread.
void SetVolume(double volume);
// Specifies the |session_id| to query which device to use.
+ // Called on the main render thread.
void SetDevice(int session_id);
// Enables or disables the WebRtc AGC control.
+ // Called from a Libjingle working thread.
void SetAutomaticGainControl(bool enable);
bool is_recording() const { return running_; }
// Returns true if a local renderer has called PrepareLoopback() and it can
// be utilized to prevent more than one local renderer.
+ // Called on the main render thread.
bool IsInLoopbackMode();
// Audio parameters utilized by the audio capturer. Can be utilized by
@@ -138,9 +162,8 @@ class WebRtcAudioCapturer
WebRtcAudioCapturer();
- // Initializes the capturer, called right after the object is created.
- // Returns false if the initialization fails.
- bool Initialize();
+ // Used to DCHECK that we are called on the correct thread.
+ base::ThreadChecker thread_checker_;
// Protects |source_|, |sinks_|, |running_|, |on_device_stopped_cb_|,
// |loopback_fifo_| and |buffering_|.

Powered by Google App Engine
This is Rietveld 408576698