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

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

Issue 2219933003: Use LocalMediaStreamAudioSource for screen-casting use cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments on patch set 1 (mostly rewrote comments). Created 4 years, 4 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 cba0545d2d53e0df57e181bae55ae24a8f1e1ad0..126de5e7fe8a2e5b2a1324e42a7a05725ddd78a9 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -19,6 +19,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/renderer/render_frame.h"
+#include "content/renderer/media/local_media_stream_audio_source.h"
#include "content/renderer/media/media_stream.h"
#include "content/renderer/media/media_stream_constraints_util.h"
#include "content/renderer/media/media_stream_dispatcher.h"
@@ -640,9 +641,18 @@ void UserMediaClientImpl::InitializeSourceObject(
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
+ // If the audio device is a loopback device (for screen capture), or if the
+ // constraints/effects parameters indicate no audio processing is needed,
+ // create an efficient, direct-path MediaStreamAudioSource instance.
+ if (IsScreenCaptureMediaType(device.device.type) ||
+ !MediaStreamAudioProcessor::WouldModifyAudio(
+ constraints, device.device.input.effects)) {
+ return new LocalMediaStreamAudioSource(RenderFrameObserver::routing_id(),
+ device);
+ }
+
+ // The audio device is not associated with screen capture and also requires
+ // processing.
ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource(
RenderFrameObserver::routing_id(), device, dependency_factory_);
source->SetSourceConstraints(constraints);

Powered by Google App Engine
This is Rietveld 408576698