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

Side by Side Diff: remoting/host/desktop_session_proxy.cc

Issue 92473002: Use webrtc::MouseCursorMonitor for cursor shapes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed obsolete #include. Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/desktop_session_proxy.h" 5 #include "remoting/host/desktop_session_proxy.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/platform_file.h" 9 #include "base/platform_file.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "ipc/ipc_channel_proxy.h" 13 #include "ipc/ipc_channel_proxy.h"
14 #include "ipc/ipc_message_macros.h" 14 #include "ipc/ipc_message_macros.h"
15 #include "remoting/base/capabilities.h" 15 #include "remoting/base/capabilities.h"
16 #include "remoting/host/chromoting_messages.h" 16 #include "remoting/host/chromoting_messages.h"
17 #include "remoting/host/client_session.h" 17 #include "remoting/host/client_session.h"
18 #include "remoting/host/client_session_control.h" 18 #include "remoting/host/client_session_control.h"
19 #include "remoting/host/desktop_session_connector.h" 19 #include "remoting/host/desktop_session_connector.h"
20 #include "remoting/host/ipc_audio_capturer.h" 20 #include "remoting/host/ipc_audio_capturer.h"
21 #include "remoting/host/ipc_input_injector.h" 21 #include "remoting/host/ipc_input_injector.h"
22 #include "remoting/host/ipc_mouse_cursor_monitor.h"
22 #include "remoting/host/ipc_screen_controls.h" 23 #include "remoting/host/ipc_screen_controls.h"
23 #include "remoting/host/ipc_video_frame_capturer.h" 24 #include "remoting/host/ipc_video_frame_capturer.h"
24 #include "remoting/proto/audio.pb.h" 25 #include "remoting/proto/audio.pb.h"
25 #include "remoting/proto/control.pb.h" 26 #include "remoting/proto/control.pb.h"
26 #include "remoting/proto/event.pb.h" 27 #include "remoting/proto/event.pb.h"
27 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 28 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
28 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 29 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
30 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
29 #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" 31 #include "third_party/webrtc/modules/desktop_capture/shared_memory.h"
30 32
31 #if defined(OS_WIN) 33 #if defined(OS_WIN)
32 #include "base/win/scoped_handle.h" 34 #include "base/win/scoped_handle.h"
33 #endif // defined(OS_WIN) 35 #endif // defined(OS_WIN)
34 36
35 const bool kReadOnly = true; 37 const bool kReadOnly = true;
36 const char kSendInitialResolution[] = "sendInitialResolution"; 38 const char kSendInitialResolution[] = "sendInitialResolution";
37 const char kRateLimitResizeRequests[] = "rateLimitResizeRequests"; 39 const char kRateLimitResizeRequests[] = "rateLimitResizeRequests";
38 40
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 return scoped_ptr<ScreenControls>(new IpcScreenControls(this)); 140 return scoped_ptr<ScreenControls>(new IpcScreenControls(this));
139 } 141 }
140 142
141 scoped_ptr<webrtc::ScreenCapturer> DesktopSessionProxy::CreateVideoCapturer() { 143 scoped_ptr<webrtc::ScreenCapturer> DesktopSessionProxy::CreateVideoCapturer() {
142 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 144 DCHECK(caller_task_runner_->BelongsToCurrentThread());
143 145
144 return scoped_ptr<webrtc::ScreenCapturer>(new IpcVideoFrameCapturer(this)); 146 return scoped_ptr<webrtc::ScreenCapturer>(new IpcVideoFrameCapturer(this));
145 } 147 }
146 148
149 scoped_ptr<webrtc::MouseCursorMonitor>
150 DesktopSessionProxy::CreateMouseCursorMonitor() {
151 return scoped_ptr<webrtc::MouseCursorMonitor>(
152 new IpcMouseCursorMonitor(this));
153 }
154
147 std::string DesktopSessionProxy::GetCapabilities() const { 155 std::string DesktopSessionProxy::GetCapabilities() const {
148 std::string result = kRateLimitResizeRequests; 156 std::string result = kRateLimitResizeRequests;
149 // Ask the client to send its resolution unconditionally. 157 // Ask the client to send its resolution unconditionally.
150 if (virtual_terminal_) 158 if (virtual_terminal_)
151 result = result + " " + kSendInitialResolution; 159 result = result + " " + kSendInitialResolution;
152 return result; 160 return result;
153 } 161 }
154 162
155 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { 163 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) {
156 // Delay creation of the desktop session until the client screen resolution is 164 // Delay creation of the desktop session until the client screen resolution is
(...skipping 19 matching lines...) Expand all
176 184
177 bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) { 185 bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) {
178 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 186 DCHECK(caller_task_runner_->BelongsToCurrentThread());
179 187
180 bool handled = true; 188 bool handled = true;
181 IPC_BEGIN_MESSAGE_MAP(DesktopSessionProxy, message) 189 IPC_BEGIN_MESSAGE_MAP(DesktopSessionProxy, message)
182 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_AudioPacket, 190 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_AudioPacket,
183 OnAudioPacket) 191 OnAudioPacket)
184 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_CaptureCompleted, 192 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_CaptureCompleted,
185 OnCaptureCompleted) 193 OnCaptureCompleted)
186 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_CursorShapeChanged, 194 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_MouseCursor,
187 OnCursorShapeChanged) 195 OnMouseCursor)
188 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_CreateSharedBuffer, 196 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_CreateSharedBuffer,
189 OnCreateSharedBuffer) 197 OnCreateSharedBuffer)
190 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_ReleaseSharedBuffer, 198 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_ReleaseSharedBuffer,
191 OnReleaseSharedBuffer) 199 OnReleaseSharedBuffer)
192 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_InjectClipboardEvent, 200 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_InjectClipboardEvent,
193 OnInjectClipboardEvent) 201 OnInjectClipboardEvent)
194 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_DisconnectSession, 202 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_DisconnectSession,
195 DisconnectSession); 203 DisconnectSession);
196 IPC_END_MESSAGE_MAP() 204 IPC_END_MESSAGE_MAP()
197 205
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 319 }
312 } 320 }
313 321
314 void DesktopSessionProxy::SetVideoCapturer( 322 void DesktopSessionProxy::SetVideoCapturer(
315 const base::WeakPtr<IpcVideoFrameCapturer> video_capturer) { 323 const base::WeakPtr<IpcVideoFrameCapturer> video_capturer) {
316 DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); 324 DCHECK(video_capture_task_runner_->BelongsToCurrentThread());
317 325
318 video_capturer_ = video_capturer; 326 video_capturer_ = video_capturer;
319 } 327 }
320 328
329 void DesktopSessionProxy::SetMouseCursorMonitor(
330 const base::WeakPtr<IpcMouseCursorMonitor>& mouse_cursor_monitor) {
331 DCHECK(video_capture_task_runner_->BelongsToCurrentThread());
332
333 mouse_cursor_monitor_ = mouse_cursor_monitor;
334 }
335
321 void DesktopSessionProxy::DisconnectSession() { 336 void DesktopSessionProxy::DisconnectSession() {
322 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 337 DCHECK(caller_task_runner_->BelongsToCurrentThread());
323 338
324 // Disconnect the client session if it hasn't been disconnected yet. 339 // Disconnect the client session if it hasn't been disconnected yet.
325 if (client_session_control_.get()) 340 if (client_session_control_.get())
326 client_session_control_->DisconnectSession(); 341 client_session_control_->DisconnectSession();
327 } 342 }
328 343
329 void DesktopSessionProxy::InjectClipboardEvent( 344 void DesktopSessionProxy::InjectClipboardEvent(
330 const protocol::ClipboardEvent& event) { 345 const protocol::ClipboardEvent& event) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 frame->set_dpi(serialized_frame.dpi); 499 frame->set_dpi(serialized_frame.dpi);
485 500
486 for (size_t i = 0; i < serialized_frame.dirty_region.size(); ++i) { 501 for (size_t i = 0; i < serialized_frame.dirty_region.size(); ++i) {
487 frame->mutable_updated_region()->AddRect(serialized_frame.dirty_region[i]); 502 frame->mutable_updated_region()->AddRect(serialized_frame.dirty_region[i]);
488 } 503 }
489 504
490 --pending_capture_frame_requests_; 505 --pending_capture_frame_requests_;
491 PostCaptureCompleted(frame.Pass()); 506 PostCaptureCompleted(frame.Pass());
492 } 507 }
493 508
494 void DesktopSessionProxy::OnCursorShapeChanged( 509 void DesktopSessionProxy::OnMouseCursor(
495 const webrtc::MouseCursorShape& cursor_shape) { 510 const webrtc::MouseCursor& mouse_cursor) {
496 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 511 DCHECK(caller_task_runner_->BelongsToCurrentThread());
497 PostCursorShape(scoped_ptr<webrtc::MouseCursorShape>( 512 scoped_ptr<webrtc::MouseCursor> cursor(
498 new webrtc::MouseCursorShape(cursor_shape))); 513 webrtc::MouseCursor::CopyOf(mouse_cursor));
514 PostMouseCursor(cursor.Pass());
499 } 515 }
500 516
501 void DesktopSessionProxy::OnInjectClipboardEvent( 517 void DesktopSessionProxy::OnInjectClipboardEvent(
502 const std::string& serialized_event) { 518 const std::string& serialized_event) {
503 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 519 DCHECK(caller_task_runner_->BelongsToCurrentThread());
504 520
505 if (client_clipboard_) { 521 if (client_clipboard_) {
506 protocol::ClipboardEvent event; 522 protocol::ClipboardEvent event;
507 if (!event.ParseFromString(serialized_event)) { 523 if (!event.ParseFromString(serialized_event)) {
508 LOG(ERROR) << "Failed to parse protocol::ClipboardEvent."; 524 LOG(ERROR) << "Failed to parse protocol::ClipboardEvent.";
509 return; 525 return;
510 } 526 }
511 527
512 client_clipboard_->InjectClipboardEvent(event); 528 client_clipboard_->InjectClipboardEvent(event);
513 } 529 }
514 } 530 }
515 531
516 void DesktopSessionProxy::PostCaptureCompleted( 532 void DesktopSessionProxy::PostCaptureCompleted(
517 scoped_ptr<webrtc::DesktopFrame> frame) { 533 scoped_ptr<webrtc::DesktopFrame> frame) {
518 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 534 DCHECK(caller_task_runner_->BelongsToCurrentThread());
519 535
520 video_capture_task_runner_->PostTask( 536 video_capture_task_runner_->PostTask(
521 FROM_HERE, 537 FROM_HERE,
522 base::Bind(&IpcVideoFrameCapturer::OnCaptureCompleted, video_capturer_, 538 base::Bind(&IpcVideoFrameCapturer::OnCaptureCompleted, video_capturer_,
523 base::Passed(&frame))); 539 base::Passed(&frame)));
524 } 540 }
525 541
526 void DesktopSessionProxy::PostCursorShape( 542 void DesktopSessionProxy::PostMouseCursor(
527 scoped_ptr<webrtc::MouseCursorShape> cursor_shape) { 543 scoped_ptr<webrtc::MouseCursor> mouse_cursor) {
528 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 544 DCHECK(caller_task_runner_->BelongsToCurrentThread());
529 545
530 video_capture_task_runner_->PostTask( 546 video_capture_task_runner_->PostTask(
531 FROM_HERE, 547 FROM_HERE,
532 base::Bind(&IpcVideoFrameCapturer::OnCursorShapeChanged, video_capturer_, 548 base::Bind(&IpcMouseCursorMonitor::OnMouseCursor, mouse_cursor_monitor_,
533 base::Passed(&cursor_shape))); 549 base::Passed(&mouse_cursor)));
534 } 550 }
535 551
536 void DesktopSessionProxy::SendToDesktop(IPC::Message* message) { 552 void DesktopSessionProxy::SendToDesktop(IPC::Message* message) {
537 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 553 DCHECK(caller_task_runner_->BelongsToCurrentThread());
538 554
539 if (desktop_channel_) { 555 if (desktop_channel_) {
540 desktop_channel_->Send(message); 556 desktop_channel_->Send(message);
541 } else { 557 } else {
542 delete message; 558 delete message;
543 } 559 }
544 } 560 }
545 561
546 // static 562 // static
547 void DesktopSessionProxyTraits::Destruct( 563 void DesktopSessionProxyTraits::Destruct(
548 const DesktopSessionProxy* desktop_session_proxy) { 564 const DesktopSessionProxy* desktop_session_proxy) {
549 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, 565 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE,
550 desktop_session_proxy); 566 desktop_session_proxy);
551 } 567 }
552 568
553 } // namespace remoting 569 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698