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

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

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests broken by recent MSAudioTrack::Stop() reworking. Created 4 years, 10 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_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..b0c26237866318fe0546578886ee60ecde991805 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.
+
+// 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,44 @@ 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;
+ // MediaStreamAudioTrack override.
+ void OnStop() final;
+
// 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 +101,8 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
mutable base::Lock lock_;
// 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);
};

Powered by Google App Engine
This is Rietveld 408576698