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

Unified Diff: content/renderer/media/media_stream_center.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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_center.cc
diff --git a/content/renderer/media/media_stream_center.cc b/content/renderer/media/media_stream_center.cc
index 2f84bd8eb2be103006c91c73cc75aaf3952521a6..c08fcb56f27cb38f2c91b8a967353affc07b5104 100644
--- a/content/renderer/media/media_stream_center.cc
+++ b/content/renderer/media/media_stream_center.cc
@@ -19,7 +19,7 @@
#include "content/renderer/media/media_stream_source.h"
#include "content/renderer/media/media_stream_video_source.h"
#include "content/renderer/media/media_stream_video_track.h"
-#include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
+#include "content/renderer/media/webaudio_media_stream_source.h"
#include "content/renderer/media/webrtc_local_audio_source_provider.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebMediaStream.h"
@@ -39,16 +39,28 @@ namespace content {
namespace {
void CreateNativeAudioMediaStreamTrack(
- const blink::WebMediaStreamTrack& track,
- PeerConnectionDependencyFactory* factory) {
- DCHECK(!MediaStreamAudioTrack::From(track));
+ const blink::WebMediaStreamTrack& track) {
blink::WebMediaStreamSource source = track.source();
- DCHECK_EQ(source.getType(), blink::WebMediaStreamSource::TypeAudio);
- if (source.remote()) {
- factory->CreateRemoteAudioTrack(track);
- } else {
- factory->CreateLocalAudioTrack(track);
+ MediaStreamAudioSource* media_stream_source =
+ MediaStreamAudioSource::From(source);
+
+ // At this point, a MediaStreamAudioSource instance must exist. The one
+ // exception is when a WebAudio destination node is acting as a source of
+ // audio.
+ //
+ // TODO(miu): This needs to be moved to an appropriate location. A WebAudio
+ // source should have been created before this method was called so that this
+ // special case code isn't needed here.
+ if (!media_stream_source && source.requiresAudioConsumer()) {
+ DVLOG(1) << "Creating WebAudio media stream source.";
+ media_stream_source = new WebAudioMediaStreamSource(&source);
+ source.setExtraData(media_stream_source); // Takes ownership.
}
+
+ if (media_stream_source)
+ media_stream_source->ConnectToTrack(track);
+ else
+ LOG(DFATAL) << "WebMediaStreamSource missing its MediaStreamAudioSource.";
}
void CreateNativeVideoMediaStreamTrack(
@@ -74,14 +86,23 @@ void CreateNativeVideoMediaStreamTrack(
track.isEnabled()));
}
-void CreateNativeMediaStreamTrack(const blink::WebMediaStreamTrack& track,
- PeerConnectionDependencyFactory* factory) {
+} // namespace
+
+MediaStreamCenter::MediaStreamCenter(
+ blink::WebMediaStreamCenterClient* client,
+ PeerConnectionDependencyFactory* factory) {}
+
+MediaStreamCenter::~MediaStreamCenter() {}
+
+void MediaStreamCenter::didCreateMediaStreamTrack(
+ const blink::WebMediaStreamTrack& track) {
+ DVLOG(1) << "MediaStreamCenter::didCreateMediaStreamTrack";
DCHECK(!track.isNull() && !track.getExtraData());
DCHECK(!track.source().isNull());
switch (track.source().getType()) {
case blink::WebMediaStreamSource::TypeAudio:
- CreateNativeAudioMediaStreamTrack(track, factory);
+ CreateNativeAudioMediaStreamTrack(track);
break;
case blink::WebMediaStreamSource::TypeVideo:
CreateNativeVideoMediaStreamTrack(track);
@@ -89,20 +110,6 @@ void CreateNativeMediaStreamTrack(const blink::WebMediaStreamTrack& track,
}
}
-} // namespace
-
-MediaStreamCenter::MediaStreamCenter(blink::WebMediaStreamCenterClient* client,
- PeerConnectionDependencyFactory* factory)
- : rtc_factory_(factory) {}
-
-MediaStreamCenter::~MediaStreamCenter() {}
-
-void MediaStreamCenter::didCreateMediaStreamTrack(
- const blink::WebMediaStreamTrack& track) {
- DVLOG(1) << "MediaStreamCenter::didCreateMediaStreamTrack";
- CreateNativeMediaStreamTrack(track, rtc_factory_);
-}
-
void MediaStreamCenter::didEnableMediaStreamTrack(
const blink::WebMediaStreamTrack& track) {
MediaStreamTrack* native_track =
@@ -142,7 +149,8 @@ MediaStreamCenter::createWebAudioSourceFromMediaStreamTrack(
DCHECK_EQ(source.getType(), blink::WebMediaStreamSource::TypeAudio);
// TODO(tommi): Rename WebRtcLocalAudioSourceProvider to
- // WebRtcAudioSourceProvider since it's not specific to local.
+ // WebAudioMediaStreamSink since it's not specific to any particular source.
+ // http://crbug.com/577874
return new WebRtcLocalAudioSourceProvider(track);
}
« no previous file with comments | « content/renderer/media/media_stream_center.h ('k') | content/renderer/media/media_stream_renderer_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698