Chromium Code Reviews| Index: content/renderer/media/webrtc_local_audio_track.h |
| diff --git a/content/renderer/media/webrtc_local_audio_track.h b/content/renderer/media/webrtc_local_audio_track.h |
| index 2eafbd160ee49b95cd42709946e504e082d094da..37b52819c22d51ba914bae730b1bf1ec94144d33 100644 |
| --- a/content/renderer/media/webrtc_local_audio_track.h |
| +++ b/content/renderer/media/webrtc_local_audio_track.h |
| @@ -10,11 +10,12 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/memory/scoped_ptr.h" |
| #include "base/synchronization/lock.h" |
| #include "base/threading/thread_checker.h" |
| +#include "content/renderer/media/media_stream_audio_level_calculator.h" |
| #include "content/renderer/media/media_stream_audio_track.h" |
| #include "content/renderer/media/tagged_list.h" |
| +#include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| #include "media/audio/audio_parameters.h" |
| namespace media { |
| @@ -23,27 +24,18 @@ class AudioBus; |
| namespace content { |
| -class MediaStreamAudioLevelCalculator; |
| class MediaStreamAudioProcessor; |
| class MediaStreamAudioSink; |
| class MediaStreamAudioSinkOwner; |
| class MediaStreamAudioTrackSink; |
| -class WebAudioCapturerSource; |
| -class WebRtcAudioCapturer; |
| -class WebRtcLocalAudioTrackAdapter; |
| - |
| -// A WebRtcLocalAudioTrack instance contains the implementations of |
| -// MediaStreamTrackExtraData. |
| -// When an instance is created, it will register itself as a track to the |
| -// WebRtcAudioCapturer to get the captured data, and forward the data to |
| -// its |sinks_|. The data flow can be stopped by disabling the audio track. |
| -// TODO(tommi): Rename to MediaStreamLocalAudioTrack. |
|
o1ka
2016/02/29 14:28:05
Can we indeed make MediaStreamLocalAudioTrack and
miu
2016/03/01 09:43:55
I'll be addressing this is my next CL. (BTW, for
o1ka
2016/03/01 14:18:59
Acknowledged.
|
| + |
| +// A WebRtcLocalAudioTrack manages thread-safe connects/disconnects to sinks, |
| +// and the delivery of audio data from the source to the sinks. |
| class CONTENT_EXPORT WebRtcLocalAudioTrack |
| : NON_EXPORTED_BASE(public MediaStreamAudioTrack) { |
| public: |
| - WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter, |
| - const scoped_refptr<WebRtcAudioCapturer>& capturer, |
| - WebAudioCapturerSource* webaudio_source); |
| + explicit WebRtcLocalAudioTrack( |
| + scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter); |
| ~WebRtcLocalAudioTrack() override; |
| @@ -56,56 +48,45 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack |
| // Called on the main render thread. |
| void RemoveSink(MediaStreamAudioSink* sink) override; |
| - // Starts the local audio track. Called on the main render thread and |
| - // should be called only once when audio track is created. |
| - void Start(); |
| - |
| // Overrides for MediaStreamTrack. |
| - |
| void SetEnabled(bool enabled) override; |
| - |
| - // Stops the local audio track. Called on the main render thread and |
| - // should be called only once when audio track going away. |
| - void Stop() override; |
| - |
| webrtc::AudioTrackInterface* GetAudioAdapter() override; |
| - |
| - // Returns the output format of the capture source. May return an invalid |
| - // AudioParameters if the format is not yet available. |
| - // Called on the main render thread. |
| media::AudioParameters GetOutputFormat() const override; |
| // Method called by the capturer to deliver the capture data. |
| // Called on the capture audio thread. |
| void Capture(const media::AudioBus& audio_bus, |
| - base::TimeTicks estimated_capture_time, |
| - bool force_report_nonzero_energy); |
| + base::TimeTicks estimated_capture_time); |
| // Method called by the capturer to set the audio parameters used by source |
| // of the capture data.. |
| // Called on the capture audio thread. |
| void OnSetFormat(const media::AudioParameters& params); |
| - // Method called by the capturer to set the processor that applies signal |
| - // processing on the data of the track. |
| - // Called on the capture audio thread. |
| + // Called by the capturer before the audio data flow begins to set the object |
| + // that provides shared access to the current audio signal level. |
| + void SetLevel(scoped_refptr<MediaStreamAudioLevelCalculator::Level> level) { |
| + adapter_->SetLevel(level); |
| + } |
| + |
| + // Called by the capturer before the audio data flow begins to provide a |
| + // reference to the audio processor so that the track can query stats from it. |
| void SetAudioProcessor( |
| - const scoped_refptr<MediaStreamAudioProcessor>& processor); |
| + const scoped_refptr<MediaStreamAudioProcessor>& processor) { |
| + adapter_->SetAudioProcessor(processor); |
| + } |
| private: |
| typedef TaggedList<MediaStreamAudioTrackSink> SinkList; |
| + // Called when this MediaStreamAudioTrack is stopped to notify all sinks the |
| + // stream has ended, and to remove all references to the sinks. |
| + void RemoveAllSinks(); |
| + |
| // All usage of libjingle is through this adapter. The adapter holds |
| // a pointer to this object, but no reference. |
| const scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_; |
| - // The provider of captured data to render. |
| - scoped_refptr<WebRtcAudioCapturer> capturer_; |
| - |
| - // The source of the audio track which is used by WebAudio, which provides |
| - // data to the audio track when hooking up with WebAudio. |
| - scoped_refptr<WebAudioCapturerSource> webaudio_source_; |
| - |
| // A tagged list of sinks that the audio data is fed to. Tags |
| // indicate tracks that need to be notified that the audio format |
| // has changed. |
| @@ -121,13 +102,8 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack |
| mutable base::Lock lock_; |
|
o1ka
2016/02/29 14:28:05
I know it's not your change and probably I am para
miu
2016/03/01 09:43:55
Totally agree. But, this is yet another thing tha
o1ka
2016/03/01 14:18:59
Acknowledged.
|
| // Audio parameters of the audio capture stream. |
| - // Accessed on only the audio capture thread. |
| media::AudioParameters audio_parameters_; |
| - // Used to calculate the signal level that shows in the UI. |
| - // Accessed on only the audio thread. |
| - scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); |
| }; |