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 afa5f9e54b546f7a6b7b6211ccc2dd651525f189..c9d3bff55f455777c8b1f0c030212f41e113fdc5 100644 |
--- a/content/renderer/media/webrtc_audio_capturer.h |
+++ b/content/renderer/media/webrtc_audio_capturer.h |
@@ -12,10 +12,13 @@ |
#include "base/files/file.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
#include "base/synchronization/lock.h" |
#include "base/threading/thread_checker.h" |
#include "base/time/time.h" |
#include "content/common/media/media_stream_options.h" |
+#include "content/renderer/media/media_stream_audio_level_calculator.h" |
#include "content/renderer/media/tagged_list.h" |
#include "media/audio/audio_input_device.h" |
#include "media/base/audio_capturer_source.h" |
@@ -41,8 +44,7 @@ class WebRtcLocalAudioTrack; |
// thread or on the main render thread but also other client threads |
// if an alternative AudioCapturerSource has been set. |
class CONTENT_EXPORT WebRtcAudioCapturer |
- : public base::RefCountedThreadSafe<WebRtcAudioCapturer>, |
- NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) { |
+ : NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) { |
public: |
// Used to construct the audio capturer. |render_frame_id| specifies the |
// RenderFrame consuming audio for capture; -1 is used for tests. |
@@ -50,13 +52,15 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// created for. |constraints| contains the settings for audio processing. |
// TODO(xians): Implement the interface for the audio source and move the |
// |constraints| to ApplyConstraints(). Called on the main render thread. |
- static scoped_refptr<WebRtcAudioCapturer> CreateCapturer( |
+ static scoped_ptr<WebRtcAudioCapturer> CreateCapturer( |
int render_frame_id, |
const StreamDeviceInfo& device_info, |
const blink::WebMediaConstraints& constraints, |
WebRtcAudioDeviceImpl* audio_device, |
MediaStreamAudioSource* audio_source); |
+ ~WebRtcAudioCapturer() override; |
+ |
// Add a audio track to the sinks of the capturer. |
// WebRtcAudioDeviceImpl calls this method on the main render thread but |
// other clients may call it from other threads. The current implementation |
@@ -84,16 +88,9 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// Audio parameters utilized by the source of the audio capturer. |
// TODO(phoglund): Think over the implications of this accessor and if we can |
// remove it. |
- media::AudioParameters source_audio_parameters() const; |
+ media::AudioParameters GetInputFormat() const; |
- // Gets information about the paired output device. Returns true if such a |
- // device exists. |
- bool GetPairedOutputParameters(int* session_id, |
- int* output_sample_rate, |
- int* output_frames_per_buffer) const; |
- |
- const std::string& device_id() const { return device_info_.device.id; } |
- int session_id() const { return device_info_.session_id; } |
+ const StreamDeviceInfo& device_info() const { return device_info_; } |
// Stops recording audio. This method will empty its track lists since |
// stopping the capturer will implicitly invalidate all its tracks. |
@@ -110,10 +107,6 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
const scoped_refptr<media::AudioCapturerSource>& source, |
media::AudioParameters params); |
- protected: |
- friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; |
- ~WebRtcAudioCapturer() override; |
- |
private: |
class TrackOwner; |
typedef TaggedList<TrackOwner> TrackList; |
@@ -144,8 +137,7 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
void SetCapturerSourceInternal( |
const scoped_refptr<media::AudioCapturerSource>& source, |
media::ChannelLayout channel_layout, |
- int sample_rate, |
- int buffer_size); |
+ int sample_rate); |
// Starts recording audio. |
// Triggered by AddSink() on the main render thread or a Libjingle working |
@@ -176,7 +168,7 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// Audio processor doing processing like FIFO, AGC, AEC and NS. Its output |
// data is in a unit of 10 ms data chunk. |
- scoped_refptr<MediaStreamAudioProcessor> audio_processor_; |
+ const scoped_refptr<MediaStreamAudioProcessor> audio_processor_; |
bool running_; |
@@ -205,6 +197,13 @@ class CONTENT_EXPORT WebRtcAudioCapturer |
// WebRtcAudioCapturer. |
MediaStreamAudioSource* const audio_source_; |
+ // Used to calculate the signal level that shows in the UI. |
+ MediaStreamAudioLevelCalculator level_calculator_; |
+ |
+ // Provides weak pointers so that the stop callbacks given to |
+ // WebRtcLocalAudioTracks can be canceled once they are no longer necessary. |
+ base::WeakPtrFactory<WebRtcAudioCapturer> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); |
}; |