summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 19:57:36 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 19:57:36 +0000
commit68cf5d990babb0a5ea79c312a21c23bf19989192 (patch)
tree2691101838a9ac1f26d518e2652e4a712fcf99b9
parent84a3e66a531e5f059595a3aed1eb513f5b37d59c (diff)
downloadchromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.zip
chromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.tar.gz
chromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.tar.bz2
Simplify ScreenCapturer interface.
Removed Stop() and InvalidateRegion() from ScreenCapturer interface. Review URL: https://codereview.chromium.org/14305004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195887 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/video/capture/screen/screen_capture_device.cc5
-rw-r--r--media/video/capture/screen/screen_capture_device_unittest.cc6
-rw-r--r--media/video/capture/screen/screen_capturer.h21
-rw-r--r--media/video/capture/screen/screen_capturer_fake.cc7
-rw-r--r--media/video/capture/screen/screen_capturer_fake.h2
-rw-r--r--media/video/capture/screen/screen_capturer_mac.mm28
-rw-r--r--media/video/capture/screen/screen_capturer_mac_unittest.cc10
-rw-r--r--media/video/capture/screen/screen_capturer_mock_objects.h2
-rw-r--r--media/video/capture/screen/screen_capturer_unittest.cc3
-rw-r--r--media/video/capture/screen/screen_capturer_win.cc21
-rw-r--r--media/video/capture/screen/screen_capturer_x11.cc9
-rw-r--r--remoting/host/chromoting_messages.h3
-rw-r--r--remoting/host/desktop_session_agent.cc33
-rw-r--r--remoting/host/desktop_session_agent.h3
-rw-r--r--remoting/host/desktop_session_proxy.cc18
-rw-r--r--remoting/host/ipc_desktop_environment_unittest.cc52
-rw-r--r--remoting/host/ipc_video_frame_capturer.cc9
-rw-r--r--remoting/host/ipc_video_frame_capturer.h2
-rw-r--r--remoting/host/video_scheduler.cc27
-rw-r--r--remoting/host/video_scheduler.h4
-rw-r--r--remoting/host/video_scheduler_unittest.cc4
21 files changed, 30 insertions, 239 deletions
diff --git a/media/video/capture/screen/screen_capture_device.cc b/media/video/capture/screen/screen_capture_device.cc
index b22466a..a4f55bd 100644
--- a/media/video/capture/screen/screen_capture_device.cc
+++ b/media/video/capture/screen/screen_capture_device.cc
@@ -313,10 +313,7 @@ void ScreenCaptureDevice::Core::DoStop() {
void ScreenCaptureDevice::Core::DoDeAllocate() {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
DoStop();
- if (screen_capturer_) {
- screen_capturer_->Stop();
- screen_capturer_.reset();
- }
+ screen_capturer_.reset();
waiting_for_frame_size_ = false;
}
diff --git a/media/video/capture/screen/screen_capture_device_unittest.cc b/media/video/capture/screen/screen_capture_device_unittest.cc
index 4689f4d..6b74465 100644
--- a/media/video/capture/screen/screen_capture_device_unittest.cc
+++ b/media/video/capture/screen/screen_capture_device_unittest.cc
@@ -67,12 +67,6 @@ class FakeScreenCapturer : public ScreenCapturer {
virtual void Start(Delegate* delegate) OVERRIDE {
delegate_ = delegate;
}
- virtual void Stop() OVERRIDE {
- delegate_ = NULL;
- }
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE {
- NOTIMPLEMENTED();
- }
virtual void CaptureFrame() OVERRIDE {
scoped_refptr<ScreenCaptureData> frame =
frames_[frame_index_ % arraysize(frames_)];
diff --git a/media/video/capture/screen/screen_capturer.h b/media/video/capture/screen/screen_capturer.h
index d28b935..bc3d454 100644
--- a/media/video/capture/screen/screen_capturer.h
+++ b/media/video/capture/screen/screen_capturer.h
@@ -11,7 +11,6 @@
#include "base/shared_memory.h"
#include "media/base/media_export.h"
#include "media/video/capture/screen/shared_buffer.h"
-#include "third_party/skia/include/core/SkRegion.h"
namespace media {
@@ -27,25 +26,13 @@ class SharedBuffer;
// This is when pre-capture steps are executed, such as flagging the
// display to prevent it from sleeping during a session.
//
-// (2) InvalidateRegion
-// This is an optional step where regions of the screen are marked as
-// invalid. Some platforms (Windows, for now) won't use this and will
-// instead calculate the diff-regions later (in step (2). Other
-// platforms (Mac) will use this to mark all the changed regions of the
-// screen. Some limited rect-merging (e.g., to eliminate exact
-// duplicates) may be done here.
-//
-// (3) CaptureFrame
+// (2) CaptureFrame
// This is where the bits for the invalid rects are packaged up and sent
// to the encoder.
// A screen capture is performed if needed. For example, Windows requires
// a capture to calculate the diff from the previous screen, whereas the
// Mac version does not.
//
-// (4) Stop
-// This is when post-capture steps are executed, such as releasing the
-// assertion that prevents the display from sleeping.
-//
// Implementation has to ensure the following guarantees:
// 1. Double buffering
// Since data can be read while another capture action is happening.
@@ -96,12 +83,6 @@ class MEDIA_EXPORT ScreenCapturer {
// valid until Stop() is called.
virtual void Start(Delegate* delegate) = 0;
- // Called at the end of a capturing session.
- virtual void Stop() = 0;
-
- // Invalidates the specified region.
- virtual void InvalidateRegion(const SkRegion& invalid_region) = 0;
-
// Captures the screen data associated with each of the accumulated
// dirty region. When the capture is complete, the delegate is notified even
// if the dirty region is empty.
diff --git a/media/video/capture/screen/screen_capturer_fake.cc b/media/video/capture/screen/screen_capturer_fake.cc
index 5db2765..ff4dedb 100644
--- a/media/video/capture/screen/screen_capturer_fake.cc
+++ b/media/video/capture/screen/screen_capturer_fake.cc
@@ -53,13 +53,6 @@ void ScreenCapturerFake::Start(Delegate* delegate) {
}
}
-void ScreenCapturerFake::Stop() {
-}
-
-void ScreenCapturerFake::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerFake::CaptureFrame() {
base::Time capture_start_time = base::Time::Now();
diff --git a/media/video/capture/screen/screen_capturer_fake.h b/media/video/capture/screen/screen_capturer_fake.h
index 561c62b..9a8dba9 100644
--- a/media/video/capture/screen/screen_capturer_fake.h
+++ b/media/video/capture/screen/screen_capturer_fake.h
@@ -26,8 +26,6 @@ class MEDIA_EXPORT ScreenCapturerFake : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
diff --git a/media/video/capture/screen/screen_capturer_mac.mm b/media/video/capture/screen/screen_capturer_mac.mm
index 0e4f88d..8248e15 100644
--- a/media/video/capture/screen/screen_capturer_mac.mm
+++ b/media/video/capture/screen/screen_capturer_mac.mm
@@ -120,8 +120,6 @@ class ScreenCapturerMac : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -235,6 +233,15 @@ ScreenCapturerMac::ScreenCapturerMac()
}
ScreenCapturerMac::~ScreenCapturerMac() {
+ if (power_assertion_id_display_ != kIOPMNullAssertionID) {
+ IOPMAssertionRelease(power_assertion_id_display_);
+ power_assertion_id_display_ = kIOPMNullAssertionID;
+ }
+ if (power_assertion_id_user_ != kIOPMNullAssertionID) {
+ IOPMAssertionRelease(power_assertion_id_user_);
+ power_assertion_id_user_ = kIOPMNullAssertionID;
+ }
+
ReleaseBuffers();
UnregisterRefreshAndMoveHandlers();
CGError err = CGDisplayRemoveReconfigurationCallback(
@@ -293,21 +300,6 @@ void ScreenCapturerMac::Start(Delegate* delegate) {
&power_assertion_id_user_);
}
-void ScreenCapturerMac::Stop() {
- if (power_assertion_id_display_ != kIOPMNullAssertionID) {
- IOPMAssertionRelease(power_assertion_id_display_);
- power_assertion_id_display_ = kIOPMNullAssertionID;
- }
- if (power_assertion_id_user_ != kIOPMNullAssertionID) {
- IOPMAssertionRelease(power_assertion_id_user_);
- power_assertion_id_user_ = kIOPMNullAssertionID;
- }
-}
-
-void ScreenCapturerMac::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerMac::CaptureFrame() {
// Only allow captures when the display configuration is not occurring.
scoped_refptr<ScreenCaptureData> data;
@@ -795,7 +787,7 @@ void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
SkRegion region;
region.setRects(skirect_array, count);
- InvalidateRegion(region);
+ helper_.InvalidateRegion(region);
}
void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
diff --git a/media/video/capture/screen/screen_capturer_mac_unittest.cc b/media/video/capture/screen/screen_capturer_mac_unittest.cc
index e7c7730..b8fb5d9 100644
--- a/media/video/capture/screen/screen_capturer_mac_unittest.cc
+++ b/media/video/capture/screen/screen_capturer_mac_unittest.cc
@@ -36,14 +36,8 @@ class ScreenCapturerMacTest : public testing::Test {
capturer_ = ScreenCapturer::Create();
}
- void AddDirtyRect() {
- SkIRect rect = SkIRect::MakeXYWH(0, 0, 10, 10);
- region_.op(rect, SkRegion::kUnion_Op);
- }
-
scoped_ptr<ScreenCapturer> capturer_;
MockScreenCapturerDelegate delegate_;
- SkRegion region_;
};
void ScreenCapturerMacTest::CaptureDoneCallback1(
@@ -64,7 +58,6 @@ void ScreenCapturerMacTest::CaptureDoneCallback2(
int width = config.pixel_bounds.width();
int height = config.pixel_bounds.height();
- EXPECT_EQ(region_, capture_data->dirty_region());
EXPECT_EQ(width, capture_data->size().width());
EXPECT_EQ(height, capture_data->size().height());
EXPECT_TRUE(capture_data->data() != NULL);
@@ -93,10 +86,7 @@ TEST_F(ScreenCapturerMacTest, Capture) {
capturer_->CaptureFrame();
// Check that subsequent dirty rects are propagated correctly.
- AddDirtyRect();
- capturer_->InvalidateRegion(region_);
capturer_->CaptureFrame();
- capturer_->Stop();
}
} // namespace media
diff --git a/media/video/capture/screen/screen_capturer_mock_objects.h b/media/video/capture/screen/screen_capturer_mock_objects.h
index 4bf9890..907fa12 100644
--- a/media/video/capture/screen/screen_capturer_mock_objects.h
+++ b/media/video/capture/screen/screen_capturer_mock_objects.h
@@ -18,8 +18,6 @@ class MockScreenCapturer : public ScreenCapturer {
virtual ~MockScreenCapturer();
MOCK_METHOD1(Start, void(Delegate* delegate));
- MOCK_METHOD0(Stop, void());
- MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region));
MOCK_METHOD0(CaptureFrame, void());
private:
diff --git a/media/video/capture/screen/screen_capturer_unittest.cc b/media/video/capture/screen/screen_capturer_unittest.cc
index 7d9ab95..4ed45d9 100644
--- a/media/video/capture/screen/screen_capturer_unittest.cc
+++ b/media/video/capture/screen/screen_capturer_unittest.cc
@@ -45,7 +45,6 @@ scoped_refptr<SharedBuffer> ScreenCapturerTest::CreateSharedBuffer(
TEST_F(ScreenCapturerTest, StartCapturer) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
- capturer_->Stop();
}
TEST_F(ScreenCapturerTest, Capture) {
@@ -62,7 +61,6 @@ TEST_F(ScreenCapturerTest, Capture) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
capturer_->CaptureFrame();
- capturer_->Stop();
}
#if defined(OS_WIN)
@@ -82,7 +80,6 @@ TEST_F(ScreenCapturerTest, UseSharedBuffers) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
capturer_->CaptureFrame();
- capturer_->Stop();
capturer_.reset();
}
diff --git a/media/video/capture/screen/screen_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc
index 41257e9..ff148b1 100644
--- a/media/video/capture/screen/screen_capturer_win.cc
+++ b/media/video/capture/screen/screen_capturer_win.cc
@@ -80,8 +80,6 @@ class ScreenCapturerWin : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -224,10 +222,12 @@ ScreenCapturerWin::ScreenCapturerWin(bool disable_aero)
}
ScreenCapturerWin::~ScreenCapturerWin() {
-}
+ // Restore Aero.
+ if (composition_func_ != NULL) {
+ (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
+ }
-void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
+ delegate_ = NULL;
}
void ScreenCapturerWin::CaptureFrame() {
@@ -267,7 +267,7 @@ void ScreenCapturerWin::CaptureFrame() {
SkRegion region;
differ_->CalcDirtyRegion(last_buffer->pixels(), current_buffer->pixels(),
&region);
- InvalidateRegion(region);
+ helper_.InvalidateRegion(region);
} else {
// No previous frame is available. Invalidate the whole screen.
helper_.InvalidateScreen(current_buffer->dimensions());
@@ -296,15 +296,6 @@ void ScreenCapturerWin::Start(Delegate* delegate) {
}
}
-void ScreenCapturerWin::Stop() {
- // Restore Aero.
- if (composition_func_ != NULL) {
- (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
- }
-
- delegate_ = NULL;
-}
-
void ScreenCapturerWin::PrepareCaptureResources() {
// Switch to the desktop receiving user input if different from the current
// one.
diff --git a/media/video/capture/screen/screen_capturer_x11.cc b/media/video/capture/screen/screen_capturer_x11.cc
index b4bfaeb..f9da3b3 100644
--- a/media/video/capture/screen/screen_capturer_x11.cc
+++ b/media/video/capture/screen/screen_capturer_x11.cc
@@ -52,8 +52,6 @@ class ScreenCapturerLinux : public ScreenCapturer {
// Capturer interface.
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -278,13 +276,6 @@ void ScreenCapturerLinux::Start(Delegate* delegate) {
delegate_ = delegate;
}
-void ScreenCapturerLinux::Stop() {
-}
-
-void ScreenCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerLinux::CaptureFrame() {
base::Time capture_start_time = base::Time::Now();
diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h
index 164bbb3..986879d 100644
--- a/remoting/host/chromoting_messages.h
+++ b/remoting/host/chromoting_messages.h
@@ -233,9 +233,6 @@ IPC_MESSAGE_CONTROL2(ChromotingNetworkDesktopMsg_StartSessionAgent,
IPC_MESSAGE_CONTROL1(ChromotingNetworkDesktopMsg_SharedBufferCreated,
int /* id */)
-IPC_MESSAGE_CONTROL1(ChromotingNetworkDesktopMsg_InvalidateRegion,
- std::vector<SkIRect> /* invalid_region */ )
-
IPC_MESSAGE_CONTROL0(ChromotingNetworkDesktopMsg_CaptureFrame)
// Carries a clipboard event from the client to the desktop session agent.
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc
index 47d814c..d3c8a3c 100644
--- a/remoting/host/desktop_session_agent.cc
+++ b/remoting/host/desktop_session_agent.cc
@@ -83,8 +83,6 @@ bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message)
IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame,
OnCaptureFrame)
- IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_InvalidateRegion,
- OnInvalidateRegion)
IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_SharedBufferCreated,
OnSharedBufferCreated)
IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_InjectClipboardEvent,
@@ -359,32 +357,6 @@ void DesktopSessionAgent::OnCaptureFrame() {
video_capturer_->CaptureFrame();
}
-void DesktopSessionAgent::OnInvalidateRegion(
- const std::vector<SkIRect>& invalid_rects) {
- if (!video_capture_task_runner()->BelongsToCurrentThread()) {
- video_capture_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&DesktopSessionAgent::OnInvalidateRegion, this,
- invalid_rects));
- return;
- }
-
- SkIRect bounds = SkIRect::MakeSize(current_size_);
-
- // Convert |invalid_rects| into a region.
- SkRegion invalid_region;
- for (std::vector<SkIRect>::const_iterator i = invalid_rects.begin();
- i != invalid_rects.end(); ++i) {
- // Validate each rectange and clip it to the frame bounds.
- SkIRect rect;
- if (rect.intersect(*i, bounds)) {
- invalid_region.op(rect, SkRegion::kUnion_Op);
- }
- }
-
- video_capturer_->InvalidateRegion(invalid_region);
-}
-
void DesktopSessionAgent::OnSharedBufferCreated(int id) {
if (!video_capture_task_runner()->BelongsToCurrentThread()) {
video_capture_task_runner()->PostTask(
@@ -501,10 +473,7 @@ void DesktopSessionAgent::StartVideoCapturer() {
void DesktopSessionAgent::StopVideoCapturer() {
DCHECK(video_capture_task_runner()->BelongsToCurrentThread());
- if (video_capturer_) {
- video_capturer_->Stop();
- video_capturer_.reset();
- }
+ video_capturer_.reset();
// Free any shared buffers left.
shared_buffers_.clear();
diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h
index b213809..7e6126f 100644
--- a/remoting/host/desktop_session_agent.h
+++ b/remoting/host/desktop_session_agent.h
@@ -131,9 +131,6 @@ class DesktopSessionAgent
// Handles CaptureFrame requests from the client.
void OnCaptureFrame();
- // Handles InvalidateRegion requests from the client.
- void OnInvalidateRegion(const std::vector<SkIRect>& invalid_rects);
-
// Handles SharedBufferCreated notification from the client.
void OnSharedBufferCreated(int id);
diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc
index a61ab7c..a21e75f 100644
--- a/remoting/host/desktop_session_proxy.cc
+++ b/remoting/host/desktop_session_proxy.cc
@@ -224,24 +224,6 @@ void DesktopSessionProxy::SetAudioCapturer(
audio_capturer_ = audio_capturer;
}
-void DesktopSessionProxy::InvalidateRegion(const SkRegion& invalid_region) {
- if (!caller_task_runner_->BelongsToCurrentThread()) {
- caller_task_runner_->PostTask(
- FROM_HERE, base::Bind(&DesktopSessionProxy::InvalidateRegion, this,
- invalid_region));
- return;
- }
-
- if (desktop_channel_) {
- std::vector<SkIRect> invalid_rects;
- for (SkRegion::Iterator i(invalid_region); !i.done(); i.next())
- invalid_rects.push_back(i.rect());
-
- SendToDesktop(
- new ChromotingNetworkDesktopMsg_InvalidateRegion(invalid_rects));
- }
-}
-
void DesktopSessionProxy::CaptureFrame() {
if (!caller_task_runner_->BelongsToCurrentThread()) {
caller_task_runner_->PostTask(
diff --git a/remoting/host/ipc_desktop_environment_unittest.cc b/remoting/host/ipc_desktop_environment_unittest.cc
index cd4346f..7a155b6 100644
--- a/remoting/host/ipc_desktop_environment_unittest.cc
+++ b/remoting/host/ipc_desktop_environment_unittest.cc
@@ -502,58 +502,6 @@ TEST_F(IpcDesktopEnvironmentTest, Reattach) {
main_run_loop_.Run();
}
-// Tests InvalidateRegion().
-TEST_F(IpcDesktopEnvironmentTest, InvalidateRegion) {
- scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
- new protocol::MockClipboardStub());
- EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
- .Times(0);
-
- // Start the input injector and screen capturer.
- input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
- video_capturer_->Start(&screen_capturer_delegate_);
-
- // Run the message loop until the desktop is attached.
- setup_run_loop_->Run();
-
- // Input injector should receive no events.
- EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_))
- .Times(0);
- EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_))
- .Times(0);
- EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_))
- .Times(0);
-
- // Stop the test when the first frame is captured.
- EXPECT_CALL(screen_capturer_delegate_, OnCaptureCompleted(_))
- .WillOnce(InvokeWithoutArgs(
- this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment));
-
- // Invalidate a region that is larger than the screen.
- SkIRect horizontal_rect = SkIRect::MakeXYWH(
- -100,
- media::ScreenCapturerFake::kHeight / 4,
- media::ScreenCapturerFake::kWidth + 200,
- media::ScreenCapturerFake::kHeight / 2);
- SkIRect vertical_rect = SkIRect::MakeXYWH(
- media::ScreenCapturerFake::kWidth / 4,
- -100,
- media::ScreenCapturerFake::kWidth / 2,
- media::ScreenCapturerFake::kHeight + 200);
-
- SkRegion invalid_region;
- invalid_region.op(horizontal_rect, SkRegion::kUnion_Op);
- invalid_region.op(vertical_rect, SkRegion::kUnion_Op);
- video_capturer_->InvalidateRegion(invalid_region);
-
- // Capture a single frame.
- video_capturer_->CaptureFrame();
-
- task_runner_ = NULL;
- io_task_runner_ = NULL;
- main_run_loop_.Run();
-}
-
// Tests injection of clipboard events.
TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) {
scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
diff --git a/remoting/host/ipc_video_frame_capturer.cc b/remoting/host/ipc_video_frame_capturer.cc
index 24383f1..5d1016f 100644
--- a/remoting/host/ipc_video_frame_capturer.cc
+++ b/remoting/host/ipc_video_frame_capturer.cc
@@ -25,15 +25,6 @@ void IpcVideoFrameCapturer::Start(Delegate* delegate) {
desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr());
}
-void IpcVideoFrameCapturer::Stop() {
- delegate_ = NULL;
- weak_factory_.InvalidateWeakPtrs();
-}
-
-void IpcVideoFrameCapturer::InvalidateRegion(const SkRegion& invalid_region) {
- desktop_session_proxy_->InvalidateRegion(invalid_region);
-}
-
void IpcVideoFrameCapturer::CaptureFrame() {
desktop_session_proxy_->CaptureFrame();
}
diff --git a/remoting/host/ipc_video_frame_capturer.h b/remoting/host/ipc_video_frame_capturer.h
index fb8fa1b..8d6b90a 100644
--- a/remoting/host/ipc_video_frame_capturer.h
+++ b/remoting/host/ipc_video_frame_capturer.h
@@ -31,8 +31,6 @@ class IpcVideoFrameCapturer : public media::ScreenCapturer {
// media::ScreenCapturer interface.
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
// Called when a video frame has been captured. |capture_data| describes
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc
index c927b3c..e6cead8 100644
--- a/remoting/host/video_scheduler.cc
+++ b/remoting/host/video_scheduler.cc
@@ -61,6 +61,10 @@ void VideoScheduler::OnCaptureCompleted(
scoped_refptr<media::ScreenCaptureData> capture_data) {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ // Do nothing if the scheduler is being stopped.
+ if (!capturer_)
+ return;
+
if (capture_data) {
scheduler_.RecordCaptureTime(
base::TimeDelta::FromMilliseconds(capture_data->capture_time_ms()));
@@ -81,6 +85,10 @@ void VideoScheduler::OnCursorShapeChanged(
scoped_ptr<media::MouseCursorShape> cursor_shape) {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ // Do nothing if the scheduler is being stopped.
+ if (!capturer_)
+ return;
+
scoped_ptr<protocol::CursorShapeInfo> cursor_proto(
new protocol::CursorShapeInfo());
cursor_proto->set_width(cursor_shape->size.width());
@@ -177,9 +185,6 @@ void VideoScheduler::StartOnCaptureThread() {
void VideoScheduler::StopOnCaptureThread() {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
- // Stop |capturer_| and clear it to prevent pending tasks from using it.
- capturer_->Stop();
-
// |capture_timer_| must be destroyed on the thread on which it is used.
capture_timer_.reset();
@@ -278,14 +283,6 @@ void VideoScheduler::SendCursorShape(
cursor_stub_->SetCursorShape(*cursor_shape);
}
-void VideoScheduler::StopOnNetworkThread(
- scoped_ptr<media::ScreenCapturer> capturer) {
- DCHECK(network_task_runner_->BelongsToCurrentThread());
-
- // This is posted by StopOnEncodeThread meaning that both capture and encode
- // threads are stopped now and it is safe to delete |capturer|.
-}
-
// Encoder thread --------------------------------------------------------------
void VideoScheduler::EncodeFrame(
@@ -327,11 +324,9 @@ void VideoScheduler::StopOnEncodeThread(
DCHECK(encode_task_runner_->BelongsToCurrentThread());
// This is posted by StopOnCaptureThread, so we know that by the time we
- // process it there are no more encode tasks queued. Pass |capturer_| for
- // deletion on the thread that created it.
- network_task_runner_->PostTask(
- FROM_HERE, base::Bind(&VideoScheduler::StopOnNetworkThread, this,
- base::Passed(&capturer)));
+ // process it there are no more encode tasks queued. Pass |capturer| for
+ // deletion on the capture thread.
+ capture_task_runner_->DeleteSoon(FROM_HERE, capturer.release());
}
} // namespace remoting
diff --git a/remoting/host/video_scheduler.h b/remoting/host/video_scheduler.h
index 0e47713..666e1ab 100644
--- a/remoting/host/video_scheduler.h
+++ b/remoting/host/video_scheduler.h
@@ -150,10 +150,6 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
// Send updated cursor shape to client.
void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape);
- // Posted to the network thread to delete |capturer| on the thread that
- // created it.
- void StopOnNetworkThread(scoped_ptr<media::ScreenCapturer> capturer);
-
// Encoder thread -----------------------------------------------------------
// Encode a frame, passing generated VideoPackets to SendVideoPacket().
diff --git a/remoting/host/video_scheduler_unittest.cc b/remoting/host/video_scheduler_unittest.cc
index 80b2b332..1b356bf 100644
--- a/remoting/host/video_scheduler_unittest.cc
+++ b/remoting/host/video_scheduler_unittest.cc
@@ -187,10 +187,6 @@ TEST_F(VideoSchedulerTest, StartAndStop) {
InvokeWithoutArgs(this, &VideoSchedulerTest::StopVideoScheduler)))
.RetiresOnSaturation();
- EXPECT_CALL(*capturer, Stop())
- .After(capturer_capture)
- .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStop));
-
// Start video frame capture.
StartVideoScheduler(capturer.PassAs<media::ScreenCapturer>());