Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: remoting/host/video_scheduler.cc

Issue 92473002: Use webrtc::MouseCursorMonitor for cursor shapes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux build Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | remoting/host/video_scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/video_scheduler.cc
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc
index 24181c393a3085d6aaf405526656a024748a3e95..7da9adfdf1f6aed5d85a9c085f330e79491820b2 100644
--- a/remoting/host/video_scheduler.cc
+++ b/remoting/host/video_scheduler.cc
@@ -21,6 +21,7 @@
#include "remoting/protocol/message_decoder.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"
@@ -48,6 +49,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)
@@ -55,6 +57,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),
@@ -65,6 +68,7 @@ VideoScheduler::VideoScheduler(
sequence_number_(0) {
DCHECK(network_task_runner_->BelongsToCurrentThread());
DCHECK(capturer_);
+ DCHECK(mouse_cursor_monitor_);
DCHECK(encoder_);
DCHECK(cursor_stub_);
DCHECK(video_stub_);
@@ -103,11 +107,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_)
@@ -115,17 +118,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());
@@ -204,6 +223,7 @@ void VideoScheduler::SetLosslessColor(bool want_lossless) {
VideoScheduler::~VideoScheduler() {
// Destroy the capturer and encoder on their respective threads.
capture_task_runner_->DeleteSoon(FROM_HERE, capturer_.release());
+ capture_task_runner_->DeleteSoon(FROM_HERE, mouse_cursor_monitor_.release());
encode_task_runner_->DeleteSoon(FROM_HERE, encoder_.release());
}
@@ -213,8 +233,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>());
@@ -222,7 +244,7 @@ void VideoScheduler::StartOnCaptureThread() {
FROM_HERE, base::TimeDelta::FromMilliseconds(kKeepAlivePacketIntervalMs),
this, &VideoScheduler::SendKeepAlivePacket));
- // Capture first frame immedately.
+ // Capture first frame immediately.
CaptureNextFrame();
}
@@ -272,6 +294,9 @@ void VideoScheduler::CaptureNextFrame() {
capture_pending_ = true;
+ // Capture the mouse shape.
+ mouse_cursor_monitor_->Capture();
+
// And finally perform one capture.
capturer_->Capture(webrtc::DesktopRegion());
}
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | remoting/host/video_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698