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 caa88d03825fe6d93ebf0f0c856c86405d9569d0..21246798cc4c6befeb04ed00ec81432abbdff57c 100644 |
--- a/content/renderer/media/webrtc_audio_capturer.h |
+++ b/content/renderer/media/webrtc_audio_capturer.h |
@@ -13,6 +13,7 @@ |
#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_source_provider.h" |
#include "media/audio/audio_input_device.h" |
#include "media/base/audio_capturer_source.h" |
@@ -50,6 +51,7 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
bool Initialize(int render_view_id, |
media::ChannelLayout channel_layout, |
int sample_rate, |
+ int buffer_size, |
int session_id, |
const std::string& device_id); |
@@ -73,6 +75,11 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
media::ChannelLayout channel_layout, |
float sample_rate); |
+ // Called when a stream is connecting to a peer connection. This will set |
+ // up the native buffer size for the stream in order to optimize the |
+ // performance for peer connection. |
+ void EnablePeerConnectionMode(); |
+ |
// Volume APIs used by WebRtcAudioDeviceImpl. |
// Called on the AudioInputDevice audio thread. |
void SetVolume(int volume); |
@@ -95,6 +102,10 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
const std::string& device_id() const { return device_id_; } |
+ WebKit::WebAudioSourceProvider* audio_source_provider() const { |
+ return source_provider_.get(); |
+ } |
+ |
protected: |
friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; |
WebRtcAudioCapturer(); |
@@ -112,9 +123,9 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
bool key_pressed) OVERRIDE; |
virtual void OnCaptureError() OVERRIDE; |
- // Reconfigures the capturer with a new buffer size and capture parameters. |
- // Must be called without holding the lock. Returns true on success. |
- bool Reconfigure(int sample_rate, media::ChannelLayout channel_layout); |
+ // Reconfigures the capturer with a new capture parameters. |
+ // Must be called without holding the lock. |
+ void Reconfigure(int sample_rate, media::ChannelLayout channel_layout); |
// Starts recording audio. |
// Triggered by AddSink() on the main render thread or a Libjingle working |
@@ -126,6 +137,9 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// thread. It should NOT be called under |lock_|. |
void Stop(); |
+ // Helper function to get the buffer size based on |peer_connection_mode_| |
+ // and sample rate; |
+ int GetBufferSize(int sample_rate) const; |
// Used to DCHECK that we are called on the correct thread. |
base::ThreadChecker thread_checker_; |
@@ -140,15 +154,20 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// The audio data source from the browser process. |
scoped_refptr<media::AudioCapturerSource> source_; |
- // Buffers used for temporary storage during capture callbacks. |
- // Allocated during initialization. |
- class ConfiguredBuffer; |
- scoped_refptr<ConfiguredBuffer> buffer_; |
+ // Cached audio parameters for output. |
+ media::AudioParameters params_; |
+ |
bool running_; |
// True when automatic gain control is enabled, false otherwise. |
bool agc_is_enabled_; |
+ int render_view_id_; |
+ |
+ // Cached value for the hardware native buffer size, used when |
+ // |peer_connection_mode_| is set to false. |
+ int hardware_buffer_size_; |
+ |
// The media session ID used to identify which input device to be started by |
// the browser. |
int session_id_; |
@@ -160,6 +179,15 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// Range is [0, 255]. |
int volume_; |
+ // The source provider to feed the capture data to other clients like |
+ // WebAudio. |
+ // TODO(xians): Move the source provider to track once we don't need to feed |
+ // delay, volume, key_pressed information to WebAudioCapturerSource. |
+ const scoped_ptr<WebRtcLocalAudioSourceProvider> source_provider_; |
+ |
+ // Flag which affects the buffer size used by the capturer. |
+ bool peer_connection_mode_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); |
}; |