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

Unified Diff: content/renderer/media/webrtc/processed_local_audio_track.h

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from PS2: AudioInputDevice --> AudioCapturerSource, and refptr foo in WebRtcMedi… 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/processed_local_audio_track.h
diff --git a/content/renderer/media/webrtc_local_audio_track.h b/content/renderer/media/webrtc/processed_local_audio_track.h
similarity index 31%
rename from content/renderer/media/webrtc_local_audio_track.h
rename to content/renderer/media/webrtc/processed_local_audio_track.h
index d3d28d5143f22223ff9f1e706bfd805a5b47afbb..66e28be627c60d9557764f5ab38e73f04e70813c 100644
--- a/content/renderer/media/webrtc_local_audio_track.h
+++ b/content/renderer/media/webrtc/processed_local_audio_track.h
@@ -2,66 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_
-#define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_
-
-#include <list>
-#include <string>
+#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_TRACK_H_
+#define CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_TRACK_H_
#include "base/macros.h"
#include "base/memory/ref_counted.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_processor.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 {
-class AudioBus;
-}
namespace content {
-class MediaStreamAudioLevelCalculator;
-class MediaStreamAudioProcessor;
-class MediaStreamAudioSink;
-class MediaStreamAudioSinkOwner;
-class MediaStreamAudioTrackSink;
+class WebRtcLocalAudioTrackAdapter;
-// 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
+// A MediaStreamAudioTrack that also holds a WebRtcLocalAudioTrackAdapter and
+// provides an "adapter" bridge between the media stream object graph in the
+// content namespace and the separate object graph in the webrtc namespace.
+//
+// This class is instantiated by ProcessLocalAudioSource.
+class CONTENT_EXPORT ProcessedLocalAudioTrack final
: NON_EXPORTED_BASE(public MediaStreamAudioTrack) {
public:
- explicit WebRtcLocalAudioTrack(
+ explicit ProcessedLocalAudioTrack(
scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter);
- ~WebRtcLocalAudioTrack() override;
-
- // Add a sink to the track. This function will trigger a OnSetFormat()
- // call on the |sink|.
- // Called on the main render thread.
- void AddSink(MediaStreamAudioSink* sink) override;
+ ~ProcessedLocalAudioTrack() final;
- // Remove a sink from the track.
- // Called on the main render thread.
- void RemoveSink(MediaStreamAudioSink* sink) override;
+ // If |track| is an instance of ProcessedLocalAudioTrack, return a type-casted
+ // pointer to it. Otherwise, return null.
+ static ProcessedLocalAudioTrack* From(MediaStreamAudioTrack* track);
- // Overrides for MediaStreamTrack.
- void SetEnabled(bool enabled) override;
- webrtc::AudioTrackInterface* GetAudioAdapter() override;
- media::AudioParameters GetOutputFormat() const override;
+ const scoped_refptr<WebRtcLocalAudioTrackAdapter>& adapter() const {
perkj_chrome 2016/04/08 14:05:42 Why isn't WebRtcLocalAudioTrackAdapter just a sink
miu 2016/04/19 00:40:22 It is now! :) As of Patch Set 4, WebRtcAudioSink
+ return adapter_;
+ }
- // 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);
-
- // 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);
+ // Override for MediaStreamTrack.
+ void SetEnabled(bool enabled) final;
// Called by the capturer before the audio data flow begins to set the object
// that provides shared access to the current audio signal level.
@@ -72,35 +48,20 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
void SetAudioProcessor(scoped_refptr<MediaStreamAudioProcessor> processor);
private:
- typedef TaggedList<MediaStreamAudioTrackSink> SinkList;
-
// MediaStreamAudioTrack override.
- void OnStop() final;
+ void* GetClassIdentifier() const 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_;
- // 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.
- SinkList sinks_;
-
- // Tests that methods are called on libjingle's signaling thread.
- base::ThreadChecker signal_thread_checker_;
-
- // Used to DCHECK that some methods are called on the capture audio thread.
- base::ThreadChecker capture_thread_checker_;
-
- // Protects |params_| and |sinks_|.
- mutable base::Lock lock_;
-
- // Audio parameters of the audio capture stream.
- media::AudioParameters audio_parameters_;
+ // In debug builds, check that all methods that could cause object graph
+ // or data flow changes are being called on the main thread.
+ base::ThreadChecker thread_checker_;
- DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack);
+ DISALLOW_COPY_AND_ASSIGN(ProcessedLocalAudioTrack);
};
} // namespace content
-#endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_
+#endif // CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_TRACK_H_

Powered by Google App Engine
This is Rietveld 408576698