diff options
author | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-07 21:02:31 +0000 |
---|---|---|
committer | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-07 21:02:31 +0000 |
commit | 2a76009bf5861d0d9a0a6de9f98e041cc9c4b7a5 (patch) | |
tree | 16c014caab0c69982164ae371994796f22746381 | |
parent | b70403fc1eb901266182d2f40b57849b60fe6716 (diff) | |
download | chromium_src-2a76009bf5861d0d9a0a6de9f98e041cc9c4b7a5.zip chromium_src-2a76009bf5861d0d9a0a6de9f98e041cc9c4b7a5.tar.gz chromium_src-2a76009bf5861d0d9a0a6de9f98e041cc9c4b7a5.tar.bz2 |
Properly set loopback device ID for system audio capture.
Make sure the MediaStreamDevice has the correct loopback device ID for system
audio capture in MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest.
Remove the hack in audio_input_renderer_host to override the loopback device ID.
BUG=269626
TBR=dalecurtis@chromium.org, xians@chromium.org
TEST=passes trybots, local testing on Chrome OS confirms device ID is passed to WebRtcLocalAudioTrack ctor.
Review URL: https://codereview.chromium.org/22408006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216271 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/common.gypi | 10 | ||||
-rw-r--r-- | chrome/browser/media/media_capture_devices_dispatcher.cc | 36 | ||||
-rw-r--r-- | content/browser/renderer_host/media/audio_input_renderer_host.cc | 17 | ||||
-rw-r--r-- | content/content_browser.gypi | 8 |
4 files changed, 39 insertions, 32 deletions
diff --git a/build/common.gypi b/build/common.gypi index 29f1278..4b36fdf 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -27,6 +27,9 @@ # Whether or not we are building the Ash shell. 'use_ash%': 0, + # Whether or not we are using CRAS, the ChromeOS Audio Server. + 'use_cras%': 0, + # Use a raw surface abstraction. 'use_ozone%': 0, }, @@ -34,6 +37,7 @@ 'chromeos%': '<(chromeos)', 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', + 'use_cras%': '<(use_cras)', 'use_ozone%': '<(use_ozone)', # Whether we are using Views Toolkit @@ -98,6 +102,7 @@ 'chromeos%': '<(chromeos)', 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', + 'use_cras%': '<(use_cras)', 'use_ozone%': '<(use_ozone)', 'use_openssl%': '<(use_openssl)', 'enable_viewport%': '<(enable_viewport)', @@ -179,6 +184,7 @@ 'toolkit_uses_gtk%': '<(toolkit_uses_gtk)', 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', + 'use_cras%': '<(use_cras)', 'use_ozone%': '<(use_ozone)', 'use_openssl%': '<(use_openssl)', 'enable_viewport%': '<(enable_viewport)', @@ -755,6 +761,7 @@ 'ui_compositor_image_transport%': '<(ui_compositor_image_transport)', 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', + 'use_cras%': '<(use_cras)', 'use_openssl%': '<(use_openssl)', 'use_nss%': '<(use_nss)', 'os_bsd%': '<(os_bsd)', @@ -1928,6 +1935,9 @@ ['use_ash==1', { 'defines': ['USE_ASH=1'], }], + ['use_cras==1', { + 'defines': ['USE_CRAS=1'], + }], ['use_ozone==1', { 'defines': ['USE_OZONE=1'], }], diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc index bbef40f..03ca4c5 100644 --- a/chrome/browser/media/media_capture_devices_dispatcher.cc +++ b/chrome/browser/media/media_capture_devices_dispatcher.cc @@ -35,6 +35,10 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#if defined(USE_CRAS) +#include "media/audio/cras/audio_manager_cras.h" +#endif + using content::BrowserThread; using content::MediaStreamDevices; @@ -193,22 +197,34 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest( const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback, const extensions::Extension* extension) { - bool component_extension = + const bool component_extension = extension && extension->location() == extensions::Manifest::COMPONENT; content::MediaStreamDevices devices; - bool screen_capture_enabled = + const bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableUserMediaScreenCapturing) || IsOriginWhitelistedForScreenCapture(request.security_origin); - bool origin_is_secure = + const bool origin_is_secure = request.security_origin.SchemeIsSecure() || request.security_origin.SchemeIs(extensions::kExtensionScheme) || CommandLine::ForCurrentProcess()->HasSwitch( switches::kAllowHttpScreenCapture); + const bool screen_video_capture_requested = + request.video_type == content::MEDIA_SCREEN_VIDEO_CAPTURE; + + const bool system_audio_capture_requested = + request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE; + +#if defined(USE_CRAS) + const bool system_audio_capture_supported = true; +#else + const bool system_audio_capture_supported = false; +#endif + // Approve request only when the following conditions are met: // 1. Screen capturing is enabled via command line switch or white-listed for // the given origin. @@ -216,9 +232,8 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest( // 3. Video capture is requested for screen video. // 4. Audio capture is either not requested, or requested for system audio. if (screen_capture_enabled && origin_is_secure && - request.video_type == content::MEDIA_SCREEN_VIDEO_CAPTURE && - (request.audio_type == content::MEDIA_NO_SERVICE || - request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE)) { + screen_video_capture_requested && + (!system_audio_capture_requested || system_audio_capture_supported)) { // For component extensions, bypass message box. bool user_approved = false; if (!component_extension) { @@ -240,9 +255,14 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest( if (user_approved || component_extension) { devices.push_back(content::MediaStreamDevice( content::MEDIA_SCREEN_VIDEO_CAPTURE, std::string(), "Screen")); - if (request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { + if (system_audio_capture_requested) { +#if defined(USE_CRAS) + // Use the special loopback device ID for system audio capture. devices.push_back(content::MediaStreamDevice( - content::MEDIA_SYSTEM_AUDIO_CAPTURE, std::string(), std::string())); + content::MEDIA_SYSTEM_AUDIO_CAPTURE, + media::AudioManagerCras::kLoopbackDeviceId, + "System Audio")); +#endif } } } diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc index 37d93ef..4a2f731 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc @@ -15,10 +15,6 @@ #include "content/browser/renderer_host/media/web_contents_capture_util.h" #include "media/audio/audio_manager_base.h" -#if defined(USE_CRAS) -#include "media/audio/cras/audio_manager_cras.h" -#endif - namespace content { struct AudioInputRendererHost::AudioEntry { @@ -241,18 +237,7 @@ void AudioInputRendererHost::OnCreateStream( return; } - if (info->device.type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { -#if defined(USE_CRAS) - // Use the special loopback device ID for system audio capture. - device_id = media::AudioManagerCras::kLoopbackDeviceId; -#else - SendErrorMessage(stream_id); - DLOG(WARNING) << "Loopback device is not supported on this platform"; - return; -#endif - } else { - device_id = info->device.id; - } + device_id = info->device.id; } // Create a new AudioEntry structure. diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 5644323..3f12bd7 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -3,9 +3,6 @@ # found in the LICENSE file. { - 'variables': { - 'use_cras%': 0, - }, 'dependencies': [ 'browser/speech/proto/speech_proto.gyp:speech_proto', '../base/base.gyp:base_static', @@ -1373,11 +1370,6 @@ '../build/linux/system.gyp:x11', ], }], - ['use_cras==1', { - 'defines': [ - 'USE_CRAS', - ], - }], ['use_pango==1', { 'dependencies': [ '../build/linux/system.gyp:pangocairo', |