Index: content/renderer/media/webaudio_capturer_source.h |
diff --git a/content/renderer/media/webaudio_capturer_source.h b/content/renderer/media/webaudio_capturer_source.h |
index 68bd05fbe03b8e396c436ce2426853b79e8f7dab..b438a4083ee1d5ff208a8c132bf0ac8346ce0247 100644 |
--- a/content/renderer/media/webaudio_capturer_source.h |
+++ b/content/renderer/media/webaudio_capturer_source.h |
@@ -7,6 +7,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/synchronization/lock.h" |
+#include "base/threading/thread_checker.h" |
#include "media/audio/audio_parameters.h" |
#include "media/base/audio_capturer_source.h" |
#include "media/base/audio_fifo.h" |
@@ -15,50 +16,59 @@ |
namespace content { |
-class WebRtcAudioCapturer; |
+class WebRtcLocalAudioTrack; |
+class WebRtcLocalAudioSourceProvider; |
// WebAudioCapturerSource is the missing link between |
-// WebAudio's MediaStreamAudioDestinationNode and WebRtcAudioCapturer. |
+// WebAudio's MediaStreamAudioDestinationNode and WebRtcLocalAudioTrack. |
// |
// 1. WebKit calls the setFormat() method setting up the basic stream format |
-// (channels, and sample-rate). At this time, it dispatches this information |
-// to the WebRtcAudioCapturer by calling its SetCapturerSource() method. |
-// 2. Initialize() is called, where we should get back the same |
-// stream format information as (1). We also get the CaptureCallback here. |
-// 3. consumeAudio() is called periodically by WebKit which dispatches the |
-// audio stream to the CaptureCallback::Capture() method. |
+// (channels, and sample-rate). |
+// 2. consumeAudio() is called periodically by WebKit which dispatches the |
+// audio stream to the WebRtcLocalAudioTrack::Capture() method. |
class WebAudioCapturerSource |
- : public media::AudioCapturerSource, |
- public WebKit::WebAudioDestinationConsumer { |
+ : public base::RefCountedThreadSafe<WebAudioCapturerSource>, |
+ public WebKit::WebAudioDestinationConsumer { |
public: |
- explicit WebAudioCapturerSource(WebRtcAudioCapturer* capturer); |
+ WebAudioCapturerSource(); |
// WebAudioDestinationConsumer implementation. |
- // setFormat() is called early on, so that we can configure the capturer. |
+ // setFormat() is called early on, so that we can configure the audio track. |
virtual void setFormat(size_t number_of_channels, float sample_rate) OVERRIDE; |
// MediaStreamAudioDestinationNode periodically calls consumeAudio(). |
+ // Called on the WebAudio audio thread. |
virtual void consumeAudio(const WebKit::WebVector<const float*>& audio_data, |
size_t number_of_frames) OVERRIDE; |
- // AudioCapturerSource implementation. |
- virtual void Initialize( |
- const media::AudioParameters& params, |
- media::AudioCapturerSource::CaptureCallback* callback, |
- int session_id) OVERRIDE; |
+ // Called when the WebAudioCapturerSource is hooking to a media audio track. |
+ // |track| is the sink of the data flow. |source_provider| is the source of |
+ // the data flow where stream information like delay, volume, key_pressed, |
+ // is stored. |
+ void Start(WebRtcLocalAudioTrack* track, |
+ WebRtcLocalAudioSourceProvider* source_provider); |
- virtual void Start() OVERRIDE; |
- virtual void Stop() OVERRIDE; |
- virtual void SetVolume(double volume) OVERRIDE { } |
- virtual void SetAutomaticGainControl(bool enable) OVERRIDE { } |
+ // Called when the media audio track is stopping. |
+ void Stop(); |
- private: |
+ protected: |
+ friend class base::RefCountedThreadSafe<WebAudioCapturerSource>; |
virtual ~WebAudioCapturerSource(); |
- WebRtcAudioCapturer* capturer_; |
+ private: |
+ // Used to DCHECK that some methods are called on the correct thread. |
+ base::ThreadChecker thread_checker_; |
+ |
+ // The audio track this WebAudioCapturerSource is feeding data to. |
+ // WebRtcLocalAudioTrack is reference counted, and owning this object. |
+ // To avoid circular reference, a raw pointer is kept here. |
+ WebRtcLocalAudioTrack* track_; |
+ |
+ // A raw pointer to the source provider to get audio processing params like |
+ // delay, volume, key_pressed information. |
+ // This |source_provider_| is guaranteed to outlive this object. |
+ WebRtcLocalAudioSourceProvider* source_provider_; |
- int set_format_channels_; |
media::AudioParameters params_; |
- media::AudioCapturerSource::CaptureCallback* callback_; |
// Wraps data coming from HandleCapture(). |
scoped_ptr<media::AudioBus> wrapper_bus_; |