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

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

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE 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/media_stream_audio_source.h
diff --git a/content/renderer/media/media_stream_audio_source.h b/content/renderer/media/media_stream_audio_source.h
index b2f44d2b44d3e582cdbae3da775cff0b292716b8..6d7da5ccf003b6b1c54accf24d9c2d857f8a32de 100644
--- a/content/renderer/media/media_stream_audio_source.h
+++ b/content/renderer/media/media_stream_audio_source.h
@@ -7,14 +7,23 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/renderer/media/media_stream_source.h"
+#include "content/renderer/media/webaudio_capturer_source.h"
#include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
#include "content/renderer/media/webrtc_audio_capturer.h"
#include "third_party/webrtc/api/mediastreaminterface.h"
namespace content {
+class MediaStreamAudioTrack;
+
+// TODO(miu): In a soon-upcoming set of refactoring changes, this class will
+// become a base class for managing tracks (part of what WebRtcAudioCapturer
+// does today). Then, the rest of WebRtcAudioCapturer will be rolled into a
+// subclass. http://crbug.com/577874
class CONTENT_EXPORT MediaStreamAudioSource
: NON_EXPORTED_BASE(public MediaStreamSource) {
public:
@@ -25,27 +34,46 @@ class CONTENT_EXPORT MediaStreamAudioSource
MediaStreamAudioSource();
~MediaStreamAudioSource() override;
+ // Returns the MediaStreamAudioSource instance owned by the given blink
+ // |source| or null.
+ static MediaStreamAudioSource* From(const blink::WebMediaStreamSource& track);
+
void AddTrack(const blink::WebMediaStreamTrack& track,
const blink::WebMediaConstraints& constraints,
const ConstraintsCallback& callback);
- void SetLocalAudioSource(webrtc::AudioSourceInterface* source) {
- local_audio_source_ = source;
+ base::WeakPtr<MediaStreamAudioSource> GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
}
- void SetAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer) {
- DCHECK(!audio_capturer_.get());
- audio_capturer_ = capturer;
- }
+ // Removes |track| from the list of instances that get a copy of the source
+ // audio data.
+ void StopAudioDeliveryTo(MediaStreamAudioTrack* track);
- const scoped_refptr<WebRtcAudioCapturer>& GetAudioCapturer() {
- return audio_capturer_;
+ WebRtcAudioCapturer* audio_capturer() const { return audio_capturer_.get(); }
+
+ void SetAudioCapturer(scoped_ptr<WebRtcAudioCapturer> capturer) {
+ DCHECK(!audio_capturer_.get());
+ audio_capturer_ = std::move(capturer);
}
webrtc::AudioSourceInterface* local_audio_source() {
return local_audio_source_.get();
}
+ void SetLocalAudioSource(scoped_refptr<webrtc::AudioSourceInterface> source) {
+ local_audio_source_ = std::move(source);
+ }
+
+ WebAudioCapturerSource* webaudio_capturer() const {
+ return webaudio_capturer_.get();
+ }
+
+ void SetWebAudioCapturer(scoped_ptr<WebAudioCapturerSource> capturer) {
+ DCHECK(!webaudio_capturer_.get());
+ webaudio_capturer_ = std::move(capturer);
+ }
+
protected:
void DoStopSource() override;
@@ -53,11 +81,22 @@ class CONTENT_EXPORT MediaStreamAudioSource
const int render_frame_id_;
PeerConnectionDependencyFactory* const factory_;
+ // MediaStreamAudioSource is the owner of either a WebRtcAudioCapturer or a
+ // WebAudioCapturerSource.
+ //
+ // TODO(miu): In a series of soon-upcoming changes, WebRtcAudioCapturer and
+ // WebAudioCapturerSource will become subclasses of MediaStreamAudioSource
+ // instead.
+ scoped_ptr<WebRtcAudioCapturer> audio_capturer_;
+ scoped_ptr<WebAudioCapturerSource> webaudio_capturer_;
+
// This member holds an instance of webrtc::LocalAudioSource. This is used
// as a container for audio options.
scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_;
- scoped_refptr<WebRtcAudioCapturer> audio_capturer_;
+ // Provides weak pointers so that MediaStreamAudioTracks won't call
+ // StopAudioDeliveryTo() if this instance dies first.
+ base::WeakPtrFactory<MediaStreamAudioSource> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource);
};
« no previous file with comments | « content/renderer/media/media_stream_audio_level_calculator.cc ('k') | content/renderer/media/media_stream_audio_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698