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

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

Issue 1780653002: Revert of MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 d3d28d5143f22223ff9f1e706bfd805a5b47afbb..2eafbd160ee49b95cd42709946e504e082d094da 100644
--- a/content/renderer/media/webrtc_local_audio_track.h
+++ b/content/renderer/media/webrtc_local_audio_track.h
@@ -10,11 +10,11 @@
#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_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 {
@@ -28,14 +28,22 @@
class MediaStreamAudioSink;
class MediaStreamAudioSinkOwner;
class MediaStreamAudioTrackSink;
+class WebAudioCapturerSource;
+class WebRtcAudioCapturer;
+class WebRtcLocalAudioTrackAdapter;
-// A WebRtcLocalAudioTrack manages thread-safe connects/disconnects to sinks,
-// and the delivery of audio data from the source to the sinks.
+// 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.
class CONTENT_EXPORT WebRtcLocalAudioTrack
: NON_EXPORTED_BASE(public MediaStreamAudioTrack) {
public:
- explicit WebRtcLocalAudioTrack(
- scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter);
+ WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter,
+ const scoped_refptr<WebRtcAudioCapturer>& capturer,
+ WebAudioCapturerSource* webaudio_source);
~WebRtcLocalAudioTrack() override;
@@ -48,38 +56,55 @@
// 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);
+ base::TimeTicks estimated_capture_time,
+ bool force_report_nonzero_energy);
// 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);
- // 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);
-
- // 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(scoped_refptr<MediaStreamAudioProcessor> processor);
+ // 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.
+ void SetAudioProcessor(
+ const scoped_refptr<MediaStreamAudioProcessor>& 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
@@ -96,7 +121,12 @@
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