Index: remoting/host/video_scheduler.cc |
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc |
index 5c95c7a9387a9040c489ae4fa0a2951f531d052f..6edac61cfa9115433ad1169a16f6e119927726a0 100644 |
--- a/remoting/host/video_scheduler.cc |
+++ b/remoting/host/video_scheduler.cc |
@@ -22,6 +22,7 @@ |
#include "remoting/protocol/util.h" |
#include "remoting/protocol/video_stub.h" |
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
+#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" |
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" |
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
@@ -36,6 +37,7 @@ VideoScheduler::VideoScheduler( |
scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
scoped_ptr<webrtc::ScreenCapturer> capturer, |
+ scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, |
scoped_ptr<VideoEncoder> encoder, |
protocol::CursorShapeStub* cursor_stub, |
protocol::VideoStub* video_stub) |
@@ -43,6 +45,7 @@ VideoScheduler::VideoScheduler( |
encode_task_runner_(encode_task_runner), |
network_task_runner_(network_task_runner), |
capturer_(capturer.Pass()), |
+ mouse_cursor_monitor_(mouse_cursor_monitor.Pass()), |
encoder_(encoder.Pass()), |
cursor_stub_(cursor_stub), |
video_stub_(video_stub), |
@@ -87,11 +90,10 @@ void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) { |
} |
} |
-void VideoScheduler::OnCursorShapeChanged( |
- webrtc::MouseCursorShape* cursor_shape) { |
+void VideoScheduler::OnMouseCursor(webrtc::MouseCursor* cursor) { |
DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
- scoped_ptr<webrtc::MouseCursorShape> owned_cursor(cursor_shape); |
+ scoped_ptr<webrtc::MouseCursor> owned_cursor(cursor); |
// Do nothing if the scheduler is being stopped. |
if (!capturer_) |
@@ -99,17 +101,33 @@ void VideoScheduler::OnCursorShapeChanged( |
scoped_ptr<protocol::CursorShapeInfo> cursor_proto( |
new protocol::CursorShapeInfo()); |
- cursor_proto->set_width(cursor_shape->size.width()); |
- cursor_proto->set_height(cursor_shape->size.height()); |
- cursor_proto->set_hotspot_x(cursor_shape->hotspot.x()); |
- cursor_proto->set_hotspot_y(cursor_shape->hotspot.y()); |
- cursor_proto->set_data(cursor_shape->data); |
+ cursor_proto->set_width(cursor->image()->size().width()); |
+ cursor_proto->set_height(cursor->image()->size().height()); |
+ cursor_proto->set_hotspot_x(cursor->hotspot().x()); |
+ cursor_proto->set_hotspot_y(cursor->hotspot().y()); |
+ |
+ std::string data; |
+ uint8_t* current_row = cursor->image()->data(); |
+ for (int y = 0; y < cursor->image()->size().height(); ++y) { |
+ cursor_proto->mutable_data()->append( |
+ current_row, |
+ current_row + cursor->image()->size().width() * |
+ webrtc::DesktopFrame::kBytesPerPixel); |
+ current_row += cursor->image()->stride(); |
+ } |
network_task_runner_->PostTask( |
FROM_HERE, base::Bind(&VideoScheduler::SendCursorShape, this, |
base::Passed(&cursor_proto))); |
} |
+void VideoScheduler::OnMouseCursorPosition( |
+ webrtc::MouseCursorMonitor::CursorState state, |
+ const webrtc::DesktopVector& position) { |
+ // We're not subscribing to mouse position changes. |
+ NOTREACHED(); |
+} |
+ |
void VideoScheduler::Start() { |
DCHECK(network_task_runner_->BelongsToCurrentThread()); |
@@ -168,8 +186,10 @@ void VideoScheduler::StartOnCaptureThread() { |
DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
DCHECK(!capture_timer_); |
- // Start the capturer and let it notify us if cursor shape changes. |
- capturer_->SetMouseShapeObserver(this); |
+ // Start mouse cursor monitor. |
+ mouse_cursor_monitor_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY); |
+ |
+ // Start the capturer. |
capturer_->Start(this); |
capture_timer_.reset(new base::OneShotTimer<VideoScheduler>()); |
@@ -224,6 +244,9 @@ void VideoScheduler::CaptureNextFrame() { |
capture_pending_ = true; |
+ // Capture the mouse shape. |
+ mouse_cursor_monitor_->Capture(); |
+ |
// And finally perform one capture. |
capturer_->Capture(webrtc::DesktopRegion()); |
} |