From bf194225d67dde6571680e557554866357ec9210 Mon Sep 17 00:00:00 2001 From: "jiayl@chromium.org" Date: Tue, 28 Jan 2014 20:29:12 +0000 Subject: Enables screen cast for individual monitors. BUG=https://code.google.com/p/webrtc/issues/detail?id=2787 Review URL: https://codereview.chromium.org/135733007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247492 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 23 ++++++++++++--------- chrome/browser/media/native_desktop_media_list.cc | 24 ++++++++++++++++++---- .../media/native_desktop_media_list_unittest.cc | 8 ++++++-- .../renderer_host/media/desktop_capture_device.cc | 7 +++---- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 3c53c11..92b9465 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -10454,7 +10454,7 @@ Would you like to start $1Add/Remove Pr Merchants often need this in case there are problems shipping your order. - + @@ -10479,7 +10479,7 @@ Would you like to start $1Add/Remove Pr Google Wallet - + Protect my payment with Google Wallet. @@ -10511,7 +10511,7 @@ Would you like to start $1Add/Remove Pr More information is needed to complete this purchase. - + Loading payment details @@ -10522,7 +10522,7 @@ Would you like to start $1Add/Remove Pr Your Virtual Card is ready. - + There's something wrong with your Google Wallet account. @@ -10545,7 +10545,7 @@ Would you like to start $1Add/Remove Pr Error code: $154 - + Edit @@ -10571,7 +10571,7 @@ Would you like to start $1Add/Remove Pr Verify - + New credit card... @@ -10600,7 +10600,7 @@ Would you like to start $1Add/Remove Pr Use billing address for shipping - + By clicking Continue you agree to use Google Wallet. To protect you from fraud, information about your computer (including its location) will be shared with Google Wallet. @@ -10623,7 +10623,7 @@ Would you like to start $1Add/Remove Pr By clicking Continue you agree to the $1Google Wallet Terms Of Service, $2Terms of Use, $3Further Terms of Use, $4Further Terms of Use, $5Further Terms of Use, and $6Privacy Policy. - + Google Wallet requires at least a first and last name. @@ -10652,7 +10652,7 @@ Would you like to start $1Add/Remove Pr Field is required - + Google Wallet is protecting your card @@ -14605,9 +14605,12 @@ Do you accept? $1Google Hangouts requested to share content of your desktop. Please select a window or the whole screen to share. - + Screen + + Screen $11 + diff --git a/chrome/browser/media/native_desktop_media_list.cc b/chrome/browser/media/native_desktop_media_list.cc index 7f5128b..3e48f90 100644 --- a/chrome/browser/media/native_desktop_media_list.cc +++ b/chrome/browser/media/native_desktop_media_list.cc @@ -5,6 +5,7 @@ #include "chrome/browser/media/native_desktop_media_list.h" #include +#include #include "base/hash.h" #include "base/logging.h" @@ -134,10 +135,23 @@ void NativeDesktopMediaList::Worker::Refresh( std::vector sources; if (screen_capturer_) { - // TODO(sergeyu): Enumerate each screen when ScreenCapturer supports it. - sources.push_back(SourceDescription(DesktopMediaID( - DesktopMediaID::TYPE_SCREEN, 0), - l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SCREEN_NAME))); + webrtc::ScreenCapturer::ScreenList screens; + if (screen_capturer_->GetScreenList(&screens)) { + bool mutiple_screens = screens.size() > 1; + base::string16 title; + for (size_t i = 0; i < screens.size(); ++i) { + if (mutiple_screens) { + title = l10n_util::GetStringFUTF16Int( + IDS_DESKTOP_MEDIA_PICKER_MULTIPLE_SCREEN_NAME, + static_cast(i + 1)); + } else { + title = l10n_util::GetStringUTF16( + IDS_DESKTOP_MEDIA_PICKER_SINGLE_SCREEN_NAME); + } + sources.push_back(SourceDescription(DesktopMediaID( + DesktopMediaID::TYPE_SCREEN, screens[i].id), title)); + } + } } if (window_capturer_) { @@ -171,6 +185,8 @@ void NativeDesktopMediaList::Worker::Refresh( SourceDescription& source = sources[i]; switch (source.id.type) { case DesktopMediaID::TYPE_SCREEN: + if (!screen_capturer_->SelectScreen(source.id.id)) + continue; screen_capturer_->Capture(webrtc::DesktopRegion()); DCHECK(current_frame_); break; diff --git a/chrome/browser/media/native_desktop_media_list_unittest.cc b/chrome/browser/media/native_desktop_media_list_unittest.cc index 4610ac3..83c6c42 100644 --- a/chrome/browser/media/native_desktop_media_list_unittest.cc +++ b/chrome/browser/media/native_desktop_media_list_unittest.cc @@ -52,11 +52,15 @@ class FakeScreenCapturer : public webrtc::ScreenCapturer { } virtual bool GetScreenList(ScreenList* screens) OVERRIDE { - return false; + webrtc::ScreenCapturer::Screen screen; + screen.id = 0; + screens->push_back(screen); + return true; } virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE { - return false; + EXPECT_EQ(0, id); + return true; } protected: diff --git a/content/browser/renderer_host/media/desktop_capture_device.cc b/content/browser/renderer_host/media/desktop_capture_device.cc index 7c78df0..74ecd80 100644 --- a/content/browser/renderer_host/media/desktop_capture_device.cc +++ b/content/browser/renderer_host/media/desktop_capture_device.cc @@ -366,13 +366,12 @@ scoped_ptr DesktopCaptureDevice::Create( switch (source.type) { case DesktopMediaID::TYPE_SCREEN: { - scoped_ptr screen_capturer; + scoped_ptr screen_capturer; screen_capturer.reset(webrtc::ScreenCapturer::Create(options)); - if (screen_capturer) { + if (screen_capturer && screen_capturer->SelectScreen(source.id)) { capturer.reset(new webrtc::DesktopAndCursorComposer( screen_capturer.release(), - webrtc::MouseCursorMonitor::CreateForScreen( - options, webrtc::kFullDesktopScreenId))); + webrtc::MouseCursorMonitor::CreateForScreen(options, source.id))); } break; } -- cgit v1.1