| OLD | NEW |
| 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/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "ipc/ipc_channel_proxy.h" | 12 #include "ipc/ipc_channel_proxy.h" |
| 13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
| 14 #include "remoting/base/capabilities.h" | 14 #include "remoting/base/capabilities.h" |
| 15 #include "remoting/host/chromoting_messages.h" | 15 #include "remoting/host/chromoting_messages.h" |
| 16 #include "remoting/host/client_session.h" | 16 #include "remoting/host/client_session.h" |
| 17 #include "remoting/host/client_session_control.h" | 17 #include "remoting/host/client_session_control.h" |
| 18 #include "remoting/host/desktop_session_connector.h" | 18 #include "remoting/host/desktop_session_connector.h" |
| 19 #include "remoting/host/ipc_audio_capturer.h" | 19 #include "remoting/host/ipc_audio_capturer.h" |
| 20 #include "remoting/host/ipc_input_injector.h" | 20 #include "remoting/host/ipc_input_injector.h" |
| 21 #include "remoting/host/ipc_mouse_cursor_monitor.h" | 21 #include "remoting/host/ipc_mouse_cursor_monitor.h" |
| 22 #include "remoting/host/ipc_screen_controls.h" | 22 #include "remoting/host/ipc_screen_controls.h" |
| 23 #include "remoting/host/ipc_video_frame_capturer.h" | 23 #include "remoting/host/ipc_video_frame_capturer.h" |
| 24 #include "remoting/proto/audio.pb.h" | 24 #include "remoting/proto/audio.pb.h" |
| 25 #include "remoting/proto/control.pb.h" | 25 #include "remoting/proto/control.pb.h" |
| 26 #include "remoting/proto/event.pb.h" | 26 #include "remoting/proto/event.pb.h" |
| 27 #include "remoting/protocol/capability_names.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" |
| 29 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" | 30 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" |
| 30 #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" | 31 #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" |
| 31 | 32 |
| 32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 33 #include "base/win/scoped_handle.h" | 34 #include "base/win/scoped_handle.h" |
| 34 #endif // defined(OS_WIN) | 35 #endif // defined(OS_WIN) |
| 35 | 36 |
| 36 const bool kReadOnly = true; | 37 const bool kReadOnly = true; |
| 37 const char kSendInitialResolution[] = "sendInitialResolution"; | |
| 38 const char kRateLimitResizeRequests[] = "rateLimitResizeRequests"; | |
| 39 | 38 |
| 40 namespace remoting { | 39 namespace remoting { |
| 41 | 40 |
| 42 class DesktopSessionProxy::IpcSharedBufferCore | 41 class DesktopSessionProxy::IpcSharedBufferCore |
| 43 : public base::RefCountedThreadSafe<IpcSharedBufferCore> { | 42 : public base::RefCountedThreadSafe<IpcSharedBufferCore> { |
| 44 public: | 43 public: |
| 45 IpcSharedBufferCore(int id, | 44 IpcSharedBufferCore(int id, |
| 46 base::SharedMemoryHandle handle, | 45 base::SharedMemoryHandle handle, |
| 47 base::ProcessHandle process, | 46 base::ProcessHandle process, |
| 48 size_t size) | 47 size_t size) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DISALLOW_COPY_AND_ASSIGN(IpcSharedBuffer); | 99 DISALLOW_COPY_AND_ASSIGN(IpcSharedBuffer); |
| 101 }; | 100 }; |
| 102 | 101 |
| 103 DesktopSessionProxy::DesktopSessionProxy( | 102 DesktopSessionProxy::DesktopSessionProxy( |
| 104 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, |
| 105 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 104 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 106 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 105 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 107 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | 106 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
| 108 base::WeakPtr<ClientSessionControl> client_session_control, | 107 base::WeakPtr<ClientSessionControl> client_session_control, |
| 109 base::WeakPtr<DesktopSessionConnector> desktop_session_connector, | 108 base::WeakPtr<DesktopSessionConnector> desktop_session_connector, |
| 110 bool virtual_terminal) | 109 bool virtual_terminal, |
| 110 bool supports_touch_events) |
| 111 : audio_capture_task_runner_(audio_capture_task_runner), | 111 : audio_capture_task_runner_(audio_capture_task_runner), |
| 112 caller_task_runner_(caller_task_runner), | 112 caller_task_runner_(caller_task_runner), |
| 113 io_task_runner_(io_task_runner), | 113 io_task_runner_(io_task_runner), |
| 114 video_capture_task_runner_(video_capture_task_runner), | 114 video_capture_task_runner_(video_capture_task_runner), |
| 115 client_session_control_(client_session_control), | 115 client_session_control_(client_session_control), |
| 116 desktop_session_connector_(desktop_session_connector), | 116 desktop_session_connector_(desktop_session_connector), |
| 117 pending_capture_frame_requests_(0), | 117 pending_capture_frame_requests_(0), |
| 118 is_desktop_session_connected_(false), | 118 is_desktop_session_connected_(false), |
| 119 virtual_terminal_(virtual_terminal) { | 119 virtual_terminal_(virtual_terminal), |
| 120 supports_touch_events_(supports_touch_events) { |
| 120 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 121 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 121 } | 122 } |
| 122 | 123 |
| 123 scoped_ptr<AudioCapturer> DesktopSessionProxy::CreateAudioCapturer() { | 124 scoped_ptr<AudioCapturer> DesktopSessionProxy::CreateAudioCapturer() { |
| 124 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 125 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 125 | 126 |
| 126 return make_scoped_ptr(new IpcAudioCapturer(this)); | 127 return make_scoped_ptr(new IpcAudioCapturer(this)); |
| 127 } | 128 } |
| 128 | 129 |
| 129 scoped_ptr<InputInjector> DesktopSessionProxy::CreateInputInjector() { | 130 scoped_ptr<InputInjector> DesktopSessionProxy::CreateInputInjector() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 | 144 |
| 144 return make_scoped_ptr(new IpcVideoFrameCapturer(this)); | 145 return make_scoped_ptr(new IpcVideoFrameCapturer(this)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 scoped_ptr<webrtc::MouseCursorMonitor> | 148 scoped_ptr<webrtc::MouseCursorMonitor> |
| 148 DesktopSessionProxy::CreateMouseCursorMonitor() { | 149 DesktopSessionProxy::CreateMouseCursorMonitor() { |
| 149 return make_scoped_ptr(new IpcMouseCursorMonitor(this)); | 150 return make_scoped_ptr(new IpcMouseCursorMonitor(this)); |
| 150 } | 151 } |
| 151 | 152 |
| 152 std::string DesktopSessionProxy::GetCapabilities() const { | 153 std::string DesktopSessionProxy::GetCapabilities() const { |
| 153 std::string result = kRateLimitResizeRequests; | 154 std::string result = protocol::kRateLimitResizeRequests; |
| 154 // Ask the client to send its resolution unconditionally. | 155 // Ask the client to send its resolution unconditionally. |
| 155 if (virtual_terminal_) | 156 if (virtual_terminal_) |
| 156 result = result + " " + kSendInitialResolution; | 157 result = result + " " + protocol::kSendInitialResolution; |
| 158 |
| 159 if (supports_touch_events_) |
| 160 result = result + " " + protocol::kTouchEventsCapability; |
| 161 |
| 157 return result; | 162 return result; |
| 158 } | 163 } |
| 159 | 164 |
| 160 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { | 165 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { |
| 161 // Delay creation of the desktop session until the client screen resolution is | 166 // Delay creation of the desktop session until the client screen resolution is |
| 162 // received if the desktop session requires the initial screen resolution | 167 // received if the desktop session requires the initial screen resolution |
| 163 // (when |virtual_terminal_| is true) and the client is expected to | 168 // (when |virtual_terminal_| is true) and the client is expected to |
| 164 // sent its screen resolution (the 'sendInitialResolution' capability is | 169 // sent its screen resolution (the 'sendInitialResolution' capability is |
| 165 // supported). | 170 // supported). |
| 166 if (virtual_terminal_ && | 171 if (virtual_terminal_ && |
| 167 HasCapability(capabilities, kSendInitialResolution)) { | 172 HasCapability(capabilities, protocol::kSendInitialResolution)) { |
| 168 VLOG(1) << "Waiting for the client screen resolution."; | 173 VLOG(1) << "Waiting for the client screen resolution."; |
| 169 return; | 174 return; |
| 170 } | 175 } |
| 171 | 176 |
| 172 // Connect to the desktop session. | 177 // Connect to the desktop session. |
| 173 if (!is_desktop_session_connected_) { | 178 if (!is_desktop_session_connected_) { |
| 174 is_desktop_session_connected_ = true; | 179 is_desktop_session_connected_ = true; |
| 175 if (desktop_session_connector_.get()) { | 180 if (desktop_session_connector_.get()) { |
| 176 desktop_session_connector_->ConnectTerminal( | 181 desktop_session_connector_->ConnectTerminal( |
| 177 this, screen_resolution_, virtual_terminal_); | 182 this, screen_resolution_, virtual_terminal_); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 576 } |
| 572 | 577 |
| 573 // static | 578 // static |
| 574 void DesktopSessionProxyTraits::Destruct( | 579 void DesktopSessionProxyTraits::Destruct( |
| 575 const DesktopSessionProxy* desktop_session_proxy) { | 580 const DesktopSessionProxy* desktop_session_proxy) { |
| 576 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 581 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
| 577 desktop_session_proxy); | 582 desktop_session_proxy); |
| 578 } | 583 } |
| 579 | 584 |
| 580 } // namespace remoting | 585 } // namespace remoting |
| OLD | NEW |