From 249beee124254cd175622a8b9261a2cfa24cad9b Mon Sep 17 00:00:00 2001 From: zijiehe Date: Tue, 18 Oct 2016 23:13:29 -0700 Subject: [PATCH] Remove DesktopRegion parameter from DesktopCapturer::Capture BUG=https://bugs.chromium.org/p/webrtc/issues/detail?id=6513 Review-Url: https://codereview.webrtc.org/2433503002 Cr-Commit-Position: refs/heads/master@{#14676} --- .../desktop_capture/cropping_window_capturer.cc | 2 +- webrtc/modules/desktop_capture/desktop_capturer.h | 14 ++++++-------- .../screen_capturer_mac_unittest.cc | 4 ++-- .../desktop_capture/screen_capturer_mock_objects.h | 7 +------ .../desktop_capture/window_capturer_unittest.cc | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/webrtc/modules/desktop_capture/cropping_window_capturer.cc b/webrtc/modules/desktop_capture/cropping_window_capturer.cc index 63a62f559b..71c5beac2b 100644 --- a/webrtc/modules/desktop_capture/cropping_window_capturer.cc +++ b/webrtc/modules/desktop_capture/cropping_window_capturer.cc @@ -79,7 +79,7 @@ void CroppingWindowCapturer::OnCaptureResult( std::unique_ptr screen_frame) { if (!ShouldUseScreenCapturer()) { LOG(LS_INFO) << "Window no longer on top when ScreenCapturer finishes"; - window_capturer_->Capture(DesktopRegion()); + window_capturer_->CaptureFrame(); return; } diff --git a/webrtc/modules/desktop_capture/desktop_capturer.h b/webrtc/modules/desktop_capture/desktop_capturer.h index 0c7b68e85d..d758946b84 100644 --- a/webrtc/modules/desktop_capture/desktop_capturer.h +++ b/webrtc/modules/desktop_capture/desktop_capturer.h @@ -31,11 +31,11 @@ class DesktopCapturer { SUCCESS, // There was a temporary error. The caller should continue calling - // Capture(), in the expectation that it will eventually recover. + // CaptureFrame(), in the expectation that it will eventually recover. ERROR_TEMPORARY, // Capture has failed and will keep failing if the caller tries calling - // Capture() again. + // CaptureFrame() again. ERROR_PERMANENT, MAX_VALUE = ERROR_PERMANENT @@ -61,17 +61,15 @@ class DesktopCapturer { // Sets SharedMemoryFactory that will be used to create buffers for the // captured frames. The factory can be invoked on a thread other than the one - // where Capture() is called. It will be destroyed on the same thread. Shared - // memory is currently supported only by some DesktopCapturer implementations. + // where CaptureFrame() is called. It will be destroyed on the same thread. + // Shared memory is currently supported only by some DesktopCapturer + // implementations. virtual void SetSharedMemoryFactory( std::unique_ptr shared_memory_factory) {} - // This is a legacy interface, consumers should call CaptureFrame() function. - virtual void Capture(const DesktopRegion& region) { CaptureFrame(); } - // Captures next frame, and involve callback provided by Start() function. // Pending capture requests are canceled when DesktopCapturer is deleted. - virtual void CaptureFrame() { Capture(DesktopRegion()); } + virtual void CaptureFrame() = 0; // Sets the window to be excluded from the captured image in the future // Capture calls. Used to exclude the screenshare notification window for diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc index 003f4dba54..e764492b3a 100644 --- a/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc +++ b/webrtc/modules/desktop_capture/screen_capturer_mac_unittest.cc @@ -93,10 +93,10 @@ TEST_F(ScreenCapturerMacTest, Capture) { capturer_->Start(&callback_); // Check that we get an initial full-screen updated. - capturer_->Capture(DesktopRegion()); + capturer_->CaptureFrame(); // Check that subsequent dirty rects are propagated correctly. - capturer_->Capture(DesktopRegion()); + capturer_->CaptureFrame(); } } // namespace webrtc diff --git a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h index 6baaa472bf..1d451432ff 100644 --- a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h +++ b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h @@ -19,15 +19,10 @@ namespace webrtc { class MockScreenCapturer : public ScreenCapturer { public: - MockScreenCapturer() { - ON_CALL(*this, Capture(testing::_)) - .WillByDefault(testing::WithoutArgs(testing::Invoke( - this, &MockScreenCapturer::CaptureFrame))); - } + MockScreenCapturer() {} virtual ~MockScreenCapturer() {} MOCK_METHOD1(Start, void(Callback* callback)); - MOCK_METHOD1(Capture, void(const DesktopRegion& region)); MOCK_METHOD0(CaptureFrame, void(void)); MOCK_METHOD1(GetScreenList, bool(ScreenList* screens)); MOCK_METHOD1(SelectScreen, bool(ScreenId id)); diff --git a/webrtc/modules/desktop_capture/window_capturer_unittest.cc b/webrtc/modules/desktop_capture/window_capturer_unittest.cc index 1a8e4d07e7..a30d23e042 100644 --- a/webrtc/modules/desktop_capture/window_capturer_unittest.cc +++ b/webrtc/modules/desktop_capture/window_capturer_unittest.cc @@ -70,7 +70,7 @@ TEST_F(WindowCapturerTest, Capture) { it != windows.end(); ++it) { frame_.reset(); if (capturer_->SelectWindow(it->id)) { - capturer_->Capture(DesktopRegion()); + capturer_->CaptureFrame(); } // If we failed to capture a window make sure it no longer exists.