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

Unified Diff: content/renderer/media/user_media_client_impl.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/user_media_client_impl.cc
diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc
index 2a00d559372047f6810036b191ebbf88bd6eb9c0..469c6f287ab0a497aa31a2a473a32cd36c15b27a 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -20,14 +20,13 @@
#include "base/thread_task_runner_handle.h"
#include "content/public/renderer/render_frame.h"
#include "content/renderer/media/media_stream.h"
-#include "content/renderer/media/media_stream_audio_source.h"
#include "content/renderer/media/media_stream_constraints_util.h"
#include "content/renderer/media/media_stream_dispatcher.h"
#include "content/renderer/media/media_stream_video_capturer_source.h"
#include "content/renderer/media/media_stream_video_track.h"
#include "content/renderer/media/peer_connection_tracker.h"
+#include "content/renderer/media/webrtc/processed_local_audio_source.h"
#include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
-#include "content/renderer/media/webrtc_audio_capturer.h"
#include "content/renderer/media/webrtc_logging.h"
#include "content/renderer/media/webrtc_uma_histograms.h"
#include "content/renderer/render_thread_impl.h"
@@ -628,18 +627,28 @@ void UserMediaClientImpl::InitializeSourceObject(
weak_factory_.GetWeakPtr())));
} else {
DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, type);
- MediaStreamAudioSource* audio_source(
- new MediaStreamAudioSource(
- RenderFrameObserver::routing_id(),
- device,
- base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
- weak_factory_.GetWeakPtr()),
- dependency_factory_));
- webkit_source->setExtraData(audio_source);
+ MediaStreamAudioSource* const audio_source =
+ CreateAudioSource(device, constraints);
+ audio_source->SetStopCallback(
+ base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
+ weak_factory_.GetWeakPtr()));
+ webkit_source->setExtraData(audio_source); // Takes ownership.
}
local_sources_.push_back(*webkit_source);
}
+MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource(
+ const StreamDeviceInfo& device,
+ const blink::WebMediaConstraints& constraints) {
+ // TODO(miu): In a soon-upcoming change, I'll be providing an alternative
+ // MediaStreamAudioSource that bypasses audio processing for the non-WebRTC
+ // use cases. http://crbug.com/577881
+ ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource(
+ RenderFrameObserver::routing_id(), device, dependency_factory_);
+ source->SetSourceConstraints(constraints);
+ return source;
+}
+
MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource(
const StreamDeviceInfo& device,
const MediaStreamSource::SourceStoppedCallback& stop_callback) {
@@ -702,7 +711,7 @@ void UserMediaClientImpl::CreateAudioTracks(
constraints,
&webkit_source);
(*webkit_tracks)[i].initialize(webkit_source);
- request->StartAudioTrack((*webkit_tracks)[i], constraints);
+ request->StartAudioTrack((*webkit_tracks)[i]);
}
}
@@ -1083,8 +1092,7 @@ UserMediaClientImpl::UserMediaRequestInfo::~UserMediaRequestInfo() {
}
void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack(
- const blink::WebMediaStreamTrack& track,
- const blink::WebMediaConstraints& constraints) {
+ const blink::WebMediaStreamTrack& track) {
DCHECK(track.source().getType() == blink::WebMediaStreamSource::TypeAudio);
MediaStreamAudioSource* native_source =
MediaStreamAudioSource::From(track.source());
@@ -1092,10 +1100,10 @@ void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack(
sources_.push_back(track.source());
sources_waiting_for_callback_.push_back(native_source);
- native_source->AddTrack(
- track, constraints, base::Bind(
- &UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted,
- AsWeakPtr()));
+ if (native_source->ConnectToTrack(track))
+ OnTrackStarted(native_source, MEDIA_DEVICE_OK, "");
+ else
+ OnTrackStarted(native_source, MEDIA_DEVICE_TRACK_START_FAILURE, "");
}
blink::WebMediaStreamTrack
« no previous file with comments | « content/renderer/media/user_media_client_impl.h ('k') | content/renderer/media/user_media_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698