OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const base::string16& registered_extension_name) { | 164 const base::string16& registered_extension_name) { |
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
166 scoped_ptr<content::MediaStreamUI> ui; | 166 scoped_ptr<content::MediaStreamUI> ui; |
167 | 167 |
168 // Add selected desktop source to the list. | 168 // Add selected desktop source to the list. |
169 devices->push_back(content::MediaStreamDevice( | 169 devices->push_back(content::MediaStreamDevice( |
170 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); | 170 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); |
171 if (capture_audio) { | 171 if (capture_audio) { |
172 // Use the special loopback device ID for system audio capture. | 172 // Use the special loopback device ID for system audio capture. |
173 devices->push_back(content::MediaStreamDevice( | 173 devices->push_back(content::MediaStreamDevice( |
174 content::MEDIA_LOOPBACK_AUDIO_CAPTURE, | 174 content::MEDIA_DESKTOP_AUDIO_CAPTURE, |
175 media::AudioManagerBase::kLoopbackInputDeviceId, "System Audio")); | 175 media::AudioManagerBase::kLoopbackInputDeviceId, "System Audio")); |
176 } | 176 } |
177 | 177 |
178 // If required, register to display the notification for stream capture. | 178 // If required, register to display the notification for stream capture. |
179 if (display_notification) { | 179 if (display_notification) { |
180 if (application_title == registered_extension_name) { | 180 if (application_title == registered_extension_name) { |
181 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16( | 181 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16( |
182 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT, | 182 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT, |
183 application_title)); | 183 application_title)); |
184 } else { | 184 } else { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 | 322 |
323 void MediaCaptureDevicesDispatcher::ProcessMediaAccessRequest( | 323 void MediaCaptureDevicesDispatcher::ProcessMediaAccessRequest( |
324 content::WebContents* web_contents, | 324 content::WebContents* web_contents, |
325 const content::MediaStreamRequest& request, | 325 const content::MediaStreamRequest& request, |
326 const content::MediaResponseCallback& callback, | 326 const content::MediaResponseCallback& callback, |
327 const extensions::Extension* extension) { | 327 const extensions::Extension* extension) { |
328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
329 | 329 |
330 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || | 330 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || |
331 request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE) { | 331 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE) { |
332 ProcessDesktopCaptureAccessRequest( | 332 ProcessDesktopCaptureAccessRequest( |
333 web_contents, request, callback, extension); | 333 web_contents, request, callback, extension); |
334 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || | 334 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || |
335 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { | 335 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { |
336 ProcessTabCaptureAccessRequest( | 336 ProcessTabCaptureAccessRequest( |
337 web_contents, request, callback, extension); | 337 web_contents, request, callback, extension); |
338 } else { | 338 } else { |
339 #if defined(ENABLE_EXTENSIONS) | 339 #if defined(ENABLE_EXTENSIONS) |
340 bool is_whitelisted = | 340 bool is_whitelisted = |
341 extension && (extension->is_platform_app() || | 341 extension && (extension->is_platform_app() || |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 517 |
518 bool loopback_audio_supported = false; | 518 bool loopback_audio_supported = false; |
519 #if defined(USE_CRAS) || defined(OS_WIN) | 519 #if defined(USE_CRAS) || defined(OS_WIN) |
520 // Currently loopback audio capture is supported only on Windows and ChromeOS. | 520 // Currently loopback audio capture is supported only on Windows and ChromeOS. |
521 loopback_audio_supported = true; | 521 loopback_audio_supported = true; |
522 #endif | 522 #endif |
523 | 523 |
524 // Audio is only supported for screen capture streams. | 524 // Audio is only supported for screen capture streams. |
525 bool capture_audio = | 525 bool capture_audio = |
526 (media_id.type == content::DesktopMediaID::TYPE_SCREEN && | 526 (media_id.type == content::DesktopMediaID::TYPE_SCREEN && |
527 request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE && | 527 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && |
528 loopback_audio_supported); | 528 loopback_audio_supported); |
529 | 529 |
530 ui = GetDevicesForDesktopCapture( | 530 ui = GetDevicesForDesktopCapture( |
531 &devices, media_id, capture_audio, true, | 531 &devices, media_id, capture_audio, true, |
532 GetApplicationTitle(web_contents, extension), | 532 GetApplicationTitle(web_contents, extension), |
533 base::UTF8ToUTF16(original_extension_name)); | 533 base::UTF8ToUTF16(original_extension_name)); |
534 | 534 |
535 callback.Run(devices, content::MEDIA_DEVICE_OK, ui.Pass()); | 535 callback.Run(devices, content::MEDIA_DEVICE_OK, ui.Pass()); |
536 } | 536 } |
537 | 537 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 #if defined(OS_CHROMEOS) | 627 #if defined(OS_CHROMEOS) |
628 screen_id = content::DesktopMediaID::RegisterAuraWindow( | 628 screen_id = content::DesktopMediaID::RegisterAuraWindow( |
629 ash::Shell::GetInstance()->GetPrimaryRootWindow()); | 629 ash::Shell::GetInstance()->GetPrimaryRootWindow()); |
630 #else // defined(OS_CHROMEOS) | 630 #else // defined(OS_CHROMEOS) |
631 screen_id = | 631 screen_id = |
632 content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, | 632 content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, |
633 webrtc::kFullDesktopScreenId); | 633 webrtc::kFullDesktopScreenId); |
634 #endif // !defined(OS_CHROMEOS) | 634 #endif // !defined(OS_CHROMEOS) |
635 | 635 |
636 bool capture_audio = | 636 bool capture_audio = |
637 (request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE && | 637 (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && |
638 loopback_audio_supported); | 638 loopback_audio_supported); |
639 | 639 |
640 // Unless we're being invoked from a component extension, register to | 640 // Unless we're being invoked from a component extension, register to |
641 // display the notification for stream capture. | 641 // display the notification for stream capture. |
642 bool display_notification = !component_extension; | 642 bool display_notification = !component_extension; |
643 | 643 |
644 ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio, | 644 ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio, |
645 display_notification, application_title, | 645 display_notification, application_title, |
646 application_title); | 646 application_title); |
647 DCHECK(!devices.empty()); | 647 DCHECK(!devices.empty()); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1105 |
1106 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1106 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
1107 const MediaStreamDevices& devices) { | 1107 const MediaStreamDevices& devices) { |
1108 test_audio_devices_ = devices; | 1108 test_audio_devices_ = devices; |
1109 } | 1109 } |
1110 | 1110 |
1111 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1111 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
1112 const MediaStreamDevices& devices) { | 1112 const MediaStreamDevices& devices) { |
1113 test_video_devices_ = devices; | 1113 test_video_devices_ = devices; |
1114 } | 1114 } |
OLD | NEW |